]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
module_need wants pointers and boolean so give NULL and false instead of 0.
[vlc] / src / input / input.c
index 24c60821b243146a52b191c6c2f0e0711f2e920c..8c6d25a6beeeabcb9a705a45e296c5a6a5fa1139 100644 (file)
@@ -162,12 +162,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     p_input->b_preparsing = b_quick;
     p_input->psz_header = psz_header ? strdup( psz_header ) : NULL;
 
-    /* Init events */
-    vlc_event_manager_t * p_em = &p_input->p->event_manager;
-    vlc_event_manager_init_with_vlc_object( p_em, p_input );
-    vlc_event_manager_register_event_type( p_em, vlc_InputStateChanged );
-    vlc_event_manager_register_event_type( p_em, vlc_InputSelectedStreamChanged );
-
     /* Init Common fields */
     p_input->b_eof = false;
     p_input->b_can_pace_control = true;
@@ -324,8 +318,6 @@ static void Destructor( input_thread_t * p_input )
     free( psz_name );
 #endif
 
-    vlc_event_manager_fini( &p_input->p->event_manager );
-
     stats_TimerDump( p_input, STATS_TIMER_INPUT_LAUNCHING );
     stats_TimerClean( p_input, STATS_TIMER_INPUT_LAUNCHING );
 #ifdef ENABLE_SOUT
@@ -1080,7 +1072,7 @@ static void LoadSlaves( input_thread_t *p_input )
         msg_Dbg( p_input, "adding slave input '%s'", psz );
 
         input_source_t *p_slave = InputSourceNew( p_input );
-        if( !InputSourceInit( p_input, p_slave, psz, NULL ) )
+        if( p_slave && !InputSourceInit( p_input, p_slave, psz, NULL ) )
             TAB_APPEND( p_input->p->i_slave, p_input->p->slave, p_slave );
         else
             free( p_slave );
@@ -1933,8 +1925,8 @@ static bool Control( input_thread_t *p_input, int i_type,
                 {
                     es_out_SetTime( p_input->p->p_es_out, -1 );
 
-                    access_Control( p_access, ACCESS_SET_TITLE, i_title );
-                    stream_AccessReset( p_input->p->input.p_stream );
+                    stream_Control( p_input->p->input.p_stream, STREAM_CONTROL_ACCESS,
+                                    ACCESS_SET_TITLE, i_title );
                 }
             }
             break;
@@ -2012,9 +2004,8 @@ static bool Control( input_thread_t *p_input, int i_type,
                 {
                     es_out_SetTime( p_input->p->p_es_out, -1 );
 
-                    access_Control( p_access, ACCESS_SET_SEEKPOINT,
-                                    i_seekpoint );
-                    stream_AccessReset( p_input->p->input.p_stream );
+                    stream_Control( p_input->p->input.p_stream, STREAM_CONTROL_ACCESS,
+                                    ACCESS_SET_SEEKPOINT, i_seekpoint );
                 }
             }
             break;
@@ -2032,7 +2023,7 @@ static bool Control( input_thread_t *p_input, int i_type,
             {
                 input_source_t *slave = InputSourceNew( p_input );
 
-                if( !InputSourceInit( p_input, slave, val.psz_string, NULL ) )
+                if( slave && !InputSourceInit( p_input, slave, val.psz_string, NULL ) )
                 {
                     vlc_meta_t *p_meta;
                     int64_t i_time;
@@ -2256,7 +2247,7 @@ static int UpdateTitleSeekpointFromAccess( input_thread_t *p_input )
     {
         input_SendEventTitle( p_input, p_access->info.i_title );
 
-        stream_AccessUpdate( p_input->p->input.p_stream );
+        stream_Control( p_input->p->input.p_stream, STREAM_UPDATE_SIZE );
 
         p_access->info.i_update &= ~INPUT_UPDATE_TITLE;
     }
@@ -2322,22 +2313,15 @@ static int InputSourceInit( input_thread_t *p_input,
                             input_source_t *in, const char *psz_mrl,
                             const char *psz_forced_demux )
 {
-    const bool b_master = in == &p_input->p->input;
-
     char psz_dup[strlen(psz_mrl) + 1];
     const char *psz_access;
     const char *psz_demux;
     char *psz_path;
-    char *psz_tmp;
-    char *psz;
     vlc_value_t val;
     double f_fps;
 
     strcpy( psz_dup, psz_mrl );
 
-    if( !in ) return VLC_EGENERIC;
-    if( !p_input ) return VLC_EGENERIC;
-
     /* Split uri */
     input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_dup );
 
@@ -2467,28 +2451,6 @@ static int InputSourceInit( input_thread_t *p_input,
             goto error;
         }
 
-        /* */
-        psz_tmp = psz = var_GetNonEmptyString( p_input, "access-filter" );
-        while( psz && *psz )
-        {
-            access_t *p_access = in->p_access;
-            char *end = strchr( psz, ':' );
-
-            if( end )
-                *end++ = '\0';
-
-            in->p_access = access_FilterNew( in->p_access, psz );
-            if( in->p_access == NULL )
-            {
-                in->p_access = p_access;
-                msg_Warn( p_input, "failed to insert access filter %s",
-                          psz );
-            }
-
-            psz = end;
-        }
-        free( psz_tmp );
-
         /* Get infos from access */
         if( !p_input->b_preparsing )
         {
@@ -2520,6 +2482,10 @@ static int InputSourceInit( input_thread_t *p_input,
             var_Set( p_input, "can-seek", val );
         }
 
+        /* TODO (maybe)
+         * do not let stream_AccessNew access input-list
+         * but give it a list of access ? */
+
         /* Autodetect extra files if none specified */
         char *psz_input_list = var_CreateGetNonEmptyString( p_input, "input-list" );
         if( !psz_input_list )
@@ -2533,7 +2499,7 @@ static int InputSourceInit( input_thread_t *p_input,
         /* Create the stream_t */
         in->p_stream = stream_AccessNew( in->p_access, p_input->b_preparsing );
 
-        /* Restor old value */
+        /* Restore old value */
         if( !psz_input_list )
             var_SetString( p_input, "input-list", "" );
         free( psz_input_list );
@@ -2544,6 +2510,14 @@ static int InputSourceInit( input_thread_t *p_input,
             goto error;
         }
 
+        /* Add stream filters */
+        char *psz_stream_filter = var_GetNonEmptyString( p_input,
+                                                         "stream-filter" );
+        in->p_stream = stream_FilterChainNew( in->p_stream,
+                                              psz_stream_filter,
+                                              var_GetBool( p_input, "input-record-native" ) );
+        free( psz_stream_filter );
+
         /* Open a demuxer */
         if( *psz_demux == '\0' && *in->p_access->psz_demux )
         {
@@ -2602,7 +2576,7 @@ static int InputSourceInit( input_thread_t *p_input,
     if( demux_Control( in->p_demux, DEMUX_CAN_RECORD, &in->b_can_stream_record ) )
         in->b_can_stream_record = false;
 #ifdef ENABLE_SOUT
-    if( !var_CreateGetBool( p_input, "input-record-native" ) )
+    if( !var_GetBool( p_input, "input-record-native" ) )
         in->b_can_stream_record = false;
     var_SetBool( p_input, "can-record", true );
 #else
@@ -2637,9 +2611,6 @@ static int InputSourceInit( input_thread_t *p_input,
     return VLC_SUCCESS;
 
 error:
-    if( b_master )
-        input_ChangeState( p_input, ERROR_S );
-
     if( in->p_demux )
         demux_Delete( in->p_demux );
 
@@ -2706,7 +2677,7 @@ static void InputSourceMeta( input_thread_t *p_input,
     if( !p_demux_meta )
         return;
 
-    module_t *p_id3 = module_need( p_demux, "meta reader", NULL, 0 );
+    module_t *p_id3 = module_need( p_demux, "meta reader", NULL, false );
     if( p_id3 )
     {
         if( p_demux_meta->p_meta )
@@ -3142,7 +3113,7 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
     var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &count, NULL );
 
     sub = InputSourceNew( p_input );
-    if( InputSourceInit( p_input, sub, psz_subtitle, "subtitle" ) )
+    if( !sub || InputSourceInit( p_input, sub, psz_subtitle, "subtitle" ) )
     {
         free( sub );
         return;
@@ -3167,22 +3138,6 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
     }
 }
 
-bool input_AddSubtitles( input_thread_t *p_input, char *psz_subtitle,
-                               bool b_check_extension )
-{
-    vlc_value_t val;
-
-    if( b_check_extension && !subtitles_Filter( psz_subtitle ) )
-        return false;
-
-    assert( psz_subtitle != NULL );
-
-    val.psz_string = strdup( psz_subtitle );
-    if( val.psz_string )
-        input_ControlPush( p_input, INPUT_CONTROL_ADD_SUBTITLE, &val );
-    return true;
-}
-
 /*****************************************************************************
  * Statistics
  *****************************************************************************/
@@ -3222,13 +3177,6 @@ void input_UpdateStatistic( input_thread_t *p_input,
     }
     vlc_mutex_unlock( &p_input->p->counters.counters_lock);
 }
-/*****************************************************************************
- * input_get_event_manager
- *****************************************************************************/
-vlc_event_manager_t *input_get_event_manager( input_thread_t *p_input )
-{
-    return &p_input->p->event_manager;
-}
 
 /**/
 /* TODO FIXME nearly the same logic that snapshot code */