add logging for camera blacklist and COM initialization status
This commit is contained in:
@ -160,7 +160,11 @@ std::vector<int> DisplayDeviceInformation(IEnumMoniker *pEnum)
|
|||||||
camera_ids.push_back(counter_device);
|
camera_ids.push_back(counter_device);
|
||||||
return_id_device = counter_device;
|
return_id_device = counter_device;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__LOG_CAM__<<"CAM ID "<<counter_device<<" EXCLUDED BY BLACKLIST ("<<name.c_str()<<")\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
__LOG_CAM__<<"RETURN DEVICE ID "<<return_id_device<<"\n";
|
__LOG_CAM__<<"RETURN DEVICE ID "<<return_id_device<<"\n";
|
||||||
|
|
||||||
@ -210,18 +214,31 @@ bool Webcam::Open(int width_, int height_) {
|
|||||||
|
|
||||||
std::vector<int> id_devices;
|
std::vector<int> id_devices;
|
||||||
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
if (SUCCEEDED(hr))
|
char hr_buf[32];
|
||||||
|
sprintf_s(hr_buf, "0x%08lX", (unsigned long)hr);
|
||||||
|
__LOG_CAM__ << "CoInitializeEx hr=" << hr_buf << "\n";
|
||||||
|
// RPC_E_CHANGED_MODE : COM deja initialise (STA) sur ce thread, utilisable tel quel
|
||||||
|
bool com_usable = SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE;
|
||||||
|
bool com_owned = SUCCEEDED(hr);
|
||||||
|
if (com_usable)
|
||||||
{
|
{
|
||||||
IEnumMoniker *pEnum;
|
IEnumMoniker *pEnum;
|
||||||
|
|
||||||
hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);
|
HRESULT hr_enum = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);
|
||||||
if (SUCCEEDED(hr))
|
sprintf_s(hr_buf, "0x%08lX", (unsigned long)hr_enum);
|
||||||
|
__LOG_CAM__ << "EnumerateDevices hr=" << hr_buf << "\n";
|
||||||
|
if (SUCCEEDED(hr_enum))
|
||||||
{
|
{
|
||||||
id_devices = DisplayDeviceInformation(pEnum);
|
id_devices = DisplayDeviceInformation(pEnum);
|
||||||
pEnum->Release();
|
pEnum->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
if (com_owned)
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__LOG_CAM__ << "CoInitializeEx FAILED, enumeration skipped\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id_devices.size() == 0) {
|
if (id_devices.size() == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user