32 #define HWND_MESSAGE ((HWND)-3)
50 switch(biCompression) {
51 case MKTAG(
'U',
'Y',
'V',
'Y'):
53 case MKTAG(
'Y',
'U',
'Y',
'2'):
55 case MKTAG(
'I',
'4',
'2',
'0'):
78 switch(biCompression) {
79 case MKTAG(
'd',
'v',
's',
'd'):
81 case MKTAG(
'M',
'J',
'P',
'G'):
82 case MKTAG(
'm',
'j',
'p',
'g'):
88 #define dstruct(pctx, sname, var, type) \
89 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
94 dstruct(s, cparms, dwRequestMicroSecPerFrame,
"lu");
95 dstruct(s, cparms, fMakeUserHitOKToCapture,
"d");
96 dstruct(s, cparms, wPercentDropForError,
"u");
97 dstruct(s, cparms, fYield,
"d");
98 dstruct(s, cparms, dwIndexSize,
"lu");
99 dstruct(s, cparms, wChunkGranularity,
"u");
100 dstruct(s, cparms, fUsingDOSMemory,
"d");
101 dstruct(s, cparms, wNumVideoRequested,
"u");
102 dstruct(s, cparms, fCaptureAudio,
"d");
103 dstruct(s, cparms, wNumAudioRequested,
"u");
104 dstruct(s, cparms, vKeyAbort,
"u");
105 dstruct(s, cparms, fAbortLeftMouse,
"d");
106 dstruct(s, cparms, fAbortRightMouse,
"d");
107 dstruct(s, cparms, fLimitEnabled,
"d");
108 dstruct(s, cparms, wTimeLimit,
"u");
109 dstruct(s, cparms, fMCIControl,
"d");
110 dstruct(s, cparms, fStepMCIDevice,
"d");
111 dstruct(s, cparms, dwMCIStartTime,
"lu");
112 dstruct(s, cparms, dwMCIStopTime,
"lu");
113 dstruct(s, cparms, fStepCaptureAt2x,
"d");
114 dstruct(s, cparms, wStepCaptureAverageFrames,
"u");
115 dstruct(s, cparms, dwAudioBufferSize,
"lu");
116 dstruct(s, cparms, fDisableWriteCache,
"d");
117 dstruct(s, cparms, AVStreamMaster,
"u");
125 dstruct(s, vhdr, dwBufferLength,
"lu");
126 dstruct(s, vhdr, dwBytesUsed,
"lu");
127 dstruct(s, vhdr, dwTimeCaptured,
"lu");
128 dstruct(s, vhdr, dwUser,
"lu");
129 dstruct(s, vhdr, dwFlags,
"lu");
130 dstruct(s, vhdr, dwReserved[0],
"lu");
131 dstruct(s, vhdr, dwReserved[1],
"lu");
132 dstruct(s, vhdr, dwReserved[2],
"lu");
133 dstruct(s, vhdr, dwReserved[3],
"lu");
141 dstruct(s, bih, biWidth,
"ld");
142 dstruct(s, bih, biHeight,
"ld");
143 dstruct(s, bih, biPlanes,
"d");
144 dstruct(s, bih, biBitCount,
"d");
145 dstruct(s, bih, biCompression,
"lu");
147 (
char*) &bih->biCompression);
148 dstruct(s, bih, biSizeImage,
"lu");
149 dstruct(s, bih, biXPelsPerMeter,
"lu");
150 dstruct(s, bih, biYPelsPerMeter,
"lu");
151 dstruct(s, bih, biClrUsed,
"lu");
152 dstruct(s, bih, biClrImportant,
"lu");
158 static const uint8_t dropscore[] = {62, 75, 87, 100};
162 if(dropscore[++ctx->
frame_num%ndropscores] <= buffer_fullness) {
164 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
185 WaitForSingleObject(ctx->
mutex, INFINITE);
196 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
197 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
199 for(ppktl = &ctx->
pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
204 SetEvent(ctx->
event);
205 ReleaseMutex(ctx->
mutex);
209 ReleaseMutex(ctx->
mutex);
219 SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
220 SendMessage(ctx->
hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
221 DestroyWindow(ctx->
hwnd);
224 CloseHandle(ctx->
mutex);
226 CloseHandle(ctx->
event);
231 av_destruct_packet(&pktl->
pkt);
246 BITMAPINFO *bi = NULL;
254 for (devnum = 0; devnum <= 9; devnum++) {
255 char driver_name[256];
256 char driver_ver[256];
257 ret = capGetDriverDescription(devnum,
258 driver_name,
sizeof(driver_name),
259 driver_ver,
sizeof(driver_ver));
278 ret = SendMessage(ctx->
hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
281 DestroyWindow(ctx->
hwnd);
285 SendMessage(ctx->
hwnd, WM_CAP_SET_OVERLAY, 0, 0);
286 SendMessage(ctx->
hwnd, WM_CAP_SET_PREVIEW, 0, 0);
288 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
295 SetWindowLongPtr(ctx->
hwnd, GWLP_USERDATA, (
LONG_PTR) s);
304 bisize = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
312 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
335 bi->bmiHeader.biWidth = 320;
336 bi->bmiHeader.biHeight = 240;
337 bi->bmiHeader.biPlanes = 1;
338 bi->bmiHeader.biBitCount = 12;
339 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
340 bi->bmiHeader.biSizeImage = 115200;
344 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
350 biCompression = bi->bmiHeader.biCompression;
351 biBitCount = bi->bmiHeader.biBitCount;
354 ret = SendMessage(ctx->
hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
362 cparms.dwRequestMicroSecPerFrame =
363 (framerate_q.
den*1000000) / framerate_q.
num;
364 cparms.fAbortLeftMouse = 0;
365 cparms.fAbortRightMouse = 0;
366 cparms.fCaptureAudio = 0;
367 cparms.vKeyAbort = 0;
369 ret = SendMessage(ctx->
hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
377 codec->
width = bi->bmiHeader.biWidth;
378 codec->
height = bi->bmiHeader.biHeight;
384 "Please report verbose (-v 9) debug information.\n");
391 if(biCompression == BI_RGB) {
405 ctx->
mutex = CreateMutex(NULL, 0, NULL);
410 ctx->
event = CreateEvent(NULL, 1, 0, NULL);
416 ret = SendMessage(ctx->
hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
436 WaitForSingleObject(ctx->
mutex, INFINITE);
443 ResetEvent(ctx->
event);
444 ReleaseMutex(ctx->
mutex);
449 WaitForSingleObject(ctx->
event, INFINITE);
459 #define OFFSET(x) offsetof(struct vfw_ctx, x)
460 #define DEC AV_OPT_FLAG_DECODING_PARAM
477 .priv_data_size =
sizeof(
struct vfw_ctx),