Better tsudp:// input handling

This commit is contained in:
Thulinma 2016-09-16 18:25:41 +02:00
parent 856043ed55
commit cd39965701
2 changed files with 8 additions and 20 deletions

View file

@ -116,7 +116,7 @@ namespace Mist {
nProxy.streamName = streamName; nProxy.streamName = streamName;
if (!setup()) { if (!setup()) {
std::cerr << config->getString("cmd") << " setup failed." << std::endl; FAIL_MSG("Setup failed - exiting");
return 0; return 0;
} }

View file

@ -12,6 +12,7 @@
#include <mist/ts_packet.h> #include <mist/ts_packet.h>
#include <mist/timing.h> #include <mist/timing.h>
#include <mist/mp4_generic.h> #include <mist/mp4_generic.h>
#include <mist/http_parser.h>
#include "input_ts.h" #include "input_ts.h"
#include <mist/tinythread.h> #include <mist/tinythread.h>
@ -78,10 +79,10 @@ void parseThread(void * ignored) {
threadTimer[tid] = Util::bootSecs(); threadTimer[tid] = Util::bootSecs();
lock.post(); lock.post();
} }
if (liveStream.isDataTrack(tid)){
myProxy.userClient.keepAlive();
}
if (!liveStream.hasPacket(tid)){ if (!liveStream.hasPacket(tid)){
if (liveStream.isDataTrack(tid)){
myProxy.userClient.keepAlive();
}
Util::sleep(100); Util::sleep(100);
} }
} }
@ -147,24 +148,11 @@ namespace Mist {
} }
//UDP input (tsudp://[host:]port[/iface[,iface[,...]]]) //UDP input (tsudp://[host:]port[/iface[,iface[,...]]])
if (inpt.substr(0, 8) == "tsudp://"){ if (inpt.substr(0, 8) == "tsudp://"){
HTTP::URL input_url(inpt);
standAlone = false; standAlone = false;
udpCon.setBlocking(false); udpCon.setBlocking(false);
uint32_t port; udpCon.bind(input_url.getPort(), input_url.host, input_url.path);
std::string host; return udpCon.getSock() != -1;
std::string ifaces;
size_t colon = inpt.find(':', 8);
if (colon != std::string::npos){
port = atoi(inpt.c_str()+colon+1);//skip to colon
host = inpt.substr(8, colon-8);
}else{
port = atoi(inpt.c_str()+8);//skip udpts://
}
size_t slash = inpt.find('/', 8);
if (slash != std::string::npos){
ifaces = inpt.substr(slash+1);
}
udpCon.bind(port, host, ifaces);
return true;
} }
//plain VoD file //plain VoD file
inFile = fopen(inpt.c_str(), "r"); inFile = fopen(inpt.c_str(), "r");