]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
include/vlc_meta.h: Use the vlc_dictionary to store extra meta tags.
[vlc] / src / input / input.c
index a1b39c0bea7a1329bbb512013002ade416b204ef..46b5759e71615da8553ca453256a4f70f234a39d 100644 (file)
@@ -147,6 +147,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     p_input->p->i_start = 0;
     p_input->i_time  = 0;
     p_input->p->i_stop  = 0;
+    p_input->p->i_run  = 0;
     p_input->p->i_title = 0;
     p_input->p->title   = NULL;
     p_input->p->i_title_offset = p_input->p->i_seekpoint_offset = 0;
@@ -227,7 +228,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
                      *psz_end = 0;
                      if( !strncmp( psz_start, "name=", 5 ) )
                      {
-                         p_seekpoint->psz_name = psz_start + 5;
+                         p_seekpoint->psz_name = strdup(psz_start + 5);
                      }
                      else if( !strncmp( psz_start, "bytes=", 6 ) )
                      {
@@ -573,6 +574,7 @@ exit:
  *****************************************************************************/
 static void MainLoop( input_thread_t *p_input )
 {
+    int64_t i_start_mdate = mdate();
     int64_t i_intf_update = 0;
     int i_updates = 0;
 
@@ -586,10 +588,11 @@ static void MainLoop( input_thread_t *p_input )
         /* Do the read */
         if( p_input->i_state != PAUSE_S  )
         {
-            if( p_input->p->i_stop <= 0 || p_input->i_time < p_input->p->i_stop )
-                i_ret=p_input->p->input.p_demux->pf_demux(p_input->p->input.p_demux);
+            if( ( p_input->p->i_stop > 0 && p_input->i_time >= p_input->p->i_stop ) ||
+                ( p_input->p->i_run > 0 && i_start_mdate+p_input->p->i_run < mdate() ) )
+                i_ret = 0; /* EOF */
             else
-                i_ret = 0;  /* EOF */
+                i_ret = p_input->p->input.p_demux->pf_demux(p_input->p->input.p_demux);
 
             if( i_ret > 0 )
             {
@@ -659,6 +662,9 @@ static void MainLoop( input_thread_t *p_input )
                         input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION,
                                            &val );
                     }
+
+                    /* */
+                    i_start_mdate = mdate();
                 }
             }
             else if( i_ret < 0 )
@@ -915,10 +921,14 @@ static int Init( input_thread_t * p_input )
 
         /* Start time*/
         /* Set start time */
-        p_input->p->i_start = (int64_t)var_GetInteger( p_input, "start-time" ) *
-                           I64C(1000000);
-        p_input->p->i_stop  = (int64_t)var_GetInteger( p_input, "stop-time" ) *
-                           I64C(1000000);
+        p_input->p->i_start = I64C(1000000) * var_GetInteger( p_input, "start-time" );
+        p_input->p->i_stop  = I64C(1000000) * var_GetInteger( p_input, "stop-time" );
+        p_input->p->i_run   = I64C(1000000) * var_GetInteger( p_input, "run-time" );
+        if( p_input->p->i_run < 0 )
+        {
+            msg_Warn( p_input, "invalid run-time ignored" );
+            p_input->p->i_run = 0;
+        }
 
         if( p_input->p->i_start > 0 )
         {
@@ -1670,14 +1680,12 @@ 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 );
 
-                /* We will not send audio data if new rate != default */
-                if( i_rate != INPUT_RATE_DEFAULT && p_input->p->i_rate == INPUT_RATE_DEFAULT )
-                    input_EsOutDiscontinuity( p_input->p->p_es_out, VLC_TRUE, VLC_TRUE );
+                input_EsOutDiscontinuity( p_input->p->p_es_out,
+                                          VLC_FALSE, VLC_FALSE );
 
                 p_input->p->i_rate  = i_rate;
 
-                /* Reset clock */
-                es_out_Control( p_input->p->p_es_out, ES_OUT_RESET_PCR );
+                input_EsOutSetRate( p_input->p->p_es_out );
 
                 b_force_update = VLC_TRUE;
             }
@@ -2190,7 +2198,16 @@ static int InputSourceInit( input_thread_t *p_input,
                                         psz_access, psz_demux, psz_path,
                                         p_input->b_preparsing );
         }
-
+        /* access failed, maybe our access detection was wrong.
+         * Retry with the full name */
+        if( in->p_access == NULL && strchr( psz_mrl, ':' ) )
+        {
+            msg_Dbg( p_input, "retrying with access `' demux `' path `%s'",
+                     psz_mrl );
+             in->p_access = access2_New( p_input,
+                                         "", "", psz_mrl,
+                                         p_input->b_preparsing );
+        }
         if( in->p_access == NULL )
         {
             msg_Err( p_input, "open of `%s' failed: %s", psz_mrl,
@@ -2491,6 +2508,7 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
 {
     input_item_t *p_item = p_input->p->input.p_item;
     char *psz_title = NULL;
+    int i;
 
     if( !p_meta )
         return;
@@ -2526,6 +2544,14 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
     }
 
     p_item->p_meta->i_status |= ITEM_PREPARSED;
+
+    /* A bit ugly */
+    p_meta = NULL;
+    if( vlc_dictionary_keys_count( &p_item->p_meta->extra_tags ) > 0 )
+    {
+        p_meta = vlc_meta_New();
+        vlc_meta_Merge( p_meta, p_item->p_meta );
+    }
     vlc_mutex_unlock( &p_item->lock );
 
     if( psz_title )
@@ -2534,25 +2560,38 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
         free( psz_title );
     }
 
+    if( p_meta )
+    {
+        char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
+        for( i = 0; ppsz_all_keys[i]; i++ )
+        {
+            input_Control( p_input, INPUT_ADD_INFO, _(VLC_META_INFO_CAT), _(ppsz_all_keys[i]),
+                    vlc_dictionary_value_for_key( &p_meta->extra_tags, ppsz_all_keys[i] ) );
+            free( ppsz_all_keys[i] );
+        }
+        free( ppsz_all_keys );
+        vlc_meta_Delete( p_meta );
+    }
+
     /** \todo handle sout meta */
 }
 
 
 static inline vlc_bool_t IsValidAccess( const char *psz )
 {
-    unsigned char c;
+    char c;
 
     while( ( c = *psz ) != '\0' )
     {
         if( c == ':' )
             return VLC_TRUE;
 
-        if( !isascii( c ) || !isalnum( c ) || ( c != '/' ) )
+        if( ( !isascii( c ) || !isalnum( c ) ) && ( c != '/' ) )
             return VLC_FALSE;
-
         psz++;
     }
-    return VLC_FALSE; /* should not happen though */
+    /* should not happen though */
+    return VLC_FALSE;
 }