1 /*****************************************************************************
2 * decoder.c: stats decoder plugin for vlc.
3 *****************************************************************************
4 * Copyright (C) 2002-2008 the VideoLAN team
6 * Authors: Samuel Hocevar <sam@zoy.org>
7 * Pierre d'Herbemont <pdherbemont@videolan.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_codec.h>
37 /*****************************************************************************
39 *****************************************************************************/
40 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block );
42 /*****************************************************************************
43 * OpenDecoder: Open the decoder
44 *****************************************************************************/
45 int OpenDecoder ( vlc_object_t *p_this )
47 decoder_t *p_dec = (decoder_t*)p_this;
49 msg_Dbg( p_this, "opening stats decoder" );
52 p_dec->pf_decode_video = DecodeBlock;
53 p_dec->pf_decode_audio = NULL;
54 p_dec->pf_decode_sub = NULL;
57 es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_CODEC_I420 );
58 p_dec->fmt_out.video.i_width = 100;
59 p_dec->fmt_out.video.i_height = 100;
60 p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR;
65 /****************************************************************************
66 * RunDecoder: the whole thing
67 ****************************************************************************/
68 static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
71 picture_t * p_pic = NULL;
73 if( !pp_block || !*pp_block ) return NULL;
76 p_pic = decoder_NewPicture( p_dec );
78 if( p_block->i_buffer == kBufferSize )
80 msg_Dbg( p_dec, "got %"PRIu64" ms",
81 *(mtime_t *)p_block->p_buffer / 1000 );
82 msg_Dbg( p_dec, "got %"PRIu64" ms offset",
83 (mdate() - *(mtime_t *)p_block->p_buffer) / 1000 );
84 *(mtime_t *)(p_pic->p->p_pixels) = *(mtime_t *)p_block->p_buffer;
88 msg_Dbg( p_dec, "got a packet not from stats demuxer" );
89 *(mtime_t *)(p_pic->p->p_pixels) = mdate();
92 p_pic->date = p_block->i_pts ? p_block->i_pts : p_block->i_dts;
93 p_pic->b_force = true;
95 block_Release( p_block );
100 /*****************************************************************************
101 * CloseDecoder: decoder destruction
102 *****************************************************************************/
103 void CloseDecoder ( vlc_object_t *p_this )
105 msg_Dbg( p_this, "closing stats decoder" );