The "show config dialog" command message can now also trigger dialog boxes for the crossbar connecting pins filter the analog tuner audio / analog tuner filters. _Untested_ as I do not have either device.
Signed-off-by: Diederick Niehorster <dcni...@gmail.com> --- libavdevice/dshow.c | 51 ++++++++++++++++++-- libavdevice/dshow_capture.h | 10 ++++ libavdevice/dshow_crossbar.c | 91 +++++++++++++++++++++++------------- 3 files changed, 114 insertions(+), 38 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 018792a886..add46e82ac 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -60,6 +60,11 @@ dshow_read_close(AVFormatContext *s) struct dshow_ctx *ctx = s->priv_data; PacketList *pktl; + if (ctx->graph_builder2[VideoDevice]) + ICaptureGraphBuilder2_Release(ctx->graph_builder2[VideoDevice]); + if (ctx->graph_builder2[AudioDevice]) + ICaptureGraphBuilder2_Release(ctx->graph_builder2[AudioDevice]); + if (ctx->control) { IMediaControl_Stop(ctx->control); IMediaControl_Release(ctx->control); @@ -1040,6 +1045,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, av_log(avctx, AV_LOG_ERROR, "Could not create CaptureGraphBuilder2\n"); goto error; } + ctx->graph_builder2[devtype] = graph_builder2; ICaptureGraphBuilder2_SetFiltergraph(graph_builder2, graph); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not set graph for CaptureGraphBuilder2\n"); @@ -1064,9 +1070,6 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, ret = 0; error: - if (graph_builder2 != NULL) - ICaptureGraphBuilder2_Release(graph_builder2); - if (pers_stream) IPersistStream_Release(pers_stream); @@ -1112,10 +1115,48 @@ static int dshow_control_message(AVFormatContext *avctx, int type, void *data, s ff_dshow_show_filter_properties(ctx->device_filter[devtype], avctx); } else if (dialog & 1<<2) { // crossbar_connection_dialog - // TODO + if (ctx->device_filter[devtype] && ctx->graph_builder2[devtype]) { + IAMCrossbar *cross_bar = NULL; + IBaseFilter *cross_bar_base_filter = NULL; + hr = ff_dshow_get_crossbar_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], cross_bar, &cross_bar_base_filter); + + if (hr == S_OK && cross_bar_base_filter) + ff_dshow_show_filter_properties(cross_bar_base_filter, avctx); + + if (cross_bar) + IAMCrossbar_Release(cross_bar); + if (cross_bar_base_filter) + IBaseFilter_Release(cross_bar_base_filter); + } } else if (dialog & 1<<3) { // tv_tuner_dialog - // TODO + if (ctx->device_filter[devtype] && ctx->graph_builder2[devtype]) { + if (devtype == VideoDevice) { + IAMTVTuner *tv_tuner_filter = NULL; + IBaseFilter *tv_tuner_base_filter = NULL; + hr = ff_dshow_get_tvtuner_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], tv_tuner_filter, tv_tuner_base_filter); + + if (hr == S_OK && tv_tuner_base_filter) + ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx); + + if (tv_tuner_filter) + IAMTVTuner_Release(tv_tuner_filter); + if (tv_tuner_base_filter) + IBaseFilter_Release(tv_tuner_base_filter); + } else { + IAMAudioInputMixer *tv_audio_filter = NULL; + IBaseFilter *tv_audio_base_filter = NULL; + hr = ff_dshow_get_audiomixer_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], tv_audio_filter, tv_audio_base_filter); + + if (hr == S_OK && tv_audio_base_filter) + ff_dshow_show_filter_properties(tv_audio_base_filter, avctx); + + if (tv_audio_filter) + IAMAudioInputMixer_Release(tv_audio_filter); + if (tv_audio_base_filter) + IBaseFilter_Release(tv_audio_base_filter); + } + } } break; } diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index bb0f76a8f2..127695a86b 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -318,6 +318,7 @@ struct dshow_ctx { IPin *device_pin[2]; DShowFilter *capture_filter[2]; DShowPin *capture_pin[2]; + ICaptureGraphBuilder2 *graph_builder2[2]; HANDLE mutex; HANDLE event[2]; /* event[0] is set by DirectShow @@ -352,6 +353,15 @@ struct dshow_ctx { HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx); +HRESULT ff_dshow_get_crossbar_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMCrossbar *cross_bar, IBaseFilter **cross_bar_base_filter); + +HRESULT ff_dshow_get_tvtuner_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMTVTuner *tv_tuner_filter, IBaseFilter *tv_tuner_base_filter); + +HRESULT ff_dshow_get_audiomixer_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMAudioInputMixer *tv_audio_filter, IBaseFilter *tv_audio_base_filter); + void ff_dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); #endif /* AVDEVICE_DSHOW_CAPTURE_H */ diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c index 961defe690..6b714e849c 100644 --- a/libavdevice/dshow_crossbar.c +++ b/libavdevice/dshow_crossbar.c @@ -133,6 +133,44 @@ setup_crossbar_options(IAMCrossbar *cross_bar, enum dshowDeviceType devtype, AVF return S_OK; } +HRESULT +ff_dshow_get_crossbar_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMCrossbar *cross_bar, IBaseFilter **cross_bar_base_filter) +{ + HRESULT hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, (const GUID *) NULL, + device_filter, &IID_IAMCrossbar, (void **) &cross_bar); + if (hr != S_OK) + /* no crossbar found */ + return hr; + + if (cross_bar_base_filter) + hr = IAMCrossbar_QueryInterface(cross_bar, &IID_IBaseFilter, (void**)cross_bar_base_filter); + + return hr; +} + +HRESULT +ff_dshow_get_tvtuner_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMTVTuner *tv_tuner_filter, IBaseFilter *tv_tuner_base_filter) +{ + HRESULT hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, NULL, + device_filter, &IID_IAMTVTuner, (void **) &tv_tuner_filter); + if (hr == S_OK) + hr = IAMCrossbar_QueryInterface(tv_tuner_filter, &IID_IBaseFilter, (void **) &tv_tuner_base_filter); + return hr; +} + +HRESULT +ff_dshow_get_audiomixer_and_filter(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, + IAMAudioInputMixer *tv_audio_filter, IBaseFilter *tv_audio_base_filter) +{ + HRESULT hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, NULL, + device_filter, &IID_IAMTVAudio, (void **) &tv_audio_filter); + if (hr == S_OK) + hr = IAMCrossbar_QueryInterface(tv_audio_filter, &IID_IBaseFilter, (void **) &tv_audio_base_filter); + return hr; +} + /** * Given a fully constructed graph, check if there is a cross bar filter, and configure its pins if so. */ @@ -140,55 +178,42 @@ HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx) { - struct dshow_ctx *ctx = avctx->priv_data; - IAMCrossbar *cross_bar = NULL; - IBaseFilter *cross_bar_base_filter = NULL; - IAMTVTuner *tv_tuner_filter = NULL; - IBaseFilter *tv_tuner_base_filter = NULL; - IAMAudioInputMixer *tv_audio_filter = NULL; - IBaseFilter *tv_audio_base_filter = NULL; + struct dshow_ctx *ctx = avctx->priv_data; + IAMCrossbar *cross_bar = NULL; + IBaseFilter *cross_bar_base_filter = NULL; + IAMTVTuner *tv_tuner_filter = NULL; + IBaseFilter *tv_tuner_base_filter = NULL; + IAMAudioInputMixer *tv_audio_filter = NULL; + IBaseFilter *tv_audio_base_filter = NULL; HRESULT hr; + int should_show_crossbar_properties = (devtype == VideoDevice) ? ctx->show_video_crossbar_connection_dialog : ctx->show_audio_crossbar_connection_dialog; - hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, (const GUID *) NULL, - device_filter, &IID_IAMCrossbar, (void**) &cross_bar); + hr = ff_dshow_get_crossbar_and_filter(graph_builder2, device_filter, cross_bar, should_show_crossbar_properties ? &cross_bar_base_filter : NULL); if (hr != S_OK) { - /* no crossbar found */ - hr = S_OK; + if (!cross_bar) + /* no crossbar found */ + hr = S_OK; goto end; } + /* TODO some TV tuners apparently have multiple crossbars? */ - if (devtype == VideoDevice && ctx->show_video_crossbar_connection_dialog || - devtype == AudioDevice && ctx->show_audio_crossbar_connection_dialog) { - hr = IAMCrossbar_QueryInterface(cross_bar, &IID_IBaseFilter, (void **) &cross_bar_base_filter); - if (hr != S_OK) - goto end; + if (should_show_crossbar_properties && cross_bar_base_filter) ff_dshow_show_filter_properties(cross_bar_base_filter, avctx); - } if (devtype == VideoDevice && ctx->show_analog_tv_tuner_dialog) { - hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, NULL, - device_filter, &IID_IAMTVTuner, (void**) &tv_tuner_filter); - if (hr == S_OK) { - hr = IAMCrossbar_QueryInterface(tv_tuner_filter, &IID_IBaseFilter, (void **) &tv_tuner_base_filter); - if (hr != S_OK) - goto end; + hr = ff_dshow_get_tvtuner_and_filter(graph_builder2, device_filter, tv_tuner_filter, tv_tuner_base_filter); + if (hr == S_OK && tv_tuner_base_filter) ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx); - } else { + else av_log(avctx, AV_LOG_WARNING, "unable to find a tv tuner to display dialog for!"); - } } if (devtype == AudioDevice && ctx->show_analog_tv_tuner_audio_dialog) { - hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, NULL, - device_filter, &IID_IAMTVAudio, (void**) &tv_audio_filter); - if (hr == S_OK) { - hr = IAMCrossbar_QueryInterface(tv_audio_filter, &IID_IBaseFilter, (void **) &tv_audio_base_filter); - if (hr != S_OK) - goto end; + hr = ff_dshow_get_audiomixer_and_filter(graph_builder2, device_filter, tv_audio_filter, tv_audio_base_filter); + if (hr == S_OK && tv_audio_base_filter) ff_dshow_show_filter_properties(tv_audio_base_filter, avctx); - } else { + else av_log(avctx, AV_LOG_WARNING, "unable to find a tv audio tuner to display dialog for!"); - } } hr = setup_crossbar_options(cross_bar, devtype, avctx); -- 2.28.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".