Commit 7e6fdf13 authored by Laurent Aimar's avatar Laurent Aimar

* stream_output: * some clean and fixed a little memory leak.

                  * give to access and muxers options. Now you can use:
--sout 'access{option1=value}/mux{a=value,b=value}:/path'. It should also
works with '#std{access=access{o=v}, mux=...}' (but untested). For now it's
not used.
parent 2ac6eec8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* stream_output.c : stream output module * stream_output.c : stream output module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: stream_output.c,v 1.30 2003/07/22 18:06:04 gbazin Exp $ * $Id: stream_output.c,v 1.31 2003/07/31 19:24:10 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static void sout_cfg_free( sout_cfg_t * );
#define sout_stream_url_to_chain( p, s ) _sout_stream_url_to_chain( VLC_OBJECT(p), s ) #define sout_stream_url_to_chain( p, s ) _sout_stream_url_to_chain( VLC_OBJECT(p), s )
static char *_sout_stream_url_to_chain( vlc_object_t *, char * ); static char *_sout_stream_url_to_chain( vlc_object_t *, char * );
...@@ -237,6 +239,7 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout, ...@@ -237,6 +239,7 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
char *psz_access, char *psz_name ) char *psz_access, char *psz_name )
{ {
sout_access_out_t *p_access; sout_access_out_t *p_access;
char *psz_next;
if( !( p_access = vlc_object_create( p_sout, if( !( p_access = vlc_object_create( p_sout,
sizeof( sout_access_out_t ) ) ) ) sizeof( sout_access_out_t ) ) ) )
...@@ -244,7 +247,12 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout, ...@@ -244,7 +247,12 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
msg_Err( p_sout, "out of memory" ); msg_Err( p_sout, "out of memory" );
return NULL; return NULL;
} }
p_access->psz_access = strdup( psz_access ? psz_access : "" );
psz_next = sout_cfg_parser( &p_access->psz_access, &p_access->p_cfg, psz_access );
if( psz_next )
{
free( psz_next );
}
p_access->psz_name = strdup( psz_name ? psz_name : "" ); p_access->psz_name = strdup( psz_name ? psz_name : "" );
p_access->p_sout = p_sout; p_access->p_sout = p_sout;
p_access->p_sys = NULL; p_access->p_sys = NULL;
...@@ -274,6 +282,9 @@ void sout_AccessOutDelete( sout_access_out_t *p_access ) ...@@ -274,6 +282,9 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
module_Unneed( p_access, p_access->p_module ); module_Unneed( p_access, p_access->p_module );
} }
free( p_access->psz_access ); free( p_access->psz_access );
sout_cfg_free( p_access->p_cfg );
free( p_access->psz_name ); free( p_access->psz_name );
vlc_object_destroy( p_access ); vlc_object_destroy( p_access );
...@@ -304,6 +315,7 @@ sout_mux_t * sout_MuxNew ( sout_instance_t *p_sout, ...@@ -304,6 +315,7 @@ sout_mux_t * sout_MuxNew ( sout_instance_t *p_sout,
sout_access_out_t *p_access ) sout_access_out_t *p_access )
{ {
sout_mux_t *p_mux; sout_mux_t *p_mux;
char *psz_next;
p_mux = vlc_object_create( p_sout, p_mux = vlc_object_create( p_sout,
sizeof( sout_mux_t ) ); sizeof( sout_mux_t ) );
...@@ -314,7 +326,11 @@ sout_mux_t * sout_MuxNew ( sout_instance_t *p_sout, ...@@ -314,7 +326,11 @@ sout_mux_t * sout_MuxNew ( sout_instance_t *p_sout,
} }
p_mux->p_sout = p_sout; p_mux->p_sout = p_sout;
p_mux->psz_mux = strdup( psz_mux ? psz_mux : "" ); psz_next = sout_cfg_parser( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux );
if( psz_next )
{
free( psz_next );
}
p_mux->p_access = p_access; p_mux->p_access = p_access;
p_mux->i_preheader = 0; p_mux->i_preheader = 0;
p_mux->pf_capacity = NULL; p_mux->pf_capacity = NULL;
...@@ -377,6 +393,8 @@ void sout_MuxDelete ( sout_mux_t *p_mux ) ...@@ -377,6 +393,8 @@ void sout_MuxDelete ( sout_mux_t *p_mux )
} }
free( p_mux->psz_mux ); free( p_mux->psz_mux );
sout_cfg_free( p_mux->p_cfg );
vlc_object_destroy( p_mux ); vlc_object_destroy( p_mux );
} }
...@@ -1082,8 +1100,21 @@ char * sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain ) ...@@ -1082,8 +1100,21 @@ char * sout_cfg_parser( char **ppsz_name, sout_cfg_t **pp_cfg, char *psz_chain )
return( NULL ); return( NULL );
} }
static void sout_cfg_free( sout_cfg_t *p_cfg )
{
while( p_cfg != NULL )
{
sout_cfg_t *p_next;
p_next = p_cfg->p_next;
FREE( p_cfg->psz_name );
FREE( p_cfg->psz_value );
free( p_cfg );
p_cfg = p_next;
}
}
/* /*
...@@ -1138,19 +1169,7 @@ void sout_stream_delete( sout_stream_t *p_stream ) ...@@ -1138,19 +1169,7 @@ void sout_stream_delete( sout_stream_t *p_stream )
FREE( p_stream->psz_name ); FREE( p_stream->psz_name );
FREE( p_stream->psz_next ); FREE( p_stream->psz_next );
p_cfg = p_stream->p_cfg; sout_cfg_free( p_stream->p_cfg );
while( p_cfg != NULL )
{
sout_cfg_t *p_next;
p_next = p_cfg->p_next;
FREE( p_cfg->psz_name );
FREE( p_cfg->psz_value );
free( p_cfg );
p_cfg = p_next;
}
msg_Dbg( p_stream, "destroying chain done" ); msg_Dbg( p_stream, "destroying chain done" );
vlc_object_destroy( p_stream ); vlc_object_destroy( p_stream );
...@@ -1209,13 +1228,14 @@ static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url ) ...@@ -1209,13 +1228,14 @@ static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url )
if( config_GetInt( p_this, "sout-display" ) ) if( config_GetInt( p_this, "sout-display" ) )
{ {
p += sprintf( p, "duplicate{dst=display,dst=std{mux=%s,access=%s,url=\"%s\"}}", mrl.psz_way, mrl.psz_access, mrl.psz_name ); p += sprintf( p, "duplicate{dst=display,dst=std{mux=\"%s\",access=\"%s\",url=\"%s\"}}", mrl.psz_way, mrl.psz_access, mrl.psz_name );
} }
else else
{ {
p += sprintf( p, "std{mux=%s,access=%s,url=\"%s\"}", mrl.psz_way, mrl.psz_access, mrl.psz_name ); p += sprintf( p, "std{mux=\"%s\",access=\"%s\",url=\"%s\"}", mrl.psz_way, mrl.psz_access, mrl.psz_name );
} }
mrl_Clean( &mrl );
return( psz_chain ); return( psz_chain );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment