Commit a3195dae authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: fix scheme handling in segments

parent 77c4f92c
...@@ -182,7 +182,7 @@ Segment::~Segment() ...@@ -182,7 +182,7 @@ Segment::~Segment()
void Segment::setSourceUrl ( const std::string &url ) void Segment::setSourceUrl ( const std::string &url )
{ {
if ( url.empty() == false ) if ( url.empty() == false )
this->sourceUrl = url; this->sourceUrl = Url(url);
} }
void Segment::debug(vlc_object_t *obj, int indent) const void Segment::debug(vlc_object_t *obj, int indent) const
...@@ -204,10 +204,17 @@ void Segment::debug(vlc_object_t *obj, int indent) const ...@@ -204,10 +204,17 @@ void Segment::debug(vlc_object_t *obj, int indent) const
Url Segment::getUrlSegment() const Url Segment::getUrlSegment() const
{ {
if(sourceUrl.hasScheme())
{
return sourceUrl;
}
else
{
Url ret = getParentUrlSegment(); Url ret = getParentUrlSegment();
if (!sourceUrl.empty()) if (!sourceUrl.empty())
ret.append(sourceUrl); ret.append(sourceUrl);
return ret; return ret;
}
} }
Chunk* Segment::toChunk(size_t index, BaseRepresentation *ctxrep) Chunk* Segment::toChunk(size_t index, BaseRepresentation *ctxrep)
......
...@@ -104,7 +104,7 @@ namespace adaptative ...@@ -104,7 +104,7 @@ namespace adaptative
protected: protected:
std::vector<SubSegment *> subsegments; std::vector<SubSegment *> subsegments;
std::string sourceUrl; Url sourceUrl;
int size; int size;
}; };
......
...@@ -35,18 +35,6 @@ BaseSegmentTemplate::BaseSegmentTemplate( ICanonicalUrl *parent ) : ...@@ -35,18 +35,6 @@ BaseSegmentTemplate::BaseSegmentTemplate( ICanonicalUrl *parent ) :
{ {
} }
Url BaseSegmentTemplate::getUrlSegment() const
{
Url ret = getParentUrlSegment();
if (!sourceUrl.empty())
{
ret.append(Url::Component(
sourceUrl,
dynamic_cast<const MediaSegmentTemplate *>(this)) /* casts to NULL if != */
);
}
return ret;
}
MediaSegmentTemplate::MediaSegmentTemplate( SegmentInformation *parent ) : MediaSegmentTemplate::MediaSegmentTemplate( SegmentInformation *parent ) :
BaseSegmentTemplate( parent ), Timelineable(), TimescaleAble( parent ) BaseSegmentTemplate( parent ), Timelineable(), TimescaleAble( parent )
...@@ -67,6 +55,11 @@ void MediaSegmentTemplate::mergeWith(MediaSegmentTemplate *updated, mtime_t prun ...@@ -67,6 +55,11 @@ void MediaSegmentTemplate::mergeWith(MediaSegmentTemplate *updated, mtime_t prun
} }
} }
void MediaSegmentTemplate::setSourceUrl(const std::string &url)
{
sourceUrl = Url(Url::Component(url, this));
}
InitSegmentTemplate::InitSegmentTemplate( ICanonicalUrl *parent ) : InitSegmentTemplate::InitSegmentTemplate( ICanonicalUrl *parent ) :
BaseSegmentTemplate(parent) BaseSegmentTemplate(parent)
{ {
......
...@@ -40,7 +40,6 @@ namespace adaptative ...@@ -40,7 +40,6 @@ namespace adaptative
{ {
public: public:
BaseSegmentTemplate( ICanonicalUrl * = NULL ); BaseSegmentTemplate( ICanonicalUrl * = NULL );
virtual Url getUrlSegment() const; /* reimpl */
}; };
class MediaSegmentTemplate : public BaseSegmentTemplate, class MediaSegmentTemplate : public BaseSegmentTemplate,
...@@ -50,6 +49,7 @@ namespace adaptative ...@@ -50,6 +49,7 @@ namespace adaptative
{ {
public: public:
MediaSegmentTemplate( SegmentInformation * = NULL ); MediaSegmentTemplate( SegmentInformation * = NULL );
virtual void setSourceUrl( const std::string &url ); /* reimpl */
void mergeWith( MediaSegmentTemplate *, mtime_t ); void mergeWith( MediaSegmentTemplate *, mtime_t );
Property<size_t> startNumber; Property<size_t> startNumber;
}; };
......
...@@ -45,6 +45,11 @@ bool Url::hasScheme() const ...@@ -45,6 +45,11 @@ bool Url::hasScheme() const
return components[0].b_scheme; return components[0].b_scheme;
} }
bool Url::empty() const
{
return components.empty();
}
Url & Url::prepend(const Component & comp) Url & Url::prepend(const Component & comp)
{ {
components.insert(components.begin(), comp); components.insert(components.begin(), comp);
......
...@@ -57,6 +57,7 @@ namespace adaptative ...@@ -57,6 +57,7 @@ namespace adaptative
Url(const Component &); Url(const Component &);
explicit Url(const std::string &); explicit Url(const std::string &);
bool hasScheme() const; bool hasScheme() const;
bool empty() const;
Url & prepend(const Component &); Url & prepend(const Component &);
Url & append(const Component &); Url & append(const Component &);
Url & append(const Url &); Url & append(const Url &);
......
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