QTCaptureDeviceWasConnectedNotification

I am developing a desktop application that lists webcams connected to the system. When the user selects webcam application streams from the device to QTCaptureView. I registered in the notification QTCaptureDeviceWasDisconnectedNotificationand QTCaptureDeviceWasConnectedNotificationto remove and add the device to the list whenever the device is disconnected and connected.

The problem is that it is QTCaptureDeviceWasConnectedNotificationsent twice when the device is connected. What is the reason for this?

Also, in one of my Mac books, I often get the following problem. The device received from the second QTCaptureDeviceWasConnectedNotification notification (I receive two notifications) does not have a localized description name. Could you tell me what could be wrong here?

+3
source share
2 answers

I had the same problem. The reason for this interesting behavior in my case was a webcam with a built-in microphone. Thus, when connecting such a multipurpose device, there will be two notifications: one for the video capture device and the second for the built-in microphone.

This is a list of my common flaws that prevented me from understanding the situation (maybe this will help):

  • A webcam with a built-in microphone was used.
  • Used [QTCaptureDevice inputDevicesWithMediaType:] instead of [QTCaptureDevice inputDevices]. This prevented me from seeing other types of devices connected (for example, a microphone).
  • , "" . , (, + ) (-mic, -video) - .

.

:

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 - .

+1

, , , , , .

, , - , :

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

"vide" "soun", QTMediaTypeVideo QTMediaTypeSound. , , QTMediaTypeVideo, .

, .

+1

Source: https://habr.com/ru/post/1791181/


All Articles