Commit f3600cde authored by Christopher Mueller's avatar Christopher Mueller Committed by Jean-Baptiste Kempf

Added DASH stream filter

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 3d0a5eb4
......@@ -4311,6 +4311,7 @@ AC_CONFIG_FILES([
modules/packetizer/Makefile
modules/services_discovery/Makefile
modules/stream_filter/Makefile
modules/stream_filter/dash/Makefile
modules/stream_out/Makefile
modules/stream_out/transcode/Makefile
modules/text_renderer/Makefile
......
SUBDIRS = dash
SOURCES_decomp = decomp.c
SOURCES_stream_filter_record = record.c
SOURCES_stream_filter_httplive = httplive.c
......
/*
* DASHManager.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 "DASHManager.h"
using namespace dash;
using namespace dash::http;
using namespace dash::xml;
using namespace dash::logic;
using namespace dash::mpd;
using namespace dash::exception;
DASHManager::DASHManager (HTTPConnectionManager *conManager, Node *node, IAdaptationLogic::LogicType type, Profile profile)
{
this->conManager = conManager;
this->node = node;
this->logicType = type;
this->profile = profile;
this->mpdManagerFactory = new MPDManagerFactory();
this->mpdManager = this->mpdManagerFactory->create(this->profile, this->node);
this->logicFactory = new AdaptationLogicFactory();
this->adaptationLogic = this->logicFactory->create(this->logicType, this->mpdManager);
this->currentChunk = NULL;
this->conManager->attach(this->adaptationLogic);
}
DASHManager::~DASHManager ()
{
delete(this->logicFactory);
delete(this->adaptationLogic);
delete(this->mpdManager);
}
int DASHManager::read (void *p_buffer, size_t len)
{
if(this->currentChunk == NULL)
{
try
{
this->currentChunk = this->adaptationLogic->getNextChunk();
}
catch(EOFException &e)
{
this->currentChunk = NULL;
return 0;
}
}
int ret = this->conManager->read(this->currentChunk, p_buffer, len);
if(ret <= 0)
{
this->currentChunk = NULL;
return this->read(p_buffer, len);
}
return ret;
}
int DASHManager::peek (const uint8_t **pp_peek, size_t i_peek)
{
if(this->currentChunk == NULL)
{
try
{
this->currentChunk = this->adaptationLogic->getNextChunk();
}
catch(EOFException &e)
{
return 0;
}
}
int ret = this->conManager->peek(this->currentChunk, pp_peek, i_peek);
return ret;
}
/*
* DASHManager.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 DASHMANAGER_H_
#define DASHMANAGER_H_
#include <stdint.h>
#include <stddef.h>
#include <iostream>
#include "http/HTTPConnectionManager.h"
#include "xml/Node.h"
#include "adaptationlogic/IAdaptationLogic.h"
#include "adaptationlogic/AdaptationLogicFactory.h"
#include "mpd/IMPDManager.h"
#include "mpd/MPDManagerFactory.h"
#include "exceptions/EOFException.h"
namespace dash
{
class DASHManager
{
public:
DASHManager (http::HTTPConnectionManager *conManager, xml::Node *node, logic::IAdaptationLogic::LogicType type, mpd::Profile profile);
virtual ~DASHManager ();
int read (void *p_buffer, size_t len);
int peek (const uint8_t **pp_peek, size_t i_peek);
private:
http::HTTPConnectionManager *conManager;
http::Chunk *currentChunk;
logic::AdaptationLogicFactory *logicFactory;
logic::IAdaptationLogic *adaptationLogic;
logic::IAdaptationLogic::LogicType logicType;
mpd::Profile profile;
xml::Node *node;
mpd::MPDManagerFactory *mpdManagerFactory;
mpd::IMPDManager *mpdManager;
};
}
#endif /* DASHMANAGER_H_ */
SOURCES_stream_filter_dash = \
adaptationlogic/AbstractAdaptationLogic.cpp \
adaptationlogic/AbstractAdaptationLogic.h \
adaptationlogic/AdaptationLogicFactory.cpp \
adaptationlogic/AdaptationLogicFactory.h \
adaptationlogic/AlwaysBestAdaptationLogic.cpp \
adaptationlogic/AlwaysBestAdaptationLogic.h \
adaptationlogic/IAdaptationLogic.h \
adaptationlogic/IDownloadRateObserver.h \
adaptationlogic/NullAdaptationLogic.h \
adaptationlogic/RateBasedAdaptationLogic.h \
adaptationlogic/RateBasedAdaptationLogic.cpp \
exceptions/AttributeNotPresentException.h \
exceptions/ElementNotPresentException.h \
exceptions/EOFException.h \
http/Chunk.cpp \
http/Chunk.h \
http/HTTPConnection.cpp \
http/HTTPConnection.h \
http/HTTPConnectionManager.cpp \
http/HTTPConnectionManager.h \
http/IHTTPConnection.h \
mpd/Accessibility.h \
mpd/BaseUrl.h \
mpd/BasicCMManager.cpp \
mpd/BasicCMManager.h \
mpd/BasicCMParser.cpp \
mpd/BasicCMParser.h \
mpd/ContentDescription.cpp \
mpd/ContentDescription.h \
mpd/ContentProtection.h \
mpd/Group.cpp \
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 \
mpd/MPDManagerFactory.h \
mpd/NullManager.cpp \
mpd/NullManager.h \
mpd/Period.cpp \
mpd/Period.h \
mpd/ProgramInformation.cpp \
mpd/ProgramInformation.h \
mpd/Rating.h \
mpd/Representation.cpp \
mpd/Representation.h \
mpd/SchemeInformation.cpp \
mpd/SchemeInformation.h \
mpd/Segment.cpp \
mpd/Segment.h \
mpd/SegmentInfo.cpp \
mpd/SegmentInfo.h \
mpd/TrickModeType.cpp \
mpd/TrickModeType.h \
mpd/Viewpoint.h \
xml/DOMHelper.cpp \
xml/DOMHelper.h \
xml/DOMParser.cpp \
xml/DOMParser.h \
xml/Node.cpp \
xml/Node.h \
dash.cpp \
DASHManager.cpp \
DASHManager.h \
$(NULL)
libvlc_LTLIBRARIES += libstream_filter_dash_plugin.la
/*
* AbstractAdaptationLogic.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 "AbstractAdaptationLogic.h"
using namespace dash::logic;
using namespace dash::xml;
using namespace dash::mpd;
using namespace dash::exception;
AbstractAdaptationLogic::AbstractAdaptationLogic (IMPDManager *mpdManager)
{
this->bpsAvg = 0;
this->bpsLastChunk = 0;
this->mpdManager = mpdManager;
}
AbstractAdaptationLogic::~AbstractAdaptationLogic ()
{
}
void AbstractAdaptationLogic::downloadRateChanged (long bpsAvg, long bpsLastChunk)
{
this->bpsAvg = bpsAvg;
this->bpsLastChunk = bpsLastChunk;
}
long AbstractAdaptationLogic::getBpsAvg ()
{
return this->bpsAvg;
}
long AbstractAdaptationLogic::getBpsLastChunk ()
{
return this->bpsLastChunk;
}
/*
* AbstractAdaptationLogic.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 ABSTRACTADAPTATIONLOGIC_H_
#define ABSTRACTADAPTATIONLOGIC_H_
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
#include "http/Chunk.h"
#include "mpd/MPD.h"
#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"
namespace dash
{
namespace logic
{
class AbstractAdaptationLogic : public IAdaptationLogic
{
public:
AbstractAdaptationLogic (dash::mpd::IMPDManager *mpdManager);
virtual ~AbstractAdaptationLogic ();
virtual dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException) = 0;
virtual void downloadRateChanged (long bpsAvg, long bpsLastChunk);
long getBpsAvg ();
long getBpsLastChunk ();
private:
long bpsAvg;
long bpsLastChunk;
dash::mpd::IMPDManager *mpdManager;
};
}
}
#endif /* ABSTRACTADAPTATIONLOGIC_H_ */
/*
* AdaptationLogicFactory.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 "AdaptationLogicFactory.h"
using namespace dash::logic;
using namespace dash::xml;
using namespace dash::mpd;
AdaptationLogicFactory::AdaptationLogicFactory ()
{
}
AdaptationLogicFactory::~AdaptationLogicFactory ()
{
}
IAdaptationLogic* AdaptationLogicFactory::create (IAdaptationLogic::LogicType logic, IMPDManager *mpdManager)
{
switch(logic)
{
case IAdaptationLogic::Default: return new NullAdaptationLogic (mpdManager);
case IAdaptationLogic::AlwaysBest: return new AlwaysBestAdaptationLogic (mpdManager);
case IAdaptationLogic::AlwaysLowest: return new NullAdaptationLogic (mpdManager);
case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpdManager);
default: return new NullAdaptationLogic (mpdManager);
}
}
/*
* AdaptationLogicFactory.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 ADAPTATIONLOGICFACTORY_H_
#define ADAPTATIONLOGICFACTORY_H_
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
#include "mpd/IMPDManager.h"
#include "adaptationlogic/AlwaysBestAdaptationLogic.h"
#include "adaptationlogic/NullAdaptationLogic.h"
#include "adaptationlogic/RateBasedAdaptationLogic.h"
namespace dash
{
namespace logic
{
class AdaptationLogicFactory
{
public:
AdaptationLogicFactory ();
virtual ~AdaptationLogicFactory ();
IAdaptationLogic* create (IAdaptationLogic::LogicType logic, dash::mpd::IMPDManager *mpdManager);
};
}
}
#endif /* ADAPTATIONLOGICFACTORY_H_ */
/*
* AlwaysBestAdaptationLogic.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 "AlwaysBestAdaptationLogic.h"
using namespace dash::logic;
using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;
using namespace dash::exception;
AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic (IMPDManager *mpdManager) : AbstractAdaptationLogic(mpdManager)
{
this->mpdManager = mpdManager;
this->count = 0;
this->initSchedule();
}
AlwaysBestAdaptationLogic::~AlwaysBestAdaptationLogic ()
{
}
Chunk* AlwaysBestAdaptationLogic::getNextChunk () throw(EOFException)
{
if(this->schedule.size() == 0)
throw EOFException();
if(this->count == this->schedule.size())
throw EOFException();
for(int i = 0; i < this->schedule.size(); i++)
{
if(this->count == i)
{
Chunk *chunk = new Chunk();
chunk->setUrl(this->schedule.at(i)->getSourceUrl());
this->count++;
return chunk;
}
}
return NULL;
}
void AlwaysBestAdaptationLogic::initSchedule ()
{
if(this->mpdManager != NULL)
{
std::vector<Period *> periods = this->mpdManager->getPeriods();
for(int i = 0; i < periods.size(); i++)
{
Representation *best = this->mpdManager->getBestRepresentation(periods.at(i));
if(best != NULL)
{
std::vector<ISegment *> segments = this->mpdManager->getSegments(best);
for(int j = 0; j < segments.size(); j++)
{
this->schedule.push_back(segments.at(j));
}
}
}
}
}
/*
* AlwaysBestAdaptationLogic.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 ALWAYSBESTADAPTATIONLOGIC_H_
#define ALWAYSBESTADAPTATIONLOGIC_H_
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "http/Chunk.h"
#include "xml/Node.h"
#include "mpd/IMPDManager.h"
#include "mpd/Period.h"
#include "mpd/Segment.h"
#include "exceptions/EOFException.h"
#include "mpd/BasicCMManager.h"
#include "mpd/ISegment.h"
#include <vector>
namespace dash
{
namespace logic
{
class AlwaysBestAdaptationLogic : public AbstractAdaptationLogic
{
public:
AlwaysBestAdaptationLogic (dash::mpd::IMPDManager *mpdManager);
virtual ~AlwaysBestAdaptationLogic ();
dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException);
private:
std::vector<dash::mpd::ISegment *> schedule;
dash::mpd::IMPDManager *mpdManager;
int count;
void initSchedule();
};
}
}
#endif /* ALWAYSBESTADAPTATIONLOGIC_H_ */
/*
* IAdaptationLogic.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 IADAPTATIONLOGIC_H_
#define IADAPTATIONLOGIC_H_
#include <http/Chunk.h>
#include <adaptationlogic/IDownloadRateObserver.h>
#include <exceptions/EOFException.h>
namespace dash
{
namespace logic
{
class IAdaptationLogic : public IDownloadRateObserver
{
public:
enum LogicType
{
Default,
AlwaysBest,
AlwaysLowest,
RateBased,
};
virtual dash::http::Chunk* getNextChunk() throw(dash::exception::EOFException) = 0;
};
}
}
#endif /* IADAPTATIONLOGIC_H_ */
/*
* IDownloadRateObserver.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 IDOWNLOADRATEOBSERVER_H_
#define IDOWNLOADRATEOBSERVER_H_
namespace dash
{
namespace logic
{
class IDownloadRateObserver
{
public:
virtual void downloadRateChanged(long bpsAvg, long bpsLastChunk) = 0;
};
}
}
#endif /* IDOWNLOADRATEOBSERVER_H_ */
/*
* NullAdaptationLogic.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 NULLADAPTATIONLOGIC_H_
#define NULLADAPTATIONLOGIC_H_
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "http/Chunk.h"
#include "xml/Node.h"
#include "mpd/IMPDManager.h"
#include "exceptions/EOFException.h"
namespace dash
{
namespace logic
{
class NullAdaptationLogic : public AbstractAdaptationLogic
{
public:
NullAdaptationLogic (dash::mpd::IMPDManager *mpdManager) : AbstractAdaptationLogic(mpdManager) {}
virtual ~NullAdaptationLogic() {}
dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException) { throw dash::exception::EOFException(); }
};
}
}
#endif /* NULLADAPTATIONLOGIC_H_ */
/*
* RateBasedAdaptationLogic.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 "RateBasedAdaptationLogic.h"
using namespace dash::logic;
using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;
using namespace dash::exception;
RateBasedAdaptationLogic::RateBasedAdaptationLogic (IMPDManager *mpdManager) : AbstractAdaptationLogic(mpdManager)
{
this->mpdManager = mpdManager;
this->currentPeriod = this->mpdManager->getFirstPeriod();
this->count = 0;
}
RateBasedAdaptationLogic::~RateBasedAdaptationLogic ()
{
}
Chunk* RateBasedAdaptationLogic::getNextChunk () throw(EOFException)
{
if(this->mpdManager == NULL)
throw EOFException();
if(this->currentPeriod == NULL)
throw EOFException();
long bitrate = this->getBpsAvg();
Representation *rep = this->mpdManager->getRepresentation(this->currentPeriod, bitrate);
if(rep == NULL)
throw EOFException();
std::vector<ISegment *> segments = this->mpdManager->getSegments(rep);
if(this->count == segments.size())
{
this->currentPeriod = this->mpdManager->getNextPeriod(this->currentPeriod);
this->count = 0;
return this->getNextChunk();
}
for(int i = 0; i < segments.size(); i++)
{
if(i == this->count)
{
this->count++;
Chunk *chunk = new Chunk();
chunk->setUrl(segments.at(i)->getSourceUrl());
return chunk;
}
}
}
/*
* RateBasedAdaptationLogic.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 RATEBASEDADAPTATIONLOGIC_H_
#define RATEBASEDADAPTATIONLOGIC_H_
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "xml/Node.h"
#include "mpd/IMPDManager.h"
#include "http/Chunk.h"
#include "exceptions/EOFException.h"
#include "mpd/BasicCMManager.h"
namespace dash
{
namespace logic
{
class RateBasedAdaptationLogic : public AbstractAdaptationLogic
{
public:
RateBasedAdaptationLogic (dash::mpd::IMPDManager *mpdManager);
virtual ~RateBasedAdaptationLogic ();
dash::http::Chunk* getNextChunk () throw(dash::exception::EOFException);
private:
dash::mpd::IMPDManager *mpdManager;
int count;
dash::mpd::Period *currentPeriod;
};
}
}
#endif /* RATEBASEDADAPTATIONLOGIC_H_ */
/*****************************************************************************
* dash.cpp: DASH module
*****************************************************************************
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
#include <vlc_stream.h>
#include <vlc_modules.h>
#include <vlc_input.h>
#include <errno.h>
#include <string>
#include <map>
#include <fcntl.h>
#include <iostream>
#include <stdio.h>
#include "DASHManager.h"
#include "xml/DOMParser.h"
#include "http/HTTPConnectionManager.h"
#include "adaptationlogic/IAdaptationLogic.h"
#define SEEK 0
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
vlc_module_begin ()
set_shortname( N_("DASH"))
set_description( N_("Dynamic Adaptive Streaming over HTTP") )
set_capability( "stream_filter", 19 )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_STREAM_FILTER )
set_callbacks( Open, Close )
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
struct stream_sys_t
{
dash::DASHManager *p_dashManager;
dash::http::HTTPConnectionManager *p_conManager;
dash::xml::Node *p_node;
int position;
bool isLive;
};
static int Read (stream_t *p_stream, void *p_buffer, unsigned int i_len);
static int Peek (stream_t *p_stream, const uint8_t **pp_peek, unsigned int i_peek);
static int Control (stream_t *p_stream, int i_query, va_list args);
static bool IsDash (stream_t *p_stream, dash::xml::DOMParser *p_parser);
/*****************************************************************************
* Open:
*****************************************************************************/
static int Open(vlc_object_t *p_this)
{
stream_t *p_stream = (stream_t*) p_this;
dash::xml::DOMParser *p_parser = new dash::xml::DOMParser(p_stream->p_source);
if(!IsDash(p_stream, p_parser))
{
delete(p_parser);
return VLC_EGENERIC;
}
stream_sys_t *p_sys = (stream_sys_t *) malloc(sizeof(stream_sys_t));
if (unlikely(p_sys == NULL))
return VLC_ENOMEM;
dash::http::HTTPConnectionManager *p_conManager = new dash::http::HTTPConnectionManager(p_stream);
dash::xml::Node *p_node = p_parser->getRootNode();
dash::DASHManager *p_dashManager = new dash::DASHManager(p_conManager,
p_node,
dash::logic::IAdaptationLogic::RateBased,
p_parser->getProfile(p_node));
delete(p_parser);
p_sys->p_dashManager = p_dashManager;
p_sys->p_node = p_node;
p_sys->p_conManager = p_conManager;
p_sys->position = 0;
p_sys->isLive = true;
p_stream->p_sys = p_sys;
p_stream->pf_read = Read;
p_stream->pf_peek = Peek;
p_stream->pf_control = Control;
msg_Dbg(p_this,"DASH filter: open (%s)", p_stream->psz_path);
return VLC_SUCCESS;
}
/*****************************************************************************
* Close:
*****************************************************************************/
static void Close(vlc_object_t *p_this)
{
stream_t *p_stream = (stream_t*) p_this;
stream_sys_t *p_sys = (stream_sys_t *) p_stream->p_sys;
dash::DASHManager *p_dashManager = p_sys->p_dashManager;
dash::http::HTTPConnectionManager *p_conManager = p_sys->p_conManager;
dash::xml::Node *p_node = p_sys->p_node;
delete(p_conManager);
delete(p_dashManager);
delete(p_node);
free(p_sys);
}
/*****************************************************************************
* Callbacks:
*****************************************************************************/
static int Read (stream_t *p_stream, void *p_buffer, unsigned int i_len)
{
stream_sys_t *p_sys = (stream_sys_t *) p_stream->p_sys;
dash::DASHManager *p_dashManager = p_sys->p_dashManager;
int i_ret = 0;
i_ret = p_dashManager->read(p_buffer, i_len);
if (i_ret < 0)
{
switch (errno)
{
case EINTR:
case EAGAIN:
break;
default:
msg_Dbg(p_stream, "DASH Read: failed to read (%m)");
return 0;
}
return 0;
}
p_sys->position += i_ret;
return i_ret;
}
static int Peek (stream_t *p_stream, const uint8_t **pp_peek, unsigned int i_peek)
{
stream_sys_t *p_sys = (stream_sys_t *) p_stream->p_sys;
dash::DASHManager *p_dashManager = p_sys->p_dashManager;
return p_dashManager->peek(pp_peek, i_peek);
}
static int Control (stream_t *p_stream, int i_query, va_list args)
{
stream_sys_t *p_sys = p_stream->p_sys;
switch (i_query)
{
case STREAM_CAN_SEEK:
case STREAM_CAN_FASTSEEK:
/*TODO Support Seek */
*(va_arg (args, bool *)) = SEEK;
break;
case STREAM_GET_POSITION:
*(va_arg (args, uint64_t *)) = p_sys->position;
break;
case STREAM_SET_POSITION:
return VLC_EGENERIC;
case STREAM_GET_SIZE:
if(p_sys->isLive)
*(va_arg (args, uint64_t *)) = 0;
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* Helpers:
*****************************************************************************/
static bool IsDash (stream_t *p_stream, dash::xml::DOMParser *p_parser)
{
if(!p_parser->isDash())
{
msg_Dbg(p_stream,"DASH filter: file is no mpd");
return false;
}
if(!p_parser->parse())
{
msg_Dbg(p_stream,"DASH filter: could not parse file");
return false;
}
return true;
}
/*
* AttributeNotPresentException.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 ATTRIBUTENOTPRESENTEXCEPTION_H_
#define ATTRIBUTENOTPRESENTEXCEPTION_H_
#include <stdexcept>
namespace dash
{
namespace exception
{
class AttributeNotPresentException : public std::exception
{
public:
AttributeNotPresentException() : std::exception() {}
};
}
}
#endif /* ATTRIBUTENOTPRESENTEXCEPTION_H_ */
/*
* EOFException.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 EOFEXCEPTION_H_
#define EOFEXCEPTION_H_
#include <stdexcept>
namespace dash
{
namespace exception
{
class EOFException : public std::exception
{
public:
EOFException() : std::exception() {}
};
}
}
#endif /* EOFEXCEPTION_H_ */
/*
* ElementNotPresentException.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 ELEMENTNOTPRESENTEXCEPTION_H_
#define ELEMENTNOTPRESENTEXCEPTION_H_
#include <stdexcept>
namespace dash
{
namespace exception
{
class ElementNotPresentException : public std::exception
{
public:
ElementNotPresentException() : std::exception() {}
};
}
}
#endif /* ELEMENTNOTPRESENTEXCEPTION_H_ */
/*
* Chunk.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 "Chunk.h"
using namespace dash::http;
Chunk::Chunk()
{
}
Chunk::~Chunk()
{
}
int Chunk::getEndByte ()
{
return endByte;
}
int Chunk::getStartByte ()
{
return startByte;
}
std::string Chunk::getUrl ()
{
return url;
}
void Chunk::setEndByte (int endByte)
{
this->endByte = endByte;
}
void Chunk::setStartByte (int startByte)
{
this->startByte = startByte;
}
void Chunk::setUrl (std::string url)
{
this->url = url;
}
/*
* Chunk.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 CHUNK_H_
#define CHUNK_H_
#include <vector>
#include <string>
namespace dash
{
namespace http
{
class Chunk
{
public:
Chunk ();
virtual ~Chunk ();
int getEndByte ();
int getStartByte ();
std::string getUrl ();
void setEndByte (int endByte);
void setStartByte (int startByte);
void setUrl (std::string url);
private:
std::string url;
std::vector<std::string> optionalUrls;
int startByte;
int endByte;
};
}
}
#endif /* CHUNK_H_ */
/*
* HTTPConnection.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 "HTTPConnection.h"
using namespace dash::http;
HTTPConnection::HTTPConnection (std::string url, stream_t *stream)
{
this->url = url;
this->stream = stream;
}
HTTPConnection::~HTTPConnection ()
{
}
int HTTPConnection::read (void *p_buffer, size_t len)
{
int size = stream_Read(this->urlStream, p_buffer, len);
if(size <= 0)
return 0;
return size;
}
int HTTPConnection::peek (const uint8_t **pp_peek, size_t i_peek)
{
return stream_Peek(this->urlStream, pp_peek, i_peek);
}
void HTTPConnection::parseURL ()
{
this->hostname = this->url;
this->hostname.erase(0, 7);
this->path = this->hostname;
size_t pos = this->hostname.find("/");
this->hostname = this->hostname.substr(0, pos);
this->path = this->path.substr(pos, this->path.size());
this->request = "GET " + this->path + " HTTP/1.1\r\n" +
"Host: " + this->hostname + "\r\nConnection: close\r\n\r\n";
}
bool HTTPConnection::init ()
{
this->urlStream = stream_UrlNew(this->stream, this->url.c_str());
if(!this->urlStream)
return false;
return true;
}
bool HTTPConnection::parseHeader ()
{
std::string line = this->readLine();
while(line.compare("\r\n"))
{
line = this->readLine();
}
return true;
}
std::string HTTPConnection::readLine ()
{
std::stringstream ss;
char c[1];
size_t size = net_Read(this->stream, this->httpSocket, NULL, c, 1, false);
while(size)
{
ss << c[0];
if(c[0] == '\n')
break;
size = net_Read(this->stream, this->httpSocket, NULL, c, 1, false);
}
if(size > 0)
return ss.str();
return "\r\n";
}
bool HTTPConnection::sendData (std::string data)
{
size_t size = 0;
size = net_Write(this->stream, this->httpSocket, NULL, data.c_str(), data.size());
if (size == -1)
{
return false;
}
if (size != data.length())
{
this->sendData(data.substr(size, data.size()));
}
return true;
}
void HTTPConnection::closeSocket ()
{
stream_Delete(this->urlStream);
}
/*
* HTTPConnection.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 HTTPCONNECTION_H_
#define HTTPCONNECTION_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_stream.h>
#include <vlc_network.h>
#include <string>
#include <stdint.h>
#include <iostream>
#include <sstream>
#include "http/IHTTPConnection.h"
namespace dash
{
namespace http
{
class HTTPConnection : public IHTTPConnection
{
public:
HTTPConnection (std::string url, stream_t *stream);
virtual ~HTTPConnection ();
bool init ();
void closeSocket ();
virtual int read (void *p_buffer, size_t len);
virtual int peek (const uint8_t **pp_peek, size_t i_peek);
private:
int httpSocket;
std::string url;
std::string hostname;
std::string path;
std::string request;
stream_t *stream;
stream_t *urlStream;
void parseURL ();
bool sendData (std::string data);
bool parseHeader ();
std::string readLine ();
};
}
}
#endif /* HTTPCONNECTION_H_ */
/*
* HTTPConnectionManager.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 "HTTPConnectionManager.h"
using namespace dash::http;
using namespace dash::logic;
HTTPConnectionManager::HTTPConnectionManager (stream_t *stream)
{
this->timeSecSession = 0;
this->bytesReadSession = 0;
this->timeSecChunk = 0;
this->bytesReadChunk = 0;
this->bpsAvg = 0;
this->bpsLastChunk = 0;
this->chunkCount = 0;
this->stream = stream;
}
HTTPConnectionManager::~HTTPConnectionManager ()
{
this->closeAllConnections();
}
IHTTPConnection* HTTPConnectionManager::getConnection (std::string url)
{
HTTPConnection *con = new HTTPConnection(url, this->stream);
con->init();
this->connections.push_back(con);
return con;
}
bool HTTPConnectionManager::closeConnection (IHTTPConnection *con)
{
for(std::vector<HTTPConnection *>::iterator it = this->connections.begin(); it != this->connections.end(); ++it)
{
if(*it == con)
{
(*it)->closeSocket();
delete(*it);
this->connections.erase(it);
return true;
}
}
return false;
}
bool HTTPConnectionManager::closeConnection (Chunk *chunk)
{
HTTPConnection *con = this->chunkMap[chunk];
bool ret = this->closeConnection(con);
this->chunkMap.erase(chunk);
delete(chunk);
return ret;
}
bool HTTPConnectionManager::closeAllConnections ()
{
for(std::vector<HTTPConnection *>::iterator it = this->connections.begin(); it != this->connections.end(); ++it)
{
(*it)->closeSocket();
delete(*it);
}
this->connections.clear();
this->urlMap.clear();
std::map<Chunk *, HTTPConnection *>::iterator it;
for(it = this->chunkMap.begin(); it != this->chunkMap.end(); ++it)
{
delete(it->first);
}
this->chunkMap.clear();
}
int HTTPConnectionManager::read (Chunk *chunk, void *p_buffer, size_t len)
{
if(this->chunkMap.find(chunk) != this->chunkMap.end())
{
mtime_t start = mdate();
int ret = this->chunkMap[chunk]->read(p_buffer, len);
mtime_t end = mdate();
double time = ((double)(end - start)) / 1000000;
this->bytesReadSession += ret;
this->bytesReadChunk += ret;
this->timeSecSession += time;
this->timeSecChunk += time;
if(this->timeSecSession > 0)
this->bpsAvg = (this->bytesReadSession / this->timeSecSession) * 8;
if(this->timeSecChunk > 0)
this->bpsLastChunk = (this->bytesReadChunk / this->timeSecChunk) * 8;
if(this->bpsAvg < 0 || this->chunkCount < 2)
this->bpsAvg = 0;
if(this->bpsLastChunk < 0 || this->chunkCount < 2)
this->bpsLastChunk = 0;
this->notify();
if(ret <= 0)
this->closeConnection(chunk);
return ret;
}
else
{
this->bytesReadChunk = 0;
this->timeSecChunk = 0;
HTTPConnection *con = this->initConnection(chunk);
return this->read(chunk, p_buffer, len);
}
}
int HTTPConnectionManager::peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek)
{
if(this->chunkMap.find(chunk) != this->chunkMap.end())
return this->chunkMap[chunk]->peek(pp_peek, i_peek);
HTTPConnection *con = this->initConnection(chunk);
return this->peek(chunk, pp_peek, i_peek);
}
HTTPConnection* HTTPConnectionManager::initConnection (Chunk *chunk)
{
HTTPConnection *con = new HTTPConnection(chunk->getUrl(), this->stream);
con->init();
this->connections.push_back(con);
this->chunkMap[chunk] = con;
this->chunkCount++;
return con;
}
void HTTPConnectionManager::attach (IDownloadRateObserver *observer)
{
this->rateObservers.push_back(observer);
}
void HTTPConnectionManager::notify ()
{
for(int i = 0; i < this->rateObservers.size(); i++)
this->rateObservers.at(i)->downloadRateChanged(this->bpsAvg, this->bpsLastChunk);
}
/*
* HTTPConnectionManager.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 HTTPCONNECTIONMANAGER_H_
#define HTTPCONNECTIONMANAGER_H_
#include <vlc_common.h>
#include <string>
#include <vector>
#include <iostream>
#include <ctime>
#include <map>
#include <limits.h>
#include "http/HTTPConnection.h"
#include "http/Chunk.h"
#include "adaptationlogic/IDownloadRateObserver.h"
namespace dash
{
namespace http
{
class HTTPConnectionManager
{
public:
HTTPConnectionManager (stream_t *stream);
virtual ~HTTPConnectionManager ();
bool closeAllConnections ();
bool closeConnection (IHTTPConnection *con);
IHTTPConnection* getConnection (std::string url);
int read (Chunk *chunk, void *p_buffer, size_t len);
int peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek);
void attach (dash::logic::IDownloadRateObserver *observer);
void notify ();
private:
std::vector<HTTPConnection *> connections;
std::map<Chunk *, HTTPConnection *> chunkMap;
std::map<std::string, HTTPConnection *> urlMap;
std::vector<dash::logic::IDownloadRateObserver *> rateObservers;
long bpsAvg;
long bpsLastChunk;
long bytesReadSession;
double timeSecSession;
long bytesReadChunk;
double timeSecChunk;
stream_t *stream;
int chunkCount;
bool closeConnection (Chunk *chunk);
HTTPConnection* initConnection (Chunk *chunk);
};
}
}
#endif /* HTTPCONNECTIONMANAGER_H_ */
/*
* IHTTPConnection.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 IHTTPCONNECTION_H_
#define IHTTPCONNECTION_H_
#include <stdint.h>
#include <unistd.h>
namespace dash
{
namespace http
{
class IHTTPConnection
{
public:
virtual int read (void *p_buffer, size_t len) = 0;
virtual int peek (const uint8_t **pp_peek, size_t i_peek) = 0;
};
}
}
#endif /* IHTTPCONNECTION_H_ */
/*
* Accessibility.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 ACCESSIBILITY_H_
#define ACCESSIBILITY_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Accessibility : public ContentDescription
{
};
}
}
#endif /* ACCESSIBILITY_H_ */
/*
* 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 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 dash
{
namespace mpd
{
class BaseUrl
{
public:
BaseUrl (std::string url) { this->url = url; }
virtual ~BaseUrl() {}
std::string getUrl() { return this->url; }
private:
std::string url;
};
}
}
#endif /* BASEURL_H_ */
/*
* BasicCMManager.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 "BasicCMManager.h"
using namespace dash::mpd;
using namespace dash::exception;
BasicCMManager::BasicCMManager (MPD *mpd)
{
this->mpd = mpd;
}
BasicCMManager::~BasicCMManager ()
{
}
std::vector<ISegment*> BasicCMManager::getSegments (Representation *rep)
{
std::vector<ISegment *> retSegments;
try
{
SegmentInfo* info = rep->getSegmentInfo();
InitSegment* init = info->getInitSegment();
retSegments.push_back(init);
std::vector<Segment *> segments = info->getSegments();
for(int i = 0; i < segments.size(); i++)
retSegments.push_back(segments.at(i));
}
catch(ElementNotPresentException &e)
{
/*TODO Debug */
}
return retSegments;
}
std::vector<Period*> BasicCMManager::getPeriods ()
{
return this->mpd->getPeriods();
}
Representation* BasicCMManager::getBestRepresentation (Period *period)
{
std::vector<Group *> groups = period->getGroups();
long bitrate = 0;
Representation *best = NULL;
for(int i = 0; i < groups.size(); i++)
{
std::vector<Representation *> reps = groups.at(i)->getRepresentations();
for(int j = 0; j < reps.size(); j++)
{
try
{
long currentBitrate = atol(reps.at(j)->getBandwidth().c_str());
if(currentBitrate > bitrate)
{
bitrate = currentBitrate;
best = reps.at(j);
}
}
catch(AttributeNotPresentException &e)
{
/* TODO DEBUG */
}
}
}
return best;
}
Period* BasicCMManager::getFirstPeriod ()
{
std::vector<Period *> periods = this->mpd->getPeriods();
if(periods.size() == 0)
return NULL;
return periods.at(0);
}
Representation* BasicCMManager::getRepresentation (Period *period, long bitrate)
{
std::vector<Group *> groups = period->getGroups();
Representation *best = NULL;
long bestDif = -1;
for(int i = 0; i < groups.size(); i++)
{
std::vector<Representation *> reps = groups.at(i)->getRepresentations();
for(int j = 0; j < reps.size(); j++)
{
try
{
long currentBitrate = atol(reps.at(j)->getBandwidth().c_str());
long dif = bitrate - currentBitrate;
if(bestDif == -1)
{
bestDif = dif;
best = reps.at(j);
}
else
{
if(dif >= 0 && dif < bestDif)
{
bestDif = dif;
best = reps.at(j);
}
}
}
catch(AttributeNotPresentException &e)
{
/* TODO DEBUG */
}
}
}
return best;
}
Period* BasicCMManager::getNextPeriod (Period *period)
{
std::vector<Period *> periods = this->mpd->getPeriods();
for(int i = 0; i < periods.size(); i++)
{
if(periods.at(i) == period && (i + 1) < periods.size())
return periods.at(i + 1);
}
return NULL;
}
/*
* BasicCMManager.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 BASICCMMANAGER_H_
#define BASICCMMANAGER_H_
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "mpd/MPD.h"
#include "mpd/Period.h"
#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"
namespace dash
{
namespace mpd
{
class BasicCMManager : public IMPDManager
{
public:
BasicCMManager (MPD *mpd);
virtual ~BasicCMManager ();
std::vector<Period *> getPeriods ();
Period* getFirstPeriod ();
Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate);
private:
MPD *mpd;
};
}
}
#endif /* BASICCMMANAGER_H_ */
/*
* BasicCMParser.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 "BasicCMParser.h"
using namespace dash::mpd;
using namespace dash::xml;
BasicCMParser::BasicCMParser (Node *root)
{
this->root = root;
}
BasicCMParser::~BasicCMParser ()
{
}
bool BasicCMParser::parse ()
{
this->setMPD();
return true;
}
void BasicCMParser::setMPD ()
{
this->mpd = new MPD(this->root->getAttributes());
this->setMPDBaseUrl(this->root);
this->setPeriods(this->root);
}
void BasicCMParser::setMPDBaseUrl (Node *root)
{
std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(root, "BaseURL");
for(int i = 0; i < baseUrls.size(); i++)
{
BaseUrl *url = new BaseUrl(baseUrls.at(i)->getText());
this->mpd->addBaseUrl(url);
}
}
void BasicCMParser::setPeriods (Node *root)
{
std::vector<Node *> periods = DOMHelper::getElementByTagName(root, "Period", false);
for(int i = 0; i < periods.size(); i++)
{
Period *period = new Period(periods.at(i)->getAttributes());
this->setGroups(periods.at(i), period);
this->mpd->addPeriod(period);
}
}
void BasicCMParser::setGroups (Node *root, Period *period)
{
std::vector<Node *> groups = DOMHelper::getElementByTagName(root, "Group", false);
for(int i = 0; i < groups.size(); i++)
{
Group *group = new Group(groups.at(i)->getAttributes());
this->setRepresentations(groups.at(i), group);
period->addGroup(group);
}
}
void BasicCMParser::setRepresentations (Node *root, Group *group)
{
std::vector<Node *> representations = DOMHelper::getElementByTagName(root, "Representation", false);
for(int i = 0; i < representations.size(); i++)
{
Representation *rep = new Representation(representations.at(i)->getAttributes());
this->setSegmentInfo(representations.at(i), rep);
group->addRepresentation(rep);
}
}
void BasicCMParser::setSegmentInfo (Node *root, Representation *rep)
{
std::vector<Node *> segmentInfo = DOMHelper::getChildElementByTagName(root, "SegmentInfo");
for(int i = 0; i < segmentInfo.size(); i++)
{
SegmentInfo *info = new SegmentInfo(segmentInfo.at(i)->getAttributes());
this->setInitSegment(segmentInfo.at(i), info);
this->setSegments(segmentInfo.at(i), info);
rep->setSegmentInfo(info);
return;
}
}
void BasicCMParser::setInitSegment (Node *root, SegmentInfo *info)
{
std::vector<Node *> initSeg = DOMHelper::getChildElementByTagName(root, "InitialisationSegmentURL");
for(int i = 0; i < initSeg.size(); i++)
{
InitSegment *seg = new InitSegment(initSeg.at(i)->getAttributes());
info->setInitSegment(seg);
return;
}
}
void BasicCMParser::setSegments (Node *root, SegmentInfo *info)
{
std::vector<Node *> segments = DOMHelper::getElementByTagName(root, "Url", false);
for(int i = 0; i < segments.size(); i++)
{
Segment *seg = new Segment(segments.at(i)->getAttributes());
info->addSegment(seg);
}
}
MPD* BasicCMParser::getMPD ()
{
return this->mpd;
}
/*
* BasicCMParser.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 BASICCMPARSER_H_
#define BASICCMPARSER_H_
#include "xml/Node.h"
#include "xml/DOMHelper.h"
#include "mpd/IMPDParser.h"
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Group.h"
#include "mpd/Representation.h"
#include "mpd/BaseUrl.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
#include "mpd/InitSegment.h"
namespace dash
{
namespace mpd
{
class BasicCMParser : public IMPDParser
{
public:
BasicCMParser (dash::xml::Node *root);
virtual ~BasicCMParser ();
bool parse ();
MPD* getMPD ();
private:
dash::xml::Node *root;
MPD *mpd;
void setMPD ();
void setPeriods (dash::xml::Node *root);
void setGroups (dash::xml::Node *root, Period *period);
void setRepresentations (dash::xml::Node *root, Group *group);
void setSegmentInfo (dash::xml::Node *root, Representation *rep);
void setInitSegment (dash::xml::Node *root, SegmentInfo *info);
void setSegments (dash::xml::Node *root, SegmentInfo *info);
void setMPDBaseUrl (dash::xml::Node *root);
};
}
}
#endif /* BASICCMPARSER_H_ */
/*
* ContentDescription.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 "ContentDescription.h"
using namespace dash::mpd;
using namespace dash::exception;
ContentDescription::ContentDescription (std::map<std::string,std::string> attributes)
{
this->attributes = attributes;
this->schemeInformation = NULL;
}
ContentDescription::~ContentDescription ()
{
delete(this->schemeInformation);
}
SchemeInformation* ContentDescription::getSchemeInformation () throw(ElementNotPresentException)
{
if(this->schemeInformation == NULL)
throw ElementNotPresentException();
return this->schemeInformation;
}
std::string ContentDescription::getSchemeIdUri () throw(AttributeNotPresentException)
{
if(this->attributes.find("schemeIdUri") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["schmeIdUri"];
}
void ContentDescription::setSchemeInformation (SchemeInformation *schemeInfo)
{
this->schemeInformation = schemeInfo;
}
/*
* ContentDescription.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 CONTENTDESCRIPTION_H_
#define CONTENTDESCRIPTION_H_
#include <string>
#include <map>
#include "mpd/SchemeInformation.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class ContentDescription
{
public:
ContentDescription (std::map<std::string, std::string> attributes);
virtual ~ContentDescription ();
std::string getSchemeIdUri () throw(dash::exception::AttributeNotPresentException);
SchemeInformation* getSchemeInformation () throw(dash::exception::ElementNotPresentException);
void setSchemeInformation (SchemeInformation *schemeInfo);
private:
std::map<std::string, std::string> attributes;
SchemeInformation *schemeInformation;
};
}
}
#endif /* CONTENTDESCRIPTION_H_ */
/*
* ContentProtection.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 CONTENTPROTECTION_H_
#define CONTENTPROTECTION_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class ContentProtection : public ContentDescription
{
};
}
}
#endif /* CONTENTPROTECTION_H_ */
/*
* Group.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.
*****************************************************************************/
#include "Group.h"
using namespace dash::mpd;
using namespace dash::exception;
Group::Group (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
this->contentProtection = NULL;
this->accessibility = NULL;
this->viewpoint = NULL;
this->rating = NULL;
}
Group::~Group ()
{
for(int i = 0; i < this->representations.size(); i++)
delete(this->representations.at(i));
delete(this->contentProtection);
delete(this->rating);
delete(this->viewpoint);
delete(this->accessibility);
}
std::string Group::getWidth () throw(AttributeNotPresentException)
{
if(this->attributes.find("width") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["width"];
}
std::string Group::getNumberOfChannels () throw(AttributeNotPresentException)
{
if(this->attributes.find("numberOfChannels") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["numberOfChannels"];
}
std::string Group::getLang () throw(AttributeNotPresentException)
{
if(this->attributes.find("lang") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["lang"];
}
std::string Group::getParY () throw(AttributeNotPresentException)
{
if(this->attributes.find("pary") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["pary"];
}
std::string Group::getParX () throw(AttributeNotPresentException)
{
if(this->attributes.find("parx") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["parx"];
}
std::string Group::getSamplingRate () throw(AttributeNotPresentException)
{
if(this->attributes.find("samplingRate") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["samplingRate"];
}
std::string Group::getMimeType () throw(AttributeNotPresentException)
{
if(this->attributes.find("mimeType") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["mimeType"];
}
std::string Group::getSubSegmentAlignment () throw(AttributeNotPresentException)
{
if(this->attributes.find("subsegmentAlignmentFlag") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["subsegmentAlignmentFlag"];
}
std::string Group::getFrameRate () throw(AttributeNotPresentException)
{
if(this->attributes.find("frameRate") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["frameRate"];
}
std::string Group::getHeight () throw(AttributeNotPresentException)
{
if(this->attributes.find("height") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["height"];
}
Viewpoint* Group::getViewpoint () throw(ElementNotPresentException)
{
if(this->viewpoint == NULL)
throw ElementNotPresentException();
return this->viewpoint;
}
Rating* Group::getRating () throw(ElementNotPresentException)
{
if(this->rating == NULL)
throw ElementNotPresentException();
return this->rating;
}
Accessibility* Group::getAccessibility () throw(ElementNotPresentException)
{
if(this->accessibility == NULL)
throw ElementNotPresentException();
return this->accessibility;
}
ContentProtection* Group::getContentProtection () throw(ElementNotPresentException)
{
if(this->contentProtection == NULL)
throw ElementNotPresentException();
return this->contentProtection;
}
std::vector<Representation*> Group::getRepresentations ()
{
return this->representations;
}
void Group::addRepresentation (Representation *rep)
{
this->representations.push_back(rep);
}
void Group::setRating (Rating *rating)
{
this->rating = rating;
}
void Group::setContentProtection (ContentProtection *protection)
{
this->contentProtection = protection;
}
void Group::setAccessibility (Accessibility *accessibility)
{
this->accessibility = accessibility;
}
void Group::setViewpoint (Viewpoint *viewpoint)
{
this->viewpoint = viewpoint;
}
/*
* Group.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 GROUP_H_
#define GROUP_H_
#include <vector>
#include <string>
#include <map>
#include "mpd/Representation.h"
#include "mpd/ContentProtection.h"
#include "mpd/Accessibility.h"
#include "mpd/Viewpoint.h"
#include "mpd/Rating.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class Group
{
public:
Group (std::map<std::string, std::string> attributes);
virtual ~Group ();
std::string getWidth () throw(dash::exception::AttributeNotPresentException);
std::string getHeight () throw(dash::exception::AttributeNotPresentException);
std::string getParX () throw(dash::exception::AttributeNotPresentException);
std::string getParY () throw(dash::exception::AttributeNotPresentException);
std::string getLang () throw(dash::exception::AttributeNotPresentException);
std::string getMimeType () throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () throw(dash::exception::AttributeNotPresentException);
std::string getNumberOfChannels () throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () throw(dash::exception::AttributeNotPresentException);
std::string getSubSegmentAlignment () throw(dash::exception::AttributeNotPresentException);
std::vector<Representation *> getRepresentations ();
Viewpoint* getViewpoint () throw(dash::exception::ElementNotPresentException);
ContentProtection* getContentProtection () throw(dash::exception::ElementNotPresentException);
Accessibility* getAccessibility () throw(dash::exception::ElementNotPresentException);
Rating* getRating () throw(dash::exception::ElementNotPresentException);
void addRepresentation (Representation *rep);
void setViewpoint (Viewpoint *viewpoint);
void setContentProtection (ContentProtection *protection);
void setAccessibility (Accessibility *accessibility);
void setRating (Rating *rating);
private:
std::map<std::string, std::string> attributes;
std::vector<Representation *> representations;
ContentProtection *contentProtection;
Accessibility *accessibility;
Viewpoint *viewpoint;
Rating *rating;
};
}
}
#endif /* GROUP_H_ */
/*
* IMPDManager.h
*
* Created on: Apr 22, 2011
* Author: Christopher Müller
*/
#ifndef IMPDMANAGER_H_
#define IMPDMANAGER_H_
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/ISegment.h"
namespace dash
{
namespace mpd
{
enum Profile
{
NotValid,
Full2011,
Basic,
BasicCM,
};
class IMPDManager
{
public:
virtual std::vector<Period *> getPeriods () = 0;
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 Representation* getRepresentation (Period *period, long bitrate) = 0;
};
}
}
#endif /* IMPDMANAGER_H_ */
/*
* IMPDParser.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 IMPDPARSER_H_
#define IMPDPARSER_H_
#include "mpd/MPD.h"
namespace dash
{
namespace mpd
{
class IMPDParser
{
public:
virtual bool parse () = 0;
virtual MPD* getMPD () = 0;
};
}
}
#endif /* IMPDPARSER_H_ */
/*
* 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;
};
}
}
#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_ */
/*
* MPD.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 "MPD.h"
using namespace dash::mpd;
using namespace dash::exception;
MPD::MPD (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
this->programInfo = NULL;
}
MPD::MPD ()
{
}
MPD::~MPD ()
{
for(int i = 0; i < this->periods.size(); i++)
delete(this->periods.at(i));
for(int i = 0; i < this->baseUrls.size(); i++)
delete(this->baseUrls.at(i));
delete(this->programInfo);
}
std::vector<Period*> MPD::getPeriods ()
{
return this->periods;
}
std::vector<BaseUrl*> MPD::getBaseUrls ()
{
return this->baseUrls;
}
std::string MPD::getMinBufferTime () throw(AttributeNotPresentException)
{
if(this->attributes.find("minBufferTime") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["minBufferTime"];
}
std::string MPD::getType () throw(AttributeNotPresentException)
{
if(this->attributes.find("type") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["type"];
}
std::string MPD::getDuration () throw(AttributeNotPresentException)
{
if(this->attributes.find("mediaPresentationDuration") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["mediaPresentationDuration"];
}
ProgramInformation* MPD::getProgramInformation () throw(ElementNotPresentException)
{
if(this->programInfo == NULL)
throw ElementNotPresentException();
return this->programInfo;
}
void MPD::addBaseUrl (BaseUrl *url)
{
this->baseUrls.push_back(url);
}
void MPD::addPeriod (Period *period)
{
this->periods.push_back(period);
}
void MPD::setProgramInformation (ProgramInformation *progInfo)
{
this->programInfo = progInfo;
}
/*
* MPD.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 MPD_H_
#define MPD_H_
#include <vector>
#include <string>
#include <map>
#include "mpd/Period.h"
#include "mpd/BaseUrl.h"
#include "mpd/ProgramInformation.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class MPD
{
public:
MPD (std::map<std::string, std::string> attributes);
MPD ();
virtual ~MPD();
std::string getType () throw(dash::exception::AttributeNotPresentException);
std::string getDuration () throw(dash::exception::AttributeNotPresentException);
std::string getMinBufferTime () throw(dash::exception::AttributeNotPresentException);
std::vector<BaseUrl *> getBaseUrls ();
std::vector<Period *> getPeriods ();
ProgramInformation* getProgramInformation () throw(dash::exception::ElementNotPresentException);
void addPeriod (Period *period);
void addBaseUrl (BaseUrl *url);
void setProgramInformation (ProgramInformation *progInfo);
private:
std::map<std::string, std::string> attributes;
std::vector<Period *> periods;
std::vector<BaseUrl *> baseUrls;
ProgramInformation *programInfo;
};
}
}
#endif /* MPD_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 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;
using namespace dash::xml;
MPDManagerFactory::MPDManagerFactory()
{
// TODO Auto-generated constructor stub
}
MPDManagerFactory::~MPDManagerFactory()
{
// TODO Auto-generated destructor stub
}
IMPDManager* MPDManagerFactory::create (Profile profile, Node *root)
{
switch(profile)
{
case mpd::Basic: return new NullManager();
case mpd::BasicCM: return this->createBasicCMManager(root);
case mpd::Full2011: return new NullManager();
case mpd::NotValid: return new NullManager();
default: return new NullManager();
}
}
IMPDManager* MPDManagerFactory::createBasicCMManager (Node *root)
{
BasicCMParser *parser = new BasicCMParser(root);
if(!parser->parse())
return new NullManager();
BasicCMManager *manager = new BasicCMManager(parser->getMPD());
delete(parser);
return manager;
}
/*
* 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 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/IMPDManager.h"
#include "mpd/NullManager.h"
#include "mpd/BasicCMManager.h"
#include "mpd/BasicCMParser.h"
#include "xml/Node.h"
namespace dash
{
namespace mpd
{
class MPDManagerFactory
{
public:
MPDManagerFactory ();
virtual ~MPDManagerFactory ();
IMPDManager* create(Profile profile, dash::xml::Node *root);
private:
IMPDManager* createBasicCMManager(dash::xml::Node *root);
};
}
}
#endif /* MPDMANAGERFACTORY_H_ */
/*
* NullManager.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 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/NullManager.h"
using namespace dash::mpd;
NullManager::NullManager ()
{
}
NullManager::~NullManager ()
{
}
std::vector<Period *> NullManager::getPeriods ()
{
return std::vector<Period *>();
}
Period* NullManager::getFirstPeriod ()
{
return NULL;
}
Period* NullManager::getNextPeriod (Period *period)
{
return NULL;
}
Representation* NullManager::getBestRepresentation (Period *period)
{
return NULL;
}
std::vector<ISegment *> NullManager::getSegments (Representation *rep)
{
return std::vector<ISegment *>();
}
Representation* NullManager::getRepresentation (Period *period, long bitrate)
{
return NULL;
}
/*
* NullManager.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 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 NULLMANAGER_H_
#define NULLMANAGER_H_
#include "mpd/IMPDManager.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/ISegment.h"
#include "mpd/IMPDManager.h"
namespace dash
{
namespace mpd
{
class NullManager : public IMPDManager
{
public:
NullManager ();
virtual ~NullManager();
std::vector<Period *> getPeriods ();
Period* getFirstPeriod ();
Period* getNextPeriod (Period *period);
Representation* getBestRepresentation (Period *period);
std::vector<ISegment *> getSegments (Representation *rep);
Representation* getRepresentation (Period *period, long bitrate);
};
}
}
#endif /* NULLMANAGER_H_ */
/*
* Period.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 "Period.h"
using namespace dash::mpd;
Period::Period (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
}
Period::~Period ()
{
for(int i = 0; i < this->groups.size(); i++)
delete(this->groups.at(i));
}
std::vector<Group*> Period::getGroups ()
{
return this->groups;
}
void Period::addGroup (Group *group)
{
this->groups.push_back(group);
}
/*
* Period.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 PERIOD_H_
#define PERIOD_H_
#include <vector>
#include <string>
#include <map>
#include "mpd/Group.h"
#include "mpd/Representation.h"
namespace dash
{
namespace mpd
{
class Period
{
public:
Period (std::map<std::string, std::string> attributes);
virtual ~Period ();
std::vector<Group *> getGroups ();
void addGroup (Group *group);
private:
std::map<std::string, std::string> attributes;
std::vector<Group *> groups;
};
}
}
#endif /* PERIOD_H_ */
/*
* ProgramInformation.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 "ProgramInformation.h"
using namespace dash::mpd;
using namespace dash::exception;
ProgramInformation::ProgramInformation (std::map<std::string, std::string> attr)
{
this->attributes = attr;
}
ProgramInformation::~ProgramInformation ()
{
}
std::string ProgramInformation::getTitle () throw(ElementNotPresentException)
{
if(this->title.empty())
throw ElementNotPresentException();
return this->title;
}
std::string ProgramInformation::getCopyright () throw(ElementNotPresentException)
{
if(this->copyright.empty())
throw ElementNotPresentException();
return this->copyright;
}
std::string ProgramInformation::getSource () throw(ElementNotPresentException)
{
if(this->source.empty())
throw ElementNotPresentException();
return this->source;
}
std::string ProgramInformation::getMoreInformationUrl () throw(AttributeNotPresentException)
{
if(this->attributes.find("moreInformationURL") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["moreInformationURL"];
}
void ProgramInformation::setTitle (std::string title)
{
this->title = title;
}
void ProgramInformation::setCopyright (std::string copyright)
{
this->copyright = copyright;
}
void ProgramInformation::setSource (std::string source)
{
this->source = source;
}
/*
* ProgramInformation.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 PROGRAMINFORMATION_H_
#define PROGRAMINFORMATION_H_
#include <string>
#include <map>
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class ProgramInformation
{
public:
ProgramInformation (std::map<std::string, std::string> attr);
virtual ~ProgramInformation ();
std::string getMoreInformationUrl () throw(dash::exception::AttributeNotPresentException);
std::string getTitle () throw(dash::exception::ElementNotPresentException);
std::string getSource () throw(dash::exception::ElementNotPresentException);
std::string getCopyright () throw(dash::exception::ElementNotPresentException);
void setTitle (std::string title);
void setSource (std::string source);
void setCopyright (std::string copyright);
private:
std::map<std::string, std::string> attributes;
std::string title;
std::string source;
std::string copyright;
};
}
}
#endif /* PROGRAMINFORMATION_H_ */
/*
* Rating.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 RATING_H_
#define RATING_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Rating : public ContentDescription
{
};
}
}
#endif /* RATING_H_ */
/*
* Representation.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 "Representation.h"
using namespace dash::mpd;
using namespace dash::exception;
Representation::Representation (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
this->contentProtection = NULL;
this->trickModeType = NULL;
this->segmentInfo = NULL;
}
Representation::~Representation ()
{
delete(this->segmentInfo);
delete(this->contentProtection);
delete(this->trickModeType);
}
std::string Representation::getFrameRate () throw(AttributeNotPresentException)
{
if(this->attributes.find("frameRate") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["frameRate"];
}
std::string Representation::getSamplingRate () throw(AttributeNotPresentException)
{
if(this->attributes.find("samplingRate") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["samplingRate"];
}
std::string Representation::getDependencyId () throw(AttributeNotPresentException)
{
if(this->attributes.find("dependencyId") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["dependencyId"];
}
std::string Representation::getId () throw(AttributeNotPresentException)
{
if(this->attributes.find("id") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["id"];
}
std::string Representation::getLang () throw(AttributeNotPresentException)
{
if(this->attributes.find("lang") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["lang"];
}
std::string Representation::getParX () throw(AttributeNotPresentException)
{
if(this->attributes.find("parx") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["parx"];
}
std::string Representation::getParY () throw(AttributeNotPresentException)
{
if(this->attributes.find("pary") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["pary"];
}
std::string Representation::getHeight () throw(AttributeNotPresentException)
{
if(this->attributes.find("height") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["height"];
}
std::string Representation::getWidth () throw(AttributeNotPresentException)
{
if(this->attributes.find("width") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["width"];
}
std::string Representation::getBandwidth () throw(AttributeNotPresentException)
{
if(this->attributes.find("bandwidth") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["bandwidth"];
}
std::string Representation::getNumberOfChannels () throw(AttributeNotPresentException)
{
if(this->attributes.find("numberOfChannels") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["numberOfChannels"];
}
SegmentInfo* Representation::getSegmentInfo () throw(ElementNotPresentException)
{
if(this->segmentInfo == NULL)
throw ElementNotPresentException();
return this->segmentInfo;
}
TrickModeType* Representation::getTrickModeType () throw(ElementNotPresentException)
{
if(this->segmentInfo == NULL)
throw ElementNotPresentException();
return this->trickModeType;
}
ContentProtection* Representation::getContentProtection () throw(ElementNotPresentException)
{
if(this->contentProtection == NULL)
throw ElementNotPresentException();
return this->contentProtection;
}
void Representation::setTrickModeType (TrickModeType *trickModeType)
{
this->trickModeType = trickModeType;
}
void Representation::setContentProtection (ContentProtection *protection)
{
this->contentProtection = protection;
}
void Representation::setSegmentInfo (SegmentInfo *info)
{
this->segmentInfo = info;
}
/*
* Representation.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 REPRESENTATION_H_
#define REPRESENTATION_H_
#include <string>
#include <vector>
#include <map>
#include "mpd/SegmentInfo.h"
#include "mpd/TrickModeType.h"
#include "mpd/ContentProtection.h"
#include "exceptions/AttributeNotPresentException.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class Representation
{
public:
Representation (std::map<std::string, std::string> attributes);
virtual ~Representation ();
std::string getWidth () throw(dash::exception::AttributeNotPresentException);
std::string getHeight () throw(dash::exception::AttributeNotPresentException);
std::string getParX () throw(dash::exception::AttributeNotPresentException);
std::string getParY () throw(dash::exception::AttributeNotPresentException);
std::string getLang () throw(dash::exception::AttributeNotPresentException);
std::string getFrameRate () throw(dash::exception::AttributeNotPresentException);
std::string getId () throw(dash::exception::AttributeNotPresentException);
std::string getBandwidth () throw(dash::exception::AttributeNotPresentException);
std::string getDependencyId () throw(dash::exception::AttributeNotPresentException);
std::string getNumberOfChannels () throw(dash::exception::AttributeNotPresentException);
std::string getSamplingRate () throw(dash::exception::AttributeNotPresentException);
SegmentInfo* getSegmentInfo () throw(dash::exception::ElementNotPresentException);
TrickModeType* getTrickModeType () throw(dash::exception::ElementNotPresentException);
ContentProtection* getContentProtection () throw(dash::exception::ElementNotPresentException);
void setSegmentInfo (SegmentInfo *info);
void setTrickModeType (TrickModeType *trickModeType);
void setContentProtection (ContentProtection *protection);
private:
std::map<std::string, std::string> attributes;
SegmentInfo *segmentInfo;
TrickModeType *trickModeType;
ContentProtection *contentProtection;
};
}
}
#endif /* REPRESENTATION_H_ */
/*
* SchemeInformation.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 "SchemeInformation.h"
using namespace dash::mpd;
SchemeInformation::SchemeInformation ()
{
}
SchemeInformation::~SchemeInformation ()
{
}
/*
* SchemeInformation.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 SCHEMEINFORMATION_H_
#define SCHEMEINFORMATION_H_
namespace dash
{
namespace mpd
{
class SchemeInformation
{
public:
SchemeInformation ();
virtual ~SchemeInformation ();
};
}
}
#endif /* SCHEMEINFORMATION_H_ */
/*
* Segment.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 "Segment.h"
using namespace dash::mpd;
using namespace dash::exception;
Segment::Segment (std::map<std::string, std::string> attributes)
{
this->attributes = attributes;
}
Segment::~Segment ()
{
}
std::string Segment::getSourceUrl () throw(AttributeNotPresentException)
{
if(this->attributes.find("sourceURL") == this->attributes.end())
throw AttributeNotPresentException();
return this->attributes["sourceURL"];
}
/*
* Segment.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 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
{
public:
Segment (std::map<std::string, std::string> attributes);
virtual ~Segment ();
std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException);
private:
std::map<std::string, std::string> attributes;
};
}
}
#endif /* SEGMENT_H_ */
/*
* SegmentInfo.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 "SegmentInfo.h"
using namespace dash::mpd;
using namespace dash::exception;
SegmentInfo::SegmentInfo(std::map<std::string,std::string> attr)
{
this->attributes = attr;
this->initSeg = NULL;
}
SegmentInfo::~SegmentInfo ()
{
for(int i = 0; i < this->segments.size(); i++)
delete(this->segments.at(i));
delete(this->initSeg);
}
InitSegment* SegmentInfo::getInitSegment () throw(ElementNotPresentException)
{
if(this->initSeg == NULL)
throw ElementNotPresentException();
return this->initSeg;
}
std::vector<Segment*> SegmentInfo::getSegments ()
{
return this->segments;
}
void SegmentInfo::addSegment (Segment *seg)
{
this->segments.push_back(seg);
}
void SegmentInfo::setInitSegment (InitSegment *initSeg)
{
this->initSeg = initSeg;
}
/*
* SegmentInfo.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 SEGMENTINFO_H_
#define SEGMENTINFO_H_
#include <vector>
#include <string>
#include <map>
#include "mpd/Segment.h"
#include "mpd/InitSegment.h"
#include "exceptions/ElementNotPresentException.h"
namespace dash
{
namespace mpd
{
class SegmentInfo
{
public:
SegmentInfo (std::map<std::string, std::string> attr);
virtual ~SegmentInfo ();
InitSegment* getInitSegment () throw(dash::exception::ElementNotPresentException);
std::vector<Segment *> getSegments ();
void setInitSegment (InitSegment *initSeg);
void addSegment (Segment *seg);
private:
std::map<std::string, std::string> attributes;
InitSegment *initSeg;
std::vector<Segment *> segments;
};
}
}
#endif /* SEGMENTINFO_H_ */
/*
* TrickModeType.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 "TrickModeType.h"
using namespace dash::mpd;
TrickModeType::TrickModeType ()
{
}
TrickModeType::~TrickModeType ()
{
}
/*
* TrickModeType.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 TRICKMODETYPE_H_
#define TRICKMODETYPE_H_
#include <string>
#include <map>
namespace dash
{
namespace mpd
{
class TrickModeType
{
public:
TrickModeType ();
virtual ~TrickModeType ();
std::string getAlternatePlayoutRate();
private:
std::map<std::string, std::string> attributes;
};
}
}
#endif /* TRICKMODETYPE_H_ */
/*
* Viewpoint.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 VIEWPOINT_H_
#define VIEWPOINT_H_
#include "mpd/ContentDescription.h"
namespace dash
{
namespace mpd
{
class Viewpoint : public ContentDescription
{
};
}
}
#endif /* VIEWPOINT_H_ */
/*
* DOMHelper.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 "DOMHelper.h"
using namespace dash::xml;
std::vector<Node *> DOMHelper::getElementByTagName (Node *root, std::string name, bool selfContain)
{
std::vector<Node *> elements;
for(int i = 0; i < root->getSubNodes().size(); i++)
{
getElementsByTagName(root->getSubNodes().at(i), name, &elements, selfContain);
}
return elements;
}
std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string name)
{
std::vector<Node *> elements;
for(int i = 0; i < root->getSubNodes().size(); i++)
{
if(!root->getSubNodes().at(i)->getName().compare(name))
elements.push_back(root->getSubNodes().at(i));
}
return elements;
}
void DOMHelper::getElementsByTagName (Node *root, std::string name, std::vector<Node*> *elements, bool selfContain)
{
if(!selfContain && !root->getName().compare(name))
{
elements->push_back(root);
return;
}
if(!root->getName().compare(name))
elements->push_back(root);
for(int i = 0; i < root->getSubNodes().size(); i++)
{
getElementsByTagName(root->getSubNodes().at(i), name, elements, selfContain);
}
}
/*
* DOMHelper.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 DOMHELPER_H_
#define DOMHELPER_H_
#include <vector>
#include <string>
#include "xml/Node.h"
namespace dash
{
namespace xml
{
class DOMHelper
{
public:
static std::vector<Node *> getElementByTagName (Node *root, std::string name, bool selfContain);
static std::vector<Node *> getChildElementByTagName (Node *root, std::string name);
private:
static void getElementsByTagName(Node *root, std::string name, std::vector<Node *> *elements, bool selfContain);
};
}
}
#endif /* DOMHELPER_H_ */
/*
* DOMParser.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 "DOMParser.h"
using namespace dash::xml;
using namespace dash::http;
using namespace dash::mpd;
DOMParser::DOMParser (stream_t *stream)
{
this->stream = stream;
this->init();
}
DOMParser::~DOMParser ()
{
if(this->vlc_reader)
xml_ReaderDelete(this->vlc_reader);
}
Node* DOMParser::getRootNode ()
{
return this->root;
}
bool DOMParser::parse ()
{
this->vlc_xml = xml_Create(this->stream);
if(!this->vlc_xml)
return false;
this->vlc_reader = xml_ReaderCreate(this->vlc_xml, this->stream);
if(!this->vlc_reader)
return false;
this->root = this->processNode();
return true;
}
Node* DOMParser::processNode ()
{
const char *data;
int type = xml_ReaderNextNode(this->vlc_reader, &data);
if(type != XML_READER_TEXT && type != XML_READER_NONE && type != XML_READER_ENDELEM)
{
Node *node = new Node();
std::string name = data;
bool isEmpty = xml_ReaderIsEmptyElement(this->vlc_reader);
node->setName(name);
this->addAttributesToNode(node);
if(isEmpty)
return node;
Node *subnode = NULL;
while(subnode = this->processNode())
node->addSubNode(subnode);
return node;
}
return NULL;
}
void DOMParser::addAttributesToNode (Node *node)
{
const char *attrValue;
const char *attrName;
while((attrName = xml_ReaderNextAttr(this->vlc_reader, &attrValue)) != NULL)
{
std::string key = attrName;
std::string value = attrValue;
node->addAttribute(key, value);
}
}
void DOMParser::print (Node *node, int offset)
{
for(int i = 0; i < offset; i++)
msg_Dbg(this->stream, " ");
msg_Dbg(this->stream, "%s", node->getName().c_str());
std::vector<std::string> keys = node->getAttributeKeys();
for(int i = 0; i < keys.size(); i++)
msg_Dbg(this->stream, " %s=%s", keys.at(i).c_str(), node->getAttributeValue(keys.at(i)).c_str());
msg_Dbg(this->stream, "\n");
offset++;
for(int i = 0; i < node->getSubNodes().size(); i++)
{
this->print(node->getSubNodes().at(i), offset);
}
}
void DOMParser::init ()
{
this->root = NULL;
this->vlc_reader = NULL;
}
void DOMParser::print ()
{
this->print(this->root, 0);
}
Profile DOMParser::getProfile (dash::xml::Node *node)
{
std::string profile = node->getAttributeValue("profiles");
if(!profile.compare("urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm"))
return dash::mpd::BasicCM;
return dash::mpd::NotValid;
}
bool DOMParser::isDash ()
{
const uint8_t *peek, *peek_end;
int64_t i_size = stream_Peek(this->stream, &peek, 2048);
if(i_size < 1)
return false;
peek_end = peek + i_size;
while(peek <= peek_end)
{
const char *p = strstr((const char*)peek, "urn:mpeg:mpegB:schema:DASH:MPD:DIS2011");
if (p != NULL)
return true;
peek++;
};
return false;
}
/*
* DOMParser.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 DOMPARSER_H_
#define DOMPARSER_H_
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_stream.h>
#include <vlc_xml.h>
#include <string.h>
#include <vector>
#include <iostream>
#include <cstdio>
#include <fstream>
#include <stdio.h>
#include "xml/Node.h"
#include "http/IHTTPConnection.h"
#include "mpd/IMPDManager.h"
namespace dash
{
namespace xml
{
class DOMParser
{
public:
DOMParser (stream_t *stream);
virtual ~DOMParser ();
bool parse ();
Node* getRootNode ();
void print ();
dash::mpd::Profile getProfile (dash::xml::Node *node);
bool isDash ();
private:
Node *root;
stream_t *stream;
xml_t *vlc_xml;
xml_reader_t *vlc_reader;
void init ();
Node* processNode ();
void addAttributesToNode (Node *node);
void print (Node *node, int offset);
};
}
}
#endif /* DOMPARSER_H_ */
/*
* Node.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 "Node.h"
using namespace dash::xml;
Node::Node ()
{
}
Node::~Node ()
{
for(int i = 0; i < this->subNodes.size(); i++)
delete(this->subNodes.at(i));
}
std::vector<Node*> Node::getSubNodes ()
{
return this->subNodes;
}
void Node::addSubNode (Node *node)
{
this->subNodes.push_back(node);
}
std::string Node::getName ()
{
return this->name;
}
void Node::setName (std::string name)
{
this->name = name;
}
std::string Node::getAttributeValue (std::string key)
{
return this->attributes[key];
}
void Node::addAttribute (std::string key, std::string value)
{
this->attributes[key] = value;
}
std::vector<std::string> Node::getAttributeKeys ()
{
std::vector<std::string> keys;
std::map<std::string, std::string>::const_iterator it;
for(it = this->attributes.begin(); it != this->attributes.end(); ++it)
{
keys.push_back(it->first);
}
return keys;
}
bool Node::hasText ()
{
return false;
}
std::string Node::getText ()
{
return "";
}
std::map<std::string,std::string> Node::getAttributes ()
{
return this->attributes;
}
/*
* Node.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 NODE_H_
#define NODE_H_
#include <vector>
#include <string>
#include <map>
#include <iostream>
namespace dash
{
namespace xml
{
class Node
{
public:
Node ();
virtual ~Node ();
std::vector<Node *> getSubNodes ();
void addSubNode (Node *node);
std::string getName ();
void setName (std::string name);
void addAttribute (std::string key, std::string value);
std::string getAttributeValue (std::string key);
std::vector<std::string> getAttributeKeys ();
bool hasText ();
std::string getText ();
std::map<std::string, std::string> getAttributes ();
private:
std::vector<Node *> subNodes;
std::map<std::string, std::string> attributes;
std::string name;
};
}
}
#endif /* NODE_H_ */
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