QTCaptureDeviceWasConnectedNotification

发布于 2024-10-16 22:27:07 字数 446 浏览 0 评论 0原文

我正在开发一个桌面应用程序,其中列出了连接到系统的网络摄像头。当用户选择网络摄像头应用程序时,它会从设备流传输到 QTCaptureView。 我已注册通知 QTCaptureDeviceWasDisconnectedNotificationQTCaptureDeviceWasConnectedNotification ,以便每当设备断开连接和连接时我都会删除设备并将其添加到列表中。

问题在于,连接设备时,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与之呼应 2024-10-23 22:27:07

我也有同样的问题。在我的例子中,这种有趣行为的原因是带有内置麦克风的网络摄像头。因此,当连接此类多功能设备时,将会有两个通知 - 第一个针对视频捕获设备,第二个针对内置麦克风。

这是我的一般错误列表,这些错误阻止我了解情况(可能会对您有所帮助):

  • 使用带有内置麦克风的网络摄像头
  • 使用 [QTCaptureDevice inputDevicesWithMediaType:] 而不是 [QTCaptureDevice inputDevices]。这阻止了我看到连接的其他类型的设备(例如麦克风)。
  • 在我的测试中,当没有“视频”设备时,我没有记录任何内容。这就是为什么我看到两个连接的通知(视频,视频+麦克风)和只有一个断开连接的通知(-麦克风,-视频) - 这一开始让我感到困惑。

这是我的测试日志。

在设备连接上,第一个通知是:

Device++ #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device++ #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device++ #2: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

您可以单独看到 UVC 相机。第二个通知是:

Device++ #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device++ #1: "AppleUSBAudioEngine:Unknown Manufacturer:Logitech Camera:5895DC4F:3" - "AppleUSBAudioDevice:Logitech Camera"
Device++ #2: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device++ #3: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

您可以看到 UVC 摄像头和 AppleUSBAudioEngine - 麦克风。

设备分离时也会有两个通知。第一个:

Device-- #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device-- #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device-- #2: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

没有麦克风,UVC 摄像头还在。第二个通知:

Device-- #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device-- #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"

没有 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):

  • Was used webcam with built-in microphone
  • Was used [QTCaptureDevice inputDevicesWithMediaType:] instead of [QTCaptureDevice inputDevices]. That blocked me from seeing other types of devices attached (such as microphone)
  • In my test I logged nothing when there is no "video" devices. That's the reason I saw two connected notifications (video,video+mic) and only one disconnected (-mic,-video) - that confused me at first.

Here logs from my test.

On device attach first notification is:

Device++ #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device++ #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device++ #2: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

You can see UVC camera alone. Second notification is:

Device++ #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device++ #1: "AppleUSBAudioEngine:Unknown Manufacturer:Logitech Camera:5895DC4F:3" - "AppleUSBAudioDevice:Logitech Camera"
Device++ #2: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device++ #3: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

You can see UVC camera and AppleUSBAudioEngine - the microphone.

On device detach there will be two notification also. First one:

Device-- #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device-- #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"
Device-- #2: "0xfd100000046d0990" - "UVC Camera VendorID_1133 ProductID_2448"

No microphone, UVC camera still there. Second notification:

Device-- #0: "AppleHDAEngineInput:1B,0,1,1:4" - "AppleHDA:12"
Device-- #1: "AppleHDAEngineInput:1B,0,1,0:3" - "AppleHDA:12"

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.

走走停停 2024-10-23 22:27:07

我遇到了同样的问题,所以我做了一些挖掘,确实它似乎与包含音频和视频的设备有关。

因此,我尝试确定该条目是音频条目还是视频条目,这是我发现的:

NSArray *inputDevices = [QTCaptureDevice inputDevices]; 
for(QTCaptureDevice *listDevice in inputDevices) {
    NSLog(@"%@",[[[device formatDescriptions] objectAtIndex:0] mediaType]);
}

上面的输出“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:

NSArray *inputDevices = [QTCaptureDevice inputDevices]; 
for(QTCaptureDevice *listDevice in inputDevices) {
    NSLog(@"%@",[[[device formatDescriptions] objectAtIndex:0] mediaType]);
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文