* demuxdump.c : Pseudo demux module for vlc (dump raw stream)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: demuxdump.c,v 1.3 2003/01/25 16:58:34 fenrir Exp $
+ * $Id: demuxdump.c,v 1.11 2003/11/05 17:57:29 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
/*****************************************************************************
* Module descriptor
*****************************************************************************/
+#define FILE_TEXT N_("Dump file name")
+#define FILE_LONGTEXT N_( \
+ "Specify a file name to which the raw stream will be dumped." )
+
vlc_module_begin();
- set_description( _("Dump Demux input") );
+ set_description( _("file dump demuxer") );
set_capability( "demux", 0 );
- add_category_hint( "File", NULL );
- add_string( "demuxdump-file", NULL, NULL,
- "dump file name",
- "file name for dumping raw stream read by demux" );
+ add_category_hint( "File", NULL, VLC_FALSE );
+ add_file( "demuxdump-file", "stream-demux.dump", NULL, FILE_TEXT,
+ FILE_LONGTEXT, VLC_FALSE );
set_callbacks( Activate, Desactivate );
add_shortcut( "dump" );
vlc_module_end();
{
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_demux;
-
+ vlc_value_t val;
char *psz_name;
/* Set the demux function */
p_input->pf_demux = Demux;
+ p_input->pf_demux_control = demux_vaControlDefault;
/* Initialize access plug-in structures. */
if( p_input->i_mtu == 0 )
p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
}
- psz_name = config_GetPsz( p_input, "demuxdump-file" );
+ var_Create( p_input, "demuxdump-file", VLC_VAR_FILE|VLC_VAR_DOINHERIT );
+ var_Get( p_input, "demuxdump-file", &val );
+ psz_name = val.psz_string;
if( !psz_name || !*psz_name )
{
- psz_name = strdup( "stream-demux.dump" );
+ msg_Warn( p_input, "no dump file name given" );
+ return VLC_EGENERIC;
}
p_demux = malloc( sizeof( demux_sys_t ) );
memset( p_demux, 0, sizeof( demux_sys_t ) );
- if( !( p_demux->p_file = fopen( psz_name, "wb" ) ) )
+ if( !strcmp( psz_name, "-" ) )
+ {
+ msg_Info( p_input,
+ "dumping raw stream to standard output" );
+ p_demux->p_file = stdout;
+ p_demux->psz_name = psz_name;
+ }
+ else if( !( p_demux->p_file = fopen( psz_name, "wb" ) ) )
{
msg_Err( p_input,
"cannot create `%s' for writing",
psz_name );
free( p_demux );
- return( -1 );
+ return VLC_EGENERIC;
}
else
{
if( input_InitStream( p_input, 0 ) == -1 )
{
- fclose( p_demux->p_file );
+ if( p_demux->p_file != stdout )
+ fclose( p_demux->p_file );
free( p_demux );
- return( -1 );
+ return VLC_EGENERIC;
}
input_AddProgram( p_input, 0, 0 );
p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
p_input->stream.p_selected_program->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
if( p_demux->p_file )
{
- fclose( p_demux->p_file );
+ if( p_demux->p_file != stdout )
+ fclose( p_demux->p_file );
p_demux->p_file = NULL;
}
if( p_demux->psz_name )
return( 1 );
}
-