Commit 227e3c35 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>
(cherry picked from commit b996a750)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 09ffaf18
......@@ -35,9 +35,6 @@ SOURCES_stream_filter_dash = \
mpd/Group.h \
mpd/IMPDManager.h \
mpd/IMPDParser.h \
mpd/InitSegment.cpp \
mpd/InitSegment.h \
mpd/ISegment.h \
mpd/MPD.cpp \
mpd/MPD.h \
mpd/MPDManagerFactory.cpp \
......
......@@ -32,7 +32,6 @@
#include "mpd/IMPDManager.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/InitSegment.h"
#include "mpd/Segment.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/EOFException.h"
......
......@@ -75,7 +75,7 @@ void AlwaysBestAdaptationLogic::initSchedule ()
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++)
{
this->schedule.push_back(segments.at(j));
......
......@@ -33,7 +33,6 @@
#include "mpd/Segment.h"
#include "exceptions/EOFException.h"
#include "mpd/BasicCMManager.h"
#include "mpd/ISegment.h"
#include <vector>
namespace dash
......@@ -49,7 +48,7 @@ namespace dash
dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException);
private:
std::vector<dash::mpd::ISegment *> schedule;
std::vector<dash::mpd::Segment *> schedule;
dash::mpd::IMPDManager *mpdManager;
size_t count;
......
......@@ -56,7 +56,7 @@ Chunk* RateBasedAdaptationLogic::getNextChunk () throw(EOFException)
if(rep == NULL)
throw EOFException();
std::vector<ISegment *> segments = this->mpdManager->getSegments(rep);
std::vector<Segment *> segments = this->mpdManager->getSegments(rep);
if(this->count == segments.size())
{
......
......@@ -39,15 +39,15 @@ BasicCMManager::~BasicCMManager ()
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
{
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();
......
......@@ -34,9 +34,7 @@
#include "mpd/Group.h"
#include "mpd/Representation.h"
#include "mpd/SegmentInfo.h"
#include "mpd/InitSegment.h"
#include "mpd/Segment.h"
#include "mpd/ISegment.h"
#include "mpd/IMPDManager.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
......@@ -55,7 +53,7 @@ namespace dash
Period* getFirstPeriod ();
Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep);
std::vector<Segment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate);
const MPD* getMPD () const;
......
......@@ -136,7 +136,7 @@ void BasicCMParser::setRepresentations (Node *root, Group *group)
if ( it != attributes.end() )
this->handleDependencyId( rep, group, it->second );
if ( this->setSegmentInfo(representations.at(i), rep) == false )
if ( this->setSegmentInfo( representations.at(i), rep ) == false )
{
delete rep;
continue ;
......@@ -188,6 +188,18 @@ bool BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
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)
{
const std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
......@@ -197,7 +209,8 @@ void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
" other InitialisationSegmentURL will be dropped." << std::endl;
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 );
}
}
......@@ -210,12 +223,14 @@ bool BasicCMParser::setSegments (Node *root, SegmentInfo *info)
return false;
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);
}
return true;
}
MPD* BasicCMParser::getMPD ()
MPD* BasicCMParser::getMPD()
{
return this->mpd;
}
......
......@@ -35,7 +35,6 @@
#include "mpd/BaseUrl.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
#include "mpd/InitSegment.h"
namespace dash
{
......@@ -66,6 +65,7 @@ namespace dash
bool setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root);
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 @@
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/ISegment.h"
namespace dash
{
......@@ -32,7 +31,7 @@ namespace dash
virtual Period* getFirstPeriod () = 0;
virtual Period* getNextPeriod (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 const MPD* getMPD () const = 0;
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 *)
{
return NULL;
}
std::vector<ISegment *> NullManager::getSegments (Representation *)
std::vector<Segment *> NullManager::getSegments (Representation *)
{
return this->segments;
}
......
......@@ -30,7 +30,6 @@
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/ISegment.h"
#include "mpd/IMPDManager.h"
namespace dash
......@@ -44,12 +43,12 @@ namespace dash
Period* getFirstPeriod ();
Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep);
std::vector<Segment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate);
const MPD* getMPD () const;
private:
std::vector<Period *> periods;
std::vector<ISegment *> segments;
std::vector<Segment *> segments;
};
}
}
......
......@@ -28,20 +28,14 @@
#include "Segment.h"
using namespace dash::mpd;
using namespace dash::exception;
Segment::Segment (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
}
Segment::~Segment ()
const std::string& Segment::getSourceUrl () const
{
return this->sourceUrl;
}
std::string Segment::getSourceUrl () throw(AttributeNotPresentException)
void Segment::setSourceUrl( const std::string &url )
{
if(this->attributes.find("sourceURL") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["sourceURL"];
if ( url.empty() == false )
this->sourceUrl = url;
}
......@@ -25,26 +25,21 @@
#ifndef SEGMENT_H_
#define SEGMENT_H_
#include <map>
#include <string>
#include "exceptions/AttributeNotPresentException.h"
#include "mpd/ISegment.h"
namespace dash
{
namespace mpd
{
class Segment : public ISegment
class Segment
{
public:
Segment (std::map<std::string, std::string> attributes);
virtual ~Segment ();
std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException);
virtual ~Segment(){}
const std::string& getSourceUrl() const;
void setSourceUrl( const std::string &url );
private:
std::map<std::string, std::string> attributes;
std::string sourceUrl;
};
}
}
......
......@@ -44,12 +44,12 @@ SegmentInfo::~SegmentInfo ()
delete(this->initSeg);
}
InitSegment* SegmentInfo::getInitSegment() const
Segment* SegmentInfo::getInitSegment() const
{
return this->initSeg;
}
void SegmentInfo::setInitSegment( InitSegment *initSeg )
void SegmentInfo::setInitSegment( Segment *initSeg )
{
this->initSeg = initSeg;
}
......
......@@ -30,7 +30,6 @@
#include <map>
#include "mpd/Segment.h"
#include "mpd/InitSegment.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
......@@ -43,15 +42,15 @@ namespace dash
SegmentInfo ();
virtual ~SegmentInfo ();
InitSegment* getInitSegment() const;
void setInitSegment( InitSegment *seg );
Segment* getInitSegment() const;
void setInitSegment( Segment *seg );
time_t getDuration() const;
void setDuration( time_t duration );
const std::vector<Segment *>& getSegments () const;
void addSegment (Segment *seg);
const std::vector<Segment *>& getSegments() const;
void addSegment(Segment *seg);
private:
InitSegment *initSeg;
Segment *initSeg;
time_t duration;
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