Refactor WebRTC self assignments in if clauses
This change refactors existing self-assignments within if clauses across
the WebRTC codebase.
*Why:*
- Bug Prevention: Assignments within conditionals are frequently
unintended errors, often mistaken for equality checks.
- Clearer Code: Separating assignments from conditionals improves code
readability and reduces the risk of misinterpretation.
Change-Id: I199dc26a35ceca109a2ac569b446811314dfdf0b
Bug: chromium:361594695
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/360460
Reviewed-by: Chuck Hays <haysc@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42850}
diff --git a/examples/objc/AppRTCMobile/ARDAppClient.m b/examples/objc/AppRTCMobile/ARDAppClient.m
index 4420972..e60d9a6 100644
--- a/examples/objc/AppRTCMobile/ARDAppClient.m
+++ b/examples/objc/AppRTCMobile/ARDAppClient.m
@@ -84,7 +84,8 @@
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 @@
}
- (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)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 @@
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 26cce9f..7c99ce2 100644
--- a/examples/objc/AppRTCMobile/ARDCaptureController.m
+++ b/examples/objc/AppRTCMobile/ARDCaptureController.m
@@ -24,12 +24,12 @@
- (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 049c0f5..1cea92f 100644
--- a/examples/objc/AppRTCMobile/ARDSignalingMessage.m
+++ b/examples/objc/AppRTCMobile/ARDSignalingMessage.m
@@ -24,7 +24,8 @@
@synthesize type = _type;
- (instancetype)initWithType:(ARDSignalingMessageType)type {
- if (self = [super init]) {
+ self = [super init];
+ if (self) {
_type = type;
}
return self;
@@ -79,7 +80,8 @@
@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 @@
- (instancetype)initWithRemovedCandidates:(NSArray<RTC_OBJC_TYPE(RTCIceCandidate) *> *)candidates {
NSParameterAssert(candidates.count);
- if (self = [super initWithType:kARDSignalingMessageTypeCandidateRemoval]) {
+ self = [super initWithType:kARDSignalingMessageTypeCandidateRemoval];
+ if (self) {
_candidates = candidates;
}
return self;
@@ -130,7 +133,8 @@
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 069231c..641e9d5 100644
--- a/examples/objc/AppRTCMobile/ARDTURNClient.m
+++ b/examples/objc/AppRTCMobile/ARDTURNClient.m
@@ -24,7 +24,8 @@
- (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 bbb0bf8..2bf081b 100644
--- a/examples/objc/AppRTCMobile/ARDWebSocketChannel.m
+++ b/examples/objc/AppRTCMobile/ARDWebSocketChannel.m
@@ -38,7 +38,8 @@
- (instancetype)initWithURL:(NSURL *)url
restURL:(NSURL *)restURL
delegate:(id<ARDSignalingChannelDelegate>)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 2ddde6d..358a73f 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 d952106..cd374a6 100644
--- a/examples/objc/AppRTCMobile/ios/ARDMainView.m
+++ b/examples/objc/AppRTCMobile/ios/ARDMainView.m
@@ -26,7 +26,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 @@
@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 867ba5b..353b1f0 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 437aea8..2364ee1 100644
--- a/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m
+++ b/examples/objc/AppRTCMobile/ios/ARDVideoCallView.m
@@ -39,8 +39,8 @@
@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 a82d90b..b092392 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<ARDVideoCallViewControllerDelegate>)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 1c276d9..a024fcd 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 982fa56..adfd028 100644
--- a/examples/objc/AppRTCMobile/mac/APPRTCViewController.m
+++ b/examples/objc/AppRTCMobile/mac/APPRTCViewController.m
@@ -72,7 +72,8 @@
#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 2dad8b3..fe44694 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -370,7 +370,8 @@
}
- (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 ef02f72..0df7374 100644
--- a/sdk/objc/api/RTCVideoRendererAdapter.mm
+++ b/sdk/objc/api/RTCVideoRendererAdapter.mm
@@ -53,7 +53,8 @@
- (instancetype)initWithNativeRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)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 1541045..1dba1e3 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 e5c33e4..f6817a6 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 86ecbab..7635ac0 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 fbaa1de..3789f7a 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 4a79cef..40a4d8e 100644
--- a/sdk/objc/api/peerconnection/RTCDataChannel.mm
+++ b/sdk/objc/api/peerconnection/RTCDataChannel.mm
@@ -50,7 +50,8 @@
- (instancetype)initWithData:(NSData *)data isBinary:(BOOL)isBinary {
NSParameterAssert(data);
- if (self = [super init]) {
+ self = [super init];
+ if (self) {
rtc::CopyOnWriteBuffer buffer(
reinterpret_cast<const uint8_t*>(data.bytes), data.length);
_dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary));
@@ -70,7 +71,8 @@
#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 @@
nativeDataChannel:
(rtc::scoped_refptr<webrtc::DataChannelInterface>)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 ee3b79c..2cec54a 100644
--- a/sdk/objc/api/peerconnection/RTCDtmfSender.mm
+++ b/sdk/objc/api/peerconnection/RTCDtmfSender.mm
@@ -64,7 +64,8 @@
- (instancetype)initWithNativeDtmfSender:
(rtc::scoped_refptr<webrtc::DtmfSenderInterface>)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 c8936d3..43fb1b1 100644
--- a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm
+++ b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm
@@ -73,7 +73,8 @@
}
- (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 9562245..ee61cda 100644
--- a/sdk/objc/api/peerconnection/RTCFileLogger.mm
+++ b/sdk/objc/api/peerconnection/RTCFileLogger.mm
@@ -54,7 +54,8 @@
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 48385ef..131c319 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 19a0a7e..d4b6330 100644
--- a/sdk/objc/api/peerconnection/RTCIceServer.mm
+++ b/sdk/objc/api/peerconnection/RTCIceServer.mm
@@ -84,7 +84,8 @@
tlsAlpnProtocols:(NSArray<NSString *> *)tlsAlpnProtocols
tlsEllipticCurves:(NSArray<NSString *> *)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 bd7a1ad..4b5c272 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 0f46e4b..ac5fb64 100644
--- a/sdk/objc/api/peerconnection/RTCMediaConstraints.mm
+++ b/sdk/objc/api/peerconnection/RTCMediaConstraints.mm
@@ -37,7 +37,8 @@
(NSDictionary<NSString *, NSString *> *)mandatory
optionalConstraints:
(NSDictionary<NSString *, NSString *> *)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 61472a7..5a26e31 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 0018dd6..4a99bd5 100644
--- a/sdk/objc/api/peerconnection/RTCMediaStream.mm
+++ b/sdk/objc/api/peerconnection/RTCMediaStream.mm
@@ -120,7 +120,8 @@
nativeMediaStream:
(rtc::scoped_refptr<webrtc::MediaStreamInterface>)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 f1e128c..60decee 100644
--- a/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm
+++ b/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm
@@ -81,7 +81,8 @@
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 e4be94e..ea01350 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 e55c8a4..62e640e 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm
+++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm
@@ -365,7 +365,8 @@
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 eb03d68..3d8ff86 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 e92ee4b..058600b 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 85537a9..b332181 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 2dc1e5d..9c38bb7 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 6201e57..e273219 100644
--- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm
+++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm
@@ -49,7 +49,8 @@
- (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 d6087da..8bb2f43 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 68093e9..0cbdb78 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 c9af744..c5cbda1 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 2baf0ec..d725f6a 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 d54efc9..02afaed 100644
--- a/sdk/objc/api/peerconnection/RTCRtpReceiver.mm
+++ b/sdk/objc/api/peerconnection/RTCRtpReceiver.mm
@@ -117,7 +117,8 @@
- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
nativeRtpReceiver:
(rtc::scoped_refptr<webrtc::RtpReceiverInterface>)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 4fadb30..3d57020 100644
--- a/sdk/objc/api/peerconnection/RTCRtpSender.mm
+++ b/sdk/objc/api/peerconnection/RTCRtpSender.mm
@@ -113,7 +113,8 @@
nativeRtpSender:(rtc::scoped_refptr<webrtc::RtpSenderInterface>)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 aa5d6c2..5f7a678 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 a7f2818..bde4d08 100644
--- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm
+++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm
@@ -29,7 +29,8 @@
@synthesize sendEncodings = _sendEncodings;
- (instancetype)init {
- if (self = [super init]) {
+ self = [super init];
+ if (self) {
_direction = RTCRtpTransceiverDirectionSendRecv;
}
return self;
@@ -166,7 +167,8 @@
(rtc::scoped_refptr<webrtc::RtpTransceiverInterface>)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 539c90b..d173f22 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 eaf2097..2622de8 100644
--- a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm
+++ b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm
@@ -114,7 +114,8 @@
@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 @@
@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 dec3a61..fb93948 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 486ca93..de718fb 100644
--- a/sdk/objc/api/peerconnection/RTCVideoSource.mm
+++ b/sdk/objc/api/peerconnection/RTCVideoSource.mm
@@ -33,9 +33,10 @@
(rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)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 d3296f6..8d9f86d 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 7aafd98..bbf2708 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<webrtc::I420BufferInterface>)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 ca31a73..78db367 100644
--- a/sdk/objc/base/RTCVideoCapturer.m
+++ b/sdk/objc/base/RTCVideoCapturer.m
@@ -15,7 +15,8 @@
@synthesize delegate = _delegate;
- (instancetype)initWithDelegate:(id<RTC_OBJC_TYPE(RTCVideoCapturerDelegate)>)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 ce26ae1..8effa29 100644
--- a/sdk/objc/base/RTCVideoCodecInfo.m
+++ b/sdk/objc/base/RTCVideoCodecInfo.m
@@ -21,7 +21,8 @@
- (instancetype)initWithName:(NSString *)name
parameters:(nullable NSDictionary<NSString *, NSString *> *)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 fb7012f..1077cd7 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 e162238..a5d23bb 100644
--- a/sdk/objc/base/RTCVideoFrame.mm
+++ b/sdk/objc/base/RTCVideoFrame.mm
@@ -66,12 +66,12 @@
- (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)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 641d2ed..0ef64a7 100644
--- a/sdk/objc/components/audio/RTCAudioSession.mm
+++ b/sdk/objc/components/audio/RTCAudioSession.mm
@@ -77,7 +77,8 @@
/** 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 71b0c0c..e04c685 100644
--- a/sdk/objc/components/audio/RTCAudioSessionConfiguration.m
+++ b/sdk/objc/components/audio/RTCAudioSessionConfiguration.m
@@ -53,7 +53,8 @@
@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 daddf31..061e452 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 e7c47b4..d25f5e2 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -65,7 +65,8 @@
// This initializer is used for testing.
- (instancetype)initWithDelegate:(__weak id<RTC_OBJC_TYPE(RTCVideoCapturerDelegate)>)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 c589741..73c5c10 100644
--- a/sdk/objc/components/network/RTCNetworkMonitor.mm
+++ b/sdk/objc/components/network/RTCNetworkMonitor.mm
@@ -54,7 +54,8 @@
- (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 410590a..cc265ac 100644
--- a/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm
+++ b/sdk/objc/components/renderer/metal/RTCMTLRenderer.mm
@@ -115,7 +115,8 @@
@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 906bb89..fe1ec90 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 89e62d2..005eae5 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<RTC_OBJC_TYPE(RTCVideoViewShading)>)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<RTC_OBJC_TYPE(RTCVideoViewShading)>)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 a91e927..541aa15 100644
--- a/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm
+++ b/sdk/objc/components/renderer/opengl/RTCI420TextureCache.mm
@@ -46,7 +46,8 @@
}
- (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 a520ac4..7eec85e 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 f0ef3ec..028f005 100644
--- a/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm
+++ b/sdk/objc/components/video_codec/RTCH264ProfileLevelId.mm
@@ -90,7 +90,8 @@
@synthesize hexString = _hexString;
- (instancetype)initWithHexString:(NSString *)hexString {
- if (self = [super init]) {
+ self = [super init];
+ if (self) {
self.hexString = hexString;
absl::optional<webrtc::H264ProfileLevelId> profile_level_id =
@@ -104,7 +105,8 @@
}
- (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 6f5afb1..27ccd6d 100644
--- a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
+++ b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
@@ -344,7 +344,8 @@
// 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 1a9b672..339d7df 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 156d632..d78d20e 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 @@
(rtc::scoped_refptr<webrtc::objc_adm::ObjCAudioDeviceModule>)audioDeviceModule
audioDeviceThread:(rtc::Thread*)thread {
RTC_DCHECK_RUN_ON(thread);
- if (self = [super init]) {
+ self = [super init];
+ if (self) {
impl_ = rtc::make_ref_counted<AudioDeviceDelegateImpl>(audioDeviceModule, thread);
preferredInputSampleRate_ = kPreferredInputSampleRate;
preferredInputIOBufferDuration_ = kPeferredInputIOBufferDuration;
diff --git a/sdk/objc/unittests/RTCAudioSessionTest.mm b/sdk/objc/unittests/RTCAudioSessionTest.mm
index d7cfc9e..e0ba52b 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 fe9d83d..e1598b6 100644
--- a/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m
+++ b/sdk/objc/unittests/RTCPeerConnectionFactory_xctest.m
@@ -42,7 +42,8 @@
- (instancetype)initWithSupportedCodecs:
(nonnull NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)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 35e95a8..f0dd2b1 100644
--- a/sdk/objc/unittests/avformatmappertests.mm
+++ b/sdk/objc/unittests/avformatmappertests.mm
@@ -53,7 +53,8 @@
- (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 7103375..c8ba232 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;