Tweaked default buffer starting position behaviour for outputs.

This commit is contained in:
Thulinma 2014-12-08 17:35:22 +01:00
parent 78aa855084
commit 0438cfcd1d
2 changed files with 20 additions and 11 deletions

View file

@ -533,20 +533,29 @@ namespace Mist {
return 0;
}
/// Returns the ID of the main selected track, or 0 if no tracks are selected.
/// The main track is the first video track, if any, and otherwise the first other track.
long unsigned int Output::getMainSelectedTrack(){
if (!selectedTracks.size()){
return 0;
}
for (std::set<long unsigned int>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
if (myMeta.tracks[*it].type == "video"){
return *it;
}
}
return *(selectedTracks.begin());
}
void Output::prepareNext(){
if (!sought){
unsigned int firstms = 0x0;
for (std::set<long unsigned int>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
lastKeyTime[*it] = 0xFFFFFFFF;
if (myMeta.tracks[*it].firstms > firstms){
firstms = myMeta.tracks[*it].firstms;
}
}
if (myMeta.live){
if (firstms < 5000){
firstms = 0;
long unsigned int mainTrack = getMainSelectedTrack();
unsigned long long seekPos = mymeta.tracks[mainTrack].keys.begin()->getTime();
if (seekPos < 5000){
seekPos = 0;
}
seek(firstms);
seek(seekPos);
}else{
seek(0);
}

View file

@ -57,6 +57,7 @@ namespace Mist {
bool seek(int tid, long long pos, bool getNextKey = false);
void stop();
void setBlocking(bool blocking);
long unsigned int getMainSelectedTrack();
void updateMeta();
static bool listenMode(){return true;}
//virtuals. The optional virtuals have default implementations that do as little as possible.
@ -75,7 +76,6 @@ namespace Mist {
long long unsigned int firstTime;///< Time of first packet after last seek. Used for real-time sending.
std::map<unsigned long, unsigned long> nxtKeyNum;///< Contains the number of the next key, for page seeking purposes.
std::set<sortedPageInfo> buffer;///< A sorted list of next-to-be-loaded packets.
std::map<unsigned long, unsigned long> lastKeyTime;///< Stores the time of the last keyframe, for preventing duplicates
bool sought;///<If a seek has been done, this is set to true. Used for seeking on prepareNext().
protected://these are to be messed with by child classes
IPC::sharedClient statsPage;///< Shared memory used for statistics reporting.