vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Thu Nov 27 15:35:53 2014 +0100| [75f7f4f68da9573782bbf9a2edee674ef0d53e1b] | committer: Francois Cartegnie
stream_filter: dash: add alwayslowest bitrate logic > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=75f7f4f68da9573782bbf9a2edee674ef0d53e1b --- modules/stream_filter/Makefile.am | 2 + .../adaptationlogic/AdaptationLogicFactory.cpp | 5 +- .../dash/adaptationlogic/AdaptationLogicFactory.h | 2 - .../AlwaysLowestAdaptationLogic.cpp | 65 +++++++++++++++++++- .../AlwaysLowestAdaptationLogic.hpp | 42 +++++++++++-- 5 files changed, 108 insertions(+), 8 deletions(-) diff --git a/modules/stream_filter/Makefile.am b/modules/stream_filter/Makefile.am index 3c002d1..fff34fb 100644 --- a/modules/stream_filter/Makefile.am +++ b/modules/stream_filter/Makefile.am @@ -15,6 +15,8 @@ libdash_plugin_la_SOURCES = \ stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h \ stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp \ stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h \ + stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp \ + stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp \ stream_filter/dash/adaptationlogic/IAdaptationLogic.h \ stream_filter/dash/adaptationlogic/IDownloadRateObserver.h \ stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h \ diff --git a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp index 7733960..727bc78 100644 --- a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp +++ b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp @@ -26,6 +26,9 @@ #endif #include "AdaptationLogicFactory.h" +#include "adaptationlogic/AlwaysBestAdaptationLogic.h" +#include "adaptationlogic/RateBasedAdaptationLogic.h" +#include "adaptationlogic/AlwaysLowestAdaptationLogic.hpp" using namespace dash::logic; using namespace dash::xml; @@ -38,8 +41,8 @@ IAdaptationLogic* AdaptationLogicFactory::create ( IAdaptationLogic::LogicType l { case IAdaptationLogic::AlwaysBest: return new AlwaysBestAdaptationLogic (mpdManager); case IAdaptationLogic::RateBased: return new RateBasedAdaptationLogic (mpdManager); + case IAdaptationLogic::AlwaysLowest: return new AlwaysLowestAdaptationLogic (mpdManager); case IAdaptationLogic::Default: - case IAdaptationLogic::AlwaysLowest: default: return NULL; } diff --git a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h index 4f17f8a..855ab9e 100644 --- a/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h +++ b/modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h @@ -28,8 +28,6 @@ #include "adaptationlogic/IAdaptationLogic.h" #include "xml/Node.h" #include "mpd/MPDManager.hpp" -#include "adaptationlogic/AlwaysBestAdaptationLogic.h" -#include "adaptationlogic/RateBasedAdaptationLogic.h" struct stream_t; diff --git a/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp b/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp index c5334f6..38e34c2 100644 --- a/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp +++ b/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp @@ -1,5 +1,68 @@ +/* + * AlwaysLowestAdaptationLogic.cpp + ***************************************************************************** + * Copyright (C) 2014 - VideoLAN authors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ #include "AlwaysLowestAdaptationLogic.hpp" +#include "Representationselectors.hpp" -AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic() +using namespace dash::logic; +using namespace dash::http; +using namespace dash::mpd; + +AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic(dash::mpd::MPDManager *mpdManager): + AbstractAdaptationLogic(mpdManager), + currentPeriod(mpdManager->getFirstPeriod()), + count(0) +{ +} + +Chunk* AlwaysLowestAdaptationLogic::getNextChunk() +{ + if(!currentPeriod) + return NULL; + + const Representation *rep = getCurrentRepresentation(); + if ( rep == NULL ) + return NULL; + + std::vector<ISegment *> segments = rep->getSegments(); + if ( count == segments.size() ) + { + currentPeriod = mpdManager->getNextPeriod(currentPeriod); + count = 0; + return getNextChunk(); + } + + if ( segments.size() > count ) + { + ISegment *seg = segments.at( count ); + Chunk *chunk = seg->toChunk(); + //In case of UrlTemplate, we must stay on the same segment. + if ( seg->isSingleShot() == true ) + count++; + seg->done(); + return chunk; + } + return NULL; +} + +const Representation *AlwaysLowestAdaptationLogic::getCurrentRepresentation() const { + RepresentationSelector selector; + return selector.select(currentPeriod, 0); } diff --git a/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp b/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp index 3707b00..b59cff7 100644 --- a/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp +++ b/modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp @@ -1,10 +1,44 @@ +/* + * AlwaysLowestAdaptationLogic.hpp + ***************************************************************************** + * Copyright (C) 2014 - VideoLAN authors + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ #ifndef ALWAYSLOWESTADAPTATIONLOGIC_HPP #define ALWAYSLOWESTADAPTATIONLOGIC_HPP -class AlwaysLowestAdaptationLogic +#include "AbstractAdaptationLogic.h" + +namespace dash { -public: - AlwaysLowestAdaptationLogic(); -}; + namespace logic + { + class AlwaysLowestAdaptationLogic : public AbstractAdaptationLogic + { + public: + AlwaysLowestAdaptationLogic(dash::mpd::MPDManager *mpdManager); + + virtual dash::http::Chunk* getNextChunk (); + virtual const dash::mpd::Representation* getCurrentRepresentation() const; + + private: + dash::mpd::Period *currentPeriod; + size_t count; + }; + } +} #endif // ALWAYSLOWESTADAPTATIONLOGIC_HPP _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits