Socket library and Config library restructuring, improvement to UDP socket reliability

This commit is contained in:
Thulinma 2020-06-25 23:34:26 +02:00
parent 97752f2c2d
commit 3d26741148
37 changed files with 151 additions and 110 deletions

View file

@ -306,7 +306,7 @@ namespace Mist{
int Input::boot(int argc, char *argv[]){
if (!(config->parseArgs(argc, argv))){return 1;}
streamName = config->getString("streamname");
Util::Config::streamName = streamName;
Util::streamName = streamName;
if (config->getBool("json")){
capa["version"] = PACKAGE_VERSION;

View file

@ -373,8 +373,8 @@ namespace Mist{
// // wrong sending port, ignore packet
// continue;
//}
tcpCon.addDown(s.data_len);
RTP::Packet pack(s.data, s.data_len);
tcpCon.addDown(s.data.size());
RTP::Packet pack(s.data, s.data.size());
if (!it->second.theirSSRC){it->second.theirSSRC = pack.getSSRC();}
it->second.sorter.addPacket(pack);
}

View file

@ -512,7 +512,7 @@ namespace Mist{
std::string leftData;
bool received = false;
while (udpCon.Receive()){
downCounter += udpCon.data_len;
downCounter += udpCon.data.size();
received = true;
if (!gettingData){
gettingData = true;
@ -521,20 +521,20 @@ namespace Mist{
size_t offset = 0;
// Try to read full TS Packets
// Watch out! We push here to a global, in order for threads to be able to access it.
while (offset < udpCon.data_len){
while (offset < udpCon.data.size()){
if (udpCon.data[offset] == 0x47){// check for sync byte
if (offset + 188 <= udpCon.data_len){
if (offset + 188 <= udpCon.data.size()){
tsBuf.FromPointer(udpCon.data + offset);
liveStream.add(tsBuf);
if (!liveStream.isDataTrack(tsBuf.getPID())){liveStream.parse(tsBuf.getPID());}
leftData.clear();
}else{
leftData.append(udpCon.data + offset, udpCon.data_len - offset);
leftData.append(udpCon.data + offset, udpCon.data.size() - offset);
}
offset += 188;
}else{
uint32_t maxBytes =
std::min((uint32_t)(188 - leftData.size()), (uint32_t)(udpCon.data_len - offset));
std::min((uint32_t)(188 - leftData.size()), (uint32_t)(udpCon.data.size() - offset));
uint32_t numBytes = maxBytes;
VERYHIGH_MSG("%" PRIu32 " bytes of non-sync-byte data received", numBytes);
if (leftData.size()){