正在显示
3 个修改的文件
包含
18 行增加
和
7 行删除
@@ -166,6 +166,18 @@ SrsCommonMessage::~SrsCommonMessage() | @@ -166,6 +166,18 @@ SrsCommonMessage::~SrsCommonMessage() | ||
166 | srs_freep(payload); | 166 | srs_freep(payload); |
167 | } | 167 | } |
168 | 168 | ||
169 | +void SrsCommonMessage::create_payload(int size) | ||
170 | +{ | ||
171 | + srs_freep(payload); | ||
172 | + | ||
173 | + payload = new char[size]; | ||
174 | + srs_verbose("create payload for RTMP message. size=%d", size); | ||
175 | + | ||
176 | +#ifdef SRS_MEM_WATCH | ||
177 | + srs_memory_watch(payload, "RTMP.msg.payload", size); | ||
178 | +#endif | ||
179 | +} | ||
180 | + | ||
169 | SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() | 181 | SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() |
170 | { | 182 | { |
171 | payload = NULL; | 183 | payload = NULL; |
@@ -283,8 +283,12 @@ public: | @@ -283,8 +283,12 @@ public: | ||
283 | char* payload; | 283 | char* payload; |
284 | public: | 284 | public: |
285 | SrsCommonMessage(); | 285 | SrsCommonMessage(); |
286 | -public: | ||
287 | virtual ~SrsCommonMessage(); | 286 | virtual ~SrsCommonMessage(); |
287 | +public: | ||
288 | + /** | ||
289 | + * alloc the payload to specified size of bytes. | ||
290 | + */ | ||
291 | + virtual void create_payload(int size); | ||
288 | }; | 292 | }; |
289 | 293 | ||
290 | /** | 294 | /** |
@@ -30,7 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,7 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
30 | #include <srs_kernel_utility.hpp> | 30 | #include <srs_kernel_utility.hpp> |
31 | #include <srs_protocol_buffer.hpp> | 31 | #include <srs_protocol_buffer.hpp> |
32 | #include <srs_rtmp_utility.hpp> | 32 | #include <srs_rtmp_utility.hpp> |
33 | -#include <srs_core_mem_watch.hpp> | ||
34 | 33 | ||
35 | // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213 | 34 | // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213 |
36 | #ifndef _WIN32 | 35 | #ifndef _WIN32 |
@@ -1411,11 +1410,7 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, SrsCommonMessage** | @@ -1411,11 +1410,7 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, SrsCommonMessage** | ||
1411 | 1410 | ||
1412 | // create msg payload if not initialized | 1411 | // create msg payload if not initialized |
1413 | if (!chunk->msg->payload) { | 1412 | if (!chunk->msg->payload) { |
1414 | - chunk->msg->payload = new char[chunk->header.payload_length]; | ||
1415 | - srs_verbose("create payload for RTMP message. size=%d", chunk->header.payload_length); | ||
1416 | -#ifdef SRS_MEM_WATCH | ||
1417 | - srs_memory_watch(chunk->msg->payload, "msg.payload", chunk->header.payload_length); | ||
1418 | -#endif | 1413 | + chunk->msg->create_payload(chunk->header.payload_length); |
1419 | } | 1414 | } |
1420 | 1415 | ||
1421 | // read payload to buffer | 1416 | // read payload to buffer |
-
请 注册 或 登录 后发表评论