Commit 2678b03b authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptative: convert tracker to use getNextSegment

parent 6e2fb50e
...@@ -34,7 +34,6 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSe ...@@ -34,7 +34,6 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSe
initializing = true; initializing = true;
index_sent = false; index_sent = false;
init_sent = false; init_sent = false;
sequence_set = false;
prevRepresentation = NULL; prevRepresentation = NULL;
setAdaptationLogic(logic_); setAdaptationLogic(logic_);
adaptationSet = adaptSet; adaptationSet = adaptSet;
...@@ -52,7 +51,6 @@ void SegmentTracker::setAdaptationLogic(AbstractAdaptationLogic *logic_) ...@@ -52,7 +51,6 @@ void SegmentTracker::setAdaptationLogic(AbstractAdaptationLogic *logic_)
void SegmentTracker::resetCounter() void SegmentTracker::resetCounter()
{ {
sequence_set = false;
prevRepresentation = NULL; prevRepresentation = NULL;
} }
...@@ -89,18 +87,6 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed) ...@@ -89,18 +87,6 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed)
if(rep->needsUpdate()) if(rep->needsUpdate())
updateSelected(); updateSelected();
/* If we're starting, set the first segment number to download */
if(!sequence_set)
{
if(! rep->getSegmentNumberByTime( VLC_TS_INVALID, &count ) )
{
msg_Warn( rep->getPlaylist()->getVLCObject(),
"Can't get first segment number for representation %s", rep->getID().str().c_str() );
count = 0;
}
sequence_set = true;
}
if(!init_sent) if(!init_sent)
{ {
init_sent = true; init_sent = true;
...@@ -117,12 +103,20 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed) ...@@ -117,12 +103,20 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed)
return segment->toChunk(count, rep); return segment->toChunk(count, rep);
} }
segment = rep->getSegment(BaseRepresentation::INFOTYPE_MEDIA, count); bool b_gap = false;
segment = rep->getNextSegment(BaseRepresentation::INFOTYPE_MEDIA, count, &count, &b_gap);
if(b_gap && count)
{
notify(SegmentTrackerListenerInterface::notifications::NOTIFICATION_DISCONTINUITY,
segment);
}
if(!segment) if(!segment)
{ {
resetCounter(); resetCounter();
return NULL; return NULL;
} }
/* stop initializing after 1st chunk */ /* stop initializing after 1st chunk */
initializing = false; initializing = false;
...@@ -155,12 +149,11 @@ void SegmentTracker::setPositionByNumber(uint64_t segnumber, bool restarted) ...@@ -155,12 +149,11 @@ void SegmentTracker::setPositionByNumber(uint64_t segnumber, bool restarted)
init_sent = false; init_sent = false;
} }
count = segnumber; count = segnumber;
sequence_set = true;
} }
mtime_t SegmentTracker::getSegmentStart() const mtime_t SegmentTracker::getSegmentStart() const
{ {
if(prevRepresentation && sequence_set) if(prevRepresentation)
return prevRepresentation->getPlaybackTimeBySegmentNumber(count); return prevRepresentation->getPlaybackTimeBySegmentNumber(count);
else else
return 0; return 0;
...@@ -174,7 +167,7 @@ void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener) ...@@ -174,7 +167,7 @@ void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
void SegmentTracker::pruneFromCurrent() void SegmentTracker::pruneFromCurrent()
{ {
AbstractPlaylist *playlist = adaptationSet->getPlaylist(); AbstractPlaylist *playlist = adaptationSet->getPlaylist();
if(playlist->isLive() && sequence_set) if(playlist->isLive())
playlist->pruneBySegmentNumber(count); playlist->pruneBySegmentNumber(count);
} }
......
...@@ -77,7 +77,6 @@ namespace adaptative ...@@ -77,7 +77,6 @@ namespace adaptative
bool initializing; bool initializing;
bool index_sent; bool index_sent;
bool init_sent; bool init_sent;
bool sequence_set;
uint64_t count; uint64_t count;
AbstractAdaptationLogic *logic; AbstractAdaptationLogic *logic;
BaseAdaptationSet *adaptationSet; BaseAdaptationSet *adaptationSet;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment