Changeset 5454


Ignore:
Timestamp:
Oct 7, 2016 5:58:54 AM (8 years ago)
Author:
ming
Message:

Re #1941: Support for AVCaptureDeviceDiscoverySession to replace the deprecated [AVCaptureDevice devices] in iOS 10.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/darwin_dev.m

    r5406 r5454  
    294294    first_idx = qf->dev_count; 
    295295    if (NSClassFromString(@"AVCaptureSession")) { 
    296         for (AVCaptureDevice *device in [AVCaptureDevice devices]) { 
     296        NSArray<AVCaptureDevice *> *dev_list; 
     297 
     298#if TARGET_OS_IPHONE && defined(__IPHONE_10_0) 
     299        if (NSClassFromString(@"AVCaptureDeviceTypeBuiltInWideAngleCamera")) { 
     300            /* Starting in iOS 10, [AVCaptureDevice devices] is deprecated 
     301             * and replaced by AVCaptureDeviceDiscoverySession. 
     302             */ 
     303            AVCaptureDeviceDiscoverySession *dds; 
     304            NSArray<AVCaptureDeviceType> *dev_types = 
     305                @[AVCaptureDeviceTypeBuiltInWideAngleCamera, 
     306                  AVCaptureDeviceTypeBuiltInDuoCamera, 
     307                  AVCaptureDeviceTypeBuiltInTelephotoCamera]; 
     308 
     309            dds = [AVCaptureDeviceDiscoverySession 
     310                   discoverySessionWithDeviceTypes:dev_types 
     311                   mediaType:AVMediaTypeVideo 
     312                   position:AVCaptureDevicePositionUnspecified]; 
     313 
     314            dev_list = [dds devices]; 
     315        } else { 
     316            dev_list = [AVCaptureDevice devices]; 
     317        } 
     318#else 
     319        dev_list = [AVCaptureDevice devices]; 
     320#endif 
     321 
     322        for (AVCaptureDevice *device in dev_list) { 
    297323            if (![device hasMediaType:AVMediaTypeVideo] || 
    298324                qf->dev_count >= MAX_DEV_COUNT) 
Note: See TracChangeset for help on using the changeset viewer.