From d2d4b0acbea711d2717dc1e044b847416ff36233 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Tue, 25 Jul 2023 09:24:04 +0200 Subject: [PATCH] Segmenter: added noendlist url param to omit the ENDLIST tag --- lib/config.cpp | 6 ++++++ src/output/output.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/config.cpp b/lib/config.cpp index ee3e7190..f23aca67 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -781,6 +781,12 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){ pp["maxwaittrackms"]["unit"] = "ms"; pp["maxwaittrackms"]["sort"] = "be"; + pp["noendlist"]["name"] = "Don't end playlist"; + pp["noendlist"]["help"] = "If set, does not write #X-EXT-ENDLIST when finalizing the playlist on exit"; + pp["noendlist"]["type"] = "bool"; + pp["noendlist"]["format"] = "set_or_unset"; + pp["noendlist"]["sort"] = "bfa"; + pp["append"]["name"] = "Append to file"; pp["append"]["help"] = "If set to any value, will (if possible) append to an existing file, rather than overwriting it"; pp["append"]["type"] = "bool"; diff --git a/src/output/output.cpp b/src/output/output.cpp index eaac40ce..d6e406d9 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -1446,6 +1446,7 @@ namespace Mist{ bool autoAdjustSplit = false; Socket::Connection plsConn; uint64_t systemBoot; + bool addEndlist = true; std::string origTarget; const char* origTargetPtr = getenv("MST_ORIG_TARGET"); @@ -1488,6 +1489,9 @@ namespace Mist{ if (targetParams.count("adjustSplit")){ autoAdjustSplit = true; } + if (targetParams.count("noendlist")){ + addEndlist = false; + } // When segmenting to a playlist, handle any existing files and init some data if (targetParams.count("m3u8")){ // Load system boot time from the global config @@ -1897,8 +1901,8 @@ namespace Mist{ tmp << "#EXTINF:" << std::fixed << std::setprecision(3) << (lastPacketTime - currentStartTime) / 1000.0 << ",\n"+ segment + "\n"; playlistBuffer += tmp.str(); } - - if (!M.getLive() || (!maxEntries && !targetAge)){playlistBuffer += "#EXT-X-ENDLIST\n";} + // Omit the ENDLIST tag for sliding window live playlists (or when explicitly requested to omit it) + if ((!M.getLive() || (!maxEntries && !targetAge)) && addEndlist){playlistBuffer += "#EXT-X-ENDLIST\n";} // Remove older entries in the playlist if (maxEntries || targetAge){ uint64_t unixMs = M.getBootMsOffset() + systemBoot + currentStartTime;