1 /*****************************************************************************
2 * encoder.c: stats encoder plugin for vlc.
3 *****************************************************************************
4 * Copyright (C) 2002-2008 the VideoLAN team
6 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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>
36 /*****************************************************************************
38 *****************************************************************************/
44 /*****************************************************************************
46 *****************************************************************************/
47 static block_t
*EncodeVideo( encoder_t
*p_enc
, picture_t
*p_pict
);
48 static block_t
*EncodeAudio( encoder_t
*p_enc
, aout_buffer_t
*p_abuff
);
50 /*****************************************************************************
51 * OpenDecoder: open the dummy encoder.
52 *****************************************************************************/
53 int OpenEncoder ( vlc_object_t
*p_this
)
55 encoder_t
*p_enc
= (encoder_t
*)p_this
;
57 p_enc
->p_sys
= malloc(sizeof(encoder_sys_t
));
59 if( !p_enc
->p_sys
) return VLC_ENOMEM
;
63 msg_Dbg( p_this
, "opening stats encoder" );
65 p_enc
->pf_encode_video
= EncodeVideo
;
66 p_enc
->pf_encode_audio
= EncodeAudio
;
72 /****************************************************************************
73 * EncodeVideo: the whole thing
74 ****************************************************************************/
75 static block_t
*EncodeVideo( encoder_t
*p_enc
, picture_t
*p_pict
)
78 block_t
* p_block
= block_New( p_enc
, kBufferSize
);
80 *(mtime_t
*)p_block
->p_buffer
= mdate();
81 p_block
->i_buffer
= kBufferSize
;
82 p_block
->i_length
= kBufferSize
;
83 p_block
->i_dts
= p_pict
->date
;
85 msg_Dbg( p_enc
, "putting %"PRIu64
"ms",
86 *(mtime_t
*)p_block
->p_buffer
/ 1000 );
90 /****************************************************************************
91 * EncodeVideo: the whole thing
92 ****************************************************************************/
93 static block_t
*EncodeAudio( encoder_t
*p_enc
, aout_buffer_t
*p_abuff
)
101 /*****************************************************************************
102 * CloseDecoder: decoder destruction
103 *****************************************************************************/
104 void CloseEncoder ( vlc_object_t
*p_this
)
106 encoder_t
*p_enc
= (encoder_t
*)p_this
;
108 msg_Dbg( p_this
, "closing stats encoder" );
109 free( p_enc
->p_sys
);