linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] Possible camera detection bug in Linphone-ios


From: Jehan Monnier
Subject: Re: [Linphone-developers] Possible camera detection bug in Linphone-ios
Date: Tue, 31 Jul 2012 16:32:38 +0200

Hi Ramon,

Thanks for you very interesting report.

Indeed, on IOS we don't need to use the localized name at all.
I changed MS2 IOS capture filter to use modelID instead of localized name.
Consequently, 

#define FRONT_CAM_NAME
becomes : 
"AV Capture: com.apple.avfoundation.avcapturedevice.built-in_video:1" /*"AV Capture: Front Camera"*/
and
#define BACK_CAM_NAME 
becomes : 
"AV Capture: com.apple.avfoundation.avcapturedevice.built-in_video:0" /*"AV Capture: Back Camera"*/

Best regards

Jehan

Le 25 juil. 2012 à 16:13, Ramon Poca a écrit :

Hi there,

I've found what seems to be a bug in the camera detection in Linphonemanager.m. It uses two static #defines with the front and back device names in english. On the other hand, mediastreamer2 uses the .localizedName property to form the camera device identifier. In some languages this is  not translated, but for instance in spanish it is, so the device name does not match the english version.

As a workaround I modified LinphoneManager.m "startup()" by calling a separate new method that does a full match with iOS camera list. This is a bit ugly as the name is modified by the upper layers. Maybe mediastreamer should provide nonlocalized names for the cameras.

The camera detection code:
----------------8<-----------------------------
- (void)detectCameras {    
    /* First get real cameras */
    NSArray *devices = [AVCaptureDevice devices];
    const char *frontCamera = NULL;
    const char *backCamera = NULL;
    
    
    for (AVCaptureDevice *device in devices) {
        NSLog(@"Device name: %@", [device localizedName]);
        if ([device hasMediaType:AVMediaTypeVideo]) {
            if ([device position] == AVCaptureDevicePositionBack) {
                backCamera = [[@"AV Capture: " stringByAppendingString:
                              device.localizedName] UTF8String];
            }
            else {
                frontCamera = [[@"AV Capture: " stringByAppendingString:device.localizedName] UTF8String];
            }
        }
    }
    
    /* Match cameras to linphone, which uses localizedName as the device id */
    frontCamId = backCamId = nil;
    char **camlist = (char **) linphone_core_get_video_devices(theLinphoneCore);
    for (char *cam = *camlist; *camlist != NULL; cam = *++camlist) {
        if (frontCamera && strcmp(frontCamera, cam) == 0) {
            frontCamId = cam;
            linphone_core_set_video_device(theLinphoneCore, cam);
        }
        if (backCamera && strcmp(backCamera, cam) == 0) {
            backCamId = cam;
        }
    }
}
----------------8<-----------------------------


--
Ramon Poca

_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers


reply via email to

[Prev in Thread] Current Thread [Next in Thread]