[vlc-commits] demux: adaptative: add segment comparison

Francois Cartegnie git at videolan.org
Wed Jun 10 18:58:02 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat May 23 16:59:38 2015 +0200| [f48876f3de8a7bb72c2516949f73e875452b3f95] | committer: Francois Cartegnie

demux: adaptative: add segment comparison

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

 modules/demux/adaptative/playlist/Segment.cpp |   20 ++++++++++++++++++++
 modules/demux/adaptative/playlist/Segment.h   |    1 +
 2 files changed, 21 insertions(+)

diff --git a/modules/demux/adaptative/playlist/Segment.cpp b/modules/demux/adaptative/playlist/Segment.cpp
index b47aacb..a1879ab 100644
--- a/modules/demux/adaptative/playlist/Segment.cpp
+++ b/modules/demux/adaptative/playlist/Segment.cpp
@@ -112,6 +112,26 @@ bool ISegment::contains(size_t byte) const
             (!endByte || byte <= endByte) );
 }
 
+int ISegment::compare(ISegment *other) const
+{
+    if(startTime.Get() != VLC_TS_INVALID)
+    {
+        int64_t diff = startTime.Get() - other->startTime.Get();
+        if(diff)
+            return diff / diff;
+    }
+
+    size_t diff = startByte - other->startByte;
+    if(diff)
+        return diff / diff;
+
+    diff = endByte - other->endByte;
+    if(diff)
+        return diff / diff;
+
+    return 0;
+}
+
 int ISegment::getClassId() const
 {
     return classId;
diff --git a/modules/demux/adaptative/playlist/Segment.h b/modules/demux/adaptative/playlist/Segment.h
index 44b4970..7b22214 100644
--- a/modules/demux/adaptative/playlist/Segment.h
+++ b/modules/demux/adaptative/playlist/Segment.h
@@ -58,6 +58,7 @@ namespace adaptative
                 virtual void                            addSubSegment   (SubSegment *) = 0;
                 virtual void                            debug           (vlc_object_t *,int = 0) const;
                 virtual bool                            contains        (size_t byte) const;
+                virtual int                             compare         (ISegment *) const;
                 int                                     getClassId      () const;
                 Property<mtime_t>       startTime;
                 Property<mtime_t>       duration;



More information about the vlc-commits mailing list