Commit 90a4caea authored by Clément Stenac's avatar Clément Stenac

Some more demux and access code factorization

parent 5e2f8763
...@@ -130,4 +130,32 @@ static inline int access2_Control( access_t *p_access, int i_query, ... ) ...@@ -130,4 +130,32 @@ static inline int access2_Control( access_t *p_access, int i_query, ... )
return i_result; return i_result;
} }
static void inline access_InitFields( access_t *p_a )
{
p_a->info.i_update = 0;
p_a->info.i_size = 0;
p_a->info.i_pos = 0;
p_a->info.b_eof = VLC_FALSE;
p_a->info.i_title = 0;
p_a->info.i_seekpoint = 0;
}
#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
p_access->pf_read = read; \
p_access->pf_block = block; \
p_access->pf_control = control; \
p_access->pf_seek = seek; \
#define STANDARD_READ_ACCESS_INIT \
access_InitFields( p_access ); \
ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
MALLOC_ERR( p_access->p_sys, access_sys_t ); \
p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
#define STANDARD_BLOCK_ACCESS_INIT \
access_InitFields( p_access ); \
ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \
MALLOC_ERR( p_access->p_sys, access_sys_t ); \
p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
#endif #endif
...@@ -155,12 +155,14 @@ static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested ) ...@@ -155,12 +155,14 @@ static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested )
#define STANDARD_DEMUX_INIT \ #define STANDARD_DEMUX_INIT \
p_demux->pf_control = Control; \ p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \ p_demux->pf_demux = Demux; \
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) );
#define STANDARD_DEMUX_INIT_MSG( msg ) \ #define STANDARD_DEMUX_INIT_MSG( msg ) \
p_demux->pf_control = Control; \ p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \ p_demux->pf_demux = Demux; \
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \ MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); \
msg_Dbg( p_demux, msg ); \ msg_Dbg( p_demux, msg ); \
#define DEMUX_BY_EXTENSION( ext ) \ #define DEMUX_BY_EXTENSION( ext ) \
...@@ -229,6 +231,10 @@ static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested ) ...@@ -229,6 +231,10 @@ static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested )
return VLC_EGENERIC; \ return VLC_EGENERIC; \
} }
#define DESTROY_PACKETIZER( location ) \
if( location->p_module ) module_Unneed( location, location->p_module ); \
vlc_object_destroy( location );
/** /**
* @} * @}
*/ */
......
...@@ -174,18 +174,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -174,18 +174,7 @@ static int Open( vlc_object_t *p_this )
free( psz_name ); free( psz_name );
/* Set up p_access */ /* Set up p_access */
p_access->pf_read = NULL; STANDARD_BLOCK_ACCESS_INIT
p_access->pf_block = Block;
p_access->pf_control = Control;
p_access->pf_seek = Seek;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->vcddev = vcddev; p_sys->vcddev = vcddev;
/* We only do separate items if the whole disc is requested - /* We only do separate items if the whole disc is requested -
......
...@@ -142,17 +142,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -142,17 +142,9 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_access, "opening device %s", psz_name ); msg_Dbg( p_access, "opening device %s", psz_name );
/* Set up p_access */ /* Set up p_access */
p_access->pf_read = NULL; access_InitFields( p_access );
p_access->pf_block = Block; ACCESS_SET_CALLBACKS( NULL, Block, Control, NULL );
p_access->pf_control = Control;
p_access->pf_seek = NULL;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.b_prebuffered = VLC_FALSE; p_access->info.b_prebuffered = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
if( !p_sys ) if( !p_sys )
......
...@@ -206,10 +206,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -206,10 +206,7 @@ static int Open( vlc_object_t *p_this )
free( psz_name ); free( psz_name );
/* Fill p_demux field */ /* Fill p_demux field */
p_demux->pf_demux = Demux; STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
p_sys->dvdnav = p_dvdnav; p_sys->dvdnav = p_dvdnav;
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
......
...@@ -246,10 +246,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -246,10 +246,7 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_demux, "VMG opened" ); msg_Dbg( p_demux, "VMG opened" );
/* Fill p_demux field */ /* Fill p_demux field */
p_demux->pf_demux = Demux; STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
p_sys->i_aspect = -1; p_sys->i_aspect = -1;
......
...@@ -92,7 +92,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -92,7 +92,6 @@ static int Open( vlc_object_t *p_this )
{ {
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
vlc_value_t val;
es_format_t fmt; es_format_t fmt;
/* Only when selected */ /* Only when selected */
...@@ -100,27 +99,17 @@ static int Open( vlc_object_t *p_this ) ...@@ -100,27 +99,17 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
/* Set up p_demux */ /* Set up p_demux */
p_demux->pf_demux = Demux; STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
p_demux->pf_control = Control;
p_demux->info.i_update = 0; p_demux->info.i_update = 0;
p_demux->info.i_title = 0; p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0; p_demux->info.i_seekpoint = 0;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
var_Create( p_demux, "fake-duration", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_sys->i_duration = var_CreateGetInteger( p_demux, "fake-duration" ) * 1000;
var_Get( p_demux, "fake-duration", &val ); p_sys->f_fps = var_CreateGetFloat( p_demux, "fake-fps" );
p_sys->i_duration = val.i_int * 1000;
var_Create( p_demux, "fake-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Get( p_demux, "fake-fps", &val );
p_sys->f_fps = val.f_float;
/* Declare the elementary stream */ /* Declare the elementary stream */
es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC('f','a','k','e') ); es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC('f','a','k','e') );
var_Create( p_demux, "fake-id", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); fmt.i_id = var_CreateGetInteger( p_demux, "fake-id" );
var_Get( p_demux, "fake-id", &val );
fmt.i_id = val.i_int;
p_sys->p_es_video = es_out_Add( p_demux->out, &fmt ); p_sys->p_es_video = es_out_Add( p_demux->out, &fmt );
/* Update default_pts to a suitable value for access */ /* Update default_pts to a suitable value for access */
......
...@@ -153,11 +153,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -153,11 +153,8 @@ static int Open( vlc_object_t *p_this )
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
struct stat stat_info; struct stat stat_info;
#endif #endif
vlc_bool_t b_stdin;
file_entry_t * p_file; file_entry_t * p_file;
vlc_bool_t b_stdin = psz_name[0] == '-' && psz_name[1] == '\0';
b_stdin = psz_name[0] == '-' && psz_name[1] == '\0';
if( !b_stdin ) if( !b_stdin )
{ {
...@@ -192,17 +189,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -192,17 +189,7 @@ static int Open( vlc_object_t *p_this )
#endif #endif
} }
p_access->pf_read = Read; STANDARD_READ_ACCESS_INIT;
p_access->pf_block = NULL;
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_sys->i_nb_reads = 0; p_sys->i_nb_reads = 0;
p_sys->b_kfir = VLC_FALSE; p_sys->b_kfir = VLC_FALSE;
p_sys->file = NULL; p_sys->file = NULL;
......
...@@ -207,18 +207,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -207,18 +207,7 @@ static int Open( vlc_object_t *p_this )
char *psz_arg; char *psz_arg;
/* Init p_access */ /* Init p_access */
p_access->pf_read = Read; STANDARD_READ_ACCESS_INIT
p_access->pf_block = NULL;
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->fd_cmd = -1; p_sys->fd_cmd = -1;
p_sys->fd_data = -1; p_sys->fd_data = -1;
......
...@@ -104,20 +104,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -104,20 +104,7 @@ static int Open( vlc_object_t *p_this )
open a file with a valid protocol, try to open at least file:// */ open a file with a valid protocol, try to open at least file:// */
gnome_vfs_open( &p_handle, "file://", 5 ); gnome_vfs_open( &p_handle, "file://", 5 );
p_access->pf_read = Read; STANDARD_READ_ACCESS_INIT;
p_access->pf_block = NULL;
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->p_handle = p_handle; p_sys->p_handle = p_handle;
p_sys->i_nb_reads = 0; p_sys->i_nb_reads = 0;
......
...@@ -161,18 +161,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -161,18 +161,7 @@ static int Open( vlc_object_t *p_this )
char *psz, *p; char *psz, *p;
/* Set up p_access */ /* Set up p_access */
p_access->pf_read = Read; STANDARD_READ_ACCESS_INIT;
p_access->pf_block = NULL;
p_access->pf_control = Control;
p_access->pf_seek = Seek;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->fd = -1; p_sys->fd = -1;
p_sys->b_proxy = VLC_FALSE; p_sys->b_proxy = VLC_FALSE;
p_sys->i_version = 1; p_sys->i_version = 1;
......
...@@ -235,11 +235,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -235,11 +235,12 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_access->info.i_size = 0; /* Init p_access */
STANDARD_READ_ACCESS_INIT;
i_ret = p_smb->fstat( p_smb, p_file, &filestat ); i_ret = p_smb->fstat( p_smb, p_file, &filestat );
if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(errno) ); if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(errno) );
else p_access->info.i_size = filestat.st_size; else p_access->info.i_size = filestat.st_size;
#else #else
#ifndef WIN32 #ifndef WIN32
...@@ -258,7 +259,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -258,7 +259,9 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_access->info.i_size = 0; /* Init p_access */
STANDARD_READ_ACCESS_INIT;
i_ret = smbc_fstat( i_smb, &filestat ); i_ret = smbc_fstat( i_smb, &filestat );
if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(i_ret) ); if( i_ret ) msg_Err( p_access, "stat failed (%s)", strerror(i_ret) );
else p_access->info.i_size = filestat.st_size; else p_access->info.i_size = filestat.st_size;
...@@ -266,19 +269,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -266,19 +269,6 @@ static int Open( vlc_object_t *p_this )
free( psz_uri ); free( psz_uri );
/* Init p_access */
p_access->pf_read = Read;
p_access->pf_block = NULL;
p_access->pf_seek = Seek;
p_access->pf_control = Control;
p_access->info.i_update = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
memset( p_sys, 0, sizeof( access_sys_t ) );
#ifdef USE_CTX #ifdef USE_CTX
p_sys->p_smb = p_smb; p_sys->p_smb = p_smb;
p_sys->p_file = p_file; p_sys->p_file = p_file;
......
...@@ -98,17 +98,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -98,17 +98,10 @@ static int Open( vlc_object_t *p_this )
*psz_parser++ = '\0'; *psz_parser++ = '\0';
/* Init p_access */ /* Init p_access */
p_access->pf_read = Read; access_InitFields( p_access ); \
p_access->pf_block = NULL; ACCESS_SET_CALLBACKS( Read, NULL, Control, NULL ); \
p_access->pf_control = Control; MALLOC_ERR( p_access->p_sys, access_sys_t ); \
p_access->pf_seek = NULL; p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_sys->fd = net_ConnectTCP( p_access, psz_dup, atoi( psz_parser ) ); p_sys->fd = net_ConnectTCP( p_access, psz_dup, atoi( psz_parser ) );
free( psz_dup ); free( psz_dup );
......
...@@ -190,19 +190,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -190,19 +190,11 @@ static int Open( vlc_object_t *p_this )
psz_server_addr, i_server_port, psz_bind_addr, i_bind_port ); psz_server_addr, i_server_port, psz_bind_addr, i_bind_port );
/* Set up p_access */ /* Set up p_access */
p_access->pf_read = NULL; access_InitFields( p_access );
p_access->pf_block = BlockChoose; ACCESS_SET_CALLBACKS( NULL, BlockChoose, Control, NULL );
p_access->pf_control = Control;
p_access->pf_seek = NULL;
p_access->info.i_update = 0;
p_access->info.i_size = 0;
p_access->info.i_pos = 0;
p_access->info.b_eof = VLC_FALSE;
p_access->info.b_prebuffered = VLC_FALSE; p_access->info.b_prebuffered = VLC_FALSE;
p_access->info.i_title = 0; MALLOC_ERR( p_access->p_sys, access_sys_t ); p_sys = p_access->p_sys;
p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_sys->fd = net_OpenUDP( p_access, psz_bind_addr, i_bind_port, p_sys->fd = net_OpenUDP( p_access, psz_bind_addr, i_bind_port,
psz_server_addr, i_server_port ); psz_server_addr, i_server_port );
if( p_sys->fd < 0 ) if( p_sys->fd < 0 )
...@@ -226,7 +218,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -226,7 +218,6 @@ static int Open( vlc_object_t *p_this )
/* Update default_pts to a suitable value for udp access */ /* Update default_pts to a suitable value for udp access */
var_Create( p_access, "udp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_access, "udp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
/* RTP reordering for out-of-sequence packets */ /* RTP reordering for out-of-sequence packets */
p_sys->i_rtp_late = var_CreateGetInteger( p_access, "rtp-late" ) * 1000; p_sys->i_rtp_late = var_CreateGetInteger( p_access, "rtp-late" ) * 1000;
p_sys->i_last_seqno = 0; p_sys->i_last_seqno = 0;
......
...@@ -163,12 +163,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -163,12 +163,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
/* Unneed module */ DESTROY_PACKETIZER( p_sys->p_packetizer );
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module );
/* Delete the decoder */
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -167,11 +167,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -167,11 +167,7 @@ static void Close( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
/* Unneed module */ DESTROY_PACKETIZER( p_sys->p_packetizer );
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module );
/* Delete the decoder */
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -118,27 +118,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -118,27 +118,10 @@ static int Open( vlc_object_t * p_this )
} }
msg_Dbg( p_demux, "using %.2f fps", p_sys->f_fps ); msg_Dbg( p_demux, "using %.2f fps", p_sys->f_fps );
/* /* Load the mpegvideo packetizer */
* Load the mpegvideo packetizer INIT_VPACKETIZER( p_sys->p_packetizer, 'h', '2', '6', '4' );
*/
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( 'h', '2', '6', '4' ) );
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, "H264" );
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 mp4v packetizer" );
free( p_sys );
return VLC_EGENERIC;
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -151,8 +134,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -151,8 +134,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); DESTROY_PACKETIZER( p_sys->p_packetizer );
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -122,8 +122,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -122,8 +122,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); DESTROY_PACKETIZER( p_sys->p_packetizer );
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -104,27 +104,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -104,27 +104,11 @@ static int Open( vlc_object_t * p_this )
p_sys->p_es = NULL; p_sys->p_es = NULL;
p_sys->i_dts = 1; p_sys->i_dts = 1;
/* /* Load the mpeg4video packetizer */
* Load the mpegvideo packetizer INIT_VPACKETIZER( p_sys->p_packetizer, 'm', 'p', '4', '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', '4', '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 =
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "mpeg4 video" );
if( p_sys->p_packetizer->p_module == NULL)
{
vlc_object_destroy( p_sys->p_packetizer );
msg_Err( p_demux, "cannot find mp4v packetizer" );
free( p_sys );
return VLC_EGENERIC;
}
/* We need to wait until we gtt p_extra (VOL header) from the packetizer /* We need to wait until we gtt p_extra (VOL header) from the packetizer
* before we create the output */ * before we create the output */
...@@ -140,8 +124,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -140,8 +124,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); DESTROY_PACKETIZER( p_sys->p_packetizer) ;
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -157,35 +157,16 @@ static int Open( vlc_object_t * p_this ) ...@@ -157,35 +157,16 @@ static int Open( vlc_object_t * p_this )
if( !b_ok && !p_demux->b_force ) return VLC_EGENERIC; if( !b_ok && !p_demux->b_force ) return VLC_EGENERIC;
} }
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
memset( p_sys, 0, sizeof( demux_sys_t ) ); memset( p_sys, 0, sizeof( demux_sys_t ) );
p_sys->p_es = 0; p_sys->p_es = 0;
p_sys->p_packetizer = 0;
p_sys->b_start = VLC_TRUE; p_sys->b_start = VLC_TRUE;
p_sys->meta = 0; p_sys->meta = 0;
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
/*
* Load the mpeg 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', 'g', '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 ) /* Load the mpeg audio packetizer */
{ INIT_APACKETIZER( p_sys->p_packetizer, 'm', 'p', 'g', 'a' );
msg_Err( p_demux, "cannot find mpga packetizer" ); es_format_Init( &p_sys->p_packetizer->fmt_out, UNKNOWN_ES, 0 );
Close( VLC_OBJECT(p_demux ) ); LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "mpga" );
return VLC_EGENERIC;
}
/* Xing header */ /* Xing header */
if( HeaderCheck( header ) ) if( HeaderCheck( header ) )
...@@ -354,13 +335,9 @@ static void Close( vlc_object_t * p_this ) ...@@ -354,13 +335,9 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
DESTROY_PACKETIZER( p_sys->p_packetizer );
if( p_sys->meta ) vlc_meta_Delete( p_sys->meta ); if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
if( p_sys->p_packetizer && p_sys->p_packetizer->p_module )
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module );
if( p_sys->p_packetizer )
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
...@@ -125,8 +125,7 @@ static void Close( vlc_object_t * p_this ) ...@@ -125,8 +125,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); DESTROY_PACKETIZER( p_sys->p_packetizer );
vlc_object_destroy( p_sys->p_packetizer );
free( p_sys ); free( p_sys );
} }
......
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