Removed minSkipAhead, improved seeking algorithm.

This commit is contained in:
Thulinma 2017-09-29 12:31:41 +02:00
parent c466f4bcba
commit 485a4ecbbe
5 changed files with 6 additions and 13 deletions

View file

@ -75,7 +75,6 @@ namespace Mist{
needsLookAhead = 0; needsLookAhead = 0;
lastStats = 0; lastStats = 0;
maxSkipAhead = 7500; maxSkipAhead = 7500;
minSkipAhead = 5000;
uaDelay = 10; uaDelay = 10;
realTime = 1000; realTime = 1000;
lastRecv = Util::epoch(); lastRecv = Util::epoch();
@ -856,6 +855,7 @@ namespace Mist{
/// It seeks to the last sync'ed keyframe of the main track, no closer than needsLookAhead+minKeepAway ms from the end. /// It seeks to the last sync'ed keyframe of the main track, no closer than needsLookAhead+minKeepAway ms from the end.
/// Aborts if not live, there is no main track or it has no keyframes. /// Aborts if not live, there is no main track or it has no keyframes.
bool Output::liveSeek(){ bool Output::liveSeek(){
static uint32_t seekCount = 2;
unsigned long long seekPos = 0; unsigned long long seekPos = 0;
if (!myMeta.live){return false;} if (!myMeta.live){return false;}
long unsigned int mainTrack = getMainSelectedTrack(); long unsigned int mainTrack = getMainSelectedTrack();
@ -865,14 +865,10 @@ namespace Mist{
if (!mainTrk.keys.size()){return false;} if (!mainTrk.keys.size()){return false;}
uint32_t minKeepAway = mainTrk.minKeepAway; uint32_t minKeepAway = mainTrk.minKeepAway;
//Only skip forward if we can win at least 500ms
if (thisPacket.getTime() + 500 > mainTrk.keys.rbegin()->getTime()){
return false;
}
for (std::deque<DTSC::Key>::reverse_iterator it = myMeta.tracks[mainTrack].keys.rbegin(); it != myMeta.tracks[mainTrack].keys.rend(); ++it){ for (std::deque<DTSC::Key>::reverse_iterator it = myMeta.tracks[mainTrack].keys.rbegin(); it != myMeta.tracks[mainTrack].keys.rend(); ++it){
seekPos = it->getTime(); seekPos = it->getTime();
if(seekPos <= thisPacket.getTime()){return false;} //Only skip forward if we can win a decent amount
if(seekPos <= thisPacket.getTime() + 250*seekCount){break;}
bool good = true; bool good = true;
//check if all tracks have data for this point in time //check if all tracks have data for this point in time
for (std::set<unsigned long>::iterator ti = selectedTracks.begin(); ti != selectedTracks.end(); ++ti){ for (std::set<unsigned long>::iterator ti = selectedTracks.begin(); ti != selectedTracks.end(); ++ti){
@ -891,7 +887,8 @@ namespace Mist{
} }
//if yes, seek here //if yes, seek here
if (good){ if (good){
INFO_MSG("Skipping forward %llums (%u ms LA, %lu ms mKA)", seekPos - thisPacket.getTime(), needsLookAhead, mainTrk.minKeepAway); INFO_MSG("Skipping forward %llums (%u ms LA, %lu ms mKA, > %lums)", seekPos - thisPacket.getTime(), needsLookAhead, mainTrk.minKeepAway, seekCount*250);
if (seekCount < 20){++seekCount;}
seek(seekPos); seek(seekPos);
return true; return true;
} }
@ -999,7 +996,7 @@ namespace Mist{
if (realTime){ if (realTime){
uint8_t i = 6; uint8_t i = 6;
while (--i && thisPacket.getTime() > (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime && keepGoing()){ while (--i && thisPacket.getTime() > (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime && keepGoing()){
Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+minSkipAhead)/realTime, 1000llu)); Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime, 1000llu));
stats(); stats();
} }
} }

View file

@ -119,7 +119,6 @@ namespace Mist {
//stream delaying variables //stream delaying variables
unsigned int maxSkipAhead;///< Maximum ms that we will go ahead of the intended timestamps. unsigned int maxSkipAhead;///< Maximum ms that we will go ahead of the intended timestamps.
unsigned int minSkipAhead;///< Minimum ms that we will go ahead of the intended timestamps.
unsigned int realTime;///< Playback speed in ms of data per second. eg: 0 is infinite, 1000 real-time, 5000 is 0.2X speed, 500 = 2X speed. unsigned int realTime;///< Playback speed in ms of data per second. eg: 0 is infinite, 1000 real-time, 5000 is 0.2X speed, 500 = 2X speed.
uint32_t needsLookAhead;///< Amount of millis we need to be able to look ahead in the metadata uint32_t needsLookAhead;///< Amount of millis we need to be able to look ahead in the metadata

View file

@ -735,7 +735,6 @@ namespace Mist {
//max lead time is set in MS, but the variable is in integer seconds for simplicity. //max lead time is set in MS, but the variable is in integer seconds for simplicity.
if (H.GetVar("buffer") != "") { if (H.GetVar("buffer") != "") {
maxSkipAhead = JSON::Value(H.GetVar("buffer")).asInt() * 1000; maxSkipAhead = JSON::Value(H.GetVar("buffer")).asInt() * 1000;
minSkipAhead = maxSkipAhead - std::min(2500u, maxSkipAhead / 2);
} }
//allow setting of play back rate through buffer variable. //allow setting of play back rate through buffer variable.
//play back rate is set in MS per second, but the variable is a simple multiplier. //play back rate is set in MS per second, but the variable is a simple multiplier.

View file

@ -126,7 +126,6 @@ namespace Mist{
} }
maxSkipAhead = 1500; maxSkipAhead = 1500;
minSkipAhead = 500;
} }
bool OutRTMP::listenMode(){ bool OutRTMP::listenMode(){

View file

@ -25,7 +25,6 @@ namespace Mist{
pausepoint = 0; pausepoint = 0;
setBlocking(false); setBlocking(false);
maxSkipAhead = 0; maxSkipAhead = 0;
minSkipAhead = 0;
expectTCP = false; expectTCP = false;
lastTimeSync = 0; lastTimeSync = 0;
mainConn = &myConn; mainConn = &myConn;