Commit 95aa92bd authored by Gildas Bazin's avatar Gildas Bazin

* modules/mux/asf.c: a few coding style changes.

parent aa2229d4
/***************************************************************************** /*****************************************************************************
* asf.c * asf.c: asf muxer module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003-2004 VideoLAN
* $Id$ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
...@@ -44,11 +44,11 @@ static void Close ( vlc_object_t * ); ...@@ -44,11 +44,11 @@ static void Close ( vlc_object_t * );
#define TITLE_LONGTEXT N_("Allows you to define the title that will be put " \ #define TITLE_LONGTEXT N_("Allows you to define the title that will be put " \
"in ASF comments.") "in ASF comments.")
#define AUTHOR_TEXT N_("Author") #define AUTHOR_TEXT N_("Author")
#define AUTHOR_LONGTEXT N_("Allows you to define the author that will be put " \ #define AUTHOR_LONGTEXT N_("Allows you to define the author that will be put "\
"in ASF comments.") "in ASF comments.")
#define COPYRIGHT_TEXT N_("Copyright") #define COPYRIGHT_TEXT N_("Copyright")
#define COPYRIGHT_LONGTEXT N_("Allows you to define the copyright string that "\ #define COPYRIGHT_LONGTEXT N_("Allows you to define the copyright string " \
"will be put in ASF comments.") "that will be put in ASF comments.")
#define COMMENT_TEXT N_("Comment") #define COMMENT_TEXT N_("Comment")
#define COMMENT_LONGTEXT N_("Allows you to define the comment that will be " \ #define COMMENT_LONGTEXT N_("Allows you to define the comment that will be " \
"put in ASF comments.") "put in ASF comments.")
...@@ -144,8 +144,7 @@ struct sout_mux_sys_t ...@@ -144,8 +144,7 @@ struct sout_mux_sys_t
static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts ); 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 b_broadcast ); static block_t *asf_header_create( sout_mux_t *, vlc_bool_t b_broadcast );
static block_t *asf_packet_create( sout_mux_t *, static block_t *asf_packet_create( sout_mux_t *, asf_track_t *, block_t * );
asf_track_t *, block_t * );
static block_t *asf_stream_end_create( sout_mux_t *); static block_t *asf_stream_end_create( sout_mux_t *);
typedef struct typedef struct
...@@ -200,7 +199,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -200,7 +199,8 @@ static int Open( vlc_object_t *p_this )
p_sys->i_track = 1; p_sys->i_track = 1;
p_sys->i_packet_size = 4096; p_sys->i_packet_size = 4096;
p_sys->i_packet_count= 0; p_sys->i_packet_count= 0;
/* generate a random fid */
/* Generate a random fid */
srand( mdate() & 0xffffffff ); srand( mdate() & 0xffffffff );
p_sys->fid.v1 = 0xbabac001; p_sys->fid.v1 = 0xbabac001;
p_sys->fid.v2 = ( (uint64_t)rand() << 16 ) / RAND_MAX; p_sys->fid.v2 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
...@@ -209,7 +209,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -209,7 +209,8 @@ static int Open( vlc_object_t *p_this )
{ {
p_sys->fid.v4[i] = ( (uint64_t)rand() << 8 ) / RAND_MAX; p_sys->fid.v4[i] = ( (uint64_t)rand() << 8 ) / RAND_MAX;
} }
/* meta data */
/* Meta data */
var_Get( p_mux, SOUT_CFG_PREFIX "title", &val ); var_Get( p_mux, SOUT_CFG_PREFIX "title", &val );
p_sys->psz_title = val.psz_string; p_sys->psz_title = val.psz_string;
...@@ -225,8 +226,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -225,8 +226,8 @@ static int Open( vlc_object_t *p_this )
var_Get( p_mux, SOUT_CFG_PREFIX "rating", &val ); var_Get( p_mux, SOUT_CFG_PREFIX "rating", &val );
p_sys->psz_rating = val.psz_string; p_sys->psz_rating = val.psz_string;
msg_Dbg( p_mux, msg_Dbg( p_mux, "meta data: title='%s' author='%s' copyright='%s' "
"meta data: title='%s' author='%s' copyright='%s' comment='%s' rating='%s'", "comment='%s' rating='%s'",
p_sys->psz_title, p_sys->psz_author, p_sys->psz_copyright, p_sys->psz_title, p_sys->psz_author, p_sys->psz_copyright,
p_sys->psz_comment, p_sys->psz_rating ); p_sys->psz_comment, p_sys->psz_rating );
...@@ -541,7 +542,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -541,7 +542,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
/***************************************************************************** /*****************************************************************************
* Mux: * Mux:
*****************************************************************************/ *****************************************************************************/
static int Mux ( sout_mux_t *p_mux ) static int Mux( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
...@@ -593,10 +594,7 @@ static int Mux ( sout_mux_t *p_mux ) ...@@ -593,10 +594,7 @@ static int Mux ( sout_mux_t *p_mux )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
static int MuxGetStream( sout_mux_t *p_mux,
int *pi_stream,
mtime_t *pi_dts )
{ {
mtime_t i_dts; mtime_t i_dts;
int i_stream; int i_stream;
...@@ -677,9 +675,7 @@ static void bo_add_mem( bo_t *p_bo, uint8_t *p_mem, int i_size ) ...@@ -677,9 +675,7 @@ static void bo_add_mem( bo_t *p_bo, uint8_t *p_mem, int i_size )
if( i_copy > 0 ) if( i_copy > 0 )
{ {
memcpy( &p_bo->p_buffer[p_bo->i_buffer], memcpy( &p_bo->p_buffer[p_bo->i_buffer], p_mem, i_copy );
p_mem,
i_copy );
} }
p_bo->i_buffer += i_size; p_bo->i_buffer += i_size;
} }
...@@ -689,14 +685,9 @@ static void bo_addle_str16( bo_t *bo, char *str ) ...@@ -689,14 +685,9 @@ static void bo_addle_str16( bo_t *bo, char *str )
bo_addle_u16( bo, strlen( str ) + 1 ); bo_addle_u16( bo, strlen( str ) + 1 );
for( ;; ) for( ;; )
{ {
uint16_t c; uint16_t c = (uint8_t)*str++;
c = (uint8_t)*str++;
bo_addle_u16( bo, c ); bo_addle_u16( bo, c );
if( c == '\0' ) if( c == '\0' ) break;
{
break;
}
} }
} }
...@@ -704,14 +695,9 @@ static void bo_addle_str16_nosize( bo_t *bo, char *str ) ...@@ -704,14 +695,9 @@ static void bo_addle_str16_nosize( bo_t *bo, char *str )
{ {
for( ;; ) for( ;; )
{ {
uint16_t c; uint16_t c = (uint8_t)*str++;
c = (uint8_t)*str++;
bo_addle_u16( bo, c ); bo_addle_u16( bo, c );
if( c == '\0' ) if( c == '\0' ) break;
{
break;
}
} }
} }
...@@ -744,7 +730,6 @@ static const guid_t asf_object_data_guid = ...@@ -744,7 +730,6 @@ static const guid_t asf_object_data_guid =
0x11CF, 0x11CF,
{ 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C } { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
}; };
static const guid_t asf_object_file_properties_guid = static const guid_t asf_object_file_properties_guid =
{ {
0x8cabdca1, 0x8cabdca1,
...@@ -768,7 +753,6 @@ static const guid_t asf_object_header_extention_guid = ...@@ -768,7 +753,6 @@ static const guid_t asf_object_header_extention_guid =
0x11CF, 0x11CF,
{ 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 } { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
}; };
static const guid_t asf_object_stream_type_audio = static const guid_t asf_object_stream_type_audio =
{ {
0xF8699E40, 0xF8699E40,
...@@ -838,8 +822,7 @@ static void asf_chunk_add( bo_t *bo, ...@@ -838,8 +822,7 @@ static void asf_chunk_add( bo_t *bo,
bo_addle_u16( bo, i_len + 8 ); bo_addle_u16( bo, i_len + 8 );
} }
static block_t *asf_header_create( sout_mux_t *p_mux, static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
vlc_bool_t b_broadcast )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
asf_track_t *tk; asf_track_t *tk;
...@@ -855,10 +838,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, ...@@ -855,10 +838,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux,
if( p_sys->i_dts_first > 0 ) if( p_sys->i_dts_first > 0 )
{ {
i_duration = p_sys->i_dts_last - p_sys->i_dts_first; i_duration = p_sys->i_dts_last - p_sys->i_dts_first;
if( i_duration < 0 ) if( i_duration < 0 ) i_duration = 0;
{
i_duration = 0;
}
} }
/* calculate header size */ /* calculate header size */
...@@ -877,6 +857,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, ...@@ -877,6 +857,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux,
i_ci_size += 6; i_ci_size += 6;
} }
} }
if( *p_sys->psz_title || *p_sys->psz_author || *p_sys->psz_copyright || if( *p_sys->psz_title || *p_sys->psz_author || *p_sys->psz_copyright ||
*p_sys->psz_comment || *p_sys->psz_rating ) *p_sys->psz_comment || *p_sys->psz_rating )
{ {
...@@ -900,6 +881,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, ...@@ -900,6 +881,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux,
out = block_New( p_mux, i_size + 50 ); out = block_New( p_mux, i_size + 50 );
bo_init( &bo, out->p_buffer, i_size + 50 ); bo_init( &bo, out->p_buffer, i_size + 50 );
} }
/* header object */ /* header object */
bo_add_guid ( &bo, &asf_object_header_guid ); bo_add_guid ( &bo, &asf_object_header_guid );
bo_addle_u64( &bo, i_size ); bo_addle_u64( &bo, i_size );
...@@ -1031,15 +1013,13 @@ static block_t *asf_packet_create( sout_mux_t *p_mux, ...@@ -1031,15 +1013,13 @@ static block_t *asf_packet_create( sout_mux_t *p_mux,
if( p_sys->pk == NULL ) if( p_sys->pk == NULL )
{ {
p_sys->pk = block_New( p_mux, p_sys->pk = block_New( p_mux, p_sys->i_packet_size + i_preheader );
p_sys->i_packet_size + i_preheader);
/* reserve 14 bytes for the packet header */ /* reserve 14 bytes for the packet header */
p_sys->i_pk_used = 14 + i_preheader; p_sys->i_pk_used = 14 + i_preheader;
p_sys->i_pk_frame = 0; p_sys->i_pk_frame = 0;
p_sys->i_pk_dts = data->i_dts; p_sys->i_pk_dts = data->i_dts;
} }
bo_init( &bo, &p_sys->pk->p_buffer[p_sys->i_pk_used], bo_init( &bo, &p_sys->pk->p_buffer[p_sys->i_pk_used],
p_sys->i_packet_size - p_sys->i_pk_used ); p_sys->i_packet_size - p_sys->i_pk_used );
...@@ -1068,15 +1048,15 @@ static block_t *asf_packet_create( sout_mux_t *p_mux, ...@@ -1068,15 +1048,15 @@ static block_t *asf_packet_create( sout_mux_t *p_mux,
if( p_sys->b_asf_http ) if( p_sys->b_asf_http )
{ {
asf_chunk_add( &bo, 0x4424, asf_chunk_add( &bo, 0x4424, p_sys->i_packet_size,
p_sys->i_packet_size, 0x00, p_sys->i_seq++); 0x00, p_sys->i_seq++);
} }
bo_add_u8 ( &bo, 0x82 ); bo_add_u8 ( &bo, 0x82 );
bo_addle_u16( &bo, 0 ); bo_addle_u16( &bo, 0 );
bo_add_u8( &bo, 0x11 ); bo_add_u8( &bo, 0x11 );
bo_add_u8( &bo, 0x5d ); bo_add_u8( &bo, 0x5d );
bo_addle_u16( &bo, i_pad ); bo_addle_u16( &bo, i_pad );
bo_addle_u32( &bo, ( p_sys->i_pk_dts - p_sys->i_dts_first )/ 1000 ); bo_addle_u32( &bo, ( p_sys->i_pk_dts - p_sys->i_dts_first )/1000 );
bo_addle_u16( &bo, 0 * data->i_length / 1000 ); bo_addle_u16( &bo, 0 * data->i_length / 1000 );
bo_add_u8( &bo, 0x80 | p_sys->i_pk_frame ); bo_add_u8( &bo, 0x80 | p_sys->i_pk_frame );
...@@ -1109,5 +1089,6 @@ static block_t *asf_stream_end_create( sout_mux_t *p_mux ) ...@@ -1109,5 +1089,6 @@ static block_t *asf_stream_end_create( sout_mux_t *p_mux )
bo_init( &bo, out->p_buffer, 12 ); bo_init( &bo, out->p_buffer, 12 );
asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ ); asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ );
} }
return out; return out;
} }
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