]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
Added a INPUT_GET_VIDEO_FPS (get the fps of the main video, should works with
[vlc] / src / input / input.c
index 017effed4ca3cacfc248d4a30b7fc4cf67c3fff7..55fe92c6820dfbc2876679df8510790c4f498c86 100644 (file)
@@ -272,23 +272,23 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
 static void Destroy( input_thread_t *p_input, sout_instance_t **pp_sout )
 {
     vlc_object_detach( p_input );
+    input_thread_private_t *priv = p_input->p;
 
     if( pp_sout )
         *pp_sout = NULL;
-    if( p_input->p->p_sout )
+    if( priv->p_sout )
     {
         if( pp_sout )
-            *pp_sout = p_input->p->p_sout;
-        else if( p_input->p->b_sout_keep )
-            SoutKeep( p_input->p->p_sout );
+            *pp_sout = priv->p_sout;
+        else if( priv->b_sout_keep )
+            SoutKeep( priv->p_sout );
         else
-            sout_DeleteInstance( p_input->p->p_sout );
+            sout_DeleteInstance( priv->p_sout );
     }
 
-    vlc_mutex_destroy( &p_input->p->lock_control );
-    free( p_input->p );
-
     vlc_object_destroy( p_input );
+    vlc_mutex_destroy( &priv->lock_control );
+    free( priv );
 }
 
 /**
@@ -761,6 +761,20 @@ static int Init( input_thread_t * p_input )
     memset( &p_input->p->counters, 0, sizeof( p_input->p->counters ) );
     vlc_mutex_init( p_input, &p_input->p->counters.counters_lock );
 
+    for( i = 0; i < p_input->p->input.p_item->i_options; i++ )
+    {
+        if( !strncmp( p_input->p->input.p_item->ppsz_options[i], "meta-file", 9 ) )
+        {
+            msg_Dbg( p_input, "Input is a meta file: disabling unneeded options" );
+            var_SetString( p_input, "sout", "" );
+            var_SetBool( p_input, "sout-all", VLC_FALSE );
+            var_SetString( p_input, "input-slave", "" );
+            var_SetInteger( p_input, "input-repeat", 0 );
+            var_SetString( p_input, "sub-file", "" );
+            var_SetBool( p_input, "sub-autodetect-file", VLC_FALSE );
+        }
+    }
+
     if( !p_input->b_preparsing )
     {
         /* Prepare statistics */
@@ -1015,7 +1029,7 @@ static int Init( input_thread_t * p_input )
             /* Then, just add the following subtitles files */
             for( ; subs && subs[i]; i++ )
             {
-                if( strcmp( psz_subtitle, subs[i] ) )
+                if( !psz_subtitle || strcmp( psz_subtitle, subs[i] ) )
                 {
                     sub = InputSourceNew( p_input );
                     if( !InputSourceInit( p_input, sub, subs[i], "subtitle" ) )
@@ -1605,8 +1619,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
                 val.i_int = PLAYING_S;
                 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
 
-                /* Reset clock */
-                es_out_Control( p_input->p->p_es_out, ES_OUT_RESET_PCR );
+                /* */
+                if( !i_ret )
+                    input_EsOutChangeState( p_input->p->p_es_out );
             }
             else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S &&
                      p_input->p->b_can_pause )
@@ -1635,9 +1650,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
                 p_input->i_state = val.i_int;
                 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
 
-                /* Send discontinuity to decoders (it will allow them to flush
-                 * if implemented */
-                input_EsOutDiscontinuity( p_input->p->p_es_out, VLC_FALSE, VLC_FALSE );
+                /* */
+                if( !i_ret )
+                    input_EsOutChangeState( p_input->p->p_es_out );
             }
             else if( val.i_int == PAUSE_S && !p_input->p->b_can_pause )
             {
@@ -1688,12 +1703,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
                 val.i_int = i_rate;
                 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
 
-                input_EsOutDiscontinuity( p_input->p->p_es_out,
-                                          VLC_FALSE, VLC_FALSE );
-
                 p_input->p->i_rate  = i_rate;
 
-                input_EsOutSetRate( p_input->p->p_es_out );
+                input_EsOutChangeRate( p_input->p->p_es_out );
 
                 b_force_update = VLC_TRUE;
             }
@@ -2071,6 +2083,7 @@ static input_source_t *InputSourceNew( input_thread_t *p_input )
     TAB_INIT( in->i_title, in->title );
     in->b_can_pace_control = VLC_TRUE;
     in->b_eof = VLC_FALSE;
+    in->f_fps = 0.0;
     in->i_cr_average = 0;
 
     return in;
@@ -2090,6 +2103,7 @@ static int InputSourceInit( input_thread_t *p_input,
     char *psz_tmp;
     char *psz;
     vlc_value_t val;
+    double f_fps;
 
     strcpy( psz_dup, psz_mrl );
 
@@ -2331,27 +2345,34 @@ static int InputSourceInit( input_thread_t *p_input,
                 in->b_title_demux = VLC_TRUE;
             }
         }
-        /* get attachment
-         * FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
-        if( 1 || !p_input->b_preparsing )
+    }
+
+    /* get attachment
+     * FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
+    if( 1 || !p_input->b_preparsing )
+    {
+        int i_attachment;
+        input_attachment_t **attachment;
+        if( !demux2_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
+                             &attachment, &i_attachment ) )
         {
-            int i_attachment;
-            input_attachment_t **attachment;
-            if( !demux2_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
-                                 &attachment, &i_attachment ) )
-            {
-                int i;
-                vlc_mutex_lock( &p_input->p->input.p_item->lock );
-                p_input->p->attachment = realloc( p_input->p->attachment,
-                        sizeof(input_attachment_t**) * ( p_input->p->i_attachment + i_attachment ) );
-                for( i = 0; i < i_attachment; i++ )
-                    p_input->p->attachment[p_input->p->i_attachment++] = attachment[i];
-                if( attachment )
-                    free( attachment );
-                vlc_mutex_unlock( &p_input->p->input.p_item->lock );
-            }
+            int i;
+            vlc_mutex_lock( &p_input->p->input.p_item->lock );
+            p_input->p->attachment = realloc( p_input->p->attachment,
+                    sizeof(input_attachment_t**) * ( p_input->p->i_attachment + i_attachment ) );
+            for( i = 0; i < i_attachment; i++ )
+                p_input->p->attachment[p_input->p->i_attachment++] = attachment[i];
+            if( attachment )
+                free( attachment );
+            vlc_mutex_unlock( &p_input->p->input.p_item->lock );
         }
     }
+    if( !demux2_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) )
+    {
+        vlc_mutex_lock( &p_input->p->input.p_item->lock );
+        in->f_fps = f_fps;
+        vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+    }
 
     if( var_GetInteger( p_input, "clock-synchro" ) != -1 )
         in->b_can_pace_control = !var_GetInteger( p_input, "clock-synchro" );