summaryrefslogtreecommitdiffstats
path: root/plugins/pluginWinMF/internals/mf_devices.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pluginWinMF/internals/mf_devices.cxx')
-rwxr-xr-xplugins/pluginWinMF/internals/mf_devices.cxx95
1 files changed, 43 insertions, 52 deletions
diff --git a/plugins/pluginWinMF/internals/mf_devices.cxx b/plugins/pluginWinMF/internals/mf_devices.cxx
index 22b862e..49005de 100755
--- a/plugins/pluginWinMF/internals/mf_devices.cxx
+++ b/plugins/pluginWinMF/internals/mf_devices.cxx
@@ -1,18 +1,18 @@
/* Copyright (C) 2013 Mamadou DIOP
* Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*/
@@ -20,25 +20,25 @@
#include "mf_utils.h"
DeviceList::DeviceList()
-: m_ppDevices(NULL)
-, m_cDevices(0)
+ : m_ppDevices(NULL)
+ , m_cDevices(0)
{
-
+
}
DeviceList::~DeviceList()
{
- Clear();
+ Clear();
}
UINT32 DeviceList::Count()const
{
- return m_cDevices;
+ return m_cDevices;
}
void DeviceList::Clear()
{
- for (UINT32 i = 0; i < m_cDevices; i++) {
+ for (UINT32 i = 0; i < m_cDevices; i++) {
SafeRelease(&m_ppDevices[i]);
}
CoTaskMemFree(m_ppDevices);
@@ -49,7 +49,7 @@ void DeviceList::Clear()
HRESULT DeviceList::EnumerateDevices(const GUID& sourceType)
{
- HRESULT hr = S_OK;
+ HRESULT hr = S_OK;
IMFAttributes *pAttributes = NULL;
Clear();
@@ -60,17 +60,15 @@ HRESULT DeviceList::EnumerateDevices(const GUID& sourceType)
hr = MFCreateAttributes(&pAttributes, 1);
// Ask for source type = video capture devices
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pAttributes->SetGUID(
- MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
- sourceType
- );
+ MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
+ sourceType
+ );
}
// Enumerate devices.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = MFEnumDeviceSources(pAttributes, &m_ppDevices, &m_cDevices);
}
@@ -81,8 +79,7 @@ HRESULT DeviceList::EnumerateDevices(const GUID& sourceType)
HRESULT DeviceList::GetDeviceAtIndex(UINT32 index, IMFActivate **ppActivate)
{
- if (index >= Count())
- {
+ if (index >= Count()) {
return E_INVALIDARG;
}
@@ -94,58 +91,52 @@ HRESULT DeviceList::GetDeviceAtIndex(UINT32 index, IMFActivate **ppActivate)
HRESULT DeviceList::GetDeviceBest(IMFActivate **ppActivate, WCHAR *pszName /*= NULL*/)
{
- UINT32 index = 0;
- if(pszName)
- {
- WCHAR *_pszName = NULL;
- BOOL bFound = FALSE;
- for(UINT32 i = 0; i < Count() && !bFound; ++i)
- {
- if((SUCCEEDED(GetDeviceName(i, &_pszName))))
- {
- if(wcscmp(_pszName, pszName) == 0)
- {
- index = i;
- bFound = TRUE;
- // do not break the loop because we need to free(_pszName)
- }
- }
- if(_pszName)
- {
- CoTaskMemFree(_pszName), _pszName = NULL;
- }
- }
- }
- return GetDeviceAtIndex(index, ppActivate);
+ UINT32 index = 0;
+ if(pszName) {
+ WCHAR *_pszName = NULL;
+ BOOL bFound = FALSE;
+ for(UINT32 i = 0; i < Count() && !bFound; ++i) {
+ if((SUCCEEDED(GetDeviceName(i, &_pszName)))) {
+ if(wcscmp(_pszName, pszName) == 0) {
+ index = i;
+ bFound = TRUE;
+ // do not break the loop because we need to free(_pszName)
+ }
+ }
+ if(_pszName) {
+ CoTaskMemFree(_pszName), _pszName = NULL;
+ }
+ }
+ }
+ return GetDeviceAtIndex(index, ppActivate);
}
// The caller must free the memory for the string by calling CoTaskMemFree
HRESULT DeviceList::GetDeviceName(UINT32 index, WCHAR **ppszName)
{
- if (index >= Count())
- {
+ if (index >= Count()) {
return E_INVALIDARG;
}
HRESULT hr = S_OK;
hr = m_ppDevices[index]->GetAllocatedString(
- MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
- ppszName,
- NULL
- );
+ MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
+ ppszName,
+ NULL
+ );
return hr;
}
HRESULT DeviceListAudio::EnumerateDevices()
{
- // call base class function
- return DeviceList::EnumerateDevices(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID);
+ // call base class function
+ return DeviceList::EnumerateDevices(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_GUID);
}
HRESULT DeviceListVideo::EnumerateDevices()
{
- // call base class function
- return DeviceList::EnumerateDevices(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
+ // call base class function
+ return DeviceList::EnumerateDevices(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
}
OpenPOWER on IntegriCloud