[vlc-commits] demux: dash: compute timelines boundaries

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


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 12 19:59:03 2015 +0100| [2f04d039996510ee1248e20a638f40f4ae5e75d1] | committer: Francois Cartegnie

demux: dash: compute timelines boundaries

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

 modules/demux/dash/mpd/MPD.cpp             |   19 +++++++++++++++++++
 modules/demux/dash/mpd/MPD.h               |    1 +
 modules/demux/dash/mpd/SegmentTimeline.cpp |   16 ++++++++++++++++
 modules/demux/dash/mpd/SegmentTimeline.h   |    2 ++
 4 files changed, 38 insertions(+)

diff --git a/modules/demux/dash/mpd/MPD.cpp b/modules/demux/dash/mpd/MPD.cpp
index 7baea47..f55556f 100644
--- a/modules/demux/dash/mpd/MPD.cpp
+++ b/modules/demux/dash/mpd/MPD.cpp
@@ -135,6 +135,25 @@ Period* MPD::getNextPeriod(Period *period)
     return NULL;
 }
 
+void MPD::getTimeLinesBoundaries(mtime_t *min, mtime_t *max) const
+{
+    *min = *max = 0;
+    for(size_t i = 0; i < periods.size(); i++)
+    {
+        std::vector<SegmentTimeline *> timelines;
+        periods.at(i)->collectTimelines(&timelines);
+
+        for(size_t j = 0; j < timelines.size(); j++)
+        {
+            const SegmentTimeline *timeline = timelines.at(j);
+            if(timeline->start() > *min)
+                *min = timeline->start();
+            if(!*max || timeline->end() < *max)
+                *max = timeline->end();
+        }
+    }
+}
+
 void MPD::mergeWith(MPD *updatedMPD)
 {
     availabilityEndTime.Set(updatedMPD->availabilityEndTime.Get());
diff --git a/modules/demux/dash/mpd/MPD.h b/modules/demux/dash/mpd/MPD.h
index 8e3e8bd..d3908e1 100644
--- a/modules/demux/dash/mpd/MPD.h
+++ b/modules/demux/dash/mpd/MPD.h
@@ -61,6 +61,7 @@ namespace dash
                 virtual Period*                         getNextPeriod(Period *period);
 
                 void                mergeWith(MPD *);
+                void                getTimeLinesBoundaries(mtime_t *, mtime_t *) const;
 
                 Property<time_t>                    duration;
                 Property<time_t>                    playbackStart;
diff --git a/modules/demux/dash/mpd/SegmentTimeline.cpp b/modules/demux/dash/mpd/SegmentTimeline.cpp
index d7140c0..e67cae0 100644
--- a/modules/demux/dash/mpd/SegmentTimeline.cpp
+++ b/modules/demux/dash/mpd/SegmentTimeline.cpp
@@ -176,6 +176,22 @@ void SegmentTimeline::mergeWith(SegmentTimeline &other)
     }
 }
 
+mtime_t SegmentTimeline::start() const
+{
+    if(elements.empty())
+        return 0;
+    return CLOCK_FREQ * elements.front()->t / inheritTimescale();
+}
+
+mtime_t SegmentTimeline::end() const
+{
+    if(elements.empty())
+        return 0;
+    const Element *last = elements.back();
+    mtime_t scaled = last->t + last->d * (last->r + 1);
+    return CLOCK_FREQ * scaled / inheritTimescale();
+}
+
 SegmentTimeline::Element::Element(mtime_t d_, uint64_t r_, mtime_t t_)
 {
     d = d_;
diff --git a/modules/demux/dash/mpd/SegmentTimeline.h b/modules/demux/dash/mpd/SegmentTimeline.h
index fec2771..3d40c18 100644
--- a/modules/demux/dash/mpd/SegmentTimeline.h
+++ b/modules/demux/dash/mpd/SegmentTimeline.h
@@ -43,6 +43,8 @@ namespace dash
                 mtime_t getScaledPlaybackTimeByElementNumber(uint64_t) const;
                 size_t prune(mtime_t);
                 void mergeWith(SegmentTimeline &);
+                mtime_t start() const;
+                mtime_t end() const;
 
             private:
                 std::list<Element *> elements;



More information about the vlc-commits mailing list