[vlc-commits] demux: adaptive: add debugging switch logic
Francois Cartegnie
git at videolan.org
Mon May 25 16:50:02 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed May 13 19:32:54 2020 +0200| [df82451c98490f068beccf2bbd7141a1c3bb0eec] | committer: Francois Cartegnie
demux: adaptive: add debugging switch logic
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=df82451c98490f068beccf2bbd7141a1c3bb0eec
---
modules/demux/Makefile.am | 2 ++
modules/demux/adaptive/PlaylistManager.cpp | 8 ++++++
modules/demux/adaptive/logic/RoundRobinLogic.cpp | 34 ++++++++++++++++++++++++
modules/demux/adaptive/logic/RoundRobinLogic.hpp | 29 ++++++++++++++++++++
modules/demux/adaptive/tools/Debug.hpp | 1 +
5 files changed, 74 insertions(+)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 954d2982e0..1f6d2ff7a3 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -353,6 +353,8 @@ libadaptive_plugin_la_SOURCES = \
demux/adaptive/logic/RateBasedAdaptationLogic.cpp \
demux/adaptive/logic/Representationselectors.hpp \
demux/adaptive/logic/Representationselectors.cpp \
+ demux/adaptive/logic/RoundRobinLogic.cpp \
+ demux/adaptive/logic/RoundRobinLogic.hpp \
demux/adaptive/mp4/AtomsReader.cpp \
demux/adaptive/mp4/AtomsReader.hpp \
demux/adaptive/http/AuthStorage.cpp \
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index c12aa3f474..bb1ad764b6 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -38,6 +38,9 @@
#include "logic/NearOptimalAdaptationLogic.hpp"
#include "logic/BufferingLogic.hpp"
#include "tools/Debug.hpp"
+#ifdef ADAPTIVE_DEBUGGING_LOGIC
+# include "logic/RoundRobinLogic.hpp"
+#endif
#include <vlc_stream.h>
#include <vlc_demux.h>
#include <vlc_threads.h>
@@ -800,6 +803,11 @@ AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::L
break;
}
case AbstractAdaptationLogic::Default:
+#ifdef ADAPTIVE_DEBUGGING_LOGIC
+ logic = new (std::nothrow) RoundRobinLogic(obj);
+ msg_Warn(p_demux, "using RoundRobinLogic every %u", RoundRobinLogic::QUANTUM);
+ break;
+#endif
case AbstractAdaptationLogic::NearOptimal:
{
NearOptimalAdaptationLogic *noplogic =
diff --git a/modules/demux/adaptive/logic/RoundRobinLogic.cpp b/modules/demux/adaptive/logic/RoundRobinLogic.cpp
new file mode 100644
index 0000000000..9b3daf50bb
--- /dev/null
+++ b/modules/demux/adaptive/logic/RoundRobinLogic.cpp
@@ -0,0 +1,34 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "RoundRobinLogic.hpp"
+
+#ifdef ADAPTIVE_DEBUGGING_LOGIC
+
+#include "Representationselectors.hpp"
+#include "../playlist/BaseAdaptationSet.h"
+
+using namespace adaptive::logic;
+using namespace adaptive::playlist;
+
+RoundRobinLogic::RoundRobinLogic (vlc_object_t *obj) :
+ AbstractAdaptationLogic (obj)
+{
+ index = 0;
+ call = 0;
+}
+
+BaseRepresentation *RoundRobinLogic::getNextRepresentation(BaseAdaptationSet *adaptSet,
+ BaseRepresentation *)
+{
+ if(adaptSet->getRepresentations().size() == 0)
+ return nullptr;
+ if((++call % QUANTUM) == 0)
+ index++;
+ if(index >= adaptSet->getRepresentations().size())
+ index = 0;
+ return adaptSet->getRepresentations().at(index);
+}
+
+#endif
diff --git a/modules/demux/adaptive/logic/RoundRobinLogic.hpp b/modules/demux/adaptive/logic/RoundRobinLogic.hpp
new file mode 100644
index 0000000000..ccd890b19f
--- /dev/null
+++ b/modules/demux/adaptive/logic/RoundRobinLogic.hpp
@@ -0,0 +1,29 @@
+#ifndef ROUNDROBINLOGIC_HPP
+#define ROUNDROBINLOGIC_HPP
+
+#include "../tools/Debug.hpp"
+
+#ifdef ADAPTIVE_DEBUGGING_LOGIC
+#include "AbstractAdaptationLogic.h"
+
+namespace adaptive
+{
+ namespace logic
+ {
+ class RoundRobinLogic : public AbstractAdaptationLogic
+ {
+ public:
+ RoundRobinLogic(vlc_object_t *);
+
+ virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *,
+ BaseRepresentation *);
+ static const unsigned QUANTUM = 2;
+ private:
+ size_t index;
+ uint64_t call;
+ };
+ }
+}
+#endif
+
+#endif // ROUNDROBINLOGIC_HPP
diff --git a/modules/demux/adaptive/tools/Debug.hpp b/modules/demux/adaptive/tools/Debug.hpp
index 7b6548b1c2..647410613c 100644
--- a/modules/demux/adaptive/tools/Debug.hpp
+++ b/modules/demux/adaptive/tools/Debug.hpp
@@ -23,6 +23,7 @@
//#define ADAPTATIVE_ADVANCED_DEBUG 0
//#define ADAPTATIVE_BW_DEBUG 0
//#define ADAPTATIVE_SEEK_DEBUG 0
+//#define ADAPTIVE_DEBUGGING_LOGIC 0
#ifdef ADAPTATIVE_ADVANCED_DEBUG
#define AdvDebug(code) code
More information about the vlc-commits
mailing list