From 97f7255f0a79da9a6c48d3d4f177f6a301c8a043 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 21 Nov 2021 11:34:20 +0800 Subject: [PATCH] =?UTF-8?q?Performance:=20=E4=BD=BF=E7=94=A8=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=B1=A0=E4=BC=98=E5=8C=96rtmp=E5=88=86=E5=8F=91?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpProtocol.cpp | 3 ++- src/Rtmp/RtmpProtocol.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Rtmp/RtmpProtocol.cpp b/src/Rtmp/RtmpProtocol.cpp index d0c5f027..4f9a8af7 100644 --- a/src/Rtmp/RtmpProtocol.cpp +++ b/src/Rtmp/RtmpProtocol.cpp @@ -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); } diff --git a/src/Rtmp/RtmpProtocol.h b/src/Rtmp/RtmpProtocol.h index 5a004874..fa51b191 100644 --- a/src/Rtmp/RtmpProtocol.h +++ b/src/Rtmp/RtmpProtocol.h @@ -107,6 +107,8 @@ private: function _next_step_func; ////////////Chunk//////////// unordered_map > _map_chunk_data; + //循环池 + ResourcePool _packet_pool; }; } /* namespace mediakit */