diff --git a/examples/objc/AppRTCMobile/ARDAppClient.m b/examples/objc/AppRTCMobile/ARDAppClient.m index 4420972598..e60d9a6e75 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient.m +++ b/examples/objc/AppRTCMobile/ARDAppClient.m @@ -84,7 +84,8 @@ static int const kKbpsMultiplier = 1000; repeats:(BOOL)repeats timerHandler:(void (^)(void))timerHandler { NSParameterAssert(timerHandler); - if (self = [super init]) { + self = [super init]; + if (self) { _timerHandler = timerHandler; _timer = [NSTimer scheduledTimerWithTimeInterval:interval target:self @@ -140,7 +141,8 @@ static int const kKbpsMultiplier = 1000; } - (instancetype)initWithDelegate:(id)delegate { - if (self = [super init]) { + self = [super init]; + if (self) { _roomServerClient = [[ARDAppEngineClient alloc] init]; _delegate = delegate; NSURL *turnRequestURL = [NSURL URLWithString:kARDIceServerRequestUrl]; @@ -160,7 +162,8 @@ static int const kKbpsMultiplier = 1000; NSParameterAssert(rsClient); NSParameterAssert(channel); NSParameterAssert(turnClient); - if (self = [super init]) { + self = [super init]; + if (self) { _roomServerClient = rsClient; _channel = channel; _turnClient = turnClient; diff --git a/examples/objc/AppRTCMobile/ARDCaptureController.m b/examples/objc/AppRTCMobile/ARDCaptureController.m index 26cce9fdaa..7c99ce2a27 100644 --- a/examples/objc/AppRTCMobile/ARDCaptureController.m +++ b/examples/objc/AppRTCMobile/ARDCaptureController.m @@ -24,12 +24,12 @@ const Float64 kFramerateLimit = 30.0; - (instancetype)initWithCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer settings:(ARDSettingsModel *)settings { - if (self = [super init]) { + self = [super init]; + if (self) { _capturer = capturer; _settings = settings; _usingFrontCamera = YES; } - return self; } diff --git a/examples/objc/AppRTCMobile/ARDSignalingMessage.m b/examples/objc/AppRTCMobile/ARDSignalingMessage.m index 049c0f5b0a..1cea92f956 100644 --- a/examples/objc/AppRTCMobile/ARDSignalingMessage.m +++ b/examples/objc/AppRTCMobile/ARDSignalingMessage.m @@ -24,7 +24,8 @@ static NSString * const kARDTypeValueRemoveCandidates = @"remove-candidates"; @synthesize type = _type; - (instancetype)initWithType:(ARDSignalingMessageType)type { - if (self = [super init]) { + self = [super init]; + if (self) { _type = type; } return self; @@ -79,7 +80,8 @@ static NSString * const kARDTypeValueRemoveCandidates = @"remove-candidates"; @synthesize candidate = _candidate; - (instancetype)initWithCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)candidate { - if (self = [super initWithType:kARDSignalingMessageTypeCandidate]) { + self = [super initWithType:kARDSignalingMessageTypeCandidate]; + if (self) { _candidate = candidate; } return self; @@ -97,7 +99,8 @@ static NSString * const kARDTypeValueRemoveCandidates = @"remove-candidates"; - (instancetype)initWithRemovedCandidates:(NSArray *)candidates { NSParameterAssert(candidates.count); - if (self = [super initWithType:kARDSignalingMessageTypeCandidateRemoval]) { + self = [super initWithType:kARDSignalingMessageTypeCandidateRemoval]; + if (self) { _candidates = candidates; } return self; @@ -130,7 +133,8 @@ static NSString * const kARDTypeValueRemoveCandidates = @"remove-candidates"; NO, @"Unexpected type: %@", [RTC_OBJC_TYPE(RTCSessionDescription) stringForType:sdpType]); break; } - if (self = [super initWithType:messageType]) { + self = [super initWithType:messageType]; + if (self) { _sessionDescription = description; } return self; diff --git a/examples/objc/AppRTCMobile/ARDTURNClient.m b/examples/objc/AppRTCMobile/ARDTURNClient.m index 069231cd7e..641e9d5bcf 100644 --- a/examples/objc/AppRTCMobile/ARDTURNClient.m +++ b/examples/objc/AppRTCMobile/ARDTURNClient.m @@ -24,7 +24,8 @@ static NSInteger kARDTURNClientErrorBadResponse = -1; - (instancetype)initWithURL:(NSURL *)url { NSParameterAssert([url absoluteString].length); - if (self = [super init]) { + self = [super init]; + if (self) { _url = url; } return self; diff --git a/examples/objc/AppRTCMobile/ARDWebSocketChannel.m b/examples/objc/AppRTCMobile/ARDWebSocketChannel.m index bbb0bf87f8..2bf081bbca 100644 --- a/examples/objc/AppRTCMobile/ARDWebSocketChannel.m +++ b/examples/objc/AppRTCMobile/ARDWebSocketChannel.m @@ -38,7 +38,8 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg"; - (instancetype)initWithURL:(NSURL *)url restURL:(NSURL *)restURL delegate:(id)delegate { - if (self = [super init]) { + self = [super init]; + if (self) { _url = url; _restURL = restURL; _delegate = delegate; diff --git a/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.m b/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.m index 2ddde6dd59..358a73f669 100644 --- a/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.m +++ b/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.m @@ -22,7 +22,8 @@ @synthesize fileCapturer = _fileCapturer; - (instancetype)initWithCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)capturer { - if (self = [super init]) { + self = [super init]; + if (self) { _fileCapturer = capturer; } return self; diff --git a/examples/objc/AppRTCMobile/ios/ARDMainView.m b/examples/objc/AppRTCMobile/ios/ARDMainView.m index d9521060eb..cd374a644d 100644 --- a/examples/objc/AppRTCMobile/ios/ARDMainView.m +++ b/examples/objc/AppRTCMobile/ios/ARDMainView.m @@ -26,7 +26,8 @@ static CGFloat const kCallControlMargin = 8; } - (instancetype)initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) { + self = [super initWithFrame:frame]; + if (self) { _roomText = [[UITextField alloc] initWithFrame:CGRectZero]; _roomText.borderStyle = UITextBorderStyleNone; _roomText.font = [UIFont systemFontOfSize:12]; @@ -82,7 +83,8 @@ static CGFloat const kCallControlMargin = 8; @synthesize isAudioLoopPlaying = _isAudioLoopPlaying; - (instancetype)initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) { + self = [super initWithFrame:frame]; + if (self) { _roomText = [[ARDRoomTextField alloc] initWithFrame:CGRectZero]; [self addSubview:_roomText]; diff --git a/examples/objc/AppRTCMobile/ios/ARDStatsView.m b/examples/objc/AppRTCMobile/ios/ARDStatsView.m index 867ba5b09e..353b1f0f81 100644 --- a/examples/objc/AppRTCMobile/ios/ARDStatsView.m +++ b/examples/objc/AppRTCMobile/ios/ARDStatsView.m @@ -20,7 +20,8 @@ } - (instancetype)initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) { + self = [super initWithFrame:frame]; + if (self) { _statsLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _statsLabel.numberOfLines = 0; _statsLabel.font = [UIFont fontWithName:@"Roboto" size:12]; diff --git a/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m b/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m index 437aea8d56..2364ee199d 100644 --- a/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m +++ b/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m @@ -39,8 +39,8 @@ static CGFloat const kStatusBarHeight = 20; @synthesize delegate = _delegate; - (instancetype)initWithFrame:(CGRect)frame { - if (self = [super initWithFrame:frame]) { - + self = [super initWithFrame:frame]; + if (self) { _remoteVideoView = [[RTC_OBJC_TYPE(RTCMTLVideoView) alloc] initWithFrame:CGRectZero]; [self addSubview:_remoteVideoView]; diff --git a/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m b/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m index a82d90b290..b0923921cf 100644 --- a/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m +++ b/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m @@ -45,7 +45,8 @@ - (instancetype)initForRoom:(NSString *)room isLoopback:(BOOL)isLoopback delegate:(id)delegate { - if (self = [super init]) { + self = [super init]; + if (self) { ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init]; _delegate = delegate; diff --git a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.m b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.m index 1c276d965f..a024fcd9b3 100644 --- a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.m +++ b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.m @@ -26,7 +26,8 @@ @synthesize capturer = _capturer; - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { _callbackLogger = [[RTC_OBJC_TYPE(RTCCallbackLogger) alloc] init]; os_log_t rtc_os_log = os_log_create("com.google.AppRTCMobile", "RTCLog"); [_callbackLogger start:^(NSString *logMessage) { diff --git a/examples/objc/AppRTCMobile/mac/APPRTCViewController.m b/examples/objc/AppRTCMobile/mac/APPRTCViewController.m index 982fa56b43..adfd02832d 100644 --- a/examples/objc/AppRTCMobile/mac/APPRTCViewController.m +++ b/examples/objc/AppRTCMobile/mac/APPRTCViewController.m @@ -72,7 +72,8 @@ static NSUInteger const kBottomViewHeight = 200; #pragma mark - Private - (instancetype)initWithFrame:(NSRect)frame { - if (self = [super initWithFrame:frame]) { + self = [super initWithFrame:frame]; + if (self) { [self setupViews]; } return self; diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm index 2dad8b356b..fe44694d3a 100644 --- a/modules/desktop_capture/mac/screen_capturer_sck.mm +++ b/modules/desktop_capture/mac/screen_capturer_sck.mm @@ -370,7 +370,8 @@ std::unique_ptr CreateScreenCapturerSck(const DesktopCaptureOpt } - (instancetype)initWithCapturer:(webrtc::ScreenCapturerSck*)capturer { - if (self = [super init]) { + self = [super init]; + if (self) { _capturer = capturer; } return self; diff --git a/sdk/objc/api/RTCVideoRendererAdapter.mm b/sdk/objc/api/RTCVideoRendererAdapter.mm index ef02f72f60..0df73749f1 100644 --- a/sdk/objc/api/RTCVideoRendererAdapter.mm +++ b/sdk/objc/api/RTCVideoRendererAdapter.mm @@ -53,7 +53,8 @@ class VideoRendererAdapter - (instancetype)initWithNativeRenderer:(id)videoRenderer { NSParameterAssert(videoRenderer); - if (self = [super init]) { + self = [super init]; + if (self) { _videoRenderer = videoRenderer; _adapter.reset(new webrtc::VideoRendererAdapter(self)); } diff --git a/sdk/objc/api/peerconnection/RTCAudioSource.mm b/sdk/objc/api/peerconnection/RTCAudioSource.mm index 1541045099..1dba1e3381 100644 --- a/sdk/objc/api/peerconnection/RTCAudioSource.mm +++ b/sdk/objc/api/peerconnection/RTCAudioSource.mm @@ -24,9 +24,10 @@ RTC_DCHECK(factory); RTC_DCHECK(nativeAudioSource); - if (self = [super initWithFactory:factory - nativeMediaSource:nativeAudioSource - type:RTCMediaSourceTypeAudio]) { + self = [super initWithFactory:factory + nativeMediaSource:nativeAudioSource + type:RTCMediaSourceTypeAudio]; + if (self) { _nativeAudioSource = nativeAudioSource; } return self; diff --git a/sdk/objc/api/peerconnection/RTCCertificate.mm b/sdk/objc/api/peerconnection/RTCCertificate.mm index e5c33e407c..f6817a6568 100644 --- a/sdk/objc/api/peerconnection/RTCCertificate.mm +++ b/sdk/objc/api/peerconnection/RTCCertificate.mm @@ -28,7 +28,8 @@ } - (instancetype)initWithPrivateKey:(NSString *)private_key certificate:(NSString *)certificate { - if (self = [super init]) { + self = [super init]; + if (self) { _private_key = [private_key copy]; _certificate = [certificate copy]; } diff --git a/sdk/objc/api/peerconnection/RTCConfiguration.mm b/sdk/objc/api/peerconnection/RTCConfiguration.mm index 86ecbabf8d..7635ac0685 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration.mm +++ b/sdk/objc/api/peerconnection/RTCConfiguration.mm @@ -72,7 +72,8 @@ - (instancetype)initWithNativeConfiguration: (const webrtc::PeerConnectionInterface::RTCConfiguration &)config { - if (self = [super init]) { + self = [super init]; + if (self) { _enableDscp = config.dscp(); NSMutableArray *iceServers = [NSMutableArray array]; for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) { diff --git a/sdk/objc/api/peerconnection/RTCCryptoOptions.mm b/sdk/objc/api/peerconnection/RTCCryptoOptions.mm index fbaa1de58d..3789f7af7b 100644 --- a/sdk/objc/api/peerconnection/RTCCryptoOptions.mm +++ b/sdk/objc/api/peerconnection/RTCCryptoOptions.mm @@ -21,7 +21,8 @@ srtpEnableAes128Sha1_32CryptoCipher:(BOOL)srtpEnableAes128Sha1_32CryptoCipher srtpEnableEncryptedRtpHeaderExtensions:(BOOL)srtpEnableEncryptedRtpHeaderExtensions sframeRequireFrameEncryption:(BOOL)sframeRequireFrameEncryption { - if (self = [super init]) { + self = [super init]; + if (self) { _srtpEnableGcmCryptoSuites = srtpEnableGcmCryptoSuites; _srtpEnableAes128Sha1_32CryptoCipher = srtpEnableAes128Sha1_32CryptoCipher; _srtpEnableEncryptedRtpHeaderExtensions = srtpEnableEncryptedRtpHeaderExtensions; diff --git a/sdk/objc/api/peerconnection/RTCDataChannel.mm b/sdk/objc/api/peerconnection/RTCDataChannel.mm index 4a79cefdb4..40a4d8e986 100644 --- a/sdk/objc/api/peerconnection/RTCDataChannel.mm +++ b/sdk/objc/api/peerconnection/RTCDataChannel.mm @@ -50,7 +50,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { - (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary { NSParameterAssert(data); - if (self = [super init]) { + self = [super init]; + if (self) { rtc::CopyOnWriteBuffer buffer( reinterpret_cast(data.bytes), data.length); _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); @@ -70,7 +71,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { #pragma mark - Private - (instancetype)initWithNativeBuffer:(const webrtc::DataBuffer&)nativeBuffer { - if (self = [super init]) { + self = [super init]; + if (self) { _dataBuffer.reset(new webrtc::DataBuffer(nativeBuffer)); } return self; @@ -167,7 +169,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { nativeDataChannel: (rtc::scoped_refptr)nativeDataChannel { NSParameterAssert(nativeDataChannel); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeDataChannel = nativeDataChannel; _observer.reset(new webrtc::DataChannelDelegateAdapter(self)); diff --git a/sdk/objc/api/peerconnection/RTCDtmfSender.mm b/sdk/objc/api/peerconnection/RTCDtmfSender.mm index ee3b79cd37..2cec54aef5 100644 --- a/sdk/objc/api/peerconnection/RTCDtmfSender.mm +++ b/sdk/objc/api/peerconnection/RTCDtmfSender.mm @@ -64,7 +64,8 @@ - (instancetype)initWithNativeDtmfSender: (rtc::scoped_refptr)nativeDtmfSender { NSParameterAssert(nativeDtmfSender); - if (self = [super init]) { + self = [super init]; + if (self) { _nativeDtmfSender = nativeDtmfSender; RTCLogInfo( @"RTC_OBJC_TYPE(RTCDtmfSender)(%p): created DTMF sender: %@", self, self.description); diff --git a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm index c8936d3ad5..43fb1b1167 100644 --- a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm +++ b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm @@ -73,7 +73,8 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { } - (instancetype)initWithNativeEncodedImage:(const webrtc::EncodedImage &)encodedImage { - if (self = [super init]) { + self = [super init]; + if (self) { // A reference to the encodedData must be stored so that it's kept alive as long // self.buffer references its underlying data. self.encodedData = encodedImage.GetEncodedData(); diff --git a/sdk/objc/api/peerconnection/RTCFileLogger.mm b/sdk/objc/api/peerconnection/RTCFileLogger.mm index 9562245611..ee61cda943 100644 --- a/sdk/objc/api/peerconnection/RTCFileLogger.mm +++ b/sdk/objc/api/peerconnection/RTCFileLogger.mm @@ -54,7 +54,8 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; rotationType:(RTCFileLoggerRotationType)rotationType { NSParameterAssert(dirPath.length); NSParameterAssert(maxFileSize); - if (self = [super init]) { + self = [super init]; + if (self) { BOOL isDir = NO; NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:dirPath isDirectory:&isDir]) { diff --git a/sdk/objc/api/peerconnection/RTCIceCandidate.mm b/sdk/objc/api/peerconnection/RTCIceCandidate.mm index 48385ef5b4..131c31993c 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidate.mm +++ b/sdk/objc/api/peerconnection/RTCIceCandidate.mm @@ -26,7 +26,8 @@ sdpMLineIndex:(int)sdpMLineIndex sdpMid:(NSString *)sdpMid { NSParameterAssert(sdp.length); - if (self = [super init]) { + self = [super init]; + if (self) { _sdpMid = [sdpMid copy]; _sdpMLineIndex = sdpMLineIndex; _sdp = [sdp copy]; diff --git a/sdk/objc/api/peerconnection/RTCIceServer.mm b/sdk/objc/api/peerconnection/RTCIceServer.mm index 19a0a7e9e8..d4b63306b6 100644 --- a/sdk/objc/api/peerconnection/RTCIceServer.mm +++ b/sdk/objc/api/peerconnection/RTCIceServer.mm @@ -84,7 +84,8 @@ tlsAlpnProtocols:(NSArray *)tlsAlpnProtocols tlsEllipticCurves:(NSArray *)tlsEllipticCurves { NSParameterAssert(urlStrings.count); - if (self = [super init]) { + self = [super init]; + if (self) { _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES]; _username = [username copy]; _credential = [credential copy]; diff --git a/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm b/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm index bd7a1ad9c9..4b5c272b19 100644 --- a/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm +++ b/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm @@ -33,7 +33,8 @@ #pragma mark - Private - (instancetype)initWithNativeReport:(const webrtc::StatsReport &)nativeReport { - if (self = [super init]) { + self = [super init]; + if (self) { _timestamp = nativeReport.timestamp(); _type = [NSString stringForStdString:nativeReport.TypeToString()]; _reportId = [NSString stringForStdString: diff --git a/sdk/objc/api/peerconnection/RTCMediaConstraints.mm b/sdk/objc/api/peerconnection/RTCMediaConstraints.mm index 0f46e4b8fe..ac5fb64171 100644 --- a/sdk/objc/api/peerconnection/RTCMediaConstraints.mm +++ b/sdk/objc/api/peerconnection/RTCMediaConstraints.mm @@ -37,7 +37,8 @@ NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kVa (NSDictionary *)mandatory optionalConstraints: (NSDictionary *)optional { - if (self = [super init]) { + self = [super init]; + if (self) { _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory copyItems:YES]; _optional = [[NSDictionary alloc] initWithDictionary:optional diff --git a/sdk/objc/api/peerconnection/RTCMediaSource.mm b/sdk/objc/api/peerconnection/RTCMediaSource.mm index 61472a782a..5a26e31669 100644 --- a/sdk/objc/api/peerconnection/RTCMediaSource.mm +++ b/sdk/objc/api/peerconnection/RTCMediaSource.mm @@ -24,7 +24,8 @@ type:(RTCMediaSourceType)type { RTC_DCHECK(factory); RTC_DCHECK(nativeMediaSource); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeMediaSource = nativeMediaSource; _type = type; diff --git a/sdk/objc/api/peerconnection/RTCMediaStream.mm b/sdk/objc/api/peerconnection/RTCMediaStream.mm index 0018dd6945..4a99bd5efd 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStream.mm +++ b/sdk/objc/api/peerconnection/RTCMediaStream.mm @@ -120,7 +120,8 @@ nativeMediaStream: (rtc::scoped_refptr)nativeMediaStream { NSParameterAssert(nativeMediaStream); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _signalingThread = factory.signalingThread; diff --git a/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm b/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm index f1e128ca60..60deceea39 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm +++ b/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm @@ -81,7 +81,8 @@ NSString * const kRTCMediaStreamTrackKindVideo = type:(RTCMediaStreamTrackType)type { NSParameterAssert(nativeTrack); NSParameterAssert(factory); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeTrack = nativeTrack; _type = type; diff --git a/sdk/objc/api/peerconnection/RTCMetricsSampleInfo.mm b/sdk/objc/api/peerconnection/RTCMetricsSampleInfo.mm index e4be94e90a..ea01350122 100644 --- a/sdk/objc/api/peerconnection/RTCMetricsSampleInfo.mm +++ b/sdk/objc/api/peerconnection/RTCMetricsSampleInfo.mm @@ -24,7 +24,8 @@ - (instancetype)initWithNativeSampleInfo: (const webrtc::metrics::SampleInfo &)info { - if (self = [super init]) { + self = [super init]; + if (self) { _name = [NSString stringForStdString:info.name]; _min = info.min; _max = info.max; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index e55c8a4a3e..62e640e2ec 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -365,7 +365,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( if (!config) { return nil; } - if (self = [super init]) { + self = [super init]; + if (self) { _observer.reset(new webrtc::PeerConnectionDelegateAdapter(self)); _nativeConstraints = constraints.nativeConstraints; CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(), config.get()); diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index eb03d68468..3d8ff8645e 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -119,7 +119,8 @@ } - (instancetype)initNative { - if (self = [super init]) { + self = [super init]; + if (self) { _networkThread = rtc::Thread::CreateWithSocketServer(); _networkThread->SetName("network_thread", _networkThread.get()); BOOL result = _networkThread->Start(); diff --git a/sdk/objc/api/peerconnection/RTCRtcpParameters.mm b/sdk/objc/api/peerconnection/RTCRtcpParameters.mm index e92ee4b3e7..058600b340 100644 --- a/sdk/objc/api/peerconnection/RTCRtcpParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtcpParameters.mm @@ -23,7 +23,8 @@ } - (instancetype)initWithNativeParameters:(const webrtc::RtcpParameters &)nativeParameters { - if (self = [super init]) { + self = [super init]; + if (self) { _cname = [NSString stringForStdString:nativeParameters.cname]; _isReducedSize = nativeParameters.reduced_size; } diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm index 85537a91ad..b332181e8f 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm @@ -28,7 +28,8 @@ - (instancetype)initWithNativeRtpCapabilities: (const webrtc::RtpCapabilities &)nativeRtpCapabilities { - if (self = [super init]) { + self = [super init]; + if (self) { NSMutableArray *codecs = [[NSMutableArray alloc] init]; for (const auto &codec : nativeRtpCapabilities.codecs) { [codecs addObject:[[RTC_OBJC_TYPE(RTCRtpCodecCapability) alloc] diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 2dc1e5dc4b..9c38bb7992 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -33,7 +33,8 @@ - (instancetype)initWithNativeRtpCodecCapability: (const webrtc::RtpCodecCapability &)nativeRtpCodecCapability { - if (self = [super init]) { + self = [super init]; + if (self) { if (nativeRtpCodecCapability.preferred_payload_type) { _preferredPayloadType = [NSNumber numberWithInt:*nativeRtpCodecCapability.preferred_payload_type]; diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm index 6201e57b93..e273219401 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm @@ -49,7 +49,8 @@ const NSString * const kRTCH264CodecName = @(cricket::kH264CodecName); - (instancetype)initWithNativeParameters: (const webrtc::RtpCodecParameters &)nativeParameters { - if (self = [super init]) { + self = [super init]; + if (self) { _payloadType = nativeParameters.payload_type; _name = [NSString stringForStdString:nativeParameters.name]; switch (nativeParameters.kind) { diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm index d6087dafb0..8bb2f438c2 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm @@ -33,7 +33,8 @@ - (instancetype)initWithNativeParameters: (const webrtc::RtpEncodingParameters &)nativeParameters { - if (self = [super init]) { + self = [super init]; + if (self) { if (!nativeParameters.rid.empty()) { _rid = [NSString stringForStdString:nativeParameters.rid]; } diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm index 68093e92ea..0cbdb787ee 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm @@ -24,7 +24,8 @@ } - (instancetype)initWithNativeParameters:(const webrtc::RtpExtension &)nativeParameters { - if (self = [super init]) { + self = [super init]; + if (self) { _uri = [NSString stringForStdString:nativeParameters.uri]; _id = nativeParameters.id; _encrypted = nativeParameters.encrypt; diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm index c9af744a92..c5cbda152e 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm @@ -25,7 +25,8 @@ - (instancetype)initWithNativeRtpHeaderExtensionCapability: (const webrtc::RtpHeaderExtensionCapability &)nativeRtpHeaderExtensionCapability { - if (self = [super init]) { + self = [super init]; + if (self) { _uri = [NSString stringForStdString:nativeRtpHeaderExtensionCapability.uri]; if (nativeRtpHeaderExtensionCapability.preferred_id) { _preferredId = [NSNumber numberWithInt:*nativeRtpHeaderExtensionCapability.preferred_id]; diff --git a/sdk/objc/api/peerconnection/RTCRtpParameters.mm b/sdk/objc/api/peerconnection/RTCRtpParameters.mm index 2baf0ecd80..d725f6a2a9 100644 --- a/sdk/objc/api/peerconnection/RTCRtpParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpParameters.mm @@ -32,7 +32,8 @@ - (instancetype)initWithNativeParameters: (const webrtc::RtpParameters &)nativeParameters { - if (self = [super init]) { + self = [super init]; + if (self) { _transactionId = [NSString stringForStdString:nativeParameters.transaction_id]; _rtcp = [[RTC_OBJC_TYPE(RTCRtcpParameters) alloc] initWithNativeParameters:nativeParameters.rtcp]; diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver.mm b/sdk/objc/api/peerconnection/RTCRtpReceiver.mm index d54efc9d02..02afaed7ba 100644 --- a/sdk/objc/api/peerconnection/RTCRtpReceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpReceiver.mm @@ -117,7 +117,8 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( - (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory nativeRtpReceiver: (rtc::scoped_refptr)nativeRtpReceiver { - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeRtpReceiver = nativeRtpReceiver; RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpReceiver)(%p): created receiver: %@", self, self.description); diff --git a/sdk/objc/api/peerconnection/RTCRtpSender.mm b/sdk/objc/api/peerconnection/RTCRtpSender.mm index 4fadb30f49..3d5702066a 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSender.mm +++ b/sdk/objc/api/peerconnection/RTCRtpSender.mm @@ -113,7 +113,8 @@ nativeRtpSender:(rtc::scoped_refptr)nativeRtpSender { NSParameterAssert(factory); NSParameterAssert(nativeRtpSender); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeRtpSender = nativeRtpSender; if (_nativeRtpSender->media_type() == cricket::MEDIA_TYPE_AUDIO) { diff --git a/sdk/objc/api/peerconnection/RTCRtpSource.mm b/sdk/objc/api/peerconnection/RTCRtpSource.mm index aa5d6c2f4b..5f7a67854e 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSource.mm +++ b/sdk/objc/api/peerconnection/RTCRtpSource.mm @@ -65,7 +65,8 @@ } - (instancetype)initWithNativeRtpSource:(const webrtc::RtpSource &)nativeRtpSource { - if (self = [super init]) { + self = [super init]; + if (self) { _nativeRtpSource = nativeRtpSource; } return self; diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index a7f28188e4..bde4d08b0f 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -29,7 +29,8 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; @synthesize sendEncodings = _sendEncodings; - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { _direction = RTCRtpTransceiverDirectionSendRecv; } return self; @@ -166,7 +167,8 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; (rtc::scoped_refptr)nativeRtpTransceiver { NSParameterAssert(factory); NSParameterAssert(nativeRtpTransceiver); - if (self = [super init]) { + self = [super init]; + if (self) { _factory = factory; _nativeRtpTransceiver = nativeRtpTransceiver; _sender = [[RTC_OBJC_TYPE(RTCRtpSender) alloc] initWithFactory:_factory diff --git a/sdk/objc/api/peerconnection/RTCSessionDescription.mm b/sdk/objc/api/peerconnection/RTCSessionDescription.mm index 539c90b14c..d173f22527 100644 --- a/sdk/objc/api/peerconnection/RTCSessionDescription.mm +++ b/sdk/objc/api/peerconnection/RTCSessionDescription.mm @@ -31,7 +31,8 @@ } - (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp { - if (self = [super init]) { + self = [super init]; + if (self) { _type = type; _sdp = [sdp copy]; } diff --git a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm index eaf2097cce..2622de8074 100644 --- a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm +++ b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm @@ -114,7 +114,8 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { @synthesize values = _values; - (instancetype)initWithStatistics:(const webrtc::RTCStats &)statistics { - if (self = [super init]) { + self = [super init]; + if (self) { _id = [NSString stringForStdString:statistics.id()]; _timestamp_us = statistics.timestamp().us(); _type = [NSString stringWithCString:statistics.type() encoding:NSUTF8StringEncoding]; @@ -161,7 +162,8 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { @implementation RTC_OBJC_TYPE (RTCStatisticsReport) (Private) - (instancetype)initWithReport : (const webrtc::RTCStatsReport &)report { - if (self = [super init]) { + self = [super init]; + if (self) { _timestamp_us = report.timestamp().us(); NSMutableDictionary *statisticsById = diff --git a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm index dec3a61090..fb93948153 100644 --- a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm +++ b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm @@ -16,7 +16,8 @@ (Private) - (instancetype)initWithNativeVideoCodec : (const webrtc::VideoCodec *)videoCodec { - if (self = [super init]) { + self = [super init]; + if (self) { if (videoCodec) { const char *codecName = CodecTypeToPayloadString(videoCodec->codecType); self.name = [NSString stringWithUTF8String:codecName]; @@ -31,7 +32,6 @@ self.mode = (RTCVideoCodecMode)videoCodec->mode; } } - return self; } diff --git a/sdk/objc/api/peerconnection/RTCVideoSource.mm b/sdk/objc/api/peerconnection/RTCVideoSource.mm index 486ca93771..de718fb570 100644 --- a/sdk/objc/api/peerconnection/RTCVideoSource.mm +++ b/sdk/objc/api/peerconnection/RTCVideoSource.mm @@ -33,9 +33,10 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( (rtc::scoped_refptr)nativeVideoSource { RTC_DCHECK(factory); RTC_DCHECK(nativeVideoSource); - if (self = [super initWithFactory:factory - nativeMediaSource:nativeVideoSource - type:RTCMediaSourceTypeVideo]) { + self = [super initWithFactory:factory + nativeMediaSource:nativeVideoSource + type:RTCMediaSourceTypeVideo]; + if (self) { _nativeVideoSource = nativeVideoSource; } return self; diff --git a/sdk/objc/api/peerconnection/RTCVideoTrack.mm b/sdk/objc/api/peerconnection/RTCVideoTrack.mm index d3296f6279..8d9f86db59 100644 --- a/sdk/objc/api/peerconnection/RTCVideoTrack.mm +++ b/sdk/objc/api/peerconnection/RTCVideoTrack.mm @@ -45,7 +45,8 @@ NSParameterAssert(factory); NSParameterAssert(nativeMediaTrack); NSParameterAssert(type == RTCMediaStreamTrackTypeVideo); - if (self = [super initWithFactory:factory nativeTrack:nativeMediaTrack type:type]) { + self = [super initWithFactory:factory nativeTrack:nativeMediaTrack type:type]; + if (self) { _adapters = [NSMutableArray array]; _workerThread = factory.workerThread; } diff --git a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm index 7aafd98f43..bbf2708ac7 100644 --- a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm +++ b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm @@ -20,10 +20,10 @@ @implementation RTC_OBJC_TYPE (RTCI420Buffer) - (instancetype)initWithWidth:(int)width height:(int)height { - if (self = [super init]) { + self = [super init]; + if (self) { _i420Buffer = webrtc::I420Buffer::Create(width, height); } - return self; } @@ -32,7 +32,8 @@ dataY:(const uint8_t *)dataY dataU:(const uint8_t *)dataU dataV:(const uint8_t *)dataV { - if (self = [super init]) { + self = [super init]; + if (self) { _i420Buffer = webrtc::I420Buffer::Copy( width, height, dataY, width, dataU, (width + 1) / 2, dataV, (width + 1) / 2); } @@ -44,18 +45,18 @@ strideY:(int)strideY strideU:(int)strideU strideV:(int)strideV { - if (self = [super init]) { + self = [super init]; + if (self) { _i420Buffer = webrtc::I420Buffer::Create(width, height, strideY, strideU, strideV); } - return self; } - (instancetype)initWithFrameBuffer:(rtc::scoped_refptr)i420Buffer { - if (self = [super init]) { + self = [super init]; + if (self) { _i420Buffer = i420Buffer; } - return self; } diff --git a/sdk/objc/base/RTCVideoCapturer.m b/sdk/objc/base/RTCVideoCapturer.m index ca31a731f0..78db367df3 100644 --- a/sdk/objc/base/RTCVideoCapturer.m +++ b/sdk/objc/base/RTCVideoCapturer.m @@ -15,7 +15,8 @@ @synthesize delegate = _delegate; - (instancetype)initWithDelegate:(id)delegate { - if (self = [super init]) { + self = [super init]; + if (self) { _delegate = delegate; } return self; diff --git a/sdk/objc/base/RTCVideoCodecInfo.m b/sdk/objc/base/RTCVideoCodecInfo.m index ce26ae1de3..8effa298d2 100644 --- a/sdk/objc/base/RTCVideoCodecInfo.m +++ b/sdk/objc/base/RTCVideoCodecInfo.m @@ -21,7 +21,8 @@ - (instancetype)initWithName:(NSString *)name parameters:(nullable NSDictionary *)parameters { - if (self = [super init]) { + self = [super init]; + if (self) { _name = name; _parameters = (parameters ? parameters : @{}); } diff --git a/sdk/objc/base/RTCVideoEncoderQpThresholds.m b/sdk/objc/base/RTCVideoEncoderQpThresholds.m index fb7012f44f..1077cd73cd 100644 --- a/sdk/objc/base/RTCVideoEncoderQpThresholds.m +++ b/sdk/objc/base/RTCVideoEncoderQpThresholds.m @@ -16,7 +16,8 @@ @synthesize high = _high; - (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high { - if (self = [super init]) { + self = [super init]; + if (self) { _low = low; _high = high; } diff --git a/sdk/objc/base/RTCVideoFrame.mm b/sdk/objc/base/RTCVideoFrame.mm index e162238d73..a5d23bb4b8 100644 --- a/sdk/objc/base/RTCVideoFrame.mm +++ b/sdk/objc/base/RTCVideoFrame.mm @@ -66,12 +66,12 @@ - (instancetype)initWithBuffer:(id)buffer rotation:(RTCVideoRotation)rotation timeStampNs:(int64_t)timeStampNs { - if (self = [super init]) { + self = [super init]; + if (self) { _buffer = buffer; _rotation = rotation; _timeStampNs = timeStampNs; } - return self; } diff --git a/sdk/objc/components/audio/RTCAudioSession.mm b/sdk/objc/components/audio/RTCAudioSession.mm index 641d2ed8c7..0ef64a7dcb 100644 --- a/sdk/objc/components/audio/RTCAudioSession.mm +++ b/sdk/objc/components/audio/RTCAudioSession.mm @@ -77,7 +77,8 @@ ABSL_CONST_INIT thread_local bool mutex_locked = false; /** This initializer provides a way for unit tests to inject a fake/mock audio session. */ - (instancetype)initWithAudioSession:(id)audioSession { - if (self = [super init]) { + self = [super init]; + if (self) { _session = audioSession; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; diff --git a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m index 71b0c0cb3a..e04c685fac 100644 --- a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m +++ b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m @@ -53,7 +53,8 @@ static RTC_OBJC_TYPE(RTCAudioSessionConfiguration) *gWebRTCConfiguration = nil; @synthesize outputNumberOfChannels = _outputNumberOfChannels; - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { // Use a category which supports simultaneous recording and playback. // By default, using this category implies that our app’s audio is // nonmixable, hence activating the session will interrupt any other diff --git a/sdk/objc/components/audio/RTCNativeAudioSessionDelegateAdapter.mm b/sdk/objc/components/audio/RTCNativeAudioSessionDelegateAdapter.mm index daddf314a4..061e452527 100644 --- a/sdk/objc/components/audio/RTCNativeAudioSessionDelegateAdapter.mm +++ b/sdk/objc/components/audio/RTCNativeAudioSessionDelegateAdapter.mm @@ -20,7 +20,8 @@ - (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer { RTC_DCHECK(observer); - if (self = [super init]) { + self = [super init]; + if (self) { _observer = observer; } return self; diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m index e7c47b4e99..d25f5e20ae 100644 --- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m +++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m @@ -65,7 +65,8 @@ const int64_t kNanosecondsPerSecond = 1000000000; // This initializer is used for testing. - (instancetype)initWithDelegate:(__weak id)delegate captureSession:(AVCaptureSession *)captureSession { - if (self = [super initWithDelegate:delegate]) { + self = [super initWithDelegate:delegate]; + if (self) { // Create the capture session and all relevant inputs and outputs. We need // to do this in init because the application may want the capture session // before we start the capturer for e.g. AVCapturePreviewLayer. All objects diff --git a/sdk/objc/components/network/RTCNetworkMonitor.mm b/sdk/objc/components/network/RTCNetworkMonitor.mm index c589741242..73c5c10503 100644 --- a/sdk/objc/components/network/RTCNetworkMonitor.mm +++ b/sdk/objc/components/network/RTCNetworkMonitor.mm @@ -54,7 +54,8 @@ rtc::AdapterType AdapterTypeFromInterfaceType(nw_interface_type_t interfaceType) - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer { RTC_DCHECK(observer); - if (self = [super init]) { + self = [super init]; + if (self) { _observer = observer; if (@available(iOS 12, *)) { _pathMonitor = nw_path_monitor_create(); diff --git a/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm b/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm index 410590a7b1..cc265ac31c 100644 --- a/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm +++ b/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm @@ -115,7 +115,8 @@ static const NSInteger kMaxInflightBuffers = 1; @synthesize rotationOverride = _rotationOverride; - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { _inflight_semaphore = dispatch_semaphore_create(kMaxInflightBuffers); } diff --git a/sdk/objc/components/renderer/opengl/RTCDisplayLinkTimer.m b/sdk/objc/components/renderer/opengl/RTCDisplayLinkTimer.m index 906bb898d6..fe1ec904eb 100644 --- a/sdk/objc/components/renderer/opengl/RTCDisplayLinkTimer.m +++ b/sdk/objc/components/renderer/opengl/RTCDisplayLinkTimer.m @@ -19,7 +19,8 @@ - (instancetype)initWithTimerHandler:(void (^)(void))timerHandler { NSParameterAssert(timerHandler); - if (self = [super init]) { + self = [super init]; + if (self) { _timerHandler = timerHandler; _displayLink = [CADisplayLink displayLinkWithTarget:self diff --git a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m index 89e62d2ce7..005eae5f3f 100644 --- a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m +++ b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m @@ -69,7 +69,8 @@ } - (instancetype)initWithFrame:(CGRect)frame shader:(id)shader { - if (self = [super initWithFrame:frame]) { + self = [super initWithFrame:frame]; + if (self) { _shader = shader; if (![self configure]) { return nil; @@ -80,7 +81,8 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder shader:(id)shader { - if (self = [super initWithCoder:aDecoder]) { + self = [super initWithCoder:aDecoder]; + if (self) { _shader = shader; if (![self configure]) { return nil; diff --git a/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm b/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm index a91e927cb4..541aa15f7e 100644 --- a/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm +++ b/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm @@ -46,7 +46,8 @@ static const GLsizei kNumTextures = kNumTexturesPerSet * kNumTextureSets; } - (instancetype)initWithContext:(GlContextType *)context { - if (self = [super init]) { + self = [super init]; + if (self) { _hasUnpackRowLength = (context.API == kEAGLRenderingAPIOpenGLES3); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/sdk/objc/components/renderer/opengl/RTCNV12TextureCache.m b/sdk/objc/components/renderer/opengl/RTCNV12TextureCache.m index a520ac45b4..7eec85e7dc 100644 --- a/sdk/objc/components/renderer/opengl/RTCNV12TextureCache.m +++ b/sdk/objc/components/renderer/opengl/RTCNV12TextureCache.m @@ -29,7 +29,8 @@ } - (instancetype)initWithContext:(EAGLContext *)context { - if (self = [super init]) { + self = [super init]; + if (self) { CVReturn ret = CVOpenGLESTextureCacheCreate( kCFAllocatorDefault, NULL, #if COREVIDEO_USE_EAGLCONTEXT_CLASS_IN_API diff --git a/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm b/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm index f0ef3ec232..028f0056f1 100644 --- a/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm +++ b/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm @@ -90,7 +90,8 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() { @synthesize hexString = _hexString; - (instancetype)initWithHexString:(NSString *)hexString { - if (self = [super init]) { + self = [super init]; + if (self) { self.hexString = hexString; absl::optional profile_level_id = @@ -104,7 +105,8 @@ NSString *MaxSupportedProfileLevelConstrainedHigh() { } - (instancetype)initWithProfile:(RTCH264Profile)profile level:(RTCH264Level)level { - if (self = [super init]) { + self = [super init]; + if (self) { self.profile = profile; self.level = level; diff --git a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm index 6f5afb17ba..27ccd6d0a4 100644 --- a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm +++ b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm @@ -344,7 +344,8 @@ NSUInteger GetMaxSampleRate(const webrtc::H264ProfileLevelId &profile_level_id) // conditions, 0.95 seems to give us better overall bitrate over long periods // of time. - (instancetype)initWithCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)codecInfo { - if (self = [super init]) { + self = [super init]; + if (self) { _codecInfo = codecInfo; _bitrateAdjuster.reset(new webrtc::BitrateAdjuster(.5, .95)); _packetizationMode = RTCH264PacketizationModeNonInterleaved; diff --git a/sdk/objc/components/video_frame_buffer/RTCCVPixelBuffer.mm b/sdk/objc/components/video_frame_buffer/RTCCVPixelBuffer.mm index 1a9b672d1a..339d7df2cf 100644 --- a/sdk/objc/components/video_frame_buffer/RTCCVPixelBuffer.mm +++ b/sdk/objc/components/video_frame_buffer/RTCCVPixelBuffer.mm @@ -62,7 +62,8 @@ cropHeight:(int)cropHeight cropX:(int)cropX cropY:(int)cropY { - if (self = [super init]) { + self = [super init]; + if (self) { _width = adaptedWidth; _height = adaptedHeight; _pixelBuffer = pixelBuffer; diff --git a/sdk/objc/native/src/objc_audio_device_delegate.mm b/sdk/objc/native/src/objc_audio_device_delegate.mm index 156d6326a4..d78d20e609 100644 --- a/sdk/objc/native/src/objc_audio_device_delegate.mm +++ b/sdk/objc/native/src/objc_audio_device_delegate.mm @@ -75,7 +75,8 @@ class AudioDeviceDelegateImpl final : public rtc::RefCountedNonVirtual)audioDeviceModule audioDeviceThread:(rtc::Thread*)thread { RTC_DCHECK_RUN_ON(thread); - if (self = [super init]) { + self = [super init]; + if (self) { impl_ = rtc::make_ref_counted(audioDeviceModule, thread); preferredInputSampleRate_ = kPreferredInputSampleRate; preferredInputIOBufferDuration_ = kPeferredInputIOBufferDuration; diff --git a/sdk/objc/unittests/RTCAudioSessionTest.mm b/sdk/objc/unittests/RTCAudioSessionTest.mm index d7cfc9ed04..e0ba52bcca 100644 --- a/sdk/objc/unittests/RTCAudioSessionTest.mm +++ b/sdk/objc/unittests/RTCAudioSessionTest.mm @@ -53,7 +53,8 @@ @synthesize outputVolume = _outputVolume; - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { _outputVolume = -1; } return self; @@ -98,7 +99,8 @@ @implementation RTCTestRemoveOnDeallocDelegate - (instancetype)init { - if (self = [super init]) { + self = [super init]; + if (self) { RTC_OBJC_TYPE(RTCAudioSession) *session = [RTC_OBJC_TYPE(RTCAudioSession) sharedInstance]; [session addDelegate:self]; } diff --git a/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m b/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m index fe9d83d8db..e1598b60a1 100644 --- a/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m +++ b/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m @@ -42,7 +42,8 @@ - (instancetype)initWithSupportedCodecs: (nonnull NSArray *)supportedCodecs { - if (self = [super init]) { + self = [super init]; + if (self) { _supportedCodecs = supportedCodecs; } return self; diff --git a/sdk/objc/unittests/avformatmappertests.mm b/sdk/objc/unittests/avformatmappertests.mm index 35e95a8c22..f0dd2b1141 100644 --- a/sdk/objc/unittests/avformatmappertests.mm +++ b/sdk/objc/unittests/avformatmappertests.mm @@ -53,7 +53,8 @@ static cricket::VideoFormat expectedFormat = - (instancetype)initWithMediaSubtype:(FourCharCode)subtype minFps:(float)minFps maxFps:(float)maxFps { - if (self = [super init]) { + self = [super init]; + if (self) { CMVideoFormatDescriptionCreate(nil, subtype, kFormatWidth, kFormatHeight, nil, &_format); // We can use OCMock for the range. diff --git a/test/mac/video_renderer_mac.mm b/test/mac/video_renderer_mac.mm index 7103375383..c8ba232993 100644 --- a/test/mac/video_renderer_mac.mm +++ b/test/mac/video_renderer_mac.mm @@ -35,7 +35,8 @@ static NSInteger nextYOrigin_; - (id)initWithTitle:(NSString *)title width:(int)width height:(int)height { - if (self = [super init]) { + self = [super init]; + if (self) { title_ = title; width_ = width; height_ = height;