From d01234419b615792cd6447cb925ba16cc12ef32e Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Fri, 23 Jan 2015 05:34:30 -0700 Subject: dshow: allow selecting devices by an alternative name (workaround for devices with symbols in them), allow specifying capture pins by name and alternative (unique) name Signed-off-by: rogerdpack --- doc/indevs.texi | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/indevs.texi b/doc/indevs.texi index fa6facf96e..00820af246 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -167,7 +167,7 @@ The input name should be in the format: @end example where @var{TYPE} can be either @var{audio} or @var{video}, -and @var{NAME} is the device's name. +and @var{NAME} is the device's name or alternative name.. @subsection Options @@ -220,6 +220,12 @@ Setting this value too low can degrade performance. See also @url{http://msdn.microsoft.com/en-us/library/windows/desktop/dd377582(v=vs.85).aspx} +@item video_pin_name +Select video capture pin to use by name or alternative name. + +@item audio_pin_name +Select audio capture pin to use by name or alternative name. + @end table @subsection Examples @@ -256,6 +262,12 @@ Print the list of supported options in selected device and exit: $ ffmpeg -list_options true -f dshow -i video="Camera" @end example +@item +Specify pin names to capture by name or alternative name, specify alternative device name: +@example +$ ffmpeg -f dshow -audio_pin_name "Audio Out" -video_pin_name 2 -i video=video="@device_pnp_\\?\pci#ven_1a0a&dev_6200&subsys_62021461&rev_01#4&e2c7dd6&0&00e1#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{ca465100-deb0-4d59-818f-8c477184adf6}":audio="Microphone" +@end example + @end itemize @section dv1394 -- cgit v1.2.3 From ec81ad21c1f8124dcde08c1e64656331d4c3d9e6 Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Fri, 23 Jan 2015 06:35:16 -0700 Subject: dshow: introduce support for crossbar [multiple input selectable] devices Signed-off-by: rogerdpack --- doc/indevs.texi | 8 +++ libavdevice/Makefile | 2 +- libavdevice/dshow.c | 97 ++++++++++++------------- libavdevice/dshow_capture.h | 61 ++++++++++++++++ libavdevice/dshow_crossbar.c | 164 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 278 insertions(+), 54 deletions(-) create mode 100644 libavdevice/dshow_crossbar.c (limited to 'doc') diff --git a/doc/indevs.texi b/doc/indevs.texi index 00820af246..ec40c3400c 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -226,6 +226,14 @@ Select video capture pin to use by name or alternative name. @item audio_pin_name Select audio capture pin to use by name or alternative name. +@item crossbar_video_input_pin_number +Select video input pin number for crossbar device. This will be +routed to the crossbar device's Video Decoder output pin. + +@item crossbar_audio_input_pin_number +Select audio input pin number for crossbar device. This will be +routed to the crossbar device's Audio Decoder output pin. + @end table @subsection Examples diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 872504bc6e..696cc88dfe 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -19,7 +19,7 @@ OBJS-$(CONFIG_BKTR_INDEV) += bktr.o OBJS-$(CONFIG_CACA_OUTDEV) += caca.o OBJS-$(CONFIG_DECKLINK_OUTDEV) += decklink_enc.o decklink_enc_c.o decklink_common.o OBJS-$(CONFIG_DECKLINK_INDEV) += decklink_dec.o decklink_dec_c.o decklink_common.o -OBJS-$(CONFIG_DSHOW_INDEV) += dshow.o dshow_enummediatypes.o \ +OBJS-$(CONFIG_DSHOW_INDEV) += dshow_crossbar.o dshow.o dshow_enummediatypes.o \ dshow_enumpins.o dshow_filter.o \ dshow_pin.o dshow_common.o OBJS-$(CONFIG_DV1394_INDEV) += dv1394.o diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 0a5788dbb9..634937734d 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -28,51 +28,6 @@ #include "avdevice.h" #include "libavcodec/raw.h" -struct dshow_ctx { - const AVClass *class; - - IGraphBuilder *graph; - - char *device_name[2]; - int video_device_number; - int audio_device_number; - - int list_options; - int list_devices; - int audio_buffer_size; - char *video_pin_name; - char *audio_pin_name; - - IBaseFilter *device_filter[2]; - IPin *device_pin[2]; - libAVFilter *capture_filter[2]; - libAVPin *capture_pin[2]; - - HANDLE mutex; - HANDLE event[2]; /* event[0] is set by DirectShow - * event[1] is set by callback() */ - AVPacketList *pktl; - - int eof; - - int64_t curbufsize[2]; - unsigned int video_frame_num; - - IMediaControl *control; - IMediaEvent *media_event; - - enum AVPixelFormat pixel_format; - enum AVCodecID video_codec_id; - char *framerate; - - int requested_width; - int requested_height; - AVRational requested_framerate; - - int sample_rate; - int sample_size; - int channels; -}; static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) { @@ -710,8 +665,7 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum, } static int -dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, - enum dshowDeviceType devtype) +dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; @@ -719,6 +673,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, IPin *device_pin = NULL; libAVPin *capture_pin = NULL; libAVFilter *capture_filter = NULL; + ICaptureGraphBuilder2 *graph_builder2 = NULL; int ret = AVERROR(EIO); int r; @@ -741,6 +696,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, ret = r; goto error; } + ctx->device_pin[devtype] = device_pin; capture_filter = libAVFilter_Create(avctx, callback, devtype); @@ -761,15 +717,39 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, capture_pin = capture_filter->pin; ctx->capture_pin[devtype] = capture_pin; - r = IGraphBuilder_ConnectDirect(graph, device_pin, (IPin *) capture_pin, NULL); + r = CoCreateInstance(&CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, + &IID_ICaptureGraphBuilder2, (void **) &graph_builder2); + if (r != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Could not create CaptureGraphBuilder2\n"); + goto error; + } + ICaptureGraphBuilder2_SetFiltergraph(graph_builder2, graph); + if (r != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Could not set graph for CaptureGraphBuilder2\n"); + goto error; + } + + r = ICaptureGraphBuilder2_RenderStream(graph_builder2, NULL, NULL, (IUnknown *) device_pin, NULL /* no intermediate filter */, + (IBaseFilter *) capture_filter); /* connect pins, optionally insert intermediate filters like crossbar if necessary */ + + if (r != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Could not RenderStream to connect pins\n"); + goto error; + } + + r = dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); + if (r != S_OK) { - av_log(avctx, AV_LOG_ERROR, "Could not connect pins\n"); + av_log(avctx, AV_LOG_ERROR, "Could not setup CrossBar\n"); goto error; } ret = 0; error: + if (graph_builder2 != NULL) + ICaptureGraphBuilder2_Release(graph_builder2); + return ret; } @@ -988,11 +968,15 @@ static int dshow_read_header(AVFormatContext *avctx) } if (ctx->list_options) { if (ctx->device_name[VideoDevice]) - dshow_list_device_options(avctx, devenum, VideoDevice); + if ((r = dshow_list_device_options(avctx, devenum, VideoDevice))) { + ret = r; + goto error; + } if (ctx->device_name[AudioDevice]) - dshow_list_device_options(avctx, devenum, AudioDevice); - ret = AVERROR_EXIT; - goto error; + if ((r = dshow_list_device_options(avctx, devenum, AudioDevice))) { + ret = r; + goto error; + } } if (ctx->device_name[VideoDevice]) { @@ -1009,6 +993,11 @@ static int dshow_read_header(AVFormatContext *avctx) goto error; } } + if (ctx->list_options) { + /* allow it to list crossbar options in dshow_open_device */ + ret = AVERROR_EXIT; + goto error; + } ctx->curbufsize[0] = 0; ctx->curbufsize[1] = 0; ctx->mutex = CreateMutex(NULL, 0, NULL); @@ -1142,6 +1131,8 @@ static const AVOption options[] = { { "audio_device_number", "set audio device number for devices with same name (starts at 0)", OFFSET(audio_device_number), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC }, { "video_pin_name", "select video capture pin by name", OFFSET(video_pin_name),AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "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 }, { NULL }, }; diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 09e9b1b15c..602969d8d7 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -277,4 +277,65 @@ long WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, wchar_t **); void libAVFilter_Destroy(libAVFilter *); libAVFilter *libAVFilter_Create (void *, void *, enum dshowDeviceType); +/***************************************************************************** + * dshow_ctx + ****************************************************************************/ +struct dshow_ctx { + const AVClass *class; + + IGraphBuilder *graph; + + char *device_name[2]; + int video_device_number; + int audio_device_number; + + int list_options; + int list_devices; + int audio_buffer_size; + int crossbar_video_input_pin_number; + int crossbar_audio_input_pin_number; + char *video_pin_name; + char *audio_pin_name; + int show_video_device_dialog; + int show_audio_device_dialog; + + IBaseFilter *device_filter[2]; + IPin *device_pin[2]; + libAVFilter *capture_filter[2]; + libAVPin *capture_pin[2]; + + HANDLE mutex; + HANDLE event[2]; /* event[0] is set by DirectShow + * event[1] is set by callback() */ + AVPacketList *pktl; + + int eof; + + int64_t curbufsize[2]; + unsigned int video_frame_num; + + IMediaControl *control; + IMediaEvent *media_event; + + enum AVPixelFormat pixel_format; + enum AVCodecID video_codec_id; + char *framerate; + + int requested_width; + int requested_height; + AVRational requested_framerate; + + int sample_rate; + int sample_size; + int channels; +}; + +/***************************************************************************** + * CrossBar + ****************************************************************************/ +HRESULT dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, + IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx); + +void dshow_show_filter_properties(IBaseFilter *pFilter, AVFormatContext *avctx); + #endif /* AVDEVICE_DSHOW_H */ diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c new file mode 100644 index 0000000000..c4d1630533 --- /dev/null +++ b/libavdevice/dshow_crossbar.c @@ -0,0 +1,164 @@ +/* + * DirectShow capture interface + * Copyright (c) 2015 Roger Pack + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dshow_capture.h" + +static const char * +GetPhysicalPinName(long pin_type) +{ + switch (pin_type) + { + case PhysConn_Video_Tuner: return "Video Tuner"; + case PhysConn_Video_Composite: return "Video Composite"; + case PhysConn_Video_SVideo: return "S-Video"; + case PhysConn_Video_RGB: return "Video RGB"; + case PhysConn_Video_YRYBY: return "Video YRYBY"; + case PhysConn_Video_SerialDigital: return "Video Serial Digital"; + case PhysConn_Video_ParallelDigital: return "Video Parallel Digital"; + case PhysConn_Video_SCSI: return "Video SCSI"; + case PhysConn_Video_AUX: return "Video AUX"; + case PhysConn_Video_1394: return "Video 1394"; + case PhysConn_Video_USB: return "Video USB"; + case PhysConn_Video_VideoDecoder: return "Video Decoder"; + case PhysConn_Video_VideoEncoder: return "Video Encoder"; + + case PhysConn_Audio_Tuner: return "Audio Tuner"; + case PhysConn_Audio_Line: return "Audio Line"; + case PhysConn_Audio_Mic: return "Audio Microphone"; + case PhysConn_Audio_AESDigital: return "Audio AES/EBU Digital"; + case PhysConn_Audio_SPDIFDigital: return "Audio S/PDIF"; + case PhysConn_Audio_SCSI: return "Audio SCSI"; + case PhysConn_Audio_AUX: return "Audio AUX"; + case PhysConn_Audio_1394: return "Audio 1394"; + case PhysConn_Audio_USB: return "Audio USB"; + case PhysConn_Audio_AudioDecoder: return "Audio Decoder"; + default: return "Unknown Crossbar Pin Type—Please report!"; + } +} + +static HRESULT +setup_crossbar_options(IAMCrossbar *cross_bar, enum dshowDeviceType devtype, AVFormatContext *avctx) +{ + struct dshow_ctx *ctx = avctx->priv_data; + long count_output_pins, count_input_pins; + int i; + int log_level = ctx->list_options ? AV_LOG_INFO : AV_LOG_DEBUG; + int video_input_pin = ctx->crossbar_video_input_pin_number; + int audio_input_pin = ctx->crossbar_audio_input_pin_number; + const char *device_name = ctx->device_name[devtype]; + HRESULT hr; + + av_log(avctx, log_level, "Crossbar Switching Information for %s:\n", device_name); + hr = IAMCrossbar_get_PinCounts(cross_bar, &count_output_pins, &count_input_pins); + if (hr != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Unable to get crossbar pin counts\n"); + return hr; + } + + for (i = 0; i < count_output_pins; i++) + { + long related_pin, pin_type, route_to_pin; + hr = IAMCrossbar_get_CrossbarPinInfo(cross_bar, FALSE, i, &related_pin, &pin_type); + if (pin_type == PhysConn_Video_VideoDecoder) { + /* assume there is only one "Video (and one Audio) Decoder" output pin, and it's all we care about routing to...for now */ + if (video_input_pin != -1) { + av_log(avctx, log_level, "Routing video input from pin %d\n", video_input_pin); + hr = IAMCrossbar_Route(cross_bar, i, video_input_pin); + if (hr != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Unable to route video input from pin %d\n", video_input_pin); + return AVERROR(EIO); + } + } + } else if (pin_type == PhysConn_Audio_AudioDecoder) { + if (audio_input_pin != -1) { + av_log(avctx, log_level, "Routing audio input from pin %d\n", audio_input_pin); + hr = IAMCrossbar_Route(cross_bar, i, audio_input_pin); + if (hr != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Unable to route audio input from pin %d\n", audio_input_pin); + return hr; + } + } + } else { + av_log(avctx, AV_LOG_WARNING, "Unexpected output pin type, please report the type if you want to use this (%s)", GetPhysicalPinName(pin_type)); + } + + hr = IAMCrossbar_get_IsRoutedTo(cross_bar, i, &route_to_pin); + if (hr != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Unable to get crossbar is routed to from pin %d\n", i); + return hr; + } + av_log(avctx, log_level, " Crossbar Output pin %d: \"%s\" related output pin: %ld ", i, GetPhysicalPinName(pin_type), related_pin); + av_log(avctx, log_level, "current input pin: %ld ", route_to_pin); + av_log(avctx, log_level, "compatible input pins: "); + + for (int j = 0; j < count_input_pins; j++) + { + hr = IAMCrossbar_CanRoute(cross_bar, i, j); + if (hr == S_OK) + av_log(avctx, log_level ,"%d ", j); + } + av_log(avctx, log_level, "\n"); + } + + for (i = 0; i < count_input_pins; i++) + { + long related_pin, pin_type; + hr = IAMCrossbar_get_CrossbarPinInfo(cross_bar, TRUE, i, &related_pin, &pin_type); + if (hr != S_OK) { + av_log(avctx, AV_LOG_ERROR, "unable to get crossbar info audio input from pin %d\n", i); + return hr; + } + av_log(avctx, log_level, " Crossbar Input pin %d - \"%s\" ", i, GetPhysicalPinName(pin_type)); + av_log(avctx, log_level, "related input pin: %ld\n", related_pin); + } + return S_OK; +} + +/** + * Given a fully constructed graph, check if there is a cross bar filter, and configure its pins if so. + */ +HRESULT +dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, + IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormatContext *avctx) +{ + IAMCrossbar *cross_bar = NULL; + IBaseFilter *cross_bar_filter = NULL; + HRESULT hr; + + hr = ICaptureGraphBuilder2_FindInterface(graph_builder2, &LOOK_UPSTREAM_ONLY, (const GUID *) NULL, + (IBaseFilter *) device_filter, &IID_IAMCrossbar, (void**) &cross_bar); + if (hr != S_OK) { + /* no crossbar found */ + hr = S_OK; + goto end; + } + + hr = setup_crossbar_options(cross_bar, devtype, avctx); + if (hr != S_OK) + goto end; + +end: + if (cross_bar) + IAMCrossbar_Release(cross_bar); + if (cross_bar_filter) + IBaseFilter_Release(cross_bar_filter); + return hr; +} -- cgit v1.2.3 From 5d72cf0f64162aa130b4720f71e9249a6a34f08a Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Fri, 23 Jan 2015 06:49:37 -0700 Subject: dshow: add options for allowing filter popup configuration dialogs to be presented to the user Signed-off-by: rogerdpack --- configure | 2 +- doc/indevs.texi | 26 +++++++++++++++++++ libavdevice/dshow.c | 62 +++++++++++++++++++++++++++++++++++++++++++- libavdevice/dshow_capture.h | 1 + libavdevice/dshow_crossbar.c | 7 +++++ 5 files changed, 96 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/configure b/configure index a0dbafb1de..0b6be39c3d 100755 --- a/configure +++ b/configure @@ -2487,7 +2487,7 @@ decklink_outdev_extralibs="-lstdc++" decklink_indev_deps="decklink pthreads" decklink_indev_extralibs="-lstdc++" dshow_indev_deps="IBaseFilter" -dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid" +dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32" dv1394_indev_deps="dv1394" dv1394_indev_select="dv_demuxer" fbdev_indev_deps="linux_fb_h" diff --git a/doc/indevs.texi b/doc/indevs.texi index ec40c3400c..a9792fdab9 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -234,6 +234,25 @@ routed to the crossbar device's Video Decoder output pin. Select audio input pin number for crossbar device. This will be routed to the crossbar device's Audio Decoder output pin. +@item show_video_device_dialog +If set to @option{true}, before capture starts, popup a display dialog +to the end user, allowing them to change video filter properties +and configurations manually. +Note that for crossbar devices, this may be needed at times to toggle +between PAL and NTSC input frame rates and sizes, etc. Possibly +enabling different scan rates/frame rates and avoiding green bars at +the bottom, etc. + +@item show_audio_device_dialog +If set to @option{true}, before capture starts, popup a display dialog +to the end user, allowing them to change audio filter properties +and configurations manually. + +@item show_crossbar_connection_dialog +If set to @option{true}, before capture starts, popup a display +dialog to the end user, allowing them to manually +modify crossbar pin routings. + @end table @subsection Examples @@ -276,6 +295,13 @@ Specify pin names to capture by name or alternative name, specify alternative de $ ffmpeg -f dshow -audio_pin_name "Audio Out" -video_pin_name 2 -i video=video="@device_pnp_\\?\pci#ven_1a0a&dev_6200&subsys_62021461&rev_01#4&e2c7dd6&0&00e1#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{ca465100-deb0-4d59-818f-8c477184adf6}":audio="Microphone" @end example +@item +Configure a crossbar device, specifying crossbar pins, allow user to adjust video capture properties at startup: +@example +$ ffmpeg -f dshow -show_video_device_dialog true -crossbar_video_input_pin_number 0 + -crossbar_audio_input_pin_number 3 -i video="AVerMedia BDA Analog Capture":audio="AVerMedia BDA Analog Capture" +@end example + @end itemize @section dv1394 diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 634937734d..691250f3ac 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -502,6 +502,53 @@ end: return ret; } +/** + * 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 @@ -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 }, }; diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 602969d8d7..c4f46812fb 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -298,6 +298,7 @@ struct dshow_ctx { char *audio_pin_name; int show_video_device_dialog; int show_audio_device_dialog; + int show_crossbar_connection_dialog; IBaseFilter *device_filter[2]; IPin *device_pin[2]; diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c index c4d1630533..1260428d2d 100644 --- a/libavdevice/dshow_crossbar.c +++ b/libavdevice/dshow_crossbar.c @@ -139,6 +139,7 @@ HRESULT 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_filter = NULL; HRESULT hr; @@ -151,6 +152,12 @@ dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, goto end; } + if (ctx->show_crossbar_connection_dialog) { + hr = IAMCrossbar_QueryInterface(cross_bar, &IID_IBaseFilter, (void **) &cross_bar_filter); + if (hr != S_OK) + goto end; + dshow_show_filter_properties(cross_bar_filter, avctx); + } hr = setup_crossbar_options(cross_bar, devtype, avctx); if (hr != S_OK) goto end; -- cgit v1.2.3 From b587ec00f7b6df7c46efd115a544c0686bcbd833 Mon Sep 17 00:00:00 2001 From: rogerdpack Date: Fri, 23 Jan 2015 08:31:58 -0700 Subject: dshow: fix docu escapes Signed-off-by: rogerdpack --- doc/indevs.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/indevs.texi b/doc/indevs.texi index a9792fdab9..1a5203fda4 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -292,7 +292,7 @@ $ ffmpeg -list_options true -f dshow -i video="Camera" @item Specify pin names to capture by name or alternative name, specify alternative device name: @example -$ ffmpeg -f dshow -audio_pin_name "Audio Out" -video_pin_name 2 -i video=video="@device_pnp_\\?\pci#ven_1a0a&dev_6200&subsys_62021461&rev_01#4&e2c7dd6&0&00e1#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{ca465100-deb0-4d59-818f-8c477184adf6}":audio="Microphone" +$ ffmpeg -f dshow -audio_pin_name "Audio Out" -video_pin_name 2 -i video=video="@@device_pnp_\\?\pci#ven_1a0a&dev_6200&subsys_62021461&rev_01#4&e2c7dd6&0&00e1#@{65e8773d-8f56-11d0-a3b9-00a0c9223196@}\@{ca465100-deb0-4d59-818f-8c477184adf6@}":audio="Microphone" @end example @item -- cgit v1.2.3