32 #define HWND_MESSAGE ((HWND)-3)
52 switch(biCompression) {
53 case MKTAG(
'U',
'Y',
'V',
'Y'):
55 case MKTAG(
'Y',
'U',
'Y',
'2'):
57 case MKTAG(
'I',
'4',
'2',
'0'):
80 switch(biCompression) {
81 case MKTAG(
'd',
'v',
's',
'd'):
83 case MKTAG(
'M',
'J',
'P',
'G'):
84 case MKTAG(
'm',
'j',
'p',
'g'):
90 #define dstruct(pctx, sname, var, type) \
91 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
96 dstruct(s, cparms, dwRequestMicroSecPerFrame,
"lu");
97 dstruct(s, cparms, fMakeUserHitOKToCapture,
"d");
98 dstruct(s, cparms, wPercentDropForError,
"u");
99 dstruct(s, cparms, fYield,
"d");
100 dstruct(s, cparms, dwIndexSize,
"lu");
101 dstruct(s, cparms, wChunkGranularity,
"u");
102 dstruct(s, cparms, fUsingDOSMemory,
"d");
103 dstruct(s, cparms, wNumVideoRequested,
"u");
104 dstruct(s, cparms, fCaptureAudio,
"d");
105 dstruct(s, cparms, wNumAudioRequested,
"u");
106 dstruct(s, cparms, vKeyAbort,
"u");
107 dstruct(s, cparms, fAbortLeftMouse,
"d");
108 dstruct(s, cparms, fAbortRightMouse,
"d");
109 dstruct(s, cparms, fLimitEnabled,
"d");
110 dstruct(s, cparms, wTimeLimit,
"u");
111 dstruct(s, cparms, fMCIControl,
"d");
112 dstruct(s, cparms, fStepMCIDevice,
"d");
113 dstruct(s, cparms, dwMCIStartTime,
"lu");
114 dstruct(s, cparms, dwMCIStopTime,
"lu");
115 dstruct(s, cparms, fStepCaptureAt2x,
"d");
116 dstruct(s, cparms, wStepCaptureAverageFrames,
"u");
117 dstruct(s, cparms, dwAudioBufferSize,
"lu");
118 dstruct(s, cparms, fDisableWriteCache,
"d");
119 dstruct(s, cparms, AVStreamMaster,
"u");
127 dstruct(s, vhdr, dwBufferLength,
"lu");
128 dstruct(s, vhdr, dwBytesUsed,
"lu");
129 dstruct(s, vhdr, dwTimeCaptured,
"lu");
130 dstruct(s, vhdr, dwUser,
"lu");
131 dstruct(s, vhdr, dwFlags,
"lu");
132 dstruct(s, vhdr, dwReserved[0],
"lu");
133 dstruct(s, vhdr, dwReserved[1],
"lu");
134 dstruct(s, vhdr, dwReserved[2],
"lu");
135 dstruct(s, vhdr, dwReserved[3],
"lu");
143 dstruct(s, bih, biWidth,
"ld");
144 dstruct(s, bih, biHeight,
"ld");
145 dstruct(s, bih, biPlanes,
"d");
146 dstruct(s, bih, biBitCount,
"d");
147 dstruct(s, bih, biCompression,
"lu");
149 (
char*) &bih->biCompression);
150 dstruct(s, bih, biSizeImage,
"lu");
151 dstruct(s, bih, biXPelsPerMeter,
"lu");
152 dstruct(s, bih, biYPelsPerMeter,
"lu");
153 dstruct(s, bih, biClrUsed,
"lu");
154 dstruct(s, bih, biClrImportant,
"lu");
160 const uint8_t dropscore[] = {62, 75, 87, 100};
164 if(dropscore[++ctx->
frame_num%ndropscores] <= buffer_fullness) {
166 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
187 WaitForSingleObject(ctx->
mutex, INFINITE);
198 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
199 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
201 for(ppktl = &ctx->
pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
206 SetEvent(ctx->
event);
207 ReleaseMutex(ctx->
mutex);
211 ReleaseMutex(ctx->
mutex);
221 SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
222 SendMessage(ctx->
hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
223 DestroyWindow(ctx->
hwnd);
226 CloseHandle(ctx->
mutex);
228 CloseHandle(ctx->
event);
256 for (devnum = 0; devnum <= 9; devnum++) {
257 char driver_name[256];
258 char driver_ver[256];
259 ret = capGetDriverDescription(devnum,
260 driver_name,
sizeof(driver_name),
261 driver_ver,
sizeof(driver_ver));
280 ret = SendMessage(ctx->
hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
283 DestroyWindow(ctx->
hwnd);
287 SendMessage(ctx->
hwnd, WM_CAP_SET_OVERLAY, 0, 0);
288 SendMessage(ctx->
hwnd, WM_CAP_SET_PREVIEW, 0, 0);
290 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
297 SetWindowLongPtr(ctx->
hwnd, GWLP_USERDATA, (LONG_PTR) s);
306 bisize = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
314 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
332 bi->bmiHeader.biWidth = 320;
333 bi->bmiHeader.biHeight = 240;
334 bi->bmiHeader.biPlanes = 1;
335 bi->bmiHeader.biBitCount = 12;
336 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
337 bi->bmiHeader.biSizeImage = 115200;
341 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
347 biCompression = bi->bmiHeader.biCompression;
348 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) {
413 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
476 .priv_data_size =
sizeof(
struct vfw_ctx),