2 * Digital video MCI Wine Driver
4 * Copyright 1999, 2000 Eric POUECH
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "private_mciavi.h"
23 #include "wine/debug.h"
24 #include "wine/unicode.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
28 /**************************************************************************
29 * MCIAVI_ConvertFrameToTimeFormat [internal]
31 static DWORD MCIAVI_ConvertFrameToTimeFormat(WINE_MCIAVI* wma, DWORD val, LPDWORD lpRet)
35 switch (wma->dwMciTimeFormat) {
36 case MCI_FORMAT_MILLISECONDS:
37 ret = (val * wma->mah.dwMicroSecPerFrame) / 1000;
39 case MCI_FORMAT_FRAMES:
43 WARN("Bad time format %u!\n", wma->dwMciTimeFormat);
45 TRACE("val=%u=0x%08x [tf=%u] => ret=%u\n", val, val, wma->dwMciTimeFormat, ret);
50 /**************************************************************************
51 * MCIAVI_ConvertTimeFormatToFrame [internal]
53 DWORD MCIAVI_ConvertTimeFormatToFrame(WINE_MCIAVI* wma, DWORD val)
57 switch (wma->dwMciTimeFormat) {
58 case MCI_FORMAT_MILLISECONDS:
59 ret = (val * 1000) / wma->mah.dwMicroSecPerFrame;
61 case MCI_FORMAT_FRAMES:
65 WARN("Bad time format %u!\n", wma->dwMciTimeFormat);
67 TRACE("val=%u=0x%08x [tf=%u] => ret=%u\n", val, val, wma->dwMciTimeFormat, ret);
71 /***************************************************************************
72 * MCIAVI_mciGetDevCaps [internal]
74 DWORD MCIAVI_mciGetDevCaps(UINT wDevID, DWORD dwFlags, LPMCI_GETDEVCAPS_PARMS lpParms)
76 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
79 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
81 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
82 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
83 if (!(dwFlags & MCI_GETDEVCAPS_ITEM)) return MCIERR_MISSING_PARAMETER;
84 if (dwFlags & MCI_TEST) return 0;
86 EnterCriticalSection(&wma->cs);
88 if (dwFlags & MCI_GETDEVCAPS_ITEM) {
89 switch (lpParms->dwItem) {
90 case MCI_GETDEVCAPS_DEVICE_TYPE:
91 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE !\n");
92 lpParms->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO, MCI_DEVTYPE_DIGITAL_VIDEO);
93 ret = MCI_RESOURCE_RETURNED;
95 case MCI_GETDEVCAPS_HAS_AUDIO:
96 TRACE("MCI_GETDEVCAPS_HAS_AUDIO !\n");
97 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
98 ret = MCI_RESOURCE_RETURNED;
100 case MCI_GETDEVCAPS_HAS_VIDEO:
101 TRACE("MCI_GETDEVCAPS_HAS_VIDEO !\n");
102 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
103 ret = MCI_RESOURCE_RETURNED;
105 case MCI_GETDEVCAPS_USES_FILES:
106 TRACE("MCI_GETDEVCAPS_USES_FILES !\n");
107 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
108 ret = MCI_RESOURCE_RETURNED;
110 case MCI_GETDEVCAPS_COMPOUND_DEVICE:
111 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE !\n");
112 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
113 ret = MCI_RESOURCE_RETURNED;
115 case MCI_GETDEVCAPS_CAN_EJECT:
116 TRACE("MCI_GETDEVCAPS_CAN_EJECT !\n");
117 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
118 ret = MCI_RESOURCE_RETURNED;
120 case MCI_GETDEVCAPS_CAN_PLAY:
121 TRACE("MCI_GETDEVCAPS_CAN_PLAY !\n");
122 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
123 ret = MCI_RESOURCE_RETURNED;
125 case MCI_GETDEVCAPS_CAN_RECORD:
126 TRACE("MCI_GETDEVCAPS_CAN_RECORD !\n");
127 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
128 ret = MCI_RESOURCE_RETURNED;
130 case MCI_GETDEVCAPS_CAN_SAVE:
131 TRACE("MCI_GETDEVCAPS_CAN_SAVE !\n");
132 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
133 ret = MCI_RESOURCE_RETURNED;
135 case MCI_DGV_GETDEVCAPS_CAN_REVERSE:
136 TRACE("MCI_DGV_GETDEVCAPS_CAN_REVERSE !\n");
137 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE); /* FIXME */
138 ret = MCI_RESOURCE_RETURNED;
140 case MCI_DGV_GETDEVCAPS_CAN_STRETCH:
141 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH !\n");
142 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE); /* FIXME */
143 ret = MCI_RESOURCE_RETURNED;
145 case MCI_DGV_GETDEVCAPS_CAN_LOCK:
146 TRACE("MCI_DGV_GETDEVCAPS_CAN_LOCK !\n");
147 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
148 ret = MCI_RESOURCE_RETURNED;
150 case MCI_DGV_GETDEVCAPS_CAN_FREEZE:
151 TRACE("MCI_DGV_GETDEVCAPS_CAN_FREEZE !\n");
152 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
153 ret = MCI_RESOURCE_RETURNED;
155 case MCI_DGV_GETDEVCAPS_CAN_STR_IN:
156 TRACE("MCI_DGV_GETDEVCAPS_CAN_STRETCH_INPUT !\n");
157 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
158 ret = MCI_RESOURCE_RETURNED;
160 case MCI_DGV_GETDEVCAPS_HAS_STILL:
161 TRACE("MCI_DGV_GETDEVCAPS_HAS_STILL !\n");
162 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
163 ret = MCI_RESOURCE_RETURNED;
165 case MCI_DGV_GETDEVCAPS_CAN_TEST:
166 TRACE("MCI_DGV_GETDEVCAPS_CAN_TEST !\n");
167 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
168 ret = MCI_RESOURCE_RETURNED;
170 case MCI_DGV_GETDEVCAPS_PALETTES:
171 TRACE("MCI_DGV_GETDEVCAPS_PALETTES !\n");
172 lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE); /* FIXME */
173 ret = MCI_RESOURCE_RETURNED;
175 /* w2k does not know MAX_WINDOWS or MAX/MINIMUM_RATE */
177 FIXME("Unknown capability (%08x) !\n", lpParms->dwItem);
178 ret = MCIERR_UNSUPPORTED_FUNCTION;
183 LeaveCriticalSection(&wma->cs);
187 /***************************************************************************
188 * MCIAVI_mciInfo [internal]
190 DWORD MCIAVI_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_DGV_INFO_PARMSW lpParms)
193 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
195 static const WCHAR wszAviPlayer[] = {'W','i','n','e','\'','s',' ','A','V','I',' ','p','l','a','y','e','r',0};
197 if (lpParms == NULL || lpParms->lpstrReturn == NULL)
198 return MCIERR_NULL_PARAMETER_BLOCK;
199 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
200 if (dwFlags & MCI_TEST) return 0;
202 TRACE("buf=%p, len=%u\n", lpParms->lpstrReturn, lpParms->dwRetSize);
204 EnterCriticalSection(&wma->cs);
206 if (dwFlags & MCI_INFO_PRODUCT)
208 else if (dwFlags & MCI_INFO_FILE)
209 str = wma->lpFileName;
211 WARN("Don't know this info command (%u)\n", dwFlags);
212 ret = MCIERR_UNRECOGNIZED_COMMAND;
215 if (strlenW(str) + 1 > lpParms->dwRetSize) {
216 ret = MCIERR_PARAM_OVERFLOW;
218 lstrcpynW(lpParms->lpstrReturn, str, lpParms->dwRetSize);
221 lpParms->lpstrReturn[0] = 0;
224 LeaveCriticalSection(&wma->cs);
228 /***************************************************************************
229 * MCIAVI_mciSet [internal]
231 DWORD MCIAVI_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_DGV_SET_PARMS lpParms)
233 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
235 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
236 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
237 if (dwFlags & MCI_TEST) return 0;
239 EnterCriticalSection(&wma->cs);
241 if (dwFlags & MCI_SET_TIME_FORMAT) {
242 switch (lpParms->dwTimeFormat) {
243 case MCI_FORMAT_MILLISECONDS:
244 TRACE("MCI_FORMAT_MILLISECONDS !\n");
245 wma->dwMciTimeFormat = MCI_FORMAT_MILLISECONDS;
247 case MCI_FORMAT_FRAMES:
248 TRACE("MCI_FORMAT_FRAMES !\n");
249 wma->dwMciTimeFormat = MCI_FORMAT_FRAMES;
252 WARN("Bad time format %u!\n", lpParms->dwTimeFormat);
253 LeaveCriticalSection(&wma->cs);
254 return MCIERR_BAD_TIME_FORMAT;
258 if (dwFlags & MCI_SET_DOOR_OPEN) {
259 TRACE("No support for door open !\n");
260 LeaveCriticalSection(&wma->cs);
261 return MCIERR_UNSUPPORTED_FUNCTION;
263 if (dwFlags & MCI_SET_DOOR_CLOSED) {
264 TRACE("No support for door close !\n");
265 LeaveCriticalSection(&wma->cs);
266 return MCIERR_UNSUPPORTED_FUNCTION;
269 if (dwFlags & MCI_SET_ON) {
270 const char *szVideo="";
271 const char *szAudio="";
272 const char *szSeek="";
274 if (dwFlags & MCI_SET_VIDEO) {
278 if (dwFlags & MCI_SET_AUDIO) {
279 switch (lpParms->dwAudio) {
280 case MCI_SET_AUDIO_ALL:
281 szAudio = " audio all";
284 case MCI_SET_AUDIO_LEFT:
285 szAudio = " audio left";
288 case MCI_SET_AUDIO_RIGHT:
289 szAudio = " audio right";
293 szAudio = " audio unknown";
294 WARN("Unknown audio channel %u\n", lpParms->dwAudio);
298 if (dwFlags & MCI_DGV_SET_SEEK_EXACTLY) {
299 szSeek = " seek_exactly";
301 FIXME("MCI_SET_ON:%s%s%s\n", szVideo, szAudio, szSeek);
304 if (dwFlags & MCI_SET_OFF) {
305 const char *szVideo="";
306 const char *szAudio="";
307 const char *szSeek="";
309 if (dwFlags & MCI_SET_VIDEO) {
313 if (dwFlags & MCI_SET_AUDIO) {
314 switch (lpParms->dwAudio) {
315 case MCI_SET_AUDIO_ALL:
316 szAudio = " audio all";
319 case MCI_SET_AUDIO_LEFT:
320 szAudio = " audio left";
323 case MCI_SET_AUDIO_RIGHT:
324 szAudio = " audio right";
328 szAudio = " audio unknown";
329 WARN("Unknown audio channel %u\n", lpParms->dwAudio);
333 if (dwFlags & MCI_DGV_SET_SEEK_EXACTLY) {
334 szSeek = " seek_exactly";
336 FIXME("MCI_SET_OFF:%s%s%s\n", szVideo, szAudio, szSeek);
338 if (dwFlags & MCI_DGV_SET_FILEFORMAT) {
340 if (dwFlags & MCI_DGV_SET_STILL)
343 switch (lpParms->dwFileFormat) {
344 case MCI_DGV_FF_AVI: FIXME("Setting file format (%s) to 'AVI'\n", str); break;
345 case MCI_DGV_FF_AVSS: FIXME("Setting file format (%s) to 'AVSS'\n", str); break;
346 case MCI_DGV_FF_DIB: FIXME("Setting file format (%s) to 'DIB'\n", str); break;
347 case MCI_DGV_FF_JFIF: FIXME("Setting file format (%s) to 'JFIF'\n", str); break;
348 case MCI_DGV_FF_JPEG: FIXME("Setting file format (%s) to 'JPEG'\n", str); break;
349 case MCI_DGV_FF_MPEG: FIXME("Setting file format (%s) to 'MPEG'\n", str); break;
350 case MCI_DGV_FF_RDIB: FIXME("Setting file format (%s) to 'RLE DIB'\n", str); break;
351 case MCI_DGV_FF_RJPEG: FIXME("Setting file format (%s) to 'RJPEG'\n", str); break;
352 default: FIXME("Setting unknown file format (%s): %d\n", str, lpParms->dwFileFormat);
356 if (dwFlags & MCI_DGV_SET_SPEED) {
357 FIXME("Setting speed to %d\n", lpParms->dwSpeed);
360 LeaveCriticalSection(&wma->cs);
364 /***************************************************************************
365 * MCIAVI_mciStatus [internal]
367 DWORD MCIAVI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSW lpParms)
369 WINE_MCIAVI* wma = MCIAVI_mciGetOpenDev(wDevID);
372 if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
373 if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
374 if (dwFlags & MCI_TEST) return 0;
376 EnterCriticalSection(&wma->cs);
378 if (dwFlags & MCI_STATUS_ITEM) {
379 switch (lpParms->dwItem) {
380 case MCI_STATUS_CURRENT_TRACK:
381 lpParms->dwReturn = 1;
382 TRACE("MCI_STATUS_CURRENT_TRACK => %lu\n", lpParms->dwReturn);
384 case MCI_STATUS_LENGTH:
386 lpParms->dwReturn = 0;
387 LeaveCriticalSection(&wma->cs);
388 return MCIERR_UNSUPPORTED_FUNCTION;
390 /* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
391 lpParms->dwReturn = MCIAVI_ConvertFrameToTimeFormat(wma, wma->mah.dwTotalFrames, &ret);
392 TRACE("MCI_STATUS_LENGTH => %lu\n", lpParms->dwReturn);
394 case MCI_STATUS_MODE:
395 lpParms->dwReturn = MAKEMCIRESOURCE(wma->dwStatus, wma->dwStatus);
396 ret = MCI_RESOURCE_RETURNED;
397 TRACE("MCI_STATUS_MODE => 0x%04x\n", LOWORD(lpParms->dwReturn));
399 case MCI_STATUS_MEDIA_PRESENT:
400 TRACE("MCI_STATUS_MEDIA_PRESENT => TRUE\n");
401 lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
402 ret = MCI_RESOURCE_RETURNED;
404 case MCI_STATUS_NUMBER_OF_TRACKS:
405 lpParms->dwReturn = 1;
406 TRACE("MCI_STATUS_NUMBER_OF_TRACKS => %lu\n", lpParms->dwReturn);
408 case MCI_STATUS_POSITION:
410 lpParms->dwReturn = 0;
411 LeaveCriticalSection(&wma->cs);
412 return MCIERR_UNSUPPORTED_FUNCTION;
414 /* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
415 lpParms->dwReturn = MCIAVI_ConvertFrameToTimeFormat(wma,
416 (dwFlags & MCI_STATUS_START) ? 0 : wma->dwCurrVideoFrame,
418 TRACE("MCI_STATUS_POSITION %s => %lu\n",
419 (dwFlags & MCI_STATUS_START) ? "start" : "current", lpParms->dwReturn);
421 case MCI_STATUS_READY:
422 lpParms->dwReturn = (wma->dwStatus == MCI_MODE_NOT_READY) ?
423 MAKEMCIRESOURCE(FALSE, MCI_FALSE) : MAKEMCIRESOURCE(TRUE, MCI_TRUE);
424 ret = MCI_RESOURCE_RETURNED;
425 TRACE("MCI_STATUS_READY = %u\n", LOWORD(lpParms->dwReturn));
427 case MCI_STATUS_TIME_FORMAT:
428 lpParms->dwReturn = MAKEMCIRESOURCE(wma->dwMciTimeFormat,
429 wma->dwMciTimeFormat + MCI_FORMAT_RETURN_BASE);
430 TRACE("MCI_STATUS_TIME_FORMAT => %u\n", LOWORD(lpParms->dwReturn));
431 ret = MCI_RESOURCE_RETURNED;
434 case MCI_AVI_STATUS_AUDIO_BREAKS:
435 case MCI_AVI_STATUS_FRAMES_SKIPPED:
436 case MCI_AVI_STATUS_LAST_PLAY_SPEED:
437 case MCI_DGV_STATUS_AUDIO:
438 case MCI_DGV_STATUS_AUDIO_INPUT:
439 case MCI_DGV_STATUS_AUDIO_RECORD:
440 case MCI_DGV_STATUS_AUDIO_SOURCE:
441 case MCI_DGV_SETAUDIO_AVERAGE:
442 case MCI_DGV_SETAUDIO_LEFT:
443 case MCI_DGV_SETAUDIO_RIGHT:
444 case MCI_DGV_SETAUDIO_STEREO:
445 case MCI_DGV_STATUS_AUDIO_STREAM:
446 case MCI_DGV_STATUS_AVGBYTESPERSEC:
447 case MCI_DGV_STATUS_BASS:
448 case MCI_DGV_STATUS_BITSPERPEL:
449 case MCI_DGV_STATUS_BITSPERSAMPLE:
450 case MCI_DGV_STATUS_BLOCKALIGN:
451 case MCI_DGV_STATUS_BRIGHTNESS:
452 case MCI_DGV_STATUS_COLOR:
453 case MCI_DGV_STATUS_CONTRAST:
454 case MCI_DGV_STATUS_FILEFORMAT:
455 case MCI_DGV_STATUS_FILE_MODE:
456 case MCI_DGV_STATUS_FILE_COMPLETION:
457 case MCI_DGV_STATUS_FORWARD:
458 case MCI_DGV_STATUS_FRAME_RATE:
459 case MCI_DGV_STATUS_GAMMA:
461 case MCI_DGV_STATUS_HPAL:
462 lpParms->dwReturn = 0;
463 TRACE("MCI_DGV_STATUS_HPAL => %lx\n", lpParms->dwReturn);
465 case MCI_DGV_STATUS_HWND:
466 lpParms->dwReturn = (DWORD_PTR)wma->hWndPaint;
467 TRACE("MCI_DGV_STATUS_HWND => %p\n", wma->hWndPaint);
470 case MCI_DGV_STATUS_KEY_COLOR:
471 case MCI_DGV_STATUS_KEY_INDEX:
472 case MCI_DGV_STATUS_MONITOR:
473 case MCI_DGV_MONITOR_FILE:
474 case MCI_DGV_MONITOR_INPUT:
475 case MCI_DGV_STATUS_MONITOR_METHOD:
476 case MCI_DGV_STATUS_PAUSE_MODE:
477 case MCI_DGV_STATUS_SAMPLESPERSECOND:
478 case MCI_DGV_STATUS_SEEK_EXACTLY:
479 case MCI_DGV_STATUS_SHARPNESS:
480 case MCI_DGV_STATUS_SIZE:
481 case MCI_DGV_STATUS_SMPTE:
482 case MCI_DGV_STATUS_SPEED:
483 case MCI_DGV_STATUS_STILL_FILEFORMAT:
484 case MCI_DGV_STATUS_TINT:
485 case MCI_DGV_STATUS_TREBLE:
486 case MCI_DGV_STATUS_UNSAVED:
487 case MCI_DGV_STATUS_VIDEO:
488 case MCI_DGV_STATUS_VIDEO_RECORD:
489 case MCI_DGV_STATUS_VIDEO_SOURCE:
490 case MCI_DGV_STATUS_VIDEO_SRC_NUM:
491 case MCI_DGV_STATUS_VIDEO_STREAM:
492 case MCI_DGV_STATUS_VOLUME:
493 case MCI_DGV_STATUS_WINDOW_VISIBLE:
494 case MCI_DGV_STATUS_WINDOW_MINIMIZED:
495 case MCI_DGV_STATUS_WINDOW_MAXIMIZED:
496 case MCI_STATUS_MEDIA_PRESENT:
499 FIXME("Unknown command %08X !\n", lpParms->dwItem);
500 TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms);
501 LeaveCriticalSection(&wma->cs);
502 return MCIERR_UNRECOGNIZED_COMMAND;
505 WARN("No Status-Item!\n");
506 LeaveCriticalSection(&wma->cs);
507 return MCIERR_UNRECOGNIZED_COMMAND;
510 if (dwFlags & MCI_NOTIFY) {
511 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
512 mciDriverNotify(HWND_32(LOWORD(lpParms->dwCallback)),
513 wDevID, MCI_NOTIFY_SUCCESSFUL);
515 LeaveCriticalSection(&wma->cs);