51 #include "d3d9types.h"
54 #ifndef AMCONTROL_COLORINFO_PRESENT
56 # define AMCONTROL_COLORINFO_PRESENT 0x00000080 // if set, indicates DXVA color info is present in the upper (24) bits of the dwControlFlags
62 switch(biCompression) {
85 switch (fmt_info->NominalRange)
87 case DXVA2_NominalRange_Unknown:
89 case DXVA2_NominalRange_Normal:
91 case DXVA2_NominalRange_Wide:
93 case DXVA2_NominalRange_48_208:
109 switch (fmt_info->VideoTransferMatrix)
111 case DXVA2_VideoTransferMatrix_BT709:
113 case DXVA2_VideoTransferMatrix_BT601:
115 case DXVA2_VideoTransferMatrix_SMPTE240M:
121 if (fmt_info->VideoTransferFunction == 12)
133 switch (fmt_info->VideoPrimaries)
135 case DXVA2_VideoPrimaries_Unknown:
137 case DXVA2_VideoPrimaries_reserved:
139 case DXVA2_VideoPrimaries_BT709:
141 case DXVA2_VideoPrimaries_BT470_2_SysM:
143 case DXVA2_VideoPrimaries_BT470_2_SysBG:
144 case DXVA2_VideoPrimaries_EBU3213:
146 case DXVA2_VideoPrimaries_SMPTE170M:
147 case DXVA2_VideoPrimaries_SMPTE_C:
149 case DXVA2_VideoPrimaries_SMPTE240M:
170 switch (fmt_info->VideoTransferFunction)
172 case DXVA2_VideoTransFunc_Unknown:
174 case DXVA2_VideoTransFunc_10:
176 case DXVA2_VideoTransFunc_18:
179 case DXVA2_VideoTransFunc_20:
182 case DXVA2_VideoTransFunc_22:
184 case DXVA2_VideoTransFunc_709:
186 case DXVA2_VideoTransFunc_240M:
188 case DXVA2_VideoTransFunc_sRGB:
190 case DXVA2_VideoTransFunc_28:
203 if (fmt_info->VideoTransferMatrix == 5)
225 if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Cosited)
227 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_MPEG1)
229 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_MPEG2)
231 else if (fmt_info->VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_DV_PAL)
245 IMediaControl_Stop(
ctx->control);
246 IMediaControl_Release(
ctx->control);
249 if (
ctx->media_event)
250 IMediaEvent_Release(
ctx->media_event);
255 r = IGraphBuilder_EnumFilters(
ctx->graph, &fenum);
258 IEnumFilters_Reset(fenum);
259 while (IEnumFilters_Next(fenum, 1, &
f,
NULL) == S_OK) {
260 if (IGraphBuilder_RemoveFilter(
ctx->graph,
f) == S_OK)
261 IEnumFilters_Reset(fenum);
263 IBaseFilter_Release(
f);
265 IEnumFilters_Release(fenum);
267 IGraphBuilder_Release(
ctx->graph);
294 CloseHandle(
ctx->mutex);
296 CloseHandle(
ctx->event[0]);
298 CloseHandle(
ctx->event[1]);
316 int l = WideCharToMultiByte(CP_UTF8, 0,
w, -1, 0, 0, 0, 0);
319 WideCharToMultiByte(CP_UTF8, 0,
w, -1,
s, l, 0, 0);
326 static const uint8_t dropscore[] = {62, 75, 87, 100};
328 unsigned int buffer_fullness = (
ctx->curbufsize[
index]*100)/
s->max_picture_buffer;
329 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio";
331 if(dropscore[++
ctx->video_frame_num%ndropscores] <= buffer_fullness) {
333 "real-time buffer [%s] [%s input] too full or near too full (%d%% of size: %d [rtbufsize parameter])! frame dropped!\n",
334 ctx->device_name[devtype], devtypename, buffer_fullness,
s->max_picture_buffer);
365 pktl_next->
pkt.
pts = time;
366 memcpy(pktl_next->
pkt.
data, buf, buf_size);
368 for(ppktl = &
ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->
next);
372 SetEvent(
ctx->event[1]);
373 ReleaseMutex(
ctx->mutex);
377 ReleaseMutex(
ctx->mutex);
384 enum AVMediaType **media_types,
int *nb_media_types)
388 int has_audio = 0, has_video = 0;
393 while (IEnumPins_Next(pins, 1, &pin,
NULL) == S_OK) {
394 IKsPropertySet *p =
NULL;
395 PIN_INFO
info = { 0 };
398 IEnumMediaTypes *types =
NULL;
401 if (IPin_QueryPinInfo(pin, &
info) != S_OK)
403 IBaseFilter_Release(
info.pFilter);
405 if (
info.dir != PINDIR_OUTPUT)
407 if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (
void **) &p) != S_OK)
409 if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
412 if (!IsEqualGUID(&
category, &PIN_CATEGORY_CAPTURE))
415 if (IPin_EnumMediaTypes(pin, &types) != S_OK)
420 IEnumMediaTypes_Reset(types);
421 while (IEnumMediaTypes_Next(types, 1, &
type,
NULL) == S_OK) {
422 if (IsEqualGUID(&
type->majortype, &MEDIATYPE_Video)) {
424 }
else if (IsEqualGUID(&
type->majortype, &MEDIATYPE_Audio)) {
432 IEnumMediaTypes_Release(types);
434 IKsPropertySet_Release(p);
439 IEnumPins_Release(pins);
441 if (has_audio || has_video) {
442 int nb_types = has_audio + has_video;
449 *nb_media_types = nb_types;
470 IEnumMoniker *classenum =
NULL;
474 :
ctx->audio_device_number;
477 const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
478 &CLSID_AudioInputDeviceCategory };
479 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio only";
480 const char *sourcetypename = (sourcetype ==
VideoSourceDevice) ?
"video" :
"audio";
482 r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[sourcetype],
483 (IEnumMoniker **) &classenum, 0);
491 IPropertyBag *bag =
NULL;
493 char *unique_name =
NULL;
495 IBindCtx *bind_ctx =
NULL;
496 LPOLESTR olestr =
NULL;
497 LPMALLOC co_malloc =
NULL;
500 int nb_media_types = 0;
503 r = CoGetMalloc(1, &co_malloc);
506 r = CreateBindCtx(0, &bind_ctx);
510 r = IMoniker_GetDisplayName(m, bind_ctx,
NULL, &olestr);
515 for (
i = 0;
i < strlen(unique_name);
i++) {
516 if (unique_name[
i] ==
':')
517 unique_name[
i] =
'_';
520 r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (
void *) &bag);
525 r = IPropertyBag_Read(bag,
L"FriendlyName", &var,
NULL);
535 r = IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (
void *) &
device_filter);
546 if (IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (
void* ) &
device_filter) == S_OK) {
563 (*device_list)->nb_devices + 1,
564 sizeof(*(*device_list)->devices)) < 0)
574 (*device_list)->devices[(*device_list)->nb_devices] = device;
575 (*device_list)->nb_devices++;
580 if (nb_media_types > 0) {
583 for (
int i = 1;
i < nb_media_types; ++
i) {
604 if (olestr && co_malloc)
605 IMalloc_Free(co_malloc, olestr);
607 IBindCtx_Release(bind_ctx);
611 IPropertyBag_Release(bag);
615 IEnumMoniker_Release(classenum);
619 av_log(avctx,
AV_LOG_ERROR,
"Could not find %s device with name [%s] among source devices of type %s.\n",
631 ICreateDevEnum *devenum =
NULL;
640 r = CoCreateInstance(&CLSID_SystemDeviceEnum,
NULL, CLSCTX_INPROC_SERVER,
641 &IID_ICreateDevEnum, (
void**)&devenum);
654 ICreateDevEnum_Release(devenum);
666 (
ctx->requested_width &&
ctx->requested_height) ||
696 BITMAPINFOHEADER *bih;
697 DXVA2_ExtendedFormat *extended_format_info =
NULL;
705 if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo)) {
706 VIDEOINFOHEADER *v = (
void *)
type->pbFormat;
710 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo2)) {
711 VIDEOINFOHEADER2 *v = (
void *)
type->pbFormat;
716 extended_format_info = (DXVA2_ExtendedFormat *) &v->dwControlFlags;
717 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx)) {
718 fx = (
void *)
type->pbFormat;
735 fmt_info->
width = bih->biWidth;
736 fmt_info->
height = bih->biHeight;
746 if (extended_format_info) {
766 if ((hr = IAMStreamConfig_GetFormat(
config,
type)) != S_OK) {
767 if (hr == E_NOTIMPL || !IsEqualGUID(&(*type)->majortype,
devtype ==
VideoDevice ? &MEDIATYPE_Video : &MEDIATYPE_Audio)) {
771 IEnumMediaTypes* types =
NULL;
772 if (IPin_EnumMediaTypes(pin, &types) != S_OK)
774 IEnumMediaTypes_Reset(types);
775 while (IEnumMediaTypes_Next(types, 1,
type,
NULL) == S_OK) {
776 if (IsEqualGUID(&(*type)->majortype,
devtype ==
VideoDevice ? &MEDIATYPE_Video : &MEDIATYPE_Audio)) {
779 CoTaskMemFree(*
type);
782 IEnumMediaTypes_Release(types);
796 IPin *pin,
int *pformat_set)
801 AM_MEDIA_TYPE *previous_match_type =
NULL;
805 int wait_for_better = 0;
815 /
ctx->requested_framerate.num : 0;
819 int requested_sample_rate =
ctx->sample_rate;
820 int requested_sample_size =
ctx->sample_size;
821 int requested_channels =
ctx->channels;
823 if (IPin_QueryInterface(pin, &IID_IAMStreamConfig, (
void **) &
config) != S_OK)
825 if (IAMStreamConfig_GetNumberOfCapabilities(
config, &n, &
size) != S_OK)
840 if (use_default && pformat_set)
853 requested_video_codec_id = fmt_info->
codec_id;
854 requested_pixel_format = fmt_info->
pix_fmt;
855 requested_framerate = fmt_info->
framerate;
856 requested_width = fmt_info->
width;
857 requested_height = fmt_info->
height;
861 requested_channels = fmt_info->
channels;
867 CoTaskMemFree(
type->pbFormat);
886 for (
i = 0;
i < n && !format_set;
i++) {
888 r = IAMStreamConfig_GetStreamCaps(
config,
i, &
type, (
void *) caps);
900 VIDEO_STREAM_CONFIG_CAPS *vcaps = caps;
901 BITMAPINFOHEADER *bih;
910 if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo)) {
911 VIDEOINFOHEADER *v = (
void *)
type->pbFormat;
912 fr = &v->AvgTimePerFrame;
915 }
else if (IsEqualGUID(&
type->formattype, &FORMAT_VideoInfo2)) {
916 VIDEOINFOHEADER2 *v = (
void *)
type->pbFormat;
917 fr = &v->AvgTimePerFrame;
927 av_log(avctx,
AV_LOG_INFO,
" unknown compression type 0x%X", (
int) bih->biCompression);
935 vcaps->MinOutputSize.cx, vcaps->MinOutputSize.cy,
936 1e7 / vcaps->MaxFrameInterval,
937 vcaps->MaxOutputSize.cx, vcaps->MaxOutputSize.cy,
938 1e7 / vcaps->MinFrameInterval);
951 prim ? prim :
"unknown",
952 trc ? trc :
"unknown");
964 if (requested_video_codec_id != fmt_info->
codec_id)
968 requested_pixel_format != fmt_info->
pix_fmt) {
971 if (requested_framerate) {
972 if (requested_framerate > vcaps->MaxFrameInterval ||
973 requested_framerate < vcaps->MinFrameInterval)
975 *fr = requested_framerate;
977 if (requested_width && requested_height) {
978 if (requested_width > vcaps->MaxOutputSize.cx ||
979 requested_width < vcaps->MinOutputSize.cx ||
980 requested_height > vcaps->MaxOutputSize.cy ||
981 requested_height < vcaps->MinOutputSize.cy)
983 bih->biWidth = requested_width;
984 bih->biHeight = requested_height;
988 AUDIO_STREAM_CONFIG_CAPS *acaps = caps;
992 if (IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx)) {
993 fx = (
void *)
type->pbFormat;
1001 " ch=%2u, bits=%2u, rate=%6lu\n",
1002 fx->nChannels, fx->wBitsPerSample, fx->nSamplesPerSec
1007 (requested_sample_rate && requested_sample_rate != fx->nSamplesPerSec) ||
1008 (requested_sample_size && requested_sample_size != fx->wBitsPerSample) ||
1009 (requested_channels && requested_channels != fx->nChannels )
1019 if (!wait_for_better) {
1020 if (IAMStreamConfig_SetFormat(
config,
type) != S_OK)
1024 else if (!previous_match_type) {
1027 previous_match_type =
type;
1033 CoTaskMemFree(
type->pbFormat);
1034 CoTaskMemFree(
type);
1039 if (pformat_set && !format_set) {
1040 if (previous_match_type) {
1047 if (IAMStreamConfig_SetFormat(
config, previous_match_type) == S_OK)
1050 else if (use_default) {
1055 if (IAMStreamConfig_SetFormat(
config,
type) == S_OK)
1058 CoTaskMemFree(
type->pbFormat);
1059 CoTaskMemFree(
type);
1065 if (previous_match_type && previous_match_type->pbFormat)
1066 CoTaskMemFree(previous_match_type->pbFormat);
1067 CoTaskMemFree(previous_match_type);
1068 IAMStreamConfig_Release(
config);
1071 *pformat_set = format_set;
1082 IAMBufferNegotiation *buffer_negotiation =
NULL;
1083 ALLOCATOR_PROPERTIES props = { -1, -1, -1, -1 };
1088 if (IPin_QueryInterface(pin, &IID_IAMStreamConfig, (
void **) &
config) != S_OK)
1090 if (IAMStreamConfig_GetFormat(
config, &
type) != S_OK)
1092 if (!IsEqualGUID(&
type->formattype, &FORMAT_WaveFormatEx))
1095 props.cbBuffer = (((WAVEFORMATEX *)
type->pbFormat)->nAvgBytesPerSec)
1096 *
ctx->audio_buffer_size / 1000;
1098 if (IPin_QueryInterface(pin, &IID_IAMBufferNegotiation, (
void **) &buffer_negotiation) != S_OK)
1100 if (IAMBufferNegotiation_SuggestAllocatorProperties(buffer_negotiation, &props) != S_OK)
1106 if (buffer_negotiation)
1107 IAMBufferNegotiation_Release(buffer_negotiation);
1110 CoTaskMemFree(
type->pbFormat);
1111 CoTaskMemFree(
type);
1114 IAMStreamConfig_Release(
config);
1124 ISpecifyPropertyPages *property_pages =
NULL;
1125 IUnknown *device_filter_iunknown =
NULL;
1127 FILTER_INFO filter_info = {0};
1128 CAUUID ca_guid = {0};
1130 hr = IBaseFilter_QueryInterface(
device_filter, &IID_ISpecifyPropertyPages, (
void **)&property_pages);
1135 hr = IBaseFilter_QueryFilterInfo(
device_filter, &filter_info);
1139 hr = IBaseFilter_QueryInterface(
device_filter, &IID_IUnknown, (
void **)&device_filter_iunknown);
1143 hr = ISpecifyPropertyPages_GetPages(property_pages, &ca_guid);
1147 hr = OleCreatePropertyFrame(
NULL, 0, 0, filter_info.achName, 1, &device_filter_iunknown, ca_guid.cElems,
1148 ca_guid.pElems, 0, 0,
NULL);
1157 ISpecifyPropertyPages_Release(property_pages);
1158 if (device_filter_iunknown)
1159 IUnknown_Release(device_filter_iunknown);
1160 if (filter_info.pGraph)
1161 IFilterGraph_Release(filter_info.pGraph);
1163 CoTaskMemFree(ca_guid.pElems);
1177 IEnumPins *pins = 0;
1182 const char *devtypename = (devtype ==
VideoDevice) ?
"video" :
"audio only";
1183 const char *sourcetypename = (sourcetype ==
VideoSourceDevice) ?
"video" :
"audio";
1187 int should_show_properties = (devtype ==
VideoDevice) ?
ctx->show_video_device_dialog :
ctx->show_audio_device_dialog;
1189 if (should_show_properties)
1200 devtypename, sourcetypename);
1203 while (!
device_pin && IEnumPins_Next(pins, 1, &pin,
NULL) == S_OK) {
1204 IKsPropertySet *p =
NULL;
1205 PIN_INFO
info = {0};
1208 char *name_buf =
NULL;
1209 wchar_t *pin_id =
NULL;
1210 char *pin_buf =
NULL;
1211 char *desired_pin_name = devtype ==
VideoDevice ?
ctx->video_pin_name :
ctx->audio_pin_name;
1213 IPin_QueryPinInfo(pin, &
info);
1214 IBaseFilter_Release(
info.pFilter);
1216 if (
info.dir != PINDIR_OUTPUT)
1218 if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (
void **) &p) != S_OK)
1220 if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY,
1223 if (!IsEqualGUID(&
category, &PIN_CATEGORY_CAPTURE))
1227 r = IPin_QueryId(pin, &pin_id);
1235 av_log(avctx,
AV_LOG_INFO,
" Pin \"%s\" (alternative pin name \"%s\")\n", name_buf, pin_buf);
1240 if (desired_pin_name) {
1241 if(strcmp(name_buf, desired_pin_name) && strcmp(pin_buf, desired_pin_name)) {
1243 name_buf, pin_buf, desired_pin_name);
1257 av_log(avctx,
AV_LOG_ERROR,
"unable to set audio buffer size %d to pin, using pin anyway...",
ctx->audio_buffer_size);
1267 IKsPropertySet_Release(p);
1273 CoTaskMemFree(pin_id);
1276 IEnumPins_Release(pins);
1285 "Could not find output pin from %s capture device.\n", devtypename);
1323 char *device_filter_unique_name =
NULL;
1328 ICaptureGraphBuilder2 *graph_builder2 =
NULL;
1331 IStream *ifile_stream =
NULL;
1332 IStream *ofile_stream =
NULL;
1333 IPersistStream *pers_stream =
NULL;
1336 const wchar_t *filter_name[2] = {
L"Audio capture filter",
L"Video capture filter" };
1339 if ( ((
ctx->audio_filter_load_file) && (strlen(
ctx->audio_filter_load_file)>0) && (sourcetype ==
AudioSourceDevice)) ||
1340 ((
ctx->video_filter_load_file) && (strlen(
ctx->video_filter_load_file)>0) && (sourcetype ==
VideoSourceDevice)) ) {
1342 char *filename =
NULL;
1345 filename =
ctx->audio_filter_load_file;
1347 filename =
ctx->video_filter_load_file;
1349 hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_READ, &ifile_stream);
1355 hr = OleLoadFromStream(ifile_stream, &IID_IBaseFilter, (
void **) &
device_filter);
1365 av_log(avctx,
AV_LOG_INFO,
"Capture filter loaded successfully from file \"%s\".\n", filename);
1373 if (
ctx->device_filter[otherDevType]) {
1376 if (!device_filter_unique_name || strcmp(device_filter_unique_name,
ctx->device_unique_name[otherDevType]) == 0) {
1377 av_log(avctx,
AV_LOG_DEBUG,
"reusing previous graph capture filter... %s\n", device_filter_unique_name);
1380 IBaseFilter_AddRef(
ctx->device_filter[otherDevType]);
1382 av_log(avctx,
AV_LOG_DEBUG,
"not reusing previous graph capture filter %s != %s\n", device_filter_unique_name,
ctx->device_unique_name[otherDevType]);
1387 ctx->device_unique_name [devtype] = device_filter_unique_name;
1409 if ( ((
ctx->audio_filter_save_file) && (strlen(
ctx->audio_filter_save_file)>0) && (sourcetype ==
AudioSourceDevice)) ||
1410 ((
ctx->video_filter_save_file) && (strlen(
ctx->video_filter_save_file)>0) && (sourcetype ==
VideoSourceDevice)) ) {
1413 char *filename =
NULL;
1416 filename =
ctx->audio_filter_save_file;
1418 filename =
ctx->video_filter_save_file;
1420 hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_CREATE | STGM_READWRITE, &ofile_stream);
1426 hr = IBaseFilter_QueryInterface(
device_filter, &IID_IPersistStream, (
void **) &pers_stream);
1432 hr = OleSaveToStream(pers_stream, ofile_stream);
1438 hr = IStream_Commit(ofile_stream, STGC_DEFAULT);
1448 av_log(avctx,
AV_LOG_INFO,
"Capture filter saved successfully to file \"%s\".\n", filename);
1452 filter_name[devtype]);
1462 r = CoCreateInstance(&CLSID_CaptureGraphBuilder2,
NULL, CLSCTX_INPROC_SERVER,
1463 &IID_ICaptureGraphBuilder2, (
void **) &graph_builder2);
1468 r = ICaptureGraphBuilder2_SetFiltergraph(graph_builder2,
graph);
1492 if (graph_builder2 !=
NULL)
1493 ICaptureGraphBuilder2_Release(graph_builder2);
1496 IPersistStream_Release(pers_stream);
1499 IStream_Release(ifile_stream);
1502 IStream_Release(ofile_stream);
1509 switch (sample_fmt) {
1561 BITMAPINFOHEADER *bih =
NULL;
1564 if (IsEqualGUID(&
type.formattype, &FORMAT_VideoInfo)) {
1565 VIDEOINFOHEADER *v = (
void *)
type.pbFormat;
1566 time_base = (
AVRational) { v->AvgTimePerFrame, 10000000 };
1567 bih = &v->bmiHeader;
1568 }
else if (IsEqualGUID(&
type.formattype, &FORMAT_VideoInfo2)) {
1569 VIDEOINFOHEADER2 *v = (
void *)
type.pbFormat;
1570 time_base = (
AVRational) { v->AvgTimePerFrame, 10000000 };
1571 bih = &v->bmiHeader;
1586 if (bih->biCompression ==
MKTAG(
'H',
'D',
'Y',
'C')) {
1597 if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) {
1612 "Please report type 0x%X.\n", (
int) bih->biCompression);
1619 if (!IsEqualGUID(&
type.formattype, &FORMAT_WaveFormatEx)) {
1638 CoTaskMemFree(
type.pbFormat);
1651 while ((
type = strtok(
tmp,
"="))) {
1652 char *token = strtok(
NULL,
":");
1655 if (!strcmp(
type,
"video")) {
1657 }
else if (!strcmp(
type,
"audio")) {
1683 ICreateDevEnum *devenum =
NULL;
1686 HANDLE media_event_handle;
1703 "video codec is not set or set to rawvideo\n");
1708 if (
ctx->framerate) {
1716 r = CoCreateInstance(&CLSID_FilterGraph,
NULL, CLSCTX_INPROC_SERVER,
1717 &IID_IGraphBuilder, (
void **) &
graph);
1724 r = CoCreateInstance(&CLSID_SystemDeviceEnum,
NULL, CLSCTX_INPROC_SERVER,
1725 &IID_ICreateDevEnum, (
void **) &devenum);
1731 if (
ctx->list_devices) {
1737 if (
ctx->list_options) {
1773 if (
ctx->list_options) {
1778 ctx->curbufsize[0] = 0;
1779 ctx->curbufsize[1] = 0;
1786 if (!
ctx->event[1]) {
1791 r = IGraphBuilder_QueryInterface(
graph, &IID_IMediaControl, (
void **) &
control);
1798 r = IGraphBuilder_QueryInterface(
graph, &IID_IMediaEvent, (
void **) &
media_event);
1805 r = IMediaEvent_GetEventHandle(
media_event, (
void *) &media_event_handle);
1810 proc = GetCurrentProcess();
1811 r = DuplicateHandle(proc, media_event_handle, proc, &
ctx->event[0],
1812 0, 0, DUPLICATE_SAME_ACCESS);
1821 r = IMediaControl_GetState(
control, 0, &pfs);
1824 av_log(avctx,
AV_LOG_ERROR,
"Could not run graph (sometimes caused by a device already in use by other application)\n");
1833 ICreateDevEnum_Release(devenum);
1852 while (IMediaEvent_GetEvent(
media_event, &
code, &p1, &p2, 0) != E_ABORT) {
1871 ctx->pktl =
ctx->pktl->next;
1875 ResetEvent(
ctx->event[1]);
1876 ReleaseMutex(
ctx->mutex);
1883 WaitForMultipleObjects(2,
ctx->event, 0, INFINITE);
1891 #define OFFSET(x) offsetof(struct dshow_ctx, x)
1892 #define DEC AV_OPT_FLAG_DECODING_PARAM
1937 .priv_data_size =
sizeof(
struct dshow_ctx),