Fixed handling of stuffing bytes in TS packets.

This commit is contained in:
Thulinma 2013-02-11 12:43:02 +01:00
parent 4f4c1784b8
commit af4caded70

View file

@ -323,19 +323,23 @@ void TS::Packet::AddStuffing(int NumBytes){
return; return;
} }
if (AdaptationField() == 3){ if (AdaptationField() == 3){
int Offset = strBuf[4]; strBuf.resize(5 + strBuf[4]);
strBuf[4] = Offset + NumBytes - 1; strBuf[4] += NumBytes;
strBuf.resize(5 + Offset + NumBytes - 2); for (int i = 0; i < NumBytes; i++){
for (int i = 0; i < (NumBytes - 2); i++){ strBuf.append(FILLER_DATA + (i % sizeof(FILLER_DATA)), 1);
strBuf[5 + Offset + i] = FILLER_DATA[i % sizeof(FILLER_DATA)];
} }
}else{ }else{
AdaptationField(3); AdaptationField(3);
strBuf.resize(6); if (NumBytes > 1){
strBuf[4] = (char)(NumBytes - 1); strBuf.resize(6);
strBuf[5] = (char)0x00; strBuf[4] = (char)(NumBytes - 1);
for (int i = 0; i < (NumBytes - 2); i++){ strBuf[5] = (char)0x00;
strBuf += FILLER_DATA[i % sizeof(FILLER_DATA)]; for (int i = 0; i < (NumBytes - 2); i++){
strBuf += FILLER_DATA[i % sizeof(FILLER_DATA)];
}
}else{
strBuf.resize(5);
strBuf[4] = (char)(NumBytes - 1);
} }
} }
} }