Added getTrackById()
This commit is contained in:
parent
0c50862344
commit
1449e9e73e
2 changed files with 25 additions and 1 deletions
24
lib/dtsc.cpp
24
lib/dtsc.cpp
|
@ -248,6 +248,15 @@ JSON::Value & DTSC::Stream::getPacket(unsigned int 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.
|
||||
DTSC::datatype DTSC::Stream::lastType(){
|
||||
return datapointertype;
|
||||
|
@ -809,6 +818,15 @@ JSON::Value & DTSC::File::getJSON(){
|
|||
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){
|
||||
seekPos tmpPos;
|
||||
tmpPos.trackID = trackNo;
|
||||
|
@ -908,8 +926,12 @@ bool DTSC::File::atKeyframe(){
|
|||
}
|
||||
|
||||
void DTSC::File::selectTracks(std::set<int> & tracks){
|
||||
currentPositions.clear();
|
||||
selectedTracks = tracks;
|
||||
if ( !currentPositions.size()){
|
||||
seek_time(0);
|
||||
}else{
|
||||
currentPositions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Close the file if open
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace DTSC {
|
|||
void seekNext();
|
||||
std::string & getPacket();
|
||||
JSON::Value & getJSON();
|
||||
JSON::Value & getTrackById(int trackNo);
|
||||
bool seek_time(int seconds);
|
||||
bool seek_time(int seconds, int trackNo);
|
||||
bool seek_bpos(int bpos);
|
||||
|
@ -154,6 +155,7 @@ namespace DTSC {
|
|||
Stream(unsigned int buffers, unsigned int bufferTime = 0);
|
||||
JSON::Value metadata;
|
||||
JSON::Value & getPacket(unsigned int num = 0);
|
||||
JSON::Value & getTrackById(int trackNo);
|
||||
datatype lastType();
|
||||
std::string & lastData();
|
||||
bool hasVideo();
|
||||
|
|
Loading…
Add table
Reference in a new issue