50 #include "d3d9types.h"
53 #ifndef AMCONTROL_COLORINFO_PRESENT
55 # define AMCONTROL_COLORINFO_PRESENT 0x00000080 // if set, indicates DXVA color info is present in the upper (24) bits of the dwControlFlags
61 switch(biCompression) {
84 switch (fmt_info->NominalRange)
86 case DXVA2_NominalRange_Unknown:
88 case DXVA2_NominalRange_Normal:
90 case DXVA2_NominalRange_Wide:
92 case DXVA2_NominalRange_48_208:
108 switch (fmt_info->VideoTransferMatrix)
110 case DXVA2_VideoTransferMatrix_BT709:
112 case DXVA2_VideoTransferMatrix_BT601:
114 case DXVA2_VideoTransferMatrix_SMPTE240M:
120 if (fmt_info->VideoTransferFunction == 12)
132 switch (fmt_info->VideoPrimaries)
134 case DXVA2_VideoPrimaries_Unknown:
136 case DXVA2_VideoPrimaries_reserved:
138 case DXVA2_VideoPrimaries_BT709:
140 case DXVA2_VideoPrimaries_BT470_2_SysM:
142 case DXVA2_VideoPrimaries_BT470_2_SysBG:
143 case DXVA2_VideoPrimaries_EBU3213:
145 case DXVA2_VideoPrimaries_SMPTE170M:
146 case DXVA2_VideoPrimaries_SMPTE_C:
148 case DXVA2_VideoPrimaries_SMPTE240M:
169 switch (fmt_info->VideoTransferFunction)
171 case DXVA2_VideoTransFunc_Unknown:
173 case DXVA2_VideoTransFunc_10:
175 case DXVA2_VideoTransFunc_18:
178 case DXVA2_VideoTransFunc_20:
181 case DXVA2_VideoTransFunc_22:
183 case DXVA2_VideoTransFunc_709:
185 case DXVA2_VideoTransFunc_240M:
187 case DXVA2_VideoTransFunc_sRGB:
189 case DXVA2_VideoTransFunc_28:
202 if (fmt_info->VideoTransferMatrix == 5)
224 if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Cosited)
226 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_MPEG1)
228 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_MPEG2)
230 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_DV_PAL)
244 IMediaControl_Stop(
ctx->control);
245 IMediaControl_Release(
ctx->control);
248 if (
ctx->media_event)
249 IMediaEvent_Release(
ctx->media_event);
254 r = IGraphBuilder_EnumFilters(
ctx->graph, &fenum);
257 IEnumFilters_Reset(fenum);
258 while (IEnumFilters_Next(fenum, 1, &
f,
NULL) == S_OK) {
259 if (IGraphBuilder_RemoveFilter(
ctx->graph,
f) == S_OK)
260 IEnumFilters_Reset(fenum);
262 IBaseFilter_Release(
f);
264 IEnumFilters_Release(fenum);
266 IGraphBuilder_Release(
ctx->graph);
293 CloseHandle(
ctx->mutex);
295 CloseHandle(
ctx->event[0]);
297 CloseHandle(
ctx->event[1]);
315 int l = WideCharToMultiByte(CP_UTF8, 0,
w, -1, 0, 0, 0, 0);
318 WideCharToMultiByte(CP_UTF8, 0,
w, -1,
s, l, 0, 0);
325 static const uint8_t dropscore[] = {62, 75, 87, 100};
327 unsigned int buffer_fullness = (
ctx->curbufsize[
index]*100)/
s->max_picture_buffer;
328 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio";
330 if(dropscore[++
ctx->video_frame_num%ndropscores] <= buffer_fullness) {
332 "real-time buffer [%s] [%s input] too full or near too full (%d%% of size: %d [rtbufsize parameter])! frame dropped!\n",
333 ctx->device_name[devtype], devtypename, buffer_fullness,
s->max_picture_buffer);
364 pktl_next->
pkt.
pts = time;
365 memcpy(pktl_next->
pkt.
data, buf, buf_size);
367 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
371 SetEvent(
ctx->event[1]);
372 ReleaseMutex(
ctx->mutex);
376 ReleaseMutex(
ctx->mutex);
383 enum AVMediaType **media_types,
int *nb_media_types)
387 int has_audio = 0, has_video = 0;
392 while (IEnumPins_Next(pins, 1, &pin,
NULL) == S_OK) {
393 IKsPropertySet *p =
NULL;
394 PIN_INFO
info = { 0 };
397 IEnumMediaTypes *types =
NULL;
400 if (IPin_QueryPinInfo(pin, &
info) != S_OK)
402 IBaseFilter_Release(
info.pFilter);
404 if (
info.dir != PINDIR_OUTPUT)
406 if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (
void **) &p) != S_OK)
408 if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
411 if (!IsEqualGUID(&
category, &PIN_CATEGORY_CAPTURE))
414 if (IPin_EnumMediaTypes(pin, &types) != S_OK)
419 IEnumMediaTypes_Reset(types);
420 while (IEnumMediaTypes_Next(types, 1, &
type,
NULL) == S_OK) {
421 if (IsEqualGUID(&
type->majortype, &MEDIATYPE_Video)) {
423 }
else if (IsEqualGUID(&
type->majortype, &MEDIATYPE_Audio)) {
431 IEnumMediaTypes_Release(types);
433 IKsPropertySet_Release(p);
438 IEnumPins_Release(pins);
440 if (has_audio || has_video) {
441 int nb_types = has_audio + has_video;
448 *nb_media_types = nb_types;
469 IEnumMoniker *classenum =
NULL;
473 :
ctx->audio_device_number;
476 const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
477 &CLSID_AudioInputDeviceCategory };
478 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio only";
479 const char *sourcetypename = (sourcetype ==
VideoSourceDevice) ?
"video" :
"audio";
481 r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[sourcetype],
482 (IEnumMoniker **) &classenum, 0);
490 IPropertyBag *bag =
NULL;
492 char *unique_name =
NULL;
494 IBindCtx *bind_ctx =
NULL;
495 LPOLESTR olestr =
NULL;
496 LPMALLOC co_malloc =
NULL;
499 int nb_media_types = 0;
502 r = CoGetMalloc(1, &co_malloc);
505 r = CreateBindCtx(0, &bind_ctx);
509 r = IMoniker_GetDisplayName(m, bind_ctx,
NULL, &olestr);
514 for (
i = 0;
i < strlen(unique_name);
i++) {
515 if (unique_name[
i] ==
':')
516 unique_name[
i] =
'_';
519 r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (
void *) &bag);
524 r = IPropertyBag_Read(bag,
L"FriendlyName", &var,
NULL);
534 r = IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (
void *) &
device_filter);
545 if (IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (
void* ) &
device_filter) == S_OK) {
562 (*device_list)->nb_devices + 1,
563 sizeof(*(*device_list)->devices)) < 0)
573 (*device_list)->devices[(*device_list)->nb_devices] = device;
574 (*device_list)->nb_devices++;
579 if (nb_media_types > 0) {
582 for (
int i = 1;
i < nb_media_types; ++
i) {
603 if (olestr && co_malloc)
604 IMalloc_Free(co_malloc, olestr);
606 IBindCtx_Release(bind_ctx);
610 IPropertyBag_Release(bag);
614 IEnumMoniker_Release(classenum);
618 av_log(avctx,
AV_LOG_ERROR,
"Could not find %s device with name [%s] among source devices of type %s.\n",
630 ICreateDevEnum *devenum =
NULL;
639 r = CoCreateInstance(&CLSID_SystemDeviceEnum,
NULL, CLSCTX_INPROC_SERVER,
640 &IID_ICreateDevEnum, (
void**)&devenum);
653 ICreateDevEnum_Release(devenum);
665 (
ctx->requested_width &&
ctx->requested_height) ||
695 BITMAPINFOHEADER *bih;
696 DXVA2_ExtendedFormat *extended_format_info =
NULL;
704 if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo)) {
705 VIDEOINFOHEADER *v = (
void *)
type->pbFormat;
709 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo2)) {
710 VIDEOINFOHEADER2 *v = (
void *)
type->pbFormat;
715 extended_format_info = (DXVA2_ExtendedFormat *) &v->dwControlFlags;
716 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx)) {
717 fx = (
void *)
type->pbFormat;
734 fmt_info->
width = bih->biWidth;
735 fmt_info->
height = bih->biHeight;
745 if (extended_format_info) {
765 if ((hr = IAMStreamConfig_GetFormat(
config,
type)) != S_OK) {
766 if (hr == E_NOTIMPL || !IsEqualGUID(&(*type)->majortype,
devtype ==
VideoDevice ? &MEDIATYPE_Video : &MEDIATYPE_Audio)) {
770 IEnumMediaTypes* types =
NULL;
771 if (IPin_EnumMediaTypes(pin, &types) != S_OK)
773 IEnumMediaTypes_Reset(types);
774 while (IEnumMediaTypes_Next(types, 1,
type,
NULL) == S_OK) {
775 if (IsEqualGUID(&(*type)->majortype,
devtype ==
VideoDevice ? &MEDIATYPE_Video : &MEDIATYPE_Audio)) {
778 CoTaskMemFree(*
type);
781 IEnumMediaTypes_Release(types);
795 IPin *pin,
int *pformat_set)
800 AM_MEDIA_TYPE *previous_match_type =
NULL;
804 int wait_for_better = 0;
814 /
ctx->requested_framerate.num : 0;
818 int requested_sample_rate =
ctx->sample_rate;
819 int requested_sample_size =
ctx->sample_size;
820 int requested_channels =
ctx->channels;
822 if (IPin_QueryInterface(pin, &IID_IAMStreamConfig, (
void **) &
config) != S_OK)
824 if (IAMStreamConfig_GetNumberOfCapabilities(
config, &n, &
size) != S_OK)
839 if (use_default && pformat_set)
852 requested_video_codec_id = fmt_info->
codec_id;
853 requested_pixel_format = fmt_info->
pix_fmt;
854 requested_framerate = fmt_info->
framerate;
855 requested_width = fmt_info->
width;
856 requested_height = fmt_info->
height;
860 requested_channels = fmt_info->
channels;
866 CoTaskMemFree(
type->pbFormat);
885 for (
i = 0;
i < n && !format_set;
i++) {
887 r = IAMStreamConfig_GetStreamCaps(
config,
i, &
type, (
void *) caps);
899 VIDEO_STREAM_CONFIG_CAPS *vcaps = caps;
900 BITMAPINFOHEADER *bih;
909 if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo)) {
910 VIDEOINFOHEADER *v = (
void *)
type->pbFormat;
911 fr = &v->AvgTimePerFrame;
914 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo2)) {
915 VIDEOINFOHEADER2 *v = (
void *)
type->pbFormat;
916 fr = &v->AvgTimePerFrame;
926 av_log(avctx,
AV_LOG_INFO,
" unknown compression type 0x%X", (
int) bih->biCompression);
934 vcaps->MinOutputSize.cx, vcaps->MinOutputSize.cy,
935 1e7 / vcaps->MaxFrameInterval,
936 vcaps->MaxOutputSize.cx, vcaps->MaxOutputSize.cy,
937 1e7 / vcaps->MinFrameInterval);
948 range ? range :
"unknown",
950 prim ? prim :
"unknown",
951 trc ? trc :
"unknown");
963 if (requested_video_codec_id != fmt_info->
codec_id)
967 requested_pixel_format != fmt_info->
pix_fmt) {
970 if (requested_framerate) {
971 if (requested_framerate > vcaps->MaxFrameInterval ||
972 requested_framerate < vcaps->MinFrameInterval)
974 *fr = requested_framerate;
976 if (requested_width && requested_height) {
977 if (requested_width > vcaps->MaxOutputSize.cx ||
978 requested_width < vcaps->MinOutputSize.cx ||
979 requested_height > vcaps->MaxOutputSize.cy ||
980 requested_height < vcaps->MinOutputSize.cy)
982 bih->biWidth = requested_width;
983 bih->biHeight = requested_height;
987 AUDIO_STREAM_CONFIG_CAPS *acaps = caps;
991 if (IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx)) {
992 fx = (
void *)
type->pbFormat;
1000 " ch=%2u, bits=%2u, rate=%6lu\n",
1001 fx->nChannels, fx->wBitsPerSample, fx->nSamplesPerSec
1006 (requested_sample_rate && requested_sample_rate != fx->nSamplesPerSec) ||
1007 (requested_sample_size && requested_sample_size != fx->wBitsPerSample) ||
1008 (requested_channels && requested_channels != fx->nChannels )
1018 if (!wait_for_better) {
1019 if (IAMStreamConfig_SetFormat(
config,
type) != S_OK)
1023 else if (!previous_match_type) {
1026 previous_match_type =
type;
1032 CoTaskMemFree(
type->pbFormat);
1033 CoTaskMemFree(
type);
1038 if (pformat_set && !format_set) {
1039 if (previous_match_type) {
1046 if (IAMStreamConfig_SetFormat(
config, previous_match_type) == S_OK)
1049 else if (use_default) {
1054 if (IAMStreamConfig_SetFormat(
config,
type) == S_OK)
1057 CoTaskMemFree(
type->pbFormat);
1058 CoTaskMemFree(
type);
1064 if (previous_match_type && previous_match_type->pbFormat)
1065 CoTaskMemFree(previous_match_type->pbFormat);
1066 CoTaskMemFree(previous_match_type);
1067 IAMStreamConfig_Release(
config);
1070 *pformat_set = format_set;
1081 IAMBufferNegotiation *buffer_negotiation =
NULL;
1082 ALLOCATOR_PROPERTIES props = { -1, -1, -1, -1 };
1087 if (IPin_QueryInterface(pin, &IID_IAMStreamConfig, (
void **) &
config) != S_OK)
1089 if (IAMStreamConfig_GetFormat(
config, &
type) != S_OK)
1091 if (!IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx))
1094 props.cbBuffer = (((WAVEFORMATEX *)
type->pbFormat)->nAvgBytesPerSec)
1095 *
ctx->audio_buffer_size / 1000;
1097 if (IPin_QueryInterface(pin, &IID_IAMBufferNegotiation, (
void **) &buffer_negotiation) != S_OK)
1099 if (IAMBufferNegotiation_SuggestAllocatorProperties(buffer_negotiation, &props) != S_OK)
1105 if (buffer_negotiation)
1106 IAMBufferNegotiation_Release(buffer_negotiation);
1109 CoTaskMemFree(
type->pbFormat);
1110 CoTaskMemFree(
type);
1113 IAMStreamConfig_Release(
config);
1123 ISpecifyPropertyPages *property_pages =
NULL;
1124 IUnknown *device_filter_iunknown =
NULL;
1126 FILTER_INFO filter_info = {0};
1127 CAUUID ca_guid = {0};
1129 hr = IBaseFilter_QueryInterface(
device_filter, &IID_ISpecifyPropertyPages, (
void **)&property_pages);
1134 hr = IBaseFilter_QueryFilterInfo(
device_filter, &filter_info);
1138 hr = IBaseFilter_QueryInterface(
device_filter, &IID_IUnknown, (
void **)&device_filter_iunknown);
1142 hr = ISpecifyPropertyPages_GetPages(property_pages, &ca_guid);
1146 hr = OleCreatePropertyFrame(
NULL, 0, 0, filter_info.achName, 1, &device_filter_iunknown, ca_guid.cElems,
1147 ca_guid.pElems, 0, 0,
NULL);
1156 ISpecifyPropertyPages_Release(property_pages);
1157 if (device_filter_iunknown)
1158 IUnknown_Release(device_filter_iunknown);
1159 if (filter_info.pGraph)
1160 IFilterGraph_Release(filter_info.pGraph);
1162 CoTaskMemFree(ca_guid.pElems);
1176 IEnumPins *pins = 0;
1181 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio only";
1182 const char *sourcetypename = (sourcetype ==
VideoSourceDevice) ?
"video" :
"audio";
1186 int should_show_properties = (devtype ==
VideoDevice) ?
ctx->show_video_device_dialog :
ctx->show_audio_device_dialog;
1188 if (should_show_properties)
1199 devtypename, sourcetypename);
1202 while (!
device_pin && IEnumPins_Next(pins, 1, &pin,
NULL) == S_OK) {
1203 IKsPropertySet *p =
NULL;
1204 PIN_INFO
info = {0};
1207 char *name_buf =
NULL;
1208 wchar_t *pin_id =
NULL;
1209 char *pin_buf =
NULL;
1210 char *desired_pin_name = devtype ==
VideoDevice ?
ctx->video_pin_name :
ctx->audio_pin_name;
1212 IPin_QueryPinInfo(pin, &
info);
1213 IBaseFilter_Release(
info.pFilter);
1215 if (
info.dir != PINDIR_OUTPUT)
1217 if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (
void **) &p) != S_OK)
1219 if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
1222 if (!IsEqualGUID(&
category, &PIN_CATEGORY_CAPTURE))
1226 r = IPin_QueryId(pin, &pin_id);
1234 av_log(avctx,
AV_LOG_INFO,
" Pin \"%s\" (alternative pin name \"%s\")\n", name_buf, pin_buf);
1239 if (desired_pin_name) {
1240 if(strcmp(name_buf, desired_pin_name) && strcmp(pin_buf, desired_pin_name)) {
1242 name_buf, pin_buf, desired_pin_name);
1256 av_log(avctx,
AV_LOG_ERROR,
"unable to set audio buffer size %d to pin, using pin anyway...",
ctx->audio_buffer_size);
1266 IKsPropertySet_Release(p);
1272 CoTaskMemFree(pin_id);
1275 IEnumPins_Release(pins);
1284 "Could not find output pin from %s capture device.\n", devtypename);
1322 char *device_filter_unique_name =
NULL;
1327 ICaptureGraphBuilder2 *graph_builder2 =
NULL;
1330 IStream *ifile_stream =
NULL;
1331 IStream *ofile_stream =
NULL;
1332 IPersistStream *pers_stream =
NULL;
1335 const wchar_t *filter_name[2] = {
L"Audio capture filter",
L"Video capture filter" };
1338 if ( ((
ctx->audio_filter_load_file) && (strlen(
ctx->audio_filter_load_file)>0) && (sourcetype ==
AudioSourceDevice)) ||
1339 ((
ctx->video_filter_load_file) && (strlen(
ctx->video_filter_load_file)>0) && (sourcetype ==
VideoSourceDevice)) ) {
1341 char *filename =
NULL;
1344 filename =
ctx->audio_filter_load_file;
1346 filename =
ctx->video_filter_load_file;
1348 hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_READ, &ifile_stream);
1354 hr = OleLoadFromStream(ifile_stream, &IID_IBaseFilter, (
void **) &
device_filter);
1364 av_log(avctx,
AV_LOG_INFO,
"Capture filter loaded successfully from file \"%s\".\n", filename);
1372 if (
ctx->device_filter[otherDevType]) {
1375 if (strcmp(device_filter_unique_name,
ctx->device_unique_name[otherDevType]) == 0) {
1376 av_log(avctx,
AV_LOG_DEBUG,
"reusing previous graph capture filter... %s\n", device_filter_unique_name);
1379 IBaseFilter_AddRef(
ctx->device_filter[otherDevType]);
1381 av_log(avctx,
AV_LOG_DEBUG,
"not reusing previous graph capture filter %s != %s\n", device_filter_unique_name,
ctx->device_unique_name[otherDevType]);
1386 ctx->device_unique_name [devtype] = device_filter_unique_name;
1408 if ( ((
ctx->audio_filter_save_file) && (strlen(
ctx->audio_filter_save_file)>0) && (sourcetype ==
AudioSourceDevice)) ||
1409 ((
ctx->video_filter_save_file) && (strlen(
ctx->video_filter_save_file)>0) && (sourcetype ==
VideoSourceDevice)) ) {
1412 char *filename =
NULL;
1415 filename =
ctx->audio_filter_save_file;
1417 filename =
ctx->video_filter_save_file;
1419 hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_CREATE | STGM_READWRITE, &ofile_stream);
1425 hr = IBaseFilter_QueryInterface(
device_filter, &IID_IPersistStream, (
void **) &pers_stream);
1431 hr = OleSaveToStream(pers_stream, ofile_stream);
1437 hr = IStream_Commit(ofile_stream, STGC_DEFAULT);
1447 av_log(avctx,
AV_LOG_INFO,
"Capture filter saved successfully to file \"%s\".\n", filename);
1451 filter_name[devtype]);
1461 r = CoCreateInstance(&CLSID_CaptureGraphBuilder2,
NULL, CLSCTX_INPROC_SERVER,
1462 &IID_ICaptureGraphBuilder2, (
void **) &graph_builder2);
1467 ICaptureGraphBuilder2_SetFiltergraph(graph_builder2,
graph);
1491 if (graph_builder2 !=
NULL)
1492 ICaptureGraphBuilder2_Release(graph_builder2);
1495 IPersistStream_Release(pers_stream);
1498 IStream_Release(ifile_stream);
1501 IStream_Release(ofile_stream);
1508 switch (sample_fmt) {
1557 BITMAPINFOHEADER *bih =
NULL;
1560 if (IsEqualGUID(&
type.formattype, &FORMAT_VideoInfo)) {
1561 VIDEOINFOHEADER *v = (
void *)
type.pbFormat;
1562 time_base = (
AVRational) { v->AvgTimePerFrame, 10000000 };
1563 bih = &v->bmiHeader;
1564 }
else if (IsEqualGUID(&
type.formattype, &FORMAT_VideoInfo2)) {
1565 VIDEOINFOHEADER2 *v = (
void *)
type.pbFormat;
1566 time_base = (
AVRational) { v->AvgTimePerFrame, 10000000 };
1567 bih = &v->bmiHeader;
1582 if (bih->biCompression ==
MKTAG(
'H',
'D',
'Y',
'C')) {
1593 if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) {
1608 "Please report type 0x%X.\n", (
int) bih->biCompression);
1615 if (!IsEqualGUID(&
type.formattype, &FORMAT_WaveFormatEx)) {
1634 CoTaskMemFree(
type.pbFormat);
1647 while ((
type = strtok(
tmp,
"="))) {
1648 char *token = strtok(
NULL,
":");
1651 if (!strcmp(
type,
"video")) {
1653 }
else if (!strcmp(
type,
"audio")) {
1679 ICreateDevEnum *devenum =
NULL;
1682 HANDLE media_event_handle;
1699 "video codec is not set or set to rawvideo\n");
1704 if (
ctx->framerate) {
1712 r = CoCreateInstance(&CLSID_FilterGraph,
NULL, CLSCTX_INPROC_SERVER,
1713 &IID_IGraphBuilder, (
void **) &
graph);
1720 r = CoCreateInstance(&CLSID_SystemDeviceEnum,
NULL, CLSCTX_INPROC_SERVER,
1721 &IID_ICreateDevEnum, (
void **) &devenum);
1727 if (
ctx->list_devices) {
1733 if (
ctx->list_options) {
1769 if (
ctx->list_options) {
1774 ctx->curbufsize[0] = 0;
1775 ctx->curbufsize[1] = 0;
1782 if (!
ctx->event[1]) {
1787 r = IGraphBuilder_QueryInterface(
graph, &IID_IMediaControl, (
void **) &
control);
1794 r = IGraphBuilder_QueryInterface(
graph, &IID_IMediaEvent, (
void **) &
media_event);
1801 r = IMediaEvent_GetEventHandle(
media_event, (
void *) &media_event_handle);
1806 proc = GetCurrentProcess();
1807 r = DuplicateHandle(proc, media_event_handle, proc, &
ctx->event[0],
1808 0, 0, DUPLICATE_SAME_ACCESS);
1817 r = IMediaControl_GetState(
control, 0, &pfs);
1820 av_log(avctx,
AV_LOG_ERROR,
"Could not run graph (sometimes caused by a device already in use by other application)\n");
1829 ICreateDevEnum_Release(devenum);
1848 while (IMediaEvent_GetEvent(
media_event, &
code, &p1, &p2, 0) != E_ABORT) {
1867 ctx->pktl =
ctx->pktl->next;
1871 ResetEvent(
ctx->event[1]);
1872 ReleaseMutex(
ctx->mutex);
1879 WaitForMultipleObjects(2,
ctx->event, 0, INFINITE);
1887 #define OFFSET(x) offsetof(struct dshow_ctx, x)
1888 #define DEC AV_OPT_FLAG_DECODING_PARAM
1930 .priv_data_size =
sizeof(
struct dshow_ctx),