dshowsrcwrapper: can list more than 1 device

something like the following code now works:

vector<string> getVideoDeviceNames()
{
    vector<string> 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;
}
This commit is contained in:
Julien Isorce 2009-08-10 16:35:36 +02:00
parent ae6935e6a3
commit 8c37eed491
2 changed files with 4 additions and 6 deletions

View file

@ -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);

View file

@ -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);