Commit 9df6750e authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: drop MPGManager{Factory,}

Was useless proxy for periods
parent 737a297d
......@@ -45,8 +45,6 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/CommonAttributesElements.h \
stream_filter/dash/mpd/ContentDescription.cpp \
stream_filter/dash/mpd/ContentDescription.h \
stream_filter/dash/mpd/MPDManager.hpp \
stream_filter/dash/mpd/MPDManager.cpp \
stream_filter/dash/mpd/ICanonicalUrl.hpp \
stream_filter/dash/mpd/IMPDParser.cpp \
stream_filter/dash/mpd/IMPDParser.h \
......@@ -56,8 +54,6 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/MPD.h \
stream_filter/dash/mpd/MPDFactory.cpp \
stream_filter/dash/mpd/MPDFactory.h \
stream_filter/dash/mpd/MPDManagerFactory.cpp \
stream_filter/dash/mpd/MPDManagerFactory.h \
stream_filter/dash/mpd/Period.cpp \
stream_filter/dash/mpd/Period.h \
stream_filter/dash/mpd/Profile.cpp \
......
......@@ -39,7 +39,6 @@ DASHManager::DASHManager ( MPD *mpd,
conManager ( NULL ),
adaptationLogic( NULL ),
logicType ( type ),
mpdManager ( NULL ),
mpd ( mpd ),
stream ( stream ),
downloader ( NULL ),
......@@ -52,17 +51,11 @@ DASHManager::~DASHManager ()
delete this->buffer;
delete this->conManager;
delete this->adaptationLogic;
delete this->mpdManager;
}
bool DASHManager::start()
{
this->mpdManager = mpd::MPDManagerFactory::create( mpd );
if ( this->mpdManager == NULL )
return false;
adaptationLogic = AdaptationLogicFactory::create( logicType, mpdManager );
adaptationLogic = AdaptationLogicFactory::create( logicType, mpd );
if ( this->adaptationLogic == NULL )
return false;
......
......@@ -29,8 +29,6 @@
#include "xml/Node.h"
#include "adaptationlogic/IAdaptationLogic.h"
#include "adaptationlogic/AdaptationLogicFactory.h"
#include "mpd/MPDManager.hpp"
#include "mpd/MPDManagerFactory.h"
#include "buffer/BlockBuffer.h"
#include "DASHDownloader.h"
#include "mpd/MPD.h"
......@@ -55,7 +53,6 @@ namespace dash
http::HTTPConnectionManager *conManager;
logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType;
mpd::MPDManager *mpdManager;
mpd::MPD *mpd;
stream_t *stream;
DASHDownloader *downloader;
......
......@@ -31,8 +31,8 @@ using namespace dash::logic;
using namespace dash::xml;
using namespace dash::mpd;
AbstractAdaptationLogic::AbstractAdaptationLogic (MPDManager *mpdManager) :
mpdManager (mpdManager),
AbstractAdaptationLogic::AbstractAdaptationLogic (MPD *mpd_) :
mpd (mpd_),
bpsAvg (0),
bpsLastChunk (0),
bufferedMicroSec (0),
......
......@@ -29,7 +29,6 @@
#include "xml/Node.h"
#include "http/Chunk.h"
#include "mpd/MPD.h"
#include "mpd/MPDManager.hpp"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/Segment.h"
......@@ -43,7 +42,7 @@ namespace dash
class AbstractAdaptationLogic : public IAdaptationLogic
{
public:
AbstractAdaptationLogic (dash::mpd::MPDManager *mpdManager);
AbstractAdaptationLogic (mpd::MPD *mpd);
virtual ~AbstractAdaptationLogic ();
virtual void downloadRateChanged (uint64_t bpsAvg, uint64_t bpsLastChunk);
......@@ -54,7 +53,7 @@ namespace dash
int getBufferPercent () const;
protected:
dash::mpd::MPDManager *mpdManager;
dash::mpd::MPD *mpd;
private:
int bpsAvg;
......
......@@ -35,13 +35,13 @@ using namespace dash::xml;
using namespace dash::mpd;
IAdaptationLogic* AdaptationLogicFactory::create ( IAdaptationLogic::LogicType logic,
MPDManager *mpdManager)
MPD *mpd)
{
switch(logic)
{
case IAdaptationLogic::AlwaysBest: return new AlwaysBestAdaptationLogic (mpdManager);
case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpdManager);
case IAdaptationLogic::AlwaysLowest: return new AlwaysLowestAdaptationLogic (mpdManager);
case IAdaptationLogic::AlwaysBest: return new AlwaysBestAdaptationLogic (mpd);
case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpd);
case IAdaptationLogic::AlwaysLowest: return new AlwaysLowestAdaptationLogic (mpd);
case IAdaptationLogic::Default:
default:
return NULL;
......
......@@ -27,7 +27,6 @@
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
#include "mpd/MPDManager.hpp"
struct stream_t;
......@@ -38,7 +37,7 @@ namespace dash
class AdaptationLogicFactory
{
public:
static IAdaptationLogic* create (IAdaptationLogic::LogicType logic, dash::mpd::MPDManager *mpdManager);
static IAdaptationLogic* create (IAdaptationLogic::LogicType logic, mpd::MPD *mpd);
};
}
}
......
......@@ -32,8 +32,8 @@ using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;
AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic (MPDManager *mpdManager) :
AbstractAdaptationLogic (mpdManager)
AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic (MPD *mpd) :
AbstractAdaptationLogic (mpd)
{
initSchedule();
}
......@@ -64,9 +64,9 @@ const Representation *AlwaysBestAdaptationLogic::getCurrentRepresentation(Stream
void AlwaysBestAdaptationLogic::initSchedule ()
{
if(mpdManager)
if(mpd)
{
std::vector<Period *> periods = mpdManager->getPeriods();
std::vector<Period *> periods = mpd->getPeriods();
if (periods.empty())
return;
RepresentationSelector selector;
......
......@@ -29,7 +29,6 @@
#include "Representationselectors.hpp"
#include "http/Chunk.h"
#include "xml/Node.h"
#include "mpd/MPDManager.hpp"
#include "mpd/Period.h"
#include "mpd/Segment.h"
#include "Streams.hpp"
......@@ -42,7 +41,7 @@ namespace dash
class AlwaysBestAdaptationLogic : public AbstractAdaptationLogic
{
public:
AlwaysBestAdaptationLogic (dash::mpd::MPDManager *mpdManager);
AlwaysBestAdaptationLogic (mpd::MPD *mpd);
virtual ~AlwaysBestAdaptationLogic ();
virtual dash::http::Chunk* getNextChunk(Streams::Type);
......
......@@ -24,9 +24,9 @@ using namespace dash::logic;
using namespace dash::http;
using namespace dash::mpd;
AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic(dash::mpd::MPDManager *mpdManager):
AbstractAdaptationLogic(mpdManager),
currentPeriod(mpdManager->getFirstPeriod()),
AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic(mpd::MPD *mpd):
AbstractAdaptationLogic(mpd),
currentPeriod(mpd->getFirstPeriod()),
count(0)
{
}
......@@ -43,7 +43,7 @@ Chunk* AlwaysLowestAdaptationLogic::getNextChunk(Streams::Type type)
std::vector<ISegment *> segments = rep->getSegments();
if ( count == segments.size() )
{
currentPeriod = mpdManager->getNextPeriod(currentPeriod);
currentPeriod = mpd->getNextPeriod(currentPeriod);
count = 0;
return getNextChunk(type);
}
......
......@@ -29,7 +29,7 @@ namespace dash
class AlwaysLowestAdaptationLogic : public AbstractAdaptationLogic
{
public:
AlwaysLowestAdaptationLogic(dash::mpd::MPDManager *mpdManager);
AlwaysLowestAdaptationLogic(mpd::MPD *mpd);
virtual dash::http::Chunk* getNextChunk (Streams::Type);
virtual const dash::mpd::Representation* getCurrentRepresentation(Streams::Type) const;
......
......@@ -36,13 +36,13 @@ using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;
RateBasedAdaptationLogic::RateBasedAdaptationLogic (MPDManager *mpdManager) :
AbstractAdaptationLogic (mpdManager),
RateBasedAdaptationLogic::RateBasedAdaptationLogic (MPD *mpd) :
AbstractAdaptationLogic (mpd),
count (0),
currentPeriod (mpdManager->getFirstPeriod())
currentPeriod (mpd->getFirstPeriod())
{
width = var_InheritInteger(mpdManager->getMPD()->getVLCObject(), "dash-prefwidth");
height = var_InheritInteger(mpdManager->getMPD()->getVLCObject(), "dash-prefheight");
width = var_InheritInteger(mpd->getVLCObject(), "dash-prefwidth");
height = var_InheritInteger(mpd->getVLCObject(), "dash-prefheight");
}
Chunk* RateBasedAdaptationLogic::getNextChunk(Streams::Type type)
......@@ -58,7 +58,7 @@ Chunk* RateBasedAdaptationLogic::getNextChunk(Streams::Type type)
if ( this->count == segments.size() )
{
this->currentPeriod = this->mpdManager->getNextPeriod(this->currentPeriod);
currentPeriod = mpd->getNextPeriod(currentPeriod);
this->count = 0;
return getNextChunk(type);
}
......
......@@ -27,7 +27,6 @@
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "xml/Node.h"
#include "mpd/MPDManager.hpp"
#include "http/Chunk.h"
#define MINBUFFER 30
......@@ -39,7 +38,7 @@ namespace dash
class RateBasedAdaptationLogic : public AbstractAdaptationLogic
{
public:
RateBasedAdaptationLogic (dash::mpd::MPDManager *mpdManager);
RateBasedAdaptationLogic (mpd::MPD *mpd);
virtual dash::http::Chunk* getNextChunk(Streams::Type);
const dash::mpd::Representation *getCurrentRepresentation(Streams::Type) const;
......
......@@ -60,10 +60,10 @@ BasicCMParser::~BasicCMParser ()
{
}
bool BasicCMParser::parse ()
bool BasicCMParser::parse (Profile profile)
{
const std::map<std::string, std::string> attr = this->root->getAttributes();
this->mpd = new MPD(p_stream);
mpd = new MPD(p_stream, profile);
std::map<std::string, std::string>::const_iterator it;
it = attr.find("mediaPresentationDuration");
......
......@@ -44,7 +44,7 @@ namespace dash
BasicCMParser( dash::xml::Node *root, stream_t *p_stream );
virtual ~BasicCMParser();
bool parse ();
bool parse (Profile profile);
private:
void handleDependencyId( Representation* rep, const AdaptationSet* adaptationSet, const std::string& dependencyId );
......
......@@ -43,7 +43,7 @@ namespace dash
public:
IMPDParser(dash::xml::Node *, MPD*, stream_t*, Representation*);
virtual ~IMPDParser(){}
virtual bool parse () = 0;
virtual bool parse (Profile profile) = 0;
virtual MPD* getMPD ();
virtual void setMPDBaseUrl(dash::xml::Node *root);
virtual void setAdaptationSets(dash::xml::Node *periodNode, Period *period) = 0;
......
......@@ -43,9 +43,9 @@ IsoffMainParser::~IsoffMainParser ()
{
}
bool IsoffMainParser::parse ()
bool IsoffMainParser::parse (Profile profile)
{
mpd = new MPD(p_stream);
mpd = new MPD(p_stream, profile);
setMPDAttributes();
setMPDBaseUrl(root);
setPeriods(root);
......
......@@ -46,7 +46,7 @@ namespace dash
IsoffMainParser (dash::xml::Node *root, stream_t *p_stream);
virtual ~IsoffMainParser ();
bool parse ();
bool parse (Profile profile);
void print ();
private:
......
......@@ -31,10 +31,10 @@
using namespace dash::mpd;
MPD::MPD (stream_t *stream_) :
MPD::MPD (stream_t *stream_, Profile profile_) :
ICanonicalUrl(),
stream(stream_),
profile( dash::mpd::Profile::Unknown ),
profile( profile_ ),
live( false ),
availabilityStartTime( -1 ),
availabilityEndTime( -1 ),
......@@ -161,11 +161,6 @@ Profile MPD::getProfile() const
return profile;
}
void MPD::setProfile(Profile profile)
{
this->profile = profile;
}
std::string MPD::getUrlSegment() const
{
if (!baseUrls.empty())
......@@ -178,3 +173,26 @@ vlc_object_t * MPD::getVLCObject() const
{
return VLC_OBJECT(stream);
}
Period* MPD::getFirstPeriod() const
{
std::vector<Period *> periods = getPeriods();
if( !periods.empty() )
return periods.front();
else
return NULL;
}
Period* MPD::getNextPeriod(Period *period)
{
std::vector<Period *> periods = getPeriods();
for(size_t i = 0; i < periods.size(); i++)
{
if(periods.at(i) == period && (i + 1) < periods.size())
return periods.at(i + 1);
}
return NULL;
}
......@@ -42,11 +42,10 @@ namespace dash
class MPD : public ICanonicalUrl
{
public:
MPD(stream_t *);
MPD(stream_t *, Profile);
virtual ~MPD();
Profile getProfile() const;
void setProfile( Profile profile );
bool isLive() const;
void setLive( bool live );
time_t getAvailabilityStartTime() const;
......@@ -61,7 +60,6 @@ namespace dash
void setMinBufferTime( time_t time );
time_t getTimeShiftBufferDepth() const;
void setTimeShiftBufferDepth( time_t depth );
const std::vector<Period *>& getPeriods() const;
const ProgramInformation* getProgramInformation() const;
void addPeriod (Period *period);
......@@ -71,6 +69,10 @@ namespace dash
virtual std::string getUrlSegment() const; /* impl */
vlc_object_t * getVLCObject() const;
virtual const std::vector<Period *>& getPeriods() const;
virtual Period* getFirstPeriod() const;
virtual Period* getNextPeriod(Period *period);
private:
stream_t *stream;
Profile profile;
......
......@@ -51,13 +51,10 @@ MPD* MPDFactory::create (dash::xml::Node *root, stream_t *p_stream,
return NULL;
MPD* mpd = NULL;
if(parser->parse())
if(parser->parse(profile))
mpd = parser->getMPD();
delete parser;
if (mpd)
mpd->setProfile(profile);
return mpd;
}
/*
* MPDManager.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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "MPDManager.hpp"
#include <limits>
using namespace dash::mpd;
MPDManager::MPDManager(MPD *mpd_) :
mpd(mpd_)
{
}
MPDManager::~MPDManager()
{
delete mpd;
}
const std::vector<Period*>& MPDManager::getPeriods() const
{
return mpd->getPeriods();
}
Period* MPDManager::getFirstPeriod() const
{
std::vector<Period *> periods = getPeriods();
if( !periods.empty() )
return periods.front();
else
return NULL;
}
Period* MPDManager::getNextPeriod(Period *period)
{
std::vector<Period *> periods = getPeriods();
for(size_t i = 0; i < periods.size(); i++)
{
if(periods.at(i) == period && (i + 1) < periods.size())
return periods.at(i + 1);
}
return NULL;
}
const MPD* MPDManager::getMPD() const
{
return mpd;
}
/*
* MPDManager.hpp
*****************************************************************************
* 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 MPDMANAGER_H_
#define MPDMANAGER_H_
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
namespace dash
{
namespace mpd
{
class MPDManager
{
public:
MPDManager( MPD *mpd );
virtual ~MPDManager();
virtual const std::vector<Period *>& getPeriods () const;
virtual Period* getFirstPeriod () const;
virtual Period* getNextPeriod (Period *period);
virtual const MPD* getMPD () const;
protected:
MPD *mpd;
};
}
}
#endif /* MPDMANAGER_H_ */
/*
* MPDManagerFactory.cpp
*****************************************************************************
* Copyright (C) 2010 - 2011 Klagenfurt University
*
* Created on: Apr 20, 2011
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "mpd/MPDManagerFactory.h"
using namespace dash::mpd;
MPDManager* MPDManagerFactory::create( MPD *mpd )
{
switch( mpd->getProfile() )
{
case mpd::Profile::ISOOnDemand:
case mpd::Profile::Full:
case mpd::Profile::ISOMain:
return new MPDManager(mpd);
default:
return NULL;
}
}
/*
* MPDManagerFactory.h
*****************************************************************************
* Copyright (C) 2010 - 2011 Klagenfurt University
*
* Created on: Apr 20, 2011
* 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 MPDMANAGERFACTORY_H_
#define MPDMANAGERFACTORY_H_
#include "mpd/MPDManager.hpp"
namespace dash
{
namespace mpd
{
class MPDManagerFactory
{
public:
static MPDManager* create( MPD *mpd );
};
}
}
#endif /* MPDMANAGERFACTORY_H_ */
......@@ -31,8 +31,8 @@
#include <vlc_common.h>
#include "mpd/MPDManager.hpp"
#include "xml/Node.h"
#include "mpd/Profile.hpp"
namespace dash
{
......
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