Commit 8158205e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

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

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent a90c1374
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_arrays.h> #include <vlc_arrays.h>
#include <iostream>
using namespace dash::mpd; using namespace dash::mpd;
SegmentTimeline::SegmentTimeline() : SegmentTimeline::SegmentTimeline() :
...@@ -53,6 +55,28 @@ void dash::mpd::SegmentTimeline::addElement(dash::mpd::SegmentTimeline::Element ...@@ -53,6 +55,28 @@ void dash::mpd::SegmentTimeline::addElement(dash::mpd::SegmentTimeline::Element
this->elements.push_back( e ); 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() : dash::mpd::SegmentTimeline::Element::Element() :
r( 0 ) r( 0 )
{ {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <list> #include <list>
#include <stdint.h> #include <stdint.h>
#include <vlc_common.h>
namespace dash namespace dash
{ {
...@@ -47,6 +48,7 @@ namespace dash ...@@ -47,6 +48,7 @@ namespace dash
int getTimescale() const; int getTimescale() const;
void setTimescale( int timescale ); void setTimescale( int timescale );
void addElement( Element* e ); void addElement( Element* e );
const Element* getElement( mtime_t dts ) const;
private: private:
int timescale; int timescale;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment