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;
}
bool DTSC::Stream::isNewest(DTSC::livePos & pos){
return (buffers.upper_bound(pos) == buffers.end());
/// Returns whether the current position is the last currently available position within allowedTracks.
/// 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){
if (!isNewest(pos)){
return (buffers.upper_bound(pos))->first;
}else{
return livePos();
std::map<livePos,JSON::Value>::iterator iter = buffers.upper_bound(pos);
while (iter != buffers.end()){
if (allowedTracks.count(iter->first.trackID)){return iter->first;}
iter++;
}
return pos;
}
/// Properly cleans up the object for erasing.

View file

@ -211,7 +211,7 @@ namespace DTSC {
int canSeekms(unsigned int ms);
livePos msSeek(unsigned int ms, std::set<int> & allowedTracks);
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);
void endStream();
void waitForMeta(Socket::Connection & sourceSocket);