Fixed track filtering in live streams.

This commit is contained in:
Thulinma 2013-10-31 14:04:12 +01:00
parent 73910bd343
commit 1e9128c23d
2 changed files with 11 additions and 7 deletions

View file

@ -513,16 +513,20 @@ DTSC::livePos DTSC::Stream::msSeek(unsigned int ms, std::set<int> & allowedTrack
return result; return result;
} }
bool DTSC::Stream::isNewest(DTSC::livePos & pos){ /// Returns whether the current position is the last currently available position within allowedTracks.
return (buffers.upper_bound(pos) == buffers.end()); /// Simply returns the result of getNext(pos, allowedTracks) == pos
bool DTSC::Stream::isNewest(DTSC::livePos & pos, std::set<int> & allowedTracks){
return getNext(pos, allowedTracks) == pos;
} }
/// Returns the next available position within allowedTracks, or the current position if no next is availble.
DTSC::livePos DTSC::Stream::getNext(DTSC::livePos & pos, std::set<int> & allowedTracks){ DTSC::livePos DTSC::Stream::getNext(DTSC::livePos & pos, std::set<int> & allowedTracks){
if (!isNewest(pos)){ std::map<livePos,JSON::Value>::iterator iter = buffers.upper_bound(pos);
return (buffers.upper_bound(pos))->first; while (iter != buffers.end()){
}else{ if (allowedTracks.count(iter->first.trackID)){return iter->first;}
return livePos(); iter++;
} }
return pos;
} }
/// Properly cleans up the object for erasing. /// Properly cleans up the object for erasing.

View file

@ -211,7 +211,7 @@ namespace DTSC {
int canSeekms(unsigned int ms); int canSeekms(unsigned int ms);
livePos msSeek(unsigned int ms, std::set<int> & allowedTracks); livePos msSeek(unsigned int ms, std::set<int> & allowedTracks);
void setBufferTime(unsigned int ms); void setBufferTime(unsigned int ms);
bool isNewest(DTSC::livePos & pos); bool isNewest(DTSC::livePos & pos, std::set<int> & allowedTracks);
DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks); DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks);
void endStream(); void endStream();
void waitForMeta(Socket::Connection & sourceSocket); void waitForMeta(Socket::Connection & sourceSocket);