Added getTrackById()

This commit is contained in:
Erik Zandvliet 2013-06-06 09:59:51 +02:00
parent 0c50862344
commit 1449e9e73e
2 changed files with 25 additions and 1 deletions

View file

@ -248,6 +248,15 @@ JSON::Value & DTSC::Stream::getPacket(unsigned int num){
return buffers[num]; return buffers[num];
} }
/// Returns a track element by giving the id.
JSON::Value & DTSC::Stream::getTrackById(int trackNo){
static JSON::Value empty;
if (trackMapping.find(trackNo) != trackMapping.end()){
return metadata["tracks"][trackMapping[trackNo]];
}
return empty;
}
/// Returns the type of the last received packet. /// Returns the type of the last received packet.
DTSC::datatype DTSC::Stream::lastType(){ DTSC::datatype DTSC::Stream::lastType(){
return datapointertype; return datapointertype;
@ -809,6 +818,15 @@ JSON::Value & DTSC::File::getJSON(){
return jsonbuffer; return jsonbuffer;
} }
/// Returns a track element by giving the id.
JSON::Value & DTSC::File::getTrackById(int trackNo){
static JSON::Value empty;
if (trackMapping.find(trackNo) != trackMapping.end()){
return metadata["tracks"][trackMapping[trackNo]];
}
return empty;
}
bool DTSC::File::seek_time(int ms, int trackNo){ bool DTSC::File::seek_time(int ms, int trackNo){
seekPos tmpPos; seekPos tmpPos;
tmpPos.trackID = trackNo; tmpPos.trackID = trackNo;
@ -908,8 +926,12 @@ bool DTSC::File::atKeyframe(){
} }
void DTSC::File::selectTracks(std::set<int> & tracks){ void DTSC::File::selectTracks(std::set<int> & tracks){
currentPositions.clear();
selectedTracks = tracks; selectedTracks = tracks;
if ( !currentPositions.size()){
seek_time(0);
}else{
currentPositions.clear();
}
} }
/// Close the file if open /// Close the file if open

View file

@ -106,6 +106,7 @@ namespace DTSC {
void seekNext(); void seekNext();
std::string & getPacket(); std::string & getPacket();
JSON::Value & getJSON(); JSON::Value & getJSON();
JSON::Value & getTrackById(int trackNo);
bool seek_time(int seconds); bool seek_time(int seconds);
bool seek_time(int seconds, int trackNo); bool seek_time(int seconds, int trackNo);
bool seek_bpos(int bpos); bool seek_bpos(int bpos);
@ -154,6 +155,7 @@ namespace DTSC {
Stream(unsigned int buffers, unsigned int bufferTime = 0); Stream(unsigned int buffers, unsigned int bufferTime = 0);
JSON::Value metadata; JSON::Value metadata;
JSON::Value & getPacket(unsigned int num = 0); JSON::Value & getPacket(unsigned int num = 0);
JSON::Value & getTrackById(int trackNo);
datatype lastType(); datatype lastType();
std::string & lastData(); std::string & lastData();
bool hasVideo(); bool hasVideo();