add_integer: remove callback parameter
[vlc/asuraparaju-public.git] / modules / stream_out / bridge.c
blobe87e829e7543cd28cdc0836485cde0b21bc17de0
1 /*****************************************************************************
2 * bridge.c: bridge stream output module
3 *****************************************************************************
4 * Copyright (C) 2005-2008 the VideoLAN team
5 * $Id$
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Antoine Cellerier <dionoea at videolan dot org>
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 /*****************************************************************************
26 * Preamble
27 *****************************************************************************/
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
35 #include <vlc_sout.h>
36 #include <vlc_block.h>
38 /*****************************************************************************
39 * Module descriptor
40 *****************************************************************************/
41 #define ID_TEXT N_("ID")
42 #define ID_LONGTEXT N_( \
43 "Integer identifier for this elementary stream. This will be used to " \
44 "\"find\" this stream later." )
46 #define DEST_TEXT N_( "Destination bridge-in name" )
47 #define DEST_LONGTEXT N_( \
48 "Name of the destination bridge-in. If you do not need more " \
49 "than one bridge-in at a time, you can discard this option." )
51 #define DELAY_TEXT N_("Delay")
52 #define DELAY_LONGTEXT N_("Pictures coming from the picture video outputs " \
53 "will be delayed according to this value (in milliseconds, should be "\
54 ">= 100 ms). For high values, you will need to raise caching values." )
56 #define ID_OFFSET_TEXT N_("ID Offset")
57 #define ID_OFFSET_LONGTEXT N_("Offset to add to the stream IDs specified in " \
58 "bridge_out to obtain the stream IDs bridge_in will register.")
60 #define NAME_TEXT N_( "Name of current instance" )
61 #define NAME_LONGTEXT N_( \
62 "Name of this bridge-in instance. If you do not need more " \
63 "than one bridge-in at a time, you can discard this option." )
65 #define PLACEHOLDER_TEXT N_( "Fallback to placeholder stream when out of data" )
66 #define PLACEHOLDER_LONGTEXT N_( \
67 "If set to true, the bridge will discard all input elementary streams " \
68 "except if it doesn't receive data from another bridge-in. This can " \
69 "be used to configure a place holder stream when the real source " \
70 "breaks. Source and placeholder streams should have the same format. " )
72 #define PLACEHOLDER_DELAY_TEXT N_( "Placeholder delay" )
73 #define PLACEHOLDER_DELAY_LONGTEXT N_( \
74 "Delay (in ms) before the placeholder kicks in." )
76 #define PLACEHOLDER_IFRAME_TEXT N_( "Wait for I frame before toggling placholder" )
77 #define PLACEHOLDER_IFRAME_LONGTEXT N_( \
78 "If enabled, switching between the placeholder and the normal stream " \
79 "will only occur on I frames. This will remove artifacts on stream " \
80 "switching at the expense of a slightly longer delay, depending on " \
81 "the frequence of I frames in the streams." )
83 static int OpenOut ( vlc_object_t * );
84 static void CloseOut( vlc_object_t * );
85 static int OpenIn ( vlc_object_t * );
86 static void CloseIn ( vlc_object_t * );
88 #define SOUT_CFG_PREFIX_OUT "sout-bridge-out-"
89 #define SOUT_CFG_PREFIX_IN "sout-bridge-in-"
91 vlc_module_begin ()
92 set_shortname( N_("Bridge"))
93 set_description( N_("Bridge stream output"))
94 add_submodule ()
95 set_section( N_("Bridge out"), NULL )
96 set_capability( "sout stream", 50 )
97 add_shortcut( "bridge-out" )
98 /* Only usable with VLM. No category so not in gui preferences
99 set_category( CAT_SOUT )
100 set_subcategory( SUBCAT_SOUT_STREAM )*/
101 add_integer( SOUT_CFG_PREFIX_OUT "id", 0, ID_TEXT, ID_LONGTEXT,
102 false )
103 add_string( SOUT_CFG_PREFIX_OUT "in-name", "default",
104 DEST_TEXT, DEST_LONGTEXT, false )
105 set_callbacks( OpenOut, CloseOut )
107 add_submodule ()
108 set_section( N_("Bridge in"), NULL )
109 set_capability( "sout stream", 50 )
110 add_shortcut( "bridge-in" )
111 /*set_category( CAT_SOUT )
112 set_subcategory( SUBCAT_SOUT_STREAM )*/
113 add_integer( SOUT_CFG_PREFIX_IN "delay", 0, DELAY_TEXT,
114 DELAY_LONGTEXT, false )
115 add_integer( SOUT_CFG_PREFIX_IN "id-offset", 8192, ID_OFFSET_TEXT,
116 ID_OFFSET_LONGTEXT, false )
117 add_string( SOUT_CFG_PREFIX_IN "name", "default",
118 NAME_TEXT, NAME_LONGTEXT, false )
119 add_bool( SOUT_CFG_PREFIX_IN "placeholder", false, NULL,
120 PLACEHOLDER_TEXT, PLACEHOLDER_LONGTEXT, false )
121 add_integer( SOUT_CFG_PREFIX_IN "placeholder-delay", 200,
122 PLACEHOLDER_DELAY_TEXT, PLACEHOLDER_DELAY_LONGTEXT, false )
123 add_bool( SOUT_CFG_PREFIX_IN "placeholder-switch-on-iframe", true, NULL,
124 PLACEHOLDER_IFRAME_TEXT, PLACEHOLDER_IFRAME_LONGTEXT, false )
125 set_callbacks( OpenIn, CloseIn )
127 vlc_module_end ()
130 /*****************************************************************************
131 * Local prototypes
132 *****************************************************************************/
133 static const char *const ppsz_sout_options_out[] = {
134 "id", "in-name", NULL
137 static const char *const ppsz_sout_options_in[] = {
138 "delay", "id-offset", "name",
139 "placeholder", "placeholder-delay", "placeholder-switch-on-iframe",
140 NULL
143 static sout_stream_id_t *AddOut ( sout_stream_t *, es_format_t * );
144 static int DelOut ( sout_stream_t *, sout_stream_id_t * );
145 static int SendOut( sout_stream_t *, sout_stream_id_t *, block_t * );
147 static sout_stream_id_t *AddIn ( sout_stream_t *, es_format_t * );
148 static int DelIn ( sout_stream_t *, sout_stream_id_t * );
149 static int SendIn( sout_stream_t *, sout_stream_id_t *, block_t * );
151 typedef struct bridged_es_t
153 es_format_t fmt;
154 block_t *p_block;
155 block_t **pp_last;
156 bool b_empty;
158 /* bridge in part */
159 sout_stream_id_t *id;
160 mtime_t i_last;
161 bool b_changed;
162 } bridged_es_t;
164 typedef struct bridge_t
166 bridged_es_t **pp_es;
167 int i_es_num;
168 } bridge_t;
172 * Bridge out
175 typedef struct out_sout_stream_sys_t
177 vlc_mutex_t *p_lock;
178 bridged_es_t *p_es;
179 int i_id;
180 bool b_inited;
182 char *psz_name;
183 } out_sout_stream_sys_t;
185 /*****************************************************************************
186 * OpenOut:
187 *****************************************************************************/
188 static int OpenOut( vlc_object_t *p_this )
190 sout_stream_t *p_stream = (sout_stream_t *)p_this;
191 out_sout_stream_sys_t *p_sys;
192 vlc_value_t val;
194 config_ChainParse( p_stream, SOUT_CFG_PREFIX_OUT, ppsz_sout_options_out,
195 p_stream->p_cfg );
197 p_sys = malloc( sizeof( out_sout_stream_sys_t ) );
198 if( unlikely( !p_sys ) )
199 return VLC_ENOMEM;
200 p_sys->b_inited = false;
202 var_Create( p_this->p_libvlc, "bridge-lock", VLC_VAR_MUTEX );
203 var_Get( p_this->p_libvlc, "bridge-lock", &val );
204 p_sys->p_lock = val.p_address;
206 var_Get( p_stream, SOUT_CFG_PREFIX_OUT "id", &val );
207 p_sys->i_id = val.i_int;
209 var_Get( p_stream, SOUT_CFG_PREFIX_OUT "in-name", &val );
210 if( asprintf( &p_sys->psz_name, "bridge-struct-%s", val.psz_string )<0 )
212 free( val.psz_string );
213 free( p_sys );
214 return VLC_ENOMEM;
216 free( val.psz_string );
218 p_stream->pf_add = AddOut;
219 p_stream->pf_del = DelOut;
220 p_stream->pf_send = SendOut;
222 p_stream->p_sys = (sout_stream_sys_t *)p_sys;
224 p_stream->p_sout->i_out_pace_nocontrol++;
226 return VLC_SUCCESS;
229 /*****************************************************************************
230 * CloseOut:
231 *****************************************************************************/
232 static void CloseOut( vlc_object_t * p_this )
234 sout_stream_t *p_stream = (sout_stream_t*)p_this;
235 out_sout_stream_sys_t *p_sys = (out_sout_stream_sys_t *)p_stream->p_sys;
237 p_stream->p_sout->i_out_pace_nocontrol--;
239 free( p_sys->psz_name );
240 free( p_sys );
243 static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt )
245 out_sout_stream_sys_t *p_sys = (out_sout_stream_sys_t *)p_stream->p_sys;
246 bridge_t *p_bridge;
247 bridged_es_t *p_es;
248 int i;
250 if ( p_sys->b_inited )
252 msg_Err( p_stream, "bridge-out can only handle 1 es at a time." );
253 return NULL;
255 p_sys->b_inited = true;
257 vlc_mutex_lock( p_sys->p_lock );
259 p_bridge = var_GetAddress( p_stream->p_libvlc, p_sys->psz_name );
260 if ( p_bridge == NULL )
262 p_bridge = xmalloc( sizeof( bridge_t ) );
264 var_Create( p_stream->p_libvlc, p_sys->psz_name, VLC_VAR_ADDRESS );
265 var_SetAddress( p_stream->p_libvlc, p_sys->psz_name, p_bridge );
267 p_bridge->i_es_num = 0;
268 p_bridge->pp_es = NULL;
271 for ( i = 0; i < p_bridge->i_es_num; i++ )
273 if ( p_bridge->pp_es[i]->b_empty && !p_bridge->pp_es[i]->b_changed )
274 break;
277 if ( i == p_bridge->i_es_num )
279 p_bridge->pp_es = xrealloc( p_bridge->pp_es,
280 (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) );
281 p_bridge->i_es_num++;
282 p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) );
285 p_sys->p_es = p_es = p_bridge->pp_es[i];
287 p_es->fmt = *p_fmt;
288 p_es->fmt.i_id = p_sys->i_id;
289 p_es->p_block = NULL;
290 p_es->pp_last = &p_es->p_block;
291 p_es->b_empty = false;
293 p_es->id = NULL;
294 p_es->i_last = VLC_TS_INVALID;
295 p_es->b_changed = true;
297 msg_Dbg( p_stream, "bridging out input codec=%4.4s id=%d pos=%d",
298 (char*)&p_es->fmt.i_codec, p_es->fmt.i_id, i );
300 vlc_mutex_unlock( p_sys->p_lock );
302 return (sout_stream_id_t *)p_sys;
305 static int DelOut( sout_stream_t *p_stream, sout_stream_id_t *id )
307 VLC_UNUSED(id);
308 out_sout_stream_sys_t *p_sys = (out_sout_stream_sys_t *)p_stream->p_sys;
309 bridged_es_t *p_es;
311 if ( !p_sys->b_inited )
313 return VLC_SUCCESS;
316 vlc_mutex_lock( p_sys->p_lock );
318 p_es = p_sys->p_es;
320 p_es->b_empty = true;
321 block_ChainRelease( p_es->p_block );
322 p_es->p_block = false;
324 p_es->b_changed = true;
325 vlc_mutex_unlock( p_sys->p_lock );
327 p_sys->b_inited = false;
329 return VLC_SUCCESS;
332 static int SendOut( sout_stream_t *p_stream, sout_stream_id_t *id,
333 block_t *p_buffer )
335 out_sout_stream_sys_t *p_sys = (out_sout_stream_sys_t *)p_stream->p_sys;
336 bridged_es_t *p_es;
338 if ( (out_sout_stream_sys_t *)id != p_sys )
340 block_ChainRelease( p_buffer );
341 return VLC_SUCCESS;
344 vlc_mutex_lock( p_sys->p_lock );
346 p_es = p_sys->p_es;
347 *p_es->pp_last = p_buffer;
348 while ( p_buffer != NULL )
350 p_es->pp_last = &p_buffer->p_next;
351 p_buffer = p_buffer->p_next;
354 vlc_mutex_unlock( p_sys->p_lock );
356 return VLC_SUCCESS;
361 * Bridge in
364 typedef struct in_sout_stream_sys_t
366 vlc_mutex_t *p_lock;
367 int i_id_offset;
368 mtime_t i_delay;
370 char *psz_name;
372 bool b_placeholder;
373 bool b_switch_on_iframe;
374 int i_state;
375 mtime_t i_placeholder_delay;
376 sout_stream_id_t *id_video;
377 mtime_t i_last_video;
378 sout_stream_id_t *id_audio;
379 mtime_t i_last_audio;
380 } in_sout_stream_sys_t;
382 enum { placeholder_on, placeholder_off };
384 /*****************************************************************************
385 * OpenIn:
386 *****************************************************************************/
387 static int OpenIn( vlc_object_t *p_this )
389 sout_stream_t *p_stream = (sout_stream_t*)p_this;
390 in_sout_stream_sys_t *p_sys;
391 vlc_value_t val;
393 p_sys = malloc( sizeof( in_sout_stream_sys_t ) );
394 if( unlikely( !p_sys ) )
395 return VLC_ENOMEM;
397 if( !p_stream->p_next )
399 msg_Err( p_stream, "cannot create chain" );
400 free( p_sys );
401 return VLC_EGENERIC;
404 config_ChainParse( p_stream, SOUT_CFG_PREFIX_IN, ppsz_sout_options_in,
405 p_stream->p_cfg );
407 var_Create( p_this->p_libvlc, "bridge-lock", VLC_VAR_MUTEX );
408 var_Get( p_this->p_libvlc, "bridge-lock", &val );
409 p_sys->p_lock = val.p_address;
411 var_Get( p_stream, SOUT_CFG_PREFIX_IN "id-offset", &val );
412 p_sys->i_id_offset = val.i_int;
414 var_Get( p_stream, SOUT_CFG_PREFIX_IN "delay", &val );
415 p_sys->i_delay = (mtime_t)val.i_int * 1000;
417 var_Get( p_stream, SOUT_CFG_PREFIX_IN "name", &val );
418 if( asprintf( &p_sys->psz_name, "bridge-struct-%s", val.psz_string )<0 )
420 free( val.psz_string );
421 free( p_sys );
422 return VLC_ENOMEM;
424 free( val.psz_string );
426 var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder", &val );
427 p_sys->b_placeholder = val.b_bool;
429 var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-switch-on-iframe", &val);
430 p_sys->b_switch_on_iframe = val.b_bool;
432 p_sys->i_state = placeholder_on;
434 var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-delay", &val );
435 p_sys->i_placeholder_delay = (mtime_t)val.i_int * 1000;
437 p_sys->i_last_video = VLC_TS_INVALID;
438 p_sys->i_last_audio = VLC_TS_INVALID;
439 p_sys->id_video = NULL;
440 p_sys->id_audio = NULL;
442 p_stream->pf_add = AddIn;
443 p_stream->pf_del = DelIn;
444 p_stream->pf_send = SendIn;
446 p_stream->p_sys = (sout_stream_sys_t *)p_sys;
448 /* update p_sout->i_out_pace_nocontrol */
449 p_stream->p_sout->i_out_pace_nocontrol++;
451 return VLC_SUCCESS;
454 /*****************************************************************************
455 * CloseIn:
456 *****************************************************************************/
457 static void CloseIn( vlc_object_t * p_this )
459 sout_stream_t *p_stream = (sout_stream_t*)p_this;
460 in_sout_stream_sys_t *p_sys = (in_sout_stream_sys_t *)p_stream->p_sys;
462 p_stream->p_sout->i_out_pace_nocontrol--;
464 free( p_sys->psz_name );
465 free( p_sys );
468 struct sout_stream_id_t
470 sout_stream_id_t *id;
471 int i_cat; /* es category. Used for placeholder option */
474 static sout_stream_id_t * AddIn( sout_stream_t *p_stream, es_format_t *p_fmt )
476 in_sout_stream_sys_t *p_sys = (in_sout_stream_sys_t *)p_stream->p_sys;
478 sout_stream_id_t *id = malloc( sizeof( sout_stream_id_t ) );
479 if( !id ) return NULL;
481 id->id = p_stream->p_next->pf_add( p_stream->p_next, p_fmt );
482 if( !id->id )
484 free( id );
485 return NULL;
488 if( p_sys->b_placeholder )
490 id->i_cat = p_fmt->i_cat;
491 switch( p_fmt->i_cat )
493 case VIDEO_ES:
494 if( p_sys->id_video != NULL )
495 msg_Err( p_stream, "We already had a video es!" );
496 p_sys->id_video = id->id;
497 break;
498 case AUDIO_ES:
499 if( p_sys->id_audio != NULL )
500 msg_Err( p_stream, "We already had an audio es!" );
501 p_sys->id_audio = id->id;
502 break;
506 return id;
509 static int DelIn( sout_stream_t *p_stream, sout_stream_id_t *id )
511 in_sout_stream_sys_t *p_sys = (in_sout_stream_sys_t *)p_stream->p_sys;
513 if( id == p_sys->id_video ) p_sys->id_video = NULL;
514 if( id == p_sys->id_audio ) p_sys->id_audio = NULL;
516 int ret = p_stream->p_next->pf_del( p_stream->p_next, id->id );
518 free( id );
519 return ret;
522 static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id,
523 block_t *p_buffer )
525 in_sout_stream_sys_t *p_sys = (in_sout_stream_sys_t *)p_stream->p_sys;
526 bridge_t *p_bridge;
527 bool b_no_es = true;
528 int i;
529 int i_date = mdate();
531 /* First forward the packet for our own ES */
532 if( !p_sys->b_placeholder )
533 p_stream->p_next->pf_send( p_stream->p_next, id->id, p_buffer );
535 /* Then check all bridged streams */
536 vlc_mutex_lock( p_sys->p_lock );
538 p_bridge = var_GetAddress( p_stream->p_libvlc, p_sys->psz_name );
540 if( p_bridge )
542 for ( i = 0; i < p_bridge->i_es_num; i++ )
544 if ( !p_bridge->pp_es[i]->b_empty )
545 b_no_es = false;
547 while ( p_bridge->pp_es[i]->p_block != NULL
548 && (p_bridge->pp_es[i]->p_block->i_dts + p_sys->i_delay
549 < i_date
550 || p_bridge->pp_es[i]->p_block->i_dts + p_sys->i_delay
551 < p_bridge->pp_es[i]->i_last) )
553 block_t *p_block = p_bridge->pp_es[i]->p_block;
554 msg_Dbg( p_stream, "dropping a packet (%"PRId64 ")",
555 i_date - p_block->i_dts - p_sys->i_delay );
556 p_bridge->pp_es[i]->p_block
557 = p_bridge->pp_es[i]->p_block->p_next;
558 block_Release( p_block );
561 if ( p_bridge->pp_es[i]->p_block == NULL )
563 p_bridge->pp_es[i]->pp_last = &p_bridge->pp_es[i]->p_block;
566 if ( p_bridge->pp_es[i]->b_changed )
568 if ( p_bridge->pp_es[i]->b_empty && p_bridge->pp_es[i]->id != NULL )
570 p_stream->p_next->pf_del( p_stream->p_next, p_bridge->pp_es[i]->id );
572 else
574 /* We need at least two packets to enter the mux. */
575 if ( p_bridge->pp_es[i]->p_block == NULL
576 || p_bridge->pp_es[i]->p_block->p_next == NULL )
578 continue;
581 p_bridge->pp_es[i]->fmt.i_id += p_sys->i_id_offset;
582 if( !p_sys->b_placeholder )
584 p_bridge->pp_es[i]->id = p_stream->p_next->pf_add(
585 p_stream->p_next, &p_bridge->pp_es[i]->fmt );
586 if ( p_bridge->pp_es[i]->id == NULL )
588 msg_Warn( p_stream, "couldn't create chain for id %d",
589 p_bridge->pp_es[i]->fmt.i_id );
592 msg_Dbg( p_stream, "bridging in input codec=%4.4s id=%d pos=%d",
593 (char*)&p_bridge->pp_es[i]->fmt.i_codec,
594 p_bridge->pp_es[i]->fmt.i_id, i );
597 p_bridge->pp_es[i]->b_changed = false;
599 if ( p_bridge->pp_es[i]->b_empty )
600 continue;
602 if ( p_bridge->pp_es[i]->p_block == NULL )
604 if ( p_bridge->pp_es[i]->id != NULL
605 && p_bridge->pp_es[i]->i_last < i_date )
607 if( !p_sys->b_placeholder )
608 p_stream->p_next->pf_del( p_stream->p_next,
609 p_bridge->pp_es[i]->id );
610 p_bridge->pp_es[i]->fmt.i_id -= p_sys->i_id_offset;
611 p_bridge->pp_es[i]->b_changed = true;
612 p_bridge->pp_es[i]->id = NULL;
614 continue;
617 if ( p_bridge->pp_es[i]->id != NULL || p_sys->b_placeholder)
619 block_t *p_block = p_bridge->pp_es[i]->p_block;
620 while ( p_block != NULL )
622 p_bridge->pp_es[i]->i_last = p_block->i_dts;
623 p_block->i_pts += p_sys->i_delay;
624 p_block->i_dts += p_sys->i_delay;
625 p_block = p_block->p_next;
627 sout_stream_id_t *newid = NULL;
628 if( p_sys->b_placeholder )
630 switch( p_bridge->pp_es[i]->fmt.i_cat )
632 case VIDEO_ES:
633 p_sys->i_last_video = i_date;
634 newid = p_sys->id_video;
635 if( !newid )
636 break;
637 if( !p_sys->b_switch_on_iframe ||
638 p_sys->i_state == placeholder_off ||
639 ( p_bridge->pp_es[i]->fmt.i_cat == VIDEO_ES &&
640 p_bridge->pp_es[i]->p_block->i_flags & BLOCK_FLAG_TYPE_I ) )
642 p_stream->p_next->pf_send( p_stream->p_next,
643 newid,
644 p_bridge->pp_es[i]->p_block );
645 p_sys->i_state = placeholder_off;
647 break;
648 case AUDIO_ES:
649 newid = p_sys->id_audio;
650 if( !newid )
651 break;
652 p_sys->i_last_audio = i_date;
653 default:
654 p_stream->p_next->pf_send( p_stream->p_next,
655 newid?newid:p_bridge->pp_es[i]->id,
656 p_bridge->pp_es[i]->p_block );
657 break;
660 else /* !b_placeholder */
661 p_stream->p_next->pf_send( p_stream->p_next,
662 p_bridge->pp_es[i]->id,
663 p_bridge->pp_es[i]->p_block );
665 else
667 block_ChainRelease( p_bridge->pp_es[i]->p_block );
670 p_bridge->pp_es[i]->p_block = NULL;
671 p_bridge->pp_es[i]->pp_last = &p_bridge->pp_es[i]->p_block;
674 if( b_no_es )
676 for ( i = 0; i < p_bridge->i_es_num; i++ )
677 free( p_bridge->pp_es[i] );
678 free( p_bridge->pp_es );
679 free( p_bridge );
680 var_Destroy( p_stream->p_libvlc, p_sys->psz_name );
684 if( p_sys->b_placeholder )
686 switch( id->i_cat )
688 case VIDEO_ES:
689 if( ( p_sys->i_last_video + p_sys->i_placeholder_delay < i_date
690 && ( !p_sys->b_switch_on_iframe
691 || p_buffer->i_flags & BLOCK_FLAG_TYPE_I ) )
692 || p_sys->i_state == placeholder_on )
694 p_stream->p_next->pf_send( p_stream->p_next, id->id, p_buffer );
695 p_sys->i_state = placeholder_on;
697 else
698 block_Release( p_buffer );
699 break;
701 case AUDIO_ES:
702 if( p_sys->i_last_audio + p_sys->i_placeholder_delay < i_date )
703 p_stream->p_next->pf_send( p_stream->p_next, id->id, p_buffer );
704 else
705 block_Release( p_buffer );
706 break;
708 default:
709 block_Release( p_buffer ); /* FIXME: placeholder subs anyone? */
710 break;
714 vlc_mutex_unlock( p_sys->p_lock );
716 return VLC_SUCCESS;