X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fstream_output%2Fstream_output.c;h=c8bc465ce401ec792da446f60b198391685342e3;hb=d016a4283ea29e3596172e4c761f6d66c0d44268;hp=9494981bbcfab2645d7b44955bc7712614963a86;hpb=fe087a38282e93addb25fa9598393e40ea233b09;p=vlc diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c index 9494981bbc..c8bc465ce4 100644 --- a/src/stream_output/stream_output.c +++ b/src/stream_output/stream_output.c @@ -20,18 +20,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ + +#include + #include /* free() */ #include /* sprintf() */ #include /* strerror() */ -#include #include +#include #include "vlc_meta.h" @@ -62,8 +65,6 @@ static int mrl_Parse( mrl_t *p_mrl, char *psz_mrl ); /* mrl_Clean: clean p_mrl after a call to mrl_Parse */ static void mrl_Clean( mrl_t *p_mrl ); -#define FREE( p ) if( p ) { free( p ); (p) = NULL; } - /***************************************************************************** * sout_NewInstance: creates a new stream output instance *****************************************************************************/ @@ -77,16 +78,15 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) msg_Warn( p_parent, "cannot get sout-keep value" ); keep.b_bool = VLC_FALSE; } - else if( keep.b_bool ) + if( keep.b_bool ) { - msg_Warn( p_parent, "sout-keep true" ); if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, - FIND_ANYWHERE ) ) ) + FIND_ANYWHERE ) ) != NULL ) { if( !strcmp( p_sout->psz_sout, psz_dest ) ) { - msg_Warn( p_parent, "sout keep : reusing sout" ); - msg_Warn( p_parent, "sout keep : you probably want to use " + msg_Dbg( p_parent, "sout keep: reusing sout" ); + msg_Dbg( p_parent, "sout keep: you probably want to use " "gather stream_out" ); vlc_object_detach( p_sout ); vlc_object_attach( p_sout, p_parent ); @@ -95,7 +95,8 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) } else { - msg_Warn( p_parent, "sout keep : destroying unusable sout" ); + msg_Dbg( p_parent, "sout keep: destroying unusable sout" ); + vlc_object_release( p_sout ); sout_DeleteInstance( p_sout ); } } @@ -103,9 +104,10 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) else if( !keep.b_bool ) { while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, - FIND_PARENT ) ) ) + FIND_PARENT ) ) != NULL ) { - msg_Warn( p_parent, "sout keep : destroying old sout" ); + msg_Dbg( p_parent, "sout keep: destroying old sout" ); + vlc_object_release( p_sout ); sout_DeleteInstance( p_sout ); } } @@ -143,10 +145,10 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) if( p_sout->p_stream == NULL ) { - msg_Err( p_sout, "stream chained failed for `%s'", p_sout->psz_chain ); + msg_Err( p_sout, "stream chain failed for `%s'", p_sout->psz_chain ); - FREE( p_sout->psz_sout ); - FREE( p_sout->psz_chain ); + FREENULL( p_sout->psz_sout ); + FREENULL( p_sout->psz_chain ); vlc_object_detach( p_sout ); vlc_object_destroy( p_sout ); @@ -155,6 +157,7 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest ) return p_sout; } + /***************************************************************************** * sout_DeleteInstance: delete a previously allocated instance *****************************************************************************/ @@ -167,8 +170,8 @@ void sout_DeleteInstance( sout_instance_t * p_sout ) sout_StreamDelete( p_sout->p_stream ); /* *** free all string *** */ - FREE( p_sout->psz_sout ); - FREE( p_sout->psz_chain ); + FREENULL( p_sout->psz_sout ); + FREENULL( p_sout->psz_chain ); /* delete meta */ if( p_sout->p_meta ) @@ -296,6 +299,10 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout, p_access->pf_read = NULL; p_access->pf_write = NULL; p_access->p_module = NULL; + + p_access->i_writes = 0; + p_access->i_sent_bytes = 0; + vlc_object_attach( p_access, p_sout ); p_access->p_module = @@ -353,6 +360,27 @@ int sout_AccessOutRead( sout_access_out_t *p_access, block_t *p_buffer ) *****************************************************************************/ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer ) { + int i_total = 0; + p_access->i_writes++; + p_access->i_sent_bytes += p_buffer->i_buffer; + if( p_access->p_libvlc->b_stats && p_access->i_writes % 30 == 0 ) + { + /* Access_out -> sout_instance -> input_thread_t */ + input_thread_t *p_input = + (input_thread_t *)vlc_object_find( p_access, VLC_OBJECT_INPUT, + FIND_PARENT ); + if( p_input ) + { + stats_UpdateInteger( p_input, p_input->counters.p_sout_sent_packets, + 30, NULL ); + stats_UpdateInteger( p_input, p_input->counters.p_sout_sent_bytes, + p_access->i_sent_bytes, &i_total ); + stats_UpdateFloat( p_input, p_input->counters.p_sout_send_bitrate, + (float)i_total, NULL ); + p_access->i_sent_bytes = 0; + vlc_object_release( p_input ); + } + } return p_access->pf_write( p_access, p_buffer ); } @@ -398,7 +426,7 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux, if( p_mux->p_module == NULL ) { - FREE( p_mux->psz_mux ); + FREENULL( p_mux->psz_mux ); vlc_object_detach( p_mux ); vlc_object_destroy( p_mux ); @@ -436,8 +464,8 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux, if( b_answer ) { - msg_Dbg( p_sout, "muxer prefers waiting for all ES before " - "starting muxing" ); + msg_Dbg( p_sout, "muxer prefers to wait for all ES before " + "starting to mux" ); p_mux->b_waiting_stream = VLC_TRUE; } } @@ -472,8 +500,8 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt ) if( !p_mux->b_add_stream_any_time && !p_mux->b_waiting_stream ) { - msg_Err( p_mux, "cannot add a new stream (unsuported while muxing " - "for this format)" ); + msg_Err( p_mux, "cannot add a new stream (unsupported while muxing " + "to this format)" ); return NULL; } @@ -519,7 +547,7 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input ) { if( p_mux->pf_delstream( p_mux, p_input ) < 0 ) { - msg_Err( p_mux, "cannot del this stream from mux" ); + msg_Err( p_mux, "cannot delete this stream from mux" ); } /* remove the entry */ @@ -527,7 +555,7 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input ) if( p_mux->i_nb_inputs == 0 ) { - msg_Warn( p_mux, "no more input stream for this mux" ); + msg_Warn( p_mux, "no more input streams for this mux" ); } block_FifoRelease( p_input->p_fifo ); @@ -695,9 +723,9 @@ static int mrl_Parse( mrl_t *p_mrl, char *psz_mrl ) /* mrl_Clean: clean p_mrl after a call to mrl_Parse */ static void mrl_Clean( mrl_t *p_mrl ) { - FREE( p_mrl->psz_access ); - FREE( p_mrl->psz_way ); - FREE( p_mrl->psz_name ); + FREENULL( p_mrl->psz_access ); + FREENULL( p_mrl->psz_way ); + FREENULL( p_mrl->psz_name ); } @@ -895,8 +923,8 @@ static void sout_CfgDestroy( sout_cfg_t *p_cfg ) p_next = p_cfg->p_next; - FREE( p_cfg->psz_name ); - FREE( p_cfg->psz_value ); + FREENULL( p_cfg->psz_name ); + FREENULL( p_cfg->psz_value ); free( p_cfg ); p_cfg = p_next; @@ -930,6 +958,7 @@ void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix, vlc_value_t val; vlc_bool_t b_yes = VLC_TRUE; vlc_bool_t b_once = VLC_FALSE; + module_config_t *p_conf; if( cfg->psz_name == NULL || *cfg->psz_name == '\0' ) { @@ -969,6 +998,38 @@ void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix, /* create name */ asprintf( &psz_name, "%s%s", psz_prefix, b_once ? &ppsz_options[i][1] : ppsz_options[i] ); + /* Check if the option is deprecated */ + p_conf = config_FindConfig( p_this, psz_name ); + + /* This is basically cut and paste from src/misc/configuration.c + * with slight changes */ + if( p_conf && p_conf->psz_current ) + { + if( !strcmp( p_conf->psz_current, "SUPPRESSED" ) ) + { + msg_Err( p_this, "Option %s is no longer used.", + p_conf->psz_name ); + goto next; + } + else if( p_conf->b_strict ) + { + msg_Err( p_this, "Option %s is deprecated. Use %s instead.", + p_conf->psz_name, p_conf->psz_current ); + /* TODO: this should return an error and end option parsing + * ... but doing this would change the VLC API and all the + * modules so i'll do it later */ + goto next; + } + else + { + msg_Warn( p_this, "Option %s is deprecated. You should use " + "%s instead.", p_conf->psz_name, p_conf->psz_current ); + free( psz_name ); + psz_name = strdup( p_conf->psz_current ); + } + } + /* */ + /* get the type of the variable */ i_type = config_GetType( p_this, psz_name ); if( !i_type ) @@ -1082,8 +1143,8 @@ void sout_StreamDelete( sout_stream_t *p_stream ) vlc_object_detach( p_stream ); if( p_stream->p_module ) module_Unneed( p_stream, p_stream->p_module ); - FREE( p_stream->psz_name ); - FREE( p_stream->psz_next ); + FREENULL( p_stream->psz_name ); + FREENULL( p_stream->psz_next ); sout_CfgDestroy( p_stream->p_cfg ); @@ -1105,12 +1166,12 @@ static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url ) if( config_GetInt( p_this, "sout-display" ) ) { p += sprintf( p, "duplicate{dst=display,dst=std{mux=\"%s\"," - "access=\"%s\",url=\"%s\"}}", + "access=\"%s\",dst=\"%s\"}}", mrl.psz_way, mrl.psz_access, mrl.psz_name ); } else { - p += sprintf( p, "std{mux=\"%s\",access=\"%s\",url=\"%s\"}", + p += sprintf( p, "std{mux=\"%s\",access=\"%s\",dst=\"%s\"}", mrl.psz_way, mrl.psz_access, mrl.psz_name ); }