stream_filter/dash/mpd/SegmentTimeline.h \
stream_filter/dash/mpd/TrickModeType.cpp \
stream_filter/dash/mpd/TrickModeType.h \
+ stream_filter/dash/mpd/Url.cpp \
+ stream_filter/dash/mpd/Url.hpp \
stream_filter/dash/mp4/AtomsReader.cpp \
stream_filter/dash/mp4/AtomsReader.hpp \
stream_filter/dash/xml/DOMHelper.cpp \
return this->isBitstreamSwitching;
}
-std::string AdaptationSet::getUrlSegment() const
+Url AdaptationSet::getUrlSegment() const
{
return getParentUrlSegment();
}
void setBitstreamSwitching(bool value);
bool getBitstreamSwitching() const;
void addRepresentation( Representation *rep );
- virtual std::string getUrlSegment() const; /* reimpl */
+ virtual Url getUrlSegment() const; /* reimpl */
private:
bool subsegmentAlignmentFlag;
#ifndef CANONICALURL_HPP
#define CANONICALURL_HPP
-#include <string>
+#include "Url.hpp"
namespace dash
{
{
public:
ICanonicalUrl( const ICanonicalUrl *parent = NULL ) { parentUrlMember = parent; }
- virtual std::string getUrlSegment() const = 0;
+ virtual Url getUrlSegment() const = 0;
protected:
- std::string getParentUrlSegment() const {
+ Url getParentUrlSegment() const {
return (parentUrlMember) ? parentUrlMember->getUrlSegment()
- : std::string();
+ : Url();
}
private:
if(!baseUrls.empty())
currentRepresentation->setBaseUrl( new BaseUrl( baseUrls.front()->getText() ) );
+ if(repNode->hasAttribute("id"))
+ currentRepresentation->setId(repNode->getAttributeValue("id"));
+
if(repNode->hasAttribute("width"))
this->currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str()));
static_cast<std::string>(mpd->getProfile()).c_str(),
mpd->getDuration(),
mpd->getMinBufferTime());
- msg_Dbg(p_stream, "BaseUrl=%s", mpd->getUrlSegment().c_str());
+ msg_Dbg(p_stream, "BaseUrl=%s", mpd->getUrlSegment().toString().c_str());
std::vector<Period *>::const_iterator i;
for(i = mpd->getPeriods().begin(); i != mpd->getPeriods().end(); i++)
{
return profile;
}
-
-std::string MPD::getUrlSegment() const
+Url MPD::getUrlSegment() const
{
if (!baseUrls.empty())
- return baseUrls.front()->getUrl();
+ return Url(baseUrls.front()->getUrl());
else
{
std::stringstream ss;
ss << stream->psz_access << "://" << Helper::getDirectoryPath(stream->psz_path) << "/";
- return ss.str();
+ return Url(ss.str());
}
}
void addBaseUrl (BaseUrl *url);
void setProgramInformation (ProgramInformation *progInfo);
- virtual std::string getUrlSegment() const; /* impl */
+ virtual Url getUrlSegment() const; /* impl */
vlc_object_t * getVLCObject() const;
virtual const std::vector<Period *>& getPeriods() const;
return NULL;
}
-std::string Period::getUrlSegment() const
+Url Period::getUrlSegment() const
{
return getParentUrlSegment();
}
AdaptationSet * getAdaptationSet (Streams::Type) const;
void addAdaptationSet (AdaptationSet *AdaptationSet);
- virtual std::string getUrlSegment() const; /* reimpl */
+ virtual Url getUrlSegment() const; /* reimpl */
private:
std::vector<AdaptationSet *> adaptationSets;
return ret;
}
-std::string Representation::getUrlSegment() const
+Url Representation::getUrlSegment() const
{
- std::string ret = getParentUrlSegment();
+ Url ret = getParentUrlSegment();
if (baseUrl)
ret.append(baseUrl->getUrl());
return ret;
MPD* getMPD () const;
std::vector<std::string> toString() const;
- virtual std::string getUrlSegment () const; /* impl */
+ virtual Url getUrlSegment () const; /* impl */
class SplitPoint
{
std::string ISegment::toString() const
{
std::stringstream ss(" ");
- ss << debugName << " url=" << getUrlSegment();
+ ss << debugName << " url=" << getUrlSegment().toString();
if(startByte!=endByte)
ss << " @" << startByte << ".." << endByte;
return ss.str();
classId = CLASSID_SUBSEGMENT;
}
-std::string SubSegment::getUrlSegment() const
+Url SubSegment::getUrlSegment() const
{
return getParentUrlSegment();
}
{
public:
Segment( Representation *parent );
+ explicit Segment( ICanonicalUrl *parent );
~Segment();
virtual void setSourceUrl( const std::string &url );
- virtual std::string getUrlSegment() const; /* impl */
+ virtual Url getUrlSegment() const; /* impl */
virtual dash::http::Chunk* toChunk();
virtual std::vector<ISegment*> subSegments();
virtual Representation* getRepresentation() const;
{
public:
SubSegment(Segment *, size_t start, size_t end);
- virtual std::string getUrlSegment() const; /* impl */
+ virtual Url getUrlSegment() const; /* impl */
virtual std::vector<ISegment*> subSegments();
virtual Representation* getRepresentation() const;
static const int CLASSID_SUBSEGMENT = 4;
this->segmentTimeline = segTl;
}
-std::string SegmentInfoCommon::getUrlSegment() const
+Url SegmentInfoCommon::getUrlSegment() const
{
- std::string ret = getParentUrlSegment();
+ Url ret = getParentUrlSegment();
if (!baseURLs.empty())
ret.append(baseURLs.front());
return ret;
void appendBaseURL( const std::string& url );
const SegmentTimeline* getSegmentTimeline() const;
void setSegmentTimeline( const SegmentTimeline *segTl );
- virtual std::string getUrlSegment() const; /* impl */
+ virtual Url getUrlSegment() const; /* impl */
private:
time_t duration;
--- /dev/null
+/*
+ * Url.cpp
+ *****************************************************************************
+ * Copyright (C) 2014 - VideoLAN Authors
+ *
+ * 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.
+ *****************************************************************************/
+#include "Url.hpp"
+#include "Representation.h"
+#include "SegmentTemplate.h"
+
+#include <sstream>
+using namespace dash::mpd;
+
+Url::Url()
+{
+}
+
+Url::Url(const Component & comp)
+{
+ prepend(comp);
+}
+
+Url::Url(const std::string &str)
+{
+ prepend(Component(str));
+}
+
+Url & Url::prepend(const Component & comp)
+{
+ components.insert(components.begin(), comp);
+ return *this;
+}
+
+Url & Url::append(const Component & comp)
+{
+ components.push_back(comp);
+ return *this;
+}
+
+Url & Url::prepend(const Url &url)
+{
+ components.insert(components.begin(), url.components.begin(), url.components.end());
+ return *this;
+}
+
+Url & Url::append(const Url &url)
+{
+ components.insert(components.end(), url.components.begin(), url.components.end());
+ return *this;
+}
+
+std::string Url::toString() const
+{
+ return toString(0, NULL);
+}
+
+std::string Url::toString(size_t index, const Representation *rep) const
+{
+ std::string ret;
+ std::vector<Component>::const_iterator it;
+ for(it = components.begin(); it != components.end(); it++)
+ {
+ ret.append((*it).contextualize(index, rep));
+ }
+ return ret;
+}
+
+Url::Component::Component(const std::string & str, const SegmentTemplate *templ_)
+{
+ component = str;
+ templ = templ_;
+}
+
+std::string Url::Component::contextualize(size_t index, const Representation *rep) const
+{
+ std::string ret(component);
+
+ if(!rep || !templ)
+ return ret;
+
+ size_t pos = ret.find("$Time$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss << (templ->getDuration() * index);
+ ret.replace(pos, std::string("$Time$").length(), ss.str());
+ }
+
+ pos = ret.find("$Index$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss << index;
+ ret.replace(pos, std::string("$Index$").length(), ss.str());
+ }
+
+ pos = ret.find("$Number$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss << index;
+ ret.replace(pos, std::string("$Number$").length(), ss.str());
+ }
+
+ pos = ret.find("$Bandwidth$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss << rep->getBandwidth();
+ ret.replace(pos, std::string("$Bandwidth$").length(), ss.str());
+ }
+
+ pos = ret.find("$RepresentationID$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss << rep->getId();
+ ret.replace(pos, std::string("$RepresentationID$").length(), ss.str());
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Url.hpp
+ *****************************************************************************
+ * Copyright (C) 2014 - VideoLAN Authors
+ *
+ * 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 URL_HPP
+#define URL_HPP
+
+#include <string>
+#include <vector>
+
+namespace dash
+{
+ namespace mpd
+ {
+ class Representation;
+ class SegmentTemplate;
+
+ class Url
+ {
+ public:
+ class Component
+ {
+ friend class Url;
+ public:
+ Component(const std::string &, const SegmentTemplate * = NULL);
+
+ protected:
+ std::string contextualize(size_t, const Representation *) const;
+ std::string component;
+ const SegmentTemplate *templ;
+ };
+
+ Url();
+ Url(const Component &);
+ explicit Url(const std::string &);
+ Url & prepend(const Component &);
+ Url & append(const Component &);
+ Url & append(const Url &);
+ Url & prepend(const Url &);
+ std::string toString(size_t, const Representation *) const;
+ std::string toString() const;
+
+ private:
+ std::vector<Component> components;
+ };
+ }
+}
+
+#endif // URL_HPP