[vlc-devel] [vlc-commits] demux: adaptive: change logic var to string
Filip Roséen
filip at atch.se
Wed Oct 12 13:11:03 CEST 2016
Hi Francois,
It could be wise to add a `static_assert` that makes sure that
`pi_logics`, `ppsz_logics_values`, and `ppsz_logics`, have the same
number of elements (given that its an assumption made by the
implementaiton).
See attached patch ("better safe than sorry", and so forth).
On 2016-10-12 11:37, Francois Cartegnie wrote:
> vlc | branch: master | Francois Cartegnie <fcvlcdev at 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 at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161012/0955c11a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-demux-adaptive-add-static_assert-related-to-module-o.patch
Type: text/x-diff
Size: 1459 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161012/0955c11a/attachment.patch>
More information about the vlc-devel
mailing list