1 /*****************************************************************************
2 * dec_dummy.c: dummy decoder plugin for vlc.
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: decoder.c,v 1.7 2003/10/25 00:49:14 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <vlc/decoder.h>
31 # include <unistd.h> /* write(), close() */
32 #elif defined( WIN32 ) && !defined( UNDER_CE )
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h> /* open() */
38 #ifdef HAVE_SYS_STAT_H
39 # include <sys/stat.h>
45 #include <stdio.h> /* sprintf() */
47 /*****************************************************************************
49 *****************************************************************************/
50 static int Run ( decoder_fifo_t * );
52 /*****************************************************************************
53 * OpenDecoder: probe the decoder and return score
54 *****************************************************************************
55 * Always returns 0 because we are the dummy decoder!
56 *****************************************************************************/
57 int E_(OpenDecoder) ( vlc_object_t *p_this )
59 ((decoder_t*)p_this)->pf_run = Run;
64 /*****************************************************************************
65 * Run: this function is called just after the thread is created
66 *****************************************************************************/
67 static int Run ( decoder_fifo_t *p_fifo )
69 uint8_t p_buffer[1024];
71 bit_stream_t bit_stream;
72 mtime_t last_date = mdate();
80 sprintf( psz_file, "stream.%i", p_fifo->i_object_id );
82 i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 );
86 msg_Err( p_fifo, "cannot create `%s'", psz_file );
88 DecoderError( p_fifo );
93 msg_Dbg( p_fifo, "dumping stream to file `%s'", psz_file );
95 if( InitBitstream( &bit_stream, p_fifo, NULL, NULL ) != VLC_SUCCESS )
97 msg_Err( p_fifo, "cannot initialize bitstream" );
99 DecoderError( p_fifo );
106 while( !p_fifo->b_die && !p_fifo->b_error )
108 GetChunk( &bit_stream, p_buffer, 1024 );
110 write( i_fd, p_buffer, 1024 );
115 if( mdate() < last_date + 2000000 )
120 msg_Dbg( p_fifo, "dumped %i bytes", i_bytes );
128 msg_Dbg( p_fifo, "dumped %i bytes", i_bytes );
134 CloseBitstream( &bit_stream );
136 if( p_fifo->b_error )
138 DecoderError( p_fifo );