Segmenter: added noendlist url param to omit the ENDLIST tag

This commit is contained in:
Marco van Dijk 2023-07-25 09:24:04 +02:00 committed by Thulinma
parent 0ad88e80b3
commit d2d4b0acbe
2 changed files with 12 additions and 2 deletions

View file

@ -781,6 +781,12 @@ void Util::Config::addStandardPushCapabilities(JSON::Value &cap){
pp["maxwaittrackms"]["unit"] = "ms"; pp["maxwaittrackms"]["unit"] = "ms";
pp["maxwaittrackms"]["sort"] = "be"; 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"]["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"]["help"] = "If set to any value, will (if possible) append to an existing file, rather than overwriting it";
pp["append"]["type"] = "bool"; pp["append"]["type"] = "bool";

View file

@ -1446,6 +1446,7 @@ namespace Mist{
bool autoAdjustSplit = false; bool autoAdjustSplit = false;
Socket::Connection plsConn; Socket::Connection plsConn;
uint64_t systemBoot; uint64_t systemBoot;
bool addEndlist = true;
std::string origTarget; std::string origTarget;
const char* origTargetPtr = getenv("MST_ORIG_TARGET"); const char* origTargetPtr = getenv("MST_ORIG_TARGET");
@ -1488,6 +1489,9 @@ namespace Mist{
if (targetParams.count("adjustSplit")){ if (targetParams.count("adjustSplit")){
autoAdjustSplit = true; autoAdjustSplit = true;
} }
if (targetParams.count("noendlist")){
addEndlist = false;
}
// When segmenting to a playlist, handle any existing files and init some data // When segmenting to a playlist, handle any existing files and init some data
if (targetParams.count("m3u8")){ if (targetParams.count("m3u8")){
// Load system boot time from the global config // 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"; tmp << "#EXTINF:" << std::fixed << std::setprecision(3) << (lastPacketTime - currentStartTime) / 1000.0 << ",\n"+ segment + "\n";
playlistBuffer += tmp.str(); playlistBuffer += tmp.str();
} }
// Omit the ENDLIST tag for sliding window live playlists (or when explicitly requested to omit it)
if (!M.getLive() || (!maxEntries && !targetAge)){playlistBuffer += "#EXT-X-ENDLIST\n";} if ((!M.getLive() || (!maxEntries && !targetAge)) && addEndlist){playlistBuffer += "#EXT-X-ENDLIST\n";}
// Remove older entries in the playlist // Remove older entries in the playlist
if (maxEntries || targetAge){ if (maxEntries || targetAge){
uint64_t unixMs = M.getBootMsOffset() + systemBoot + currentStartTime; uint64_t unixMs = M.getBootMsOffset() + systemBoot + currentStartTime;