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

demux: dash: fix TimeLine class

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