1 /*****************************************************************************
2 * stream_output.c : stream output module
3 *****************************************************************************
4 * Copyright (C) 2002-2004 VideoLAN
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Laurent Aimar <fenrir@via.ecp.fr>
9 * Eric Petit <titer@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
29 #include <stdlib.h> /* free() */
30 #include <stdio.h> /* sprintf() */
31 #include <string.h> /* strerror() */
39 /*****************************************************************************
41 *****************************************************************************/
42 static void sout_CfgDestroy( sout_cfg_t * );
44 #define sout_stream_url_to_chain( p, s ) \
45 _sout_stream_url_to_chain( VLC_OBJECT(p), s )
46 static char *_sout_stream_url_to_chain( vlc_object_t *, char * );
60 /* mrl_Parse: parse psz_mrl and fill p_mrl */
61 static int mrl_Parse( mrl_t *p_mrl, char *psz_mrl );
62 /* mrl_Clean: clean p_mrl after a call to mrl_Parse */
63 static void mrl_Clean( mrl_t *p_mrl );
65 #define FREE( p ) if( p ) { free( p ); (p) = NULL; }
67 /*****************************************************************************
68 * sout_NewInstance: creates a new stream output instance
69 *****************************************************************************/
70 sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
72 sout_instance_t *p_sout;
75 if( var_Get( p_parent, "sout-keep", &keep ) < 0 )
77 msg_Warn( p_parent, "cannot get sout-keep value" );
78 keep.b_bool = VLC_FALSE;
80 else if( keep.b_bool )
82 msg_Warn( p_parent, "sout-keep true" );
83 if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
86 if( !strcmp( p_sout->psz_sout, psz_dest ) )
88 msg_Warn( p_parent, "sout keep : reusing sout" );
89 msg_Warn( p_parent, "sout keep : you probably want to use "
90 "gather stream_out" );
91 vlc_object_detach( p_sout );
92 vlc_object_attach( p_sout, p_parent );
93 vlc_object_release( p_sout );
98 msg_Warn( p_parent, "sout keep : destroying unusable sout" );
99 sout_DeleteInstance( p_sout );
103 else if( !keep.b_bool )
105 while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
108 msg_Warn( p_parent, "sout keep : destroying old sout" );
109 sout_DeleteInstance( p_sout );
113 /* *** Allocate descriptor *** */
114 p_sout = vlc_object_create( p_parent, VLC_OBJECT_SOUT );
117 msg_Err( p_parent, "out of memory" );
121 /* *** init descriptor *** */
122 p_sout->psz_sout = strdup( psz_dest );
123 p_sout->p_meta = NULL;
124 p_sout->i_out_pace_nocontrol = 0;
125 p_sout->p_sys = NULL;
127 vlc_mutex_init( p_sout, &p_sout->lock );
128 if( psz_dest && psz_dest[0] == '#' )
130 p_sout->psz_chain = strdup( &psz_dest[1] );
134 p_sout->psz_chain = sout_stream_url_to_chain( p_sout, psz_dest );
135 msg_Dbg( p_sout, "using sout chain=`%s'", p_sout->psz_chain );
137 p_sout->p_stream = NULL;
139 /* attach it for inherit */
140 vlc_object_attach( p_sout, p_parent );
142 p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
144 if( p_sout->p_stream == NULL )
146 msg_Err( p_sout, "stream chained failed for `%s'", p_sout->psz_chain );
148 FREE( p_sout->psz_sout );
149 FREE( p_sout->psz_chain );
151 vlc_object_detach( p_sout );
152 vlc_object_destroy( p_sout );
158 /*****************************************************************************
159 * sout_DeleteInstance: delete a previously allocated instance
160 *****************************************************************************/
161 void sout_DeleteInstance( sout_instance_t * p_sout )
164 vlc_object_detach( p_sout );
166 /* remove the stream out chain */
167 sout_StreamDelete( p_sout->p_stream );
169 /* *** free all string *** */
170 FREE( p_sout->psz_sout );
171 FREE( p_sout->psz_chain );
176 vlc_meta_Delete( p_sout->p_meta );
179 vlc_mutex_destroy( &p_sout->lock );
181 /* *** free structure *** */
182 vlc_object_destroy( p_sout );
185 /*****************************************************************************
187 *****************************************************************************/
188 sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
191 sout_packetizer_input_t *p_input;
193 msg_Dbg( p_sout, "adding a new input" );
195 /* *** create a packetizer input *** */
196 p_input = malloc( sizeof( sout_packetizer_input_t ) );
197 p_input->p_sout = p_sout;
198 p_input->p_fmt = p_fmt;
200 if( p_fmt->i_codec == VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
202 vlc_object_release( p_sout );
206 /* *** add it to the stream chain */
207 vlc_mutex_lock( &p_sout->lock );
208 p_input->id = p_sout->p_stream->pf_add( p_sout->p_stream, p_fmt );
209 vlc_mutex_unlock( &p_sout->lock );
211 if( p_input->id == NULL )
220 /*****************************************************************************
222 *****************************************************************************/
223 int sout_InputDelete( sout_packetizer_input_t *p_input )
225 sout_instance_t *p_sout = p_input->p_sout;
227 msg_Dbg( p_sout, "removing an input" );
229 if( p_input->p_fmt->i_codec != VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
231 vlc_mutex_lock( &p_sout->lock );
232 p_sout->p_stream->pf_del( p_sout->p_stream, p_input->id );
233 vlc_mutex_unlock( &p_sout->lock );
238 return( VLC_SUCCESS);
241 /*****************************************************************************
243 *****************************************************************************/
244 int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
247 sout_instance_t *p_sout = p_input->p_sout;
250 if( p_input->p_fmt->i_codec == VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
252 block_Release( p_buffer );
255 if( p_buffer->i_dts <= 0 )
257 msg_Warn( p_sout, "trying to send non-dated packet to stream output!");
258 block_Release( p_buffer );
262 vlc_mutex_lock( &p_sout->lock );
263 i_ret = p_sout->p_stream->pf_send( p_sout->p_stream,
264 p_input->id, p_buffer );
265 vlc_mutex_unlock( &p_sout->lock );
270 /*****************************************************************************
271 * sout_AccessOutNew: allocate a new access out
272 *****************************************************************************/
273 sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
274 char *psz_access, char *psz_name )
276 sout_access_out_t *p_access;
279 if( !( p_access = vlc_object_create( p_sout,
280 sizeof( sout_access_out_t ) ) ) )
282 msg_Err( p_sout, "out of memory" );
286 psz_next = sout_CfgCreate( &p_access->psz_access, &p_access->p_cfg,
292 p_access->psz_name = strdup( psz_name ? psz_name : "" );
293 p_access->p_sout = p_sout;
294 p_access->p_sys = NULL;
295 p_access->pf_seek = NULL;
296 p_access->pf_read = NULL;
297 p_access->pf_write = NULL;
298 p_access->p_module = NULL;
299 vlc_object_attach( p_access, p_sout );
302 module_Need( p_access, "sout access", p_access->psz_access, VLC_TRUE );
304 if( !p_access->p_module )
306 free( p_access->psz_access );
307 free( p_access->psz_name );
308 vlc_object_detach( p_access );
309 vlc_object_destroy( p_access );
315 /*****************************************************************************
316 * sout_AccessDelete: delete an access out
317 *****************************************************************************/
318 void sout_AccessOutDelete( sout_access_out_t *p_access )
320 vlc_object_detach( p_access );
321 if( p_access->p_module )
323 module_Unneed( p_access, p_access->p_module );
325 free( p_access->psz_access );
327 sout_CfgDestroy( p_access->p_cfg );
329 free( p_access->psz_name );
331 vlc_object_destroy( p_access );
334 /*****************************************************************************
336 *****************************************************************************/
337 int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
339 return p_access->pf_seek( p_access, i_pos );
342 /*****************************************************************************
344 *****************************************************************************/
345 int sout_AccessOutRead( sout_access_out_t *p_access, block_t *p_buffer )
347 return( p_access->pf_read ?
348 p_access->pf_read( p_access, p_buffer ) : VLC_EGENERIC );
351 /*****************************************************************************
353 *****************************************************************************/
354 int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
356 return p_access->pf_write( p_access, p_buffer );
359 /*****************************************************************************
360 * sout_MuxNew: create a new mux
361 *****************************************************************************/
362 sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
363 sout_access_out_t *p_access )
368 p_mux = vlc_object_create( p_sout, sizeof( sout_mux_t ) );
371 msg_Err( p_sout, "out of memory" );
375 p_mux->p_sout = p_sout;
376 psz_next = sout_CfgCreate( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux );
377 if( psz_next ) free( psz_next );
379 p_mux->p_access = p_access;
380 p_mux->pf_control = NULL;
381 p_mux->pf_addstream = NULL;
382 p_mux->pf_delstream = NULL;
383 p_mux->pf_mux = NULL;
384 p_mux->i_nb_inputs = 0;
385 p_mux->pp_inputs = NULL;
388 p_mux->p_module = NULL;
390 p_mux->b_add_stream_any_time = VLC_FALSE;
391 p_mux->b_waiting_stream = VLC_TRUE;
392 p_mux->i_add_stream_start = -1;
394 vlc_object_attach( p_mux, p_sout );
397 module_Need( p_mux, "sout mux", p_mux->psz_mux, VLC_TRUE );
399 if( p_mux->p_module == NULL )
401 FREE( p_mux->psz_mux );
403 vlc_object_detach( p_mux );
404 vlc_object_destroy( p_mux );
408 /* *** probe mux capacity *** */
409 if( p_mux->pf_control )
411 int b_answer = VLC_FALSE;
413 if( sout_MuxControl( p_mux, MUX_CAN_ADD_STREAM_WHILE_MUXING,
416 b_answer = VLC_FALSE;
421 msg_Dbg( p_sout, "muxer support adding stream at any time" );
422 p_mux->b_add_stream_any_time = VLC_TRUE;
423 p_mux->b_waiting_stream = VLC_FALSE;
425 /* If we control the output pace then it's better to wait before
426 * starting muxing (generates better streams/files). */
427 if( !p_sout->i_out_pace_nocontrol )
431 else if( sout_MuxControl( p_mux, MUX_GET_ADD_STREAM_WAIT,
434 b_answer = VLC_FALSE;
439 msg_Dbg( p_sout, "muxer prefers waiting for all ES before "
441 p_mux->b_waiting_stream = VLC_TRUE;
449 /*****************************************************************************
451 *****************************************************************************/
452 void sout_MuxDelete( sout_mux_t *p_mux )
454 vlc_object_detach( p_mux );
455 if( p_mux->p_module )
457 module_Unneed( p_mux, p_mux->p_module );
459 free( p_mux->psz_mux );
461 sout_CfgDestroy( p_mux->p_cfg );
463 vlc_object_destroy( p_mux );
466 /*****************************************************************************
468 *****************************************************************************/
469 sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
471 sout_input_t *p_input;
473 if( !p_mux->b_add_stream_any_time && !p_mux->b_waiting_stream )
475 msg_Err( p_mux, "cannot add a new stream (unsuported while muxing "
476 "for this format)" );
480 msg_Dbg( p_mux, "adding a new input" );
482 /* create a new sout input */
483 p_input = malloc( sizeof( sout_input_t ) );
484 p_input->p_sout = p_mux->p_sout;
485 p_input->p_fmt = p_fmt;
486 p_input->p_fifo = block_FifoNew( p_mux->p_sout );
487 p_input->p_sys = NULL;
489 TAB_APPEND( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input );
490 if( p_mux->pf_addstream( p_mux, p_input ) < 0 )
492 msg_Err( p_mux, "cannot add this stream" );
493 TAB_REMOVE( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input );
494 block_FifoRelease( p_input->p_fifo );
502 /*****************************************************************************
503 * sout_MuxDeleteStream:
504 *****************************************************************************/
505 void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input )
509 if( p_mux->b_waiting_stream && p_input->p_fifo->i_depth > 0 )
511 /* We stop waiting, and call the muxer for taking care of the data
512 * before we remove this es */
513 p_mux->b_waiting_stream = VLC_FALSE;
514 p_mux->pf_mux( p_mux );
517 TAB_FIND( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input, i_index );
520 if( p_mux->pf_delstream( p_mux, p_input ) < 0 )
522 msg_Err( p_mux, "cannot del this stream from mux" );
525 /* remove the entry */
526 TAB_REMOVE( p_mux->i_nb_inputs, p_mux->pp_inputs, p_input );
528 if( p_mux->i_nb_inputs == 0 )
530 msg_Warn( p_mux, "no more input stream for this mux" );
533 block_FifoRelease( p_input->p_fifo );
538 /*****************************************************************************
539 * sout_MuxSendBuffer:
540 *****************************************************************************/
541 void sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
544 block_FifoPut( p_input->p_fifo, p_buffer );
546 if( p_mux->b_waiting_stream )
548 if( p_mux->i_add_stream_start < 0 )
550 p_mux->i_add_stream_start = p_buffer->i_dts;
553 if( p_mux->i_add_stream_start >= 0 &&
554 p_mux->i_add_stream_start + I64C(1500000) < p_buffer->i_dts )
556 /* Wait until we have more than 1.5 seconds worth of data
557 * before start muxing */
558 p_mux->b_waiting_stream = VLC_FALSE;
565 p_mux->pf_mux( p_mux );
568 /*****************************************************************************
570 *****************************************************************************/
571 static int mrl_Parse( mrl_t *p_mrl, char *psz_mrl )
573 char * psz_dup = strdup( psz_mrl );
574 char * psz_parser = psz_dup;
575 char * psz_access = "";
577 char * psz_name = "";
579 /* *** first parse psz_dest */
580 while( *psz_parser && *psz_parser != ':' )
582 if( *psz_parser == '{' )
584 while( *psz_parser && *psz_parser != '}' )
598 #if defined( WIN32 ) || defined( UNDER_CE )
599 if( psz_parser - psz_dup == 1 )
601 /* msg_Warn( p_sout, "drive letter %c: found in source string",
609 psz_access = psz_way = "";
614 *psz_parser++ = '\0';
616 /* let's skip '//' */
617 if( psz_parser[0] == '/' && psz_parser[1] == '/' )
622 psz_name = psz_parser ;
624 /* Come back to parse the access and mux plug-ins */
625 psz_parser = psz_dup;
632 else if( *psz_parser == '/' )
640 psz_access = psz_parser;
642 while( *psz_parser && *psz_parser != '/' )
644 if( *psz_parser == '{' )
646 while( *psz_parser && *psz_parser != '}' )
661 if( *psz_parser == '/' )
663 *psz_parser++ = '\0';
674 psz_way = psz_parser;
678 p_mrl->psz_access = strdup( psz_access );
679 p_mrl->psz_way = strdup( psz_way );
680 p_mrl->psz_name = strdup( psz_name );
683 return( VLC_SUCCESS );
687 /* mrl_Clean: clean p_mrl after a call to mrl_Parse */
688 static void mrl_Clean( mrl_t *p_mrl )
690 FREE( p_mrl->psz_access );
691 FREE( p_mrl->psz_way );
692 FREE( p_mrl->psz_name );
696 /****************************************************************************
697 ****************************************************************************
701 ****************************************************************************
702 ****************************************************************************/
704 /* create a complete chain */
706 module{option=*:option=*}[:module{option=*:...}]
710 * parse module{options=str, option="str "}:
711 * return a pointer on the rest
712 * XXX: psz_chain is modified
714 #define SKIPSPACE( p ) { while( *p && ( *p == ' ' || *p == '\t' ) ) p++; }
715 #define SKIPTRAILINGSPACE( p, e ) \
716 { while( e > p && ( *(e-1) == ' ' || *(e-1) == '\t' ) ) e--; }
718 /* go accross " " and { } */
719 static char *_get_chain_end( char *str )
727 if( !*p || *p == ',' || *p == '}' ) return p;
729 if( *p != '{' && *p != '"' && *p != '\'' )
735 if( *p == '{' ) c = '}';
743 if( *p == c ) return ++p;
744 else if( *p == '{' && c == '}' ) p = _get_chain_end( p );
750 char *sout_CfgCreate( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
752 sout_cfg_t *p_cfg = NULL;
758 if( !p ) return NULL;
762 while( *p && *p != '{' && *p != ':' && *p != ' ' && *p != '\t' ) p++;
764 if( p == psz_chain ) return NULL;
766 *ppsz_name = strndup( psz_chain, p - psz_chain );
784 while( *p && *p != '=' && *p != ',' && *p != '{' && *p != '}' &&
785 *p != ' ' && *p != '\t' ) p++;
787 /* fprintf( stderr, "name=%s - rest=%s\n", psz_name, p ); */
790 fprintf( stderr, "invalid options (empty)" );
794 cfg.psz_name = strndup( psz_name, p - psz_name );
798 if( *p == '=' || *p == '{' )
801 vlc_bool_t b_keep_brackets = (*p == '{');
805 end = _get_chain_end( p );
808 cfg.psz_value = NULL;
812 /* Skip heading and trailing spaces.
813 * This ain't necessary but will avoid simple
820 cfg.psz_value = NULL;
824 if( *p == '\'' || *p == '"' ||
825 ( !b_keep_brackets && *p == '{' ) )
829 if( *(end-1) != '\'' && *(end-1) == '"' )
830 SKIPTRAILINGSPACE( p, end );
832 if( end - 1 <= p ) cfg.psz_value = NULL;
833 else cfg.psz_value = strndup( p, end -1 - p );
837 SKIPTRAILINGSPACE( p, end );
838 if( end <= p ) cfg.psz_value = NULL;
839 else cfg.psz_value = strndup( p, end - p );
848 cfg.psz_value = NULL;
854 p_cfg->p_next = malloc( sizeof( sout_cfg_t ) );
855 memcpy( p_cfg->p_next, &cfg, sizeof( sout_cfg_t ) );
857 p_cfg = p_cfg->p_next;
861 p_cfg = malloc( sizeof( sout_cfg_t ) );
862 memcpy( p_cfg, &cfg, sizeof( sout_cfg_t ) );
877 if( *p == ':' ) return( strdup( p + 1 ) );
882 static void sout_CfgDestroy( sout_cfg_t *p_cfg )
884 while( p_cfg != NULL )
888 p_next = p_cfg->p_next;
890 FREE( p_cfg->psz_name );
891 FREE( p_cfg->psz_value );
898 void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix,
899 const char **ppsz_options, sout_cfg_t *cfg )
905 /* First, var_Create all variables */
906 for( i = 0; ppsz_options[i] != NULL; i++ )
908 asprintf( &psz_name, "%s%s", psz_prefix,
909 *ppsz_options[i] == '*' ? &ppsz_options[i][1] : ppsz_options[i] );
911 i_type = config_GetType( p_this, psz_name );
913 var_Create( p_this, psz_name, i_type | VLC_VAR_DOINHERIT );
917 /* Now parse options and set value */
918 if( psz_prefix == NULL ) psz_prefix = "";
923 vlc_bool_t b_yes = VLC_TRUE;
924 vlc_bool_t b_once = VLC_FALSE;
926 if( cfg->psz_name == NULL || *cfg->psz_name == '\0' )
931 for( i = 0; ppsz_options[i] != NULL; i++ )
933 if( !strcmp( ppsz_options[i], cfg->psz_name ) )
937 if( ( !strncmp( cfg->psz_name, "no-", 3 ) &&
938 !strcmp( ppsz_options[i], cfg->psz_name + 3 ) ) ||
939 ( !strncmp( cfg->psz_name, "no", 2 ) &&
940 !strcmp( ppsz_options[i], cfg->psz_name + 2 ) ) )
946 if( *ppsz_options[i] == '*' &&
947 !strcmp( &ppsz_options[i][1], cfg->psz_name ) )
954 if( ppsz_options[i] == NULL )
956 msg_Warn( p_this, "option %s is unknown", cfg->psz_name );
962 asprintf( &psz_name, "%s%s", psz_prefix, b_once ? &ppsz_options[i][1] : ppsz_options[i] );
964 /* get the type of the variable */
965 i_type = config_GetType( p_this, psz_name );
968 msg_Warn( p_this, "unknown option %s (value=%s)",
969 cfg->psz_name, cfg->psz_value );
972 if( i_type != VLC_VAR_BOOL && cfg->psz_value == NULL )
974 msg_Warn( p_this, "missing value for option %s", cfg->psz_name );
977 if( i_type != VLC_VAR_STRING && b_once )
979 msg_Warn( p_this, "*option_name need to be a string option" );
988 case VLC_VAR_INTEGER:
989 val.i_int = strtol( cfg->psz_value ? cfg->psz_value : "0",
993 val.f_float = atof( cfg->psz_value ? cfg->psz_value : "0" );
996 val.psz_string = cfg->psz_value;
999 msg_Warn( p_this, "unhandled config var type" );
1000 memset( &val, 0, sizeof( vlc_value_t ) );
1007 var_Get( p_this, psz_name, &val2 );
1008 if( *val2.psz_string )
1010 free( val2.psz_string );
1011 msg_Dbg( p_this, "ignoring option %s (not first occurrence)", psz_name );
1014 free( val2.psz_string );
1016 var_Set( p_this, psz_name, val );
1017 msg_Dbg( p_this, "set sout option: %s to %s", psz_name, cfg->psz_value );
1027 * XXX name and p_cfg are used (-> do NOT free them)
1029 sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_chain )
1031 sout_stream_t *p_stream;
1035 msg_Err( p_sout, "invalid chain" );
1039 p_stream = vlc_object_create( p_sout, sizeof( sout_stream_t ) );
1043 msg_Err( p_sout, "out of memory" );
1047 p_stream->p_sout = p_sout;
1048 p_stream->p_sys = NULL;
1050 p_stream->psz_next =
1051 sout_CfgCreate( &p_stream->psz_name, &p_stream->p_cfg, psz_chain);
1053 msg_Dbg( p_sout, "stream=`%s'", p_stream->psz_name );
1055 vlc_object_attach( p_stream, p_sout );
1057 p_stream->p_module =
1058 module_Need( p_stream, "sout stream", p_stream->psz_name, VLC_TRUE );
1060 if( !p_stream->p_module )
1062 sout_StreamDelete( p_stream );
1069 void sout_StreamDelete( sout_stream_t *p_stream )
1071 msg_Dbg( p_stream, "destroying chain... (name=%s)", p_stream->psz_name );
1073 vlc_object_detach( p_stream );
1074 if( p_stream->p_module ) module_Unneed( p_stream, p_stream->p_module );
1076 FREE( p_stream->psz_name );
1077 FREE( p_stream->psz_next );
1079 sout_CfgDestroy( p_stream->p_cfg );
1081 msg_Dbg( p_stream, "destroying chain done" );
1082 vlc_object_destroy( p_stream );
1085 static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url )
1088 char *psz_chain, *p;
1090 mrl_Parse( &mrl, psz_url );
1091 p = psz_chain = malloc( 500 + strlen( mrl.psz_way ) +
1092 strlen( mrl.psz_access ) +
1093 strlen( mrl.psz_name ) );
1096 if( config_GetInt( p_this, "sout-display" ) )
1098 p += sprintf( p, "duplicate{dst=display,dst=std{mux=\"%s\","
1099 "access=\"%s\",url=\"%s\"}}",
1100 mrl.psz_way, mrl.psz_access, mrl.psz_name );
1104 p += sprintf( p, "std{mux=\"%s\",access=\"%s\",url=\"%s\"}",
1105 mrl.psz_way, mrl.psz_access, mrl.psz_name );
1109 return( psz_chain );