From 1e9128c23dc19530517042f20009e4df21158011 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 31 Oct 2013 14:04:12 +0100 Subject: [PATCH] Fixed track filtering in live streams. --- lib/dtsc.cpp | 16 ++++++++++------ lib/dtsc.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index e8205ca2..c887cfed 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -513,16 +513,20 @@ DTSC::livePos DTSC::Stream::msSeek(unsigned int ms, std::set & 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 & 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 & allowedTracks){ - if (!isNewest(pos)){ - return (buffers.upper_bound(pos))->first; - }else{ - return livePos(); + std::map::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. diff --git a/lib/dtsc.h b/lib/dtsc.h index ac07bcf1..24156a25 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -211,7 +211,7 @@ namespace DTSC { int canSeekms(unsigned int ms); livePos msSeek(unsigned int ms, std::set & allowedTracks); void setBufferTime(unsigned int ms); - bool isNewest(DTSC::livePos & pos); + bool isNewest(DTSC::livePos & pos, std::set & allowedTracks); DTSC::livePos getNext(DTSC::livePos & pos, std::set & allowedTracks); void endStream(); void waitForMeta(Socket::Connection & sourceSocket);