linphone-developers
[Top][All Lists]
Advanced

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

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


From: Ramon Poca
Subject: [Linphone-developers] Possible camera detection bug in Linphone-ios
Date: Wed, 25 Jul 2012 16:13:11 +0200

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


reply via email to

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