diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index fad50ea2ba..415cf87a82 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -184,6 +184,8 @@ SrsTsMessage* SrsTsMessage::detach() cp->sid = sid; cp->PES_packet_length = PES_packet_length; cp->continuity_counter = continuity_counter; + //use the origin msg's payload, just free ours + srs_freep(cp->payload); cp->payload = payload; payload = NULL; return cp; diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index 3321e29c85..09053d1277 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -902,25 +902,29 @@ int SrsIngestSrsOutput::parse_message_queue() nb_videos--; } queue.erase(it); - // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { srs_error("mpegts: initialize av stream failed. ret=%d", ret); + srs_freep(msg); return ret; } // publish audio or video. if (msg->channel->stream == SrsTsStreamVideoH264) { if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } if (msg->channel->stream == SrsTsStreamAudioAAC) { if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } + //release detached ts msg + srs_freep(msg); } return ret; @@ -936,25 +940,29 @@ int SrsIngestSrsOutput::flush_message_queue() SrsTsMessage* msg = it->second; queue.erase(it); - // parse the stream. SrsStream avs; if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) { srs_error("mpegts: initialize av stream failed. ret=%d", ret); + srs_freep(msg); return ret; } // publish audio or video. if (msg->channel->stream == SrsTsStreamVideoH264) { if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } if (msg->channel->stream == SrsTsStreamAudioAAC) { if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) { + srs_freep(msg); return ret; } } + //release detached ts msg + srs_freep(msg); } return ret;