[vlc-commits] demux: dash: parse SegmentTimeline

Francois Cartegnie git at videolan.org
Mon Jan 12 20:22:06 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jan  7 02:26:18 2015 +0100| [0d3181d59a936e5ecf4c14a39f8a79b529740f0f] | committer: Francois Cartegnie

demux: dash: parse SegmentTimeline

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

 modules/demux/dash/mpd/IsoffMainParser.cpp |   34 ++++++++++++++++++++++++++++
 modules/demux/dash/mpd/IsoffMainParser.h   |    1 +
 2 files changed, 35 insertions(+)

diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 16d3524..f781369 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -28,6 +28,7 @@
 
 #include "IsoffMainParser.h"
 #include "SegmentTemplate.h"
+#include "SegmentTimeline.h"
 #include "ProgramInformation.h"
 #include "xml/DOMHelper.h"
 #include <vlc_strings.h>
@@ -136,6 +137,8 @@ size_t IsoffMainParser::parseSegmentTemplate(Node *templateNode, SegmentInformat
     mediaTemplate->initialisationSegment.Set(initTemplate);
     info->setSegmentTemplate(mediaTemplate);
 
+    parseTimeline(DOMHelper::getFirstChildElementByName(templateNode, "SegmentTimeline"), mediaTemplate);
+
     total += ( mediaTemplate != NULL );
 
     return total;
@@ -340,6 +343,37 @@ void IsoffMainParser::parseInitSegment(Node *initNode, Initializable<Segment> *i
     init->initialisationSegment.Set(seg);
 }
 
+void IsoffMainParser::parseTimeline(Node *node, Timelineable *timelineable)
+{
+    if(!node)
+        return;
+
+    SegmentTimeline *timeline = new (std::nothrow) SegmentTimeline();
+    if(timeline)
+    {
+        std::vector<Node *> elements = DOMHelper::getElementByTagName(node, "S", false);
+        std::vector<Node *>::const_iterator it;
+        for(it = elements.begin(); it != elements.end(); it++)
+        {
+            const Node *s = *it;
+            if(!s->hasAttribute("d")) /* Mandatory */
+                continue;
+            mtime_t d = Integer<mtime_t>(s->getAttributeValue("d"));
+            mtime_t r = 0; // never repeats by default
+            if(s->hasAttribute("r"))
+                r = Integer<uint64_t>(s->getAttributeValue("r"));
+            if(s->hasAttribute("t"))
+            {
+                mtime_t t = Integer<mtime_t>(s->getAttributeValue("t"));
+                timeline->addElement(d, r, t);
+            }
+            else timeline->addElement(d, r);
+
+            timelineable->segmentTimeline.Set(timeline);
+        }
+    }
+}
+
 void IsoffMainParser::parseProgramInformation(Node * node, MPD *mpd)
 {
     if(!node)
diff --git a/modules/demux/dash/mpd/IsoffMainParser.h b/modules/demux/dash/mpd/IsoffMainParser.h
index ba36e11..0891b37 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.h
+++ b/modules/demux/dash/mpd/IsoffMainParser.h
@@ -54,6 +54,7 @@ namespace dash
                 void    setAdaptationSets   (dash::xml::Node *periodNode, Period *period);
                 void    setRepresentations  (dash::xml::Node *adaptationSetNode, AdaptationSet *adaptationSet);
                 void    parseInitSegment    (dash::xml::Node *, Initializable<Segment> *);
+                void    parseTimeline       (dash::xml::Node *, Timelineable *);
                 void    parsePeriods        (dash::xml::Node *);
                 size_t  parseSegmentInformation(dash::xml::Node *, SegmentInformation *);
                 void    parseSegmentBase    (dash::xml::Node *, SegmentInformation *);



More information about the vlc-commits mailing list