Performance: 使用循环池优化rtmp分发性能

This commit is contained in:
xiongziliang 2021-11-21 11:34:20 +08:00
parent 5404a5266a
commit 97f7255f0a
2 changed files with 4 additions and 1 deletions

View File

@ -55,6 +55,7 @@ static string openssl_HMACsha256(const void *key, size_t key_len, const void *da
namespace mediakit {
RtmpProtocol::RtmpProtocol() {
_packet_pool.setSize(64);
_next_step_func = [this](const char *data, size_t len) {
return handle_C0C1(data, len);
};
@ -776,7 +777,7 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
}
BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) {
auto buffer = BufferRaw::create();
auto buffer = _packet_pool.obtain();
if (data && len) {
buffer->assign((const char *) data, len);
}

View File

@ -107,6 +107,8 @@ private:
function<const char * (const char *data, size_t len)> _next_step_func;
////////////Chunk////////////
unordered_map<int, std::pair<RtmpPacket::Ptr/*now*/, RtmpPacket::Ptr/*last*/> > _map_chunk_data;
//循环池
ResourcePool<BufferRaw> _packet_pool;
};
} /* namespace mediakit */