Commit b996a750 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

dash: Reworking segments.

- Don't differenciate InitSegment and Segment, as the standard define
  them as the same type
- therefore, removing ISegment
- reworking attribut parsing (to be completely handled later)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b412a126
...@@ -35,9 +35,6 @@ SOURCES_stream_filter_dash = \ ...@@ -35,9 +35,6 @@ SOURCES_stream_filter_dash = \
mpd/Group.h \ mpd/Group.h \
mpd/IMPDManager.h \ mpd/IMPDManager.h \
mpd/IMPDParser.h \ mpd/IMPDParser.h \
mpd/InitSegment.cpp \
mpd/InitSegment.h \
mpd/ISegment.h \
mpd/MPD.cpp \ mpd/MPD.cpp \
mpd/MPD.h \ mpd/MPD.h \
mpd/MPDManagerFactory.cpp \ mpd/MPDManagerFactory.cpp \
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
#include "mpd/Period.h" #include "mpd/Period.h"
#include "mpd/Representation.h" #include "mpd/Representation.h"
#include "mpd/InitSegment.h"
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "exceptions/AttributeNotPresentException.h" #include "exceptions/AttributeNotPresentException.h"
#include "exceptions/EOFException.h" #include "exceptions/EOFException.h"
......
...@@ -75,7 +75,7 @@ void AlwaysBestAdaptationLogic::initSchedule () ...@@ -75,7 +75,7 @@ void AlwaysBestAdaptationLogic::initSchedule ()
if(best != NULL) if(best != NULL)
{ {
std::vector<ISegment *> segments = this->mpdManager->getSegments(best); std::vector<Segment *> segments = this->mpdManager->getSegments(best);
for(size_t j = 0; j < segments.size(); j++) for(size_t j = 0; j < segments.size(); j++)
{ {
this->schedule.push_back(segments.at(j)); this->schedule.push_back(segments.at(j));
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "exceptions/EOFException.h" #include "exceptions/EOFException.h"
#include "mpd/BasicCMManager.h" #include "mpd/BasicCMManager.h"
#include "mpd/ISegment.h"
#include <vector> #include <vector>
namespace dash namespace dash
...@@ -49,7 +48,7 @@ namespace dash ...@@ -49,7 +48,7 @@ namespace dash
dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException); dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException);
private: private:
std::vector<dash::mpd::ISegment *> schedule; std::vector<dash::mpd::Segment *> schedule;
dash::mpd::IMPDManager *mpdManager; dash::mpd::IMPDManager *mpdManager;
size_t count; size_t count;
......
...@@ -56,7 +56,7 @@ Chunk* RateBasedAdaptationLogic::getNextChunk () throw(EOFException) ...@@ -56,7 +56,7 @@ Chunk* RateBasedAdaptationLogic::getNextChunk () throw(EOFException)
if(rep == NULL) if(rep == NULL)
throw EOFException(); throw EOFException();
std::vector<ISegment *> segments = this->mpdManager->getSegments(rep); std::vector<Segment *> segments = this->mpdManager->getSegments(rep);
if(this->count == segments.size()) if(this->count == segments.size())
{ {
......
...@@ -39,15 +39,15 @@ BasicCMManager::~BasicCMManager () ...@@ -39,15 +39,15 @@ BasicCMManager::~BasicCMManager ()
delete this->mpd; delete this->mpd;
} }
std::vector<ISegment*> BasicCMManager::getSegments (Representation *rep) std::vector<Segment*> BasicCMManager::getSegments (Representation *rep)
{ {
std::vector<ISegment *> retSegments; std::vector<Segment *> retSegments;
try try
{ {
SegmentInfo* info = rep->getSegmentInfo(); SegmentInfo* info = rep->getSegmentInfo();
InitSegment* init = info->getInitSegment(); Segment* initSegment = info->getInitSegment();
retSegments.push_back(init); retSegments.push_back(initSegment);
std::vector<Segment *> segments = info->getSegments(); std::vector<Segment *> segments = info->getSegments();
......
...@@ -34,9 +34,7 @@ ...@@ -34,9 +34,7 @@
#include "mpd/Group.h" #include "mpd/Group.h"
#include "mpd/Representation.h" #include "mpd/Representation.h"
#include "mpd/SegmentInfo.h" #include "mpd/SegmentInfo.h"
#include "mpd/InitSegment.h"
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "mpd/ISegment.h"
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
#include "exceptions/AttributeNotPresentException.h" #include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h" #include "exceptions/ElementNotPresentException.h"
...@@ -55,7 +53,7 @@ namespace dash ...@@ -55,7 +53,7 @@ namespace dash
Period* getFirstPeriod (); Period* getFirstPeriod ();
Period* getNextPeriod (Period *period); Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period); Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep); std::vector<Segment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate); Representation* getRepresentation (Period *period, long bitrate);
const MPD* getMPD () const; const MPD* getMPD () const;
......
...@@ -136,7 +136,7 @@ void BasicCMParser::setRepresentations (Node *root, Group *group) ...@@ -136,7 +136,7 @@ void BasicCMParser::setRepresentations (Node *root, Group *group)
if ( it != attributes.end() ) if ( it != attributes.end() )
this->handleDependencyId( rep, group, it->second ); this->handleDependencyId( rep, group, it->second );
if ( this->setSegmentInfo(representations.at(i), rep) == false ) if ( this->setSegmentInfo( representations.at(i), rep ) == false )
{ {
delete rep; delete rep;
continue ; continue ;
...@@ -188,6 +188,18 @@ bool BasicCMParser::setSegmentInfo (Node *root, Representation *rep) ...@@ -188,6 +188,18 @@ bool BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
return false; return false;
} }
bool BasicCMParser::parseSegment(Segment *seg, const std::map<std::string, std::string>& attr )
{
std::map<std::string, std::string>::const_iterator it;
it = attr.find( "sourceURL" );
//FIXME: When not present, the sourceUrl attribute should be computed
//using BaseURL and the range attribute.
if ( it != attr.end() )
seg->setSourceUrl( it->second );
return true;
}
void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info) void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
{ {
const std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL"); const std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
...@@ -197,7 +209,8 @@ void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info) ...@@ -197,7 +209,8 @@ void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
" other InitialisationSegmentURL will be dropped." << std::endl; " other InitialisationSegmentURL will be dropped." << std::endl;
if ( initSeg.size() == 1 ) if ( initSeg.size() == 1 )
{ {
InitSegment *seg = new InitSegment( initSeg.at(0)->getAttributes() ); Segment *seg = new Segment();
parseSegment( seg, initSeg.at(0)->getAttributes() );
info->setInitSegment( seg ); info->setInitSegment( seg );
} }
} }
...@@ -210,12 +223,14 @@ bool BasicCMParser::setSegments (Node *root, SegmentInfo *info) ...@@ -210,12 +223,14 @@ bool BasicCMParser::setSegments (Node *root, SegmentInfo *info)
return false; return false;
for(size_t i = 0; i < segments.size(); i++) for(size_t i = 0; i < segments.size(); i++)
{ {
Segment *seg = new Segment(segments.at(i)->getAttributes()); Segment *seg = new Segment();
parseSegment( seg, segments.at(i)->getAttributes() );
info->addSegment(seg); info->addSegment(seg);
} }
return true; return true;
} }
MPD* BasicCMParser::getMPD ()
MPD* BasicCMParser::getMPD()
{ {
return this->mpd; return this->mpd;
} }
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "mpd/BaseUrl.h" #include "mpd/BaseUrl.h"
#include "mpd/SegmentInfo.h" #include "mpd/SegmentInfo.h"
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "mpd/InitSegment.h"
namespace dash namespace dash
{ {
...@@ -66,6 +65,7 @@ namespace dash ...@@ -66,6 +65,7 @@ namespace dash
bool setSegments (dash::xml::Node *root, SegmentInfo *info); bool setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root); void setMPDBaseUrl (dash::xml::Node *root);
bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const; bool parseCommonAttributesElements( dash::xml::Node *node, CommonAttributesElements *common ) const;
bool parseSegment( Segment *seg, const std::map<std::string, std::string> &attr );
}; };
} }
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "mpd/Period.h" #include "mpd/Period.h"
#include "mpd/Representation.h" #include "mpd/Representation.h"
#include "mpd/ISegment.h"
namespace dash namespace dash
{ {
...@@ -32,7 +31,7 @@ namespace dash ...@@ -32,7 +31,7 @@ namespace dash
virtual Period* getFirstPeriod () = 0; virtual Period* getFirstPeriod () = 0;
virtual Period* getNextPeriod (Period *period) = 0; virtual Period* getNextPeriod (Period *period) = 0;
virtual Representation* getBestRepresentation (Period *period) = 0; virtual Representation* getBestRepresentation (Period *period) = 0;
virtual std::vector<ISegment *> getSegments (Representation *rep) = 0; virtual std::vector<Segment *> getSegments (Representation *rep) = 0;
virtual Representation* getRepresentation (Period *period, long bitrate) = 0; virtual Representation* getRepresentation (Period *period, long bitrate) = 0;
virtual const MPD* getMPD () const = 0; virtual const MPD* getMPD () const = 0;
virtual ~IMPDManager(){} virtual ~IMPDManager(){}
......
/*
* ISegment.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 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 ISEGMENT_H_
#define ISEGMENT_H_
#include <string>
#include "exceptions/AttributeNotPresentException.h"
namespace dash
{
namespace mpd
{
class ISegment
{
public:
virtual std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException) = 0;
virtual ~ISegment(){}
};
}
}
#endif /* ISEGMENT_H_ */
/*
* InitSegment.cpp
*****************************************************************************
* 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 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "InitSegment.h"
using namespace dash::mpd;
using namespace dash::exception;
InitSegment::InitSegment (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
}
InitSegment::~InitSegment ()
{
}
std::string InitSegment::getSourceUrl () throw(AttributeNotPresentException)
{
if(this->attributes.find("sourceURL") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["sourceURL"];
}
/*
* InitSegment.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 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 INITSEGMENT_H_
#define INITSEGMENT_H_
#include <map>
#include <string>
#include "exceptions/AttributeNotPresentException.h"
#include "mpd/ISegment.h"
namespace dash
{
namespace mpd
{
class InitSegment : public ISegment
{
public:
InitSegment (std::map<std::string, std::string> attributes);
virtual ~InitSegment();
std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException);
private:
std::map<std::string, std::string> attributes;
};
}
}
#endif /* INITSEGMENT_H_ */
...@@ -45,7 +45,7 @@ Representation* NullManager::getBestRepresentation (Period *) ...@@ -45,7 +45,7 @@ Representation* NullManager::getBestRepresentation (Period *)
{ {
return NULL; return NULL;
} }
std::vector<ISegment *> NullManager::getSegments (Representation *) std::vector<Segment *> NullManager::getSegments (Representation *)
{ {
return this->segments; return this->segments;
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "mpd/MPD.h" #include "mpd/MPD.h"
#include "mpd/Period.h" #include "mpd/Period.h"
#include "mpd/Representation.h" #include "mpd/Representation.h"
#include "mpd/ISegment.h"
#include "mpd/IMPDManager.h" #include "mpd/IMPDManager.h"
namespace dash namespace dash
...@@ -44,12 +43,12 @@ namespace dash ...@@ -44,12 +43,12 @@ namespace dash
Period* getFirstPeriod (); Period* getFirstPeriod ();
Period* getNextPeriod (Period *period); Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period); Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep); std::vector<Segment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate); Representation* getRepresentation (Period *period, long bitrate);
const MPD* getMPD () const; const MPD* getMPD () const;
private: private:
std::vector<Period *> periods; std::vector<Period *> periods;
std::vector<ISegment *> segments; std::vector<Segment *> segments;
}; };
} }
} }
......
...@@ -28,20 +28,14 @@ ...@@ -28,20 +28,14 @@
#include "Segment.h" #include "Segment.h"
using namespace dash::mpd; using namespace dash::mpd;
using namespace dash::exception;
Segment::Segment (std::map<std::string, std::string> attributes) const std::string& Segment::getSourceUrl () const
{
this->attributes = attributes;
}
Segment::~Segment ()
{ {
return this->sourceUrl;
} }
std::string Segment::getSourceUrl () throw(AttributeNotPresentException) void Segment::setSourceUrl( const std::string &url )
{ {
if(this->attributes.find("sourceURL") == this->attributes.end()) if ( url.empty() == false )
throw AttributeNotPresentException(); this->sourceUrl = url;
return this->attributes["sourceURL"];
} }
...@@ -25,26 +25,21 @@ ...@@ -25,26 +25,21 @@
#ifndef SEGMENT_H_ #ifndef SEGMENT_H_
#define SEGMENT_H_ #define SEGMENT_H_
#include <map>
#include <string> #include <string>
#include "exceptions/AttributeNotPresentException.h"
#include "mpd/ISegment.h"
namespace dash namespace dash
{ {
namespace mpd namespace mpd
{ {
class Segment : public ISegment class Segment
{ {
public: public:
Segment (std::map<std::string, std::string> attributes); virtual ~Segment(){}
virtual ~Segment (); const std::string& getSourceUrl() const;
void setSourceUrl( const std::string &url );
std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException);
private: private:
std::map<std::string, std::string> attributes; std::string sourceUrl;
}; };
} }
} }
......
...@@ -44,12 +44,12 @@ SegmentInfo::~SegmentInfo () ...@@ -44,12 +44,12 @@ SegmentInfo::~SegmentInfo ()
delete(this->initSeg); delete(this->initSeg);
} }
InitSegment* SegmentInfo::getInitSegment() const Segment* SegmentInfo::getInitSegment() const
{ {
return this->initSeg; return this->initSeg;
} }
void SegmentInfo::setInitSegment( InitSegment *initSeg ) void SegmentInfo::setInitSegment( Segment *initSeg )
{ {
this->initSeg = initSeg; this->initSeg = initSeg;
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <map> #include <map>
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "mpd/InitSegment.h"
#include "exceptions/ElementNotPresentException.h" #include "exceptions/ElementNotPresentException.h"
namespace dash namespace dash
...@@ -43,15 +42,15 @@ namespace dash ...@@ -43,15 +42,15 @@ namespace dash
SegmentInfo (); SegmentInfo ();
virtual ~SegmentInfo (); virtual ~SegmentInfo ();
InitSegment* getInitSegment() const; Segment* getInitSegment() const;
void setInitSegment( InitSegment *seg ); void setInitSegment( Segment *seg );
time_t getDuration() const; time_t getDuration() const;
void setDuration( time_t duration ); void setDuration( time_t duration );
const std::vector<Segment *>& getSegments () const; const std::vector<Segment *>& getSegments() const;
void addSegment (Segment *seg); void addSegment(Segment *seg);
private: private:
InitSegment *initSeg; Segment *initSeg;
time_t duration; time_t duration;
std::vector<Segment *> segments; std::vector<Segment *> segments;
}; };
......
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