Added minKeepAway support to DTSC::Track object, senders and parsers

This commit is contained in:
Thulinma 2017-08-03 15:06:12 +02:00
parent c895a6b7e2
commit f3f2802844
3 changed files with 34 additions and 6 deletions

View file

@ -297,6 +297,7 @@ namespace DTSC {
std::string codec; std::string codec;
std::string type; std::string type;
std::string lang;///< ISO 639-2 Language of track, empty or und if unknown. std::string lang;///< ISO 639-2 Language of track, empty or und if unknown.
uint32_t minKeepAway;///<Time in MS to never seek closer than live point to
//audio only //audio only
int rate; int rate;
int size; int size;

View file

@ -1105,6 +1105,7 @@ namespace DTSC {
width = 0; width = 0;
height = 0; height = 0;
fpks = 0; fpks = 0;
minKeepAway = 0;
} }
///\brief Constructs a track from a JSON::Value ///\brief Constructs a track from a JSON::Value
@ -1148,6 +1149,11 @@ namespace DTSC {
keySizes.push_back((((long unsigned)tmp[i]) << 24) | (((long unsigned)tmp[i+1]) << 16) | (((long unsigned int)tmp[i+2]) << 8) | tmp[i+3]); keySizes.push_back((((long unsigned)tmp[i]) << 24) | (((long unsigned)tmp[i+1]) << 16) | (((long unsigned int)tmp[i+2]) << 8) | tmp[i+3]);
} }
} }
if (trackRef.isMember("keepaway") && trackRef["keepaway"].isInt()){
minKeepAway = trackRef["keepaway"].asInt();
}else{
minKeepAway = 0;
}
} }
///\brief Constructs a track from a JSON::Value ///\brief Constructs a track from a JSON::Value
@ -1199,6 +1205,11 @@ namespace DTSC {
keySizes.push_back((((long unsigned)tmp[i]) << 24) | (((long unsigned)tmp[i+1]) << 16) | (((long unsigned int)tmp[i+2]) << 8) | tmp[i+3]); keySizes.push_back((((long unsigned)tmp[i]) << 24) | (((long unsigned)tmp[i+1]) << 16) | (((long unsigned int)tmp[i+2]) << 8) | tmp[i+3]);
} }
} }
if (trackRef.getMember("keepaway").getType() == DTSC_INT){
minKeepAway = trackRef.getMember("keepaway").asInt();
}else{
minKeepAway = 0;
}
} }
///\brief Updates a track and its metadata given new packet properties. ///\brief Updates a track and its metadata given new packet properties.
@ -1641,6 +1652,9 @@ namespace DTSC {
if (!skipDynamic && missedFrags) { if (!skipDynamic && missedFrags) {
result += 23; result += 23;
} }
if (minKeepAway){
result += 19;
}
return result; return result;
} }
@ -1736,6 +1750,10 @@ namespace DTSC {
writePointer(p, "\000\004fpks\001", 7); writePointer(p, "\000\004fpks\001", 7);
writePointer(p, convertLongLong(fpks), 8); writePointer(p, convertLongLong(fpks), 8);
} }
if (minKeepAway){
writePointer(p, "\000\010keepaway\001", 11);
writePointer(p, convertLongLong(minKeepAway), 8);
}
writePointer(p, "\000\000\356", 3);//End this track Object writePointer(p, "\000\000\356", 3);//End this track Object
} }
@ -1813,6 +1831,10 @@ namespace DTSC {
conn.SendNow("\000\004fpks\001", 7); conn.SendNow("\000\004fpks\001", 7);
conn.SendNow(convertLongLong(fpks), 8); conn.SendNow(convertLongLong(fpks), 8);
} }
if (minKeepAway){
conn.SendNow("\000\010keepaway\001", 11);
conn.SendNow(convertLongLong(minKeepAway), 8);
}
conn.SendNow("\000\000\356", 3);//End this track Object conn.SendNow("\000\000\356", 3);//End this track Object
} }
@ -1965,6 +1987,11 @@ namespace DTSC {
result["height"] = height; result["height"] = height;
result["fpks"] = fpks; result["fpks"] = fpks;
} }
if(minKeepAway){
result["keepaway"] = minKeepAway;
}
return result; return result;
} }

View file

@ -624,7 +624,7 @@ namespace Mist{
/// This function decides where in the stream initial playback starts. /// This function decides where in the stream initial playback starts.
/// The default implementation calls seek(0) for VoD. /// The default implementation calls seek(0) for VoD.
/// For live, it seeks to the last sync'ed keyframe of the main track, no closer than needsLookAhead ms from the end. /// For live, it seeks to the last sync'ed keyframe of the main track, no closer than needsLookAhead+minKeepAway ms from the end.
/// Unless lastms < 5000, then it seeks to the first keyframe of the main track. /// Unless lastms < 5000, then it seeks to the first keyframe of the main track.
/// Aborts if there is no main track or it has no keyframes. /// Aborts if there is no main track or it has no keyframes.
void Output::initialSeek(){ void Output::initialSeek(){
@ -640,17 +640,17 @@ namespace Mist{
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){
if (myMeta.tracks[*ti].lastms < seekPos+needsLookAhead){good = false; break;}
if (mainTrack == *ti){continue;}//skip self
if (!myMeta.tracks.count(*ti)){ if (!myMeta.tracks.count(*ti)){
HIGH_MSG("Skipping track %lu, not in tracks", *ti); HIGH_MSG("Skipping track %lu, not in tracks", *ti);
continue; continue;
}//ignore missing tracks }//ignore missing tracks
if (myMeta.tracks[*ti].lastms == myMeta.tracks[*ti].firstms){ DTSC::Track & thisTrack = myMeta.tracks[*ti];
if (thisTrack.lastms < seekPos+needsLookAhead+thisTrack.minKeepAway){good = false; break;}
if (mainTrack == *ti){continue;}//skip self
if (thisTrack.lastms == thisTrack.firstms){
HIGH_MSG("Skipping track %lu, last equals first", *ti); HIGH_MSG("Skipping track %lu, last equals first", *ti);
continue; continue;
}//ignore point-tracks }//ignore point-tracks
if (myMeta.tracks[*ti].lastms < seekPos){good = false; break;}
HIGH_MSG("Track %lu is good", *ti); HIGH_MSG("Track %lu is good", *ti);
} }
//if yes, seek here //if yes, seek here