<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Francois,</p>
<p>It could be wise to add a <code>static_assert</code> that makes sure that <code>pi_logics</code>, <code>ppsz_logics_values</code>, and <code>ppsz_logics</code>, have the same number of elements (given that its an assumption made by the implementaiton).</p>
<p>See attached patch (“better safe than sorry”, and so forth).</p>
<p>On 2016-10-12 11:37, Francois Cartegnie wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> vlc | branch: master | Francois Cartegnie <fcvlcdev@free.fr> | Wed Oct 12 11:24:01 2016 +0200| [92646bf1f2625151a5f6e73b4ea739bc9c2b0511] | committer: Francois Cartegnie

 demux: adaptive: change logic var to string</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<h3 id="httpgit.videolan.orggitweb.cgivlc.gitacommith92646bf1f2625151a5f6e73b4ea739bc9c2b0511">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=92646bf1f2625151a5f6e73b4ea739bc9c2b0511</h3>
</blockquote>
<pre><code>  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</code></pre>
</blockquote>
</body>
</html>