Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2016-10-11 15:04:11 +02:00
commit 915a10207b
6 changed files with 70 additions and 10 deletions

View file

@ -353,6 +353,8 @@ namespace DTSC {
void toPrettyString(std::ostream & str, int indent = 0, int verbosity = 0);
//members:
std::map<unsigned int, Track> tracks;
Track & mainTrack();
uint32_t biggestFragment();
bool vod;
bool live;
bool merged;

View file

@ -1417,6 +1417,28 @@ namespace DTSC {
}
}
/// Returns a reference to the first video track, or the first track.
/// Beware: returns a reference to invalid memory if there are no tracks!
/// Will print a WARN-level message if this is the case.
Track & Meta::mainTrack(){
if (!tracks.size()){
WARN_MSG("Returning nonsense reference - crashing is likely");
return tracks.begin()->second;
}
for (std::map<unsigned int, Track>::iterator it = tracks.begin(); it != tracks.end(); it++) {
if (it->second.type == "video"){
return it->second;
}
}
return tracks.begin()->second;
}
/// Returns 0 if there are no tracks, otherwise calls mainTrack().biggestFragment().
uint32_t Meta::biggestFragment(){
if (!tracks.size()){return 0;}
return mainTrack().biggestFragment();
}
///\brief Converts a track to a human readable string
///\param str The stringstream to append to
///\param indent the amount of indentation needed