1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include "pch.h"
- #include "MediaDevices.h"
- #include "webrtc/modules/video_capture/video_capture_factory.h"
- int __stdcall CreateVideoDeviceInfo(void** hDeviceInfo)
- {
- try
- {
- webrtc::VideoCaptureModule::DeviceInfo* deviceInfo = webrtc::VideoCaptureFactory::CreateDeviceInfo();
- *hDeviceInfo = deviceInfo;
- int num = deviceInfo->NumberOfDevices();
- return num;
- }
- catch (int e)
- {
- *hDeviceInfo = nullptr;
- return 0;
- }
- }
- int __stdcall GetVidoeDeviceInfo(void* hDeviceInfo, uint32_t deviceNumber, void** mediaDeviceInfo)
- {
- try
- {
- webrtc::VideoCaptureModule::DeviceInfo* deviceInfo = static_cast<webrtc::VideoCaptureModule::DeviceInfo*>(hDeviceInfo);
- std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(deviceInfo);
- const uint32_t kSize = 256;
- char deviceNameUTF8[kSize] = {0};
- char deviceUniqueIdUTF8[kSize] = { 0 };
- char productUniqueIdUTF8[kSize] = { 0 };
-
- VideoDeviceInfo* df = (VideoDeviceInfo*)malloc(sizeof(struct VideoDeviceInfo)); //TODO who will free it ?
- int32_t iRet = info->GetDeviceName(deviceNumber, deviceNameUTF8, kSize, deviceUniqueIdUTF8, kSize, productUniqueIdUTF8, kSize);
- /*MyDeviceInfo df;*/
- df->deviceNumber = deviceNumber;
- strcpy(df->deviceNameUTF8, deviceNameUTF8);
- strcpy(df->deviceUniqueIdUTF8, deviceUniqueIdUTF8);
- strcpy(df->productUniqueIdUTF8, productUniqueIdUTF8);
-
- void* result = static_cast<void*>(df);
- *mediaDeviceInfo = result;
-
- return (int)iRet;
- //return 0;
- }
- catch (int e)
- {
- return -1;
- }
- }
|