From: Christopher Mueller Date: Fri, 7 Oct 2011 02:36:57 +0000 (-0700) Subject: Added DASH stream filter X-Git-Tag: 1.2.0-pre1~89 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f3600cde89b93c2291b72d4b918589e72825dc94;p=vlc Added DASH stream filter Signed-off-by: Jean-Baptiste Kempf --- diff --git a/configure.ac b/configure.ac index d30dc83cde..63dd1fe7b1 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/modules/stream_filter/Modules.am b/modules/stream_filter/Modules.am index bdc2e69d55..a864ebafe4 100644 --- a/modules/stream_filter/Modules.am +++ b/modules/stream_filter/Modules.am @@ -1,3 +1,5 @@ +SUBDIRS = dash + SOURCES_decomp = decomp.c SOURCES_stream_filter_record = record.c SOURCES_stream_filter_httplive = httplive.c diff --git a/modules/stream_filter/dash/DASHManager.cpp b/modules/stream_filter/dash/DASHManager.cpp new file mode 100644 index 0000000000..7483ca47f4 --- /dev/null +++ b/modules/stream_filter/dash/DASHManager.cpp @@ -0,0 +1,99 @@ +/* + * DASHManager.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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; +} diff --git a/modules/stream_filter/dash/DASHManager.h b/modules/stream_filter/dash/DASHManager.h new file mode 100644 index 0000000000..394d010b04 --- /dev/null +++ b/modules/stream_filter/dash/DASHManager.h @@ -0,0 +1,64 @@ +/* + * DASHManager.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#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_ */ diff --git a/modules/stream_filter/dash/Modules.am b/modules/stream_filter/dash/Modules.am new file mode 100644 index 0000000000..01ff93c7ea --- /dev/null +++ b/modules/stream_filter/dash/Modules.am @@ -0,0 +1,71 @@ +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 diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp new file mode 100644 index 0000000000..5a5c1bc3a3 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp @@ -0,0 +1,57 @@ +/* + * AbstractAdaptationLogic.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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; +} diff --git a/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h new file mode 100644 index 0000000000..d66c0dc1cc --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h @@ -0,0 +1,64 @@ +/* + * AbstractAdaptationLogic.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp new file mode 100644 index 0000000000..3e286521c5 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp @@ -0,0 +1,54 @@ +/* + * AdaptationLogicFactory.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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); + } +} diff --git a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h new file mode 100644 index 0000000000..9988d2eb1c --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h @@ -0,0 +1,50 @@ +/* + * AdaptationLogicFactory.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp new file mode 100644 index 0000000000..55798c5471 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp @@ -0,0 +1,86 @@ +/* + * AlwaysBestAdaptationLogic.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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 segments = this->mpdManager->getSegments(best); + for(int j = 0; j < segments.size(); j++) + { + this->schedule.push_back(segments.at(j)); + } + } + } + } +} diff --git a/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h new file mode 100644 index 0000000000..9c8273f1c1 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h @@ -0,0 +1,61 @@ +/* + * AlwaysBestAdaptationLogic.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +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 schedule; + dash::mpd::IMPDManager *mpdManager; + int count; + + void initSchedule(); + }; + } +} + +#endif /* ALWAYSBESTADAPTATIONLOGIC_H_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h new file mode 100644 index 0000000000..ef386046f9 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/IAdaptationLogic.h @@ -0,0 +1,54 @@ +/* + * IAdaptationLogic.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +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_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/IDownloadRateObserver.h b/modules/stream_filter/dash/adaptationlogic/IDownloadRateObserver.h new file mode 100644 index 0000000000..cc4759cbd1 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/IDownloadRateObserver.h @@ -0,0 +1,40 @@ +/* + * IDownloadRateObserver.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/NullAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/NullAdaptationLogic.h new file mode 100644 index 0000000000..a5e88ed070 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/NullAdaptationLogic.h @@ -0,0 +1,49 @@ +/* + * NullAdaptationLogic.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp new file mode 100644 index 0000000000..0e57965204 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp @@ -0,0 +1,80 @@ +/* + * RateBasedAdaptationLogic.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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; + } + } +} diff --git a/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h new file mode 100644 index 0000000000..2db342adb5 --- /dev/null +++ b/modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h @@ -0,0 +1,55 @@ +/* + * RateBasedAdaptationLogic.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/dash.cpp b/modules/stream_filter/dash/dash.cpp new file mode 100644 index 0000000000..f94e94e7d7 --- /dev/null +++ b/modules/stream_filter/dash/dash.cpp @@ -0,0 +1,222 @@ +/***************************************************************************** + * dash.cpp: DASH module + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#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; +} diff --git a/modules/stream_filter/dash/exceptions/AttributeNotPresentException.h b/modules/stream_filter/dash/exceptions/AttributeNotPresentException.h new file mode 100644 index 0000000000..9e85986adb --- /dev/null +++ b/modules/stream_filter/dash/exceptions/AttributeNotPresentException.h @@ -0,0 +1,42 @@ +/* + * AttributeNotPresentException.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +namespace dash +{ + namespace exception + { + class AttributeNotPresentException : public std::exception + { + public: + AttributeNotPresentException() : std::exception() {} + }; + } +} + +#endif /* ATTRIBUTENOTPRESENTEXCEPTION_H_ */ diff --git a/modules/stream_filter/dash/exceptions/EOFException.h b/modules/stream_filter/dash/exceptions/EOFException.h new file mode 100644 index 0000000000..06a95d198f --- /dev/null +++ b/modules/stream_filter/dash/exceptions/EOFException.h @@ -0,0 +1,42 @@ +/* + * EOFException.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +namespace dash +{ + namespace exception + { + class EOFException : public std::exception + { + public: + EOFException() : std::exception() {} + }; + } +} + +#endif /* EOFEXCEPTION_H_ */ diff --git a/modules/stream_filter/dash/exceptions/ElementNotPresentException.h b/modules/stream_filter/dash/exceptions/ElementNotPresentException.h new file mode 100644 index 0000000000..7e2fc0f4af --- /dev/null +++ b/modules/stream_filter/dash/exceptions/ElementNotPresentException.h @@ -0,0 +1,43 @@ +/* + * ElementNotPresentException.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +namespace dash +{ + namespace exception + { + class ElementNotPresentException : public std::exception + { + public: + ElementNotPresentException() : std::exception() {} + + }; + } +} + +#endif /* ELEMENTNOTPRESENTEXCEPTION_H_ */ diff --git a/modules/stream_filter/dash/http/Chunk.cpp b/modules/stream_filter/dash/http/Chunk.cpp new file mode 100644 index 0000000000..023c7e60fb --- /dev/null +++ b/modules/stream_filter/dash/http/Chunk.cpp @@ -0,0 +1,63 @@ +/* + * Chunk.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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; +} diff --git a/modules/stream_filter/dash/http/Chunk.h b/modules/stream_filter/dash/http/Chunk.h new file mode 100644 index 0000000000..07055c31d3 --- /dev/null +++ b/modules/stream_filter/dash/http/Chunk.h @@ -0,0 +1,58 @@ +/* + * Chunk.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +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 optionalUrls; + int startByte; + int endByte; + + }; + } +} + +#endif /* CHUNK_H_ */ diff --git a/modules/stream_filter/dash/http/HTTPConnection.cpp b/modules/stream_filter/dash/http/HTTPConnection.cpp new file mode 100644 index 0000000000..07a4be24d4 --- /dev/null +++ b/modules/stream_filter/dash/http/HTTPConnection.cpp @@ -0,0 +1,128 @@ +/* + * HTTPConnection.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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); +} diff --git a/modules/stream_filter/dash/http/HTTPConnection.h b/modules/stream_filter/dash/http/HTTPConnection.h new file mode 100644 index 0000000000..fcf6012c35 --- /dev/null +++ b/modules/stream_filter/dash/http/HTTPConnection.h @@ -0,0 +1,77 @@ +/* + * HTTPConnection.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include +#include + +#include +#include +#include +#include + +#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_ */ diff --git a/modules/stream_filter/dash/http/HTTPConnectionManager.cpp b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp new file mode 100644 index 0000000000..fb71f303cd --- /dev/null +++ b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp @@ -0,0 +1,166 @@ +/* + * HTTPConnectionManager.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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::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::iterator it = this->connections.begin(); it != this->connections.end(); ++it) + { + (*it)->closeSocket(); + delete(*it); + } + this->connections.clear(); + this->urlMap.clear(); + + std::map::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); +} diff --git a/modules/stream_filter/dash/http/HTTPConnectionManager.h b/modules/stream_filter/dash/http/HTTPConnectionManager.h new file mode 100644 index 0000000000..64f3bbea51 --- /dev/null +++ b/modules/stream_filter/dash/http/HTTPConnectionManager.h @@ -0,0 +1,80 @@ +/* + * HTTPConnectionManager.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +#include +#include +#include +#include +#include +#include + +#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 connections; + std::map chunkMap; + std::map urlMap; + std::vector 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_ */ diff --git a/modules/stream_filter/dash/http/IHTTPConnection.h b/modules/stream_filter/dash/http/IHTTPConnection.h new file mode 100644 index 0000000000..54e30c0688 --- /dev/null +++ b/modules/stream_filter/dash/http/IHTTPConnection.h @@ -0,0 +1,44 @@ +/* + * IHTTPConnection.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +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_ */ diff --git a/modules/stream_filter/dash/mpd/Accessibility.h b/modules/stream_filter/dash/mpd/Accessibility.h new file mode 100644 index 0000000000..4dbac78fa2 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Accessibility.h @@ -0,0 +1,40 @@ +/* + * Accessibility.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/BaseUrl.h b/modules/stream_filter/dash/mpd/BaseUrl.h new file mode 100644 index 0000000000..02088e3bdb --- /dev/null +++ b/modules/stream_filter/dash/mpd/BaseUrl.h @@ -0,0 +1,48 @@ +/* + * BaseUrl.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +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_ */ diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.cpp b/modules/stream_filter/dash/mpd/BasicCMManager.cpp new file mode 100644 index 0000000000..f982b0ac0b --- /dev/null +++ b/modules/stream_filter/dash/mpd/BasicCMManager.cpp @@ -0,0 +1,158 @@ +/* + * BasicCMManager.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 BasicCMManager::getSegments (Representation *rep) +{ + std::vector retSegments; + try + { + SegmentInfo* info = rep->getSegmentInfo(); + InitSegment* init = info->getInitSegment(); + + retSegments.push_back(init); + + std::vector 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 BasicCMManager::getPeriods () +{ + return this->mpd->getPeriods(); +} +Representation* BasicCMManager::getBestRepresentation (Period *period) +{ + std::vector groups = period->getGroups(); + + long bitrate = 0; + Representation *best = NULL; + + for(int i = 0; i < groups.size(); i++) + { + std::vector 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 periods = this->mpd->getPeriods(); + + if(periods.size() == 0) + return NULL; + + return periods.at(0); +} +Representation* BasicCMManager::getRepresentation (Period *period, long bitrate) +{ + std::vector groups = period->getGroups(); + + Representation *best = NULL; + long bestDif = -1; + + for(int i = 0; i < groups.size(); i++) + { + std::vector 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 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; +} diff --git a/modules/stream_filter/dash/mpd/BasicCMManager.h b/modules/stream_filter/dash/mpd/BasicCMManager.h new file mode 100644 index 0000000000..9c399c9006 --- /dev/null +++ b/modules/stream_filter/dash/mpd/BasicCMManager.h @@ -0,0 +1,67 @@ +/* + * BasicCMManager.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#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 getPeriods (); + Period* getFirstPeriod (); + Period* getNextPeriod (Period *period); + Representation* getBestRepresentation (Period *period); + std::vector getSegments (Representation *rep); + Representation* getRepresentation (Period *period, long bitrate); + + private: + MPD *mpd; + }; + } +} + +#endif /* BASICCMMANAGER_H_ */ diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.cpp b/modules/stream_filter/dash/mpd/BasicCMParser.cpp new file mode 100644 index 0000000000..e508baf010 --- /dev/null +++ b/modules/stream_filter/dash/mpd/BasicCMParser.cpp @@ -0,0 +1,132 @@ +/* + * BasicCMParser.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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 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 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 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 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 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 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; +} diff --git a/modules/stream_filter/dash/mpd/BasicCMParser.h b/modules/stream_filter/dash/mpd/BasicCMParser.h new file mode 100644 index 0000000000..5813b912e2 --- /dev/null +++ b/modules/stream_filter/dash/mpd/BasicCMParser.h @@ -0,0 +1,69 @@ +/* + * BasicCMParser.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/ContentDescription.cpp b/modules/stream_filter/dash/mpd/ContentDescription.cpp new file mode 100644 index 0000000000..6854a031cc --- /dev/null +++ b/modules/stream_filter/dash/mpd/ContentDescription.cpp @@ -0,0 +1,61 @@ +/* + * ContentDescription.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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; +} diff --git a/modules/stream_filter/dash/mpd/ContentDescription.h b/modules/stream_filter/dash/mpd/ContentDescription.h new file mode 100644 index 0000000000..d777f844ec --- /dev/null +++ b/modules/stream_filter/dash/mpd/ContentDescription.h @@ -0,0 +1,56 @@ +/* + * ContentDescription.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +#include "mpd/SchemeInformation.h" +#include "exceptions/AttributeNotPresentException.h" +#include "exceptions/ElementNotPresentException.h" + +namespace dash +{ + namespace mpd + { + class ContentDescription + { + public: + ContentDescription (std::map attributes); + virtual ~ContentDescription (); + + std::string getSchemeIdUri () throw(dash::exception::AttributeNotPresentException); + SchemeInformation* getSchemeInformation () throw(dash::exception::ElementNotPresentException); + void setSchemeInformation (SchemeInformation *schemeInfo); + + private: + std::map attributes; + SchemeInformation *schemeInformation; + }; + } +} + +#endif /* CONTENTDESCRIPTION_H_ */ diff --git a/modules/stream_filter/dash/mpd/ContentProtection.h b/modules/stream_filter/dash/mpd/ContentProtection.h new file mode 100644 index 0000000000..c51886dad0 --- /dev/null +++ b/modules/stream_filter/dash/mpd/ContentProtection.h @@ -0,0 +1,40 @@ +/* + * ContentProtection.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/Group.cpp b/modules/stream_filter/dash/mpd/Group.cpp new file mode 100644 index 0000000000..1807f04850 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Group.cpp @@ -0,0 +1,170 @@ +/* + * Group.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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 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; +} diff --git a/modules/stream_filter/dash/mpd/Group.h b/modules/stream_filter/dash/mpd/Group.h new file mode 100644 index 0000000000..05809538e1 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Group.h @@ -0,0 +1,83 @@ +/* + * Group.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#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 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 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 attributes; + std::vector representations; + ContentProtection *contentProtection; + Accessibility *accessibility; + Viewpoint *viewpoint; + Rating *rating; + }; + } +} + +#endif /* GROUP_H_ */ diff --git a/modules/stream_filter/dash/mpd/IMPDManager.h b/modules/stream_filter/dash/mpd/IMPDManager.h new file mode 100644 index 0000000000..7b6491d85d --- /dev/null +++ b/modules/stream_filter/dash/mpd/IMPDManager.h @@ -0,0 +1,38 @@ +/* + * 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 getPeriods () = 0; + virtual Period* getFirstPeriod () = 0; + virtual Period* getNextPeriod (Period *period) = 0; + virtual Representation* getBestRepresentation (Period *period) = 0; + virtual std::vector getSegments (Representation *rep) = 0; + virtual Representation* getRepresentation (Period *period, long bitrate) = 0; + }; + } +} +#endif /* IMPDMANAGER_H_ */ diff --git a/modules/stream_filter/dash/mpd/IMPDParser.h b/modules/stream_filter/dash/mpd/IMPDParser.h new file mode 100644 index 0000000000..cea7b388da --- /dev/null +++ b/modules/stream_filter/dash/mpd/IMPDParser.h @@ -0,0 +1,43 @@ +/* + * IMPDParser.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/ISegment.h b/modules/stream_filter/dash/mpd/ISegment.h new file mode 100644 index 0000000000..7464021254 --- /dev/null +++ b/modules/stream_filter/dash/mpd/ISegment.h @@ -0,0 +1,44 @@ +/* + * ISegment.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 + +#include "exceptions/AttributeNotPresentException.h" + +namespace dash +{ + namespace mpd + { + class ISegment + { + public: + virtual std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException) = 0; + }; + } +} + +#endif /* ISEGMENT_H_ */ diff --git a/modules/stream_filter/dash/mpd/InitSegment.cpp b/modules/stream_filter/dash/mpd/InitSegment.cpp new file mode 100644 index 0000000000..1c86c5ce89 --- /dev/null +++ b/modules/stream_filter/dash/mpd/InitSegment.cpp @@ -0,0 +1,48 @@ +/* + * InitSegment.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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"]; +} diff --git a/modules/stream_filter/dash/mpd/InitSegment.h b/modules/stream_filter/dash/mpd/InitSegment.h new file mode 100644 index 0000000000..41dd04000f --- /dev/null +++ b/modules/stream_filter/dash/mpd/InitSegment.h @@ -0,0 +1,52 @@ +/* + * InitSegment.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +#include "exceptions/AttributeNotPresentException.h" +#include "mpd/ISegment.h" + +namespace dash +{ + namespace mpd + { + class InitSegment : public ISegment + { + public: + InitSegment (std::map attributes); + virtual ~InitSegment(); + + std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException); + + private: + std::map attributes; + }; + } +} + +#endif /* INITSEGMENT_H_ */ diff --git a/modules/stream_filter/dash/mpd/MPD.cpp b/modules/stream_filter/dash/mpd/MPD.cpp new file mode 100644 index 0000000000..1157f65d90 --- /dev/null +++ b/modules/stream_filter/dash/mpd/MPD.cpp @@ -0,0 +1,100 @@ +/* + * MPD.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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 MPD::getPeriods () +{ + return this->periods; +} +std::vector 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; +} diff --git a/modules/stream_filter/dash/mpd/MPD.h b/modules/stream_filter/dash/mpd/MPD.h new file mode 100644 index 0000000000..732d38b3ad --- /dev/null +++ b/modules/stream_filter/dash/mpd/MPD.h @@ -0,0 +1,68 @@ +/* + * MPD.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#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 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 getBaseUrls (); + std::vector getPeriods (); + ProgramInformation* getProgramInformation () throw(dash::exception::ElementNotPresentException); + + void addPeriod (Period *period); + void addBaseUrl (BaseUrl *url); + void setProgramInformation (ProgramInformation *progInfo); + + private: + std::map attributes; + std::vector periods; + std::vector baseUrls; + ProgramInformation *programInfo; + }; + } +} +#endif /* MPD_H_ */ diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp new file mode 100644 index 0000000000..fdf3e2e68b --- /dev/null +++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.cpp @@ -0,0 +1,68 @@ +/* + * MPDManagerFactory.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Apr 20, 2011 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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; +} diff --git a/modules/stream_filter/dash/mpd/MPDManagerFactory.h b/modules/stream_filter/dash/mpd/MPDManagerFactory.h new file mode 100644 index 0000000000..6741696457 --- /dev/null +++ b/modules/stream_filter/dash/mpd/MPDManagerFactory.h @@ -0,0 +1,52 @@ +/* + * MPDManagerFactory.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Apr 20, 2011 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/NullManager.cpp b/modules/stream_filter/dash/mpd/NullManager.cpp new file mode 100644 index 0000000000..4568b83235 --- /dev/null +++ b/modules/stream_filter/dash/mpd/NullManager.cpp @@ -0,0 +1,63 @@ +/* + * NullManager.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Apr 20, 2011 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 NullManager::getPeriods () +{ + return std::vector(); +} +Period* NullManager::getFirstPeriod () +{ + return NULL; +} +Period* NullManager::getNextPeriod (Period *period) +{ + return NULL; +} +Representation* NullManager::getBestRepresentation (Period *period) +{ + return NULL; +} +std::vector NullManager::getSegments (Representation *rep) +{ + return std::vector(); +} +Representation* NullManager::getRepresentation (Period *period, long bitrate) +{ + return NULL; +} diff --git a/modules/stream_filter/dash/mpd/NullManager.h b/modules/stream_filter/dash/mpd/NullManager.h new file mode 100644 index 0000000000..fc17bfa14f --- /dev/null +++ b/modules/stream_filter/dash/mpd/NullManager.h @@ -0,0 +1,55 @@ +/* + * NullManager.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Apr 20, 2011 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 getPeriods (); + Period* getFirstPeriod (); + Period* getNextPeriod (Period *period); + Representation* getBestRepresentation (Period *period); + std::vector getSegments (Representation *rep); + Representation* getRepresentation (Period *period, long bitrate); + }; + } +} + +#endif /* NULLMANAGER_H_ */ diff --git a/modules/stream_filter/dash/mpd/Period.cpp b/modules/stream_filter/dash/mpd/Period.cpp new file mode 100644 index 0000000000..4a795be4a1 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Period.cpp @@ -0,0 +1,49 @@ +/* + * Period.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 attributes) +{ + this->attributes = attributes; +} +Period::~Period () +{ + for(int i = 0; i < this->groups.size(); i++) + delete(this->groups.at(i)); +} + +std::vector Period::getGroups () +{ + return this->groups; +} +void Period::addGroup (Group *group) +{ + this->groups.push_back(group); +} diff --git a/modules/stream_filter/dash/mpd/Period.h b/modules/stream_filter/dash/mpd/Period.h new file mode 100644 index 0000000000..d019bc4b0d --- /dev/null +++ b/modules/stream_filter/dash/mpd/Period.h @@ -0,0 +1,56 @@ +/* + * Period.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#include "mpd/Group.h" +#include "mpd/Representation.h" + +namespace dash +{ + namespace mpd + { + class Period + { + public: + Period (std::map attributes); + virtual ~Period (); + + std::vector getGroups (); + void addGroup (Group *group); + + private: + std::map attributes; + std::vector groups; + + + }; + } +} + +#endif /* PERIOD_H_ */ diff --git a/modules/stream_filter/dash/mpd/ProgramInformation.cpp b/modules/stream_filter/dash/mpd/ProgramInformation.cpp new file mode 100644 index 0000000000..669ee8ecf5 --- /dev/null +++ b/modules/stream_filter/dash/mpd/ProgramInformation.cpp @@ -0,0 +1,81 @@ +/* + * ProgramInformation.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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; +} diff --git a/modules/stream_filter/dash/mpd/ProgramInformation.h b/modules/stream_filter/dash/mpd/ProgramInformation.h new file mode 100644 index 0000000000..44b22f8707 --- /dev/null +++ b/modules/stream_filter/dash/mpd/ProgramInformation.h @@ -0,0 +1,62 @@ +/* + * ProgramInformation.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +#include "exceptions/AttributeNotPresentException.h" +#include "exceptions/ElementNotPresentException.h" + +namespace dash +{ + namespace mpd + { + class ProgramInformation + { + public: + ProgramInformation (std::map 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 attributes; + std::string title; + std::string source; + std::string copyright; + }; + } +} + +#endif /* PROGRAMINFORMATION_H_ */ diff --git a/modules/stream_filter/dash/mpd/Rating.h b/modules/stream_filter/dash/mpd/Rating.h new file mode 100644 index 0000000000..e2831de23d --- /dev/null +++ b/modules/stream_filter/dash/mpd/Rating.h @@ -0,0 +1,40 @@ +/* + * Rating.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/Representation.cpp b/modules/stream_filter/dash/mpd/Representation.cpp new file mode 100644 index 0000000000..160e763e87 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Representation.cpp @@ -0,0 +1,167 @@ +/* + * Representation.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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; +} diff --git a/modules/stream_filter/dash/mpd/Representation.h b/modules/stream_filter/dash/mpd/Representation.h new file mode 100644 index 0000000000..1b6debffa9 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Representation.h @@ -0,0 +1,77 @@ +/* + * Representation.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#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 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 attributes; + SegmentInfo *segmentInfo; + TrickModeType *trickModeType; + ContentProtection *contentProtection; + + }; + } +} + +#endif /* REPRESENTATION_H_ */ diff --git a/modules/stream_filter/dash/mpd/SchemeInformation.cpp b/modules/stream_filter/dash/mpd/SchemeInformation.cpp new file mode 100644 index 0000000000..829e3ce748 --- /dev/null +++ b/modules/stream_filter/dash/mpd/SchemeInformation.cpp @@ -0,0 +1,38 @@ +/* + * SchemeInformation.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 () +{ +} diff --git a/modules/stream_filter/dash/mpd/SchemeInformation.h b/modules/stream_filter/dash/mpd/SchemeInformation.h new file mode 100644 index 0000000000..8ca967e646 --- /dev/null +++ b/modules/stream_filter/dash/mpd/SchemeInformation.h @@ -0,0 +1,41 @@ +/* + * SchemeInformation.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/mpd/Segment.cpp b/modules/stream_filter/dash/mpd/Segment.cpp new file mode 100644 index 0000000000..86634fae23 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Segment.cpp @@ -0,0 +1,47 @@ +/* + * Segment.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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"]; +} diff --git a/modules/stream_filter/dash/mpd/Segment.h b/modules/stream_filter/dash/mpd/Segment.h new file mode 100644 index 0000000000..1f45d5d697 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Segment.h @@ -0,0 +1,52 @@ +/* + * Segment.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +#include "exceptions/AttributeNotPresentException.h" +#include "mpd/ISegment.h" + +namespace dash +{ + namespace mpd + { + class Segment : public ISegment + { + public: + Segment (std::map attributes); + virtual ~Segment (); + + std::string getSourceUrl() throw(dash::exception::AttributeNotPresentException); + + private: + std::map attributes; + }; + } +} + +#endif /* SEGMENT_H_ */ diff --git a/modules/stream_filter/dash/mpd/SegmentInfo.cpp b/modules/stream_filter/dash/mpd/SegmentInfo.cpp new file mode 100644 index 0000000000..cf66359e89 --- /dev/null +++ b/modules/stream_filter/dash/mpd/SegmentInfo.cpp @@ -0,0 +1,64 @@ +/* + * SegmentInfo.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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 SegmentInfo::getSegments () +{ + return this->segments; +} +void SegmentInfo::addSegment (Segment *seg) +{ + this->segments.push_back(seg); +} +void SegmentInfo::setInitSegment (InitSegment *initSeg) +{ + this->initSeg = initSeg; +} diff --git a/modules/stream_filter/dash/mpd/SegmentInfo.h b/modules/stream_filter/dash/mpd/SegmentInfo.h new file mode 100644 index 0000000000..43cce91dd8 --- /dev/null +++ b/modules/stream_filter/dash/mpd/SegmentInfo.h @@ -0,0 +1,59 @@ +/* + * SegmentInfo.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include + +#include "mpd/Segment.h" +#include "mpd/InitSegment.h" +#include "exceptions/ElementNotPresentException.h" + +namespace dash +{ + namespace mpd + { + class SegmentInfo + { + public: + SegmentInfo (std::map attr); + virtual ~SegmentInfo (); + + InitSegment* getInitSegment () throw(dash::exception::ElementNotPresentException); + std::vector getSegments (); + void setInitSegment (InitSegment *initSeg); + void addSegment (Segment *seg); + + private: + std::map attributes; + InitSegment *initSeg; + std::vector segments; + }; + } +} + +#endif /* SEGMENTINFO_H_ */ diff --git a/modules/stream_filter/dash/mpd/TrickModeType.cpp b/modules/stream_filter/dash/mpd/TrickModeType.cpp new file mode 100644 index 0000000000..8e4a5872a0 --- /dev/null +++ b/modules/stream_filter/dash/mpd/TrickModeType.cpp @@ -0,0 +1,38 @@ +/* + * TrickModeType.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 () +{ +} diff --git a/modules/stream_filter/dash/mpd/TrickModeType.h b/modules/stream_filter/dash/mpd/TrickModeType.h new file mode 100644 index 0000000000..9f61d0ad12 --- /dev/null +++ b/modules/stream_filter/dash/mpd/TrickModeType.h @@ -0,0 +1,48 @@ +/* + * TrickModeType.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +namespace dash +{ + namespace mpd + { + class TrickModeType + { + public: + TrickModeType (); + virtual ~TrickModeType (); + + std::string getAlternatePlayoutRate(); + + private: + std::map attributes; + }; + } +} +#endif /* TRICKMODETYPE_H_ */ diff --git a/modules/stream_filter/dash/mpd/Viewpoint.h b/modules/stream_filter/dash/mpd/Viewpoint.h new file mode 100644 index 0000000000..ea33154d13 --- /dev/null +++ b/modules/stream_filter/dash/mpd/Viewpoint.h @@ -0,0 +1,40 @@ +/* + * Viewpoint.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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_ */ diff --git a/modules/stream_filter/dash/xml/DOMHelper.cpp b/modules/stream_filter/dash/xml/DOMHelper.cpp new file mode 100644 index 0000000000..a053237f72 --- /dev/null +++ b/modules/stream_filter/dash/xml/DOMHelper.cpp @@ -0,0 +1,70 @@ +/* + * DOMHelper.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 DOMHelper::getElementByTagName (Node *root, std::string name, bool selfContain) +{ + std::vector elements; + + for(int i = 0; i < root->getSubNodes().size(); i++) + { + getElementsByTagName(root->getSubNodes().at(i), name, &elements, selfContain); + } + + return elements; +} +std::vector DOMHelper::getChildElementByTagName (Node *root, std::string name) +{ + std::vector 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 *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); + } +} diff --git a/modules/stream_filter/dash/xml/DOMHelper.h b/modules/stream_filter/dash/xml/DOMHelper.h new file mode 100644 index 0000000000..75a93bbe57 --- /dev/null +++ b/modules/stream_filter/dash/xml/DOMHelper.h @@ -0,0 +1,49 @@ +/* + * DOMHelper.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include + +#include "xml/Node.h" + +namespace dash +{ + namespace xml + { + class DOMHelper + { + public: + static std::vector getElementByTagName (Node *root, std::string name, bool selfContain); + static std::vector getChildElementByTagName (Node *root, std::string name); + + private: + static void getElementsByTagName(Node *root, std::string name, std::vector *elements, bool selfContain); + }; + } +} + +#endif /* DOMHELPER_H_ */ diff --git a/modules/stream_filter/dash/xml/DOMParser.cpp b/modules/stream_filter/dash/xml/DOMParser.cpp new file mode 100644 index 0000000000..0cd74d696a --- /dev/null +++ b/modules/stream_filter/dash/xml/DOMParser.cpp @@ -0,0 +1,160 @@ +/* + * DOMParser.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 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; +} diff --git a/modules/stream_filter/dash/xml/DOMParser.h b/modules/stream_filter/dash/xml/DOMParser.h new file mode 100644 index 0000000000..5d47412779 --- /dev/null +++ b/modules/stream_filter/dash/xml/DOMParser.h @@ -0,0 +1,75 @@ +/* + * DOMParser.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#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_ */ diff --git a/modules/stream_filter/dash/xml/Node.cpp b/modules/stream_filter/dash/xml/Node.cpp new file mode 100644 index 0000000000..20914a85f5 --- /dev/null +++ b/modules/stream_filter/dash/xml/Node.cpp @@ -0,0 +1,87 @@ +/* + * Node.cpp + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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::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 Node::getAttributeKeys () +{ + std::vector keys; + std::map::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 Node::getAttributes () +{ + return this->attributes; +} diff --git a/modules/stream_filter/dash/xml/Node.h b/modules/stream_filter/dash/xml/Node.h new file mode 100644 index 0000000000..4a28c5f93f --- /dev/null +++ b/modules/stream_filter/dash/xml/Node.h @@ -0,0 +1,63 @@ +/* + * Node.h + ***************************************************************************** + * Copyright (C) 2010 - 2011 Klagenfurt University + * + * Created on: Aug 10, 2010 + * Authors: Christopher Mueller + * Christian Timmerer + * + * 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 +#include +#include +#include + +namespace dash +{ + namespace xml + { + class Node + { + public: + Node (); + virtual ~Node (); + + std::vector 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 getAttributeKeys (); + bool hasText (); + std::string getText (); + std::map getAttributes (); + + private: + std::vector subNodes; + std::map attributes; + std::string name; + + }; + } +} + +#endif /* NODE_H_ */