Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 341
spd Avatar asked Mar 25 '26 03:03

spd


1 Answers

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.

like image 136
wonder.mice Avatar answered Mar 27 '26 22:03

wonder.mice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!