1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004-2005 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea@videolan.org>
8 * Christophe Massiot <massiot@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <errno.h> /* ENOMEM */
29 #include <stdlib.h> /* free() */
30 #include <string.h> /* strerror() */
34 #include <vlc_block.h>
35 #include <vlc_codec.h>
37 #include "vlc_image.h"
39 #include "../video_filter/mosaic.h"
41 /*****************************************************************************
43 *****************************************************************************/
44 struct sout_stream_sys_t
50 image_handler_t *p_image; /* filter for resizing */
51 int i_height, i_width;
52 unsigned int i_sar_num, i_sar_den;
57 vlc_mutex_t mask_lock;
60 #define PICTURE_RING_SIZE 4
61 struct decoder_owner_sys_t
63 picture_t *pp_pics[PICTURE_RING_SIZE];
65 /* Current format in use by the output */
69 typedef void (* pf_release_t)( picture_t * );
70 static void ReleasePicture( picture_t *p_pic )
74 if ( p_pic->i_refcount <= 0 )
76 if ( p_pic->p_sys != NULL )
78 pf_release_t pf_release = (pf_release_t)p_pic->p_sys;
84 if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig );
85 if( p_pic ) free( p_pic );
90 /* copied from video_filters/erase.c . Gruik ? */
91 static void LoadMask( sout_stream_t *p_stream, const char *psz_filename )
93 image_handler_t *p_image;
94 video_format_t fmt_in, fmt_out;
95 memset( &fmt_in, 0, sizeof( video_format_t ) );
96 memset( &fmt_out, 0, sizeof( video_format_t ) );
97 fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
98 if( p_stream->p_sys->p_mask )
99 p_stream->p_sys->p_mask->pf_release( p_stream->p_sys->p_mask );
100 p_image = image_HandlerCreate( p_stream );
101 p_stream->p_sys->p_mask =
102 image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
103 image_HandlerDelete( p_image );
106 /*****************************************************************************
108 *****************************************************************************/
109 static int Open ( vlc_object_t * );
110 static void Close ( vlc_object_t * );
111 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
112 static int Del ( sout_stream_t *, sout_stream_id_t * );
113 static int Send( sout_stream_t *, sout_stream_id_t *, block_t * );
115 static void video_del_buffer( decoder_t *, picture_t * );
116 static picture_t *video_new_buffer( decoder_t * );
117 static void video_link_picture_decoder( decoder_t *, picture_t * );
118 static void video_unlink_picture_decoder( decoder_t *, picture_t * );
119 static int MosaicBridgeCallback( vlc_object_t *, char const *,
120 vlc_value_t, vlc_value_t, void * );
122 /*****************************************************************************
124 *****************************************************************************/
125 #define ID_TEXT N_("ID")
126 #define ID_LONGTEXT N_( \
127 "Specify an identifier string for this subpicture" )
129 #define WIDTH_TEXT N_("Video width")
130 #define WIDTH_LONGTEXT N_( \
131 "Output video width." )
132 #define HEIGHT_TEXT N_("Video height")
133 #define HEIGHT_LONGTEXT N_( \
134 "Output video height." )
135 #define RATIO_TEXT N_("Sample aspect ratio")
136 #define RATIO_LONGTEXT N_( \
137 "Sample aspect ratio of the destination (1:1, 3:4, 2:3)." )
138 #define MASK_TEXT N_("Transparency mask")
139 #define MASK_LONGTEXT N_( \
140 "Alpha blending transparency mask. Use's a png alpha channel.")
142 #define SOUT_CFG_PREFIX "sout-mosaic-bridge-"
145 set_shortname( _( "Mosaic bridge" ) );
146 set_description(_("Mosaic bridge stream output") );
147 set_capability( "sout stream", 0 );
148 add_shortcut( "mosaic-bridge" );
150 add_string( SOUT_CFG_PREFIX "id", "Id", NULL, ID_TEXT, ID_LONGTEXT,
152 add_integer( SOUT_CFG_PREFIX "width", 0, NULL, WIDTH_TEXT,
153 WIDTH_LONGTEXT, VLC_TRUE );
154 add_integer( SOUT_CFG_PREFIX "height", 0, NULL, HEIGHT_TEXT,
155 HEIGHT_LONGTEXT, VLC_TRUE );
156 add_string( SOUT_CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT,
157 RATIO_LONGTEXT, VLC_FALSE );
158 add_string( SOUT_CFG_PREFIX "mask", NULL, NULL, MASK_TEXT,
159 MASK_LONGTEXT, VLC_FALSE );
161 set_callbacks( Open, Close );
163 var_Create( p_module->p_libvlc_global, "mosaic-lock", VLC_VAR_MUTEX );
166 static const char *ppsz_sout_options[] = {
167 "id", "width", "height", "sar", "mask", NULL
170 /*****************************************************************************
172 *****************************************************************************/
173 static int Open( vlc_object_t *p_this )
175 sout_stream_t *p_stream = (sout_stream_t *)p_this;
176 sout_stream_sys_t *p_sys;
177 libvlc_global_data_t *p_libvlc_global = p_this->p_libvlc_global;
180 config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options,
183 p_sys = malloc( sizeof( sout_stream_sys_t ) );
184 p_stream->p_sys = p_sys;
185 p_sys->b_inited = VLC_FALSE;
187 var_Get( p_libvlc_global, "mosaic-lock", &val );
188 p_sys->p_lock = val.p_address;
190 var_Get( p_stream, SOUT_CFG_PREFIX "id", &val );
191 p_sys->psz_id = val.psz_string;
193 var_Get( p_stream, SOUT_CFG_PREFIX "height", &val );
194 p_sys->i_height = val.i_int;
196 var_Get( p_stream, SOUT_CFG_PREFIX "width", &val );
197 p_sys->i_width = val.i_int;
199 vlc_mutex_init( p_stream, &p_sys->mask_lock );
201 var_CreateGetStringCommand( p_stream, SOUT_CFG_PREFIX "mask" );
202 var_AddCallback( p_stream, SOUT_CFG_PREFIX "mask", MosaicBridgeCallback,
204 if( val.psz_string && *val.psz_string )
206 p_sys->p_mask = NULL;
207 LoadMask( p_stream, val.psz_string );
209 msg_Err( p_stream, "Error while loading mask (%s).",
213 p_sys->p_mask = NULL;
214 free( val.psz_string );
216 var_Get( p_stream, SOUT_CFG_PREFIX "sar", &val );
217 if ( val.psz_string )
219 char *psz_parser = strchr( val.psz_string, ':' );
223 *psz_parser++ = '\0';
224 p_sys->i_sar_num = atoi( val.psz_string );
225 p_sys->i_sar_den = atoi( psz_parser );
226 vlc_ureduce( &p_sys->i_sar_num, &p_sys->i_sar_den,
227 p_sys->i_sar_num, p_sys->i_sar_den, 0 );
231 msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
232 p_sys->i_sar_num = p_sys->i_sar_den = 1;
235 free( val.psz_string );
239 p_sys->i_sar_num = p_sys->i_sar_den = 1;
242 p_stream->pf_add = Add;
243 p_stream->pf_del = Del;
244 p_stream->pf_send = Send;
246 p_stream->p_sout->i_out_pace_nocontrol++;
251 /*****************************************************************************
253 *****************************************************************************/
254 static void Close( vlc_object_t * p_this )
256 sout_stream_t *p_stream = (sout_stream_t*)p_this;
257 sout_stream_sys_t *p_sys = p_stream->p_sys;
259 p_stream->p_sout->i_out_pace_nocontrol--;
262 free( p_sys->psz_id );
264 vlc_mutex_destroy( &p_sys->mask_lock );
265 if( p_stream->p_sys->p_mask )
266 p_stream->p_sys->p_mask->pf_release( p_stream->p_sys->p_mask );
271 static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
273 sout_stream_sys_t *p_sys = p_stream->p_sys;
278 if ( p_sys->b_inited )
283 /* Create decoder object */
284 p_sys->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER );
285 vlc_object_attach( p_sys->p_decoder, p_stream );
286 p_sys->p_decoder->p_module = NULL;
287 p_sys->p_decoder->fmt_in = *p_fmt;
288 p_sys->p_decoder->b_pace_control = VLC_FALSE;
289 p_sys->p_decoder->fmt_out = p_sys->p_decoder->fmt_in;
290 p_sys->p_decoder->fmt_out.i_extra = 0;
291 p_sys->p_decoder->fmt_out.p_extra = 0;
292 p_sys->p_decoder->pf_decode_video = 0;
293 p_sys->p_decoder->pf_vout_buffer_new = video_new_buffer;
294 p_sys->p_decoder->pf_vout_buffer_del = video_del_buffer;
295 p_sys->p_decoder->pf_picture_link = video_link_picture_decoder;
296 p_sys->p_decoder->pf_picture_unlink = video_unlink_picture_decoder;
297 p_sys->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) );
298 for( i = 0; i < PICTURE_RING_SIZE; i++ )
299 p_sys->p_decoder->p_owner->pp_pics[i] = 0;
300 p_sys->p_decoder->p_owner->video = p_fmt->video;
301 //p_sys->p_decoder->p_cfg = p_sys->p_video_cfg;
303 p_sys->p_decoder->p_module =
304 module_Need( p_sys->p_decoder, "decoder", "$codec", 0 );
306 if( !p_sys->p_decoder->p_module )
308 msg_Err( p_stream, "cannot find decoder" );
309 vlc_object_detach( p_sys->p_decoder );
310 vlc_object_destroy( p_sys->p_decoder );
314 p_sys->b_inited = VLC_TRUE;
315 vlc_mutex_lock( p_sys->p_lock );
317 p_bridge = GetBridge( p_stream );
318 if ( p_bridge == NULL )
320 libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global;
323 p_bridge = malloc( sizeof( bridge_t ) );
325 var_Create( p_libvlc_global, "mosaic-struct", VLC_VAR_ADDRESS );
326 val.p_address = p_bridge;
327 var_Set( p_libvlc_global, "mosaic-struct", val );
329 p_bridge->i_es_num = 0;
330 p_bridge->pp_es = NULL;
333 for ( i = 0; i < p_bridge->i_es_num; i++ )
335 if ( p_bridge->pp_es[i]->b_empty )
339 if ( i == p_bridge->i_es_num )
341 p_bridge->pp_es = realloc( p_bridge->pp_es,
342 (p_bridge->i_es_num + 1)
343 * sizeof(bridged_es_t *) );
344 p_bridge->i_es_num++;
345 p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) );
348 p_sys->p_es = p_es = p_bridge->pp_es[i];
350 //p_es->fmt = *p_fmt;
351 p_es->psz_id = p_sys->psz_id;
352 p_es->p_picture = NULL;
353 p_es->pp_last = &p_es->p_picture;
354 p_es->b_empty = VLC_FALSE;
356 vlc_mutex_unlock( p_sys->p_lock );
358 if ( p_sys->i_height || p_sys->i_width )
360 p_sys->p_image = image_HandlerCreate( p_stream );
363 msg_Dbg( p_stream, "mosaic bridge id=%s pos=%d", p_es->psz_id, i );
365 return (sout_stream_id_t *)p_sys;
368 static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
370 sout_stream_sys_t *p_sys = p_stream->p_sys;
373 vlc_bool_t b_last_es = VLC_TRUE;
376 if ( !p_sys->b_inited )
381 if ( p_sys->p_decoder != NULL )
383 picture_t **pp_ring = p_sys->p_decoder->p_owner->pp_pics;
385 if( p_sys->p_decoder->p_module )
386 module_Unneed( p_sys->p_decoder, p_sys->p_decoder->p_module );
387 vlc_object_detach( p_sys->p_decoder );
388 vlc_object_destroy( p_sys->p_decoder );
390 for( i = 0; i < PICTURE_RING_SIZE; i++ )
392 if ( pp_ring[i] != NULL )
394 if ( pp_ring[i]->p_data_orig != NULL )
395 free( pp_ring[i]->p_data_orig );
396 free( pp_ring[i]->p_sys );
402 vlc_mutex_lock( p_sys->p_lock );
404 p_bridge = GetBridge( p_stream );
407 p_es->b_empty = VLC_TRUE;
408 while ( p_es->p_picture )
410 picture_t *p_next = p_es->p_picture->p_next;
411 p_es->p_picture->pf_release( p_es->p_picture );
412 p_es->p_picture = p_next;
415 for ( i = 0; i < p_bridge->i_es_num; i++ )
417 if ( !p_bridge->pp_es[i]->b_empty )
419 b_last_es = VLC_FALSE;
426 libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global;
427 for ( i = 0; i < p_bridge->i_es_num; i++ )
428 free( p_bridge->pp_es[i] );
429 free( p_bridge->pp_es );
431 var_Destroy( p_libvlc_global, "mosaic-struct" );
434 vlc_mutex_unlock( p_sys->p_lock );
436 if ( p_sys->i_height || p_sys->i_width )
438 image_HandlerDelete( p_sys->p_image );
441 p_sys->b_inited = VLC_FALSE;
446 /*****************************************************************************
447 * PushPicture : push a picture in the mosaic-struct structure
448 *****************************************************************************/
449 static void PushPicture( sout_stream_t *p_stream, picture_t *p_picture )
451 sout_stream_sys_t *p_sys = p_stream->p_sys;
452 bridged_es_t *p_es = p_sys->p_es;
454 vlc_mutex_lock( p_sys->p_lock );
456 *p_es->pp_last = p_picture;
457 p_picture->p_next = NULL;
458 p_es->pp_last = &p_picture->p_next;
460 vlc_mutex_unlock( p_sys->p_lock );
463 static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
466 sout_stream_sys_t *p_sys = p_stream->p_sys;
469 if ( (sout_stream_sys_t *)id != p_sys )
471 block_ChainRelease( p_buffer );
475 while ( (p_pic = p_sys->p_decoder->pf_decode_video( p_sys->p_decoder,
478 picture_t *p_new_pic;
480 if( p_sys->i_height || p_sys->i_width )
482 video_format_t fmt_out, fmt_in;
484 memset( &fmt_in, 0, sizeof(video_format_t) );
485 memset( &fmt_out, 0, sizeof(video_format_t) );
486 fmt_in = p_sys->p_decoder->fmt_out.video;
490 vlc_mutex_lock( &p_sys->mask_lock );
491 fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
494 fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
496 if ( !p_sys->i_height )
498 fmt_out.i_width = p_sys->i_width;
499 fmt_out.i_height = (p_sys->i_width * VOUT_ASPECT_FACTOR
500 * p_sys->i_sar_num / p_sys->i_sar_den / fmt_in.i_aspect)
503 else if ( !p_sys->i_width )
505 fmt_out.i_height = p_sys->i_height;
506 fmt_out.i_width = (p_sys->i_height * fmt_in.i_aspect
507 * p_sys->i_sar_den / p_sys->i_sar_num / VOUT_ASPECT_FACTOR)
512 fmt_out.i_width = p_sys->i_width;
513 fmt_out.i_height = p_sys->i_height;
515 fmt_out.i_visible_width = fmt_out.i_width;
516 fmt_out.i_visible_height = fmt_out.i_height;
518 p_new_pic = image_Convert( p_sys->p_image,
519 p_pic, &fmt_in, &fmt_out );
520 if ( p_new_pic == NULL )
522 msg_Err( p_stream, "image conversion failed" );
528 plane_t *p_mask = p_sys->p_mask->p+A_PLANE;
529 plane_t *p_apic = p_new_pic->p+A_PLANE;
530 if( p_mask->i_visible_pitch
531 != p_apic->i_visible_pitch
532 || p_mask->i_visible_lines
533 != p_apic->i_visible_lines )
536 "Mask size (%d x %d) and image size (%d x %d) "
537 "don't match. The mask will not be applied.",
538 p_mask->i_visible_pitch,
539 p_mask->i_visible_lines,
540 p_apic->i_visible_pitch,
541 p_apic->i_visible_lines );
545 if( p_mask->i_pitch != p_apic->i_pitch
546 || p_mask->i_lines != p_apic->i_lines )
548 /* visible plane sizes match ... but not the undelying
549 * buffer. I'm not sure that this can happen,
550 * but better safe than sorry. */
552 int i_lines = p_mask->i_visible_lines;
553 uint8_t *p_src = p_mask->p_pixels;
554 uint8_t *p_dst = p_apic->p_pixels;
555 int i_src_pitch = p_mask->i_pitch;
556 int i_dst_pitch = p_apic->i_pitch;
557 int i_visible_pitch = p_mask->i_visible_pitch;
558 for( i_line = 0; i_line < i_lines; i_line++,
559 p_src += i_src_pitch, p_dst += i_dst_pitch )
561 p_stream->p_libvlc->pf_memcpy(
562 p_dst, p_src, i_visible_pitch );
567 /* plane sizes match */
568 p_stream->p_libvlc->pf_memcpy(
569 p_apic->p_pixels, p_mask->p_pixels,
570 p_mask->i_pitch * p_mask->i_lines );
573 vlc_mutex_unlock( &p_sys->mask_lock );
578 p_new_pic = (picture_t*)malloc( sizeof(picture_t) );
579 vout_AllocatePicture( p_stream, p_new_pic, p_pic->format.i_chroma,
580 p_pic->format.i_width, p_pic->format.i_height,
581 p_sys->p_decoder->fmt_out.video.i_aspect );
583 vout_CopyPicture( p_stream, p_new_pic, p_pic );
586 p_new_pic->i_refcount = 1;
587 p_new_pic->i_status = DESTROYED_PICTURE;
588 p_new_pic->i_type = DIRECT_PICTURE;
589 p_new_pic->p_sys = (picture_sys_t *)p_new_pic->pf_release;
590 p_new_pic->pf_release = ReleasePicture;
591 p_new_pic->date = p_pic->date;
593 p_pic->pf_release( p_pic );
594 PushPicture( p_stream, p_new_pic );
602 vlc_object_t *p_owner;
606 static void video_release_buffer( picture_t *p_pic )
608 if( p_pic && !p_pic->i_refcount && p_pic->pf_release && p_pic->p_sys )
610 video_del_buffer( (decoder_t *)p_pic->p_sys->p_owner, p_pic );
612 else if( p_pic && p_pic->i_refcount > 0 ) p_pic->i_refcount--;
615 static picture_t *video_new_buffer( decoder_t *p_dec )
617 decoder_owner_sys_t *p_sys = (decoder_owner_sys_t *)p_dec->p_owner;
618 picture_t **pp_ring = p_dec->p_owner->pp_pics;
622 if( p_dec->fmt_out.video.i_width != p_sys->video.i_width ||
623 p_dec->fmt_out.video.i_height != p_sys->video.i_height ||
624 p_dec->fmt_out.video.i_chroma != p_sys->video.i_chroma ||
625 p_dec->fmt_out.video.i_aspect != p_sys->video.i_aspect )
627 if( !p_dec->fmt_out.video.i_sar_num ||
628 !p_dec->fmt_out.video.i_sar_den )
630 p_dec->fmt_out.video.i_sar_num =
631 p_dec->fmt_out.video.i_aspect * p_dec->fmt_out.video.i_height;
633 p_dec->fmt_out.video.i_sar_den = VOUT_ASPECT_FACTOR *
634 p_dec->fmt_out.video.i_width;
637 vlc_ureduce( &p_dec->fmt_out.video.i_sar_num,
638 &p_dec->fmt_out.video.i_sar_den,
639 p_dec->fmt_out.video.i_sar_num,
640 p_dec->fmt_out.video.i_sar_den, 0 );
642 if( !p_dec->fmt_out.video.i_visible_width ||
643 !p_dec->fmt_out.video.i_visible_height )
645 p_dec->fmt_out.video.i_visible_width =
646 p_dec->fmt_out.video.i_width;
647 p_dec->fmt_out.video.i_visible_height =
648 p_dec->fmt_out.video.i_height;
651 p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
652 p_sys->video = p_dec->fmt_out.video;
654 for( i = 0; i < PICTURE_RING_SIZE; i++ )
656 if ( pp_ring[i] != NULL )
658 if ( pp_ring[i]->i_status == DESTROYED_PICTURE )
660 if ( pp_ring[i]->p_data_orig != NULL )
661 free( pp_ring[i]->p_data_orig );
662 free( pp_ring[i]->p_sys );
667 pp_ring[i]->p_sys->b_dead = VLC_TRUE;
674 /* Find an empty space in the picture ring buffer */
675 for( i = 0; i < PICTURE_RING_SIZE; i++ )
677 if( pp_ring[i] != NULL && pp_ring[i]->i_status == DESTROYED_PICTURE )
679 pp_ring[i]->i_status = RESERVED_PICTURE;
683 for( i = 0; i < PICTURE_RING_SIZE; i++ )
685 if( pp_ring[i] == NULL ) break;
688 if( i == PICTURE_RING_SIZE )
690 msg_Err( p_dec, "decoder/filter is leaking pictures, "
691 "resetting its ring buffer" );
693 for( i = 0; i < PICTURE_RING_SIZE; i++ )
695 pp_ring[i]->pf_release( pp_ring[i] );
701 p_pic = malloc( sizeof(picture_t) );
702 p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
703 vout_AllocatePicture( VLC_OBJECT(p_dec), p_pic,
704 p_dec->fmt_out.video.i_chroma,
705 p_dec->fmt_out.video.i_width,
706 p_dec->fmt_out.video.i_height,
707 p_dec->fmt_out.video.i_aspect );
709 if( !p_pic->i_planes )
715 p_pic->pf_release = video_release_buffer;
716 p_pic->p_sys = malloc( sizeof(picture_sys_t) );
717 p_pic->p_sys->p_owner = VLC_OBJECT(p_dec);
718 p_pic->p_sys->b_dead = VLC_FALSE;
719 p_pic->i_status = RESERVED_PICTURE;
726 static void video_del_buffer( decoder_t *p_this, picture_t *p_pic )
728 p_pic->i_refcount = 0;
729 p_pic->i_status = DESTROYED_PICTURE;
730 if ( p_pic->p_sys->b_dead )
732 if ( p_pic->p_data_orig != NULL )
733 free( p_pic->p_data_orig );
734 free( p_pic->p_sys );
739 static void video_link_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
744 static void video_unlink_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
746 video_release_buffer( p_pic );
750 /**********************************************************************
751 * Callback to update (some) params on the fly
752 **********************************************************************/
753 static int MosaicBridgeCallback( vlc_object_t *p_this, char const *psz_var,
754 vlc_value_t oldval, vlc_value_t newval,
757 sout_stream_t *p_stream = (sout_stream_t *)p_data;
758 sout_stream_sys_t *p_sys = p_stream->p_sys;
760 if( !strcmp( psz_var, SOUT_CFG_PREFIX "mask" ) )
762 vlc_mutex_lock( &p_sys->mask_lock );
763 if( newval.psz_string && *newval.psz_string )
765 LoadMask( p_stream, newval.psz_string );
767 msg_Err( p_stream, "Error while loading mask (%s).",
770 else if( p_sys->p_mask )
772 p_sys->p_mask->pf_release( p_sys->p_mask );
773 p_sys->p_mask = NULL;
775 vlc_mutex_unlock( &p_sys->mask_lock );