diff options
author | rogerdpack <rogerpack2005@gmail.com> | 2015-01-23 16:49:37 +0300 |
---|---|---|
committer | rogerdpack <rogerpack2005@gmail.com> | 2015-01-23 16:49:37 +0300 |
commit | 5d72cf0f64162aa130b4720f71e9249a6a34f08a (patch) | |
tree | 78aa28f3b959c1c8ea5ad1295e6c526b199259f6 /libavdevice/dshow.c | |
parent | ec81ad21c1f8124dcde08c1e64656331d4c3d9e6 (diff) |
dshow: add options for allowing filter popup configuration dialogs to be presented to the user
Signed-off-by: rogerdpack <rogerpack2005@gmail.com>
Diffstat (limited to 'libavdevice/dshow.c')
-rw-r--r-- | libavdevice/dshow.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 634937734d..691250f3ac 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -503,6 +503,53 @@ end: } /** + * Pops up a user dialog allowing them to adjust properties for the given filter, if possible. + */ +void +dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) { + ISpecifyPropertyPages *property_pages = NULL; + IUnknown *device_filter_iunknown = NULL; + HRESULT hr; + FILTER_INFO filter_info = {0}; /* a warning on this line is false positive GCC bug 53119 */ + CAUUID ca_guid = {0}; + + hr = IBaseFilter_QueryInterface(device_filter, &IID_ISpecifyPropertyPages, (void **)&property_pages); + if (hr != S_OK) { + av_log(avctx, AV_LOG_WARNING, "requested filter does not have a property page to show"); + goto end; + } + hr = IBaseFilter_QueryFilterInfo(device_filter, &filter_info); + if (hr != S_OK) { + goto fail; + } + hr = IBaseFilter_QueryInterface(device_filter, &IID_IUnknown, (void **)&device_filter_iunknown); + if (hr != S_OK) { + goto fail; + } + hr = ISpecifyPropertyPages_GetPages(property_pages, &ca_guid); + if (hr != S_OK) { + goto fail; + } + hr = OleCreatePropertyFrame(NULL, 0, 0, filter_info.achName, 1, &device_filter_iunknown, ca_guid.cElems, + ca_guid.pElems, 0, 0, NULL); + if (hr != S_OK) { + goto fail; + } + goto end; +fail: + av_log(avctx, AV_LOG_ERROR, "Failure showing property pages for filter"); +end: + if (property_pages) + ISpecifyPropertyPages_Release(property_pages); + if (device_filter_iunknown) + IUnknown_Release(device_filter_iunknown); + if (filter_info.pGraph) + IFilterGraph_Release(filter_info.pGraph); + if (ca_guid.pElems) + CoTaskMemFree(ca_guid.pElems); +} + +/** * Cycle through available pins using the device_filter device, of type * devtype, retrieve the first output pin and return the pointer to the * object found in *ppin. @@ -527,6 +574,10 @@ dshow_cycle_pins(AVFormatContext *avctx, enum dshowDeviceType devtype, ctx->video_codec_id != AV_CODEC_ID_RAWVIDEO)) || (devtype == AudioDevice && (ctx->channels || ctx->sample_rate)); int format_set = 0; + int should_show_properties = (devtype == VideoDevice) ? ctx->show_video_device_dialog : ctx->show_audio_device_dialog; + + if (should_show_properties) + dshow_show_filter_properties(device_filter, avctx); r = IBaseFilter_EnumPins(device_filter, &pins); if (r != S_OK) { @@ -975,7 +1026,7 @@ static int dshow_read_header(AVFormatContext *avctx) if (ctx->device_name[AudioDevice]) if ((r = dshow_list_device_options(avctx, devenum, AudioDevice))) { ret = r; - goto error;
+ goto error; } } @@ -1133,6 +1184,15 @@ static const AVOption options[] = { { "audio_pin_name", "select audio capture pin by name", OFFSET(audio_pin_name),AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "crossbar_video_input_pin_number", "set video input pin number for crossbar device", OFFSET(crossbar_video_input_pin_number), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, DEC }, { "crossbar_audio_input_pin_number", "set audio input pin number for crossbar device", OFFSET(crossbar_audio_input_pin_number), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, DEC }, + { "show_video_device_dialog", "display property dialog for video capture device", OFFSET(show_video_device_dialog), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC, "show_video_device_dialog" }, + { "true", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, DEC, "show_video_device_dialog" }, + { "false", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, DEC, "show_video_device_dialog" }, + { "show_audio_device_dialog", "display property dialog for audio capture device", OFFSET(show_audio_device_dialog), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC, "show_audio_device_dialog" }, + { "true", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, DEC, "show_audio_device_dialog" }, + { "false", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, DEC, "show_audio_device_dialog" }, + { "show_crossbar_connection_dialog", "display property dialog for crossbar connecting pins filter", OFFSET(show_crossbar_connection_dialog), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC, "show_crossbar_connection_dialog" }, + { "true", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, DEC, "show_crossbar_connection_dialog" }, + { "false", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, DEC, "show_crossbar_connection_dialog" }, { NULL }, }; |