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){
|
if (paySize - offset - pesOffset < realPayloadSize){
|
||||||
INFO_MSG("Not enough data left on track %lu.", tid);
|
WARN_MSG("Packet loss detected, glitches will occur");
|
||||||
break;
|
realPayloadSize = paySize - offset - pesOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * pesPayload = payload + offset + pesOffset;
|
char * pesPayload = payload + offset + pesOffset;
|
||||||
|
|
|
@ -382,18 +382,29 @@ namespace Mist {
|
||||||
ctr++;
|
ctr++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
std::string leftData;
|
||||||
while (udpCon.Receive()) {
|
while (udpCon.Receive()) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
//Try to read full TS Packets
|
//Try to read full TS Packets
|
||||||
//Assumption here is made that one UDP Datagram consists of complete TS Packets.
|
//Watch out! We push here to a global, in order for threads to be able to access it.
|
||||||
//Assumption made because of possible packet loss issues
|
while (offset < udpCon.data_len) {
|
||||||
while ((udpCon.data_len - offset) >= 188) {
|
if (udpCon.data[0] == 0x47){//check for sync byte
|
||||||
//Watch out! We push here to a global, in order for threads to be able to access it.
|
if (offset + 188 <= udpCon.data_len){
|
||||||
liveStream.add(udpCon.data + offset);
|
liveStream.add(udpCon.data + offset);
|
||||||
offset += 188;
|
}else{
|
||||||
}
|
leftData.append(udpCon.data + offset, udpCon.data_len - offset);
|
||||||
if (offset < udpCon.data_len) {
|
}
|
||||||
WARN_MSG("%d bytes left in datagram", 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