[vlc-devel] [RFC] description: don't use vlc_object_find()

Pierre Ynard linkfanel at yahoo.fr
Fri Nov 12 03:49:24 CET 2010


This also fixes the conflict with the input item formats: the point
is to use description after an eventual #transcode to get the output
formats. The VLM now replaces the input formats with the output formats,
instead of adding them in the same array. The VoD API is preserved (for
now). Is there anything else that relies on #description ?

Once again, this works by passing down input variables, which is still
broken since the input resources were made not to be children of the
input. How should we fix that? One solution I see is to make the input
resource an object, and copy all the input variables to it.

(This patch is to be completed to eliminate the other use of
vlc_object_find(), to stop the input.)


diff --git a/modules/stream_out/description.c b/modules/stream_out/description.c
index 6930642..70ac3df 100644
--- a/modules/stream_out/description.c
+++ b/modules/stream_out/description.c
@@ -59,6 +59,8 @@ vlc_module_end ()
 
 struct sout_stream_sys_t
 {
+    int *pi_es;
+    es_format_t ***p_es;
     mtime_t i_stream_start;
 };
 
@@ -79,6 +81,14 @@ static int Open( vlc_object_t *p_this )
     p_stream->pf_send = Send;
     p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t));
 
+    p_sys->pi_es = var_InheritAddress(p_stream, "sout-description-index");
+    p_sys->p_es = var_InheritAddress(p_stream, "sout-description-es");
+    if (p_sys->pi_es == NULL || p_sys->p_es == NULL)
+    {
+        msg_Err(p_stream, "The description stream output is not meant to be used like that");
+        free(p_sys);
+        return VLC_EGENERIC;
+    }
     p_sys->i_stream_start = 0;
 
     return VLC_SUCCESS;
@@ -102,22 +112,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     sout_stream_id_t *id;
     es_format_t *p_fmt_copy;
-    input_item_t *p_item;
-    input_thread_t *p_input;
 
     msg_Dbg( p_stream, "Adding a stream" );
-    p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_PARENT );
-    assert( p_input );
  
-    p_item = input_GetItem(p_input);
-
     p_fmt_copy = malloc(sizeof(es_format_t));
     es_format_Copy( p_fmt_copy, p_fmt );
 
-    vlc_mutex_lock( &p_item->lock );
-    TAB_APPEND( p_item->i_es, p_item->es, p_fmt_copy );
-    vlc_mutex_unlock( &p_item->lock );
-    vlc_object_release( p_input );
+    TAB_APPEND( *p_sys->pi_es, *p_sys->p_es, p_fmt_copy );
 
     if( p_sys->i_stream_start <= 0 )
         p_sys->i_stream_start = mdate();
diff --git a/src/input/vlm.c b/src/input/vlm.c
index fa1f4cd..bff4f9a 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -615,12 +615,20 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
             if( asprintf( &psz_header, _("Media: %s"), p_cfg->psz_name ) == -1 )
                 psz_header = NULL;
 
+            int i_es;
+            es_format_t **p_out_es;
+            TAB_INIT(i_es, p_out_es);
+
             p_input = input_Create( p_vlm->p_vod, p_media->vod.p_item, psz_header, NULL );
             if( p_input )
             {
                 vlc_sem_t sem_preparse;
                 vlc_sem_init( &sem_preparse, 0 );
                 var_AddCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
+                var_Create( p_input, "sout-description-index", VLC_VAR_ADDRESS );
+                var_SetAddress( p_input, "sout-description-index", &i_es );
+                var_Create( p_input, "sout-description-es", VLC_VAR_ADDRESS );
+                var_SetAddress( p_input, "sout-description-es", &p_out_es );
 
                 if( !input_Start( p_input ) )
                 {
@@ -637,9 +645,10 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
             }
             free( psz_header );
 
+            /* XXX: Don't do it that way, but properly use a new input item ref. */
+            input_item_t item = *p_media->vod.p_item;;
             if( p_cfg->vod.psz_mux )
             {
-                input_item_t item;
                 es_format_t es, *p_es = &es;
                 union { char text[5]; uint32_t value; } fourcc;
 
@@ -649,20 +658,19 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
                 fourcc.text[2] = tolower(fourcc.text[2]);
                 fourcc.text[3] = tolower(fourcc.text[3]);
 
-                /* XXX: Don't do it that way, but properly use a new input item ref. */
-                item = *p_media->vod.p_item;
                 item.i_es = 1;
                 item.es = &p_es;
                 es_format_Init( &es, VIDEO_ES, fourcc.value );
-
-                p_media->vod.p_media =
-                    p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, &item );
             }
             else
             {
-                p_media->vod.p_media =
-                    p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, p_media->vod.p_item );
+                item.i_es = i_es;
+                item.es = p_out_es;
             }
+            p_media->vod.p_media = p_vlm->p_vod->pf_media_new( p_vlm->p_vod,
+                                                    p_cfg->psz_name, &item );
+
+            TAB_CLEAN(i_es, p_out_es);
         }
     }
     else if ( p_cfg->b_vod )


Regards,

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list