From 75559a367b8d80488e8524665717242d3d876d80 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 20 Jan 2022 01:52:54 +0100 Subject: [PATCH] Set livepeer-transcoded track to have a source track, exclude tracks with source track from stream health info --- lib/dtsc.cpp | 29 +++++++++++++++++++---------- src/process/process_livepeer.cpp | 3 +++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 4d186c8c..5f92ab49 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -3233,7 +3233,6 @@ namespace DTSC{ JSON::Value &track = retRef[getTrackIdentifier(i)]; uint64_t minKeep = getMinKeepAway(*it); track["jitter"] = minKeep; - if (jitter < minKeep){jitter = minKeep;} std::string codec = getCodec(i); std::string type = getType(i); track["kbits"] = getBps(i) * 8 / 1024; @@ -3266,16 +3265,26 @@ namespace DTSC{ track["keys"]["frames_max"] = longest_cnt; uint64_t trBuffer = getLastms(i) - getFirstms(i); track["buffer"] = trBuffer; + size_t srcTrk = getSourceTrack(i); + if (srcTrk != INVALID_TRACK_ID){ + if (trackValid(srcTrk)){ + track["source"] = getTrackIdentifier(srcTrk); + }else{ + track["source"] = "Invalid track " + JSON::Value(srcTrk).asString(); + } + }else{ + if (jitter < minKeep){jitter = minKeep;} + if (longest_prt > 500){ + issues << "unstable connection (" << longest_prt << "ms " << codec << " frame)! "; + } + if (shrtest_cnt < 6){ + issues << "unstable connection (" << shrtest_cnt << " " << codec << " frame(s) in key)! "; + } + if (longest_key > shrtest_key*1.30){ + issues << "unstable key interval (" << (uint32_t)(((longest_key/shrtest_key)-1)*100) << "% " << codec << " variance)! "; + } + } if (buffer < trBuffer){buffer = trBuffer;} - if (longest_prt > 500){ - issues << "unstable connection (" << longest_prt << "ms " << codec << " frame)! "; - } - if (shrtest_cnt < 6){ - issues << "unstable connection (" << shrtest_cnt << " " << codec << " frame(s) in key)! "; - } - if (longest_key > shrtest_key*1.30){ - issues << "unstable key interval (" << (uint32_t)(((longest_key/shrtest_key)-1)*100) << "% " << codec << " variance)! "; - } if (codec == "AAC"){hasAAC = true;} if (codec == "H264"){hasH264 = true;} if (type == "video"){ diff --git a/src/process/process_livepeer.cpp b/src/process/process_livepeer.cpp index 70df4fc6..0dc0091c 100644 --- a/src/process/process_livepeer.cpp +++ b/src/process/process_livepeer.cpp @@ -33,6 +33,7 @@ Util::Config conf; size_t insertTurn = 0; bool isStuck = false; +size_t sourceIndex = INVALID_TRACK_ID; namespace Mist{ @@ -134,6 +135,7 @@ namespace Mist{ } if (thisTime > statSourceMs){statSourceMs = thisTime;} if (thisPacket.getFlag("keyframe") && M.trackLoaded(thisIdx) && M.getType(thisIdx) == "video" && (thisTime - presegs[currPreSeg].time) >= 1000){ + sourceIndex = getMainSelectedTrack(); if (presegs[currPreSeg].data.size() > 187){ presegs[currPreSeg].keyNo = keyCount; presegs[currPreSeg].width = M.getWidth(thisIdx); @@ -233,6 +235,7 @@ namespace Mist{ INFO_MSG("Initializing track %zi as %" PRIu64 " for playlist %zu", thisPacket.getTrackId(), trackId, S.ID); S.S.initializeMetadata(meta, thisPacket.getTrackId(), trackId); thisIdx = M.trackIDToIndex(trackId, getpid()); + meta.setSourceTrack(thisIdx, sourceIndex); } } if (S.byteOffset >= S.data.size() && !S.S.hasPacket()){