diff --git a/src/output/output.cpp b/src/output/output.cpp index 1d4d82f5..53105e58 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -503,7 +503,7 @@ namespace Mist{ continue; } //autoSeeking and target not in bounds? Drop it too. - if (autoSeek && myMeta.tracks[*it].lastms < seekTarget - 6000){ + if (autoSeek && myMeta.tracks[*it].lastms < std::max(seekTarget, 6000lu) - 6000){ toRemove.insert(*it); } } @@ -584,7 +584,7 @@ namespace Mist{ if (myMeta.live){ for (std::map::reverse_iterator trit = myMeta.tracks.rbegin(); trit != myMeta.tracks.rend(); trit++){ if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){ - if (autoSeek && trit->second.lastms < seekTarget - 6000){continue;} + if (autoSeek && trit->second.lastms < std::max(seekTarget, 6000lu) - 6000){continue;} /*LTS-START*/ if (noSelAudio && trit->second.type == "audio"){continue;} if (noSelVideo && trit->second.type == "video"){continue;} @@ -598,7 +598,7 @@ namespace Mist{ }else{ for (std::map::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){ if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){ - if (autoSeek && trit->second.lastms < seekTarget - 6000){continue;} + if (autoSeek && trit->second.lastms < std::max(seekTarget, 6000lu) - 6000){continue;} /*LTS-START*/ if (noSelAudio && trit->second.type == "audio"){continue;} if (noSelVideo && trit->second.type == "video"){continue;} @@ -645,6 +645,7 @@ namespace Mist{ void Output::stop(){ buffer.clear(); parseData = false; + sought = false; } unsigned int Output::getKeyForTime(long unsigned int trackId, long long timeStamp){ diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index 6a1618bd..a3ad5190 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -268,6 +268,7 @@ namespace Mist { //Handle upgrade to websocket if the output supports it if (doesWebsockets() && H.GetHeader("Upgrade") == "websocket"){ INFO_MSG("Switching to Websocket mode"); + setBlocking(false); preWebsocketConnect(); webSock = new HTTP::Websocket(myConn, H); if (!(*webSock)){ diff --git a/src/output/output_json.cpp b/src/output/output_json.cpp index 2a8d800f..12345fca 100644 --- a/src/output/output_json.cpp +++ b/src/output/output_json.cpp @@ -94,24 +94,30 @@ namespace Mist { static bool recursive = false; if (recursive){return true;} recursive = true; - if (keepReselecting && !isPushing()){ + if (keepReselecting && !isPushing() && !myMeta.vod){ uint64_t maxTimer = 7200; - while (--maxTimer && nProxy.userClient.isAlive() && keepGoing()){ + while (--maxTimer && keepGoing()){ + if (!isBlocking){myConn.spool();} Util::wait(500); stats(); if (Util::getStreamStatus(streamName) != STRMSTAT_READY){ - disconnect(); + if (isInitialized){ + INFO_MSG("Disconnecting from offline stream"); + disconnect(); + stop(); + } }else{ - updateMeta(); if (isReadyForPlay()){ + INFO_MSG("Resuming playback!"); recursive = false; + parseData = true; return true; } } } recursive = false; } - if (!jsonp.size() && !first){ + if (!webSock && !jsonp.size() && !first){ myConn.SendNow("]\n", 2); } myConn.close();