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 \
#endif
#include "AdaptationLogicFactory.h"
+#include "adaptationlogic/AlwaysBestAdaptationLogic.h"
+#include "adaptationlogic/RateBasedAdaptationLogic.h"
+#include "adaptationlogic/AlwaysLowestAdaptationLogic.hpp"
using namespace dash::logic;
using namespace dash::xml;
{
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;
}
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
#include "mpd/MPDManager.hpp"
-#include "adaptationlogic/AlwaysBestAdaptationLogic.h"
-#include "adaptationlogic/RateBasedAdaptationLogic.h"
struct stream_t;
+/*
+ * 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);
}
+/*
+ * 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