32 #define HWND_MESSAGE ((HWND) -3)
49 switch(biCompression) {
50 case MKTAG(
'U',
'Y',
'V',
'Y'):
52 case MKTAG(
'Y',
'U',
'Y',
'2'):
54 case MKTAG(
'I',
'4',
'2',
'0'):
77 switch(biCompression) {
78 case MKTAG(
'd',
'v',
's',
'd'):
80 case MKTAG(
'M',
'J',
'P',
'G'):
81 case MKTAG(
'm',
'j',
'p',
'g'):
87 #define dstruct(pctx, sname, var, type) \
88 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
93 dstruct(s, cparms, dwRequestMicroSecPerFrame,
"lu");
94 dstruct(s, cparms, fMakeUserHitOKToCapture,
"d");
95 dstruct(s, cparms, wPercentDropForError,
"u");
96 dstruct(s, cparms, fYield,
"d");
97 dstruct(s, cparms, dwIndexSize,
"lu");
98 dstruct(s, cparms, wChunkGranularity,
"u");
99 dstruct(s, cparms, fUsingDOSMemory,
"d");
100 dstruct(s, cparms, wNumVideoRequested,
"u");
101 dstruct(s, cparms, fCaptureAudio,
"d");
102 dstruct(s, cparms, wNumAudioRequested,
"u");
103 dstruct(s, cparms, vKeyAbort,
"u");
104 dstruct(s, cparms, fAbortLeftMouse,
"d");
105 dstruct(s, cparms, fAbortRightMouse,
"d");
106 dstruct(s, cparms, fLimitEnabled,
"d");
107 dstruct(s, cparms, wTimeLimit,
"u");
108 dstruct(s, cparms, fMCIControl,
"d");
109 dstruct(s, cparms, fStepMCIDevice,
"d");
110 dstruct(s, cparms, dwMCIStartTime,
"lu");
111 dstruct(s, cparms, dwMCIStopTime,
"lu");
112 dstruct(s, cparms, fStepCaptureAt2x,
"d");
113 dstruct(s, cparms, wStepCaptureAverageFrames,
"u");
114 dstruct(s, cparms, dwAudioBufferSize,
"lu");
115 dstruct(s, cparms, fDisableWriteCache,
"d");
116 dstruct(s, cparms, AVStreamMaster,
"u");
124 dstruct(s, vhdr, dwBufferLength,
"lu");
125 dstruct(s, vhdr, dwBytesUsed,
"lu");
126 dstruct(s, vhdr, dwTimeCaptured,
"lu");
127 dstruct(s, vhdr, dwUser,
"lu");
128 dstruct(s, vhdr, dwFlags,
"lu");
129 dstruct(s, vhdr, dwReserved[0],
"lu");
130 dstruct(s, vhdr, dwReserved[1],
"lu");
131 dstruct(s, vhdr, dwReserved[2],
"lu");
132 dstruct(s, vhdr, dwReserved[3],
"lu");
140 dstruct(s, bih, biWidth,
"ld");
141 dstruct(s, bih, biHeight,
"ld");
142 dstruct(s, bih, biPlanes,
"d");
143 dstruct(s, bih, biBitCount,
"d");
144 dstruct(s, bih, biCompression,
"lu");
146 (
char*) &bih->biCompression);
147 dstruct(s, bih, biSizeImage,
"lu");
148 dstruct(s, bih, biXPelsPerMeter,
"lu");
149 dstruct(s, bih, biYPelsPerMeter,
"lu");
150 dstruct(s, bih, biClrUsed,
"lu");
151 dstruct(s, bih, biClrImportant,
"lu");
157 static const uint8_t dropscore[] = {62, 75, 87, 100};
161 if(dropscore[++ctx->
frame_num%ndropscores] <= buffer_fullness) {
163 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
184 WaitForSingleObject(ctx->
mutex, INFINITE);
195 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
196 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
198 for(ppktl = &ctx->
pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
203 SetEvent(ctx->
event);
204 ReleaseMutex(ctx->
mutex);
208 ReleaseMutex(ctx->
mutex);
218 SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
219 SendMessage(ctx->
hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
220 DestroyWindow(ctx->
hwnd);
223 CloseHandle(ctx->
mutex);
225 CloseHandle(ctx->
event);
245 BITMAPINFO *bi =
NULL;
253 for (devnum = 0; devnum <= 9; devnum++) {
254 char driver_name[256];
255 char driver_ver[256];
256 ret = capGetDriverDescription(devnum,
257 driver_name,
sizeof(driver_name),
258 driver_ver,
sizeof(driver_ver));
277 ret = SendMessage(ctx->
hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
280 DestroyWindow(ctx->
hwnd);
284 SendMessage(ctx->
hwnd, WM_CAP_SET_OVERLAY, 0, 0);
285 SendMessage(ctx->
hwnd, WM_CAP_SET_PREVIEW, 0, 0);
287 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
294 SetWindowLongPtr(ctx->
hwnd, GWLP_USERDATA, (
LONG_PTR) s);
303 bisize = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
311 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
334 bi->bmiHeader.biWidth = 320;
335 bi->bmiHeader.biHeight = 240;
336 bi->bmiHeader.biPlanes = 1;
337 bi->bmiHeader.biBitCount = 12;
338 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
339 bi->bmiHeader.biSizeImage = 115200;
343 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
349 biCompression = bi->bmiHeader.biCompression;
350 biBitCount = bi->bmiHeader.biBitCount;
353 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
361 cparms.dwRequestMicroSecPerFrame =
362 (framerate_q.
den*1000000) / framerate_q.
num;
363 cparms.fAbortLeftMouse = 0;
364 cparms.fAbortRightMouse = 0;
365 cparms.fCaptureAudio = 0;
366 cparms.vKeyAbort = 0;
368 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
376 codec->
width = bi->bmiHeader.biWidth;
377 codec->
height = bi->bmiHeader.biHeight;
383 "Please report verbose (-v 9) debug information.\n");
390 if(biCompression == BI_RGB) {
415 ret = SendMessage(ctx->
hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
435 WaitForSingleObject(ctx->
mutex, INFINITE);
442 ResetEvent(ctx->
event);
443 ReleaseMutex(ctx->
mutex);
448 WaitForSingleObject(ctx->
event, INFINITE);
458 #define OFFSET(x) offsetof(struct vfw_ctx, x)
459 #define DEC AV_OPT_FLAG_DECODING_PARAM
477 .priv_data_size =
sizeof(
struct vfw_ctx),