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

Better packetizer helpers

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