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
;
84 EnterCriticalSection(&wma
->cs
);
86 if (dwFlags
& MCI_GETDEVCAPS_ITEM
) {
87 switch (lpParms
->dwItem
) {
88 case MCI_GETDEVCAPS_DEVICE_TYPE
:
89 TRACE("MCI_GETDEVCAPS_DEVICE_TYPE !\n");
90 lpParms
->dwReturn
= MAKEMCIRESOURCE(MCI_DEVTYPE_DIGITAL_VIDEO
, MCI_DEVTYPE_DIGITAL_VIDEO
);
91 ret
= MCI_RESOURCE_RETURNED
;
93 case MCI_GETDEVCAPS_HAS_AUDIO
:
94 TRACE("MCI_GETDEVCAPS_HAS_AUDIO !\n");
95 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
96 ret
= MCI_RESOURCE_RETURNED
;
98 case MCI_GETDEVCAPS_HAS_VIDEO
:
99 TRACE("MCI_GETDEVCAPS_HAS_VIDEO !\n");
100 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
101 ret
= MCI_RESOURCE_RETURNED
;
103 case MCI_GETDEVCAPS_USES_FILES
:
104 TRACE("MCI_GETDEVCAPS_USES_FILES !\n");
105 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
106 ret
= MCI_RESOURCE_RETURNED
;
108 case MCI_GETDEVCAPS_COMPOUND_DEVICE
:
109 TRACE("MCI_GETDEVCAPS_COMPOUND_DEVICE !\n");
110 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
111 ret
= MCI_RESOURCE_RETURNED
;
113 case MCI_GETDEVCAPS_CAN_EJECT
:
114 TRACE("MCI_GETDEVCAPS_CAN_EJECT !\n");
115 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
116 ret
= MCI_RESOURCE_RETURNED
;
118 case MCI_GETDEVCAPS_CAN_PLAY
:
119 TRACE("MCI_GETDEVCAPS_CAN_PLAY !\n");
120 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
121 ret
= MCI_RESOURCE_RETURNED
;
123 case MCI_GETDEVCAPS_CAN_RECORD
:
124 TRACE("MCI_GETDEVCAPS_CAN_RECORD !\n");
125 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
126 ret
= MCI_RESOURCE_RETURNED
;
128 case MCI_GETDEVCAPS_CAN_SAVE
:
129 TRACE("MCI_GETDEVCAPS_CAN_SAVE !\n");
130 lpParms
->dwReturn
= MAKEMCIRESOURCE(FALSE
, MCI_FALSE
);
131 ret
= MCI_RESOURCE_RETURNED
;
134 FIXME("Unknown capability (%08x) !\n", lpParms
->dwItem
);
135 ret
= MCIERR_UNRECOGNIZED_COMMAND
;
139 WARN("No GetDevCaps-Item !\n");
140 ret
= MCIERR_UNRECOGNIZED_COMMAND
;
143 LeaveCriticalSection(&wma
->cs
);
147 /***************************************************************************
148 * MCIAVI_mciInfo [internal]
150 DWORD
MCIAVI_mciInfo(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_INFO_PARMSW lpParms
)
153 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
155 static const WCHAR wszAviPlayer
[] = {'W','i','n','e','\'','s',' ','A','V','I',' ','p','l','a','y','e','r',0};
157 if (lpParms
== NULL
|| lpParms
->lpstrReturn
== NULL
)
158 return MCIERR_NULL_PARAMETER_BLOCK
;
159 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
161 TRACE("buf=%p, len=%u\n", lpParms
->lpstrReturn
, lpParms
->dwRetSize
);
163 EnterCriticalSection(&wma
->cs
);
165 if (dwFlags
& MCI_INFO_PRODUCT
)
167 else if (dwFlags
& MCI_INFO_FILE
)
168 str
= wma
->lpFileName
;
170 WARN("Don't know this info command (%u)\n", dwFlags
);
171 ret
= MCIERR_UNRECOGNIZED_COMMAND
;
174 if (strlenW(str
) + 1 > lpParms
->dwRetSize
) {
175 ret
= MCIERR_PARAM_OVERFLOW
;
177 lstrcpynW(lpParms
->lpstrReturn
, str
, lpParms
->dwRetSize
);
180 lpParms
->lpstrReturn
[0] = 0;
183 LeaveCriticalSection(&wma
->cs
);
187 /***************************************************************************
188 * MCIAVI_mciSet [internal]
190 DWORD
MCIAVI_mciSet(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_SET_PARMS lpParms
)
192 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
194 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
195 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
197 EnterCriticalSection(&wma
->cs
);
199 if (dwFlags
& MCI_SET_TIME_FORMAT
) {
200 switch (lpParms
->dwTimeFormat
) {
201 case MCI_FORMAT_MILLISECONDS
:
202 TRACE("MCI_FORMAT_MILLISECONDS !\n");
203 wma
->dwMciTimeFormat
= MCI_FORMAT_MILLISECONDS
;
205 case MCI_FORMAT_FRAMES
:
206 TRACE("MCI_FORMAT_FRAMES !\n");
207 wma
->dwMciTimeFormat
= MCI_FORMAT_FRAMES
;
210 WARN("Bad time format %u!\n", lpParms
->dwTimeFormat
);
211 LeaveCriticalSection(&wma
->cs
);
212 return MCIERR_BAD_TIME_FORMAT
;
216 if (dwFlags
& MCI_SET_DOOR_OPEN
) {
217 TRACE("No support for door open !\n");
218 LeaveCriticalSection(&wma
->cs
);
219 return MCIERR_UNSUPPORTED_FUNCTION
;
221 if (dwFlags
& MCI_SET_DOOR_CLOSED
) {
222 TRACE("No support for door close !\n");
223 LeaveCriticalSection(&wma
->cs
);
224 return MCIERR_UNSUPPORTED_FUNCTION
;
227 if (dwFlags
& MCI_SET_ON
) {
230 strcpy(buffer
, "MCI_SET_ON:");
232 if (dwFlags
& MCI_SET_VIDEO
) {
233 strncat(buffer
, " video", sizeof(buffer
)-sizeof("MCI_SET_ON:"));
236 if (dwFlags
& MCI_SET_AUDIO
) {
237 strncat(buffer
, " audio", sizeof(buffer
)-sizeof("MCI_SET_ON:"));
238 switch (lpParms
->dwAudio
) {
239 case MCI_SET_AUDIO_ALL
:
240 strncat(buffer
, " all", sizeof(buffer
)-sizeof("MCI_SET_ON:"));
243 case MCI_SET_AUDIO_LEFT
:
244 strncat(buffer
, " left", sizeof(buffer
)-sizeof("MCI_SET_ON:"));
247 case MCI_SET_AUDIO_RIGHT
:
248 strncat(buffer
, " right", sizeof(buffer
)-sizeof("MCI_SET_ON:"));
252 WARN("Unknown audio channel %u\n", lpParms
->dwAudio
);
256 if (dwFlags
& MCI_DGV_SET_SEEK_EXACTLY
) {
257 strncat(buffer
, " seek_exactly", sizeof(buffer
));
259 FIXME("%s\n", buffer
);
262 if (dwFlags
& MCI_SET_OFF
) {
265 strcpy(buffer
, "MCI_SET_OFF:");
266 if (dwFlags
& MCI_SET_VIDEO
) {
267 strncat(buffer
, " video", sizeof(buffer
)-sizeof("MCI_SET_OFF:"));
270 if (dwFlags
& MCI_SET_AUDIO
) {
271 strncat(buffer
, " audio", sizeof(buffer
)-sizeof("MCI_SET_OFF:"));
272 switch (lpParms
->dwAudio
) {
273 case MCI_SET_AUDIO_ALL
:
274 strncat(buffer
, " all", sizeof(buffer
)-sizeof("MCI_SET_OFF:"));
277 case MCI_SET_AUDIO_LEFT
:
278 strncat(buffer
, " left", sizeof(buffer
)-sizeof("MCI_SET_OFF:"));
281 case MCI_SET_AUDIO_RIGHT
:
282 strncat(buffer
, " right", sizeof(buffer
)-sizeof("MCI_SET_OFF:"));
286 WARN("Unknown audio channel %u\n", lpParms
->dwAudio
);
290 if (dwFlags
& MCI_DGV_SET_SEEK_EXACTLY
) {
291 strncat(buffer
, " seek_exactly", sizeof(buffer
)-strlen(buffer
)-1);
293 FIXME("%s\n", buffer
);
295 if (dwFlags
& MCI_DGV_SET_FILEFORMAT
) {
297 if (dwFlags
& MCI_DGV_SET_STILL
)
300 switch (lpParms
->dwFileFormat
) {
301 case MCI_DGV_FF_AVI
: FIXME("Setting file format (%s) to 'AVI'\n", str
); break;
302 case MCI_DGV_FF_AVSS
: FIXME("Setting file format (%s) to 'AVSS'\n", str
); break;
303 case MCI_DGV_FF_DIB
: FIXME("Setting file format (%s) to 'DIB'\n", str
); break;
304 case MCI_DGV_FF_JFIF
: FIXME("Setting file format (%s) to 'JFIF'\n", str
); break;
305 case MCI_DGV_FF_JPEG
: FIXME("Setting file format (%s) to 'JPEG'\n", str
); break;
306 case MCI_DGV_FF_MPEG
: FIXME("Setting file format (%s) to 'MPEG'\n", str
); break;
307 case MCI_DGV_FF_RDIB
: FIXME("Setting file format (%s) to 'RLE DIB'\n", str
); break;
308 case MCI_DGV_FF_RJPEG
: FIXME("Setting file format (%s) to 'RJPEG'\n", str
); break;
309 default: FIXME("Setting unknown file format (%s): %d\n", str
, lpParms
->dwFileFormat
);
313 if (dwFlags
& MCI_DGV_SET_SPEED
) {
314 FIXME("Setting speed to %d\n", lpParms
->dwSpeed
);
317 LeaveCriticalSection(&wma
->cs
);
321 /***************************************************************************
322 * MCIAVI_mciStatus [internal]
324 DWORD
MCIAVI_mciStatus(UINT wDevID
, DWORD dwFlags
, LPMCI_DGV_STATUS_PARMSW lpParms
)
326 WINE_MCIAVI
* wma
= MCIAVI_mciGetOpenDev(wDevID
);
329 if (lpParms
== NULL
) return MCIERR_NULL_PARAMETER_BLOCK
;
330 if (wma
== NULL
) return MCIERR_INVALID_DEVICE_ID
;
332 EnterCriticalSection(&wma
->cs
);
334 if (dwFlags
& MCI_STATUS_ITEM
) {
335 switch (lpParms
->dwItem
) {
336 case MCI_STATUS_CURRENT_TRACK
:
337 lpParms
->dwReturn
= 1;
338 TRACE("MCI_STATUS_CURRENT_TRACK => %lu\n", lpParms
->dwReturn
);
340 case MCI_STATUS_LENGTH
:
342 lpParms
->dwReturn
= 0;
343 LeaveCriticalSection(&wma
->cs
);
344 return MCIERR_UNSUPPORTED_FUNCTION
;
346 /* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
347 lpParms
->dwReturn
= MCIAVI_ConvertFrameToTimeFormat(wma
, wma
->mah
.dwTotalFrames
, &ret
);
348 TRACE("MCI_STATUS_LENGTH => %lu\n", lpParms
->dwReturn
);
350 case MCI_STATUS_MODE
:
351 lpParms
->dwReturn
= MAKEMCIRESOURCE(wma
->dwStatus
, wma
->dwStatus
);
352 ret
= MCI_RESOURCE_RETURNED
;
353 TRACE("MCI_STATUS_MODE => 0x%04x\n", LOWORD(lpParms
->dwReturn
));
355 case MCI_STATUS_MEDIA_PRESENT
:
356 TRACE("MCI_STATUS_MEDIA_PRESENT => TRUE\n");
357 lpParms
->dwReturn
= MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
358 ret
= MCI_RESOURCE_RETURNED
;
360 case MCI_STATUS_NUMBER_OF_TRACKS
:
361 lpParms
->dwReturn
= 1;
362 TRACE("MCI_STATUS_NUMBER_OF_TRACKS => %lu\n", lpParms
->dwReturn
);
364 case MCI_STATUS_POSITION
:
366 lpParms
->dwReturn
= 0;
367 LeaveCriticalSection(&wma
->cs
);
368 return MCIERR_UNSUPPORTED_FUNCTION
;
370 /* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
371 lpParms
->dwReturn
= MCIAVI_ConvertFrameToTimeFormat(wma
,
372 (dwFlags
& MCI_STATUS_START
) ? 0 : wma
->dwCurrVideoFrame
,
374 TRACE("MCI_STATUS_POSITION %s => %lu\n",
375 (dwFlags
& MCI_STATUS_START
) ? "start" : "current", lpParms
->dwReturn
);
377 case MCI_STATUS_READY
:
378 lpParms
->dwReturn
= (wma
->dwStatus
== MCI_MODE_NOT_READY
) ?
379 MAKEMCIRESOURCE(FALSE
, MCI_FALSE
) : MAKEMCIRESOURCE(TRUE
, MCI_TRUE
);
380 ret
= MCI_RESOURCE_RETURNED
;
381 TRACE("MCI_STATUS_READY = %u\n", LOWORD(lpParms
->dwReturn
));
383 case MCI_STATUS_TIME_FORMAT
:
384 lpParms
->dwReturn
= MAKEMCIRESOURCE(wma
->dwMciTimeFormat
,
385 wma
->dwMciTimeFormat
+ MCI_FORMAT_RETURN_BASE
);
386 TRACE("MCI_STATUS_TIME_FORMAT => %u\n", LOWORD(lpParms
->dwReturn
));
387 ret
= MCI_RESOURCE_RETURNED
;
390 case MCI_AVI_STATUS_AUDIO_BREAKS
:
391 case MCI_AVI_STATUS_FRAMES_SKIPPED
:
392 case MCI_AVI_STATUS_LAST_PLAY_SPEED
:
393 case MCI_DGV_STATUS_AUDIO
:
394 case MCI_DGV_STATUS_AUDIO_INPUT
:
395 case MCI_DGV_STATUS_AUDIO_RECORD
:
396 case MCI_DGV_STATUS_AUDIO_SOURCE
:
397 case MCI_DGV_SETAUDIO_AVERAGE
:
398 case MCI_DGV_SETAUDIO_LEFT
:
399 case MCI_DGV_SETAUDIO_RIGHT
:
400 case MCI_DGV_SETAUDIO_STEREO
:
401 case MCI_DGV_STATUS_AUDIO_STREAM
:
402 case MCI_DGV_STATUS_AVGBYTESPERSEC
:
403 case MCI_DGV_STATUS_BASS
:
404 case MCI_DGV_STATUS_BITSPERPEL
:
405 case MCI_DGV_STATUS_BITSPERSAMPLE
:
406 case MCI_DGV_STATUS_BLOCKALIGN
:
407 case MCI_DGV_STATUS_BRIGHTNESS
:
408 case MCI_DGV_STATUS_COLOR
:
409 case MCI_DGV_STATUS_CONTRAST
:
410 case MCI_DGV_STATUS_FILEFORMAT
:
411 case MCI_DGV_STATUS_FILE_MODE
:
412 case MCI_DGV_STATUS_FILE_COMPLETION
:
413 case MCI_DGV_STATUS_FORWARD
:
414 case MCI_DGV_STATUS_FRAME_RATE
:
415 case MCI_DGV_STATUS_GAMMA
:
417 case MCI_DGV_STATUS_HPAL
:
418 lpParms
->dwReturn
= 0;
419 TRACE("MCI_DGV_STATUS_HPAL => %lx\n", lpParms
->dwReturn
);
421 case MCI_DGV_STATUS_HWND
:
422 lpParms
->dwReturn
= (DWORD_PTR
)wma
->hWndPaint
;
423 TRACE("MCI_DGV_STATUS_HWND => %p\n", wma
->hWndPaint
);
426 case MCI_DGV_STATUS_KEY_COLOR
:
427 case MCI_DGV_STATUS_KEY_INDEX
:
428 case MCI_DGV_STATUS_MONITOR
:
429 case MCI_DGV_MONITOR_FILE
:
430 case MCI_DGV_MONITOR_INPUT
:
431 case MCI_DGV_STATUS_MONITOR_METHOD
:
432 case MCI_DGV_STATUS_PAUSE_MODE
:
433 case MCI_DGV_STATUS_SAMPLESPERSECOND
:
434 case MCI_DGV_STATUS_SEEK_EXACTLY
:
435 case MCI_DGV_STATUS_SHARPNESS
:
436 case MCI_DGV_STATUS_SIZE
:
437 case MCI_DGV_STATUS_SMPTE
:
438 case MCI_DGV_STATUS_SPEED
:
439 case MCI_DGV_STATUS_STILL_FILEFORMAT
:
440 case MCI_DGV_STATUS_TINT
:
441 case MCI_DGV_STATUS_TREBLE
:
442 case MCI_DGV_STATUS_UNSAVED
:
443 case MCI_DGV_STATUS_VIDEO
:
444 case MCI_DGV_STATUS_VIDEO_RECORD
:
445 case MCI_DGV_STATUS_VIDEO_SOURCE
:
446 case MCI_DGV_STATUS_VIDEO_SRC_NUM
:
447 case MCI_DGV_STATUS_VIDEO_STREAM
:
448 case MCI_DGV_STATUS_VOLUME
:
449 case MCI_DGV_STATUS_WINDOW_VISIBLE
:
450 case MCI_DGV_STATUS_WINDOW_MINIMIZED
:
451 case MCI_DGV_STATUS_WINDOW_MAXIMIZED
:
452 case MCI_STATUS_MEDIA_PRESENT
:
455 FIXME("Unknown command %08X !\n", lpParms
->dwItem
);
456 TRACE("(%04x, %08X, %p)\n", wDevID
, dwFlags
, lpParms
);
457 LeaveCriticalSection(&wma
->cs
);
458 return MCIERR_UNRECOGNIZED_COMMAND
;
461 WARN("No Status-Item!\n");
462 LeaveCriticalSection(&wma
->cs
);
463 return MCIERR_UNRECOGNIZED_COMMAND
;
466 if (dwFlags
& MCI_NOTIFY
) {
467 TRACE("MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms
->dwCallback
);
468 mciDriverNotify(HWND_32(LOWORD(lpParms
->dwCallback
)),
469 wDevID
, MCI_NOTIFY_SUCCESSFUL
);
471 LeaveCriticalSection(&wma
->cs
);