TS input can now cope a bit better with packet loss, incomplete UDP packets now buffered
This commit is contained in:
parent
4bcfb5191a
commit
523c00f462
2 changed files with 22 additions and 11 deletions
|
@ -442,8 +442,8 @@ namespace TS {
|
|||
}
|
||||
|
||||
if (paySize - offset - pesOffset < realPayloadSize){
|
||||
INFO_MSG("Not enough data left on track %lu.", tid);
|
||||
break;
|
||||
WARN_MSG("Packet loss detected, glitches will occur");
|
||||
realPayloadSize = paySize - offset - pesOffset;
|
||||
}
|
||||
|
||||
char * pesPayload = payload + offset + pesOffset;
|
||||
|
|
|
@ -382,18 +382,29 @@ namespace Mist {
|
|||
ctr++;
|
||||
}
|
||||
} else {
|
||||
std::string leftData;
|
||||
while (udpCon.Receive()) {
|
||||
int offset = 0;
|
||||
//Try to read full TS Packets
|
||||
//Assumption here is made that one UDP Datagram consists of complete TS Packets.
|
||||
//Assumption made because of possible packet loss issues
|
||||
while ((udpCon.data_len - offset) >= 188) {
|
||||
//Watch out! We push here to a global, in order for threads to be able to access it.
|
||||
liveStream.add(udpCon.data + offset);
|
||||
offset += 188;
|
||||
}
|
||||
if (offset < udpCon.data_len) {
|
||||
WARN_MSG("%d bytes left in datagram", udpCon.data_len - offset);
|
||||
//Watch out! We push here to a global, in order for threads to be able to access it.
|
||||
while (offset < udpCon.data_len) {
|
||||
if (udpCon.data[0] == 0x47){//check for sync byte
|
||||
if (offset + 188 <= udpCon.data_len){
|
||||
liveStream.add(udpCon.data + offset);
|
||||
}else{
|
||||
leftData.append(udpCon.data + offset, udpCon.data_len - offset);
|
||||
}
|
||||
offset += 188;
|
||||
}else{
|
||||
if (leftData.size()){
|
||||
leftData.append(udpCon.data + offset, 1);
|
||||
if (leftData.size() >= 188){
|
||||
liveStream.add((char*)leftData.data());
|
||||
leftData.erase(0, 188);
|
||||
}
|
||||
}
|
||||
++offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue