vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Tue Sep 20 
21:42:03 2016 +0200| [ca22f1171378d641dd49a038e21b05b6b1912afc] | committer: 
Francois Cartegnie

demux: adaptive: add new selectors

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

 .../adaptive/logic/Representationselectors.cpp     | 29 ++++++++++++++++++++++
 .../adaptive/logic/Representationselectors.hpp     |  4 +++
 2 files changed, 33 insertions(+)

diff --git a/modules/demux/adaptive/logic/Representationselectors.cpp 
b/modules/demux/adaptive/logic/Representationselectors.cpp
index 1e6b36e..07700f3 100644
--- a/modules/demux/adaptive/logic/Representationselectors.cpp
+++ b/modules/demux/adaptive/logic/Representationselectors.cpp
@@ -26,6 +26,7 @@
 #include "../playlist/BaseAdaptationSet.h"
 #include "../playlist/BasePeriod.h"
 #include <limits>
+#include <algorithm>
 
 using namespace adaptive::logic;
 
@@ -37,6 +38,34 @@ RepresentationSelector::~RepresentationSelector()
 {
 }
 
+BaseRepresentation * RepresentationSelector::lowest(BaseAdaptationSet 
*adaptSet) const
+{
+    std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
+    return (reps.empty()) ? NULL : *(reps.begin());
+}
+
+BaseRepresentation * RepresentationSelector::highest(BaseAdaptationSet 
*adaptSet) const
+{
+    std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
+    return (reps.empty()) ? NULL : *reps.rbegin();
+}
+
+BaseRepresentation * RepresentationSelector::higher(BaseAdaptationSet 
*adaptSet, BaseRepresentation *rep) const
+{
+    std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
+    std::vector<BaseRepresentation *>::iterator it = 
std::upper_bound(reps.begin(), reps.end(), rep,
+                                                                      
BaseRepresentation::bwCompare);
+    return (it == reps.end()) ? rep : *it;
+}
+
+BaseRepresentation * RepresentationSelector::lower(BaseAdaptationSet 
*adaptSet, BaseRepresentation *rep) const
+{
+    std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
+    std::vector<BaseRepresentation *>::iterator it = 
std::lower_bound(reps.begin(), reps.end(), rep,
+                                                                      
BaseRepresentation::bwCompare);
+    return (it > reps.begin()) ? *(--it) : rep;
+}
+
 BaseRepresentation * RepresentationSelector::select(BaseAdaptationSet 
*adaptSet) const
 {
     return select(adaptSet, std::numeric_limits<uint64_t>::max());
diff --git a/modules/demux/adaptive/logic/Representationselectors.hpp 
b/modules/demux/adaptive/logic/Representationselectors.hpp
index b244b25..b39e07b 100644
--- a/modules/demux/adaptive/logic/Representationselectors.hpp
+++ b/modules/demux/adaptive/logic/Representationselectors.hpp
@@ -40,6 +40,10 @@ namespace adaptive
         public:
             RepresentationSelector();
              ~RepresentationSelector();
+            BaseRepresentation * lowest(BaseAdaptationSet *) const;
+            BaseRepresentation * highest(BaseAdaptationSet *) const;
+            BaseRepresentation * higher(BaseAdaptationSet *, 
BaseRepresentation *) const;
+            BaseRepresentation * lower(BaseAdaptationSet *, BaseRepresentation 
*) const;
             BaseRepresentation * select(BaseAdaptationSet *) const;
             BaseRepresentation * select(BaseAdaptationSet *, uint64_t bitrate) 
const;
             BaseRepresentation * select(BaseAdaptationSet *, uint64_t bitrate,

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to