# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <vlc_codecs.h>
#define RATING_LONGTEXT N_("\"Rating\" to put in ASF comments." )
#define PACKETSIZE_TEXT N_("Packet Size")
#define PACKETSIZE_LONGTEXT N_("ASF packet size -- default is 4096 bytes")
+#define BITRATE_TEXT N_("Bitrate override")
+#define BITRATE_LONGTEXT N_("Do not try to guess ASF bitrate. Setting this, allows you to control how Windows Media Player will cache streamed content. Set to audio+video bitrate in bytes")
-vlc_module_begin();
- set_description( _("ASF muxer") );
- set_category( CAT_SOUT );
- set_subcategory( SUBCAT_SOUT_MUX );
- set_shortname( "ASF" );
- set_capability( "sout mux", 5 );
- add_shortcut( "asf" );
- add_shortcut( "asfh" );
- set_callbacks( Open, Close );
+vlc_module_begin ()
+ set_description( N_("ASF muxer") )
+ set_category( CAT_SOUT )
+ set_subcategory( SUBCAT_SOUT_MUX )
+ set_shortname( "ASF" )
+
+ set_capability( "sout mux", 5 )
+ add_shortcut( "asf" )
+ add_shortcut( "asfh" )
+ set_callbacks( Open, Close )
add_string( SOUT_CFG_PREFIX "title", "", NULL, TITLE_TEXT, TITLE_LONGTEXT,
- true );
+ true )
add_string( SOUT_CFG_PREFIX "author", "", NULL, AUTHOR_TEXT,
- AUTHOR_LONGTEXT, true );
+ AUTHOR_LONGTEXT, true )
add_string( SOUT_CFG_PREFIX "copyright","", NULL, COPYRIGHT_TEXT,
- COPYRIGHT_LONGTEXT, true );
+ COPYRIGHT_LONGTEXT, true )
add_string( SOUT_CFG_PREFIX "comment", "", NULL, COMMENT_TEXT,
- COMMENT_LONGTEXT, true );
+ COMMENT_LONGTEXT, true )
add_string( SOUT_CFG_PREFIX "rating", "", NULL, RATING_TEXT,
- RATING_LONGTEXT, true );
- add_integer( "sout-asf-packet-size", 4096, NULL, PACKETSIZE_TEXT, PACKETSIZE_LONGTEXT, true );
+ RATING_LONGTEXT, true )
+ add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT,
+ PACKETSIZE_LONGTEXT, true )
+ add_integer( SOUT_CFG_PREFIX "bitrate-override", 0, NULL, BITRATE_TEXT,
+ BITRATE_LONGTEXT, true )
-vlc_module_end();
+vlc_module_end ()
/*****************************************************************************
* Locales prototypes
*****************************************************************************/
-static const char *ppsz_sout_options[] = {
+static const char *const ppsz_sout_options[] = {
"title", "author", "copyright", "comment", "rating", NULL
};
mtime_t i_dts_last;
mtime_t i_preroll_time;
int64_t i_bitrate;
+ int64_t i_bitrate_override;
int i_track;
asf_track_t track[MAX_ASF_TRACKS];
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
+ if( !p_sys )
+ return VLC_ENOMEM;
p_sys->b_asf_http = p_mux->psz_mux && !strcmp( p_mux->psz_mux, "asfh" );
if( p_sys->b_asf_http )
{
p_sys->i_dts_last = 0;
p_sys->i_preroll_time = 2000;
p_sys->i_bitrate = 0;
+ p_sys->i_bitrate_override = 0;
p_sys->i_seq = 0;
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" );
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 */
free( p_sys->track[i].p_extra );
es_format_Clean( &p_sys->track[i].fmt );
}
+
+ free( p_sys->psz_title );
+ free( p_sys->psz_author );
+ free( p_sys->psz_copyright );
+ free( p_sys->psz_comment );
+ free( p_sys->psz_rating );
free( p_sys );
}
tk->i_extra = sizeof( WAVEFORMATEX ) +
p_input->p_fmt->i_extra + i_extra;
tk->p_extra = malloc( tk->i_extra );
+ if( !tk->p_extra )
+ return VLC_ENOMEM;
bo_init( &bo, tk->p_extra, tk->i_extra );
bo_addle_u16( &bo, tk->i_tag );
bo_addle_u16( &bo, p_input->p_fmt->audio.i_channels );
}
else
{
- p_sys->i_bitrate += 512000;
+ p_sys->i_bitrate += 128000;
}
+ if (p_sys->i_bitrate_override)
+ p_sys->i_bitrate = p_sys->i_bitrate_override;
break;
}
case VIDEO_ES:
tk->i_extra = 11 + sizeof( BITMAPINFOHEADER ) +
p_input->p_fmt->i_extra;
tk->p_extra = malloc( tk->i_extra );
+ if( !tk->p_extra )
+ return VLC_ENOMEM;
bo_init( &bo, tk->p_extra, tk->i_extra );
bo_addle_u32( &bo, p_input->p_fmt->video.i_width );
bo_addle_u32( &bo, p_input->p_fmt->video.i_height );
}
else
{
- p_sys->i_bitrate += 1000000;
+ p_sys->i_bitrate += 512000;
}
+ if (p_sys->i_bitrate_override)
+ p_sys->i_bitrate = p_sys->i_bitrate_override;
break;
}
default:
*****************************************************************************/
static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
- VLC_UNUSED(p_input);
+ /* if bitrate ain't defined in commanline, reduce it when tracks are deleted
+ */
+ sout_mux_sys_t *p_sys = p_mux->p_sys;
+ asf_track_t *tk = p_input->p_sys;
+ if(!p_sys->i_bitrate_override)
+ {
+ if( tk->i_cat == AUDIO_ES )
+ {
+ if( p_input->p_fmt->i_bitrate > 24000 )
+ p_sys->i_bitrate -= p_input->p_fmt->i_bitrate;
+ else
+ p_sys->i_bitrate -= 128000;
+ }
+ else if(tk->i_cat == VIDEO_ES )
+ {
+ if( p_input->p_fmt->i_bitrate > 50000 )
+ p_sys->i_bitrate -= p_input->p_fmt->i_bitrate;
+ else
+ p_sys->i_bitrate -= 512000;
+ }
+ }
msg_Dbg( p_mux, "removing input" );
return VLC_SUCCESS;
}