[vlc-commits] [Git][videolan/vlc][master] 3 commits: input: rename/move input_create_option

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Mar 17 07:20:00 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
dee5364c by Thomas Guillem at 2022-03-17T06:46:51+00:00
input: rename/move input_create_option

Rename it to input_type, expose it via input_internal.h (usable by
input.c / es_out.c), and pass it to es_out in order to avoid fetching
input_thread_t private data.

- - - - -
28a9b74b by Thomas Guillem at 2022-03-17T06:46:51+00:00
input: merge all Create functions

They are all internal now, it's ok to require unused arguments for a given type.

- - - - -
9dcae0aa by Thomas Guillem at 2022-03-17T06:46:51+00:00
decoder: pass input_type directly

- - - - -


10 changed files:

- src/input/decoder.c
- src/input/decoder.h
- src/input/es_out.c
- src/input/es_out.h
- src/input/input.c
- src/input/input_internal.h
- src/input/item.c
- src/input/thumbnailer.c
- src/input/var.c
- src/player/input.c


Changes:

=====================================
src/input/decoder.c
=====================================
@@ -48,6 +48,7 @@
 #include "audio_output/aout_internal.h"
 #include "stream_output/stream_output.h"
 #include "../clock/clock.h"
+#include "input_internal.h"
 #include "decoder.h"
 #include "resource.h"
 #include "libvlc.h"
@@ -1807,7 +1808,7 @@ static vlc_input_decoder_t *
 CreateDecoder( vlc_object_t *p_parent, const es_format_t *fmt,
                const char *psz_id, vlc_clock_t *p_clock,
                input_resource_t *p_resource, sout_stream_t *p_sout,
-               bool b_thumbnailing, const struct vlc_input_decoder_callbacks *cbs,
+               enum input_type input_type, const struct vlc_input_decoder_callbacks *cbs,
                void *cbs_userdata )
 {
     decoder_t *p_dec;
@@ -1815,6 +1816,8 @@ CreateDecoder( vlc_object_t *p_parent, const es_format_t *fmt,
     static_assert(offsetof(vlc_input_decoder_t, dec) == 0,
                   "the decoder must be first in the owner structure");
 
+    assert(input_type != INPUT_TYPE_PREPARSING);
+
     p_owner = vlc_custom_create( p_parent, sizeof( *p_owner ), "decoder" );
     if( p_owner == NULL )
         return NULL;
@@ -1898,10 +1901,10 @@ CreateDecoder( vlc_object_t *p_parent, const es_format_t *fmt,
     switch( fmt->i_cat )
     {
         case VIDEO_ES:
-            if( !b_thumbnailing )
-                p_dec->cbs = &dec_video_cbs;
-            else
+            if( input_type == INPUT_TYPE_THUMBNAILING )
                 p_dec->cbs = &dec_thumbnailer_cbs;
+            else
+                p_dec->cbs = &dec_video_cbs;
             break;
         case AUDIO_ES:
             p_dec->cbs = &dec_audio_cbs;
@@ -2064,7 +2067,7 @@ static void DecoderUnsupportedCodec( decoder_t *p_dec, const es_format_t *fmt, b
 static vlc_input_decoder_t *
 decoder_New( vlc_object_t *p_parent, const es_format_t *fmt, const char *psz_id,
              vlc_clock_t *p_clock, input_resource_t *p_resource,
-             sout_stream_t *p_sout, bool thumbnailing,
+             sout_stream_t *p_sout, enum input_type input_type,
              const struct vlc_input_decoder_callbacks *cbs, void *userdata)
 {
     const char *psz_type = p_sout ? N_("packetizer") : N_("decoder");
@@ -2073,7 +2076,7 @@ decoder_New( vlc_object_t *p_parent, const es_format_t *fmt, const char *psz_id,
     /* Create the decoder configuration structure */
     vlc_input_decoder_t *p_owner =
         CreateDecoder( p_parent, fmt, psz_id, p_clock, p_resource, p_sout,
-                       thumbnailing, cbs, userdata );
+                       input_type, cbs, userdata );
     if( p_owner == NULL )
     {
         msg_Err( p_parent, "could not create %s", psz_type );
@@ -2139,11 +2142,11 @@ vlc_input_decoder_t *
 vlc_input_decoder_New( vlc_object_t *parent, es_format_t *fmt,
                   const char *psz_id, vlc_clock_t *p_clock,
                   input_resource_t *resource,
-                  sout_stream_t *p_sout, bool thumbnailing,
+                  sout_stream_t *p_sout, enum input_type input_type,
                   const struct vlc_input_decoder_callbacks *cbs,
                   void *cbs_userdata)
 {
-    return decoder_New( parent, fmt, psz_id, p_clock, resource, p_sout, thumbnailing,
+    return decoder_New( parent, fmt, psz_id, p_clock, resource, p_sout, input_type,
                         cbs, cbs_userdata );
 }
 
@@ -2154,8 +2157,8 @@ vlc_input_decoder_t *
 vlc_input_decoder_Create( vlc_object_t *p_parent, const es_format_t *fmt,
                      input_resource_t *p_resource )
 {
-    return decoder_New( p_parent, fmt, NULL, NULL, p_resource, NULL, false, NULL,
-                        NULL );
+    return decoder_New( p_parent, fmt, NULL, NULL, p_resource, NULL, INPUT_TYPE_NONE,
+                        NULL, NULL );
 }
 
 
@@ -2409,7 +2412,7 @@ int vlc_input_decoder_SetCcState( vlc_input_decoder_t *p_owner, vlc_fourcc_t cod
         fmt.subs.cc.i_reorder_depth = p_owner->cc.desc.i_reorder_depth;
         p_ccowner = vlc_input_decoder_New( VLC_OBJECT(p_dec), &fmt, p_owner->psz_id,
                                       p_owner->p_clock, p_owner->p_resource, p_owner->p_sout,
-                                      false, NULL, NULL );
+                                      INPUT_TYPE_NONE, NULL, NULL );
         if( !p_ccowner )
         {
             msg_Err( p_dec, "could not create decoder" );


=====================================
src/input/decoder.h
=====================================
@@ -52,7 +52,7 @@ struct vlc_input_decoder_callbacks {
 
 vlc_input_decoder_t *
 vlc_input_decoder_New( vlc_object_t *parent, es_format_t *, const char *psz_id, vlc_clock_t *,
-                       input_resource_t *, sout_stream_t *, bool thumbnailing,
+                       input_resource_t *, sout_stream_t *, enum input_type input_type,
                        const struct vlc_input_decoder_callbacks *cbs,
                        void *userdata ) VLC_USED;
 


=====================================
src/input/es_out.c
=====================================
@@ -173,6 +173,7 @@ typedef struct
 typedef struct
 {
     input_thread_t *p_input;
+    enum input_type input_type;
 
     input_source_t *main_source;
 
@@ -498,7 +499,7 @@ static void EsOutPropsCleanup( es_out_es_props_t *p_props )
 
 static void EsOutPropsInit( es_out_es_props_t *p_props,
                             bool autoselect,
-                            input_thread_t *p_input,
+                            input_thread_t *p_input, enum input_type input_type,
                             enum es_out_policy_e e_default_policy,
                             const char *psz_trackidvar,
                             const char *psz_trackvar,
@@ -513,7 +514,7 @@ static void EsOutPropsInit( es_out_es_props_t *p_props,
     p_props->i_demux_id = -1;
     p_props->p_main_es = NULL;
 
-    if( !input_priv(p_input)->b_preparsing && psz_langvar )
+    if( input_type != INPUT_TYPE_PREPARSING && psz_langvar )
     {
         char *psz_string = var_GetString( p_input, psz_langvar );
         p_props->ppsz_language = LanguageSplit( psz_string );
@@ -532,7 +533,8 @@ static const struct es_out_callbacks es_out_cbs;
 /*****************************************************************************
  * input_EsOutNew:
  *****************************************************************************/
-es_out_t *input_EsOutNew( input_thread_t *p_input, input_source_t *main_source, float rate )
+es_out_t *input_EsOutNew( input_thread_t *p_input, input_source_t *main_source, float rate,
+                          enum input_type input_type )
 {
     es_out_sys_t *p_sys = calloc( 1, sizeof( *p_sys ) );
     if( !p_sys )
@@ -546,17 +548,21 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, input_source_t *main_source,
 
     p_sys->b_active = false;
     p_sys->i_mode   = ES_OUT_MODE_NONE;
+    p_sys->input_type = input_type;
 
     vlc_list_init(&p_sys->programs);
     vlc_list_init(&p_sys->es);
     vlc_list_init(&p_sys->es_slaves);
 
     /* */
-    EsOutPropsInit( &p_sys->video, true, p_input, ES_OUT_ES_POLICY_AUTO,
+    EsOutPropsInit( &p_sys->video, true, p_input, input_type,
+                    ES_OUT_ES_POLICY_AUTO,
                     "video-track-id", "video-track", NULL, NULL );
-    EsOutPropsInit( &p_sys->audio, true, p_input, ES_OUT_ES_POLICY_EXCLUSIVE,
+    EsOutPropsInit( &p_sys->audio, true, p_input, input_type,
+                    ES_OUT_ES_POLICY_EXCLUSIVE,
                     "audio-track-id", "audio-track", "audio-language", "audio" );
-    EsOutPropsInit( &p_sys->sub,  false, p_input, ES_OUT_ES_POLICY_AUTO,
+    EsOutPropsInit( &p_sys->sub,  false, p_input, input_type,
+                    ES_OUT_ES_POLICY_AUTO,
                     "sub-track-id", "sub-track", "sub-language", "sub" );
 
     p_sys->cc_decoder = var_InheritInteger( p_input, "captions" );
@@ -849,7 +855,7 @@ static int EsOutSetRecord(  es_out_t *out, bool b_record )
                 vlc_input_decoder_New( VLC_OBJECT(p_input), &p_es->fmt,
                                        p_es->id.str_id, NULL,
                                        input_priv(p_input)->p_resource,
-                                       p_sys->p_sout_record, false,
+                                       p_sys->p_sout_record, INPUT_TYPE_NONE,
                                        &decoder_cbs, p_es );
 
             if( p_es->p_dec_record && p_sys->b_buffering )
@@ -1788,7 +1794,7 @@ static void EsOutProgramMeta( es_out_t *out, input_source_t *source,
         input_item_MergeInfos( p_item, p_cat );
         b_has_new_infos = true;
     }
-    if( !input_priv(p_input)->b_preparsing && b_has_new_infos )
+    if( p_sys->input_type != INPUT_TYPE_PREPARSING && b_has_new_infos )
         input_SendEventMetaInfo( p_input );
 }
 
@@ -1883,7 +1889,7 @@ static void EsOutProgramEpg( es_out_t *out, input_source_t *source,
         else
             ret = input_item_DelInfo( p_item, psz_cat, now_playing_tr );
 
-        if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
+        if( ret == VLC_SUCCESS && p_sys->input_type != INPUT_TYPE_PREPARSING  )
             input_SendEventMetaInfo( p_input );
     }
 
@@ -1927,7 +1933,7 @@ static void EsOutProgramUpdateScrambled( es_out_t *p_out, es_out_pgrm_t *p_pgrm
         ret = input_item_DelInfo( p_item, psz_cat, _("Scrambled") );
     free( psz_cat );
 
-    if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
+    if( ret == VLC_SUCCESS && p_sys->input_type != INPUT_TYPE_PREPARSING )
         input_SendEventMetaInfo( p_input );
     input_SendEventProgramScrambled( p_input, p_pgrm->i_id, b_scrambled );
 }
@@ -2338,7 +2344,7 @@ static void EsOutCreateDecoder( es_out_t *out, es_out_id_t *p_es )
     dec = vlc_input_decoder_New( VLC_OBJECT(p_input), &p_es->fmt,
                                  p_es->id.str_id, p_es->p_clock,
                                  priv->p_resource, priv->p_sout,
-                                 priv->b_thumbnailing, &decoder_cbs, p_es );
+                                 p_sys->input_type, &decoder_cbs, p_es );
     if( dec != NULL )
     {
         vlc_input_decoder_ChangeRate( dec, p_sys->rate );
@@ -2352,7 +2358,7 @@ static void EsOutCreateDecoder( es_out_t *out, es_out_id_t *p_es )
                 vlc_input_decoder_New( VLC_OBJECT(p_input), &p_es->fmt,
                                        p_es->id.str_id, NULL,
                                        priv->p_resource, p_sys->p_sout_record,
-                                       false, &decoder_cbs, p_es );
+                                       INPUT_TYPE_NONE, &decoder_cbs, p_es );
             if( p_es->p_dec_record && p_sys->b_buffering )
                 vlc_input_decoder_StartWait( p_es->p_dec_record );
         }
@@ -2399,7 +2405,7 @@ static void EsOutSelectEs( es_out_t *out, es_out_id_t *es, bool b_force )
 {
     es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
     input_thread_t *p_input = p_sys->p_input;
-    bool b_thumbnailing = input_priv(p_input)->b_thumbnailing;
+    bool b_thumbnailing = p_sys->input_type == INPUT_TYPE_THUMBNAILING;
 
     if( EsIsSelected( es ) )
     {
@@ -4539,7 +4545,7 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const vlc_meta_t *p
     }
     /* */
     input_item_ReplaceInfos( p_item, p_cat );
-    if( !input_priv(p_input)->b_preparsing  )
+    if( p_sys->input_type != INPUT_TYPE_PREPARSING )
         input_SendEventMetaInfo( p_input );
 }
 
@@ -4555,7 +4561,7 @@ static void EsOutDeleteInfoEs( es_out_t *out, es_out_id_t *es )
         int ret = input_item_DelInfo( p_item, psz_info_category, NULL );
         free( psz_info_category );
 
-        if( ret == VLC_SUCCESS && !input_priv(p_input)->b_preparsing  )
+        if( ret == VLC_SUCCESS && p_sys->input_type != INPUT_TYPE_PREPARSING )
             input_SendEventMetaInfo( p_input );
     }
 }


=====================================
src/input/es_out.h
=====================================
@@ -242,7 +242,8 @@ static inline int es_out_SetVbiTransparency( es_out_t *p_out, vlc_es_id_t *id,
                                enabled );
 }
 
-es_out_t  *input_EsOutNew( input_thread_t *, input_source_t *main_source, float rate );
+es_out_t  *input_EsOutNew( input_thread_t *, input_source_t *main_source, float rate,
+                           enum input_type input_type );
 es_out_t  *input_EsOutTimeshiftNew( input_thread_t *, es_out_t *, float i_rate );
 es_out_t  *input_EsOutSourceNew(es_out_t *master_out, input_source_t *in);
 


=====================================
src/input/input.c
=====================================
@@ -59,18 +59,9 @@
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-enum input_create_option {
-    INPUT_CREATE_OPTION_NONE,
-    INPUT_CREATE_OPTION_PREPARSING,
-    INPUT_CREATE_OPTION_THUMBNAILING,
-};
-
 static  void *Run( void * );
 static  void *Preparse( void * );
 
-static input_thread_t * Create  ( vlc_object_t *, input_thread_events_cb, void *,
-                                  input_item_t *, enum input_create_option option,
-                                  input_resource_t *, vlc_renderer_item_t * );
 static void             Destroy ( input_thread_t *p_input );
 static  int             Init    ( input_thread_t *p_input );
 static void             End     ( input_thread_t *p_input );
@@ -119,44 +110,6 @@ static int input_SlaveSourceAdd( input_thread_t *, enum slave_type,
 static char *input_SubtitleFile2Uri( input_thread_t *, const char * );
 static void input_ChangeState( input_thread_t *p_input, int i_state, vlc_tick_t ); /* TODO fix name */
 
-#undef input_Create
-/**
- * Create a new input_thread_t.
- *
- * You need to call input_Start on it when you are done
- * adding callback on the variables/events you want to monitor.
- *
- * \param p_parent a vlc_object
- * \param p_item an input item
- * \param p_resource an optional input resource
- * \return a pointer to the spawned input thread
- */
-input_thread_t *input_Create( vlc_object_t *p_parent,
-                              input_thread_events_cb events_cb, void *events_data,
-                              input_item_t *p_item,
-                              input_resource_t *p_resource,
-                              vlc_renderer_item_t *p_renderer )
-{
-    return Create( p_parent, events_cb, events_data, p_item,
-                   INPUT_CREATE_OPTION_NONE, p_resource, p_renderer );
-}
-
-input_thread_t *input_CreatePreparser( vlc_object_t *parent,
-                                       input_thread_events_cb events_cb,
-                                       void *events_data, input_item_t *item )
-{
-    return Create( parent, events_cb, events_data, item,
-                   INPUT_CREATE_OPTION_PREPARSING, NULL, NULL );
-}
-
-input_thread_t *input_CreateThumbnailer(vlc_object_t *obj,
-                                        input_thread_events_cb events_cb,
-                                        void *events_data, input_item_t *item)
-{
-    return Create( obj, events_cb, events_data, item,
-                   INPUT_CREATE_OPTION_THUMBNAILING, NULL, NULL );
-}
-
 /**
  * Start a input_thread_t created by input_Create.
  *
@@ -169,7 +122,7 @@ int input_Start( input_thread_t *p_input )
     input_thread_private_t *priv = input_priv(p_input);
     void *(*func)(void *) = Run;
 
-    if( priv->b_preparsing )
+    if( priv->type == INPUT_TYPE_PREPARSING )
         func = Preparse;
 
     assert( !priv->is_running );
@@ -250,18 +203,23 @@ input_item_t *input_GetItem( input_thread_t *p_input )
     return input_priv(p_input)->p_item;
 }
 
-/*****************************************************************************
- * This function creates a new input, and returns a pointer
- * to its description. On error, it returns NULL.
+#undef input_Create
+/**
+ * Create a new input_thread_t.
  *
- * XXX Do not forget to update vlc_input.h if you add new variables.
- *****************************************************************************/
-static input_thread_t *Create( vlc_object_t *p_parent,
-                               input_thread_events_cb events_cb, void *events_data,
-                               input_item_t *p_item,
-                               enum input_create_option option,
-                               input_resource_t *p_resource,
-                               vlc_renderer_item_t *p_renderer )
+ * You need to call input_Start on it when you are done
+ * adding callback on the variables/events you want to monitor.
+ *
+ * \param p_parent a vlc_object
+ * \param p_item an input item
+ * \param p_resource an optional input ressource
+ * \return a pointer to the spawned input thread
+ */
+input_thread_t *input_Create( vlc_object_t *p_parent,
+                              input_thread_events_cb events_cb, void *events_data,
+                              input_item_t *p_item, enum input_type type,
+                              input_resource_t *p_resource,
+                              vlc_renderer_item_t *p_renderer )
 {
     /* Allocate descriptor */
     input_thread_private_t *priv;
@@ -280,20 +238,20 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     input_thread_t *p_input = &priv->input;
 
     char * psz_name = input_item_GetName( p_item );
-    const char *option_str;
-    switch (option)
+    const char *type_str;
+    switch (type)
     {
-        case INPUT_CREATE_OPTION_PREPARSING:
-            option_str = "preparsing ";
+        case INPUT_TYPE_PREPARSING:
+            type_str = "preparsing ";
             break;
-        case INPUT_CREATE_OPTION_THUMBNAILING:
-            option_str = "thumbnailing ";
+        case INPUT_TYPE_THUMBNAILING:
+            type_str = "thumbnailing ";
             break;
         default:
-            option_str = "";
+            type_str = "";
             break;
     }
-    msg_Dbg( p_input, "Creating an input for %s'%s'", option_str, psz_name);
+    msg_Dbg( p_input, "Creating an input for %s'%s'", type_str, psz_name);
     free( psz_name );
 
     /* Parse input options */
@@ -302,8 +260,7 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     /* Init Common fields */
     priv->events_cb = events_cb;
     priv->events_data = events_data;
-    priv->b_preparsing = option == INPUT_CREATE_OPTION_PREPARSING;
-    priv->b_thumbnailing = option == INPUT_CREATE_OPTION_THUMBNAILING;
+    priv->type = type;
     priv->i_start = 0;
     priv->i_stop  = 0;
     priv->i_title_offset = input_priv(p_input)->i_seekpoint_offset = 0;
@@ -315,8 +272,8 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     priv->normal_time = VLC_TICK_0;
     TAB_INIT( priv->i_attachment, priv->attachment );
     priv->p_sout   = NULL;
-    priv->b_out_pace_control = priv->b_thumbnailing;
-    priv->p_renderer = p_renderer && priv->b_preparsing == false ?
+    priv->b_out_pace_control = priv->type == INPUT_TYPE_THUMBNAILING;
+    priv->p_renderer = p_renderer && priv->type != INPUT_TYPE_PREPARSING ?
                 vlc_renderer_item_hold( p_renderer ) : NULL;
 
     priv->viewpoint_changed = false;
@@ -338,7 +295,8 @@ static input_thread_t *Create( vlc_object_t *p_parent,
 
     /* setup the preparse depth of the item
      * if we are preparsing, use the i_preparse_depth of the parent item */
-    if( priv->b_preparsing || priv->b_thumbnailing )
+    if( priv->type == INPUT_TYPE_PREPARSING
+     || priv->type == INPUT_TYPE_THUMBNAILING )
     {
         p_input->obj.logger = NULL;
         p_input->obj.no_interact = true;
@@ -401,12 +359,13 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     input_item_SetESNowPlaying( p_item, NULL );
 
     /* */
-    if( !priv->b_preparsing && var_InheritBool( p_input, "stats" ) )
+    if( priv->type != INPUT_TYPE_PREPARSING && var_InheritBool( p_input, "stats" ) )
         priv->stats = input_stats_Create();
     else
         priv->stats = NULL;
 
-    priv->p_es_out_display = input_EsOutNew( p_input, priv->master, priv->rate );
+    priv->p_es_out_display = input_EsOutNew( p_input, priv->master, priv->rate,
+                                             priv->type );
     if( !priv->p_es_out_display )
     {
         Destroy( p_input );
@@ -785,7 +744,7 @@ static int InitSout( input_thread_t * p_input )
 {
     input_thread_private_t *priv = input_priv(p_input);
 
-    if( priv->b_preparsing )
+    if( priv->type == INPUT_TYPE_PREPARSING )
         return VLC_SUCCESS;
 
     /* Find a usable sout and attach it to p_input */
@@ -879,7 +838,7 @@ static void InitTitle( input_thread_t * p_input, bool had_titles )
     input_thread_private_t *priv = input_priv(p_input);
     input_source_t *p_master = priv->master;
 
-    if( priv->b_preparsing )
+    if( priv->type == INPUT_TYPE_PREPARSING )
         return;
 
     vlc_mutex_lock( &priv->p_item->lock );
@@ -1353,7 +1312,7 @@ static int Init( input_thread_t * p_input )
     input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, priv->normal_time,
                           i_length );
 
-    if( !priv->b_preparsing )
+    if( priv->type != INPUT_TYPE_PREPARSING )
     {
         StartTitle( p_input );
         SetSubtitlesOptions( p_input );
@@ -1369,7 +1328,7 @@ static int Init( input_thread_t * p_input )
     }
 
 #ifdef ENABLE_SOUT
-    if( !priv->b_preparsing && priv->p_sout )
+    if( priv->type != INPUT_TYPE_PREPARSING && priv->p_sout )
     {
         priv->b_out_pace_control = sout_StreamIsSynchronous(priv->p_sout);
         msg_Dbg( p_input, "starting in %ssync mode",
@@ -2555,7 +2514,8 @@ static demux_t *InputDemuxNew( input_thread_t *p_input, es_out_t *p_es_out,
 
     /* create the underlying access stream */
     stream_t *p_stream = stream_AccessNew( obj, p_input, p_es_out,
-                                           priv->b_preparsing, url );
+                                           priv->type == INPUT_TYPE_PREPARSING,
+                                           url );
     if( p_stream == NULL )
         return NULL;
 
@@ -2588,7 +2548,7 @@ static demux_t *InputDemuxNew( input_thread_t *p_input, es_out_t *p_es_out,
 
     /* create a regular demux with the access stream created */
     demux_t *demux = demux_NewAdvanced( obj, p_input, psz_demux, url, p_stream,
-                                        p_es_out, priv->b_preparsing );
+                                        p_es_out, priv->type == INPUT_TYPE_PREPARSING );
     if( demux != NULL )
         return demux;
 
@@ -2808,8 +2768,8 @@ static int InputSourceInit( input_source_t *in, input_thread_t *p_input,
     demux_Control( in->p_demux, DEMUX_CAN_PAUSE, &in->b_can_pause );
 
     /* get attachment
-     * FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
-    if( !input_priv(p_input)->b_preparsing )
+     * FIXME improve for preparsing: move it after GET_META and check psz_arturl */
+    if( input_priv(p_input)->type != INPUT_TYPE_PREPARSING )
     {
         if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO,
                            &in->title, &in->i_title,


=====================================
src/input/input_internal.h
=====================================
@@ -54,6 +54,12 @@ typedef struct input_thread_t
  * Input events and variables
  *****************************************************************************/
 
+enum input_type {
+    INPUT_TYPE_NONE,
+    INPUT_TYPE_PREPARSING,
+    INPUT_TYPE_THUMBNAILING,
+};
+
 /**
  * Input state
  *
@@ -313,31 +319,9 @@ typedef void (*input_thread_events_cb)( input_thread_t *input,
  *****************************************************************************/
 input_thread_t * input_Create( vlc_object_t *p_parent,
                                input_thread_events_cb event_cb, void *events_data,
-                               input_item_t *, input_resource_t *,
-                               vlc_renderer_item_t* p_renderer ) VLC_USED;
-#define input_Create(a,b,c,d,e,f) input_Create(VLC_OBJECT(a),b,c,d,e,f)
-
-
-/**
- * Creates an item preparser.
- *
- * Creates an input thread to preparse an item. The input needs to be started
- * with input_Start() afterwards.
- *
- * @param obj parent object
- * @param item input item to preparse
- * @return an input thread or NULL on error
- */
-input_thread_t *input_CreatePreparser(vlc_object_t *obj,
-                                      input_thread_events_cb events_cb,
-                                      void *events_data, input_item_t *item)
-VLC_USED;
-
-VLC_API
-input_thread_t *input_CreateThumbnailer(vlc_object_t *obj,
-                                        input_thread_events_cb events_cb,
-                                        void *events_data, input_item_t *item)
-VLC_USED;
+                               input_item_t *, enum input_type type,
+                               input_resource_t *, vlc_renderer_item_t* p_renderer ) VLC_USED;
+#define input_Create(a,b,c,d,e,f,g) input_Create(VLC_OBJECT(a),b,c,d,e,f,g)
 
 int input_Start( input_thread_t * );
 
@@ -469,15 +453,13 @@ typedef struct input_thread_private_t
     input_thread_events_cb events_cb;
     void *events_data;
 
-    /* Global properties */
-    bool        b_preparsing;
+    enum input_type type;
 
     /* Current state */
     int         i_state;
     bool        is_running;
     bool        is_stopped;
     bool        b_recording;
-    bool        b_thumbnailing;
     float       rate;
     vlc_tick_t  normal_time;
 


=====================================
src/input/item.c
=====================================
@@ -1384,8 +1384,8 @@ input_item_Parse(input_item_t *item, vlc_object_t *obj,
     parser->state = INIT_S;
     parser->cbs = cbs;
     parser->userdata = userdata;
-    parser->input = input_CreatePreparser(obj, input_item_parser_InputEvent,
-                                          parser, item);
+    parser->input = input_Create(obj, input_item_parser_InputEvent, parser,
+                                 item, INPUT_TYPE_PREPARSING, NULL, NULL);
     if (!parser->input || input_Start(parser->input))
     {
         if (parser->input)


=====================================
src/input/thumbnailer.c
=====================================
@@ -184,8 +184,8 @@ RunnableRun(void *userdata)
     vlc_tick_t now = vlc_tick_now();
 
     input_thread_t* input =
-        input_CreateThumbnailer(thumbnailer->parent, on_thumbnailer_input_event,
-                                task, task->item);
+            input_Create( thumbnailer->parent, on_thumbnailer_input_event, task,
+                          task->item, INPUT_TYPE_THUMBNAILING, NULL, NULL );
     if (!input)
         goto end;
 


=====================================
src/input/var.c
=====================================
@@ -40,7 +40,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
 {
     /* Create Object Variables for private use only */
 
-    if( !input_priv(p_input)->b_preparsing )
+    if( input_priv(p_input)->type != INPUT_TYPE_PREPARSING )
     {
         var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
         var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );


=====================================
src/player/input.c
=====================================
@@ -980,7 +980,8 @@ vlc_player_input_New(vlc_player_t *player, input_item_t *item)
     input->ml.has_audio_tracks = input->ml.has_video_tracks = false;
 
     input->thread = input_Create(player, input_thread_Events, input, item,
-                                 player->resource, player->renderer);
+                                 INPUT_TYPE_NONE, player->resource,
+                                 player->renderer);
     if (!input->thread)
     {
         free(input);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fafd64e06f5634cc4ee427f99935510032c37fa3...9dcae0aa3ece449ac01d81ea5f414da0b69299c3

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fafd64e06f5634cc4ee427f99935510032c37fa3...9dcae0aa3ece449ac01d81ea5f414da0b69299c3
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list