如何通过符号链接连接到对应IMFMediaSource的libusb设备?
问题:关联Microsoft Media Foundation设备符号链接与libusb设备序列号
我正在用Microsoft Media Foundation(MF)访问一款支持批量传输的视频流设备,同时需要通过libusb连接该设备。当前有两台VID和PID完全相同的设备,无法区分MF的<IMFMediaSource>对应的设备和libusb连接的设备是否为同一台。
从MF中仅能获取到设备的符号链接:\\?\usb#vid_----&pid_----&mi_00#8&20ba1d94&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\global(已隐藏实际VID和PID)
通过libusb可以读取到设备的序列号:$Rev:0001_CID:0009011D01502130_SN:76543210$
两台设备的序列号不同,但找不到方法将MF的符号链接与libusb的序列号关联,以确认是否为同一台设备。
获取MF设备符号链接的代码
IMFAttributes* pAttributes = NULL; IMFActivate** ppDevices = NULL; HRESULT hr = EnumerateVideoDevices(pAttributes, ppDevices, availDeviceCount); availDevice = new Device[availDeviceCount]; // initialise empty return array // populate return array w/ devices for (int i = 0; i < availDeviceCount; i++) { wchar_t* deviceFriendlyName; UINT len = 0; hr = ppDevices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &deviceFriendlyName, &len); Device newDevice{ i, ToNarrow(deviceFriendlyName), NULL, 0 }; // TODO: check that change from unicode to String doesn't screw anything up (see ToNarrow, misc.h) // retain for device change notificatios ppDevices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &newDevice.g_pwszSymbolicLink, &newDevice.g_cchSymbolicLink); availDevice[i] = newDevice; }
通过libusb获取设备序列号的代码
String serial = LibUsb.getStringDescriptor(handle, descriptor.iSerialNumber());
内容的提问来源于stack exchange,提问作者TerZer
相关产品推荐
相关产品推荐

