Added maxKeepAway option for live streams, renamed minkeepaway/keepaway to "jitter" externally, added global jitter and bframe checks in all JSON-like metadata outputs

This commit is contained in:
Thulinma 2020-08-24 23:16:53 +02:00
parent 7b523d53c7
commit 49ee109b50
7 changed files with 90 additions and 23 deletions

View file

@ -84,6 +84,20 @@ namespace Mist{
capa["optional"]["resume"]["default"] = 0;
option.null();
option["arg"] = "integer";
option["long"] = "maxkeepaway";
option["short"] = "M";
option["help"] = "Maximum distance in milliseconds to fall behind the live point for stable playback.";
option["value"].append(45000);
config->addOption("maxkeepaway", option);
capa["optional"]["maxkeepaway"]["name"] = "Maximum live keep-away distance";
capa["optional"]["maxkeepaway"]["help"] = "Maximum distance in milliseconds to fall behind the live point for stable playback.";
capa["optional"]["maxkeepaway"]["option"] = "--resume";
capa["optional"]["maxkeepaway"]["type"] = "uint";
capa["optional"]["maxkeepaway"]["default"] = 45000;
maxKeepAway = 45000;
option.null();
option["arg"] = "integer";
option["long"] = "segment-size";
option["short"] = "S";
@ -163,9 +177,13 @@ namespace Mist{
bool hasAAC = false;
std::stringstream issues;
std::set<size_t> validTracks = M.getValidTracks();
uint64_t jitter = 0;
for (std::set<size_t>::iterator it = validTracks.begin(); it != validTracks.end(); it++){
size_t i = *it;
JSON::Value &track = details[M.getTrackIdentifier(i)];
uint64_t minKeep = M.getMinKeepAway(*it);
track["jitter"] = minKeep;
if (jitter < minKeep){jitter = minKeep;}
std::string codec = M.getCodec(i);
std::string type = M.getType(i);
track["kbits"] = M.getBps(i) * 8 / 1024;
@ -218,6 +236,13 @@ namespace Mist{
track["channels"] = M.getChannels(i);
}
}
if (jitter > 500){
issues << "High jitter (" << jitter << "ms)! ";
}
details["jitter"] = jitter;
if (M.getMaxKeepAway()){
details["maxkeepaway"] = M.getMaxKeepAway();
}
if ((hasAAC || hasH264) && validTracks.size() > 1){
if (!hasAAC){issues << "HLS no audio!";}
if (!hasH264){issues << "HLS no video!";}
@ -600,6 +625,13 @@ namespace Mist{
meta.setMinimumFragmentDuration(segmentSize);
}
//Check if segmentsize setting is correct
tmpNum = retrieveSetting(streamCfg, "maxkeepaway");
if (M.getMaxKeepAway() != tmpNum){
INFO_MSG("Setting maxKeepAway from %" PRIu64 " to new value of %" PRIu64, M.getMaxKeepAway(), tmpNum);
meta.setMaxKeepAway(tmpNum);
}
/*LTS-END*/
return true;
}

View file

@ -20,6 +20,7 @@ namespace Mist{
bool hasPush;//Is a push currently being received?
bool everHadPush;//Was there ever a push received?
bool resumeMode;
uint64_t maxKeepAway;
IPC::semaphore *liveMeta;
protected:

View file

@ -207,21 +207,24 @@ namespace Mist{
}
}
JSON::Value option;
option["arg"] = "integer";
option["long"] = "buffer";
option["short"] = "b";
option["help"] = "DVR buffer time in ms";
option["value"].append(50000);
config->addOption("bufferTime", option);
capa["optional"]["DVR"]["name"] = "Buffer time (ms)";
capa["optional"]["DVR"]["help"] =
"The target available buffer time for this live stream, in milliseconds. This is the time "
"available to seek around in, and will automatically be extended to fit whole keyframes as "
"well as the minimum duration needed for stable playback.";
capa["optional"]["DVR"]["option"] = "--buffer";
capa["optional"]["DVR"]["type"] = "uint";
capa["optional"]["DVR"]["default"] = 50000;
capa["optional"]["maxkeepaway"]["name"] = "Maximum live keep-away distance";
capa["optional"]["maxkeepaway"]["help"] = "Maximum distance in milliseconds to fall behind the live point for stable playback.";
capa["optional"]["maxkeepaway"]["type"] = "uint";
capa["optional"]["maxkeepaway"]["default"] = 45000;
capa["optional"]["segmentsize"]["name"] = "Segment size (ms)";
capa["optional"]["segmentsize"]["help"] = "Target time duration in milliseconds for segments.";
capa["optional"]["segmentsize"]["type"] = "uint";
capa["optional"]["segmentsize"]["default"] = 1900;
}
inputTS::~inputTS(){

View file

@ -953,6 +953,13 @@ namespace Mist{
if (ti->first == INVALID_TRACK_ID){continue;}
if (M.getMinKeepAway(ti->first) > r){r = M.getMinKeepAway(ti->first);}
}
//Limit the value to the maxKeepAway setting
//Also lowers extraKeepAway if needed
uint64_t maxKeepAway = M.getMaxKeepAway();
if (maxKeepAway){
if (r > maxKeepAway){r = maxKeepAway;}
if (r+extraKeepAway > maxKeepAway){extraKeepAway = maxKeepAway - r;}
}
return r;
}

View file

@ -485,10 +485,8 @@ namespace Mist{
if (it->isMember("lang")){
(*it)["language"] = Encodings::ISO639::decode((*it)["lang"].asStringRef());
}
if (M.hasBFrames((*it)["idx"].asInt())){(*it)["bframes"] = 1;}
}
json_resp["meta"].removeMember("source");
json_resp["meta"]["bframes"] = (M.hasBFrames() ? 1 : 0);
// Get sources/protocols information
Util::DTSCShmReader rCapa(SHM_CAPA);