]> git.sesse.net Git - vlc/commitdiff
* control: added INPUT_DEL_INFO.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 26 Apr 2005 07:17:42 +0000 (07:17 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 26 Apr 2005 07:17:42 +0000 (07:17 +0000)
 * input: allow chaining of access_filter (like filter1:filter2 ...)
 * es_out: support VLC_META_NOW_PLAYING for multi-program stream.

src/input/control.c
src/input/es_out.c
src/input/input.c

index 9ae07321e8d51d52295af4b6ac89cc6a01690266..776cfc94a3055605c538da7de41981238aa2bd80 100644 (file)
@@ -196,6 +196,47 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             NotifyPlaylist( p_input );
         }
         return VLC_SUCCESS;
+        case INPUT_DEL_INFO:
+        {
+            char *psz_cat = (char *)va_arg( args, char * );
+            char *psz_name = (char *)va_arg( args, char * );
+
+            info_category_t *p_cat = NULL;
+            int i;
+
+            vlc_mutex_lock( &p_input->input.p_item->lock );
+            for( i = 0; i < p_input->input.p_item->i_categories; i++ )
+            {
+                if( !strcmp( p_input->input.p_item->pp_categories[i]->psz_name,
+                             psz_cat ) )
+                {
+                    p_cat = p_input->input.p_item->pp_categories[i];
+                    break;
+                }
+            }
+            if( p_cat == NULL )
+            {
+                vlc_mutex_unlock( &p_input->input.p_item->lock );
+                return VLC_EGENERIC;
+            }
+
+            for( i = 0; i < p_cat->i_infos; i++ )
+            {
+                if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
+                {
+                    REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
+                    break;
+                }
+            }
+            vlc_mutex_unlock( &p_input->input.p_item->lock );
+
+            if( i >= p_cat->i_infos )
+                return VLC_EGENERIC;
+
+            NotifyPlaylist( p_input );
+        }
+        return VLC_SUCCESS;
+
 
         case INPUT_GET_INFO:
         {
@@ -203,7 +244,6 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             char *psz_name = (char *)va_arg( args, char * );
             char **ppsz_value = (char **)va_arg( args, char ** );
             int i_ret = VLC_EGENERIC;
-            int i;
             *ppsz_value = NULL;
 
             *ppsz_value = vlc_input_item_GetInfo( p_input->input.p_item,
index 3e875da76a6dabfd066e48b077eb21ea69abc2fc..280eedf3a9835ff75100b19bd0580f5040bc4257 100644 (file)
@@ -53,6 +53,8 @@ typedef struct
     /* Clock for this program */
     input_clock_t clock;
 
+    char    *psz_now_playing;
+
 } es_out_pgrm_t;
 
 struct es_out_id_t
@@ -238,6 +240,8 @@ void input_EsOutDelete( es_out_t *out )
 
     for( i = 0; i < p_sys->i_pgrm; i++ )
     {
+        if( p_sys->pgrm[i]->psz_now_playing )
+            free( p_sys->pgrm[i]->psz_now_playing );
         free( p_sys->pgrm[i] );
     }
     if( p_sys->pgrm )
@@ -441,6 +445,18 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
         EsOutSelect( out, p_sys->es[i], VLC_FALSE );
     }
 
+    /* Update now playing if defined per program */
+    if( p_pgrm->psz_now_playing )
+    {
+        char *psz_cat = malloc( strlen(_("Program")) + 10 );
+
+        sprintf( psz_cat, "%s %d", _("Program"), p_pgrm->i_id );
+        input_Control( p_input, INPUT_ADD_INFO, _("Meta-information"),
+                       VLC_META_NOW_PLAYING, "%s", p_pgrm->psz_now_playing );
+        free( psz_cat );
+    }
+
+
     var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
 }
 
@@ -459,6 +475,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
     p_pgrm->i_id = i_group;
     p_pgrm->i_es = 0;
     p_pgrm->b_selected = VLC_FALSE;
+    p_pgrm->psz_now_playing = NULL;
     input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->input.i_cr_average );
 
     /* Append it */
@@ -484,8 +501,12 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
 static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
 {
     es_out_sys_t      *p_sys = out->p_sys;
+    es_out_pgrm_t     *p_pgrm = NULL;
     input_thread_t    *p_input = p_sys->p_input;
     char              *psz_cat = malloc( strlen(_("Program")) + 10 );
+    char              *psz_name = NULL;
+    char              *psz_now_playing = NULL;
+    char              *psz_provider = NULL;
     int i;
 
     msg_Dbg( p_input, "EsOutProgramMeta: number=%d", i_group );
@@ -497,6 +518,63 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
 
         input_Control( p_input, INPUT_ADD_INFO, psz_cat,
                       _(p_meta->name[i]), "%s", p_meta->value[i] );
+        if( !strcasecmp( p_meta->name[i], "Name" ) )
+            psz_name = p_meta->value[i];
+        else if( !strcasecmp( p_meta->name[i], "Provider" ) )
+            psz_provider = p_meta->value[i];
+        else if( !strcasecmp( p_meta->name[i], VLC_META_NOW_PLAYING ) )
+            psz_now_playing = p_meta->value[i];
+    }
+
+    if( !psz_name && !psz_now_playing )
+    {
+        free( psz_cat );
+        return;
+    }
+
+    for( i = 0; i < p_sys->i_pgrm; i++ )
+    {
+        if( p_sys->pgrm[i]->i_id == i_group )
+        {
+            p_pgrm = p_sys->pgrm[i];
+            break;
+        }
+    }
+
+    if( p_pgrm == NULL )
+        p_pgrm = EsOutProgramAdd( out, i_group );
+
+    /* Update the description text of the program */
+    if( psz_name && *psz_name )
+    {
+        vlc_value_t val;
+        vlc_value_t text;
+
+        /* ugly but it works */
+        val.i_int = i_group;
+        var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
+
+        if( psz_provider && *psz_provider )
+        {
+            asprintf( &text.psz_string, "%s [%s]", psz_name, psz_provider );
+            var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, &text );
+            free( text.psz_string );
+        }
+        else
+        {
+            text.psz_string = psz_name;
+            var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, &text );
+        }
+    }
+    if( psz_now_playing )
+    {
+        p_pgrm->psz_now_playing = strdup(psz_now_playing);
+
+        if( p_sys->p_pgrm == p_pgrm )
+        {
+            input_Control( p_input, INPUT_ADD_INFO, _("Meta-information"),
+                           VLC_META_NOW_PLAYING, "%s", psz_now_playing );
+        }
     }
     free( psz_cat );
 }
index 4fbe16bb4b0246f1a74feeca726477252cbad457..fb02a6ff40538584a5b2d2256a7750f3b0b39b57 100644 (file)
@@ -218,6 +218,10 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
         free( val.psz_string );
     }
 
+    /* Remove 'Now playing' info as it is probably outdated */
+    input_Control( p_input, INPUT_DEL_INFO, _("Meta-information"),
+                   VLC_META_NOW_PLAYING );
+
     /* Now we can attach our new input */
     vlc_object_attach( p_input, p_parent );
 
@@ -1911,13 +1915,15 @@ static int InputSourceInit( input_thread_t *p_input,
     char *psz_access;
     char *psz_demux;
     char *psz_path;
+    char *psz_tmp;
     char *psz;
     vlc_value_t val;
 
     /* Split uri */
     if( !b_quick )
     {
-        MRLSplit( p_input, psz_dup, &psz_access, &psz_demux, &psz_path );
+        MRLSplit( VLC_OBJECT(p_input), psz_dup,
+                  &psz_access, &psz_demux, &psz_path );
 
         msg_Dbg( p_input, "`%s' gives access `%s' demux `%s' path `%s'",
                  psz_mrl, psz_access, psz_demux, psz_path );
@@ -2022,12 +2028,15 @@ static int InputSourceInit( input_thread_t *p_input,
         }
 
         /* */
-        psz = var_GetString( p_input, "access-filter" );
-        if( *psz )
+        psz_tmp = psz = var_GetString( p_input, "access-filter" );
+        while( psz && *psz )
         {
             access_t *p_access = in->p_access;
+            char *end = strchr( psz, ':' );
+
+            if( end )
+                *end++ = '\0';
 
-            /* TODO support chained access-filter */
             in->p_access = access2_FilterNew( in->p_access, psz );
             if( in->p_access == NULL )
             {
@@ -2035,8 +2044,10 @@ static int InputSourceInit( input_thread_t *p_input,
                 msg_Warn( p_input, "failed to insert access filter %s",
                           psz );
             }
+
+            psz = end;
         }
-        free( psz );
+        free( psz_tmp );
 
         /* Get infos from access */
         if( !b_quick )