[vlc-commits] demux: adaptive: keep representations ordered by bandwidth

Francois Cartegnie git at videolan.org
Wed Sep 21 18:52:32 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Sep 20 21:11:21 2016 +0200| [2d35944ba3ead83afc62ea6db0b8db0c1a5082d6] | committer: Francois Cartegnie

demux: adaptive: keep representations ordered by bandwidth

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d35944ba3ead83afc62ea6db0b8db0c1a5082d6
---

 modules/demux/adaptive/playlist/BaseAdaptationSet.cpp  | 8 +++++++-
 modules/demux/adaptive/playlist/BaseRepresentation.cpp | 6 ++++++
 modules/demux/adaptive/playlist/BaseRepresentation.h   | 2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
index 7f7a984..8915cbf 100644
--- a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
+++ b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
@@ -36,6 +36,8 @@
 #include "BasePeriod.h"
 #include "Inheritables.hpp"
 
+#include <algorithm>
+
 using namespace adaptive;
 using namespace adaptive::playlist;
 
@@ -78,7 +80,11 @@ BaseRepresentation * BaseAdaptationSet::getRepresentationByID(const ID &id)
 
 void BaseAdaptationSet::addRepresentation(BaseRepresentation *rep)
 {
-    representations.push_back(rep);
+    representations.insert(std::upper_bound(representations.begin(),
+                                            representations.end(),
+                                            rep,
+                                            BaseRepresentation::bwCompare),
+                           rep);
     childs.push_back(rep);
 }
 
diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.cpp b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
index cebc48e..680c410 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.cpp
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
@@ -156,6 +156,12 @@ std::string BaseRepresentation::contextualize(size_t, const std::string &compone
     return component;
 }
 
+bool BaseRepresentation::bwCompare(const BaseRepresentation *a,
+                                   const BaseRepresentation *b)
+{
+    return a->getBandwidth() < b->getBandwidth();
+}
+
 bool BaseRepresentation::validateCodec(const std::string &) const
 {
     return true;
diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.h b/modules/demux/adaptive/playlist/BaseRepresentation.h
index e2d013c..7de1278 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.h
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.h
@@ -73,6 +73,8 @@ namespace adaptive
                 virtual std::string contextualize(size_t, const std::string &,
                                                   const BaseSegmentTemplate *) const;
 
+                static bool         bwCompare(const BaseRepresentation *a,
+                                              const BaseRepresentation *b);
             protected:
                 virtual bool        validateCodec(const std::string &) const;
                 BaseAdaptationSet                  *adaptationSet;



More information about the vlc-commits mailing list