Commit 19eaa954 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: fix TimeLine class

parent d92a169b
...@@ -33,17 +33,25 @@ ...@@ -33,17 +33,25 @@
using namespace dash::mpd; using namespace dash::mpd;
Timelineable::Timelineable()
{
segmentTimeline.Set(NULL);
}
Timelineable::~Timelineable()
{
delete segmentTimeline.Get();
}
SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) : SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
ICanonicalUrl( parent ), Initializable(), ICanonicalUrl( parent ), Initializable(),
duration( -1 ), duration( -1 ),
startIndex( 0 ), startIndex( 0 )
segmentTimeline( NULL )
{ {
} }
SegmentInfoCommon::~SegmentInfoCommon() SegmentInfoCommon::~SegmentInfoCommon()
{ {
delete this->segmentTimeline;
} }
time_t SegmentInfoCommon::getDuration() const time_t SegmentInfoCommon::getDuration() const
...@@ -73,17 +81,6 @@ void SegmentInfoCommon::appendBaseURL(const std::string &url) ...@@ -73,17 +81,6 @@ void SegmentInfoCommon::appendBaseURL(const std::string &url)
this->baseURLs.push_back( url ); this->baseURLs.push_back( url );
} }
const SegmentTimeline *SegmentInfoCommon::getSegmentTimeline() const
{
return this->segmentTimeline;
}
void SegmentInfoCommon::setSegmentTimeline( const SegmentTimeline *segTl )
{
if ( segTl != NULL )
this->segmentTimeline = segTl;
}
Url SegmentInfoCommon::getUrlSegment() const Url SegmentInfoCommon::getUrlSegment() const
{ {
Url ret = getParentUrlSegment(); Url ret = getParentUrlSegment();
......
...@@ -52,6 +52,14 @@ namespace dash ...@@ -52,6 +52,14 @@ namespace dash
Property<T *> initialisationSegment; Property<T *> initialisationSegment;
}; };
class Timelineable
{
public:
Timelineable();
~Timelineable();
Property<SegmentTimeline *> segmentTimeline;
};
class SegmentInfoCommon : public ICanonicalUrl, class SegmentInfoCommon : public ICanonicalUrl,
public Initializable<Segment> public Initializable<Segment>
{ {
...@@ -63,15 +71,12 @@ namespace dash ...@@ -63,15 +71,12 @@ namespace dash
int getStartIndex() const; int getStartIndex() const;
void setStartIndex( int startIndex ); void setStartIndex( int startIndex );
void appendBaseURL( const std::string& url ); void appendBaseURL( const std::string& url );
const SegmentTimeline* getSegmentTimeline() const;
void setSegmentTimeline( const SegmentTimeline *segTl );
virtual Url getUrlSegment() const; /* impl */ virtual Url getUrlSegment() const; /* impl */
private: private:
time_t duration; time_t duration;
int startIndex; int startIndex;
std::list<std::string> baseURLs; std::list<std::string> baseURLs;
const SegmentTimeline* segmentTimeline;
}; };
} }
} }
......
...@@ -50,7 +50,7 @@ Url BaseSegmentTemplate::getUrlSegment() const ...@@ -50,7 +50,7 @@ Url BaseSegmentTemplate::getUrlSegment() const
} }
MediaSegmentTemplate::MediaSegmentTemplate( ICanonicalUrl *parent ) : MediaSegmentTemplate::MediaSegmentTemplate( ICanonicalUrl *parent ) :
BaseSegmentTemplate( parent ) BaseSegmentTemplate( parent ), Timelineable()
{ {
debugName = "SegmentTemplate"; debugName = "SegmentTemplate";
classId = Segment::CLASSID_SEGMENT; classId = Segment::CLASSID_SEGMENT;
......
...@@ -43,7 +43,8 @@ namespace dash ...@@ -43,7 +43,8 @@ namespace dash
}; };
class MediaSegmentTemplate : public BaseSegmentTemplate, class MediaSegmentTemplate : public BaseSegmentTemplate,
public Initializable<InitSegmentTemplate> public Initializable<InitSegmentTemplate>,
public Timelineable
{ {
public: public:
MediaSegmentTemplate( ICanonicalUrl * = NULL ); MediaSegmentTemplate( ICanonicalUrl * = NULL );
......
...@@ -27,72 +27,29 @@ ...@@ -27,72 +27,29 @@
#include "SegmentTimeline.h" #include "SegmentTimeline.h"
#include <vlc_common.h>
#include <vlc_arrays.h>
#include <iostream>
using namespace dash::mpd; using namespace dash::mpd;
SegmentTimeline::SegmentTimeline() : SegmentTimeline::SegmentTimeline()
timescale( -1 )
{ {
} }
SegmentTimeline::~SegmentTimeline() SegmentTimeline::~SegmentTimeline()
{ {
vlc_delete_all( this->elements ); std::list<Element *>::iterator it;
} for(it = elements.begin(); it != elements.end(); it++)
delete *it;
int dash::mpd::SegmentTimeline::getTimescale() const
{
return this->timescale;
}
void dash::mpd::SegmentTimeline::setTimescale(int timescale)
{
this->timescale = timescale;
}
void dash::mpd::SegmentTimeline::addElement(dash::mpd::SegmentTimeline::Element *e)
{
int64_t offset = 0;
for ( int i = 0; i < e->r; ++i )
{
this->elements.push_back( e );
e = new SegmentTimeline::Element( *e );
offset += e->d;
e->t += offset;
}
this->elements.push_back( e );
}
const SegmentTimeline::Element* SegmentTimeline::getElement( unsigned int index ) const
{
if ( this->elements.size() <= index )
return NULL;
std::list<Element*>::const_iterator it = this->elements.begin();
std::list<Element*>::const_iterator end = this->elements.end();
unsigned int i = 0;
while ( it != end )
{
if ( i == index )
return *it;
++it;
++i;
}
return NULL;
} }
dash::mpd::SegmentTimeline::Element::Element() : void SegmentTimeline::addElement(mtime_t d, uint64_t r, mtime_t t)
r( 0 )
{ {
Element *element = new (std::nothrow) Element(d, r, t);
if(element)
elements.push_back(element);
} }
SegmentTimeline::Element::Element(const SegmentTimeline::Element &e) : SegmentTimeline::Element::Element(mtime_t d_, uint64_t r_, mtime_t t_)
t( e.t ),
d( e.d ),
r( 0 )
{ {
d = d_;
t = t_;
r = r_;
} }
...@@ -24,9 +24,8 @@ ...@@ -24,9 +24,8 @@
#ifndef SEGMENTTIMELINE_H #ifndef SEGMENTTIMELINE_H
#define SEGMENTTIMELINE_H #define SEGMENTTIMELINE_H
#include <sys/types.h> #include <vlc_common.h>
#include <list> #include <list>
#include <stdint.h>
namespace dash namespace dash
{ {
...@@ -34,25 +33,24 @@ namespace dash ...@@ -34,25 +33,24 @@ namespace dash
{ {
class SegmentTimeline class SegmentTimeline
{ {
class Element;
public: public:
struct Element
{
Element();
Element( const Element& e );
int64_t t;
int64_t d;
int r;
};
SegmentTimeline(); SegmentTimeline();
~SegmentTimeline(); virtual ~SegmentTimeline();
int getTimescale() const; void addElement(mtime_t d, uint64_t r = 0, mtime_t t = 0);
void setTimescale( int timescale );
void addElement( Element* e );
const Element* getElement( unsigned int index ) const;
private: private:
int timescale; std::list<Element *> elements;
std::list<Element*> elements;
class Element
{
public:
Element(mtime_t, uint64_t, mtime_t);
mtime_t t;
mtime_t d;
uint64_t r;
};
}; };
} }
} }
......
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