]> git.sesse.net Git - vlc/blob - modules/video_filter/opencv_wrapper.c
db6b4a527fc99cbbc90e4714d28c474a8e397644
[vlc] / modules / video_filter / opencv_wrapper.c
1 /*****************************************************************************
2  * opencv_wrapper.c : OpenCV wrapper video filter
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  *
6  * Authors: Dugal Harris <dugalh@protoclea.co.za>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26
27 #include <cxcore.h>
28 #include <cv.h>
29 #include <highgui.h>
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc_common.h>
36 #include <vlc_plugin.h>
37 #include <vlc_vout.h>
38
39 #include <math.h>
40 #include <time.h>
41
42 #include "vlc_filter.h"
43 #include "filter_common.h"
44 #include <vlc_charset.h>
45 #include "vlc_image.h"
46 #include "vlc_input.h"
47 #include "vlc_playlist.h"
48
49
50 /*****************************************************************************
51  * Local prototypes
52  *****************************************************************************/
53 static int  Create    ( vlc_object_t * );
54 static void Destroy   ( vlc_object_t * );
55
56 static int  Init      ( vout_thread_t * );
57 static void End       ( vout_thread_t * );
58 static void Render    ( vout_thread_t *, picture_t * );
59
60 static int  SendEvents( vlc_object_t *, char const *,
61                         vlc_value_t, vlc_value_t, void * );
62 static void ReleaseImages( vout_thread_t *p_vout );
63 static void VlcPictureToIplImage( vout_thread_t *p_vout, picture_t *p_in );
64
65 /*****************************************************************************
66  * Module descriptor
67  *****************************************************************************/
68
69 static const char *const chroma_list[] = { "input", "I420", "RGB32"};
70 static const char *const chroma_list_text[] = { N_("Use input chroma unaltered"),
71   N_("I420 - first plane is greyscale"), N_("RGB32")};
72
73 static const char *const output_list[] = { "none", "input", "processed"};
74 static const char *const output_list_text[] = { N_("Don't display any video"),
75   N_("Display the input video"), N_("Display the processed video")};
76
77 static const char *const verbosity_list[] = { "error", "warning", "debug"};
78 static const char *const verbosity_list_text[] = { N_("Show only errors"),
79   N_("Show errors and warnings"), N_("Show everything including debug messages")};
80
81 vlc_module_begin();
82     set_description( N_("OpenCV video filter wrapper") );
83     set_shortname( N_("OpenCV" ));
84     set_category( CAT_VIDEO );
85     set_subcategory( SUBCAT_VIDEO_VFILTER );
86     set_capability( "video filter", 0 );
87     add_shortcut( "opencv_wrapper" );
88     set_callbacks( Create, Destroy );
89     add_float_with_range( "opencv-scale", 1.0, 0.1, 2.0, NULL,
90                           N_("Scale factor (0.1-2.0)"),
91                           N_("Ammount by which to scale the picture before sending it to the internal OpenCV filter"),
92                           false );
93     add_string( "opencv-chroma", "input", NULL,
94                           N_("OpenCV filter chroma"),
95                           N_("Chroma to convert picture to before sending it to the internal OpenCV filter"), false);
96         change_string_list( chroma_list, chroma_list_text, 0);
97     add_string( "opencv-output", "input", NULL,
98                           N_("Wrapper filter output"),
99                           N_("Determines what (if any) video is displayed by the wrapper filter"), false);
100         change_string_list( output_list, output_list_text, 0);
101     add_string( "opencv-verbosity", "error", NULL,
102                           N_("Wrapper filter verbosity"),
103                           N_("Determines wrapper filter verbosity level"), false);
104         change_string_list( verbosity_list, verbosity_list_text, 0);
105     add_string( "opencv-filter-name", "none", NULL,
106                           N_("OpenCV internal filter name"),
107                           N_("Name of internal OpenCV plugin filter to use"), false);
108 vlc_module_end();
109
110
111 /*****************************************************************************
112  * wrapper_output_t: what video is output
113  *****************************************************************************/
114 enum wrapper_output_t
115 {
116    NONE,    //not working yet
117    VINPUT,
118    PROCESSED
119 };
120
121 /*****************************************************************************
122  * internal_chroma_t: what chroma is sent to the internal opencv filter
123  *****************************************************************************/
124 enum internal_chroma_t
125 {
126    CINPUT,
127    GREY,
128    RGB
129 };
130
131 /*****************************************************************************
132  * verbosity_t:
133  *****************************************************************************/
134 enum verbosity_t
135 {
136    VERB_ERROR,
137    VERB_WARN,
138    VERB_DEBUG
139 };
140
141 /*****************************************************************************
142  * vout_sys_t: opencv_wrapper video output method descriptor
143  *****************************************************************************
144  * This structure is part of the video output thread descriptor.
145  * It describes the opencv_wrapper specific properties of an output thread.
146  *****************************************************************************/
147 struct vout_sys_t
148 {
149     vout_thread_t *p_vout;
150
151     image_handler_t *p_image;
152
153     int i_cv_image_size;
154
155     picture_t *p_proc_image;
156     picture_t *p_to_be_freed;
157
158     float f_scale;
159
160     int i_wrapper_output;
161     int i_internal_chroma;
162     int i_verbosity;
163
164     IplImage *p_cv_image[VOUT_MAX_PLANES];
165
166     filter_t *p_opencv;
167     char* psz_inner_name;
168
169     picture_t hacked_pic;
170 };
171
172 /*****************************************************************************
173  * Control: control facility for the vout (forwards to child vout)
174  *****************************************************************************/
175 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
176 {
177     return vout_vaControl( p_vout->p_sys->p_vout, i_query, args );
178 }
179
180 /*****************************************************************************
181  * Create: allocates opencv_wrapper video thread output method
182  *****************************************************************************
183  * This function allocates and initializes a opencv_wrapper vout method.
184  *****************************************************************************/
185 static int Create( vlc_object_t *p_this )
186 {
187     vout_thread_t *p_vout = (vout_thread_t *)p_this;
188     char *psz_chroma, *psz_output, *psz_verbosity;
189     int i = 0;
190
191     /* Allocate structure */
192     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
193     if( p_vout->p_sys == NULL )
194     {
195         msg_Err( p_vout, "out of memory" );
196         return VLC_ENOMEM;
197     }
198
199     /* Init structure */
200     p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
201     for (i = 0; i < VOUT_MAX_PLANES; i++)
202         p_vout->p_sys->p_cv_image[i] = NULL;
203     p_vout->p_sys->p_proc_image = NULL;
204     p_vout->p_sys->p_to_be_freed = NULL;
205     p_vout->p_sys->i_cv_image_size = 0;
206
207     p_vout->pf_init = Init;
208     p_vout->pf_end = End;
209     p_vout->pf_manage = NULL;
210     p_vout->pf_render = Render;
211     p_vout->pf_display = NULL;
212     p_vout->pf_control = Control;
213
214     /* Retrieve and apply config */
215     if( !(psz_chroma = config_GetPsz( p_vout, "opencv-chroma" )) )
216     {
217         msg_Err( p_vout, "configuration variable %s empty, using 'grey'",
218                          "opencv-chroma" );
219         p_vout->p_sys->i_internal_chroma = GREY;
220     }
221     else
222     {
223         if( !strcmp( psz_chroma, "input" ) )
224             p_vout->p_sys->i_internal_chroma = CINPUT;
225         else if( !strcmp( psz_chroma, "I420" ) )
226             p_vout->p_sys->i_internal_chroma = GREY;
227         else if( !strcmp( psz_chroma, "RGB32" ) )
228             p_vout->p_sys->i_internal_chroma = RGB;
229         else
230         {
231             msg_Err( p_vout, "no valid opencv-chroma provided, using 'grey'" );
232             p_vout->p_sys->i_internal_chroma = GREY;
233         }
234     }
235     free( psz_chroma);
236
237     if( !(psz_output = config_GetPsz( p_vout, "opencv-output" )) )
238     {
239         msg_Err( p_vout, "configuration variable %s empty, using 'input'",
240                          "opencv-output" );
241         p_vout->p_sys->i_wrapper_output = VINPUT;
242     }
243     else
244     {
245         if( !strcmp( psz_output, "none" ) )
246             p_vout->p_sys->i_wrapper_output = NONE;
247         else if( !strcmp( psz_output, "input" ) )
248             p_vout->p_sys->i_wrapper_output = VINPUT;
249         else if( !strcmp( psz_output, "processed" ) )
250             p_vout->p_sys->i_wrapper_output = PROCESSED;
251         else
252         {
253             msg_Err( p_vout, "no valid opencv-output provided, using 'input'" );
254             p_vout->p_sys->i_wrapper_output = VINPUT;
255         }
256     }
257     free( psz_output);
258
259     if( !(psz_verbosity = config_GetPsz( p_vout, "opencv-verbosity" )) )
260     {
261         msg_Err( p_vout, "configuration variable %s empty, using 'input'",
262                          "opencv-verbosity" );
263         p_vout->p_sys->i_verbosity = VERB_ERROR;
264     }
265     else
266     {
267         if( !strcmp( psz_verbosity, "error" ) )
268             p_vout->p_sys->i_verbosity = VERB_ERROR;
269         else if( !strcmp( psz_verbosity, "warning" ) )
270             p_vout->p_sys->i_verbosity = VERB_WARN;
271         else if( !strcmp( psz_verbosity, "debug" ) )
272             p_vout->p_sys->i_verbosity = VERB_DEBUG;
273         else
274         {
275             msg_Err( p_vout, "no valid opencv-verbosity provided, using 'error'" );
276             p_vout->p_sys->i_verbosity = VERB_ERROR;
277         }
278     }
279     free( psz_verbosity);
280
281     p_vout->p_sys->psz_inner_name = config_GetPsz( p_vout, "opencv-filter-name" );
282
283     p_vout->p_sys->f_scale =
284         config_GetFloat( p_vout, "opencv-scale" );
285
286     if (p_vout->p_sys->i_verbosity > VERB_WARN)
287         msg_Info(p_vout, "Configuration: opencv-scale: %f, opencv-chroma: %d, "
288             "opencv-output: %d, opencv-verbosity %d, opencv-filter %s",
289             p_vout->p_sys->f_scale,
290             p_vout->p_sys->i_internal_chroma,
291             p_vout->p_sys->i_wrapper_output,
292             p_vout->p_sys->i_verbosity,
293             p_vout->p_sys->psz_inner_name);
294
295     return VLC_SUCCESS;
296 }
297
298 /*****************************************************************************
299  * Init: initialize opencv_wrapper video thread output method
300  *****************************************************************************/
301 static int Init( vout_thread_t *p_vout )
302 {
303     int i_index;
304     picture_t *p_pic;
305     video_format_t fmt;
306     vout_sys_t *p_sys = p_vout->p_sys;
307     I_OUTPUTPICTURES = 0;
308
309     /* Initialize the output video format */
310     memset( &fmt, 0, sizeof(video_format_t) );
311     p_vout->output.i_chroma = p_vout->render.i_chroma;
312     p_vout->output.i_width  = p_vout->render.i_width;
313     p_vout->output.i_height = p_vout->render.i_height;
314     p_vout->output.i_aspect = p_vout->render.i_aspect;
315     p_vout->fmt_out = p_vout->fmt_in;           //set to input video format
316
317     fmt = p_vout->fmt_out;
318     if (p_sys->i_wrapper_output == PROCESSED)   //set to processed video format
319     {
320         fmt.i_width = fmt.i_width * p_sys->f_scale;
321         fmt.i_height = fmt.i_height * p_sys->f_scale;
322         fmt.i_visible_width = fmt.i_visible_width * p_sys->f_scale;
323         fmt.i_visible_height = fmt.i_visible_height * p_sys->f_scale;
324         fmt.i_x_offset = fmt.i_x_offset * p_sys->f_scale;
325         fmt.i_y_offset = fmt.i_y_offset * p_sys->f_scale;
326
327         if (p_sys->i_internal_chroma == GREY)
328             fmt.i_chroma = VLC_FOURCC('I','4','2','0');
329         else if (p_sys->i_internal_chroma == RGB)
330             fmt.i_chroma = VLC_FOURCC('R','V','3','2');
331     }
332
333     /* Load the internal opencv filter */
334     /* We don't need to set up video formats for this filter as it not actually using a picture_t */
335     p_sys->p_opencv = vlc_object_create( p_vout, sizeof(filter_t) );
336     vlc_object_attach( p_sys->p_opencv, p_vout );
337
338     if (p_vout->p_sys->psz_inner_name)
339         p_sys->p_opencv->p_module =
340             module_Need( p_sys->p_opencv, p_sys->psz_inner_name, 0, 0 );
341
342     if( !p_sys->p_opencv->p_module )
343     {
344         msg_Err( p_vout, "can't open internal opencv filter: %s", p_vout->p_sys->psz_inner_name );
345         p_vout->p_sys->psz_inner_name = NULL;
346         vlc_object_detach( p_sys->p_opencv );
347         vlc_object_release( p_sys->p_opencv );
348         p_sys->p_opencv = NULL;
349     }
350
351     /* Try to open the real video output */
352     if (p_sys->i_verbosity > VERB_WARN)
353         msg_Dbg( p_vout, "spawning the real video output" );
354
355     p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
356
357     /* Everything failed */
358     if( p_vout->p_sys->p_vout == NULL )
359     {
360         msg_Err( p_vout, "can't open vout, aborting" );
361         return VLC_EGENERIC;
362     }
363
364     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
365
366     ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
367
368     ADD_PARENT_CALLBACKS( SendEventsToChild );
369
370     return VLC_SUCCESS;
371 }
372
373 /*****************************************************************************
374  * End: terminate opencv_wrapper video thread output method
375  *****************************************************************************/
376 static void End( vout_thread_t *p_vout )
377 {
378     int i_index;
379
380     /* Free the fake output buffers we allocated */
381     for( i_index = I_OUTPUTPICTURES ; i_index ; )
382     {
383         i_index--;
384         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
385     }
386
387     if ( p_vout->p_sys->p_opencv )
388     {
389         //release the internal opencv filter
390         if( p_vout->p_sys->p_opencv->p_module )
391             module_Unneed( p_vout->p_sys->p_opencv, p_vout->p_sys->p_opencv->p_module );
392         vlc_object_detach( p_vout->p_sys->p_opencv );
393         vlc_object_release( p_vout->p_sys->p_opencv );
394         p_vout->p_sys->p_opencv = NULL;
395     }
396
397 }
398
399 /*****************************************************************************
400  * Destroy: destroy opencv_wrapper video thread output method
401  *****************************************************************************
402  * Terminate an output method created by opencv_wrapperCreateOutputMethod
403  *****************************************************************************/
404 static void Destroy( vlc_object_t *p_this )
405 {
406     vout_thread_t *p_vout = (vout_thread_t *)p_this;
407
408     if( p_vout->p_sys->p_vout )
409     {
410         DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
411         vlc_object_detach( p_vout->p_sys->p_vout );
412         vlc_object_release( p_vout->p_sys->p_vout );
413     }
414
415     DEL_PARENT_CALLBACKS( SendEventsToChild );
416
417     ReleaseImages(p_vout);
418
419     if( p_vout->p_sys->p_image )
420         image_HandlerDelete( p_vout->p_sys->p_image );
421
422     free( p_vout->p_sys );
423 }
424
425 /*****************************************************************************
426  * ReleaseImages: Release OpenCV images in vout_sys_t.
427  *****************************************************************************/
428 static void ReleaseImages(vout_thread_t *p_vout)
429 {
430     int i = 0;
431     if (p_vout->p_sys->p_cv_image)
432     {
433         for (i = 0; i < VOUT_MAX_PLANES; i++)
434         {
435             if (p_vout->p_sys->p_cv_image[i])
436                 cvReleaseImageHeader(&(p_vout->p_sys->p_cv_image[i]));
437             p_vout->p_sys->p_cv_image[i] = NULL;
438         }
439     }
440     p_vout->p_sys->i_cv_image_size = 0;
441
442     /* Release temp picture_t if it exists */
443     if (p_vout->p_sys->p_to_be_freed)
444     {
445         p_vout->p_sys->p_to_be_freed->pf_release( p_vout->p_sys->p_to_be_freed );
446         p_vout->p_sys->p_to_be_freed = NULL;
447     }
448     if (p_vout->p_sys->i_verbosity > VERB_WARN)
449         msg_Dbg( p_vout, "images released" );
450 }
451
452 /*****************************************************************************
453  * VlcPictureToIplImage: Convert picture_t to IplImage
454  *****************************************************************************
455  * Converts given picture_t into IplImage(s) according to module config.
456  * IplImage(s) are stored in vout_sys_t.
457  *****************************************************************************/
458 static void VlcPictureToIplImage( vout_thread_t *p_vout, picture_t *p_in )
459 {
460     int planes = p_in->i_planes;    //num input video planes
461     // input video size
462     CvSize sz = cvSize(abs(p_in->format.i_width), abs(p_in->format.i_height));
463     video_format_t fmt_out;
464     clock_t start, finish;  //performance measures
465     double  duration;
466     int i = 0;
467     vout_sys_t* p_sys = p_vout->p_sys;
468
469     memset( &fmt_out, 0, sizeof(video_format_t) );
470
471     start = clock();
472
473     //do scale / color conversion according to p_sys config
474     if ((p_sys->f_scale != 1) || (p_sys->i_internal_chroma != CINPUT))
475     {
476         fmt_out = p_in->format;
477
478         //calc the scaled video size
479         fmt_out.i_width = p_in->format.i_width * p_sys->f_scale;
480         fmt_out.i_height = p_in->format.i_height * p_sys->f_scale;
481
482         if (p_sys->i_internal_chroma == RGB)
483         {
484             //rgb2 gives 3 separate planes, this gives 1 interleaved plane
485             //rv24 gives is about 20% faster but gives r&b the wrong way round
486             //and I cant think of an easy way to fix this
487             fmt_out.i_chroma = VLC_FOURCC('R','V','3','2');
488         }
489         else if (p_sys->i_internal_chroma == GREY)
490         {
491             //take the I (gray) plane (video seems to commonly be in this fmt so usually the
492             //conversion does nothing)
493             fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
494         }
495
496         //convert from the input image
497         p_sys->p_proc_image = image_Convert( p_sys->p_image, p_in,
498                                      &(p_in->format), &fmt_out );
499
500         if (!p_sys->p_proc_image)
501         {
502             msg_Err(p_vout, "can't convert (unsupported formats?), aborting...");
503             return;
504         }
505
506         p_sys->p_to_be_freed = p_sys->p_proc_image;    //remember this so we can free it later
507
508     }
509     else    //((p_sys->f_scale != 1) || (p_sys->i_internal_chroma != CINPUT))
510     {
511         //use the input image without conversion
512         p_sys->p_proc_image = p_in;
513     }
514
515     //Convert to the IplImage array that is to be processed.
516     //If there are multiple planes in p_sys->p_proc_image, then 1 IplImage
517     //is created for each plane.
518     planes = p_sys->p_proc_image->i_planes;
519     p_sys->i_cv_image_size = planes;
520     for ( i = 0; i < planes; i++ )
521     {
522         sz = cvSize(abs(p_sys->p_proc_image->p[i].i_visible_pitch /
523             p_sys->p_proc_image->p[i].i_pixel_pitch),
524             abs(p_sys->p_proc_image->p[i].i_visible_lines));
525
526         p_sys->p_cv_image[i] = cvCreateImageHeader(sz, IPL_DEPTH_8U,
527             p_sys->p_proc_image->p[i].i_pixel_pitch);
528
529         cvSetData( p_sys->p_cv_image[i],
530             (char*)(p_sys->p_proc_image->p[i].p_pixels), p_sys->p_proc_image->p[i].i_pitch );
531     }
532
533     //Hack the above opencv image array into a picture_t so that it can be sent to
534     //another video filter
535     p_sys->hacked_pic.p_data_orig = p_sys->p_cv_image;
536     p_sys->hacked_pic.i_planes = planes;
537     p_sys->hacked_pic.format.i_chroma = fmt_out.i_chroma;
538
539     //calculate duration of conversion
540     finish = clock();
541     duration = (double)(finish - start) / CLOCKS_PER_SEC;
542     if (p_sys->i_verbosity > VERB_WARN)
543         msg_Dbg( p_vout, "VlcPictureToIplImageRgb took %2.4f seconds\n", duration );
544 }
545
546 /*****************************************************************************
547  * Render: displays previously rendered output
548  *****************************************************************************
549  * This function send the currently rendered image to the internal opencv
550  * filter for processing.
551  *****************************************************************************/
552 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
553 {
554     picture_t *p_outpic = NULL;
555     clock_t start, finish;
556     double  duration;
557
558     while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )
559               == NULL )
560     {
561         if( p_vout->b_die || p_vout->b_error )
562         {   return; }
563         msleep( VOUT_OUTMEM_SLEEP );
564     }
565
566     vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
567
568     start = clock();
569
570     if (p_vout->p_sys->i_wrapper_output == VINPUT)  //output = input video
571     {
572         //This copy is a bit unfortunate but image_Convert can't write into an existing image so it is better to copy the
573         //(say) 16bit YUV image here than a 32bit RGB image somehwere else.
574         //It is also not that expensive in time.
575         vout_CopyPicture( p_vout, p_outpic, p_pic );
576         VlcPictureToIplImage( p_vout, p_pic);
577         //pass the image to the internal opencv filter for processing
578         if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
579             p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
580     }
581     else    //output = processed video (NONE option not working yet)
582     {
583         VlcPictureToIplImage( p_vout, p_pic);
584         //pass the image to the internal opencv filter for processing
585         if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
586             p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
587         //copy the processed image into the output image
588         if ((p_vout->p_sys->p_proc_image) && (p_vout->p_sys->p_proc_image->p_data))
589             vout_CopyPicture( p_vout, p_outpic, p_vout->p_sys->p_proc_image );
590     }
591
592     //calculate duration
593     finish = clock();
594     duration = (double)(finish - start) / CLOCKS_PER_SEC;
595     if (p_vout->p_sys->i_verbosity > VERB_WARN)
596         msg_Dbg( p_vout, "Render took %2.4f seconds\n", duration );
597
598     ReleaseImages(p_vout);
599     vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
600     
601     vout_UnlinkPicture( p_vout->p_sys->p_vout, p_outpic );
602     vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
603 }
604
605 /*****************************************************************************
606  * SendEvents: forward mouse and keyboard events to the parent p_vout
607  *****************************************************************************/
608 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
609                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
610 {
611     var_Set( (vlc_object_t *)p_data, psz_var, newval );
612
613     return VLC_SUCCESS;
614 }
615
616 /*****************************************************************************
617  * SendEventsToChild: forward events to the child/children vout
618  *****************************************************************************/
619 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
620                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
621 {
622     vout_thread_t *p_vout = (vout_thread_t *)p_this;
623     var_Set( p_vout->p_sys->p_vout, psz_var, newval );
624     return VLC_SUCCESS;
625 }