mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
mpeg-ts解析丢弃不完整的包 (#1478)
* 丢弃不正确的包 因为网络抖动或者拉流超时导致ts包不全. 这里丢弃掉有问题的包, 避免客户端解码中断 * Update TSDecoder.cpp * 格式化代码 Co-authored-by: 夏楚 <771730766@qq.com>
This commit is contained in:
parent
276f763c08
commit
4be3c349be
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user