Commit 1850ed6c authored by François Cartegnie's avatar François Cartegnie 🤞

demux: dash: remove BaseUrl

parent f1b37e54
......@@ -293,7 +293,6 @@ libdash_plugin_la_SOURCES += \
demux/adaptative/playlist/BasePeriod.h \
demux/adaptative/playlist/BaseRepresentation.cpp \
demux/adaptative/playlist/BaseRepresentation.h \
demux/adaptative/playlist/BaseUrl.h \
demux/adaptative/playlist/CommonAttributesElements.cpp \
demux/adaptative/playlist/CommonAttributesElements.h \
demux/adaptative/playlist/ICanonicalUrl.hpp \
......
......@@ -26,7 +26,6 @@
#include "../tools/Helper.h"
#include "BasePeriod.h"
#include "SegmentTimeline.h"
#include "BaseUrl.h"
#include <vlc_common.h>
#include <vlc_stream.h>
#include <sstream>
......@@ -51,9 +50,6 @@ AbstractPlaylist::~AbstractPlaylist()
{
for(size_t i = 0; i < this->periods.size(); i++)
delete(this->periods.at(i));
for(size_t i = 0; i < this->baseUrls.size(); i++)
delete(this->baseUrls.at(i));
}
const std::vector<BasePeriod *>& AbstractPlaylist::getPeriods()
......@@ -61,7 +57,7 @@ const std::vector<BasePeriod *>& AbstractPlaylist::getPeriods()
return periods;
}
void AbstractPlaylist::addBaseUrl(BaseUrl *url)
void AbstractPlaylist::addBaseUrl(const std::string &url)
{
baseUrls.push_back(url);
}
......@@ -78,7 +74,7 @@ void AbstractPlaylist::setType(const std::string &type_)
Url AbstractPlaylist::getUrlSegment() const
{
if (!baseUrls.empty())
return Url(baseUrls.front()->getUrl());
return Url(baseUrls.front());
else
{
std::stringstream ss;
......
......@@ -32,7 +32,6 @@ namespace adaptative
namespace playlist
{
class BasePeriod;
class BaseUrl;
class AbstractPlaylist : public ICanonicalUrl
{
......@@ -45,7 +44,7 @@ namespace adaptative
virtual void debug() = 0;
void addPeriod (BasePeriod *period);
void addBaseUrl (BaseUrl *url);
void addBaseUrl (const std::string &);
virtual Url getUrlSegment() const; /* impl */
vlc_object_t * getVLCObject() const;
......@@ -69,7 +68,7 @@ namespace adaptative
protected:
stream_t *stream;
std::vector<BasePeriod *> periods;
std::vector<BaseUrl *> baseUrls;
std::vector<std::string> baseUrls;
std::string type;
};
}
......
......@@ -79,11 +79,6 @@ bool BaseAdaptationSet::getBitstreamSwitching () const
return this->isBitstreamSwitching;
}
Url BaseAdaptationSet::getUrlSegment() const
{
return getParentUrlSegment();
}
std::vector<std::string> BaseAdaptationSet::toString(int indent) const
{
std::vector<std::string> ret;
......
......@@ -50,7 +50,6 @@ namespace adaptative
void setBitstreamSwitching(bool value);
bool getBitstreamSwitching() const;
void addRepresentation( BaseRepresentation *rep );
virtual Url getUrlSegment() const; /* reimpl */
std::vector<std::string> toString(int = 0) const;
protected:
......
......@@ -87,14 +87,6 @@ BaseAdaptationSet * BasePeriod::getAdaptationSet(Streams::Type type) const
return NULL;
}
Url BasePeriod::getUrlSegment() const
{
if( baseUrl.Get() )
return *(baseUrl.Get());
else
return getParentUrlSegment();
}
std::vector<std::string> BasePeriod::toString(int indent) const
{
std::vector<std::string> ret;
......
......@@ -48,10 +48,8 @@ namespace adaptative
void addAdaptationSet (BaseAdaptationSet *AdaptationSet);
std::vector<std::string> toString (int = 0) const;
virtual Url getUrlSegment() const; /* reimpl */
virtual mtime_t getPeriodStart() const; /* reimpl */
Property<Url *> baseUrl;
Property<mtime_t> duration;
Property<mtime_t> startTime;
......
......@@ -29,7 +29,6 @@
#include "BaseRepresentation.h"
#include "BaseAdaptationSet.h"
#include "BaseUrl.h"
#include "SegmentTemplate.h"
using namespace adaptative::playlist;
......@@ -38,14 +37,12 @@ BaseRepresentation::BaseRepresentation( BaseAdaptationSet *set, AbstractPlaylist
SegmentInformation( set ),
playlist ( playlist_ ),
adaptationSet ( set ),
bandwidth (0),
baseUrl ( NULL )
bandwidth (0)
{
}
BaseRepresentation::~BaseRepresentation ()
{
delete baseUrl;
}
uint64_t BaseRepresentation::getBandwidth () const
......@@ -58,11 +55,6 @@ void BaseRepresentation::setBandwidth( uint64_t bandwidth )
this->bandwidth = bandwidth;
}
void BaseRepresentation::setBaseUrl(BaseUrl *base)
{
baseUrl = base;
}
std::vector<std::string> BaseRepresentation::toString(int indent) const
{
std::vector<std::string> ret;
......@@ -77,14 +69,6 @@ std::vector<std::string> BaseRepresentation::toString(int indent) const
return ret;
}
Url BaseRepresentation::getUrlSegment() const
{
Url ret = getParentUrlSegment();
if (baseUrl)
ret.append(baseUrl->getUrl());
return ret;
}
AbstractPlaylist * BaseRepresentation::getPlaylist() const
{
return playlist;
......
......@@ -36,7 +36,6 @@ namespace adaptative
{
class BaseAdaptationSet;
class AbstractPlaylist;
class BaseUrl;
class BaseSegmentTemplate;
class BaseRepresentation : public CommonAttributesElements,
......@@ -55,11 +54,9 @@ namespace adaptative
uint64_t getBandwidth () const;
void setBandwidth ( uint64_t bandwidth );
void setBaseUrl (BaseUrl *baseUrl);
AbstractPlaylist* getPlaylist () const;
std::vector<std::string> toString(int = 0) const;
virtual Url getUrlSegment () const; /* impl */
/* for segment templates */
virtual std::string contextualize(size_t, const std::string &,
......@@ -69,7 +66,6 @@ namespace adaptative
AbstractPlaylist *playlist;
BaseAdaptationSet *adaptationSet;
uint64_t bandwidth;
BaseUrl *baseUrl;
};
}
}
......
/*
* BaseUrl.h
*****************************************************************************
* Copyright (C) 2010 - 2011 Klagenfurt University
*
* Created on: Aug 10, 2010
* Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
* Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef BASEURL_H_
#define BASEURL_H_
#include <string>
namespace adaptative
{
namespace playlist
{
class BaseUrl
{
public:
BaseUrl (const std::string& url) : url(url) {}
virtual ~BaseUrl() {}
const std::string& getUrl() const { return this->url; }
private:
std::string url;
};
}
}
#endif /* BASEURL_H_ */
......@@ -327,6 +327,21 @@ void SegmentInformation::setBitstreamSwitching(bool bitswitch)
bitswitch_policy = (bitswitch) ? BITSWITCH_YES : BITSWITCH_NO;
}
Url SegmentInformation::getUrlSegment() const
{
if(baseUrl.Get() && baseUrl.Get()->hasScheme())
{
return *(baseUrl.Get());
}
else
{
Url ret = getParentUrlSegment();
if (baseUrl.Get())
ret.append(*(baseUrl.Get()));
return ret;
}
}
SegmentBase * SegmentInformation::inheritSegmentBase() const
{
if(segmentBase)
......
......@@ -88,6 +88,8 @@ namespace adaptative
void setSegmentBase(SegmentBase *);
void setSegmentTemplate(MediaSegmentTemplate *);
void setBitstreamSwitching(bool);
virtual Url getUrlSegment() const; /* impl */
Property<Url *> baseUrl;
private:
void init();
......
......@@ -37,6 +37,19 @@ Url::Url(const std::string &str)
prepend(Component(str));
}
bool Url::hasScheme() const
{
if(components.empty())
return false;
const Component *comp = &components[0];
if(comp->component.compare(0, 7, "http://") &&
comp->component.compare(0, 8, "https://"))
return false;
return true;
}
Url & Url::prepend(const Component & comp)
{
components.insert(components.begin(), comp);
......
......@@ -52,6 +52,7 @@ namespace adaptative
Url();
Url(const Component &);
explicit Url(const std::string &);
bool hasScheme() const;
Url & prepend(const Component &);
Url & append(const Component &);
Url & append(const Url &);
......
......@@ -19,7 +19,6 @@
*****************************************************************************/
#include "IMPDParser.h"
#include "xml/DOMHelper.h"
#include "../adaptative/playlist/BaseUrl.h"
using namespace dash::mpd;
using namespace dash::xml;
......@@ -37,10 +36,7 @@ void IMPDParser::setMPDBaseUrl(Node *root)
std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(root, "BaseURL");
for(size_t i = 0; i < baseUrls.size(); i++)
{
BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
mpd->addBaseUrl(url);
}
mpd->addBaseUrl(baseUrls.at(i)->getText());
}
MPD* IMPDParser::getMPD()
......
......@@ -32,7 +32,6 @@
#include "../adaptative/playlist/SegmentBase.h"
#include "../adaptative/playlist/SegmentList.h"
#include "../adaptative/playlist/SegmentTimeline.h"
#include "../adaptative/playlist/BaseUrl.h"
#include "Representation.h"
#include "Period.h"
#include "AdaptationSet.h"
......@@ -196,6 +195,10 @@ void IsoffMainParser::setAdaptationSets (Node *periodNode, Period *period)
if((*it)->hasAttribute("mimeType"))
adaptationSet->setMimeType((*it)->getAttributeValue("mimeType"));
Node *baseUrl = DOMHelper::getFirstChildElementByName((*it), "BaseURL");
if(baseUrl)
adaptationSet->baseUrl.Set(new Url(baseUrl->getText()));
parseSegmentInformation( *it, adaptationSet );
setRepresentations((*it), adaptationSet);
......@@ -213,7 +216,7 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation
std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL");
if(!baseUrls.empty())
currentRepresentation->setBaseUrl( new BaseUrl( baseUrls.front()->getText() ) );
currentRepresentation->baseUrl.Set(new Url(baseUrls.front()->getText()));
if(repNode->hasAttribute("id"))
currentRepresentation->setId(repNode->getAttributeValue("id"));
......
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