diff options
author | Lev Zelenskiy <lev.zelenskiy@nokia.com> | 2012-07-27 11:35:17 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-03 06:01:13 +0200 |
commit | 42cdb92543ebba4d4cadff76f51712219245f347 (patch) | |
tree | 25144a475777a8581ff4f789f849095e84d59d1f /src/plugins/directshow/dsserviceplugin.cpp | |
parent | a6e88ea87f544638cf15f3bb61ccc276b1cc5664 (diff) |
Use moniker display name for device string.
Moniker names are unique, while device friendly names are not.
Change-Id: Ic3e842e49d04c502cf5ad1fc40f89db657f0401a
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'src/plugins/directshow/dsserviceplugin.cpp')
-rw-r--r-- | src/plugins/directshow/dsserviceplugin.cpp | 57 |
1 files changed, 4 insertions, 53 deletions
diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp index d3871c844..84ba84f4b 100644 --- a/src/plugins/directshow/dsserviceplugin.cpp +++ b/src/plugins/directshow/dsserviceplugin.cpp @@ -44,7 +44,7 @@ #include <QtCore/QFile> #include "dsserviceplugin.h" - +#include "dsvideodevicecontrol.h" #ifdef QMEDIA_DIRECTSHOW_CAMERA #include <dshow.h> @@ -138,58 +138,9 @@ QString DSServicePlugin::deviceDescription(const QByteArray &service, const QByt void DSServicePlugin::updateDevices() const { - m_cameraDevices.clear(); - m_cameraDescriptions.clear(); - BOOL bFound = TRUE; - CoInitialize(NULL); - ICreateDevEnum* pDevEnum = NULL; - IEnumMoniker* pEnum = NULL; - // Create the System device enumerator - HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, - CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, - reinterpret_cast<void**>(&pDevEnum)); - if(SUCCEEDED(hr)) { - // Create the enumerator for the video capture category - hr = pDevEnum->CreateClassEnumerator( - CLSID_VideoInputDeviceCategory, &pEnum, 0); - if (S_OK == hr) { - pEnum->Reset(); - // go through and find all video capture devices - IMoniker* pMoniker = NULL; - while(pEnum->Next(1, &pMoniker, NULL) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag, - (void**)(&pPropBag)); - if(FAILED(hr)) { - pMoniker->Release(); - continue; // skip this one - } - bFound = TRUE; - // Find the description - WCHAR str[120]; - VARIANT varName; - varName.vt = VT_BSTR; - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if(SUCCEEDED(hr)) { - wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0])); - QString temp(QString::fromUtf16((unsigned short*)str)); - m_cameraDevices.append(QString("ds:%1").arg(temp).toLocal8Bit().constData()); - hr = pPropBag->Read(L"Description", &varName, 0); - wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0])); - QString temp2(QString::fromUtf16((unsigned short*)str)); - m_cameraDescriptions.append(temp2); - } else { - qWarning() << "No friendly name"; - } - pPropBag->Release(); - pMoniker->Release(); - } - pEnum->Release(); - } - pDevEnum->Release(); - } - CoUninitialize(); - if (!bFound) { + DSVideoDeviceControl::enumerateDevices(&m_cameraDevices, &m_cameraDescriptions); + + if (m_cameraDevices.isEmpty()) { qWarning() << "No camera devices found"; } } |