[svn] / branches / release-1_0-branch / xvidcore / vfw / src / driverproc.c Repository:
ViewVC logotype

Annotation of /branches/release-1_0-branch/xvidcore/vfw/src/driverproc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1396 - (view) (download)

1 : edgomez 1382 /*****************************************************************************
2 :     *
3 :     * XVID MPEG-4 VFW FRONTEND
4 :     * - driverproc main -
5 :     *
6 :     * Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
7 :     *
8 :     * This program is free software ; you can redistribute it and/or modify
9 :     * it under the terms of the GNU General Public License as published by
10 :     * the Free Software Foundation ; either version 2 of the License, or
11 :     * (at your option) any later version.
12 :     *
13 :     * This program is distributed in the hope that it will be useful,
14 :     * but WITHOUT ANY WARRANTY ; without even the implied warranty of
15 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     * GNU General Public License for more details.
17 :     *
18 :     * You should have received a copy of the GNU General Public License
19 :     * along with this program ; if not, write to the Free Software
20 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 :     *
22 : edgomez 1396 * $Id: driverproc.c,v 1.2.2.1 2004-03-31 19:35:31 edgomez Exp $
23 : edgomez 1382 *
24 :     ****************************************************************************/
25 :    
26 :     #include <windows.h>
27 :     #include <vfw.h>
28 :     #include "vfwext.h"
29 :    
30 :     #include "debug.h"
31 :     #include "codec.h"
32 :     #include "config.h"
33 :     #include "status.h"
34 :     #include "resource.h"
35 :    
36 :    
37 :     BOOL WINAPI DllMain(
38 :     HANDLE hModule,
39 :     DWORD ul_reason_for_call,
40 :     LPVOID lpReserved)
41 :     {
42 :     g_hInst = (HINSTANCE) hModule;
43 :     return TRUE;
44 :     }
45 :    
46 :     /* __declspec(dllexport) */ LRESULT WINAPI DriverProc(
47 :     DWORD dwDriverId,
48 :     HDRVR hDriver,
49 :     UINT uMsg,
50 :     LPARAM lParam1,
51 :     LPARAM lParam2)
52 :     {
53 :     CODEC * codec = (CODEC *)dwDriverId;
54 :    
55 :     switch(uMsg)
56 :     {
57 :    
58 :     /* driver primitives */
59 :    
60 :     case DRV_LOAD :
61 :     case DRV_FREE :
62 :     return DRV_OK;
63 :    
64 :     case DRV_OPEN :
65 :     DPRINTF("DRV_OPEN");
66 : edgomez 1396
67 : edgomez 1382 {
68 :     ICOPEN * icopen = (ICOPEN *)lParam2;
69 :    
70 :     if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO)
71 :     {
72 :     return DRV_CANCEL;
73 :     }
74 :    
75 :     codec = malloc(sizeof(CODEC));
76 :    
77 :     if (codec == NULL)
78 :     {
79 :     if (icopen != NULL)
80 :     {
81 :     icopen->dwError = ICERR_MEMORY;
82 :     }
83 :     return 0;
84 :     }
85 :    
86 : edgomez 1396 memset(codec, 0, sizeof(CODEC));
87 : edgomez 1382
88 :     codec->status.hDlg = NULL;
89 :     codec->config.ci_valid = 0;
90 :     codec->ehandle = codec->dhandle = NULL;
91 :     codec->fbase = 25;
92 :     codec->fincr = 1;
93 :     config_reg_get(&codec->config);
94 :    
95 :     #if 0
96 :     /* bad things happen if this piece of code is activated */
97 :     if (lstrcmp(XVID_BUILD, codec->config.build))
98 :     {
99 :     config_reg_default(&codec->config);
100 :     }
101 :     #endif
102 :    
103 :     if (icopen != NULL)
104 :     {
105 :     icopen->dwError = ICERR_OK;
106 :     }
107 :     return (LRESULT)codec;
108 :     }
109 :    
110 :     case DRV_CLOSE :
111 :     DPRINTF("DRV_CLOSE");
112 :     /* compress_end/decompress_end don't always get called */
113 :     compress_end(codec);
114 :     decompress_end(codec);
115 :     status_destroy_always(&codec->status);
116 :     free(codec);
117 :     return DRV_OK;
118 :    
119 :     case DRV_DISABLE :
120 :     case DRV_ENABLE :
121 :     return DRV_OK;
122 :    
123 :     case DRV_INSTALL :
124 :     case DRV_REMOVE :
125 :     return DRV_OK;
126 :    
127 :     case DRV_QUERYCONFIGURE :
128 :     case DRV_CONFIGURE :
129 :     return DRV_CANCEL;
130 :    
131 :    
132 :     /* info */
133 :    
134 :     case ICM_GETINFO :
135 :     DPRINTF("ICM_GETINFO");
136 :     {
137 :     ICINFO *icinfo = (ICINFO *)lParam1;
138 :    
139 :     icinfo->fccType = ICTYPE_VIDEO;
140 :     icinfo->fccHandler = FOURCC_XVID;
141 :     icinfo->dwFlags =
142 :     VIDCF_FASTTEMPORALC |
143 :     VIDCF_FASTTEMPORALD |
144 :     VIDCF_COMPRESSFRAMES;
145 :    
146 :     icinfo->dwVersion = 0;
147 :     icinfo->dwVersionICM = ICVERSION;
148 :    
149 :     wcscpy(icinfo->szName, XVID_NAME_L);
150 :     wcscpy(icinfo->szDescription, XVID_DESC_L);
151 :    
152 :     return lParam2; /* size of struct */
153 :     }
154 :    
155 :     /* state control */
156 :    
157 :     case ICM_ABOUT :
158 :     DPRINTF("ICM_ABOUT");
159 :     DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);
160 :     return ICERR_OK;
161 :    
162 :     case ICM_CONFIGURE :
163 :     DPRINTF("ICM_CONFIGURE");
164 :     if (lParam1 != -1)
165 :     {
166 :     CONFIG temp;
167 :    
168 :     codec->config.save = FALSE;
169 :     memcpy(&temp, &codec->config, sizeof(CONFIG));
170 :    
171 :     DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);
172 :    
173 :     if (temp.save)
174 :     {
175 :     memcpy(&codec->config, &temp, sizeof(CONFIG));
176 :     config_reg_set(&codec->config);
177 :     }
178 :     }
179 :     return ICERR_OK;
180 :    
181 :     case ICM_GETSTATE :
182 :     DPRINTF("ICM_GETSTATE");
183 :     if ((void*)lParam1 == NULL)
184 :     {
185 :     return sizeof(CONFIG);
186 :     }
187 :     memcpy((void*)lParam1, &codec->config, sizeof(CONFIG));
188 :     return ICERR_OK;
189 :    
190 :     case ICM_SETSTATE :
191 :     DPRINTF("ICM_SETSTATE");
192 :     if ((void*)lParam1 == NULL)
193 :     {
194 :     DPRINTF("ICM_SETSTATE : DEFAULT");
195 :     config_reg_get(&codec->config);
196 :     return 0;
197 :     }
198 :     memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));
199 :     return 0; /* sizeof(CONFIG); */
200 :    
201 :     /* not sure the difference, private/public data? */
202 :    
203 :     case ICM_GET :
204 :     case ICM_SET :
205 :     return ICERR_OK;
206 :    
207 :    
208 :     /* older-stype config */
209 :    
210 :     case ICM_GETDEFAULTQUALITY :
211 :     case ICM_GETQUALITY :
212 :     case ICM_SETQUALITY :
213 :     case ICM_GETBUFFERSWANTED :
214 :     case ICM_GETDEFAULTKEYFRAMERATE :
215 :     return ICERR_UNSUPPORTED;
216 :    
217 :    
218 :     /* compressor */
219 :    
220 :     case ICM_COMPRESS_QUERY :
221 :     DPRINTF("ICM_COMPRESS_QUERY");
222 :     return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
223 :    
224 :     case ICM_COMPRESS_GET_FORMAT :
225 :     DPRINTF("ICM_COMPRESS_GET_FORMAT");
226 :     return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
227 :    
228 :     case ICM_COMPRESS_GET_SIZE :
229 :     DPRINTF("ICM_COMPRESS_GET_SIZE");
230 :     return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
231 :    
232 :     case ICM_COMPRESS_FRAMES_INFO :
233 :     DPRINTF("ICM_COMPRESS_FRAMES_INFO");
234 :     return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);
235 :    
236 :     case ICM_COMPRESS_BEGIN :
237 :     DPRINTF("ICM_COMPRESS_BEGIN");
238 :     return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
239 :    
240 :     case ICM_COMPRESS_END :
241 :     DPRINTF("ICM_COMPRESS_END");
242 :     return compress_end(codec);
243 :    
244 :     case ICM_COMPRESS :
245 :     DPRINTF("ICM_COMPRESS");
246 :     return compress(codec, (ICCOMPRESS *)lParam1);
247 :    
248 :     /* decompressor */
249 :    
250 :     case ICM_DECOMPRESS_QUERY :
251 :     DPRINTF("ICM_DECOMPRESS_QUERY");
252 :     return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
253 :    
254 :     case ICM_DECOMPRESS_GET_FORMAT :
255 :     DPRINTF("ICM_DECOMPRESS_GET_FORMAT");
256 :     return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
257 :    
258 :     case ICM_DECOMPRESS_BEGIN :
259 :     DPRINTF("ICM_DECOMPRESS_BEGIN");
260 :     return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
261 :    
262 :     case ICM_DECOMPRESS_END :
263 :     DPRINTF("ICM_DECOMPRESS_END");
264 :     return decompress_end(codec);
265 :    
266 :     case ICM_DECOMPRESS :
267 :     DPRINTF("ICM_DECOMPRESS");
268 :     return decompress(codec, (ICDECOMPRESS *)lParam1);
269 :    
270 :     case ICM_DECOMPRESS_GET_PALETTE :
271 :     case ICM_DECOMPRESS_SET_PALETTE :
272 :     case ICM_DECOMPRESSEX_QUERY:
273 :     case ICM_DECOMPRESSEX_BEGIN:
274 :     case ICM_DECOMPRESSEX_END:
275 :     case ICM_DECOMPRESSEX:
276 :     return ICERR_UNSUPPORTED;
277 :    
278 :     /* VFWEXT entry point */
279 :     case ICM_USER+0x0fff :
280 :     if (lParam1 == VFWEXT_CONFIGURE_INFO) {
281 :     VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2;
282 :     DPRINTF("%i %i %i %i %i %i",
283 :     info->ciWidth, info->ciHeight,
284 :     info->ciRate, info->ciScale,
285 :     info->ciActiveFrame, info->ciFrameCount);
286 :    
287 :     codec->config.ci_valid = 1;
288 :     memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T));
289 :     return ICERR_OK;
290 :     }
291 :     return ICERR_UNSUPPORTED;
292 :    
293 :     default:
294 :     return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);
295 :     }
296 :     }
297 :    
298 :    
299 :     void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)
300 :     {
301 :     DWORD dwDriverId;
302 :    
303 :     dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0);
304 :     if (dwDriverId != (DWORD)NULL)
305 :     {
306 :     DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0);
307 :     DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);
308 :     }
309 :     }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4