[vlc-commits] demux: adaptative: convert tracker to use getNextSegment

Francois Cartegnie git at videolan.org
Wed Sep 23 21:15:10 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 23 18:18:21 2015 +0200| [2678b03b431cf0e6f6a48024935f9b929505cb59] | committer: Francois Cartegnie

demux: adaptative: convert tracker to use getNextSegment

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2678b03b431cf0e6f6a48024935f9b929505cb59
---

 modules/demux/adaptative/SegmentTracker.cpp |   29 ++++++++++-----------------
 modules/demux/adaptative/SegmentTracker.hpp |    1 -
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp
index 2d7f492..b83c22a 100644
--- a/modules/demux/adaptative/SegmentTracker.cpp
+++ b/modules/demux/adaptative/SegmentTracker.cpp
@@ -34,7 +34,6 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, BaseAdaptationSe
     initializing = true;
     index_sent = false;
     init_sent = false;
-    sequence_set = false;
     prevRepresentation = NULL;
     setAdaptationLogic(logic_);
     adaptationSet = adaptSet;
@@ -52,7 +51,6 @@ void SegmentTracker::setAdaptationLogic(AbstractAdaptationLogic *logic_)
 
 void SegmentTracker::resetCounter()
 {
-    sequence_set = false;
     prevRepresentation = NULL;
 }
 
@@ -89,18 +87,6 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed)
     if(rep->needsUpdate())
         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)
     {
         init_sent = true;
@@ -117,12 +103,20 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed)
             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)
     {
         resetCounter();
         return NULL;
     }
+
     /* stop initializing after 1st chunk */
     initializing = false;
 
@@ -155,12 +149,11 @@ void SegmentTracker::setPositionByNumber(uint64_t segnumber, bool restarted)
         init_sent = false;
     }
     count = segnumber;
-    sequence_set = true;
 }
 
 mtime_t SegmentTracker::getSegmentStart() const
 {
-    if(prevRepresentation && sequence_set)
+    if(prevRepresentation)
         return prevRepresentation->getPlaybackTimeBySegmentNumber(count);
     else
         return 0;
@@ -174,7 +167,7 @@ void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
 void SegmentTracker::pruneFromCurrent()
 {
     AbstractPlaylist *playlist = adaptationSet->getPlaylist();
-    if(playlist->isLive() && sequence_set)
+    if(playlist->isLive())
         playlist->pruneBySegmentNumber(count);
 }
 
diff --git a/modules/demux/adaptative/SegmentTracker.hpp b/modules/demux/adaptative/SegmentTracker.hpp
index a524b83..59edfca 100644
--- a/modules/demux/adaptative/SegmentTracker.hpp
+++ b/modules/demux/adaptative/SegmentTracker.hpp
@@ -77,7 +77,6 @@ namespace adaptative
             bool initializing;
             bool index_sent;
             bool init_sent;
-            bool sequence_set;
             uint64_t count;
             AbstractAdaptationLogic *logic;
             BaseAdaptationSet *adaptationSet;



More information about the vlc-commits mailing list