1 /*****************************************************************************
2 * vout_dummy.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
35 #define DUMMY_WIDTH 16
36 #define DUMMY_HEIGHT 16
37 #define DUMMY_MAX_DIRECTBUFFERS 10
41 /*****************************************************************************
43 *****************************************************************************/
44 static int Init ( vout_thread_t * );
45 static void End ( vout_thread_t * );
46 static int Manage ( vout_thread_t * );
47 static void Render ( vout_thread_t *, picture_t * );
48 static void Display ( vout_thread_t *, picture_t * );
49 static void SetPalette ( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
50 static int Control ( vout_thread_t *, int, va_list );
52 /*****************************************************************************
53 * OpenVideo: activates dummy video thread output method
54 *****************************************************************************
55 * This function initializes a dummy vout method.
56 *****************************************************************************/
57 int OpenVideo ( vlc_object_t *p_this )
59 vout_thread_t * p_vout = (vout_thread_t *)p_this;
61 p_vout->pf_init = Init;
63 p_vout->pf_manage = Manage;
64 p_vout->pf_render = Render;
65 p_vout->pf_display = Display;
66 p_vout->pf_control = Control;
71 /*****************************************************************************
72 * Control: control facility for the vout
73 *****************************************************************************/
74 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
76 (void) p_vout; (void) i_query; (void) args;
81 /*****************************************************************************
82 * Init: initialize dummy video thread output method
83 *****************************************************************************/
84 static int Init( vout_thread_t *p_vout )
86 int i_index, i_chroma;
91 psz_chroma = config_GetPsz( p_vout, "dummy-chroma" );
92 i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
93 b_chroma = i_chroma != 0;
98 /* Initialize the output structure */
101 msg_Dbg( p_vout, "forcing chroma 0x%.8x (%4.4s)",
102 i_chroma, (char*)&i_chroma );
103 p_vout->output.i_chroma = i_chroma;
104 if ( i_chroma == VLC_CODEC_RGB8 )
106 p_vout->output.pf_setpalette = SetPalette;
108 p_vout->output.i_width = p_vout->render.i_width;
109 p_vout->output.i_height = p_vout->render.i_height;
110 p_vout->output.i_aspect = p_vout->render.i_aspect;
114 /* Use same chroma as input */
115 p_vout->output.i_chroma = p_vout->render.i_chroma;
116 p_vout->output.i_rmask = p_vout->render.i_rmask;
117 p_vout->output.i_gmask = p_vout->render.i_gmask;
118 p_vout->output.i_bmask = p_vout->render.i_bmask;
119 p_vout->output.i_width = p_vout->render.i_width;
120 p_vout->output.i_height = p_vout->render.i_height;
121 p_vout->output.i_aspect = p_vout->render.i_aspect;
124 /* Try to initialize DUMMY_MAX_DIRECTBUFFERS direct buffers */
125 while( I_OUTPUTPICTURES < DUMMY_MAX_DIRECTBUFFERS )
129 /* Find an empty picture slot */
130 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
132 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
134 p_pic = p_vout->p_picture + i_index;
139 /* Allocate the picture */
145 vout_AllocatePicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
146 p_vout->output.i_width, p_vout->output.i_height,
147 p_vout->output.i_aspect );
149 if( p_pic->i_planes == 0 )
154 p_pic->i_status = DESTROYED_PICTURE;
155 p_pic->i_type = DIRECT_PICTURE;
157 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
165 /*****************************************************************************
166 * End: terminate dummy video thread output method
167 *****************************************************************************/
168 static void End( vout_thread_t *p_vout )
172 /* Free the fake output buffers we allocated */
173 for( i_index = I_OUTPUTPICTURES ; i_index ; )
176 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
180 /*****************************************************************************
181 * Manage: handle dummy events
182 *****************************************************************************
183 * This function should be called regularly by video output thread. It manages
184 * console events. It returns a non null value on error.
185 *****************************************************************************/
186 static int Manage( vout_thread_t *p_vout )
192 /*****************************************************************************
193 * Render: render previously calculated output
194 *****************************************************************************/
195 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
197 VLC_UNUSED(p_vout); VLC_UNUSED(p_pic);
198 /* No need to do anything, the fake direct buffers stay as they are */
201 /*****************************************************************************
202 * Display: displays previously rendered output
203 *****************************************************************************/
204 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
206 VLC_UNUSED(p_vout); VLC_UNUSED(p_pic);
207 /* No need to do anything, the fake direct buffers stay as they are */
210 /*****************************************************************************
211 * SetPalette: set the palette for the picture
212 *****************************************************************************/
213 static void SetPalette ( vout_thread_t *p_vout,
214 uint16_t *red, uint16_t *green, uint16_t *blue )
216 VLC_UNUSED(p_vout); VLC_UNUSED(red); VLC_UNUSED(green); VLC_UNUSED(blue);
217 /* No need to do anything, the fake direct buffers stay as they are */