From 4be3c349bea79fc35c3fadd6ec983bbd18626b23 Mon Sep 17 00:00:00 2001 From: alexliyu7352 Date: Sat, 12 Mar 2022 09:41:15 +0800 Subject: [PATCH] =?UTF-8?q?mpeg-ts=E8=A7=A3=E6=9E=90=E4=B8=A2=E5=BC=83?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84=E5=8C=85=20(#1478)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 丢弃不正确的包 因为网络抖动或者拉流超时导致ts包不全. 这里丢弃掉有问题的包, 避免客户端解码中断 * Update TSDecoder.cpp * 格式化代码 Co-authored-by: 夏楚 <771730766@qq.com> --- src/Rtp/TSDecoder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Rtp/TSDecoder.cpp b/src/Rtp/TSDecoder.cpp index 1c3d9404..0f86c10e 100644 --- a/src/Rtp/TSDecoder.cpp +++ b/src/Rtp/TSDecoder.cpp @@ -55,14 +55,19 @@ const char *TSSegment::onSearchPacketTail(const char *data, size_t len) { #if defined(ENABLE_HLS) #include "mpeg-ts.h" +#include "mpeg-ts-proto.h" TSDecoder::TSDecoder() : _ts_segment() { _ts_segment.setOnSegment([this](const char *data, size_t len){ ts_demuxer_input(_demuxer_ctx,(uint8_t*)data,len); }); _demuxer_ctx = ts_demuxer_create([](void* param, int program, int stream, int codecid, int flags, int64_t pts, int64_t dts, const void* data, size_t bytes){ TSDecoder *thiz = (TSDecoder*)param; - if(thiz->_on_decode){ - thiz->_on_decode(stream,codecid,flags,pts,dts,data,bytes); + if (thiz->_on_decode) { + if (flags & MPEG_FLAG_PACKET_CORRUPT) { + WarnL << "ts packet lost, dts:" << dts << " pts:" << pts << " bytes:" << bytes; + } else { + thiz->_on_decode(stream, codecid, flags, pts, dts, data, bytes); + } } return 0; },this);