X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmux%2Fasf.c;h=4217cf2077662bdf9324adedd84de066a8a0ab5f;hb=27d483e9ef7a451397d7857251c8d67097661f1d;hp=21fa7711193059a5153f2b8cd24f5e7ca238a4ec;hpb=2cb472dba008f7d877ffe6bae9c5575253365282;p=vlc diff --git a/modules/mux/asf.c b/modules/mux/asf.c index 21fa771119..4217cf2077 100644 --- a/modules/mux/asf.c +++ b/modules/mux/asf.c @@ -1,7 +1,7 @@ /***************************************************************************** * asf.c: asf muxer module for vlc ***************************************************************************** - * Copyright (C) 2003-2004 the VideoLAN team + * Copyright (C) 2003-2004, 2006 the VideoLAN team * $Id$ * * Authors: Laurent Aimar @@ -25,13 +25,17 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include -#include -#include +#include +#include +#include +#include -#include "codecs.h" typedef GUID guid_t; #define MAX_ASF_TRACKS 128 @@ -46,22 +50,17 @@ static void Close ( vlc_object_t * ); #define SOUT_CFG_PREFIX "sout-asf-" #define TITLE_TEXT N_("Title") -#define TITLE_LONGTEXT N_("Allows you to define the title that will be put " \ - "in ASF comments.") +#define TITLE_LONGTEXT N_("Title to put in ASF comments." ) #define AUTHOR_TEXT N_("Author") -#define AUTHOR_LONGTEXT N_("Allows you to define the author that will be put "\ - "in ASF comments.") +#define AUTHOR_LONGTEXT N_("Author to put in ASF comments." ) #define COPYRIGHT_TEXT N_("Copyright") -#define COPYRIGHT_LONGTEXT N_("Allows you to define the copyright string " \ - "that will be put in ASF comments.") +#define COPYRIGHT_LONGTEXT N_("Copyright string to put in ASF comments." ) #define COMMENT_TEXT N_("Comment") -#define COMMENT_LONGTEXT N_("Allows you to define the comment that will be " \ - "put in ASF comments.") +#define COMMENT_LONGTEXT N_("Comment to put in ASF comments." ) #define RATING_TEXT N_("Rating") -#define RATING_LONGTEXT N_("Allows you to define the \"rating\" that will " \ - "be put in ASF comments.") +#define RATING_LONGTEXT N_("\"Rating\" to put in ASF comments." ) #define PACKETSIZE_TEXT N_("Packet Size") -#define PACKETSIZE_LONGTEXT N_("The ASF packet size -- default is 4096 bytes") +#define PACKETSIZE_LONGTEXT N_("ASF packet size -- default is 4096 bytes") vlc_module_begin(); set_description( _("ASF muxer") ); @@ -75,16 +74,16 @@ vlc_module_begin(); set_callbacks( Open, Close ); add_string( SOUT_CFG_PREFIX "title", "", NULL, TITLE_TEXT, TITLE_LONGTEXT, - VLC_TRUE ); + true ); add_string( SOUT_CFG_PREFIX "author", "", NULL, AUTHOR_TEXT, - AUTHOR_LONGTEXT, VLC_TRUE ); + AUTHOR_LONGTEXT, true ); add_string( SOUT_CFG_PREFIX "copyright","", NULL, COPYRIGHT_TEXT, - COPYRIGHT_LONGTEXT, VLC_TRUE ); + COPYRIGHT_LONGTEXT, true ); add_string( SOUT_CFG_PREFIX "comment", "", NULL, COMMENT_TEXT, - COMMENT_LONGTEXT, VLC_TRUE ); + COMMENT_LONGTEXT, true ); add_string( SOUT_CFG_PREFIX "rating", "", NULL, RATING_TEXT, - RATING_LONGTEXT, VLC_TRUE ); - add_integer( "sout-asf-packet-size", 4096, NULL, PACKETSIZE_TEXT, PACKETSIZE_LONGTEXT, VLC_TRUE ); + RATING_LONGTEXT, true ); + add_integer( "sout-asf-packet-size", 4096, NULL, PACKETSIZE_TEXT, PACKETSIZE_LONGTEXT, true ); vlc_module_end(); @@ -108,9 +107,9 @@ typedef struct /* codec information */ uint16_t i_tag; /* for audio */ vlc_fourcc_t i_fourcc; /* for video */ - char *psz_name; /* codec name */ + const char *psz_name; /* codec name */ int i_blockalign; /* for audio only */ - vlc_bool_t b_audio_correction; + bool b_audio_correction; int i_sequence; @@ -134,14 +133,14 @@ struct sout_mux_sys_t int i_track; asf_track_t track[MAX_ASF_TRACKS]; - vlc_bool_t b_write_header; + bool b_write_header; block_t *pk; int i_pk_used; int i_pk_frame; mtime_t i_pk_dts; - vlc_bool_t b_asf_http; + bool b_asf_http; int i_seq; /* meta data */ @@ -154,7 +153,7 @@ struct sout_mux_sys_t static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts ); -static block_t *asf_header_create( sout_mux_t *, vlc_bool_t ); +static block_t *asf_header_create( sout_mux_t *, bool ); static block_t *asf_packet_create( sout_mux_t *, asf_track_t *, block_t * ); static block_t *asf_stream_end_create( sout_mux_t *); static block_t *asf_packet_flush( sout_mux_t * ); @@ -174,7 +173,7 @@ static void bo_addle_u32( bo_t *, uint32_t ); static void bo_addle_u64( bo_t *, uint64_t ); static void bo_add_mem ( bo_t *, uint8_t *, int ); -static void bo_addle_str16( bo_t *, char * ); +static void bo_addle_str16( bo_t *, const char * ); /***************************************************************************** * Open: @@ -186,8 +185,8 @@ static int Open( vlc_object_t *p_this ) vlc_value_t val; int i; - msg_Dbg( p_mux, "Asf muxer opened" ); - sout_CfgParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg ); + msg_Dbg( p_mux, "asf muxer opened" ); + config_ChainParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg ); p_mux->pf_control = Control; p_mux->pf_addstream = AddStream; @@ -209,7 +208,7 @@ static int Open( vlc_object_t *p_this ) p_sys->i_bitrate = 0; p_sys->i_seq = 0; - p_sys->b_write_header = VLC_TRUE; + p_sys->b_write_header = true; p_sys->i_track = 0; p_sys->i_packet_size = config_GetInt( p_mux, "sout-asf-packet-size" ); msg_Dbg( p_mux, "Packet size %d", p_sys->i_packet_size); @@ -241,8 +240,8 @@ static int Open( vlc_object_t *p_this ) var_Get( p_mux, SOUT_CFG_PREFIX "rating", &val ); p_sys->psz_rating = val.psz_string; - msg_Dbg( p_mux, "meta data: title='%s' author='%s' copyright='%s' " - "comment='%s' rating='%s'", + msg_Dbg( p_mux, "meta data: title='%s', author='%s', copyright='%s', " + "comment='%s', rating='%s'", p_sys->psz_title, p_sys->psz_author, p_sys->psz_copyright, p_sys->psz_comment, p_sys->psz_rating ); @@ -273,9 +272,9 @@ static void Close( vlc_object_t * p_this ) } /* rewrite header */ - if( !sout_AccessOutSeek( p_mux->p_access, 0 ) ) + if( sout_AccessOutSeek( p_mux->p_access, 0 ) == VLC_SUCCESS ) { - out = asf_header_create( p_mux, VLC_FALSE ); + out = asf_header_create( p_mux, false ); sout_AccessOutWrite( p_mux->p_access, out ); } @@ -293,20 +292,20 @@ static void Close( vlc_object_t * p_this ) static int Control( sout_mux_t *p_mux, int i_query, va_list args ) { sout_mux_sys_t *p_sys = p_mux->p_sys; - vlc_bool_t *pb_bool; + bool *pb_bool; char **ppsz; switch( i_query ) { case MUX_CAN_ADD_STREAM_WHILE_MUXING: - pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); - if( p_sys->b_asf_http ) *pb_bool = VLC_TRUE; - else *pb_bool = VLC_FALSE; + pb_bool = (bool*)va_arg( args, bool * ); + if( p_sys->b_asf_http ) *pb_bool = true; + else *pb_bool = false; return VLC_SUCCESS; case MUX_GET_ADD_STREAM_WAIT: - pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); - *pb_bool = VLC_TRUE; + pb_bool = (bool*)va_arg( args, bool * ); + *pb_bool = true; return VLC_SUCCESS; case MUX_GET_MIME: @@ -334,7 +333,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) msg_Dbg( p_mux, "adding input" ); if( p_sys->i_track >= MAX_ASF_TRACKS ) { - msg_Dbg( p_mux, "cannot add this track (too much track)" ); + msg_Dbg( p_mux, "cannot add this track (too much tracks)" ); return VLC_EGENERIC; } @@ -359,6 +358,11 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) tk->psz_name = "A/52"; i_bitspersample = 0; break; + case VLC_FOURCC( 'm', 'p', '4', 'a' ): + tk->i_tag = WAVE_FORMAT_AAC; + tk->psz_name = "MPEG-4 Audio"; + i_bitspersample = 0; + break; case VLC_FOURCC( 'm', 'p', 'g', 'a' ): #if 1 tk->psz_name = "MPEG Audio Layer 3"; @@ -378,23 +382,23 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) case VLC_FOURCC( 'w', 'm', 'a', '1' ): tk->psz_name = "Windows Media Audio v1"; tk->i_tag = WAVE_FORMAT_WMA1; - tk->b_audio_correction = VLC_TRUE; + tk->b_audio_correction = true; break; case VLC_FOURCC( 'w', 'm', 'a', ' ' ): case VLC_FOURCC( 'w', 'm', 'a', '2' ): tk->psz_name= "Windows Media Audio (v2) 7, 8 and 9 Series"; tk->i_tag = WAVE_FORMAT_WMA2; - tk->b_audio_correction = VLC_TRUE; + tk->b_audio_correction = true; break; case VLC_FOURCC( 'w', 'm', 'a', 'p' ): tk->psz_name = "Windows Media Audio 9 Professional"; tk->i_tag = WAVE_FORMAT_WMAP; - tk->b_audio_correction = VLC_TRUE; + tk->b_audio_correction = true; break; case VLC_FOURCC( 'w', 'm', 'a', 'l' ): tk->psz_name = "Windows Media Audio 9 Lossless"; tk->i_tag = WAVE_FORMAT_WMAL; - tk->b_audio_correction = VLC_TRUE; + tk->b_audio_correction = true; break; /* raw codec */ case VLC_FOURCC( 'u', '8', ' ', ' ' ): @@ -578,6 +582,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) *****************************************************************************/ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) { + VLC_UNUSED(p_input); msg_Dbg( p_mux, "removing input" ); return VLC_SUCCESS; } @@ -591,12 +596,12 @@ static int Mux( sout_mux_t *p_mux ) if( p_sys->b_write_header ) { - block_t *out = asf_header_create( p_mux, VLC_TRUE ); + block_t *out = asf_header_create( p_mux, true ); out->i_flags |= BLOCK_FLAG_HEADER; sout_AccessOutWrite( p_mux->p_access, out ); - p_sys->b_write_header = VLC_FALSE; + p_sys->b_write_header = false; } for( ;; ) @@ -648,7 +653,7 @@ static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts ) sout_input_t *p_input = p_mux->pp_inputs[i]; block_t *p_data; - if( p_input->p_fifo->i_depth <= 0 ) + if( block_FifoCount( p_input->p_fifo ) <= 0 ) { if( p_input->p_fmt->i_cat == AUDIO_ES || p_input->p_fmt->i_cat == VIDEO_ES ) @@ -722,7 +727,7 @@ static void bo_add_mem( bo_t *p_bo, uint8_t *p_mem, int i_size ) p_bo->i_buffer += i_size; } -static void bo_addle_str16( bo_t *bo, char *str ) +static void bo_addle_str16( bo_t *bo, const char *str ) { bo_addle_u16( bo, strlen( str ) + 1 ); for( ;; ) @@ -733,7 +738,7 @@ static void bo_addle_str16( bo_t *bo, char *str ) } } -static void bo_addle_str16_nosize( bo_t *bo, char *str ) +static void bo_addle_str16_nosize( bo_t *bo, const char *str ) { for( ;; ) { @@ -766,7 +771,7 @@ static const guid_t asf_object_file_properties_guid = {0x8cabdca1, 0xa947, 0x11cf, {0x8e, 0xe4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; static const guid_t asf_object_stream_properties_guid = {0xB7DC0791, 0xA9B7, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; -static const guid_t asf_object_header_extention_guid = +static const guid_t asf_object_header_extension_guid = {0x5FBF03B5, 0xA92E, 0x11CF, {0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}}; static const guid_t asf_object_stream_type_audio = {0xF8699E40, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}}; @@ -804,7 +809,7 @@ static void asf_chunk_add( bo_t *bo, bo_addle_u16( bo, i_len + 8 ); } -static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast ) +static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast ) { sout_mux_sys_t *p_sys = p_mux->p_sys; asf_track_t *tk; @@ -898,10 +903,10 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast ) bo_addle_u32( &bo, p_sys->i_packet_size ); /* packet size max */ bo_addle_u32( &bo, p_sys->i_bitrate ); /* maxbitrate */ - /* header extention */ + /* header extension */ if( i_header_ext_size ) { - bo_add_guid ( &bo, &asf_object_header_extention_guid ); + bo_add_guid ( &bo, &asf_object_header_extension_guid ); bo_addle_u64( &bo, i_header_ext_size ); bo_add_guid ( &bo, &asf_guid_reserved_1 ); bo_addle_u16( &bo, 6 );