Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

避免跳过一个正常的ts包 #2423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Rtp/TSDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ const char *TSSegment::onSearchPacketTail(const char *data, size_t len) {
}
return nullptr;
}
//下一个包头
//精确匹配下一个包头
if (((uint8_t *) data)[_size] == TS_SYNC_BYTE) {
return data + _size;
}
auto pos = memchr(data + _size, TS_SYNC_BYTE, len - _size);
if (pos) {
return (char *) pos;
//搜索下一个包头
for (int i = 1; i < len - _size; ++i) {
if (((uint8_t *) data)[i] == TS_SYNC_BYTE && ((uint8_t *) data)[i + _size] == TS_SYNC_BYTE) {
return data + i;
}
}
if (remainDataSize() > 4 * _size) {
//数据这么多都没ts包,全部清空
Expand Down