summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/camera/dscamerasession.cpp
diff options
context:
space:
mode:
authorLev Zelenskiy <lev.zelenskiy@nokia.com>2012-07-27 11:35:17 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-03 06:01:13 +0200
commit42cdb92543ebba4d4cadff76f51712219245f347 (patch)
tree25144a475777a8581ff4f789f849095e84d59d1f /src/plugins/directshow/camera/dscamerasession.cpp
parenta6e88ea87f544638cf15f3bb61ccc276b1cc5664 (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/camera/dscamerasession.cpp')
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp59
1 files changed, 21 insertions, 38 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index ccc39a874..71151b557 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -417,31 +417,23 @@ void DSCameraSession::setDevice(const QString &device)
pEnum->Reset();
// go through and find all video capture devices
IMoniker* pMoniker = NULL;
+ IMalloc *mallocInterface = 0;
+ CoGetMalloc(1, (LPMALLOC*)&mallocInterface);
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
- }
- // Find the description
- WCHAR str[120];
- VARIANT varName;
- varName.vt = VT_BSTR;
- hr = pPropBag->Read(L"Description", &varName, 0);
- if(FAILED(hr))
- 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));
+
+ BSTR strName = 0;
+ hr = pMoniker->GetDisplayName(NULL, NULL, &strName);
+ if (SUCCEEDED(hr)) {
+ QString temp(QString::fromWCharArray(strName));
+ mallocInterface->Free(strName);
if(temp.contains(device)) {
available = true;
}
}
- pPropBag->Release();
+
pMoniker->Release();
}
+ mallocInterface->Release();
pEnum->Release();
}
pDevEnum->Release();
@@ -449,7 +441,7 @@ void DSCameraSession::setDevice(const QString &device)
CoUninitialize();
if(available) {
- m_device = QByteArray(device.toLocal8Bit().constData());
+ m_device = QByteArray(device.toUtf8().constData());
graph = createFilterGraph();
if(!graph)
available = false;
@@ -698,36 +690,27 @@ bool DSCameraSession::createFilterGraph()
pDevEnum->Release();
if (S_OK == hr) {
pEnum->Reset();
+ IMalloc *mallocInterface = 0;
+ CoGetMalloc(1, (LPMALLOC*)&mallocInterface);
//go through and find all video capture devices
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
- }
- // Find the description
- WCHAR str[120];
- VARIANT varName;
- varName.vt = VT_BSTR;
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
+
+ BSTR strName = 0;
+ hr = pMoniker->GetDisplayName(NULL, NULL, &strName);
if (SUCCEEDED(hr)) {
- // check if it is the selected device
- wcsncpy(str, varName.bstrVal, sizeof(str)/sizeof(str[0]));
- QString output = QString::fromUtf16((unsigned short*)str);
- if (m_device.contains(output.toLocal8Bit().constData())) {
+ QString output = QString::fromWCharArray(strName);
+ mallocInterface->Free(strName);
+ if (m_device.contains(output.toUtf8().constData())) {
hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pCap);
if (SUCCEEDED(hr)) {
- pPropBag->Release();
pMoniker->Release();
break;
}
}
}
- pPropBag->Release();
pMoniker->Release();
}
+ mallocInterface->Release();
if (NULL == pCap)
{
if (m_device.contains("default"))
@@ -770,7 +753,7 @@ bool DSCameraSession::createFilterGraph()
return false;
}
- pSG_Filter->QueryInterface(IID_ISampleGrabber, (void**)&pSG);
+ hr = pSG_Filter->QueryInterface(IID_ISampleGrabber, (void**)&pSG);
if (FAILED(hr)) {
qWarning() << "failed to get sample grabber";
return false;