[vlc-commits] demux: adaptative: add tracker listeners interface

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


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 22 22:47:30 2015 +0200| [de283d704cbef76ac9261466f7978d8674af3bbf] | committer: Francois Cartegnie

demux: adaptative: add tracker listeners interface

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

 modules/demux/adaptative/SegmentTracker.cpp |   12 ++++++++++++
 modules/demux/adaptative/SegmentTracker.hpp |   18 +++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp
index 360362f..2d7f492 100644
--- a/modules/demux/adaptative/SegmentTracker.cpp
+++ b/modules/demux/adaptative/SegmentTracker.cpp
@@ -166,6 +166,11 @@ mtime_t SegmentTracker::getSegmentStart() const
         return 0;
 }
 
+void SegmentTracker::registerListener(SegmentTrackerListenerInterface *listener)
+{
+    listeners.push_back(listener);
+}
+
 void SegmentTracker::pruneFromCurrent()
 {
     AbstractPlaylist *playlist = adaptationSet->getPlaylist();
@@ -178,3 +183,10 @@ void SegmentTracker::updateSelected()
     if(prevRepresentation)
         prevRepresentation->runLocalUpdates(getSegmentStart(), count);
 }
+
+void SegmentTracker::notify(SegmentTrackerListenerInterface::notifications type, ISegment *segment)
+{
+    std::list<SegmentTrackerListenerInterface *>::const_iterator it;
+    for(it=listeners.begin();it != listeners.end(); ++it)
+        (*it)->trackerNotification(type, segment);
+}
diff --git a/modules/demux/adaptative/SegmentTracker.hpp b/modules/demux/adaptative/SegmentTracker.hpp
index 90eeac0..a524b83 100644
--- a/modules/demux/adaptative/SegmentTracker.hpp
+++ b/modules/demux/adaptative/SegmentTracker.hpp
@@ -26,6 +26,7 @@
 
 #include "StreamsType.hpp"
 #include <vlc_common.h>
+#include <list>
 
 namespace adaptative
 {
@@ -39,11 +40,22 @@ namespace adaptative
         class BaseAdaptationSet;
         class BaseRepresentation;
         class SegmentChunk;
+        class ISegment;
     }
 
     using namespace playlist;
     using namespace logic;
 
+    class SegmentTrackerListenerInterface
+    {
+        public:
+            enum notifications
+            {
+                NOTIFICATION_DISCONTINUITY = 0
+            };
+            virtual void trackerNotification(notifications, ISegment *) = 0;
+    };
+
     class SegmentTracker
     {
         public:
@@ -53,12 +65,15 @@ namespace adaptative
             void setAdaptationLogic(AbstractAdaptationLogic *);
             void resetCounter();
             SegmentChunk* getNextChunk(bool);
-            bool setPosition(mtime_t, bool, bool);
+            bool setPositionByTime(mtime_t, bool, bool);
+            void setPositionByNumber(uint64_t, bool);
             mtime_t getSegmentStart() const;
+            void registerListener(SegmentTrackerListenerInterface *);
             void pruneFromCurrent();
             void updateSelected();
 
         private:
+            void notify(SegmentTrackerListenerInterface::notifications, ISegment *);
             bool initializing;
             bool index_sent;
             bool init_sent;
@@ -67,6 +82,7 @@ namespace adaptative
             AbstractAdaptationLogic *logic;
             BaseAdaptationSet *adaptationSet;
             BaseRepresentation *prevRepresentation;
+            std::list<SegmentTrackerListenerInterface *> listeners;
     };
 }
 



More information about the vlc-commits mailing list