diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index 4b3d3812..d0f1ab08 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -200,8 +200,8 @@ namespace Mist{ JSON::Value r; r["type"] = "on_stop"; r["data"]["current"] = currentTime(); - r["data"]["begin"] = Output::startTime(); - r["data"]["end"] = Output::endTime(); + r["data"]["begin"] = startTime(); + r["data"]["end"] = endTime(); webSock->sendFrame(r.toString()); parseData = false; return false; @@ -574,15 +574,9 @@ namespace Mist{ //Play command, sets pause state off and optionally also seeks if (command["type"] == "play") { - bool wasPlaying = parseData; parseData = true; if (command.isMember("seek_time")){ handleWebsocketSeek(command); - }else{ - if (!wasPlaying){ - command["seek_time"] = 0; - handleWebsocketSeek(command); - } } return true; } @@ -591,6 +585,22 @@ namespace Mist{ return false; } + void HTTPOutput::initialSeek(bool dryRun){ + Output::initialSeek(dryRun); + if (!webSock){return;} + + // For websockets, simulate seeking behaviour + if (M.getLive()){ + // live streams fast-forward to the live point + stayLive = true; + forwardTo = endTime(); + realTime = 0; + } + // No matter what, run the idle commands to print current time in the websocket + handleWebsocketIdle(); + onIdle(); + } + void HTTPOutput::handleWebsocketIdle(){ if (!webSock){return;} if (!parseData){return;} @@ -624,9 +634,9 @@ namespace Mist{ r["type"] = "on_time"; r["data"]["current"] = targetTime(); r["data"]["next"] = currentTime(); - r["data"]["begin"] = Output::startTime(); + r["data"]["begin"] = startTime(); - r["data"]["end"] = Output::endTime(); + r["data"]["end"] = endTime(); if (realTime == 0){ r["data"]["play_rate_curr"] = "fast-forward"; }else{ @@ -731,9 +741,9 @@ namespace Mist{ selectDefaultTracks(); } - stayLive = (target_rate == 0.0) && (Output::endTime() < seek_time + 5000); + stayLive = (target_rate == 0.0) && (endTime() < seek_time + 5000); if (command["seek_time"].asStringRef() == "live"){stayLive = true;} - if (stayLive){seek_time = Output::endTime();} + if (stayLive){seek_time = endTime();} if (!seek(seek_time, true)) { r["error"] = "seek failed, continuing as-is"; diff --git a/src/output/output_http.h b/src/output/output_http.h index 76e09f80..387e4100 100644 --- a/src/output/output_http.h +++ b/src/output/output_http.h @@ -19,6 +19,7 @@ namespace Mist{ virtual void preHTTP(); virtual bool onFinish(); virtual void sendNext(); + virtual void initialSeek(bool dryRun = false); static bool listenMode(){return false;} void reConnector(std::string &connector); std::string getHandler();