mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
HLS: ts分包器主动丢弃非法数据
This commit is contained in:
parent
c25ff6400f
commit
5832de7ed8
@ -15,8 +15,8 @@ bool TSSegment::isTSPacket(const char *data, size_t len){
|
|||||||
return len == TS_PACKET_SIZE && ((uint8_t*)data)[0] == TS_SYNC_BYTE;
|
return len == TS_PACKET_SIZE && ((uint8_t*)data)[0] == TS_SYNC_BYTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSSegment::setOnSegment(const TSSegment::onSegment &cb) {
|
void TSSegment::setOnSegment(TSSegment::onSegment cb) {
|
||||||
_onSegment = cb;
|
_onSegment = std::move(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t TSSegment::onRecvHeader(const char *data, size_t len) {
|
ssize_t TSSegment::onRecvHeader(const char *data, size_t len) {
|
||||||
@ -43,6 +43,11 @@ const char *TSSegment::onSearchPacketTail(const char *data, size_t len) {
|
|||||||
if (pos) {
|
if (pos) {
|
||||||
return (char *) pos;
|
return (char *) pos;
|
||||||
}
|
}
|
||||||
|
if (remainDataSize() > 4 * _size) {
|
||||||
|
//数据这么多都没ts包,全部清空
|
||||||
|
return data + len;
|
||||||
|
}
|
||||||
|
//等待更多数据
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
typedef std::function<void(const char *data,size_t len)> onSegment;
|
typedef std::function<void(const char *data,size_t len)> onSegment;
|
||||||
TSSegment(size_t size = TS_PACKET_SIZE) : _size(size){}
|
TSSegment(size_t size = TS_PACKET_SIZE) : _size(size){}
|
||||||
~TSSegment(){}
|
~TSSegment(){}
|
||||||
void setOnSegment(const onSegment &cb);
|
void setOnSegment(onSegment cb);
|
||||||
static bool isTSPacket(const char *data, size_t len);
|
static bool isTSPacket(const char *data, size_t len);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user