40 #define HWND_MESSAGE ((HWND) -3)
57 switch(biCompression) {
58 case MKTAG(
'U',
'Y',
'V',
'Y'):
60 case MKTAG(
'Y',
'U',
'Y',
'2'):
62 case MKTAG(
'I',
'4',
'2',
'0'):
85 switch(biCompression) {
86 case MKTAG(
'd',
'v',
's',
'd'):
88 case MKTAG(
'M',
'J',
'P',
'G'):
89 case MKTAG(
'm',
'j',
'p',
'g'):
95 #define dstruct(pctx, sname, var, type) \
96 av_log(pctx, AV_LOG_DEBUG, #var":\t%"type"\n", sname->var)
101 dstruct(
s, cparms, dwRequestMicroSecPerFrame,
"lu");
102 dstruct(
s, cparms, fMakeUserHitOKToCapture,
"d");
103 dstruct(
s, cparms, wPercentDropForError,
"u");
105 dstruct(
s, cparms, dwIndexSize,
"lu");
106 dstruct(
s, cparms, wChunkGranularity,
"u");
107 dstruct(
s, cparms, fUsingDOSMemory,
"d");
108 dstruct(
s, cparms, wNumVideoRequested,
"u");
109 dstruct(
s, cparms, fCaptureAudio,
"d");
110 dstruct(
s, cparms, wNumAudioRequested,
"u");
112 dstruct(
s, cparms, fAbortLeftMouse,
"d");
113 dstruct(
s, cparms, fAbortRightMouse,
"d");
114 dstruct(
s, cparms, fLimitEnabled,
"d");
115 dstruct(
s, cparms, wTimeLimit,
"u");
116 dstruct(
s, cparms, fMCIControl,
"d");
117 dstruct(
s, cparms, fStepMCIDevice,
"d");
118 dstruct(
s, cparms, dwMCIStartTime,
"lu");
119 dstruct(
s, cparms, dwMCIStopTime,
"lu");
120 dstruct(
s, cparms, fStepCaptureAt2x,
"d");
121 dstruct(
s, cparms, wStepCaptureAverageFrames,
"u");
122 dstruct(
s, cparms, dwAudioBufferSize,
"lu");
123 dstruct(
s, cparms, fDisableWriteCache,
"d");
124 dstruct(
s, cparms, AVStreamMaster,
"u");
132 dstruct(
s, vhdr, dwBufferLength,
"lu");
133 dstruct(
s, vhdr, dwBytesUsed,
"lu");
134 dstruct(
s, vhdr, dwTimeCaptured,
"lu");
137 dstruct(
s, vhdr, dwReserved[0],
"lu");
138 dstruct(
s, vhdr, dwReserved[1],
"lu");
139 dstruct(
s, vhdr, dwReserved[2],
"lu");
140 dstruct(
s, vhdr, dwReserved[3],
"lu");
152 dstruct(
s, bih, biCompression,
"lu");
154 (
char*) &bih->biCompression);
156 dstruct(
s, bih, biXPelsPerMeter,
"lu");
157 dstruct(
s, bih, biYPelsPerMeter,
"lu");
159 dstruct(
s, bih, biClrImportant,
"lu");
165 static const uint8_t dropscore[4] = { 62, 75, 87, 100 };
167 unsigned int buffer_fullness = (
ctx->curbufsize*100)/
s->max_picture_buffer;
169 if(dropscore[++
ctx->frame_num%ndropscores] <= buffer_fullness) {
171 "real-time buffer %d%% full! frame dropped!\n", buffer_fullness);
203 pktl_next->
pkt.
pts = vdhdr->dwTimeCaptured;
204 memcpy(pktl_next->
pkt.
data, vdhdr->lpData, vdhdr->dwBytesUsed);
206 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
209 ctx->curbufsize += vdhdr->dwBytesUsed;
211 SetEvent(
ctx->event);
212 ReleaseMutex(
ctx->mutex);
216 ReleaseMutex(
ctx->mutex);
226 SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
227 SendMessage(
ctx->hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
228 DestroyWindow(
ctx->hwnd);
231 CloseHandle(
ctx->mutex);
233 CloseHandle(
ctx->event);
253 BITMAPINFO *bi =
NULL;
260 if (!strcmp(
s->url,
"list")) {
261 for (devnum = 0; devnum <= 9; devnum++) {
262 char driver_name[256];
263 char driver_ver[256];
264 ret = capGetDriverDescription(devnum,
265 driver_name,
sizeof(driver_name),
266 driver_ver,
sizeof(driver_ver));
283 devnum = atoi(
s->url);
285 ret = SendMessage(
ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
288 DestroyWindow(
ctx->hwnd);
292 SendMessage(
ctx->hwnd, WM_CAP_SET_OVERLAY, 0, 0);
293 SendMessage(
ctx->hwnd, WM_CAP_SET_PREVIEW, 0, 0);
295 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0,
302 SetWindowLongPtr(
ctx->hwnd, GWLP_USERDATA, (LONG_PTR)
s);
311 bisize = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
319 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
331 if (
ctx->video_size) {
338 bi->bmiHeader.biWidth =
w;
339 bi->bmiHeader.biHeight =
h;
345 bi->bmiHeader.biWidth = 320;
346 bi->bmiHeader.biHeight = 240;
347 bi->bmiHeader.biPlanes = 1;
348 bi->bmiHeader.biBitCount = 12;
349 bi->bmiHeader.biCompression =
MKTAG(
'I',
'4',
'2',
'0');
350 bi->bmiHeader.biSizeImage = 115200;
354 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
360 biCompression = bi->bmiHeader.biCompression;
361 biBitCount = bi->bmiHeader.biBitCount;
364 ret = SendMessage(
ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP,
sizeof(cparms),
372 cparms.dwRequestMicroSecPerFrame =
373 (framerate_q.
den*1000000) / framerate_q.
num;
374 cparms.fAbortLeftMouse = 0;
375 cparms.fAbortRightMouse = 0;
376 cparms.fCaptureAudio = 0;
377 cparms.vKeyAbort = 0;
379 ret = SendMessage(
ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP,
sizeof(cparms),
388 par->
width = bi->bmiHeader.biWidth;
389 par->
height = bi->bmiHeader.biHeight;
401 if(biCompression == BI_RGB) {
426 ret = SendMessage(
ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
450 ctx->pktl =
ctx->pktl->next;
453 ResetEvent(
ctx->event);
454 ReleaseMutex(
ctx->mutex);
469 #define OFFSET(x) offsetof(struct vfw_ctx, x)
470 #define DEC AV_OPT_FLAG_DECODING_PARAM
488 .priv_data_size =
sizeof(
struct vfw_ctx),