vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Wed Oct 12 
11:24:01 2016 +0200| [92646bf1f2625151a5f6e73b4ea739bc9c2b0511] | committer: 
Francois Cartegnie

demux: adaptive: change logic var to string

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

 modules/demux/adaptive/adaptive.cpp | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/modules/demux/adaptive/adaptive.cpp 
b/modules/demux/adaptive/adaptive.cpp
index 0ec02d0..ca3a994 100644
--- a/modules/demux/adaptive/adaptive.cpp
+++ b/modules/demux/adaptive/adaptive.cpp
@@ -75,13 +75,22 @@ static void Close   (vlc_object_t *);
 #define ADAPT_ACCESS_TEXT N_("Use regular HTTP modules")
 #define ADAPT_ACCESS_LONGTEXT N_("Connect using http access instead of custom 
http code")
 
-static const int pi_logics[] = {AbstractAdaptationLogic::Default,
+static const AbstractAdaptationLogic::LogicType pi_logics[] = {
+                                AbstractAdaptationLogic::Default,
                                 AbstractAdaptationLogic::Predictive,
                                 AbstractAdaptationLogic::RateBased,
                                 AbstractAdaptationLogic::FixedRate,
                                 AbstractAdaptationLogic::AlwaysLowest,
                                 AbstractAdaptationLogic::AlwaysBest};
 
+static const char *const ppsz_logics_values[] = {
+                                "",
+                                "predictive",
+                                "rate",
+                                "fixedrate",
+                                "lowest",
+                                "highest"};
+
 static const char *const ppsz_logics[] = { N_("Default"),
                                            N_("Predictive"),
                                            N_("Bandwidth Adaptive"),
@@ -95,9 +104,8 @@ vlc_module_begin ()
         set_capability( "demux", 12 )
         set_category( CAT_INPUT )
         set_subcategory( SUBCAT_INPUT_DEMUX )
-        add_integer( "adaptive-logic",  AbstractAdaptationLogic::Default,
-                                          ADAPT_LOGIC_TEXT, NULL, false )
-            change_integer_list( pi_logics, ppsz_logics )
+        add_string( "adaptive-logic",  "", ADAPT_LOGIC_TEXT, NULL, false )
+            change_string_list( ppsz_logics_values, ppsz_logics )
         add_integer( "adaptive-width",  0, ADAPT_WIDTH_TEXT,  
ADAPT_WIDTH_TEXT,  true )
         add_integer( "adaptive-height", 0, ADAPT_HEIGHT_TEXT, 
ADAPT_HEIGHT_TEXT, true )
         add_integer( "adaptive-bw",     250, ADAPT_BW_TEXT,     
ADAPT_BW_LONGTEXT,     false )
@@ -130,8 +138,21 @@ static int Open(vlc_object_t *p_obj)
     }
 
     PlaylistManager *p_manager = NULL;
-    AbstractAdaptationLogic::LogicType logic =
-            
static_cast<AbstractAdaptationLogic::LogicType>(var_InheritInteger(p_obj, 
"adaptive-logic"));
+
+    char *psz_logic = var_InheritString(p_obj, "adaptive-logic");
+    AbstractAdaptationLogic::LogicType logic = 
AbstractAdaptationLogic::Default;
+    if( psz_logic )
+    {
+        for(size_t i=0;i<ARRAY_SIZE(pi_logics); i++)
+        {
+            if(!strcmp(psz_logic, ppsz_logics_values[i]))
+            {
+                logic = pi_logics[i];
+                break;
+            }
+        }
+        free( psz_logic );
+    }
 
     std::string playlisturl(p_demux->s->psz_url);
 

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

Reply via email to