Commit f6ef9859 authored by Clément Stenac's avatar Clément Stenac

Better packetizer helpers

parent f0ddd615
......@@ -199,25 +199,31 @@ static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested )
if( stream_Peek( p_demux->s , &p_peek, size ) < size ) return VLC_EGENERIC;}
#define POKE( peek, stuff, size ) (strncasecmp( (char *)peek, stuff, size )==0)
#define CREATE_PACKETIZER( a,b,c,d ) \
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER ); \
p_sys->p_packetizer->pf_decode_audio = 0; \
p_sys->p_packetizer->pf_decode_video = 0; \
p_sys->p_packetizer->pf_decode_sub = 0; \
p_sys->p_packetizer->pf_packetize = 0; \
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES, \
#define COMMON_INIT_PACKETIZER( location ) \
location = vlc_object_create( p_demux, VLC_OBJECT_DECODER ); \
location->pf_decode_audio = 0; \
location->pf_decode_video = 0; \
location->pf_decode_sub = 0; \
location->pf_packetize = 0; \
#define INIT_APACKETIZER( location, a,b,c,d ) \
COMMON_INIT_PACKETIZER(location ); \
es_format_Init( &location->fmt_in, AUDIO_ES, \
VLC_FOURCC( a, b, c, d ) );
#define INIT_VPACKETIZER( location, a,b,c,d ) \
COMMON_INIT_PACKETIZER(location ); \
es_format_Init( &location->fmt_in, VIDEO_ES, \
VLC_FOURCC( a, b, c, d ) );
/* BEWARE ! This can lead to memory leaks ! */
#define LOAD_PACKETIZER_OR_FAIL( msg ) \
p_sys->p_packetizer->p_module = \
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); \
\
if( p_sys->p_packetizer->p_module == NULL ) \
#define LOAD_PACKETIZER_OR_FAIL( location, msg ) \
location->p_module = \
module_Need( location, "packetizer", NULL, 0 ); \
if( location->p_module == NULL ) \
{ \
vlc_object_destroy( p_sys->p_packetizer ); \
vlc_object_destroy( location ); \
msg_Err( p_demux, "cannot find packetizer for " # msg ); \
free( p_sys ); \
return VLC_EGENERIC; \
......
......@@ -146,23 +146,8 @@ static int Open( vlc_object_t * p_this )
p_sys->b_big_endian = b_big_endian;
/* Load the A52 packetizer */
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER );
p_sys->p_packetizer->pf_decode_audio = 0;
p_sys->p_packetizer->pf_decode_video = 0;
p_sys->p_packetizer->pf_decode_sub = 0;
p_sys->p_packetizer->pf_packetize = 0;
/* Initialization of decoder structure */
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES,
VLC_FOURCC( 'a', '5', '2', ' ' ) );
p_sys->p_packetizer->p_module =
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
if( !p_sys->p_packetizer->p_module )
{
msg_Err( p_demux, "cannot find A52 packetizer" );
return VLC_EGENERIC;
}
INIT_APACKETIZER( p_sys->p_packetizer, 'a', '5', '2', ' ' );
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "A52" );
/* Create one program */
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_in );
......
......@@ -151,8 +151,8 @@ static int Open( vlc_object_t * p_this )
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
INIT_PACKETIZER( 'd','t','s',' ' );
LOAD_PACKETIZER_OR_FAIL( "DTS" );
INIT_APACKETIZER( p_sys->p_packetizer, 'd','t','s',' ' );
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "DTS" );
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_in );
......
......@@ -107,18 +107,8 @@ static int Open( vlc_object_t * p_this )
return VLC_EGENERIC;
}
/*
* Load the FLAC packetizer
*/
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER );
p_sys->p_packetizer->pf_decode_audio = 0;
p_sys->p_packetizer->pf_decode_video = 0;
p_sys->p_packetizer->pf_decode_sub = 0;
p_sys->p_packetizer->pf_packetize = 0;
/* Initialization of decoder structure */
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES,
VLC_FOURCC( 'f', 'l', 'a', 'c' ) );
/* Load the FLAC packetizer */
INIT_APACKETIZER( p_sys->p_packetizer, 'f', 'l', 'a', 'c' );
/* Store STREAMINFO for the decoder and packetizer */
p_sys->p_packetizer->fmt_in.i_extra = fmt.i_extra = STREAMINFO_SIZE + 4;
......
......@@ -106,27 +106,10 @@ static int Open( vlc_object_t * p_this )
p_sys->p_es = NULL;
p_sys->b_start = VLC_TRUE;
/*
* Load the mpeg 4 audio packetizer
*/
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER );
p_sys->p_packetizer->pf_decode_audio = NULL;
p_sys->p_packetizer->pf_decode_video = NULL;
p_sys->p_packetizer->pf_decode_sub = NULL;
p_sys->p_packetizer->pf_packetize = NULL;
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES,
VLC_FOURCC( 'm', 'p', '4', 'a' ) );
/* Load the mpeg 4 audio packetizer */
INIT_APACKETIZER( p_sys->p_packetizer, 'm', 'p', '4', 'a' );
es_format_Init( &p_sys->p_packetizer->fmt_out, UNKNOWN_ES, 0 );
p_sys->p_packetizer->p_module =
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
if( p_sys->p_packetizer->p_module == NULL)
{
vlc_object_destroy( p_sys->p_packetizer );
msg_Err( p_demux, "cannot find mp4a packetizer" );
free( p_sys );
return VLC_EGENERIC;
}
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "mp4 audio" );
return VLC_SUCCESS;
}
......
......@@ -105,31 +105,12 @@ static int Open( vlc_object_t * p_this )
p_sys->b_start = VLC_TRUE;
p_sys->p_es = NULL;
/*
* Load the mpegvideo packetizer
*/
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER );
p_sys->p_packetizer->pf_decode_audio = NULL;
p_sys->p_packetizer->pf_decode_video = NULL;
p_sys->p_packetizer->pf_decode_sub = NULL;
p_sys->p_packetizer->pf_packetize = NULL;
es_format_Init( &p_sys->p_packetizer->fmt_in, VIDEO_ES,
VLC_FOURCC( 'm', 'p', 'g', 'v' ) );
/* Load the mpegvideo packetizer */
INIT_VPACKETIZER( p_sys->p_packetizer, 'm', 'p', 'g', 'v' );
es_format_Init( &p_sys->p_packetizer->fmt_out, UNKNOWN_ES, 0 );
p_sys->p_packetizer->p_module =
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "MPEG Video" );
if( p_sys->p_packetizer->p_module == NULL)
{
vlc_object_destroy( p_sys->p_packetizer );
msg_Err( p_demux, "cannot find mpgv packetizer" );
free( p_sys );
return VLC_EGENERIC;
}
/*
* create the output
*/
/* create the output */
es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( 'm', 'p', 'g', 'v' ) );
p_sys->p_es = es_out_Add( p_demux->out, &fmt );
......
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