Fixed TS stream parser not parsing last PES packet sometimes

This commit is contained in:
Thulinma 2021-02-16 13:45:22 +01:00
parent 0c8261bf2f
commit 6f6827607d

View file

@ -366,7 +366,7 @@ namespace TS{
psCache = &(pesStreams[tid]);
psCacheTid = tid;
}
if (psCache->size() <= 1){
if (!psCache->size() || (!finished && psCache->size() <= 1)){
if (!finished){FAIL_MSG("No PES packets to parse");}
seenUnitStart[tid] = 0;
return;
@ -535,6 +535,12 @@ namespace TS{
// headers/padding
offset += realPayloadSize + (9 + pesHeader[8]);
}
if (finished && (pidToCodec[tid] == H264 || pidToCodec[tid] == H265)){
if (buildPacket.count(tid) && buildPacket[tid].getDataStringLen()){
outPackets[tid].push_back(buildPacket[tid]);
buildPacket.erase(tid);
}
}
free(payload);
}