]> git.sesse.net Git - vlc/blob - modules/video_output/wingdi.c
* ./modules/video_output/wingdi.c: skeleton of a Windows GDI video output.
[vlc] / modules / video_output / wingdi.c
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 $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <string.h>
29
30 #include <vlc/vlc.h>
31 #include <vlc/vout.h>
32
33 #define MAX_DIRECTBUFFERS 10
34
35 /*****************************************************************************
36  * Local prototypes
37  *****************************************************************************/
38 static int  OpenVideo  ( vlc_object_t * );
39 static void CloseVideo ( vlc_object_t * );
40
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 * );
46
47 /*****************************************************************************
48  * Module descriptor
49  *****************************************************************************/
50 vlc_module_begin();
51     set_description( _("Windows GDI video output module") );
52     set_capability( "video output", 10 );
53     set_callbacks( OpenVideo, CloseVideo );
54 vlc_module_end();
55
56 /*****************************************************************************
57  * OpenVideo: activate GDI video thread output method
58  *****************************************************************************/
59 static int OpenVideo ( vlc_object_t *p_this )
60 {
61     vout_thread_t * p_vout = (vout_thread_t *)p_this;
62
63     p_vout->pf_init = Init;
64     p_vout->pf_end = End;
65     p_vout->pf_manage = Manage;
66     p_vout->pf_render = Render;
67     p_vout->pf_display = Display;
68
69     return VLC_SUCCESS;
70 }
71
72 /*****************************************************************************
73  * CloseVideo: deactivate the GDI video output
74  *****************************************************************************/
75 static void CloseVideo ( vlc_object_t *p_this )
76 {
77     ;
78 }
79
80 /*****************************************************************************
81  * Init: initialize video thread output method
82  *****************************************************************************/
83 static int Init( vout_thread_t *p_vout )
84 {
85     int i_index;
86     picture_t *p_pic;
87
88     I_OUTPUTPICTURES = 0;
89
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;
98
99     /* Try to initialize MAX_DIRECTBUFFERS direct buffers */
100     while( I_OUTPUTPICTURES < MAX_DIRECTBUFFERS )
101     {
102         p_pic = NULL;
103
104         /* Find an empty picture slot */
105         for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
106         {
107             if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
108             {
109                 p_pic = p_vout->p_picture + i_index;
110                 break;
111             }
112         }
113
114         /* Allocate the picture */
115         if( p_pic == NULL )
116         {
117             break;
118         }
119
120         vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width,
121                               p_vout->output.i_height,
122                               p_vout->output.i_chroma );
123
124         if( p_pic->i_planes == 0 )
125         {
126             break;
127         }
128
129         p_pic->i_status = DESTROYED_PICTURE;
130         p_pic->i_type   = DIRECT_PICTURE;
131
132         PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
133
134         I_OUTPUTPICTURES++;
135     }
136
137     return VLC_SUCCESS;
138 }
139
140 /*****************************************************************************
141  * End: terminate video thread output method
142  *****************************************************************************/
143 static void End( vout_thread_t *p_vout )
144 {
145     int i_index;
146
147     /* Free the fake output buffers we allocated */
148     for( i_index = I_OUTPUTPICTURES ; i_index ; )
149     {
150         i_index--;
151         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
152     }
153 }
154
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 )
162 {
163     return VLC_SUCCESS;
164 }
165
166 /*****************************************************************************
167  * Render: render previously calculated output
168  *****************************************************************************/
169 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
170 {
171     /* No need to do anything, the fake direct buffers stay as they are */
172 }
173
174 /*****************************************************************************
175  * Display: displays previously rendered output
176  *****************************************************************************/
177 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
178 {
179     /* No need to do anything, the fake direct buffers stay as they are */
180 }
181