]> git.sesse.net Git - vlc/blob - modules/video_filter/wall.c
Snapshot Deprecate the old names not conflicting
[vlc] / modules / video_filter / wall.c
1 /*****************************************************************************
2  * wall.c : Wall video plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000, 2001, 2002, 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_vout.h>
35 #include <assert.h>
36
37 #include "filter_common.h"
38
39 /*****************************************************************************
40  * Local prototypes
41  *****************************************************************************/
42 static int  Create    ( vlc_object_t * );
43 static void Destroy   ( vlc_object_t * );
44
45 static int  Init      ( vout_thread_t * );
46 static void End       ( vout_thread_t * );
47 static void Render    ( vout_thread_t *, picture_t * );
48
49 static void RemoveAllVout  ( vout_thread_t *p_vout );
50
51 static int  MouseEvent( vlc_object_t *, char const *,
52                         vlc_value_t, vlc_value_t, void * );
53 static int  FullscreenEventUp( vlc_object_t *, char const *,
54                                vlc_value_t, vlc_value_t, void * );
55 static int  FullscreenEventDown( vlc_object_t *, char const *,
56                                  vlc_value_t, vlc_value_t, void * );
57
58 /*****************************************************************************
59  * Module descriptor
60  *****************************************************************************/
61 #define COLS_TEXT N_("Number of columns")
62 #define COLS_LONGTEXT N_("Number of horizontal windows in " \
63     "which to split the video.")
64
65 #define ROWS_TEXT N_("Number of rows")
66 #define ROWS_LONGTEXT N_("Number of vertical windows in " \
67     "which to split the video.")
68
69 #define ACTIVE_TEXT N_("Active windows")
70 #define ACTIVE_LONGTEXT N_("Comma-separated list of active windows, " \
71     "defaults to all")
72
73 #define ASPECT_TEXT N_("Element aspect ratio")
74 #define ASPECT_LONGTEXT N_("Aspect ratio of the individual displays " \
75    "building the wall.")
76
77 #define CFG_PREFIX "wall-"
78
79 vlc_module_begin ()
80     set_description( N_("Wall video filter") )
81     set_shortname( N_("Image wall" ))
82     set_capability( "video filter", 0 )
83     set_category( CAT_VIDEO )
84     set_subcategory( SUBCAT_VIDEO_VFILTER )
85
86     add_integer( CFG_PREFIX "cols", 3, NULL, COLS_TEXT, COLS_LONGTEXT, false )
87     add_integer( CFG_PREFIX "rows", 3, NULL, ROWS_TEXT, ROWS_LONGTEXT, false )
88     add_string( CFG_PREFIX "active", NULL, NULL, ACTIVE_TEXT, ACTIVE_LONGTEXT,
89                  true )
90     add_string( CFG_PREFIX "element-aspect", "4:3", NULL, ASPECT_TEXT, ASPECT_LONGTEXT, false )
91
92     add_shortcut( "wall" )
93     set_callbacks( Create, Destroy )
94 vlc_module_end ()
95
96 static const char *const ppsz_filter_options[] = {
97     "cols", "rows", "active", "element-aspect", NULL
98 };
99
100 /*****************************************************************************
101  * vout_sys_t: Wall video output method descriptor
102  *****************************************************************************
103  * This structure is part of the video output thread descriptor.
104  * It describes the Wall specific properties of an output thread.
105  *****************************************************************************/
106 struct vout_sys_t
107 {
108     int    i_col;
109     int    i_row;
110     int    i_vout;
111     struct vout_list_t
112     {
113         bool b_active;
114         int i_width;
115         int i_height;
116         int i_left;
117         int i_top;
118         vout_thread_t *p_vout;
119     } *pp_vout;
120 };
121
122 /*****************************************************************************
123  * Control: control facility for the vout (forwards to child vout)
124  *****************************************************************************/
125 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
126 {
127     int i_row, i_col, i_vout = 0;
128
129     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
130     {
131         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
132         {
133             vout_vaControl( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
134                             i_query, args );
135             i_vout++;
136         }
137     }
138     return VLC_SUCCESS;
139 }
140
141 /*****************************************************************************
142  * Create: allocates Wall video thread output method
143  *****************************************************************************
144  * This function allocates and initializes a Wall vout method.
145  *****************************************************************************/
146 static int Create( vlc_object_t *p_this )
147 {
148     vout_thread_t *p_vout = (vout_thread_t *)p_this;
149     char *psz_method, *psz_tmp, *psz_method_tmp;
150     int i_vout;
151
152     /* Allocate structure */
153     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
154     if( p_vout->p_sys == NULL )
155         return VLC_ENOMEM;
156
157     p_vout->pf_init = Init;
158     p_vout->pf_end = End;
159     p_vout->pf_manage = NULL;
160     p_vout->pf_render = Render;
161     p_vout->pf_display = NULL;
162     p_vout->pf_control = Control;
163
164     config_ChainParse( p_vout, CFG_PREFIX, ppsz_filter_options,
165                        p_vout->p_cfg );
166
167     /* Look what method was requested */
168     p_vout->p_sys->i_col = var_CreateGetInteger( p_vout, CFG_PREFIX "cols" );
169     p_vout->p_sys->i_row = var_CreateGetInteger( p_vout, CFG_PREFIX "rows" );
170
171     p_vout->p_sys->i_col = __MAX( 1, __MIN( 15, p_vout->p_sys->i_col ) );
172     p_vout->p_sys->i_row = __MAX( 1, __MIN( 15, p_vout->p_sys->i_row ) );
173
174     msg_Dbg( p_vout, "opening a %i x %i wall",
175              p_vout->p_sys->i_col, p_vout->p_sys->i_row );
176
177     p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_row *
178                                      p_vout->p_sys->i_col *
179                                      sizeof(struct vout_list_t) );
180     if( p_vout->p_sys->pp_vout == NULL )
181     {
182         free( p_vout->p_sys );
183         return VLC_ENOMEM;
184     }
185
186     psz_method_tmp =
187     psz_method = var_CreateGetNonEmptyString( p_vout, CFG_PREFIX "active" );
188
189     /* If no trailing vout are specified, take them all */
190     if( psz_method == NULL )
191     {
192         for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
193              i_vout--; )
194         {
195             p_vout->p_sys->pp_vout[i_vout].b_active = 1;
196         }
197     }
198     /* If trailing vout are specified, activate only the requested ones */
199     else
200     {
201         for( i_vout = p_vout->p_sys->i_row * p_vout->p_sys->i_col;
202              i_vout--; )
203         {
204             p_vout->p_sys->pp_vout[i_vout].b_active = 0;
205         }
206
207         while( *psz_method )
208         {
209             psz_tmp = psz_method;
210             while( *psz_tmp && *psz_tmp != ',' )
211             {
212                 psz_tmp++;
213             }
214
215             if( *psz_tmp )
216             {
217                 *psz_tmp = '\0';
218                 i_vout = atoi( psz_method );
219                 psz_method = psz_tmp + 1;
220             }
221             else
222             {
223                 i_vout = atoi( psz_method );
224                 psz_method = psz_tmp;
225             }
226
227             if( i_vout >= 0 &&
228                 i_vout < p_vout->p_sys->i_row * p_vout->p_sys->i_col )
229             {
230                 p_vout->p_sys->pp_vout[i_vout].b_active = 1;
231             }
232         }
233     }
234
235     free( psz_method_tmp );
236
237     return VLC_SUCCESS;
238 }
239
240 /*****************************************************************************
241  * Init: initialize Wall video thread output method
242  *****************************************************************************/
243 static int Init( vout_thread_t *p_vout )
244 {
245     int i_row, i_col, i_width, i_height, i_left, i_top;
246     unsigned int i_target_width,i_target_height;
247     video_format_t fmt;
248     int i_aspect = 4*VOUT_ASPECT_FACTOR/3;
249     int i_align = 0;
250     unsigned int i_hstart, i_hend, i_vstart, i_vend;
251     unsigned int w1,h1,w2,h2;
252     int i_xpos, i_ypos;
253     int i_vstart_rounded = 0, i_hstart_rounded = 0;
254     char *psz_aspect;
255
256     memset( &fmt, 0, sizeof(video_format_t) );
257
258     psz_aspect = var_CreateGetNonEmptyString( p_vout,
259                                               CFG_PREFIX "element-aspect" );
260     if( psz_aspect && *psz_aspect )
261     {
262         char *psz_parser = strchr( psz_aspect, ':' );
263         if( psz_parser )
264         {
265             *psz_parser++ = '\0';
266             i_aspect = atoi( psz_aspect ) * VOUT_ASPECT_FACTOR
267                 / atoi( psz_parser );
268         }
269         else
270         {
271             msg_Warn( p_vout, "invalid aspect ratio specification" );
272         }
273     }
274     free( psz_aspect );
275
276     i_xpos = var_CreateGetInteger( p_vout, "video-x" );
277     i_ypos = var_CreateGetInteger( p_vout, "video-y" );
278     if( i_xpos < 0 ) i_xpos = 0;
279     if( i_ypos < 0 ) i_ypos = 0;
280
281     I_OUTPUTPICTURES = 0;
282
283     /* Initialize the output structure */
284     p_vout->output.i_chroma = p_vout->render.i_chroma;
285     p_vout->output.i_width  = p_vout->render.i_width;
286     p_vout->output.i_height = p_vout->render.i_height;
287     p_vout->output.i_aspect = p_vout->render.i_aspect;
288     var_Create( p_vout, "align", VLC_VAR_INTEGER );
289
290     fmt.i_width = fmt.i_visible_width = p_vout->render.i_width;
291     fmt.i_height = fmt.i_visible_height = p_vout->render.i_height;
292     fmt.i_x_offset = fmt.i_y_offset = 0;
293     fmt.i_chroma = p_vout->render.i_chroma;
294     fmt.i_aspect = p_vout->render.i_aspect;
295     fmt.i_sar_num = p_vout->render.i_aspect * fmt.i_height / fmt.i_width;
296     fmt.i_sar_den = VOUT_ASPECT_FACTOR;
297
298     w1 = p_vout->output.i_width / p_vout->p_sys->i_col;
299     w1 &= ~1;
300     h1 = w1 * VOUT_ASPECT_FACTOR / i_aspect&~1;
301     h1 &= ~1;
302
303     h2 = p_vout->output.i_height / p_vout->p_sys->i_row&~1;
304     h2 &= ~1;
305     w2 = h2 * i_aspect / VOUT_ASPECT_FACTOR&~1;
306     w2 &= ~1;
307
308     if ( h1 * p_vout->p_sys->i_row < p_vout->output.i_height )
309     {
310         unsigned int i_tmp;
311         i_target_width = w2;
312         i_target_height = h2;
313         i_vstart = 0;
314         i_vend = p_vout->output.i_height;
315         i_tmp = i_target_width * p_vout->p_sys->i_col;
316         while( i_tmp < p_vout->output.i_width ) i_tmp += p_vout->p_sys->i_col;
317         i_hstart = (( i_tmp - p_vout->output.i_width ) / 2)&~1;
318         i_hstart_rounded  = ( ( i_tmp - p_vout->output.i_width ) % 2 ) ||
319             ( ( ( i_tmp - p_vout->output.i_width ) / 2 ) & 1 );
320         i_hend = i_hstart + p_vout->output.i_width;
321     }
322     else
323     {
324         unsigned int i_tmp;
325         i_target_height = h1;
326         i_target_width = w1;
327         i_hstart = 0;
328         i_hend = p_vout->output.i_width;
329         i_tmp = i_target_height * p_vout->p_sys->i_row;
330         while( i_tmp < p_vout->output.i_height ) i_tmp += p_vout->p_sys->i_row;
331         i_vstart = ( ( i_tmp - p_vout->output.i_height ) / 2 ) & ~1;
332         i_vstart_rounded  = ( ( i_tmp - p_vout->output.i_height ) % 2 ) ||
333             ( ( ( i_tmp - p_vout->output.i_height ) / 2 ) & 1 );
334         i_vend = i_vstart + p_vout->output.i_height;
335     }
336     msg_Dbg( p_vout, "target resolution %dx%d", i_target_width, i_target_height );
337
338     /* Try to open the real video output */
339     msg_Dbg( p_vout, "spawning the real video outputs" );
340
341     p_vout->p_sys->i_vout = 0;
342     msg_Dbg( p_vout, "target window (%d,%d)-(%d,%d)", i_hstart,i_vstart,i_hend,i_vend );
343
344
345     i_top = 0;
346     i_height = 0;
347     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
348     {
349         i_left = 0;
350         i_top += i_height;
351         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
352         {
353             i_align = 0;
354
355             if( i_col*i_target_width >= i_hstart &&
356                 (i_col+1)*i_target_width <= i_hend )
357             {
358                 i_width = i_target_width;
359             }
360             else if( ( i_col + 1 ) * i_target_width < i_hstart ||
361                      ( i_col * i_target_width ) > i_hend )
362             {
363                 i_width = 0;
364             }
365             else
366             {
367                 i_width = ( i_target_width - i_hstart % i_target_width );
368                 if( i_col >= ( p_vout->p_sys->i_col / 2 ) )
369                 {
370                     i_align |= VOUT_ALIGN_LEFT;
371                     i_width -= i_hstart_rounded ? 2: 0;
372                 }
373                 else
374                 {
375                     i_align |= VOUT_ALIGN_RIGHT;
376                 }
377             }
378
379             if( i_row * i_target_height >= i_vstart &&
380                 ( i_row + 1 ) * i_target_height <= i_vend )
381             {
382                 i_height = i_target_height;
383             }
384             else if( ( i_row + 1 ) * i_target_height < i_vstart ||
385                      ( i_row * i_target_height ) > i_vend )
386             {
387                 i_height = 0;
388             }
389             else
390             {
391                 i_height = ( i_target_height -
392                              i_vstart%i_target_height );
393                 if(  i_row >= ( p_vout->p_sys->i_row / 2 ) )
394                 {
395                     i_align |= VOUT_ALIGN_TOP;
396                     i_height -= i_vstart_rounded ? 2: 0;
397                 }
398                 else
399                 {
400                     i_align |= VOUT_ALIGN_BOTTOM;
401                 }
402             }
403             if( i_height == 0 || i_width == 0 )
404             {
405                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active = false;
406             }
407
408             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_width = i_width;
409             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_height = i_height;
410             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_left = i_left;
411             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].i_top = i_top;
412             i_left += i_width;
413
414             if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].b_active )
415             {
416                 p_vout->p_sys->i_vout++;
417                 continue;
418             }
419             var_SetInteger( p_vout, "align", i_align );
420             var_SetInteger( p_vout, "video-x", i_left + i_xpos - i_width);
421             var_SetInteger( p_vout, "video-y", i_top + i_ypos );
422
423             fmt.i_width = fmt.i_visible_width = i_width;
424             fmt.i_height = fmt.i_visible_height = i_height;
425             fmt.i_aspect = i_aspect * i_target_height / i_height *
426                 i_width / i_target_width;
427
428             p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout =
429                 vout_Create( p_vout, &fmt );
430             if( !p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout )
431             {
432                 msg_Err( p_vout, "failed to get %ix%i vout threads",
433                                  p_vout->p_sys->i_col, p_vout->p_sys->i_row );
434                 RemoveAllVout( p_vout );
435                 return VLC_EGENERIC;
436             }
437             vout_filter_SetupChild( p_vout, p_vout->p_sys->pp_vout[p_vout->p_sys->i_vout].p_vout,
438                                     MouseEvent, FullscreenEventUp, FullscreenEventDown, true );
439             p_vout->p_sys->i_vout++;
440         }
441     }
442
443     vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
444
445     return VLC_SUCCESS;
446 }
447
448 /*****************************************************************************
449  * End: terminate Wall video thread output method
450  *****************************************************************************/
451 static void End( vout_thread_t *p_vout )
452 {
453     RemoveAllVout( p_vout );
454
455     vout_filter_ReleaseDirectBuffers( p_vout );
456 }
457
458 /*****************************************************************************
459  * Destroy: destroy Wall video thread output method
460  *****************************************************************************
461  * Terminate an output method created by WallCreateOutputMethod
462  *****************************************************************************/
463 static void Destroy( vlc_object_t *p_this )
464 {
465     vout_thread_t *p_vout = (vout_thread_t *)p_this;
466
467
468     free( p_vout->p_sys->pp_vout );
469     free( p_vout->p_sys );
470 }
471
472 /*****************************************************************************
473  * Render: displays previously rendered output
474  *****************************************************************************
475  * This function send the currently rendered image to Wall image, waits
476  * until it is displayed and switch the two rendering buffers, preparing next
477  * frame.
478  *****************************************************************************/
479 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
480 {
481     picture_t *p_outpic = NULL;
482     int i_col, i_row, i_vout, i_plane;
483     int pi_left_skip[VOUT_MAX_PLANES], pi_top_skip[VOUT_MAX_PLANES];
484
485     i_vout = 0;
486
487     for( i_row = 0; i_row < p_vout->p_sys->i_row; i_row++ )
488     {
489         for( i_col = 0; i_col < p_vout->p_sys->i_col; i_col++ )
490         {
491             for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
492             {
493                 pi_left_skip[i_plane] = p_vout->p_sys->pp_vout[ i_vout ].i_left * p_pic->p[ i_plane ].i_pitch / p_vout->output.i_width;
494                 pi_top_skip[i_plane] = (p_vout->p_sys->pp_vout[ i_vout ].i_top * p_pic->p[ i_plane ].i_lines / p_vout->output.i_height)*p_pic->p[i_plane].i_pitch;
495             }
496
497             if( !p_vout->p_sys->pp_vout[ i_vout ].b_active )
498             {
499                 i_vout++;
500                 continue;
501             }
502
503             while( ( p_outpic =
504                 vout_CreatePicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
505                                     0, 0, 0 )
506                    ) == NULL )
507             {
508                 if( !vlc_object_alive (p_vout) || p_vout->b_error )
509                 {
510                     vout_DestroyPicture(
511                         p_vout->p_sys->pp_vout[ i_vout ].p_vout, p_outpic );
512                     return;
513                 }
514
515                 msleep( VOUT_OUTMEM_SLEEP );
516             }
517             p_outpic->date = p_pic->date;
518
519             vout_LinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
520                               p_outpic );
521
522             for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
523             {
524                 uint8_t *p_in, *p_in_end, *p_out;
525                 int i_in_pitch = p_pic->p[i_plane].i_pitch;
526                 int i_out_pitch = p_outpic->p[i_plane].i_pitch;
527                 int i_copy_pitch = p_outpic->p[i_plane].i_visible_pitch;
528
529                 p_in = p_pic->p[i_plane].p_pixels
530                         + pi_top_skip[i_plane] + pi_left_skip[i_plane];
531
532                 p_in_end = p_in + p_outpic->p[i_plane].i_visible_lines
533                                    * p_pic->p[i_plane].i_pitch;
534
535                 p_out = p_outpic->p[i_plane].p_pixels;
536
537                 while( p_in < p_in_end )
538                 {
539                     vlc_memcpy( p_out, p_in, i_copy_pitch );
540                     p_in += i_in_pitch;
541                     p_out += i_out_pitch;
542                 }
543
544 //                pi_left_skip[i_plane] += i_copy_pitch;
545             }
546
547             vout_UnlinkPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
548                                 p_outpic );
549             vout_DisplayPicture( p_vout->p_sys->pp_vout[ i_vout ].p_vout,
550                                  p_outpic );
551
552             i_vout++;
553         }
554
555 /*         for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ ) */
556 /*         { */
557 /*             pi_top_skip[i_plane] += p_vout->p_sys->pp_vout[ i_vout ].i_height */
558 /*                                      * p_pic->p[i_plane].i_visible_lines */
559 /*                                      / p_vout->output.i_height */
560 /*                                      * p_pic->p[i_plane].i_pitch; */
561 /*         } */
562     }
563 }
564
565 /*****************************************************************************
566  * RemoveAllVout: destroy all the child video output threads
567  *****************************************************************************/
568 static void RemoveAllVout( vout_thread_t *p_vout )
569 {
570     vout_sys_t *p_sys = p_vout->p_sys;
571
572     while( p_sys->i_vout )
573     {
574         p_sys->i_vout--;
575         if( p_sys->pp_vout[p_sys->i_vout ].b_active )
576         {
577             vout_filter_SetupChild( p_vout, p_sys->pp_vout[p_sys->i_vout].p_vout,
578                                     MouseEvent, FullscreenEventUp, FullscreenEventDown, false );
579             vout_CloseAndRelease( p_sys->pp_vout[p_sys->i_vout].p_vout );
580         }
581     }
582 }
583
584 /**
585  * Forward mouse event with proper conversion.
586  */
587 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
588                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
589 {
590     vout_thread_t *p_vout = p_data;
591     vout_sys_t *p_sys = p_vout->p_sys;
592     VLC_UNUSED(oldval);
593     int i_vout;
594
595     /* Find the video output index */
596     for( i_vout = 0; i_vout < p_sys->i_vout; i_vout++ )
597     {
598         if( p_sys->pp_vout[i_vout].b_active &&
599             p_this == VLC_OBJECT(p_sys->pp_vout[i_vout].p_vout) )
600             break;
601     }
602     assert( i_vout < p_vout->p_sys->i_vout );
603
604     /* Translate the mouse coordinates */
605     if( !strcmp( psz_var, "mouse-x" ) )
606         newval.i_int += p_vout->output.i_width * (i_vout % p_sys->i_col) / p_sys->i_col;
607     else if( !strcmp( psz_var, "mouse-y" ) )
608         newval.i_int += p_vout->output.i_height * (i_vout / p_sys->i_row) / p_sys->i_row;
609
610     return var_Set( p_vout, psz_var, newval );
611 }
612
613 /**
614  * Forward fullscreen event to/from the childrens.
615  */
616 static bool IsFullscreenActive( vout_thread_t *p_vout )
617 {
618     vout_sys_t *p_sys = p_vout->p_sys;
619     for( int i = 0; i < p_sys->i_vout; i++ )
620     {
621         if( p_sys->pp_vout[i].b_active &&
622             var_GetBool( p_sys->pp_vout[i].p_vout, "fullscreen" ) )
623             return true;
624     }
625     return false;
626 }
627 static int FullscreenEventUp( vlc_object_t *p_this, char const *psz_var,
628                               vlc_value_t oldval, vlc_value_t newval, void *p_data )
629 {
630     vout_thread_t *p_vout = p_data;
631     VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(newval);
632
633     const bool b_fullscreen = IsFullscreenActive( p_vout );
634     if( !var_GetBool( p_vout, "fullscreen" ) != !b_fullscreen )
635         return var_SetBool( p_vout, "fullscreen", b_fullscreen );
636     return VLC_SUCCESS;
637 }
638 static int FullscreenEventDown( vlc_object_t *p_this, char const *psz_var,
639                                 vlc_value_t oldval, vlc_value_t newval, void *p_data )
640 {
641     vout_thread_t *p_vout = (vout_thread_t*)p_this;
642     vout_sys_t *p_sys = p_vout->p_sys;
643     VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_var);
644
645     const bool b_fullscreen = IsFullscreenActive( p_vout );
646     if( !b_fullscreen != !newval.b_bool )
647     {
648         for( int i = 0; i < p_sys->i_vout; i++ )
649         {
650             if( !p_sys->pp_vout[i].b_active )
651                 continue;
652
653             vout_thread_t *p_child = p_sys->pp_vout[i].p_vout;
654             if( !var_GetBool( p_child, "fullscreen" ) != !newval.b_bool )
655             {
656                 var_SetBool( p_child, "fullscreen", newval.b_bool );
657                 if( newval.b_bool )
658                     return VLC_SUCCESS;
659             }
660         }
661     }
662     return VLC_SUCCESS;
663 }
664