[vlc-commits] dash: Allow SegmentTimeline to be queried for a "S" element.

Hugo Beauzée-Luyssen git at videolan.org
Tue Jan 24 23:22:00 CET 2012


vlc/vlc-1.2 | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Jan  5 14:53:49 2012 +0100| [de45860f99ff6e58f60642b61bf6b486635ce701] | committer: Jean-Baptiste Kempf

dash: Allow SegmentTimeline to be queried for a "S" element.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 8158205e527712886aa05a644d508e406a024e68)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/stream_filter/dash/mpd/SegmentTimeline.cpp |   24 ++++++++++++++++++++
 modules/stream_filter/dash/mpd/SegmentTimeline.h   |    2 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/modules/stream_filter/dash/mpd/SegmentTimeline.cpp b/modules/stream_filter/dash/mpd/SegmentTimeline.cpp
index c18e537..f97aeae 100644
--- a/modules/stream_filter/dash/mpd/SegmentTimeline.cpp
+++ b/modules/stream_filter/dash/mpd/SegmentTimeline.cpp
@@ -26,6 +26,8 @@
 #include <vlc_common.h>
 #include <vlc_arrays.h>
 
+#include <iostream>
+
 using namespace dash::mpd;
 
 SegmentTimeline::SegmentTimeline() :
@@ -53,6 +55,28 @@ void dash::mpd::SegmentTimeline::addElement(dash::mpd::SegmentTimeline::Element
     this->elements.push_back( e );
 }
 
+const SegmentTimeline::Element*    SegmentTimeline::getElement( mtime_t dts ) const
+{
+    if ( this->elements.size() == 0 )
+        return NULL;
+    int64_t     targetT = dts * this->timescale / 1000000;
+    targetT -= this->elements.front()->t;
+
+    std::list<Element*>::const_iterator     it = this->elements.begin();
+    std::list<Element*>::const_iterator     end = this->elements.end();
+    const Element*  res = NULL;
+
+    while ( it != end )
+    {
+        if ( (*it)->t > targetT )
+            return res;
+        res = *it;
+        ++it;
+    }
+    std::cerr << "No more element to be used." << std::endl;
+    return NULL;
+}
+
 dash::mpd::SegmentTimeline::Element::Element() :
     r( 0 )
 {
diff --git a/modules/stream_filter/dash/mpd/SegmentTimeline.h b/modules/stream_filter/dash/mpd/SegmentTimeline.h
index efc5db7..c7d5cde 100644
--- a/modules/stream_filter/dash/mpd/SegmentTimeline.h
+++ b/modules/stream_filter/dash/mpd/SegmentTimeline.h
@@ -27,6 +27,7 @@
 #include <sys/types.h>
 #include <list>
 #include <stdint.h>
+#include <vlc_common.h>
 
 namespace dash
 {
@@ -47,6 +48,7 @@ namespace dash
                 int                     getTimescale() const;
                 void                    setTimescale( int timescale );
                 void                    addElement( Element* e );
+                const Element*          getElement( mtime_t dts ) const;
 
             private:
                 int                     timescale;



More information about the vlc-commits mailing list