1 /*****************************************************************************
2 * wingdi.c : Win32 / WinCE GDI video output plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: wingdi.c,v 1.1 2002/11/21 13:53:32 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 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
33 #define MAX_DIRECTBUFFERS 10
35 /*****************************************************************************
37 *****************************************************************************/
38 static int OpenVideo ( vlc_object_t * );
39 static void CloseVideo ( vlc_object_t * );
41 static int Init ( vout_thread_t * );
42 static void End ( vout_thread_t * );
43 static int Manage ( vout_thread_t * );
44 static void Render ( vout_thread_t *, picture_t * );
45 static void Display ( vout_thread_t *, picture_t * );
47 /*****************************************************************************
49 *****************************************************************************/
51 set_description( _("Windows GDI video output module") );
52 set_capability( "video output", 10 );
53 set_callbacks( OpenVideo, CloseVideo );
56 /*****************************************************************************
57 * OpenVideo: activate GDI video thread output method
58 *****************************************************************************/
59 static int OpenVideo ( vlc_object_t *p_this )
61 vout_thread_t * p_vout = (vout_thread_t *)p_this;
63 p_vout->pf_init = Init;
65 p_vout->pf_manage = Manage;
66 p_vout->pf_render = Render;
67 p_vout->pf_display = Display;
72 /*****************************************************************************
73 * CloseVideo: deactivate the GDI video output
74 *****************************************************************************/
75 static void CloseVideo ( vlc_object_t *p_this )
80 /*****************************************************************************
81 * Init: initialize video thread output method
82 *****************************************************************************/
83 static int Init( vout_thread_t *p_vout )
90 /* Initialize the output structure */
91 p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6');
92 p_vout->output.i_rmask = 0xf800;
93 p_vout->output.i_gmask = 0x07e0;
94 p_vout->output.i_bmask = 0x001f;
95 p_vout->output.i_width = p_vout->render.i_width;
96 p_vout->output.i_height = p_vout->render.i_height;
97 p_vout->output.i_aspect = p_vout->render.i_aspect;
99 /* Try to initialize MAX_DIRECTBUFFERS direct buffers */
100 while( I_OUTPUTPICTURES < MAX_DIRECTBUFFERS )
104 /* Find an empty picture slot */
105 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
107 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
109 p_pic = p_vout->p_picture + i_index;
114 /* Allocate the picture */
120 vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width,
121 p_vout->output.i_height,
122 p_vout->output.i_chroma );
124 if( p_pic->i_planes == 0 )
129 p_pic->i_status = DESTROYED_PICTURE;
130 p_pic->i_type = DIRECT_PICTURE;
132 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
140 /*****************************************************************************
141 * End: terminate video thread output method
142 *****************************************************************************/
143 static void End( vout_thread_t *p_vout )
147 /* Free the fake output buffers we allocated */
148 for( i_index = I_OUTPUTPICTURES ; i_index ; )
151 free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
155 /*****************************************************************************
156 * Manage: handle events
157 *****************************************************************************
158 * This function should be called regularly by video output thread. It manages
159 * console events. It returns a non null value on error.
160 *****************************************************************************/
161 static int Manage( vout_thread_t *p_vout )
166 /*****************************************************************************
167 * Render: render previously calculated output
168 *****************************************************************************/
169 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
171 /* No need to do anything, the fake direct buffers stay as they are */
174 /*****************************************************************************
175 * Display: displays previously rendered output
176 *****************************************************************************/
177 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
179 /* No need to do anything, the fake direct buffers stay as they are */