summaryrefslogtreecommitdiff
path: root/libavdevice/dshow.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2011-09-30 17:49:09 -0300
committerMichael Niedermayer <michaelni@gmx.at>2011-11-06 01:19:56 +0100
commit2f9b955918f8efd9915dbd51bfe8be657cb337e3 (patch)
tree1eac9950ae62b3c38f2df5d9ca4b9ab269a39233 /libavdevice/dshow.c
parent68b531fe6aef7ef7f135bf33471990c19945a598 (diff)
dshow: support choosing between devices with same name
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice/dshow.c')
-rw-r--r--libavdevice/dshow.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index ab5f7e97e0..a5263df90b 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -31,6 +31,8 @@ struct dshow_ctx {
IGraphBuilder *graph;
char *device_name[2];
+ int video_device_number;
+ int audio_device_number;
int list_options;
int list_devices;
@@ -249,6 +251,8 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
IEnumMoniker *classenum = NULL;
IMoniker *m = NULL;
const char *device_name = ctx->device_name[devtype];
+ int skip = (devtype == VideoDevice) ? ctx->video_device_number
+ : ctx->audio_device_number;
int r;
const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory,
@@ -283,6 +287,7 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum,
if (strcmp(device_name, buf))
goto fail1;
+ if (!skip--)
IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter);
} else {
av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf);
@@ -938,6 +943,8 @@ static const AVOption options[] = {
{ "list_options", "list available options for specified device", OFFSET(list_options), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_options" },
{ "true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_options" },
{ "false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_options" },
+ { "video_device_number", "set video device number for devices with same name (starts at 0)", OFFSET(video_device_number), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC },
+ { "audio_device_number", "set audio device number for devices with same name (starts at 0)", OFFSET(audio_device_number), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC },
{ NULL },
};