Commit 8877066d authored by Sam Hocevar's avatar Sam Hocevar

* ./plugins/dummy/dec_dummy.c: new dummy decoder, for testing purposes.

   Usage: "--codec dummy" will use the dummy decoder for all streams, and
  save the stream to a stream.1242 file (where 1242 is the internal vlc
  object ID). If the input file was for instance an mpeg file, you can
  play one of the resulting files using an mp3 player.
parent 255db009
null_SOURCES = null.c null_SOURCES = null.c
dummy_SOURCES = dummy.c aout_dummy.c vout_dummy.c intf_dummy.c input_dummy.c dummy_SOURCES = dummy.c aout_dummy.c vout_dummy.c intf_dummy.c input_dummy.c dec_dummy.c
/*****************************************************************************
* dec_dummy.c: dummy decoder plugin for vlc.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: dec_dummy.c,v 1.1 2002/07/23 20:15:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/decoder.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* write(), close() */
#endif
#include <sys/types.h> /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h> /* sprintf() */
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Probe ( vlc_fourcc_t * );
static int Run ( decoder_fifo_t * );
/*****************************************************************************
* Capabilities
*****************************************************************************/
void _M( dec_getfunctions )( function_list_t * p_function_list )
{
p_function_list->functions.dec.pf_probe = Probe;
p_function_list->functions.dec.pf_run = Run;
}
/*****************************************************************************
* Probe: probe the decoder and return score
*****************************************************************************
* Always returns 0 because we are the dummy decoder!
*****************************************************************************/
static int Probe( vlc_fourcc_t *pi_type )
{
return 0;
}
/*****************************************************************************
* Run: this function is called just after the thread is created
*****************************************************************************/
static int Run ( decoder_fifo_t *p_fifo )
{
bit_stream_t bit_stream;
mtime_t last_date = mdate();
size_t i_bytes = 0;
char psz_file[100];
int i_fd;
sprintf( psz_file, "stream.%i", p_fifo->i_object_id );
i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 );
if( i_fd == -1 )
{
msg_Err( p_fifo, "cannot create `%s'", psz_file );
p_fifo->b_error = 1;
DecoderError( p_fifo );
return -1;
}
msg_Dbg( p_fifo, "dumping stream to file `%s'", psz_file );
InitBitstream( &bit_stream, p_fifo, NULL, NULL );
while( !p_fifo->b_die && !p_fifo->b_error )
{
byte_t byte;
byte = GetBits( &bit_stream, 8 );
i_bytes++;
write( i_fd, &byte, 1 );
if( mdate() < last_date + 2000000 )
{
continue;
}
msg_Dbg( p_fifo, "dumped %i bytes", i_bytes );
i_bytes = 0;
last_date = mdate();
}
if( i_bytes )
{
msg_Dbg( p_fifo, "dumped %i bytes", i_bytes );
}
close( i_fd );
if( p_fifo->b_error )
{
DecoderError( p_fifo );
return -1;
}
return 0;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dummy.c : dummy plugin for vlc * dummy.c : dummy plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: dummy.c,v 1.22 2002/06/11 09:44:21 gbazin Exp $ * $Id: dummy.c,v 1.23 2002/07/23 20:15:41 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -37,6 +37,7 @@ void _M( demux_getfunctions ) ( function_list_t * p_function_list ); ...@@ -37,6 +37,7 @@ void _M( demux_getfunctions ) ( function_list_t * p_function_list );
void _M( aout_getfunctions ) ( function_list_t * p_function_list ); void _M( aout_getfunctions ) ( function_list_t * p_function_list );
void _M( vout_getfunctions ) ( function_list_t * p_function_list ); void _M( vout_getfunctions ) ( function_list_t * p_function_list );
void _M( intf_getfunctions ) ( function_list_t * p_function_list ); void _M( intf_getfunctions ) ( function_list_t * p_function_list );
void _M( dec_getfunctions ) ( function_list_t * p_function_list );
/***************************************************************************** /*****************************************************************************
* Build configuration tree. * Build configuration tree.
...@@ -57,11 +58,12 @@ MODULE_INIT_START ...@@ -57,11 +58,12 @@ MODULE_INIT_START
SET_DESCRIPTION( _("dummy functions module") ) SET_DESCRIPTION( _("dummy functions module") )
/* Capability score set to 0 because we don't want to be spawned /* Capability score set to 0 because we don't want to be spawned
* unless explicitly requested to */ * unless explicitly requested to */
ADD_CAPABILITY( AOUT, 0 )
ADD_CAPABILITY( VOUT, 0 )
ADD_CAPABILITY( INTF, 0 ) ADD_CAPABILITY( INTF, 0 )
ADD_CAPABILITY( ACCESS, 0 ) ADD_CAPABILITY( ACCESS, 0 )
ADD_CAPABILITY( DEMUX, 0 ) ADD_CAPABILITY( DEMUX, 0 )
ADD_CAPABILITY( DECODER, 0 )
ADD_CAPABILITY( AOUT, 0 )
ADD_CAPABILITY( VOUT, 0 )
ADD_SHORTCUT( "vlc" ) ADD_SHORTCUT( "vlc" )
MODULE_INIT_STOP MODULE_INIT_STOP
...@@ -72,6 +74,7 @@ MODULE_ACTIVATE_START ...@@ -72,6 +74,7 @@ MODULE_ACTIVATE_START
_M( aout_getfunctions )( &p_module->p_functions->aout ); _M( aout_getfunctions )( &p_module->p_functions->aout );
_M( vout_getfunctions )( &p_module->p_functions->vout ); _M( vout_getfunctions )( &p_module->p_functions->vout );
_M( intf_getfunctions )( &p_module->p_functions->intf ); _M( intf_getfunctions )( &p_module->p_functions->intf );
_M( dec_getfunctions )( &p_module->p_functions->dec );
MODULE_ACTIVATE_STOP MODULE_ACTIVATE_STOP
......
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