/*****************************************************************************
* asf.c: asf muxer module for vlc
*****************************************************************************
- * Copyright (C) 2003-2004, 2006 the VideoLAN team
+ * Copyright (C) 2003-2004, 2006 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
# include "config.h"
#endif
+#include <assert.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <vlc_codecs.h>
+#include <vlc_arrays.h>
+#include <vlc_rand.h>
-typedef GUID guid_t;
+#include "../demux/asf/libasf_guid.h"
#define MAX_ASF_TRACKS 128
#define ASF_DATA_PACKET_SIZE 4096 // deprecated -- added sout-asf-packet-size
set_shortname( "ASF" )
set_capability( "sout mux", 5 )
- add_shortcut( "asf" )
- add_shortcut( "asfh" )
+ add_shortcut( "asf", "asfh" )
set_callbacks( Open, Close )
- add_string( SOUT_CFG_PREFIX "title", "", NULL, TITLE_TEXT, TITLE_LONGTEXT,
+ add_string( SOUT_CFG_PREFIX "title", "", TITLE_TEXT, TITLE_LONGTEXT,
true )
- add_string( SOUT_CFG_PREFIX "author", "", NULL, AUTHOR_TEXT,
+ add_string( SOUT_CFG_PREFIX "author", "", AUTHOR_TEXT,
AUTHOR_LONGTEXT, true )
- add_string( SOUT_CFG_PREFIX "copyright","", NULL, COPYRIGHT_TEXT,
+ add_string( SOUT_CFG_PREFIX "copyright","", COPYRIGHT_TEXT,
COPYRIGHT_LONGTEXT, true )
- add_string( SOUT_CFG_PREFIX "comment", "", NULL, COMMENT_TEXT,
+ add_string( SOUT_CFG_PREFIX "comment", "", COMMENT_TEXT,
COMMENT_LONGTEXT, true )
- add_string( SOUT_CFG_PREFIX "rating", "", NULL, RATING_TEXT,
+ add_string( SOUT_CFG_PREFIX "rating", "", RATING_TEXT,
RATING_LONGTEXT, true )
- add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT,
+ add_integer( SOUT_CFG_PREFIX "packet-size", 4096, PACKETSIZE_TEXT,
PACKETSIZE_LONGTEXT, true )
- add_integer( SOUT_CFG_PREFIX "bitrate-override", 0, NULL, BITRATE_TEXT,
+ add_integer( SOUT_CFG_PREFIX "bitrate-override", 0, BITRATE_TEXT,
BITRATE_LONGTEXT, true )
vlc_module_end ()
int64_t i_bitrate;
int64_t i_bitrate_override;
- int i_track;
- asf_track_t track[MAX_ASF_TRACKS];
+ vlc_array_t *p_tracks;
- bool b_write_header;
+ bool b_write_header;
block_t *pk;
int i_pk_used;
char *psz_rating;
};
-static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts );
-
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 *);
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys;
- vlc_value_t val;
- int i;
msg_Dbg( p_mux, "asf muxer opened" );
config_ChainParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg );
p_sys->pk = NULL;
p_sys->i_pk_used = 0;
p_sys->i_pk_frame = 0;
- p_sys->i_dts_first = -1;
- p_sys->i_dts_last = 0;
+ p_sys->i_dts_first =
+ p_sys->i_dts_last = VLC_TS_INVALID;
p_sys->i_preroll_time = 2000;
p_sys->i_bitrate = 0;
p_sys->i_bitrate_override = 0;
p_sys->i_seq = 0;
+ p_sys->p_tracks = vlc_array_new();
p_sys->b_write_header = true;
- p_sys->i_track = 0;
- p_sys->i_packet_size = config_GetInt( p_mux, "sout-asf-packet-size" );
- p_sys->i_bitrate_override = config_GetInt( p_mux, "sout-asf-bitrate-override" );
+ p_sys->i_packet_size = var_InheritInteger( p_mux, "sout-asf-packet-size" );
+ p_sys->i_bitrate_override = var_InheritInteger( p_mux, "sout-asf-bitrate-override" );
msg_Dbg( p_mux, "Packet size %d", p_sys->i_packet_size);
if (p_sys->i_bitrate_override)
msg_Dbg( p_mux, "Bitrate override %"PRId64, p_sys->i_bitrate_override);
p_sys->i_packet_count= 0;
/* Generate a random fid */
- srand( mdate() & 0xffffffff );
p_sys->fid.Data1 = 0xbabac001;
- p_sys->fid.Data2 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
- p_sys->fid.Data3 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
- for( i = 0; i < 8; i++ )
- {
- p_sys->fid.Data4[i] = ( (uint64_t)rand() << 8 ) / RAND_MAX;
- }
+ vlc_rand_bytes(&p_sys->fid.Data2, sizeof(p_sys->fid.Data2));
+ vlc_rand_bytes(&p_sys->fid.Data3, sizeof(p_sys->fid.Data3));
+ vlc_rand_bytes(p_sys->fid.Data4, sizeof(p_sys->fid.Data4));
/* Meta data */
- var_Get( p_mux, SOUT_CFG_PREFIX "title", &val );
- p_sys->psz_title = val.psz_string;
-
- var_Get( p_mux, SOUT_CFG_PREFIX "author", &val );
- p_sys->psz_author = val.psz_string;
-
- var_Get( p_mux, SOUT_CFG_PREFIX "copyright", &val );
- p_sys->psz_copyright = val.psz_string;
-
- var_Get( p_mux, SOUT_CFG_PREFIX "comment", &val );
- p_sys->psz_comment = val.psz_string;
-
- var_Get( p_mux, SOUT_CFG_PREFIX "rating", &val );
- p_sys->psz_rating = val.psz_string;
+ p_sys->psz_title = var_GetString( p_mux, SOUT_CFG_PREFIX "title" );
+ p_sys->psz_author = var_GetString( p_mux, SOUT_CFG_PREFIX "author" );
+ p_sys->psz_copyright = var_GetString( p_mux, SOUT_CFG_PREFIX "copyright" );
+ p_sys->psz_comment = var_GetString( p_mux, SOUT_CFG_PREFIX "comment" );
+ p_sys->psz_rating = var_GetString( p_mux, SOUT_CFG_PREFIX "rating" );
msg_Dbg( p_mux, "meta data: title='%s', author='%s', copyright='%s', "
"comment='%s', rating='%s'",
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
block_t *out;
- int i;
msg_Dbg( p_mux, "Asf muxer closed" );
sout_AccessOutWrite( p_mux->p_access, out );
}
- for( i = 0; i < p_sys->i_track; i++ )
+
+ for( int i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- free( p_sys->track[i].p_extra );
- es_format_Clean( &p_sys->track[i].fmt );
+ asf_track_t *track = (asf_track_t *)vlc_array_item_at_index( p_sys->p_tracks, i );
+ free( track->p_extra );
+ es_format_Clean( &track->fmt );
}
+ vlc_array_clear( p_sys->p_tracks );
+
+ vlc_array_destroy( p_sys->p_tracks );
+
free( p_sys->psz_title );
free( p_sys->psz_author );
free( p_sys->psz_copyright );
bo_t bo;
msg_Dbg( p_mux, "adding input" );
- if( p_sys->i_track >= MAX_ASF_TRACKS )
+ if( vlc_array_count( p_sys->p_tracks ) >= MAX_ASF_TRACKS )
{
msg_Dbg( p_mux, "cannot add this track (too much tracks)" );
return VLC_EGENERIC;
}
- tk = p_input->p_sys = &p_sys->track[p_sys->i_track];
- tk->i_id = p_sys->i_track + 1;
+ tk = p_input->p_sys = malloc( sizeof( asf_track_t ) );
+ memset( tk, 0, sizeof( *tk ) );
tk->i_cat = p_input->p_fmt->i_cat;
tk->i_sequence = 0;
tk->b_audio_correction = 0;
tk->psz_name = "MSMPEG-4 V2 Video";
tk->i_fourcc = VLC_FOURCC( 'M', 'P', '4', '2' );
}
- else if( p_input->p_fmt->i_codec == VLC_CODEC_DIV2 )
+ else if( p_input->p_fmt->i_codec == VLC_CODEC_DIV1 )
{
tk->psz_name = "MSMPEG-4 V1 Video";
tk->i_fourcc = VLC_FOURCC( 'M', 'P', 'G', '4' );
{
tk->psz_name = "Windows Media Video 9";
tk->i_fourcc = VLC_FOURCC( 'W', 'M', 'V', '3' );
+ tk->b_extended = true;
}
else if( p_input->p_fmt->i_codec == VLC_CODEC_VC1 )
{
}
}
- tk->i_extra = 11 + sizeof( BITMAPINFOHEADER ) + i_codec_extra;
+ tk->i_extra = 11 + sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra;
tk->p_extra = malloc( tk->i_extra );
if( !tk->p_extra )
{
bo_addle_u32( &bo, p_input->p_fmt->video.i_width );
bo_addle_u32( &bo, p_input->p_fmt->video.i_height );
bo_add_u8 ( &bo, 0x02 ); /* flags */
- bo_addle_u16( &bo, sizeof( BITMAPINFOHEADER ) + i_codec_extra );
- bo_addle_u32( &bo, sizeof( BITMAPINFOHEADER ) + i_codec_extra );
+ bo_addle_u16( &bo, sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra );
+ bo_addle_u32( &bo, sizeof( VLC_BITMAPINFOHEADER ) + i_codec_extra );
bo_addle_u32( &bo, p_input->p_fmt->video.i_width );
bo_addle_u32( &bo, p_input->p_fmt->video.i_height );
bo_addle_u16( &bo, 1 );
es_format_Copy( &tk->fmt, p_input->p_fmt );
- p_sys->i_track++;
+ vlc_array_append( p_sys->p_tracks, (void *)tk);
+ tk->i_id = vlc_array_index_of_item( p_sys->p_tracks, tk ) + 1;
+
+
+ if( p_sys->b_asf_http )
+ p_sys->b_write_header = true;
+
return VLC_SUCCESS;
}
*****************************************************************************/
static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
- /* if bitrate ain't defined in commanline, reduce it when tracks are deleted
+ /* if bitrate ain't defined in commandline, reduce it when tracks are deleted
*/
sout_mux_sys_t *p_sys = p_mux->p_sys;
asf_track_t *tk = p_input->p_sys;
+ msg_Dbg( p_mux, "removing input" );
if(!p_sys->i_bitrate_override)
{
if( tk->i_cat == AUDIO_ES )
p_sys->i_bitrate -= 512000;
}
}
- msg_Dbg( p_mux, "removing input" );
+
+ if( p_sys->b_asf_http )
+ {
+ vlc_array_remove( p_sys->p_tracks, vlc_array_index_of_item( p_sys->p_tracks, (void *)tk ) );
+ p_sys->b_write_header = true;
+ }
return VLC_SUCCESS;
}
{
sout_input_t *p_input;
asf_track_t *tk;
- int i_stream;
mtime_t i_dts;
block_t *data;
block_t *pk;
- if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
+ int i_stream = sout_MuxGetStream( p_mux, 1, &i_dts );
+ if( i_stream < 0 )
{
/* not enough data */
return VLC_SUCCESS;
}
- if( p_sys->i_dts_first < 0 )
+ if( p_sys->i_dts_first <= VLC_TS_INVALID )
{
p_sys->i_dts_first = i_dts;
}
return VLC_SUCCESS;
}
-static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
-{
- mtime_t i_dts;
- int i_stream;
- int i;
-
- for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
- {
- sout_input_t *p_input = p_mux->pp_inputs[i];
- block_t *p_data;
-
- 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 )
- {
- /* We need that audio+video fifo contain at least 1 packet */
- return VLC_EGENERIC;
- }
- /* SPU */
- continue;
- }
-
- p_data = block_FifoShow( p_input->p_fifo );
- if( i_stream == -1 || p_data->i_dts < i_dts )
- {
- i_stream = i;
- i_dts = p_data->i_dts;
- }
- }
-
- *pi_stream = i_stream;
- *pi_dts = i_dts;
-
- return VLC_SUCCESS;
-}
-
/****************************************************************************
* Asf header construction
****************************************************************************/
****************************************************************************/
static void bo_add_guid( bo_t *p_bo, const guid_t *id )
{
- int i;
bo_addle_u32( p_bo, id->Data1 );
bo_addle_u16( p_bo, id->Data2 );
bo_addle_u16( p_bo, id->Data3 );
- for( i = 0; i < 8; i++ )
+ for( int i = 0; i < 8; i++ )
{
bo_add_u8( p_bo, id->Data4[i] );
}
}
-static const guid_t asf_object_header_guid =
-{0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
-static const guid_t asf_object_data_guid =
-{0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
-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_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}};
-static const guid_t asf_object_stream_type_video =
-{0xbc19efc0, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
-static const guid_t asf_guid_audio_conceal_none =
-{0x20FB5700, 0x5B55, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
-static const guid_t asf_guid_audio_conceal_spread =
-{0xBFC3CD50, 0x618F, 0x11CF, {0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20}};
-static const guid_t asf_guid_video_conceal_none =
-{0x20FB5700, 0x5B55, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
-static const guid_t asf_guid_reserved_1 =
-{0xABD3D211, 0xA9BA, 0x11cf, {0x8E, 0xE6, 0x00, 0xC0, 0x0C ,0x20, 0x53, 0x65}};
-static const guid_t asf_object_codec_list_guid =
-{0x86D15240, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
-static const guid_t asf_object_codec_list_reserved_guid =
-{0x86D15241, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
-static const guid_t asf_object_content_description_guid =
-{0x75B22633, 0x668E, 0x11CF, {0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}};
-static const guid_t asf_object_index_guid =
-{0x33000890, 0xE5B1, 0x11CF, {0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}};
-static const guid_t asf_object_metadata_guid =
-{0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}};
-static const guid_t asf_object_extended_stream_properties_guid =
-{0x14E6A5CB, 0xC672, 0x4332, {0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A}};
-
/****************************************************************************
* Misc
****************************************************************************/
int i_ci_size, i_cm_size = 0, i_cd_size = 0;
block_t *out;
bo_t bo;
+ tk=NULL;
msg_Dbg( p_mux, "Asf muxer creating header" );
- if( p_sys->i_dts_first > 0 )
+ if( p_sys->i_dts_first > VLC_TS_INVALID )
{
i_duration = p_sys->i_dts_last - p_sys->i_dts_first;
if( i_duration < 0 ) i_duration = 0;
/* calculate header size */
i_size = 30 + 104;
i_ci_size = 44;
- for( i = 0; i < p_sys->i_track; i++ )
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- i_size += 78 + p_sys->track[i].i_extra;
- i_ci_size += 8 + 2 * strlen( p_sys->track[i].psz_name );
- if( p_sys->track[i].i_cat == AUDIO_ES ) i_ci_size += 4;
- else if( p_sys->track[i].i_cat == VIDEO_ES ) i_ci_size += 6;
+ tk = vlc_array_item_at_index( p_sys->p_tracks, i );
+ /* update also track-id */
+ tk->i_id = i + 1;
+
+ i_size += 78 + tk->i_extra;
+ i_ci_size += 8 + 2 * strlen( tk->psz_name );
+ if( tk->i_cat == AUDIO_ES ) i_ci_size += 4;
+ else if( tk->i_cat == VIDEO_ES ) i_ci_size += 6;
/* Error correction data field */
- if( p_sys->track[i].b_audio_correction ) i_size += 8;
+ if( tk->b_audio_correction ) i_size += 8;
}
/* size of the content description object */
i_header_ext_size = 46;
/* size of the metadata object */
- for( i = 0; i < p_sys->i_track; i++ )
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- const asf_track_t *p_track = &p_sys->track[i];
- if( p_track->i_cat == VIDEO_ES && p_track->fmt.video.i_aspect != 0 )
+ const asf_track_t *p_track = vlc_array_item_at_index( p_sys->p_tracks, i );
+ if( p_track->i_cat == VIDEO_ES &&
+ p_track->fmt.video.i_sar_num != 0 &&
+ p_track->fmt.video.i_sar_den != 0 )
{
i_cm_size = 26 + 2 * (16 + 2 * sizeof("AspectRatio?"));
- break;
}
if( p_track->b_extended )
i_header_ext_size += 88;
if( p_sys->b_asf_http )
{
- out = block_New( p_mux, i_size + 50 + 12 );
+ out = block_Alloc( i_size + 50 + 12 );
bo_init( &bo, out->p_buffer, i_size + 50 + 12 );
asf_chunk_add( &bo, 0x4824, i_size + 50, 0xc00, p_sys->i_seq++ );
}
else
{
- out = block_New( p_mux, i_size + 50 );
+ out = block_Alloc( i_size + 50 );
bo_init( &bo, out->p_buffer, i_size + 50 );
}
/* header object */
bo_add_guid ( &bo, &asf_object_header_guid );
bo_addle_u64( &bo, i_size );
- bo_addle_u32( &bo, 2 + p_sys->i_track +
+ bo_addle_u32( &bo, 2 + vlc_array_count( p_sys->p_tracks ) + 1 +
(i_cd_size ? 1 : 0) + (i_cm_size ? 1 : 0) );
bo_add_u8 ( &bo, 1 );
bo_add_u8 ( &bo, 2 );
bo_addle_u32( &bo, b_broadcast ? 0x01 : 0x02 /* seekable */ ); /* flags */
bo_addle_u32( &bo, p_sys->i_packet_size ); /* packet size min */
bo_addle_u32( &bo, p_sys->i_packet_size ); /* packet size max */
- bo_addle_u32( &bo, p_sys->i_bitrate ); /* maxbitrate */
+ /* NOTE: According to p6-9 of the ASF specification the bitrate cannot be 0,
+ * therefor apply this workaround to make sure it is not 0. If the bitrate is
+ * 0 the file will play in WMP11, but not in Sliverlight and WMP12 */
+ bo_addle_u32( &bo, p_sys->i_bitrate > 0 ? p_sys->i_bitrate : 1 ); /* maxbitrate */
/* header extension */
bo_add_guid ( &bo, &asf_object_header_extension_guid );
bo_addle_u32( &bo, i_header_ext_size - 46 );
/* extended stream properties */
- for( i = 0; i < p_sys->i_track; i++ )
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- const asf_track_t *p_track = &p_sys->track[i];
+ const asf_track_t *p_track = vlc_array_item_at_index( p_sys->p_tracks, i );
const es_format_t *p_fmt = &p_track->fmt;
if( !p_track->b_extended )
bo_addle_u64( &bo, 0 );
bo_addle_u64( &bo, 0 );
bo_addle_u32( &bo, p_fmt->i_bitrate ); /* Bitrate */
- bo_addle_u32( &bo, 0 ); /* Buffer size */
+ bo_addle_u32( &bo, p_sys->i_preroll_time ); /* Buffer size */
bo_addle_u32( &bo, 0 ); /* Initial buffer fullness */
bo_addle_u32( &bo, p_fmt->i_bitrate ); /* Alternate Bitrate */
bo_addle_u32( &bo, 0 ); /* Alternate Buffer size */
bo_addle_u32( &bo, 0 ); /* Alternate Initial buffer fullness */
- bo_addle_u32( &bo, 0 ); /* Maximum object size (0 = unkown) */
+ bo_addle_u32( &bo, 0 ); /* Maximum object size (0 = unknown) */
bo_addle_u32( &bo, 0x02 ); /* Flags (seekable) */
- bo_addle_u16( &bo, i+1 ); /* Stream number */
+ bo_addle_u16( &bo, p_track->i_id ); /* Stream number */
bo_addle_u16( &bo, 0 ); /* Stream language index */
bo_addle_u64( &bo, i_avg_duration ); /* Average time per frame */
bo_addle_u16( &bo, 0 ); /* Stream name count */
/* metadata object (part of header extension) */
if( i_cm_size )
{
- int64_t i_num, i_den;
unsigned int i_dst_num, i_dst_den;
- for( i = 0; i < p_sys->i_track; i++ )
- if( p_sys->track[i].i_cat == VIDEO_ES ) break;
+ asf_track_t *tk = NULL;
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
+ {
+ tk = vlc_array_item_at_index( p_sys->p_tracks, i );
+ if( tk->i_cat == VIDEO_ES &&
+ tk->fmt.video.i_sar_num != 0 &&
+ tk->fmt.video.i_sar_den != 0 )
+ break;
+ }
+ assert( tk != NULL );
- i_num = p_sys->track[i].fmt.video.i_aspect *
- (int64_t)p_sys->track[i].fmt.video.i_height;
- i_den = VOUT_ASPECT_FACTOR * p_sys->track[i].fmt.video.i_width;
- vlc_ureduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
+ vlc_ureduce( &i_dst_num, &i_dst_den,
+ tk->fmt.video.i_sar_num,
+ tk->fmt.video.i_sar_den, 0 );
msg_Dbg( p_mux, "pixel aspect-ratio: %i/%i", i_dst_num, i_dst_den );
bo_addle_u16( &bo, 2 ); /* description records count */
/* 1st description record */
bo_addle_u16( &bo, 0 ); /* reserved */
- bo_addle_u16( &bo, i + 1 ); /* stream number (0 for the whole file) */
+ bo_addle_u16( &bo, tk->i_id ); /* stream number (0 for the whole file) */
bo_addle_u16( &bo, 2 * sizeof("AspectRatioX") ); /* name length */
bo_addle_u16( &bo, 0x3 /* DWORD */ ); /* data type */
bo_addle_u32( &bo, 4 ); /* data length */
bo_addle_u32( &bo, i_dst_num ); /* data */
/* 2nd description record */
bo_addle_u16( &bo, 0 ); /* reserved */
- bo_addle_u16( &bo, i + 1 ); /* stream number (0 for the whole file) */
+ bo_addle_u16( &bo, tk->i_id ); /* stream number (0 for the whole file) */
bo_addle_u16( &bo, 2 * sizeof("AspectRatioY") ); /* name length */
bo_addle_u16( &bo, 0x3 /* DWORD */ ); /* data type */
bo_addle_u32( &bo, 4 ); /* data length */
}
/* stream properties */
- for( i = 0; i < p_sys->i_track; i++ )
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- tk = &p_sys->track[i];
+ tk = vlc_array_item_at_index( p_sys->p_tracks, i);
bo_add_guid ( &bo, &asf_object_stream_properties_guid );
bo_addle_u64( &bo, 78 + tk->i_extra + (tk->b_audio_correction ? 8:0) );
if( tk->b_audio_correction )
bo_add_guid( &bo, &asf_guid_audio_conceal_spread );
else
- bo_add_guid( &bo, &asf_guid_audio_conceal_none );
+ bo_add_guid( &bo, &asf_no_error_correction_guid );
}
else if( tk->i_cat == VIDEO_ES )
{
bo_add_guid( &bo, &asf_object_stream_type_video );
- bo_add_guid( &bo, &asf_guid_video_conceal_none );
+ bo_add_guid( &bo, &asf_no_error_correction_guid );
}
bo_addle_u64( &bo, 0 ); /* time offset */
bo_addle_u32( &bo, tk->i_extra );
/* Codec Infos */
bo_add_guid ( &bo, &asf_object_codec_list_guid );
bo_addle_u64( &bo, i_ci_size );
- bo_add_guid ( &bo, &asf_object_codec_list_reserved_guid );
- bo_addle_u32( &bo, p_sys->i_track );
- for( i = 0; i < p_sys->i_track; i++ )
+ bo_add_guid ( &bo, &asf_guid_reserved_2 );
+ bo_addle_u32( &bo, vlc_array_count( p_sys->p_tracks ) );
+ for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
{
- tk = &p_sys->track[i];
+ tk = vlc_array_item_at_index( p_sys->p_tracks ,i);
if( tk->i_cat == VIDEO_ES ) bo_addle_u16( &bo, 1 /* video */ );
else if( tk->i_cat == AUDIO_ES ) bo_addle_u16( &bo, 2 /* audio */ );
if( p_sys->pk == NULL )
{
- p_sys->pk = block_New( p_mux, p_sys->i_packet_size + i_preheader );
+ p_sys->pk = block_Alloc( p_sys->i_packet_size + i_preheader );
/* reserve 14 bytes for the packet header */
p_sys->i_pk_used = 14 + i_preheader;
p_sys->i_pk_frame = 0;
if( p_sys->b_asf_http )
{
- out = block_New( p_mux, 12 );
+ out = block_Alloc( 12 );
bo_init( &bo, out->p_buffer, 12 );
asf_chunk_add( &bo, 0x4524, 0, 0x00, p_sys->i_seq++ );
}
else
{
/* Create index */
- out = block_New( p_mux, 56 );
+ out = block_Alloc( 56 );
bo_init( &bo, out->p_buffer, 56 );
bo_add_guid ( &bo, &asf_object_index_guid );
bo_addle_u64( &bo, 56 );