[vlc-commits] demux: dash: handle index segment

Francois Cartegnie git at videolan.org
Thu Apr 30 20:50:22 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Apr 28 18:37:38 2015 +0200| [a98cee48dbb62aef8218186db06fed3a1ae64dbc] | committer: Francois Cartegnie

demux: dash: handle index segment

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

 modules/demux/adaptative/SegmentTracker.cpp        |    9 +++++++++
 modules/demux/adaptative/SegmentTracker.hpp        |    1 +
 modules/demux/adaptative/playlist/SegmentBase.cpp  |    3 ++-
 modules/demux/adaptative/playlist/SegmentBase.h    |    3 ++-
 .../adaptative/playlist/SegmentInfoCommon.cpp      |    2 +-
 .../demux/adaptative/playlist/SegmentInfoCommon.h  |   17 ++++++++++++++++-
 .../adaptative/playlist/SegmentInformation.cpp     |   20 +++++++++++++++++++-
 modules/demux/dash/mpd/IsoffMainParser.cpp         |    6 +++---
 8 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/modules/demux/adaptative/SegmentTracker.cpp b/modules/demux/adaptative/SegmentTracker.cpp
index 33717cf..c5f2793 100644
--- a/modules/demux/adaptative/SegmentTracker.cpp
+++ b/modules/demux/adaptative/SegmentTracker.cpp
@@ -30,6 +30,7 @@ SegmentTracker::SegmentTracker(AbstractAdaptationLogic *logic_, AbstractPlaylist
 {
     count = 0;
     initializing = true;
+    indexed = false;
     prevRepresentation = NULL;
     setAdaptationLogic(logic_);
     playlist = playlist_;
@@ -82,6 +83,14 @@ Chunk * SegmentTracker::getNextChunk(Streams::Type type)
             return segment->toChunk(count, rep);
     }
 
+    if(!indexed)
+    {
+        indexed = true;
+        segment = rep->getSegment(BaseRepresentation::INFOTYPE_INDEX);
+        if(segment)
+            return segment->toChunk(count, rep);
+    }
+
     segment = rep->getSegment(BaseRepresentation::INFOTYPE_MEDIA, count);
     if(!segment)
     {
diff --git a/modules/demux/adaptative/SegmentTracker.hpp b/modules/demux/adaptative/SegmentTracker.hpp
index 89fd0a0..5bd7166 100644
--- a/modules/demux/adaptative/SegmentTracker.hpp
+++ b/modules/demux/adaptative/SegmentTracker.hpp
@@ -64,6 +64,7 @@ namespace adaptative
 
         private:
             bool initializing;
+            bool indexed;
             uint64_t count;
             AbstractAdaptationLogic *logic;
             AbstractPlaylist *playlist;
diff --git a/modules/demux/adaptative/playlist/SegmentBase.cpp b/modules/demux/adaptative/playlist/SegmentBase.cpp
index d4eb3ef..1900f54 100644
--- a/modules/demux/adaptative/playlist/SegmentBase.cpp
+++ b/modules/demux/adaptative/playlist/SegmentBase.cpp
@@ -27,7 +27,8 @@
 using namespace adaptative::playlist;
 
 SegmentBase::SegmentBase    () :
-             Initializable()
+             Initializable(),
+             Indexable()
 {
 }
 SegmentBase::~SegmentBase   ()
diff --git a/modules/demux/adaptative/playlist/SegmentBase.h b/modules/demux/adaptative/playlist/SegmentBase.h
index 15fc7ad..be6f41b 100644
--- a/modules/demux/adaptative/playlist/SegmentBase.h
+++ b/modules/demux/adaptative/playlist/SegmentBase.h
@@ -32,7 +32,8 @@ namespace adaptative
 {
     namespace playlist
     {
-        class SegmentBase : public Initializable<Segment>
+        class SegmentBase : public Initializable<Segment>,
+                            public Indexable<Segment>
         {
             public:
                 SegmentBase             ();
diff --git a/modules/demux/adaptative/playlist/SegmentInfoCommon.cpp b/modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
index 89fb25e..d6be9ea 100644
--- a/modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
@@ -64,7 +64,7 @@ uint64_t TimescaleAble::inheritTimescale() const
 }
 
 SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
-    ICanonicalUrl( parent ), Initializable(),
+    ICanonicalUrl( parent ), Initializable(), Indexable(),
     duration( 0 ),
     startIndex( 0 )
 {
diff --git a/modules/demux/adaptative/playlist/SegmentInfoCommon.h b/modules/demux/adaptative/playlist/SegmentInfoCommon.h
index 5fa7845..21c139a 100644
--- a/modules/demux/adaptative/playlist/SegmentInfoCommon.h
+++ b/modules/demux/adaptative/playlist/SegmentInfoCommon.h
@@ -52,6 +52,20 @@ namespace adaptative
                 Property<T *> initialisationSegment;
         };
 
+        template<class T> class Indexable
+        {
+            public:
+                Indexable()
+                {
+                    indexSegment.Set(NULL);
+                }
+                ~Indexable()
+                {
+                    delete indexSegment.Get();
+                }
+                Property<T *> indexSegment;
+        };
+
         class Timelineable
         {
             public:
@@ -88,7 +102,8 @@ namespace adaptative
         };
 
         class SegmentInfoCommon : public ICanonicalUrl,
-                                  public Initializable<Segment>
+                                  public Initializable<Segment>,
+                                  public Indexable<Segment>
         {
             public:
                 SegmentInfoCommon( ICanonicalUrl *parent = NULL );
diff --git a/modules/demux/adaptative/playlist/SegmentInformation.cpp b/modules/demux/adaptative/playlist/SegmentInformation.cpp
index b0dcea9..091fd02 100644
--- a/modules/demux/adaptative/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptative/playlist/SegmentInformation.cpp
@@ -93,6 +93,14 @@ vector<ISegment *> SegmentInformation::getSegments(SegmentInfoType type) const
                 }
             }
         }
+        break;
+
+        case INFOTYPE_INDEX:
+        {
+            ISegment *segment = getSegment( INFOTYPE_INDEX );
+            if( segment )
+                retSegments.push_back( segment );
+        }
 
         default:
         break;
@@ -150,7 +158,17 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
             break;
 
         case INFOTYPE_INDEX:
-            //returned with media for now;
+            if( segBase && segBase->indexSegment.Get() )
+            {
+                segment = segBase->indexSegment.Get();
+            }
+            else if( segList && segList->indexSegment.Get() )
+            {
+                segment = segList->indexSegment.Get();
+            }
+            // templated index ?
+            break;
+
         default:
             break;
     }
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 777ce90..0696e71 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -265,9 +265,9 @@ size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformat
         size_t start = 0, end = 0;
         if (std::sscanf(segmentBaseNode->getAttributeValue("indexRange").c_str(), "%zu-%zu", &start, &end) == 2)
         {
-            seg = new DashIndexSegment(info);
-            seg->setByteRange(start, end);
-            list->addSegment(seg);
+            IndexSegment *index = new DashIndexSegment(info);
+            index->setByteRange(start, end);
+            list->indexSegment.Set(index);
             /* index must be before data, so data starts at index end */
             seg = new Segment(info);
             seg->setByteRange(end + 1, 0);



More information about the vlc-commits mailing list