diff --git a/sdk/objc/components/audio/RTCAudioSessionConfiguration.h b/sdk/objc/components/audio/RTCAudioSessionConfiguration.h index 4582b80557..6c6f808a32 100644 --- a/sdk/objc/components/audio/RTCAudioSessionConfiguration.h +++ b/sdk/objc/components/audio/RTCAudioSessionConfiguration.h @@ -17,9 +17,7 @@ NS_ASSUME_NONNULL_BEGIN RTC_EXTERN const int kRTCAudioSessionPreferredNumberOfChannels; RTC_EXTERN const double kRTCAudioSessionHighPerformanceSampleRate; -RTC_EXTERN const double kRTCAudioSessionLowComplexitySampleRate; RTC_EXTERN const double kRTCAudioSessionHighPerformanceIOBufferDuration; -RTC_EXTERN const double kRTCAudioSessionLowComplexityIOBufferDuration; // Struct to hold configuration values. RTC_OBJC_EXPORT diff --git a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m index 39e9ac13ec..71b0c0cb3a 100644 --- a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m +++ b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m @@ -30,10 +30,6 @@ const int kRTCAudioSessionPreferredNumberOfChannels = 1; // 8000Hz as native sample rate. const double kRTCAudioSessionHighPerformanceSampleRate = 48000.0; -// A lower sample rate will be used for devices with only one core -// (e.g. iPhone 4). The goal is to reduce the CPU load of the application. -const double kRTCAudioSessionLowComplexitySampleRate = 16000.0; - // Use a hardware I/O buffer size (unit is in seconds) that matches the 10ms // size used by WebRTC. The exact actual size will differ between devices. // Example: using 48kHz on iPhone 6 results in a native buffer size of @@ -44,13 +40,6 @@ const double kRTCAudioSessionLowComplexitySampleRate = 16000.0; // callback sequence without bursts of callbacks back to back. const double kRTCAudioSessionHighPerformanceIOBufferDuration = 0.02; -// Use a larger buffer size on devices with only one core (e.g. iPhone 4). -// It will result in a lower CPU consumption at the cost of a larger latency. -// The size of 60ms is based on instrumentation that shows a significant -// reduction in CPU load compared with 10ms on low-end devices. -// TODO(henrika): monitor this size and determine if it should be modified. -const double kRTCAudioSessionLowComplexityIOBufferDuration = 0.06; - static RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *gWebRTCConfiguration = nil; @implementation RTC_OBJC_TYPE (RTCAudioSessionConfiguration) @@ -75,20 +64,10 @@ static RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *gWebRTCConfiguration = nil; // Specify mode for two-way voice communication (e.g. VoIP). _mode = AVAudioSessionModeVoiceChat; - // Set the session's sample rate or the hardware sample rate. - // It is essential that we use the same sample rate as stream format - // to ensure that the I/O unit does not have to do sample rate conversion. - // Set the preferred audio I/O buffer duration, in seconds. - NSUInteger processorCount = [NSProcessInfo processInfo].processorCount; // Use best sample rate and buffer duration if the CPU has more than one // core. - if (processorCount > 1 && [UIDevice deviceType] != RTCDeviceTypeIPhone4S) { - _sampleRate = kRTCAudioSessionHighPerformanceSampleRate; - _ioBufferDuration = kRTCAudioSessionHighPerformanceIOBufferDuration; - } else { - _sampleRate = kRTCAudioSessionLowComplexitySampleRate; - _ioBufferDuration = kRTCAudioSessionLowComplexityIOBufferDuration; - } + _sampleRate = kRTCAudioSessionHighPerformanceSampleRate; + _ioBufferDuration = kRTCAudioSessionHighPerformanceIOBufferDuration; // We try to use mono in both directions to save resources and format // conversions in the audio unit. Some devices does only support stereo; diff --git a/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm b/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm index 09e642bc37..3f30bb1e8a 100644 --- a/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm +++ b/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm @@ -246,9 +246,7 @@ void decompressionOutputCallback(void *decoderRef, - (void)destroyDecompressionSession { if (_decompressionSession) { #if defined(WEBRTC_IOS) - if ([UIDevice isIOS11OrLater]) { - VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession); - } + VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession); #endif VTDecompressionSessionInvalidate(_decompressionSession); CFRelease(_decompressionSession); diff --git a/sdk/objc/helpers/UIDevice+RTCDevice.h b/sdk/objc/helpers/UIDevice+RTCDevice.h index 1c5d228546..4d04f38f8c 100644 --- a/sdk/objc/helpers/UIDevice+RTCDevice.h +++ b/sdk/objc/helpers/UIDevice+RTCDevice.h @@ -10,103 +10,8 @@ #import -typedef NS_ENUM(NSInteger, RTCDeviceType) { - RTCDeviceTypeUnknown, - RTCDeviceTypeIPhone1G, - RTCDeviceTypeIPhone3G, - RTCDeviceTypeIPhone3GS, - RTCDeviceTypeIPhone4, - RTCDeviceTypeIPhone4Verizon, - RTCDeviceTypeIPhone4S, - RTCDeviceTypeIPhone5GSM, - RTCDeviceTypeIPhone5GSM_CDMA, - RTCDeviceTypeIPhone5CGSM, - RTCDeviceTypeIPhone5CGSM_CDMA, - RTCDeviceTypeIPhone5SGSM, - RTCDeviceTypeIPhone5SGSM_CDMA, - RTCDeviceTypeIPhone6Plus, - RTCDeviceTypeIPhone6, - RTCDeviceTypeIPhone6S, - RTCDeviceTypeIPhone6SPlus, - RTCDeviceTypeIPhone7, - RTCDeviceTypeIPhone7Plus, - RTCDeviceTypeIPhoneSE, - RTCDeviceTypeIPhone8, - RTCDeviceTypeIPhone8Plus, - RTCDeviceTypeIPhoneX, - RTCDeviceTypeIPhoneXS, - RTCDeviceTypeIPhoneXSMax, - RTCDeviceTypeIPhoneXR, - RTCDeviceTypeIPhone11, - RTCDeviceTypeIPhone11Pro, - RTCDeviceTypeIPhone11ProMax, - RTCDeviceTypeIPhone12Mini, - RTCDeviceTypeIPhone12, - RTCDeviceTypeIPhone12Pro, - RTCDeviceTypeIPhone12ProMax, - RTCDeviceTypeIPhoneSE2Gen, - RTCDeviceTypeIPhone13, - RTCDeviceTypeIPhone13Mini, - RTCDeviceTypeIPhone13Pro, - RTCDeviceTypeIPhone13ProMax, - - RTCDeviceTypeIPodTouch1G, - RTCDeviceTypeIPodTouch2G, - RTCDeviceTypeIPodTouch3G, - RTCDeviceTypeIPodTouch4G, - RTCDeviceTypeIPodTouch5G, - RTCDeviceTypeIPodTouch6G, - RTCDeviceTypeIPodTouch7G, - RTCDeviceTypeIPad, - RTCDeviceTypeIPad2Wifi, - RTCDeviceTypeIPad2GSM, - RTCDeviceTypeIPad2CDMA, - RTCDeviceTypeIPad2Wifi2, - RTCDeviceTypeIPadMiniWifi, - RTCDeviceTypeIPadMiniGSM, - RTCDeviceTypeIPadMiniGSM_CDMA, - RTCDeviceTypeIPad3Wifi, - RTCDeviceTypeIPad3GSM_CDMA, - RTCDeviceTypeIPad3GSM, - RTCDeviceTypeIPad4Wifi, - RTCDeviceTypeIPad4GSM, - RTCDeviceTypeIPad4GSM_CDMA, - RTCDeviceTypeIPad5, - RTCDeviceTypeIPad6, - RTCDeviceTypeIPadAirWifi, - RTCDeviceTypeIPadAirCellular, - RTCDeviceTypeIPadAirWifiCellular, - RTCDeviceTypeIPadAir2, - RTCDeviceTypeIPadMini2GWifi, - RTCDeviceTypeIPadMini2GCellular, - RTCDeviceTypeIPadMini2GWifiCellular, - RTCDeviceTypeIPadMini3, - RTCDeviceTypeIPadMini4, - RTCDeviceTypeIPadPro9Inch, - RTCDeviceTypeIPadPro12Inch, - RTCDeviceTypeIPadPro12Inch2, - RTCDeviceTypeIPadPro10Inch, - RTCDeviceTypeIPad7Gen10Inch, - RTCDeviceTypeIPadPro3Gen11Inch, - RTCDeviceTypeIPadPro3Gen12Inch, - RTCDeviceTypeIPadPro4Gen11Inch, - RTCDeviceTypeIPadPro4Gen12Inch, - RTCDeviceTypeIPadMini5Gen, - RTCDeviceTypeIPadAir3Gen, - RTCDeviceTypeIPad8, - RTCDeviceTypeIPad9, - RTCDeviceTypeIPadMini6, - RTCDeviceTypeIPadAir4Gen, - RTCDeviceTypeIPadPro5Gen11Inch, - RTCDeviceTypeIPadPro5Gen12Inch, - RTCDeviceTypeSimulatori386, - RTCDeviceTypeSimulatorx86_64, -}; - @interface UIDevice (RTCDevice) + (NSString *)machineName; -+ (RTCDeviceType)deviceType; -+ (BOOL)isIOS11OrLater; @end diff --git a/sdk/objc/helpers/UIDevice+RTCDevice.mm b/sdk/objc/helpers/UIDevice+RTCDevice.mm index 77a5d79f79..f3c21991b8 100644 --- a/sdk/objc/helpers/UIDevice+RTCDevice.mm +++ b/sdk/objc/helpers/UIDevice+RTCDevice.mm @@ -15,144 +15,6 @@ @implementation UIDevice (RTCDevice) -+ (RTCDeviceType)deviceType { - NSDictionary *machineNameToType = @{ - @"iPhone1,1" : @(RTCDeviceTypeIPhone1G), - @"iPhone1,2" : @(RTCDeviceTypeIPhone3G), - @"iPhone2,1" : @(RTCDeviceTypeIPhone3GS), - @"iPhone3,1" : @(RTCDeviceTypeIPhone4), - @"iPhone3,2" : @(RTCDeviceTypeIPhone4), - @"iPhone3,3" : @(RTCDeviceTypeIPhone4Verizon), - @"iPhone4,1" : @(RTCDeviceTypeIPhone4S), - @"iPhone5,1" : @(RTCDeviceTypeIPhone5GSM), - @"iPhone5,2" : @(RTCDeviceTypeIPhone5GSM_CDMA), - @"iPhone5,3" : @(RTCDeviceTypeIPhone5CGSM), - @"iPhone5,4" : @(RTCDeviceTypeIPhone5CGSM_CDMA), - @"iPhone6,1" : @(RTCDeviceTypeIPhone5SGSM), - @"iPhone6,2" : @(RTCDeviceTypeIPhone5SGSM_CDMA), - @"iPhone7,1" : @(RTCDeviceTypeIPhone6Plus), - @"iPhone7,2" : @(RTCDeviceTypeIPhone6), - @"iPhone8,1" : @(RTCDeviceTypeIPhone6S), - @"iPhone8,2" : @(RTCDeviceTypeIPhone6SPlus), - @"iPhone8,4" : @(RTCDeviceTypeIPhoneSE), - @"iPhone9,1" : @(RTCDeviceTypeIPhone7), - @"iPhone9,2" : @(RTCDeviceTypeIPhone7Plus), - @"iPhone9,3" : @(RTCDeviceTypeIPhone7), - @"iPhone9,4" : @(RTCDeviceTypeIPhone7Plus), - @"iPhone10,1" : @(RTCDeviceTypeIPhone8), - @"iPhone10,2" : @(RTCDeviceTypeIPhone8Plus), - @"iPhone10,3" : @(RTCDeviceTypeIPhoneX), - @"iPhone10,4" : @(RTCDeviceTypeIPhone8), - @"iPhone10,5" : @(RTCDeviceTypeIPhone8Plus), - @"iPhone10,6" : @(RTCDeviceTypeIPhoneX), - @"iPhone11,2" : @(RTCDeviceTypeIPhoneXS), - @"iPhone11,4" : @(RTCDeviceTypeIPhoneXSMax), - @"iPhone11,6" : @(RTCDeviceTypeIPhoneXSMax), - @"iPhone11,8" : @(RTCDeviceTypeIPhoneXR), - @"iPhone12,1" : @(RTCDeviceTypeIPhone11), - @"iPhone12,3" : @(RTCDeviceTypeIPhone11Pro), - @"iPhone12,5" : @(RTCDeviceTypeIPhone11ProMax), - @"iPhone12,8" : @(RTCDeviceTypeIPhoneSE2Gen), - @"iPhone13,1" : @(RTCDeviceTypeIPhone12Mini), - @"iPhone13,2" : @(RTCDeviceTypeIPhone12), - @"iPhone13,3" : @(RTCDeviceTypeIPhone12Pro), - @"iPhone13,4" : @(RTCDeviceTypeIPhone12ProMax), - @"iPhone14,5" : @(RTCDeviceTypeIPhone13), - @"iPhone14,4" : @(RTCDeviceTypeIPhone13Mini), - @"iPhone14,2" : @(RTCDeviceTypeIPhone13Pro), - @"iPhone14,3" : @(RTCDeviceTypeIPhone13ProMax), - @"iPod1,1" : @(RTCDeviceTypeIPodTouch1G), - @"iPod2,1" : @(RTCDeviceTypeIPodTouch2G), - @"iPod3,1" : @(RTCDeviceTypeIPodTouch3G), - @"iPod4,1" : @(RTCDeviceTypeIPodTouch4G), - @"iPod5,1" : @(RTCDeviceTypeIPodTouch5G), - @"iPod7,1" : @(RTCDeviceTypeIPodTouch6G), - @"iPod9,1" : @(RTCDeviceTypeIPodTouch7G), - @"iPad1,1" : @(RTCDeviceTypeIPad), - @"iPad2,1" : @(RTCDeviceTypeIPad2Wifi), - @"iPad2,2" : @(RTCDeviceTypeIPad2GSM), - @"iPad2,3" : @(RTCDeviceTypeIPad2CDMA), - @"iPad2,4" : @(RTCDeviceTypeIPad2Wifi2), - @"iPad2,5" : @(RTCDeviceTypeIPadMiniWifi), - @"iPad2,6" : @(RTCDeviceTypeIPadMiniGSM), - @"iPad2,7" : @(RTCDeviceTypeIPadMiniGSM_CDMA), - @"iPad3,1" : @(RTCDeviceTypeIPad3Wifi), - @"iPad3,2" : @(RTCDeviceTypeIPad3GSM_CDMA), - @"iPad3,3" : @(RTCDeviceTypeIPad3GSM), - @"iPad3,4" : @(RTCDeviceTypeIPad4Wifi), - @"iPad3,5" : @(RTCDeviceTypeIPad4GSM), - @"iPad3,6" : @(RTCDeviceTypeIPad4GSM_CDMA), - @"iPad4,1" : @(RTCDeviceTypeIPadAirWifi), - @"iPad4,2" : @(RTCDeviceTypeIPadAirCellular), - @"iPad4,3" : @(RTCDeviceTypeIPadAirWifiCellular), - @"iPad4,4" : @(RTCDeviceTypeIPadMini2GWifi), - @"iPad4,5" : @(RTCDeviceTypeIPadMini2GCellular), - @"iPad4,6" : @(RTCDeviceTypeIPadMini2GWifiCellular), - @"iPad4,7" : @(RTCDeviceTypeIPadMini3), - @"iPad4,8" : @(RTCDeviceTypeIPadMini3), - @"iPad4,9" : @(RTCDeviceTypeIPadMini3), - @"iPad5,1" : @(RTCDeviceTypeIPadMini4), - @"iPad5,2" : @(RTCDeviceTypeIPadMini4), - @"iPad5,3" : @(RTCDeviceTypeIPadAir2), - @"iPad5,4" : @(RTCDeviceTypeIPadAir2), - @"iPad6,3" : @(RTCDeviceTypeIPadPro9Inch), - @"iPad6,4" : @(RTCDeviceTypeIPadPro9Inch), - @"iPad6,7" : @(RTCDeviceTypeIPadPro12Inch), - @"iPad6,8" : @(RTCDeviceTypeIPadPro12Inch), - @"iPad6,11" : @(RTCDeviceTypeIPad5), - @"iPad6,12" : @(RTCDeviceTypeIPad5), - @"iPad7,1" : @(RTCDeviceTypeIPadPro12Inch2), - @"iPad7,2" : @(RTCDeviceTypeIPadPro12Inch2), - @"iPad7,3" : @(RTCDeviceTypeIPadPro10Inch), - @"iPad7,4" : @(RTCDeviceTypeIPadPro10Inch), - @"iPad7,5" : @(RTCDeviceTypeIPad6), - @"iPad7,6" : @(RTCDeviceTypeIPad6), - @"iPad7,11" : @(RTCDeviceTypeIPad7Gen10Inch), - @"iPad7,12" : @(RTCDeviceTypeIPad7Gen10Inch), - @"iPad8,1" : @(RTCDeviceTypeIPadPro3Gen11Inch), - @"iPad8,2" : @(RTCDeviceTypeIPadPro3Gen11Inch), - @"iPad8,3" : @(RTCDeviceTypeIPadPro3Gen11Inch), - @"iPad8,4" : @(RTCDeviceTypeIPadPro3Gen11Inch), - @"iPad8,5" : @(RTCDeviceTypeIPadPro3Gen12Inch), - @"iPad8,6" : @(RTCDeviceTypeIPadPro3Gen12Inch), - @"iPad8,7" : @(RTCDeviceTypeIPadPro3Gen12Inch), - @"iPad8,8" : @(RTCDeviceTypeIPadPro3Gen12Inch), - @"iPad8,9" : @(RTCDeviceTypeIPadPro4Gen11Inch), - @"iPad8,10" : @(RTCDeviceTypeIPadPro4Gen11Inch), - @"iPad8,11" : @(RTCDeviceTypeIPadPro4Gen12Inch), - @"iPad8,12" : @(RTCDeviceTypeIPadPro4Gen12Inch), - @"iPad11,1" : @(RTCDeviceTypeIPadMini5Gen), - @"iPad11,2" : @(RTCDeviceTypeIPadMini5Gen), - @"iPad11,3" : @(RTCDeviceTypeIPadAir3Gen), - @"iPad11,4" : @(RTCDeviceTypeIPadAir3Gen), - @"iPad11,6" : @(RTCDeviceTypeIPad8), - @"iPad11,7" : @(RTCDeviceTypeIPad8), - @"iPad12,1" : @(RTCDeviceTypeIPad9), - @"iPad12,2" : @(RTCDeviceTypeIPad9), - @"iPad13,1" : @(RTCDeviceTypeIPadAir4Gen), - @"iPad13,2" : @(RTCDeviceTypeIPadAir4Gen), - @"iPad13,4" : @(RTCDeviceTypeIPadPro5Gen11Inch), - @"iPad13,5" : @(RTCDeviceTypeIPadPro5Gen11Inch), - @"iPad13,6" : @(RTCDeviceTypeIPadPro5Gen11Inch), - @"iPad13,7" : @(RTCDeviceTypeIPadPro5Gen11Inch), - @"iPad13,8" : @(RTCDeviceTypeIPadPro5Gen12Inch), - @"iPad13,9" : @(RTCDeviceTypeIPadPro5Gen12Inch), - @"iPad13,10" : @(RTCDeviceTypeIPadPro5Gen12Inch), - @"iPad13,11" : @(RTCDeviceTypeIPadPro5Gen12Inch), - @"iPad14,1" : @(RTCDeviceTypeIPadMini6), - @"iPad14,2" : @(RTCDeviceTypeIPadMini6), - @"i386" : @(RTCDeviceTypeSimulatori386), - @"x86_64" : @(RTCDeviceTypeSimulatorx86_64), - }; - - RTCDeviceType deviceType = RTCDeviceTypeUnknown; - NSNumber *typeNumber = machineNameToType[[self machineName]]; - if (typeNumber) { - deviceType = static_cast(typeNumber.integerValue); - } - return deviceType; -} - + (NSString *)machineName { struct utsname systemInfo; uname(&systemInfo); @@ -160,12 +22,4 @@ encoding:NSUTF8StringEncoding]; } -+ (double)currentDeviceSystemVersion { - return [self currentDevice].systemVersion.doubleValue; -} - -+ (BOOL)isIOS11OrLater { - return [self currentDeviceSystemVersion] >= 11.0; -} - @end