RTSP input fixes

This commit is contained in:
Thulinma 2020-09-24 20:11:44 +02:00
parent 8ba7baea98
commit 431fecb67b
2 changed files with 21 additions and 8 deletions

View file

@ -102,7 +102,7 @@ namespace Mist{
}
}
sndH.SendRequest(tcpCon, "", true);
parsePacket();
parsePacket(true);
if (reAuth && needAuth && authRequest.size() && (username.size() || password.size()) && tcpCon){
INFO_MSG("Authenticating %s...", cmd.c_str());
@ -150,19 +150,32 @@ namespace Mist{
return;
}
if (sdpState.tracks.size()){
bool atLeastOne = false;
for (std::map<uint32_t, SDP::Track>::iterator it = sdpState.tracks.begin();
it != sdpState.tracks.end(); ++it){
transportSet = false;
extraHeaders.clear();
extraHeaders["Transport"] = it->second.generateTransport(it->first, url.host, TCPmode);
sendCommand("SETUP", HTTP::URL(url.getUrl()+"/").link(it->second.control).getUrl(), "", &extraHeaders);
if (!tcpCon || !transportSet){
if (tcpCon && transportSet){
atLeastOne = true;
continue;
}
if (!atLeastOne && tcpCon){
INFO_MSG("Failed to set up transport for track %s, switching transports...", myMeta.tracks[it->first].getIdentifier().c_str());
TCPmode = !TCPmode;
extraHeaders["Transport"] = it->second.generateTransport(it->first, url.host, TCPmode);
sendCommand("SETUP", HTTP::URL(url.getUrl()+"/").link(it->second.control).getUrl(), "", &extraHeaders);
}
if (tcpCon && transportSet){
atLeastOne = true;
continue;
}
FAIL_MSG("Could not setup track %s!", myMeta.tracks[it->first].getIdentifier().c_str());
tcpCon.close();
return;
}
}
}
INFO_MSG("Setup complete");
extraHeaders.clear();
extraHeaders["Range"] = "npt=0.000-";
@ -224,7 +237,7 @@ namespace Mist{
return "Unknown";
}
bool InputRTSP::parsePacket(){
bool InputRTSP::parsePacket(bool mustHave){
uint32_t waitTime = 500;
if (!TCPmode){waitTime = 50;}
do{
@ -233,7 +246,7 @@ namespace Mist{
if (!tcpCon.spool() && tcpCon && config->is_active && nProxy.userClient.isAlive()){
nProxy.userClient.keepAlive();
Util::sleep(waitTime);
if (!TCPmode){return true;}
if (!mustHave){return tcpCon;}
}
continue;
}

View file

@ -29,7 +29,7 @@ namespace Mist{
void seek(int seekTime){}
void sendCommand(const std::string &cmd, const std::string &cUrl, const std::string &body,
const std::map<std::string, std::string> *extraHeaders = 0, bool reAuth=true);
bool parsePacket();
bool parsePacket(bool mustHave = false);
bool handleUDP();
std::string streamMainLoop();
Socket::Connection tcpCon;