static GstCaps * gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc) { HRESULT hres = S_OK; IBindCtx *lpbc = NULL; IMoniker *audiom = NULL; DWORD dwEaten; GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (basesrc); gunichar2 *unidevice = NULL; if (src->device) { g_free (src->device); src->device = NULL; } src->device = gst_dshow_getdevice_from_devicename (&CLSID_AudioInputDeviceCategory, &src->device_name); if (!src->device) { GST_CAT_ERROR (dshowaudiosrc_debug, "No audio device found."); return NULL; } unidevice = g_utf8_to_utf16 (src->device, strlen (src->device), NULL, NULL, NULL); if (!src->audio_cap_filter) { hres = CreateBindCtx (0, &lpbc); if (SUCCEEDED (hres)) { hres = MkParseDisplayName (lpbc, unidevice, &dwEaten, &audiom); if (SUCCEEDED (hres)) { hres = IMoniker_BindToObject (audiom, lpbc, NULL, &IID_IBaseFilter, &src->audio_cap_filter); IMoniker_Release (audiom); } IBindCtx_Release (lpbc); } } if (src->audio_cap_filter && !src->caps) { /* get the capture pins supported types */ IPin *capture_pin = NULL; IEnumPins *enumpins = NULL; HRESULT hres; hres = IBaseFilter_EnumPins (src->audio_cap_filter, &enumpins); if (SUCCEEDED (hres)) { while (IEnumPins_Next (enumpins, 1, &capture_pin, NULL) == S_OK) { IKsPropertySet *pKs = NULL; hres = IPin_QueryInterface (capture_pin, &IID_IKsPropertySet, (void **) &pKs); if (SUCCEEDED (hres) && pKs) { DWORD cbReturned; GUID pin_category; RPC_STATUS rpcstatus; hres = IKsPropertySet_Get (pKs, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, &pin_category, sizeof (GUID), &cbReturned); /* we only want capture pins */ if (UuidCompare (&pin_category, &PIN_CATEGORY_CAPTURE, &rpcstatus) == 0) { IAMStreamConfig *streamcaps = NULL; if (SUCCEEDED (IPin_QueryInterface (capture_pin, &IID_IAMStreamConfig, (void **) &streamcaps))) { src->caps = gst_dshowaudiosrc_getcaps_from_streamcaps (src, capture_pin, streamcaps); IAMStreamConfig_Release (streamcaps); } } IKsPropertySet_Release (pKs); } IPin_Release (capture_pin); } IEnumPins_Release (enumpins); } } if (unidevice) { g_free (unidevice); } if (src->caps) { return gst_caps_ref (src->caps); } return NULL; }
static GstCaps * gst_dshowaudiosrc_get_caps (GstBaseSrc * basesrc, GstCaps * filter) { HRESULT hres = S_OK; IBindCtx *lpbc = NULL; IMoniker *audiom = NULL; DWORD dwEaten; GstDshowAudioSrc *src = GST_DSHOWAUDIOSRC (basesrc); gunichar2 *unidevice = NULL; if (src->device) { g_free (src->device); src->device = NULL; } src->device = gst_dshow_getdevice_from_devicename (&CLSID_AudioInputDeviceCategory, &src->device_name); if (!src->device) { GST_ERROR ("No audio device found."); return NULL; } unidevice = g_utf8_to_utf16 (src->device, strlen (src->device), NULL, NULL, NULL); if (!src->audio_cap_filter) { hres = CreateBindCtx (0, &lpbc); if (SUCCEEDED (hres)) { hres = MkParseDisplayName (lpbc, (LPCOLESTR) unidevice, &dwEaten, &audiom); if (SUCCEEDED (hres)) { hres = audiom->BindToObject (lpbc, NULL, IID_IBaseFilter, (LPVOID *) & src->audio_cap_filter); audiom->Release (); } lpbc->Release (); } } if (src->audio_cap_filter && !src->caps) { /* get the capture pins supported types */ IPin *capture_pin = NULL; IEnumPins *enumpins = NULL; HRESULT hres; hres = src->audio_cap_filter->EnumPins (&enumpins); if (SUCCEEDED (hres)) { while (enumpins->Next (1, &capture_pin, NULL) == S_OK) { IKsPropertySet *pKs = NULL; hres = capture_pin->QueryInterface (IID_IKsPropertySet, (LPVOID *) & pKs); if (SUCCEEDED (hres) && pKs) { DWORD cbReturned; GUID pin_category; RPC_STATUS rpcstatus; hres = pKs->Get (AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, &pin_category, sizeof (GUID), &cbReturned); /* we only want capture pins */ if (UuidCompare (&pin_category, (UUID *) & PIN_CATEGORY_CAPTURE, &rpcstatus) == 0) { IAMStreamConfig *streamcaps = NULL; if (SUCCEEDED (capture_pin->QueryInterface (IID_IAMStreamConfig, (LPVOID *) & streamcaps))) { src->caps = gst_dshowaudiosrc_getcaps_from_streamcaps (src, capture_pin, streamcaps); streamcaps->Release (); } } pKs->Release (); } capture_pin->Release (); } enumpins->Release (); } } if (unidevice) { g_free (unidevice); } if (src->caps) { GstCaps *caps; if (filter) { caps = gst_caps_intersect_full (filter, src->caps, GST_CAPS_INTERSECT_FIRST); } else { caps = gst_caps_ref (src->caps); } return caps; } return NULL; }