QTCaptureDeviceWasConnectedNotification
我正在开发一个桌面应用程序,其中列出了连接到系统的网络摄像头。当用户选择网络摄像头应用程序时,它会从设备流传输到 QTCaptureView。 我已注册通知 QTCaptureDeviceWasDisconnectedNotification
和 QTCaptureDeviceWasConnectedNotification
,以便每当设备断开连接和连接时我都会删除设备并将其添加到列表中。
问题在于,连接设备时,QTCaptureDeviceWasConnectedNotification
会发布两次。这是什么原因呢?
另外,在我的一台 Mac Book 中,我经常遇到以下问题。 从 QTCaptureDeviceWasConnectedNotification 第二个通知(我收到两个通知)获得的设备没有本地化的描述名称。 你能告诉我这里可能出了什么问题吗?
I am developing a Desktop application that lists the webcams connected to the system. When the user selects the web-cam app streams from the device to the QTCaptureView.
I have registered to the notification QTCaptureDeviceWasDisconnectedNotification
and QTCaptureDeviceWasConnectedNotification
so that I remove and add the device to the list whenever device is disconnected and connected.
The problem is that QTCaptureDeviceWasConnectedNotification
is posted twice when a device is connected. What is the reason for this?
Also, in one of my Mac Book I get the following problem frequently.
The device obtained from QTCaptureDeviceWasConnectedNotification 2nd notification (I get two notifications) does not have the localized description name.
Could you please tell me what might have gone wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的问题。在我的例子中,这种有趣行为的原因是带有内置麦克风的网络摄像头。因此,当连接此类多功能设备时,将会有两个通知 - 第一个针对视频捕获设备,第二个针对内置麦克风。
这是我的一般错误列表,这些错误阻止我了解情况(可能会对您有所帮助):
这是我的测试日志。
在设备连接上,第一个通知是:
您可以单独看到 UVC 相机。第二个通知是:
您可以看到 UVC 摄像头和 AppleUSBAudioEngine - 麦克风。
设备分离时也会有两个通知。第一个:
没有麦克风,UVC 摄像头还在。第二个通知:
没有 UVC 摄像头,没有麦克风。
此外,QTKit 可能可以“合并”通知,因为有时我只收到一项通知(一项用于连接,一项用于断开连接),因此实际通知数量不仅取决于连接或断开连接的(子)设备的数量。
对于 localizedDisplayName - 还没有任何问题。
I had the same problem. The reason of such interesting behavior in my case was webcam with built-in microphone. So, when attaching such multi-purpose device there will be two notifications - one for video capture device and second for built-in microphone.
This is list of my general faults that blocked me from understanding the situation (possibly will help you):
Here logs from my test.
On device attach first notification is:
You can see UVC camera alone. Second notification is:
You can see UVC camera and AppleUSBAudioEngine - the microphone.
On device detach there will be two notification also. First one:
No microphone, UVC camera still there. Second notification:
No UVC camera, no microphone.
Also, QTKit possibly can "merge" notifications since sometimes I get only one notification (one for connect and one for disconnect), so actual number of notifications depends not only from number of (sub-)devices connected or disconnected.
For localizedDisplayName - had no problems with it yet.
我遇到了同样的问题,所以我做了一些挖掘,确实它似乎与包含音频和视频的设备有关。
因此,我尝试确定该条目是音频条目还是视频条目,这是我发现的:
上面的输出“vide”或“soun”,它们是 QTMediaTypeVideo 和 QTMediaTypeSound 的值。因此,如果您只想使用视频设备,可以检查上述值是否为 QTMediaTypeVideo。
不确定它是否对您的问题有帮助。
I had the same issue so I did some digging, and indeed it seems related to a device that contains audio as well as video.
So I tried to determine if the entry was an audio one or video one, here is what I found:
The above outputs "vide" or "soun" which are the values for QTMediaTypeVideo and QTMediaTypeSound. So you can check if the above value is QTMediaTypeVideo if you just want to work with the video device.
Not sure if it helps your issue.