From dc0cd0d451cecf2d493b12ebd5172f8642859f64 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 20 Oct 2020 20:46:29 +0200 Subject: [PATCH] Fixed general output shutdown behaviour and logging on end of stream, MP4 output now correctly ends HTTP response on stream end. Bugfix in HTTP::Parser when calling Chunkify before initializing --- lib/http_parser.cpp | 1 + src/output/output.cpp | 7 +++++-- src/output/output_mp4.cpp | 11 ++++++----- src/output/output_mp4.h | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/http_parser.cpp b/lib/http_parser.cpp index d8c7a259..b4bdad23 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -37,6 +37,7 @@ void HTTP::Parser::CleanPreserveHeaders(){ seenReq = false; possiblyComplete = false; getChunks = false; + sendingChunks = false; doingChunk = 0; bufferChunks = false; method = "GET"; diff --git a/src/output/output.cpp b/src/output/output.cpp index 8d98557e..9ee0305b 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -1307,7 +1307,7 @@ namespace Mist{ } sendNext(); }else{ - Util::logExitReason("end of stream"); + parseData = false; /*LTS-START*/ if (Triggers::shouldTrigger("CONN_STOP", streamName)){ std::string payload = @@ -1315,7 +1315,10 @@ namespace Mist{ Triggers::doTrigger("CONN_STOP", payload, streamName); } /*LTS-END*/ - if (!onFinish()){break;} + if (!onFinish()){ + Util::logExitReason("end of stream"); + break; + } } } if (!meta){ diff --git a/src/output/output_mp4.cpp b/src/output/output_mp4.cpp index ea576232..1c7f5d6c 100644 --- a/src/output/output_mp4.cpp +++ b/src/output/output_mp4.cpp @@ -942,6 +942,12 @@ namespace Mist{ H.Chunkify(mdatHeader, 8, myConn); } + bool OutMP4::onFinish(){ + H.Chunkify(0, 0, myConn); + wantRequest = true; + return true; + } + void OutMP4::onHTTP(){ std::string dl; if (H.GetVar("dl").size()){ @@ -1226,11 +1232,6 @@ namespace Mist{ } } - if (leftOver < 1){ - // stop playback, wait for new request - stop(); - wantRequest = true; - } } void OutMP4::sendHeader(){ diff --git a/src/output/output_mp4.h b/src/output/output_mp4.h index f09bd263..fde593b1 100644 --- a/src/output/output_mp4.h +++ b/src/output/output_mp4.h @@ -99,6 +99,7 @@ namespace Mist{ void onHTTP(); void sendNext(); void sendHeader(); + virtual bool onFinish(); protected: uint64_t fileSize;