[vlc-devel] Patch: clone-vout-list option

Olivier Aubert oaubert at bat710.univ-lyon1.fr
Mon Mar 17 18:42:23 CET 2003


Hello.

Here is a patch (in the right order this time) against the current CVS
tree. It adds a new option to the clone module : clone-vout-list. It is
a comma-separated list of vout module names. 

This setting overrides the clone-count one (which it sets to the number
of specified vouts). When present, it will spawn the specified vout
modules. There is a special identifier, "default", which will spawn the
default output module (whichever vlc guesses).

We can now specify, for instance, that we want a sdl-output and a X11
one :
vlc --filter clone --clone-vout-list sdl,x11

Another example (I developped it in order to integrate a snapshot
functionality in vlc) :
vlc --filter clone --clone-vout-list default,snapshot

The snapshot vout module is still in my CVS, I have to clean it up a
little before submitting it, if there is interest.

Question for the VLC-architecture wizards : there is a problem during
the deleting phase. It gives the following error messages :
[00000135] main video output error: cannot delete object with a parent
[00000134] main video output error: cannot delete object with a parent
[00000133] main video output error: cannot delete object with children

It does it with the original clone module, so I did not investigate much
further. I guess that there is some kind of circular reference between
clone and the different vouts, that should be resolved one way or the
other.

Bye

Olivier

-------------- next part --------------
--- vlc-cvs/modules/video_filter/clone.c	2003-02-20 02:52:46.000000000 +0100
+++ vlc-0.5.0/modules/video_filter/clone.c	2003-03-14 10:05:53.000000000 +0100
@@ -54,9 +54,13 @@
 #define COUNT_LONGTEXT N_("Select the number of video windows in which to "\
     "clone the video")
 
+#define VOUTLIST_TEXT N_("list of vout modules")
+#define VOUTLIST_LONGTEXT N_("Select the specific vout modules that you want to activate")
+
 vlc_module_begin();
-    add_category_hint( N_("Clone"), NULL, VLC_FALSE );
-    add_integer( "clone-count", 2, NULL, COUNT_TEXT, COUNT_LONGTEXT, VLC_FALSE );
+    add_category_hint( N_("Miscellaneous"), NULL );
+    add_integer( "clone-count", 2, NULL, COUNT_TEXT, COUNT_LONGTEXT );
+    add_string ( "clone-vout-list", NULL, NULL, VOUTLIST_TEXT, VOUTLIST_LONGTEXT );
     set_description( _("image clone video module") );
     set_capability( "video filter", 0 );
     add_shortcut( "clone" );
@@ -72,6 +76,12 @@
 struct vout_sys_t
 {
     int    i_clones;
+
+  /* list of vout modules to use. "default" will launch a default
+     module. If specified, overrides the setting in i_clones (which it
+     sets to the list length) */
+  char** ppsz_vout_list;
+
     vout_thread_t **pp_vout;
 };
 
@@ -83,6 +93,7 @@
 static int Create( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
+    char* psz_clonelist;
 
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
@@ -98,8 +109,61 @@
     p_vout->pf_render = Render;
     p_vout->pf_display = NULL;
 
-    /* Look what method was requested */
-    p_vout->p_sys->i_clones = config_GetInt( p_vout, "clone-count" );
+    psz_clonelist = config_GetPsz( p_vout, "clone-vout-list" );
+    if (psz_clonelist)
+      {
+	int i_dummy;
+	char* psz_token;
+	char* psz_temp;
+
+	#define VOUTSEPARATOR ","
+	/* Count the number of defined vout */
+	p_vout->p_sys->i_clones = 1;
+	i_dummy = 0;
+	while (psz_clonelist[i_dummy] != 0)
+	  {
+	    if (psz_clonelist[i_dummy] == VOUTSEPARATOR[0])
+	      p_vout->p_sys->i_clones++;	    
+	    i_dummy++;
+	  }
+	
+	p_vout->p_sys->ppsz_vout_list = malloc (p_vout->p_sys->i_clones);
+	if (! p_vout->p_sys->ppsz_vout_list)
+	  {
+	    msg_Err( p_vout, "out of memory" );
+	    free( p_vout->p_sys );
+	    return VLC_ENOMEM;
+	  }
+
+	/* Tokenize the list */
+	i_dummy = 0;
+	psz_token = strtok_r( psz_clonelist, VOUTSEPARATOR, &psz_temp );
+	while (psz_token)
+	  {
+	    p_vout->p_sys->ppsz_vout_list[i_dummy] = strdup (psz_token);
+	    psz_token = strtok_r( NULL, VOUTSEPARATOR, &psz_temp );
+	    i_dummy++;
+	  }
+
+	/* Test */
+	/*
+	fprintf (stderr, "Clones : \n");
+	for (i_dummy = 0 ; i_dummy < p_vout->p_sys->i_clones ; i_dummy++)
+	  {
+	    fprintf (stderr, "  Vout[%d]: %s\n", 
+		     i_dummy + 1, 
+		     p_vout->p_sys->ppsz_vout_list[i_dummy]);
+	  }
+	*/
+	free (psz_clonelist);
+      }
+    else
+      {
+	/* No list was specified. We will use the default vout, and get
+	   the number of clones from clone-count */
+	p_vout->p_sys->i_clones = config_GetInt( p_vout, "clone-count" );
+	p_vout->p_sys->ppsz_vout_list = NULL;
+      }
 
     p_vout->p_sys->i_clones = __MAX( 1, __MIN( 99, p_vout->p_sys->i_clones ) );
 
@@ -124,6 +188,7 @@
 {
     int   i_index, i_vout;
     picture_t *p_pic;
+    char* psz_default_vout;
 
     I_OUTPUTPICTURES = 0;
 
@@ -136,22 +201,47 @@
     /* Try to open the real video output */
     msg_Dbg( p_vout, "spawning the real video outputs" );
 
+    /* Save the default vout */
+    psz_default_vout = config_GetPsz( p_vout, "vout" );
+
     for( i_vout = 0; i_vout < p_vout->p_sys->i_clones; i_vout++ )
     {
-        p_vout->p_sys->pp_vout[ i_vout ] = vout_Create( p_vout,
-                            p_vout->render.i_width, p_vout->render.i_height,
-                            p_vout->render.i_chroma, p_vout->render.i_aspect );
-        if( p_vout->p_sys->pp_vout[ i_vout ] == NULL )
+      if (p_vout->p_sys->ppsz_vout_list == NULL 
+	  || (! strncmp (p_vout->p_sys->ppsz_vout_list [i_vout],
+			 "default", 8)))
+	{
+	  p_vout->p_sys->pp_vout[i_vout] = vout_Create( p_vout,
+							p_vout->render.i_width,
+							p_vout->render.i_height,
+							p_vout->render.i_chroma, 
+							p_vout->render.i_aspect);
+	}
+      else
+	{
+	  /* create the appropriate vout instead of the default one */
+	  config_PutPsz( p_vout, "vout", p_vout->p_sys->ppsz_vout_list [i_vout]);
+	  p_vout->p_sys->pp_vout[i_vout] = vout_Create( p_vout,
+							p_vout->render.i_width,
+							p_vout->render.i_height,
+							p_vout->render.i_chroma, 
+							p_vout->render.i_aspect);
+
+	  /* Reset the default value */
+	  config_PutPsz( p_vout, "vout", psz_default_vout);
+	}
+      
+      if( p_vout->p_sys->pp_vout[ i_vout ] == NULL )
         {
-            msg_Err( p_vout, "failed to clone %i vout threads",
-                             p_vout->p_sys->i_clones );
-            p_vout->p_sys->i_clones = i_vout;
-            RemoveAllVout( p_vout );
-            return VLC_EGENERIC;
+	  msg_Err( p_vout, "failed to clone %i vout threads",
+		   p_vout->p_sys->i_clones );
+	  p_vout->p_sys->i_clones = i_vout;
+	  free (psz_default_vout);
+	  RemoveAllVout( p_vout );
+	  return VLC_EGENERIC;
         }
-        ADD_CALLBACKS( p_vout->p_sys->pp_vout[ i_vout ], SendEvents );
+      ADD_CALLBACKS( p_vout->p_sys->pp_vout[ i_vout ], SendEvents );
     }
-
+    free (psz_default_vout);
     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
 
     return VLC_SUCCESS;


More information about the vlc-devel mailing list