Bug 1924098 - Vendor libwebrtc from ab009c27b4

Upstream commit: https://webrtc.googlesource.com/src/+/ab009c27b4ff22b15f81a2de730f3075bf676cfd
    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}
This commit is contained in:
Michael Froman 2024-10-11 13:10:30 -05:00
parent 969ad4121c
commit 535101cb36
82 changed files with 198 additions and 112 deletions

View File

@ -32337,3 +32337,6 @@ b4dc789c1f
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
9e8652853e
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
ab009c27b4

View File

@ -21582,3 +21582,5 @@ libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-10-11T18:08:11.227524.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-10-11T18:09:26.564512.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-10-11T18:10:20.598596.

View File

@ -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<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 @@ 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;

View File

@ -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;
}

View File

@ -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<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 @@ 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;

View File

@ -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;

View File

@ -38,7 +38,8 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
- (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;

View File

@ -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;

View File

@ -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];

View File

@ -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];

View File

@ -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];

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -685,7 +685,8 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOp
}
- (instancetype)initWithCapturer:(webrtc::ScreenCapturerSck*)capturer {
if (self = [super init]) {
self = [super init];
if (self) {
_capturer = capturer;
}
return self;

View File

@ -29,10 +29,10 @@ index 370bfa70f0..b1f3f64f74 100644
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
index e7c47b4e99..1361207faf 100644
index d25f5e20ae..4f92f56807 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -117,14 +117,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
@@ -118,14 +118,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

View File

@ -33,7 +33,7 @@ index 2c5241d33e..105cbf0783 100644
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(
const DesktopCaptureOptions& options);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 2dad8b356b..a16a74d451 100644
index fe44694d3a..ab4d9137a0 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -24,6 +24,8 @@
@ -74,7 +74,7 @@ index 2dad8b356b..a16a74d451 100644
}
} // namespace webrtc
@@ -418,3 +427,5 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
@@ -419,3 +428,5 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
}
@end

View File

@ -15,7 +15,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6f6acc479b373662d
1 file changed, 1 insertion(+)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index a16a74d451..a7fdfb1012 100644
index ab4d9137a0..af1a4e360b 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -245,6 +245,7 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {

View File

@ -254,7 +254,7 @@ index 105cbf0783..eb3a370eed 100644
#endif // MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_SCK_H_
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index a7fdfb1012..51a5275905 100644
index af1a4e360b..b92399e6b6 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -20,11 +20,13 @@
@ -692,7 +692,7 @@ index a7fdfb1012..51a5275905 100644
} // namespace webrtc
@implementation SckHelper {
@@ -393,6 +603,50 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
@@ -394,6 +604,50 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
}
}
@ -743,7 +743,7 @@ index a7fdfb1012..51a5275905 100644
- (void)stream:(SCStream*)stream
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
ofType:(SCStreamOutputType)type {
@@ -424,6 +678,7 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
@@ -425,6 +679,7 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
- (void)releaseCapturer {
webrtc::MutexLock lock(&_capturer_lock);

View File

@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/aabf0bd94f282ae97
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 51a5275905..e98b61ccdb 100644
index b92399e6b6..96d54c5c03 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -103,7 +103,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
@ -70,7 +70,7 @@ index 51a5275905..e98b61ccdb 100644
if (!CGRectIsEmpty(rect)) {
dirty = true;
break;
@@ -672,7 +667,7 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOp
@@ -673,7 +668,7 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOp
webrtc::MutexLock lock(&_capturer_lock);
if (_capturer) {

View File

@ -112,7 +112,7 @@ index b59b319db9..7a5b595f19 100644
io_surface_(io_surface) {
RTC_DCHECK(io_surface_);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index e98b61ccdb..19c887d435 100644
index 96d54c5c03..f331bafdfd 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -169,6 +169,12 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture

View File

@ -12,7 +12,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d52f2fd575479da7
1 file changed, 17 insertions(+)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 19c887d435..482501e2d9 100644
index f331bafdfd..ddaf9a9624 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -511,6 +511,7 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at

View File

@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ade6f6dc0c5a5df1c
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 482501e2d9..9e45e94ccd 100644
index ddaf9a9624..9136915033 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -305,10 +305,18 @@ void ScreenCapturerSck::EnsureVisible() {

View File

@ -53,7 +53,8 @@ class VideoRendererAdapter
- (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));
}

View File

@ -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;

View File

@ -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];
}

View File

@ -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) {

View File

@ -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;

View File

@ -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<const uint8_t*>(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<webrtc::DataChannelInterface>)nativeDataChannel {
NSParameterAssert(nativeDataChannel);
if (self = [super init]) {
self = [super init];
if (self) {
_factory = factory;
_nativeDataChannel = nativeDataChannel;
_observer.reset(new webrtc::DataChannelDelegateAdapter(self));

View File

@ -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);

View File

@ -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();

View File

@ -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]) {

View File

@ -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];

View File

@ -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];

View File

@ -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:

View File

@ -37,7 +37,8 @@ NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kVa
(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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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());

View File

@ -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();

View File

@ -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;
}

View File

@ -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]

View File

@ -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];

View File

@ -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) {

View File

@ -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];
}

View File

@ -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;

View File

@ -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];

View File

@ -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];

View File

@ -117,7 +117,8 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived(
- (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);

View File

@ -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) {

View File

@ -65,7 +65,8 @@
}
- (instancetype)initWithNativeRtpSource:(const webrtc::RtpSource &)nativeRtpSource {
if (self = [super init]) {
self = [super init];
if (self) {
_nativeRtpSource = nativeRtpSource;
}
return self;

View File

@ -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<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

View File

@ -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];
}

View File

@ -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 =

View File

@ -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;
}

View File

@ -33,9 +33,10 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource(
(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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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 : @{});
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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];

View File

@ -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 apps audio is
// nonmixable, hence activating the session will interrupt any other

View File

@ -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;

View File

@ -65,7 +65,8 @@ const int64_t kNanosecondsPerSecond = 1000000000;
// 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

View File

@ -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();

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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<webrtc::H264ProfileLevelId> 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;

View File

@ -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;

View File

@ -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;

View File

@ -75,7 +75,8 @@ class AudioDeviceDelegateImpl final : public rtc::RefCountedNonVirtual<AudioDevi
(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;

View File

@ -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];
}

View File

@ -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;

View File

@ -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.

View File

@ -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;