From 8c37eed49162a3006753de0253d66bab3fabbf9b Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Mon, 10 Aug 2009 16:35:36 +0200 Subject: [PATCH] dshowsrcwrapper: can list more than 1 device something like the following code now works: vector getVideoDeviceNames() { vector l_name; string property; GstElement* videodevicesrc = create_element("dshowvideosrc", "videodevicesrc"); GstPropertyProbe* probe = GST_PROPERTY_PROBE (videodevicesrc); GValueArray* va = gst_property_probe_get_values_name (probe, "device-name"); if (va) { for(size_t i=0; i < va->n_values; ++i) { GValue* v = g_value_array_get_nth(va, i); string name(g_value_get_string(v)); l_name.push_back(name); } } if (videodevicesrc) gst_object_unref(GST_OBJECT (videodevicesrc)); return l_name; } --- sys/dshowsrcwrapper/gstdshowaudiosrc.cpp | 5 ++--- sys/dshowsrcwrapper/gstdshowvideosrc.cpp | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp index f16f747895..03dab12def 100755 --- a/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp +++ b/sys/dshowsrcwrapper/gstdshowaudiosrc.cpp @@ -264,15 +264,12 @@ static GValueArray * gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src) { GValueArray *array = g_value_array_new (0); - GValue value = { 0 }; ICreateDevEnum *devices_enum = NULL; IEnumMoniker *moniker_enum = NULL; IMoniker *moniker = NULL; HRESULT hres = S_FALSE; ULONG fetched; - g_value_init (&value, G_TYPE_STRING); - hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (LPVOID *) &devices_enum); if (hres != S_OK) { @@ -310,6 +307,8 @@ gst_dshowaudiosrc_get_device_name_values (GstDshowAudioSrc * src) g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal, wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL); + GValue value = { 0 }; + g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, friendly_name); g_value_array_append (array, &value); g_value_unset (&value); diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp index 4042408f05..86cb5eb76c 100755 --- a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp +++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp @@ -353,15 +353,12 @@ static GValueArray * gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src) { GValueArray *array = g_value_array_new (0); - GValue value = { 0 }; ICreateDevEnum *devices_enum = NULL; IEnumMoniker *moniker_enum = NULL; IMoniker *moniker = NULL; HRESULT hres = S_FALSE; ULONG fetched; - g_value_init (&value, G_TYPE_STRING); - hres = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (LPVOID *) &devices_enum); if (hres != S_OK) { @@ -400,6 +397,8 @@ gst_dshowvideosrc_get_device_name_values (GstDshowVideoSrc * src) g_utf16_to_utf8 ((const gunichar2 *) varFriendlyName.bstrVal, wcslen (varFriendlyName.bstrVal), NULL, NULL, NULL); + GValue value = { 0 }; + g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, friendly_name); g_value_array_append (array, &value); g_value_unset (&value);