diff --git a/sdk/objc/api/RTCVideoRendererAdapter+Private.h b/sdk/objc/api/RTCVideoRendererAdapter+Private.h index 9b123d2d05..4f40a158b4 100644 --- a/sdk/objc/api/RTCVideoRendererAdapter+Private.h +++ b/sdk/objc/api/RTCVideoRendererAdapter+Private.h @@ -23,17 +23,20 @@ NS_ASSUME_NONNULL_BEGIN * Calls made to the webrtc::VideoRenderInterface will be adapted and passed to * this video renderer. */ -@property(nonatomic, readonly) id videoRenderer; +@property(nonatomic, readonly) id + videoRenderer; /** * The native VideoSinkInterface surface exposed by this adapter. Calls made * to this interface will be adapted and passed to the RTCVideoRenderer supplied * during construction. This pointer is unsafe and owned by this class. */ -@property(nonatomic, readonly) rtc::VideoSinkInterface *nativeVideoRenderer; +@property(nonatomic, readonly) + rtc::VideoSinkInterface *nativeVideoRenderer; /** Initialize an RTCVideoRendererAdapter with an RTCVideoRenderer. */ -- (instancetype)initWithNativeRenderer:(id)videoRenderer +- (instancetype)initWithNativeRenderer: + (id)videoRenderer NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/RTCVideoRendererAdapter.mm b/sdk/objc/api/RTCVideoRendererAdapter.mm index 0df73749f1..32fa186da7 100644 --- a/sdk/objc/api/RTCVideoRendererAdapter.mm +++ b/sdk/objc/api/RTCVideoRendererAdapter.mm @@ -26,11 +26,12 @@ class VideoRendererAdapter } void OnFrame(const webrtc::VideoFrame& nativeVideoFrame) override { - RTC_OBJC_TYPE(RTCVideoFrame)* videoFrame = NativeToObjCVideoFrame(nativeVideoFrame); + RTC_OBJC_TYPE(RTCVideoFrame)* videoFrame = + NativeToObjCVideoFrame(nativeVideoFrame); - CGSize current_size = (videoFrame.rotation % 180 == 0) - ? CGSizeMake(videoFrame.width, videoFrame.height) - : CGSizeMake(videoFrame.height, videoFrame.width); + CGSize current_size = (videoFrame.rotation % 180 == 0) ? + CGSizeMake(videoFrame.width, videoFrame.height) : + CGSizeMake(videoFrame.height, videoFrame.width); if (!CGSizeEqualToSize(size_, current_size)) { size_ = current_size; @@ -40,10 +41,10 @@ class VideoRendererAdapter } private: - __weak RTCVideoRendererAdapter *adapter_; + __weak RTCVideoRendererAdapter* adapter_; CGSize size_; }; -} +} // namespace webrtc @implementation RTCVideoRendererAdapter { std::unique_ptr _adapter; @@ -51,7 +52,8 @@ class VideoRendererAdapter @synthesize videoRenderer = _videoRenderer; -- (instancetype)initWithNativeRenderer:(id)videoRenderer { +- (instancetype)initWithNativeRenderer: + (id)videoRenderer { NSParameterAssert(videoRenderer); self = [super init]; if (self) { @@ -61,7 +63,7 @@ class VideoRendererAdapter return self; } -- (rtc::VideoSinkInterface *)nativeVideoRenderer { +- (rtc::VideoSinkInterface*)nativeVideoRenderer { return _adapter.get(); } diff --git a/sdk/objc/api/logging/RTCCallbackLogger.h b/sdk/objc/api/logging/RTCCallbackLogger.h index b196bd63c9..08bfbf0f91 100644 --- a/sdk/objc/api/logging/RTCCallbackLogger.h +++ b/sdk/objc/api/logging/RTCCallbackLogger.h @@ -16,8 +16,8 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^RTCCallbackLoggerMessageHandler)(NSString *message); -typedef void (^RTCCallbackLoggerMessageAndSeverityHandler)(NSString *message, - RTCLoggingSeverity severity); +typedef void (^RTCCallbackLoggerMessageAndSeverityHandler)( + NSString *message, RTCLoggingSeverity severity); // This class intercepts WebRTC logs and forwards them to a registered block. // This class is not threadsafe. diff --git a/sdk/objc/api/logging/RTCCallbackLogger.mm b/sdk/objc/api/logging/RTCCallbackLogger.mm index ba6fe1b1cc..435fd66a0a 100644 --- a/sdk/objc/api/logging/RTCCallbackLogger.mm +++ b/sdk/objc/api/logging/RTCCallbackLogger.mm @@ -42,24 +42,32 @@ class CallbackLogSink final : public rtc::LogSink { class CallbackWithSeverityLogSink final : public rtc::LogSink { public: - CallbackWithSeverityLogSink(RTCCallbackLoggerMessageAndSeverityHandler callbackHandler) + CallbackWithSeverityLogSink( + RTCCallbackLoggerMessageAndSeverityHandler callbackHandler) : callback_handler_(callbackHandler) {} - void OnLogMessage(const std::string& message) override { RTC_DCHECK_NOTREACHED(); } + void OnLogMessage(const std::string& message) override { + RTC_DCHECK_NOTREACHED(); + } - void OnLogMessage(const std::string& message, rtc::LoggingSeverity severity) override { + void OnLogMessage(const std::string& message, + rtc::LoggingSeverity severity) override { OnLogMessage(absl::string_view(message), severity); } - void OnLogMessage(absl::string_view message, rtc::LoggingSeverity severity) override { + void OnLogMessage(absl::string_view message, + rtc::LoggingSeverity severity) override { if (callback_handler_) { - RTCLoggingSeverity loggingSeverity = NativeSeverityToObjcSeverity(severity); - callback_handler_([NSString stringForAbslStringView:message], loggingSeverity); + RTCLoggingSeverity loggingSeverity = + NativeSeverityToObjcSeverity(severity); + callback_handler_([NSString stringForAbslStringView:message], + loggingSeverity); } } private: - static RTCLoggingSeverity NativeSeverityToObjcSeverity(rtc::LoggingSeverity severity) { + static RTCLoggingSeverity NativeSeverityToObjcSeverity( + rtc::LoggingSeverity severity) { switch (severity) { case rtc::LS_VERBOSE: return RTCLoggingSeverityVerbose; @@ -77,7 +85,7 @@ class CallbackWithSeverityLogSink final : public rtc::LogSink { RTCCallbackLoggerMessageAndSeverityHandler callback_handler_; }; -} +} // namespace @implementation RTC_OBJC_TYPE (RTCCallbackLogger) { BOOL _hasStarted; @@ -110,7 +118,7 @@ class CallbackWithSeverityLogSink final : public rtc::LogSink { } - (void)startWithMessageAndSeverityHandler: - (nullable RTCCallbackLoggerMessageAndSeverityHandler)handler { + (nullable RTCCallbackLoggerMessageAndSeverityHandler)handler { if (_hasStarted) { return; } diff --git a/sdk/objc/api/peerconnection/RTCAudioSource+Private.h b/sdk/objc/api/peerconnection/RTCAudioSource+Private.h index 2c333f9d73..fe9e828ffa 100644 --- a/sdk/objc/api/peerconnection/RTCAudioSource+Private.h +++ b/sdk/objc/api/peerconnection/RTCAudioSource+Private.h @@ -19,16 +19,20 @@ * The AudioSourceInterface object passed to this RTCAudioSource during * construction. */ - @property(nonatomic, - readonly) rtc::scoped_refptr nativeAudioSource; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeAudioSource; /** Initialize an RTCAudioSource from a native AudioSourceInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeAudioSource:(rtc::scoped_refptr)nativeAudioSource +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeAudioSource: + (rtc::scoped_refptr)nativeAudioSource NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type NS_UNAVAILABLE; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type NS_UNAVAILABLE; @end diff --git a/sdk/objc/api/peerconnection/RTCAudioSource.mm b/sdk/objc/api/peerconnection/RTCAudioSource.mm index 1dba1e3381..0d3681fca6 100644 --- a/sdk/objc/api/peerconnection/RTCAudioSource.mm +++ b/sdk/objc/api/peerconnection/RTCAudioSource.mm @@ -18,9 +18,10 @@ @synthesize volume = _volume; @synthesize nativeAudioSource = _nativeAudioSource; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeAudioSource: - (rtc::scoped_refptr)nativeAudioSource { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeAudioSource: + (rtc::scoped_refptr)nativeAudioSource { RTC_DCHECK(factory); RTC_DCHECK(nativeAudioSource); @@ -33,16 +34,20 @@ return self; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type { RTC_DCHECK_NOTREACHED(); return nil; } - (NSString *)description { NSString *stateString = [[self class] stringForState:self.state]; - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCAudioSource)( %p ): %@", self, stateString]; + return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCAudioSource)( %p ): %@", + self, + stateString]; } - (void)setVolume:(double)volume { diff --git a/sdk/objc/api/peerconnection/RTCAudioTrack+Private.h b/sdk/objc/api/peerconnection/RTCAudioTrack+Private.h index 6495500484..b253220587 100644 --- a/sdk/objc/api/peerconnection/RTCAudioTrack+Private.h +++ b/sdk/objc/api/peerconnection/RTCAudioTrack+Private.h @@ -19,10 +19,12 @@ NS_ASSUME_NONNULL_BEGIN () /** AudioTrackInterface created or passed in at construction. */ - @property(nonatomic, readonly) rtc::scoped_refptr nativeAudioTrack; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeAudioTrack; /** Initialize an RTCAudioTrack with an id. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory source:(RTC_OBJC_TYPE(RTCAudioSource) *)source trackId:(NSString *)trackId; diff --git a/sdk/objc/api/peerconnection/RTCAudioTrack.mm b/sdk/objc/api/peerconnection/RTCAudioTrack.mm index ae6c08a718..07a6156117 100644 --- a/sdk/objc/api/peerconnection/RTCAudioTrack.mm +++ b/sdk/objc/api/peerconnection/RTCAudioTrack.mm @@ -21,7 +21,8 @@ @synthesize source = _source; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory source:(RTC_OBJC_TYPE(RTCAudioSource) *)source trackId:(NSString *)trackId { RTC_DCHECK(factory); @@ -30,17 +31,22 @@ std::string nativeId = [NSString stdStringForString:trackId]; rtc::scoped_refptr track = - factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource.get()); - self = [self initWithFactory:factory nativeTrack:track type:RTCMediaStreamTrackTypeAudio]; + factory.nativeFactory->CreateAudioTrack(nativeId, + source.nativeAudioSource.get()); + self = [self initWithFactory:factory + nativeTrack:track + type:RTCMediaStreamTrackTypeAudio]; if (self) { _source = source; } return self; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack:(rtc::scoped_refptr)nativeTrack - type:(RTCMediaStreamTrackType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack: + (rtc::scoped_refptr)nativeTrack + type:(RTCMediaStreamTrackType)type { NSParameterAssert(factory); NSParameterAssert(nativeTrack); NSParameterAssert(type == RTCMediaStreamTrackTypeAudio); @@ -49,10 +55,12 @@ - (RTC_OBJC_TYPE(RTCAudioSource) *)source { if (!_source) { - rtc::scoped_refptr source(self.nativeAudioTrack->GetSource()); + rtc::scoped_refptr source( + self.nativeAudioTrack->GetSource()); if (source) { - _source = [[RTC_OBJC_TYPE(RTCAudioSource) alloc] initWithFactory:self.factory - nativeAudioSource:source]; + _source = + [[RTC_OBJC_TYPE(RTCAudioSource) alloc] initWithFactory:self.factory + nativeAudioSource:source]; } } return _source; diff --git a/sdk/objc/api/peerconnection/RTCCertificate.h b/sdk/objc/api/peerconnection/RTCCertificate.h index 9d379bab78..343eb24d0d 100644 --- a/sdk/objc/api/peerconnection/RTCCertificate.h +++ b/sdk/objc/api/peerconnection/RTCCertificate.h @@ -24,10 +24,12 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly, copy) NSString *certificate; /** - * Initialize an RTCCertificate with PEM strings for private_key and certificate. + * Initialize an RTCCertificate with PEM strings for private_key and + * certificate. */ - (instancetype)initWithPrivateKey:(NSString *)private_key - certificate:(NSString *)certificate NS_DESIGNATED_INITIALIZER; + certificate:(NSString *)certificate + NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; @@ -37,7 +39,8 @@ RTC_OBJC_EXPORT * provided. * - name: "ECDSA" or "RSASSA-PKCS1-v1_5" */ -+ (nullable RTC_OBJC_TYPE(RTCCertificate) *)generateCertificateWithParams:(NSDictionary *)params; ++ (nullable RTC_OBJC_TYPE(RTCCertificate) *)generateCertificateWithParams: + (NSDictionary *)params; @end diff --git a/sdk/objc/api/peerconnection/RTCCertificate.mm b/sdk/objc/api/peerconnection/RTCCertificate.mm index c3e5d7f9cc..ce4dff9f92 100644 --- a/sdk/objc/api/peerconnection/RTCCertificate.mm +++ b/sdk/objc/api/peerconnection/RTCCertificate.mm @@ -22,12 +22,14 @@ @synthesize certificate = _certificate; - (id)copyWithZone:(NSZone *)zone { - id copy = [[[self class] alloc] initWithPrivateKey:[self.private_key copyWithZone:zone] - certificate:[self.certificate copyWithZone:zone]]; + id copy = [[[self class] alloc] + initWithPrivateKey:[self.private_key copyWithZone:zone] + certificate:[self.certificate copyWithZone:zone]]; return copy; } -- (instancetype)initWithPrivateKey:(NSString *)private_key certificate:(NSString *)certificate { +- (instancetype)initWithPrivateKey:(NSString *)private_key + certificate:(NSString *)certificate { self = [super init]; if (self) { _private_key = [private_key copy]; @@ -36,7 +38,8 @@ return self; } -+ (nullable RTC_OBJC_TYPE(RTCCertificate) *)generateCertificateWithParams:(NSDictionary *)params { ++ (nullable RTC_OBJC_TYPE(RTCCertificate) *)generateCertificateWithParams: + (NSDictionary *)params { rtc::KeyType keyType = rtc::KT_ECDSA; NSString *keyTypeString = [params valueForKey:@"name"]; if (keyTypeString && [keyTypeString isEqualToString:@"RSASSA-PKCS1-v1_5"]) { @@ -47,11 +50,11 @@ rtc::scoped_refptr cc_certificate = nullptr; if (expires != nil) { uint64_t expirationTimestamp = [expires unsignedLongLongValue]; - cc_certificate = rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType), - expirationTimestamp); + cc_certificate = rtc::RTCCertificateGenerator::GenerateCertificate( + rtc::KeyParams(keyType), expirationTimestamp); } else { - cc_certificate = - rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType), std::nullopt); + cc_certificate = rtc::RTCCertificateGenerator::GenerateCertificate( + rtc::KeyParams(keyType), std::nullopt); } if (!cc_certificate) { RTCLogError(@"Failed to generate certificate."); @@ -64,9 +67,9 @@ RTC_LOG(LS_INFO) << "CERT PEM "; RTC_LOG(LS_INFO) << pem_certificate; - RTC_OBJC_TYPE(RTCCertificate) *cert = - [[RTC_OBJC_TYPE(RTCCertificate) alloc] initWithPrivateKey:@(pem_private_key.c_str()) - certificate:@(pem_certificate.c_str())]; + RTC_OBJC_TYPE(RTCCertificate) *cert = [[RTC_OBJC_TYPE(RTCCertificate) alloc] + initWithPrivateKey:@(pem_private_key.c_str()) + certificate:@(pem_certificate.c_str())]; return cert; } diff --git a/sdk/objc/api/peerconnection/RTCConfiguration+Private.h b/sdk/objc/api/peerconnection/RTCConfiguration+Private.h index 6ad780acdc..9fdb5df03a 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration+Private.h +++ b/sdk/objc/api/peerconnection/RTCConfiguration+Private.h @@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCConfiguration) () - + (webrtc::PeerConnectionInterface::IceTransportsType)nativeTransportsTypeForTransportPolicy + + (webrtc::PeerConnectionInterface::IceTransportsType) + nativeTransportsTypeForTransportPolicy : (RTCIceTransportPolicy)policy; + (RTCIceTransportPolicy)transportPolicyForTransportsType: @@ -41,16 +42,16 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy; -+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeTcpCandidatePolicyForPolicy: - (RTCTcpCandidatePolicy)policy; ++ (webrtc::PeerConnectionInterface::TcpCandidatePolicy) + nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy; + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy; + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy; -+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativeCandidateNetworkPolicyForPolicy: - (RTCCandidateNetworkPolicy)policy; ++ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy) + nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy; + (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy: (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy; @@ -59,9 +60,11 @@ NS_ASSUME_NONNULL_BEGIN + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:(RTCEncryptionKeyType)keyType; -+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics; ++ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics: + (RTCSdpSemantics)sdpSemantics; -+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics; ++ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics: + (webrtc::SdpSemantics)sdpSemantics; + (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics; @@ -69,10 +72,12 @@ NS_ASSUME_NONNULL_BEGIN * RTCConfiguration struct representation of this RTCConfiguration. * This is needed to pass to the underlying C++ APIs. */ -- (nullable webrtc::PeerConnectionInterface::RTCConfiguration *)createNativeConfiguration; +- (nullable webrtc::PeerConnectionInterface::RTCConfiguration *) + createNativeConfiguration; - (instancetype)initWithNativeConfiguration: - (const webrtc::PeerConnectionInterface::RTCConfiguration &)config NS_DESIGNATED_INITIALIZER; + (const webrtc::PeerConnectionInterface::RTCConfiguration &)config + NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCConfiguration.h b/sdk/objc/api/peerconnection/RTCConfiguration.h index 107d5d0562..b75ac6cf9a 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration.h +++ b/sdk/objc/api/peerconnection/RTCConfiguration.h @@ -35,7 +35,10 @@ typedef NS_ENUM(NSInteger, RTCBundlePolicy) { }; /** Represents the rtcp mux policy. */ -typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { RTCRtcpMuxPolicyNegotiate, RTCRtcpMuxPolicyRequire }; +typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { + RTCRtcpMuxPolicyNegotiate, + RTCRtcpMuxPolicyRequire +}; /** Represents the tcp candidate policy. */ typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { @@ -95,7 +98,8 @@ RTC_OBJC_EXPORT @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; @property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy; -@property(nonatomic, assign) RTCContinualGatheringPolicy continualGatheringPolicy; +@property(nonatomic, assign) + RTCContinualGatheringPolicy continualGatheringPolicy; /** If set to YES, don't gather IPv6 ICE candidates on Wi-Fi. * Only intended to be used on specific devices. Certain phones disable IPv6 @@ -150,7 +154,8 @@ RTC_OBJC_EXPORT * transport type and as a result not observed by PeerConnectionDelegateAdapter, * will be surfaced to the delegate. */ -@property(nonatomic, assign) BOOL shouldSurfaceIceCandidatesOnIceTransportTypeChanged; +@property(nonatomic, assign) + BOOL shouldSurfaceIceCandidatesOnIceTransportTypeChanged; /** If set to non-nil, controls the minimal interval between consecutive ICE * check packets. @@ -225,7 +230,8 @@ RTC_OBJC_EXPORT * when ICE is strongly connected, and it overrides the * default value of this interval in the ICE implementation; */ -@property(nonatomic, copy, nullable) NSNumber *iceCheckIntervalStrongConnectivity; +@property(nonatomic, copy, nullable) + NSNumber *iceCheckIntervalStrongConnectivity; /** * Defines the counterpart for ALL pairs when ICE is diff --git a/sdk/objc/api/peerconnection/RTCConfiguration.mm b/sdk/objc/api/peerconnection/RTCConfiguration.mm index d53a948ab5..91151ef59c 100644 --- a/sdk/objc/api/peerconnection/RTCConfiguration.mm +++ b/sdk/objc/api/peerconnection/RTCConfiguration.mm @@ -57,8 +57,10 @@ @synthesize rtcpVideoReportIntervalMs = _rtcpVideoReportIntervalMs; @synthesize enableImplicitRollback = _enableImplicitRollback; @synthesize offerExtmapAllowMixed = _offerExtmapAllowMixed; -@synthesize iceCheckIntervalStrongConnectivity = _iceCheckIntervalStrongConnectivity; -@synthesize iceCheckIntervalWeakConnectivity = _iceCheckIntervalWeakConnectivity; +@synthesize iceCheckIntervalStrongConnectivity = + _iceCheckIntervalStrongConnectivity; +@synthesize iceCheckIntervalWeakConnectivity = + _iceCheckIntervalWeakConnectivity; @synthesize iceUnwritableTimeout = _iceUnwritableTimeout; @synthesize iceUnwritableMinChecks = _iceUnwritableMinChecks; @synthesize iceInactiveTimeout = _iceInactiveTimeout; @@ -76,7 +78,8 @@ if (self) { _enableDscp = config.dscp(); NSMutableArray *iceServers = [NSMutableArray array]; - for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) { + for (const webrtc::PeerConnectionInterface::IceServer &server : + config.servers) { RTC_OBJC_TYPE(RTCIceServer) *iceServer = [[RTC_OBJC_TYPE(RTCIceServer) alloc] initWithNativeServer:server]; [iceServers addObject:iceServer]; @@ -96,18 +99,20 @@ [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; _rtcpMuxPolicy = [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; - _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: - config.tcp_candidate_policy]; + _tcpCandidatePolicy = [[self class] + tcpCandidatePolicyForNativePolicy:config.tcp_candidate_policy]; _candidateNetworkPolicy = [[self class] candidateNetworkPolicyForNativePolicy:config.candidate_network_policy]; webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = - config.continual_gathering_policy; - _continualGatheringPolicy = [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; + config.continual_gathering_policy; + _continualGatheringPolicy = + [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; _disableIPV6OnWiFi = config.disable_ipv6_on_wifi; _maxIPv6Networks = config.max_ipv6_networks; _disableLinkLocalNetworks = config.disable_link_local_networks; _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; - _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate; + _audioJitterBufferFastAccelerate = + config.audio_jitter_buffer_fast_accelerate; _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; _iceBackupCandidatePairPingInterval = config.ice_backup_candidate_pair_ping_interval; @@ -122,30 +127,34 @@ _iceCheckMinInterval = [NSNumber numberWithInt:*config.ice_check_min_interval]; } - _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics]; + _sdpSemantics = + [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics]; _turnCustomizer = config.turn_customizer; _activeResetSrtpParams = config.active_reset_srtp_params; if (config.crypto_options) { _cryptoOptions = [[RTC_OBJC_TYPE(RTCCryptoOptions) alloc] initWithSrtpEnableGcmCryptoSuites:config.crypto_options->srtp .enable_gcm_crypto_suites - srtpEnableAes128Sha1_32CryptoCipher:config.crypto_options->srtp - .enable_aes128_sha1_32_crypto_cipher - srtpEnableEncryptedRtpHeaderExtensions:config.crypto_options->srtp - .enable_encrypted_rtp_header_extensions + srtpEnableAes128Sha1_32CryptoCipher: + config.crypto_options->srtp.enable_aes128_sha1_32_crypto_cipher + srtpEnableEncryptedRtpHeaderExtensions: + config.crypto_options->srtp.enable_encrypted_rtp_header_extensions sframeRequireFrameEncryption:config.crypto_options->sframe .require_frame_encryption]; } - _turnLoggingId = [NSString stringWithUTF8String:config.turn_logging_id.c_str()]; + _turnLoggingId = + [NSString stringWithUTF8String:config.turn_logging_id.c_str()]; _rtcpAudioReportIntervalMs = config.audio_rtcp_report_interval_ms(); _rtcpVideoReportIntervalMs = config.video_rtcp_report_interval_ms(); _enableImplicitRollback = config.enable_implicit_rollback; _offerExtmapAllowMixed = config.offer_extmap_allow_mixed; _iceCheckIntervalStrongConnectivity = config.ice_check_interval_strong_connectivity.has_value() ? - [NSNumber numberWithInt:*config.ice_check_interval_strong_connectivity] : + [NSNumber + numberWithInt:*config.ice_check_interval_strong_connectivity] : nil; - _iceCheckIntervalWeakConnectivity = config.ice_check_interval_weak_connectivity.has_value() ? + _iceCheckIntervalWeakConnectivity = + config.ice_check_interval_weak_connectivity.has_value() ? [NSNumber numberWithInt:*config.ice_check_interval_weak_connectivity] : nil; _iceUnwritableTimeout = config.ice_unwritable_timeout.has_value() ? @@ -162,35 +171,39 @@ } - (NSString *)description { - static NSString *formatString = @"RTC_OBJC_TYPE(RTCConfiguration): " - @"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n" - @"%d\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n}\n"; + static NSString *formatString = + @"RTC_OBJC_TYPE(RTCConfiguration): " + @"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n" + @"%d\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n}\n"; return [NSString - stringWithFormat:formatString, - _iceServers, - [[self class] stringForTransportPolicy:_iceTransportPolicy], - [[self class] stringForBundlePolicy:_bundlePolicy], - [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], - [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], - [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], - [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy], - [[self class] stringForSdpSemantics:_sdpSemantics], - _audioJitterBufferMaxPackets, - _audioJitterBufferFastAccelerate, - _iceConnectionReceivingTimeout, - _iceBackupCandidatePairPingInterval, - _iceCandidatePoolSize, - _shouldPruneTurnPorts, - _shouldPresumeWritableWhenFullyRelayed, - _shouldSurfaceIceCandidatesOnIceTransportTypeChanged, - _iceCheckMinInterval, - _disableLinkLocalNetworks, - _disableIPV6OnWiFi, - _maxIPv6Networks, - _activeResetSrtpParams, - _enableDscp, - _enableImplicitRollback]; + stringWithFormat: + formatString, + _iceServers, + [[self class] stringForTransportPolicy:_iceTransportPolicy], + [[self class] stringForBundlePolicy:_bundlePolicy], + [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], + [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], + [[self class] + stringForCandidateNetworkPolicy:_candidateNetworkPolicy], + [[self class] + stringForContinualGatheringPolicy:_continualGatheringPolicy], + [[self class] stringForSdpSemantics:_sdpSemantics], + _audioJitterBufferMaxPackets, + _audioJitterBufferFastAccelerate, + _iceConnectionReceivingTimeout, + _iceBackupCandidatePairPingInterval, + _iceCandidatePoolSize, + _shouldPruneTurnPorts, + _shouldPresumeWritableWhenFullyRelayed, + _shouldSurfaceIceCandidatesOnIceTransportTypeChanged, + _iceCheckMinInterval, + _disableLinkLocalNetworks, + _disableIPV6OnWiFi, + _maxIPv6Networks, + _activeResetSrtpParams, + _enableDscp, + _enableImplicitRollback]; } #pragma mark - Private @@ -215,14 +228,14 @@ [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; nativeConfig->candidate_network_policy = [[self class] nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy]; - nativeConfig->continual_gathering_policy = - [[self class] nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; + nativeConfig->continual_gathering_policy = [[self class] + nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; nativeConfig->disable_ipv6_on_wifi = _disableIPV6OnWiFi; nativeConfig->max_ipv6_networks = _maxIPv6Networks; nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks; nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; nativeConfig->audio_jitter_buffer_fast_accelerate = - _audioJitterBufferFastAccelerate ? true : false; + _audioJitterBufferFastAccelerate ? true : false; nativeConfig->ice_connection_receiving_timeout = _iceConnectionReceivingTimeout; nativeConfig->ice_backup_candidate_pair_ping_interval = @@ -234,8 +247,10 @@ RTC_LOG(LS_INFO) << "Have configured cert - using it."; std::string pem_private_key = [[_certificate private_key] UTF8String]; std::string pem_certificate = [[_certificate certificate] UTF8String]; - rtc::RTCCertificatePEM pem = rtc::RTCCertificatePEM(pem_private_key, pem_certificate); - rtc::scoped_refptr certificate = rtc::RTCCertificate::FromPEM(pem); + rtc::RTCCertificatePEM pem = + rtc::RTCCertificatePEM(pem_private_key, pem_certificate); + rtc::scoped_refptr certificate = + rtc::RTCCertificate::FromPEM(pem); RTC_LOG(LS_INFO) << "Created cert from PEM strings."; if (!certificate) { RTC_LOG(LS_ERROR) << "Failed to generate certificate from PEM."; @@ -247,8 +262,8 @@ // Generate non-default certificate. if (keyType != rtc::KT_DEFAULT) { rtc::scoped_refptr certificate = - rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType), - std::optional()); + rtc::RTCCertificateGenerator::GenerateCertificate( + rtc::KeyParams(keyType), std::optional()); if (!certificate) { RTCLogError(@"Failed to generate certificate."); return nullptr; @@ -263,13 +278,16 @@ nativeConfig->surface_ice_candidates_on_ice_transport_type_changed = _shouldSurfaceIceCandidatesOnIceTransportTypeChanged ? true : false; if (_iceCheckMinInterval != nil) { - nativeConfig->ice_check_min_interval = std::optional(_iceCheckMinInterval.intValue); + nativeConfig->ice_check_min_interval = + std::optional(_iceCheckMinInterval.intValue); } - nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics]; + nativeConfig->sdp_semantics = + [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics]; if (_turnCustomizer) { nativeConfig->turn_customizer = _turnCustomizer; } - nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false; + nativeConfig->active_reset_srtp_params = + _activeResetSrtpParams ? true : false; if (_cryptoOptions) { webrtc::CryptoOptions nativeCryptoOptions; nativeCryptoOptions.srtp.enable_gcm_crypto_suites = @@ -280,7 +298,8 @@ _cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions ? true : false; nativeCryptoOptions.sframe.require_frame_encryption = _cryptoOptions.sframeRequireFrameEncryption ? true : false; - nativeConfig->crypto_options = std::optional(nativeCryptoOptions); + nativeConfig->crypto_options = + std::optional(nativeCryptoOptions); } nativeConfig->turn_logging_id = [_turnLoggingId UTF8String]; nativeConfig->set_audio_rtcp_report_interval_ms(_rtcpAudioReportIntervalMs); @@ -296,13 +315,16 @@ std::optional(_iceCheckIntervalWeakConnectivity.intValue); } if (_iceUnwritableTimeout != nil) { - nativeConfig->ice_unwritable_timeout = std::optional(_iceUnwritableTimeout.intValue); + nativeConfig->ice_unwritable_timeout = + std::optional(_iceUnwritableTimeout.intValue); } if (_iceUnwritableMinChecks != nil) { - nativeConfig->ice_unwritable_min_checks = std::optional(_iceUnwritableMinChecks.intValue); + nativeConfig->ice_unwritable_min_checks = + std::optional(_iceUnwritableMinChecks.intValue); } if (_iceInactiveTimeout != nil) { - nativeConfig->ice_inactive_timeout = std::optional(_iceInactiveTimeout.intValue); + nativeConfig->ice_inactive_timeout = + std::optional(_iceInactiveTimeout.intValue); } return nativeConfig.release(); } @@ -512,7 +534,8 @@ } } -+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics { ++ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics: + (RTCSdpSemantics)sdpSemantics { switch (sdpSemantics) { case RTCSdpSemanticsPlanB: return webrtc::SdpSemantics::kPlanB_DEPRECATED; @@ -521,7 +544,8 @@ } } -+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics { ++ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics: + (webrtc::SdpSemantics)sdpSemantics { switch (sdpSemantics) { case webrtc::SdpSemantics::kPlanB_DEPRECATED: return RTCSdpSemanticsPlanB; diff --git a/sdk/objc/api/peerconnection/RTCCryptoOptions.h b/sdk/objc/api/peerconnection/RTCCryptoOptions.h index d4820163d5..cb4ddd9c5d 100644 --- a/sdk/objc/api/peerconnection/RTCCryptoOptions.h +++ b/sdk/objc/api/peerconnection/RTCCryptoOptions.h @@ -50,10 +50,13 @@ RTC_OBJC_EXPORT * Initializes CryptoOptions with all possible options set explicitly. This * is done when converting from a native RTCConfiguration.crypto_options. */ -- (instancetype)initWithSrtpEnableGcmCryptoSuites:(BOOL)srtpEnableGcmCryptoSuites - srtpEnableAes128Sha1_32CryptoCipher:(BOOL)srtpEnableAes128Sha1_32CryptoCipher - srtpEnableEncryptedRtpHeaderExtensions:(BOOL)srtpEnableEncryptedRtpHeaderExtensions - sframeRequireFrameEncryption:(BOOL)sframeRequireFrameEncryption +- (instancetype) + initWithSrtpEnableGcmCryptoSuites:(BOOL)srtpEnableGcmCryptoSuites + srtpEnableAes128Sha1_32CryptoCipher: + (BOOL)srtpEnableAes128Sha1_32CryptoCipher + srtpEnableEncryptedRtpHeaderExtensions: + (BOOL)srtpEnableEncryptedRtpHeaderExtensions + sframeRequireFrameEncryption:(BOOL)sframeRequireFrameEncryption NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; diff --git a/sdk/objc/api/peerconnection/RTCCryptoOptions.mm b/sdk/objc/api/peerconnection/RTCCryptoOptions.mm index 3789f7af7b..0b777b59e9 100644 --- a/sdk/objc/api/peerconnection/RTCCryptoOptions.mm +++ b/sdk/objc/api/peerconnection/RTCCryptoOptions.mm @@ -13,19 +13,25 @@ @implementation RTC_OBJC_TYPE (RTCCryptoOptions) @synthesize srtpEnableGcmCryptoSuites = _srtpEnableGcmCryptoSuites; -@synthesize srtpEnableAes128Sha1_32CryptoCipher = _srtpEnableAes128Sha1_32CryptoCipher; -@synthesize srtpEnableEncryptedRtpHeaderExtensions = _srtpEnableEncryptedRtpHeaderExtensions; +@synthesize srtpEnableAes128Sha1_32CryptoCipher = + _srtpEnableAes128Sha1_32CryptoCipher; +@synthesize srtpEnableEncryptedRtpHeaderExtensions = + _srtpEnableEncryptedRtpHeaderExtensions; @synthesize sframeRequireFrameEncryption = _sframeRequireFrameEncryption; -- (instancetype)initWithSrtpEnableGcmCryptoSuites:(BOOL)srtpEnableGcmCryptoSuites - srtpEnableAes128Sha1_32CryptoCipher:(BOOL)srtpEnableAes128Sha1_32CryptoCipher - srtpEnableEncryptedRtpHeaderExtensions:(BOOL)srtpEnableEncryptedRtpHeaderExtensions - sframeRequireFrameEncryption:(BOOL)sframeRequireFrameEncryption { +- (instancetype) + initWithSrtpEnableGcmCryptoSuites:(BOOL)srtpEnableGcmCryptoSuites + srtpEnableAes128Sha1_32CryptoCipher: + (BOOL)srtpEnableAes128Sha1_32CryptoCipher + srtpEnableEncryptedRtpHeaderExtensions: + (BOOL)srtpEnableEncryptedRtpHeaderExtensions + sframeRequireFrameEncryption:(BOOL)sframeRequireFrameEncryption { self = [super init]; if (self) { _srtpEnableGcmCryptoSuites = srtpEnableGcmCryptoSuites; _srtpEnableAes128Sha1_32CryptoCipher = srtpEnableAes128Sha1_32CryptoCipher; - _srtpEnableEncryptedRtpHeaderExtensions = srtpEnableEncryptedRtpHeaderExtensions; + _srtpEnableEncryptedRtpHeaderExtensions = + srtpEnableEncryptedRtpHeaderExtensions; _sframeRequireFrameEncryption = sframeRequireFrameEncryption; } return self; diff --git a/sdk/objc/api/peerconnection/RTCDataChannel+Private.h b/sdk/objc/api/peerconnection/RTCDataChannel+Private.h index d903b0c002..9b42b0e25a 100644 --- a/sdk/objc/api/peerconnection/RTCDataChannel+Private.h +++ b/sdk/objc/api/peerconnection/RTCDataChannel+Private.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN () /** - * The native DataBuffer representation of this RTCDatabuffer object. This is - * needed to pass to the underlying C++ APIs. + * The native DataBuffer representation of this RTCDatabuffer object. This + * is needed to pass to the underlying C++ APIs. */ @property(nonatomic, readonly) const webrtc::DataBuffer *nativeDataBuffer; @@ -37,7 +37,8 @@ NS_ASSUME_NONNULL_BEGIN /** Initialize an RTCDataChannel from a native DataChannelInterface. */ - (instancetype)initWithFactory : (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory nativeDataChannel - : (rtc::scoped_refptr)nativeDataChannel NS_DESIGNATED_INITIALIZER; + : (rtc::scoped_refptr) + nativeDataChannel NS_DESIGNATED_INITIALIZER; + (webrtc::DataChannelInterface::DataState)nativeDataChannelStateForState: (RTCDataChannelState)state; diff --git a/sdk/objc/api/peerconnection/RTCDataChannel.h b/sdk/objc/api/peerconnection/RTCDataChannel.h index 54f6642cad..d08bd4903b 100644 --- a/sdk/objc/api/peerconnection/RTCDataChannel.h +++ b/sdk/objc/api/peerconnection/RTCDataChannel.h @@ -40,7 +40,8 @@ RTC_OBJC_EXPORT (RTCDataChannelDelegate) /** The data channel state changed. */ - - (void)dataChannelDidChangeState : (RTC_OBJC_TYPE(RTCDataChannel) *)dataChannel; + - (void)dataChannelDidChangeState + : (RTC_OBJC_TYPE(RTCDataChannel) *)dataChannel; /** The data channel successfully received a data buffer. */ - (void)dataChannel:(RTC_OBJC_TYPE(RTCDataChannel) *)dataChannel @@ -77,7 +78,8 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) BOOL isOrdered; /** Deprecated. Use maxPacketLifeTime. */ -@property(nonatomic, readonly) NSUInteger maxRetransmitTime DEPRECATED_ATTRIBUTE; +@property(nonatomic, readonly) + NSUInteger maxRetransmitTime DEPRECATED_ATTRIBUTE; /** * The length of the time window (in milliseconds) during which transmissions diff --git a/sdk/objc/api/peerconnection/RTCDataChannel.mm b/sdk/objc/api/peerconnection/RTCDataChannel.mm index 40a4d8e986..7d0aaa82a3 100644 --- a/sdk/objc/api/peerconnection/RTCDataChannel.mm +++ b/sdk/objc/api/peerconnection/RTCDataChannel.mm @@ -18,17 +18,19 @@ namespace webrtc { class DataChannelDelegateAdapter : public DataChannelObserver { public: - DataChannelDelegateAdapter(RTC_OBJC_TYPE(RTCDataChannel) * channel) { channel_ = channel; } + DataChannelDelegateAdapter(RTC_OBJC_TYPE(RTCDataChannel) * channel) { + channel_ = channel; + } void OnStateChange() override { [channel_.delegate dataChannelDidChangeState:channel_]; } - void OnMessage(const DataBuffer& buffer) override { + void OnMessage(const DataBuffer &buffer) override { RTC_OBJC_TYPE(RTCDataBuffer) *data_buffer = [[RTC_OBJC_TYPE(RTCDataBuffer) alloc] initWithNativeBuffer:buffer]; [channel_.delegate dataChannel:channel_ - didReceiveMessageWithBuffer:data_buffer]; + didReceiveMessageWithBuffer:data_buffer]; } void OnBufferedAmountChange(uint64_t previousAmount) override { @@ -42,7 +44,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver { private: __weak RTC_OBJC_TYPE(RTCDataChannel) * channel_; }; -} +} // namespace webrtc @implementation RTC_OBJC_TYPE (RTCDataBuffer) { std::unique_ptr _dataBuffer; @@ -52,8 +54,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { NSParameterAssert(data); self = [super init]; if (self) { - rtc::CopyOnWriteBuffer buffer( - reinterpret_cast(data.bytes), data.length); + rtc::CopyOnWriteBuffer buffer(reinterpret_cast(data.bytes), + data.length); _dataBuffer.reset(new webrtc::DataBuffer(buffer, isBinary)); } return self; @@ -70,7 +72,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver { #pragma mark - Private -- (instancetype)initWithNativeBuffer:(const webrtc::DataBuffer&)nativeBuffer { +- (instancetype)initWithNativeBuffer:(const webrtc::DataBuffer &)nativeBuffer { self = [super init]; if (self) { _dataBuffer.reset(new webrtc::DataBuffer(nativeBuffer)); @@ -140,8 +142,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { } - (RTCDataChannelState)readyState { - return [[self class] dataChannelStateForNativeState: - _nativeDataChannel->state()]; + return + [[self class] dataChannelStateForNativeState:_nativeDataChannel->state()]; } - (uint64_t)bufferedAmount { @@ -157,17 +159,19 @@ class DataChannelDelegateAdapter : public DataChannelObserver { } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCDataChannel):\n%ld\n%@\n%@", - (long)self.channelId, - self.label, - [[self class] stringForState:self.readyState]]; + return + [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCDataChannel):\n%ld\n%@\n%@", + (long)self.channelId, + self.label, + [[self class] stringForState:self.readyState]]; } #pragma mark - Private -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeDataChannel: - (rtc::scoped_refptr)nativeDataChannel { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeDataChannel: + (rtc::scoped_refptr)nativeDataChannel { NSParameterAssert(nativeDataChannel); self = [super init]; if (self) { @@ -179,8 +183,8 @@ class DataChannelDelegateAdapter : public DataChannelObserver { return self; } -+ (webrtc::DataChannelInterface::DataState) - nativeDataChannelStateForState:(RTCDataChannelState)state { ++ (webrtc::DataChannelInterface::DataState)nativeDataChannelStateForState: + (RTCDataChannelState)state { switch (state) { case RTCDataChannelStateConnecting: return webrtc::DataChannelInterface::DataState::kConnecting; diff --git a/sdk/objc/api/peerconnection/RTCDataChannelConfiguration+Private.h b/sdk/objc/api/peerconnection/RTCDataChannelConfiguration+Private.h index 5aef10fcef..59e115cf69 100644 --- a/sdk/objc/api/peerconnection/RTCDataChannelConfiguration+Private.h +++ b/sdk/objc/api/peerconnection/RTCDataChannelConfiguration+Private.h @@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCDataChannelConfiguration) () - @property(nonatomic, readonly) webrtc::DataChannelInit nativeDataChannelInit; + @property(nonatomic, + readonly) webrtc::DataChannelInit nativeDataChannelInit; @end diff --git a/sdk/objc/api/peerconnection/RTCDtmfSender+Private.h b/sdk/objc/api/peerconnection/RTCDtmfSender+Private.h index 7f70887e51..3ae90ce77c 100644 --- a/sdk/objc/api/peerconnection/RTCDtmfSender+Private.h +++ b/sdk/objc/api/peerconnection/RTCDtmfSender+Private.h @@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN /** Initialize an RTCDtmfSender with a native DtmfSenderInterface. */ - (instancetype)initWithNativeDtmfSender: - (rtc::scoped_refptr)nativeDtmfSender NS_DESIGNATED_INITIALIZER; + (rtc::scoped_refptr)nativeDtmfSender + NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCDtmfSender.h b/sdk/objc/api/peerconnection/RTCDtmfSender.h index 1035f16aa9..c860bc9978 100644 --- a/sdk/objc/api/peerconnection/RTCDtmfSender.h +++ b/sdk/objc/api/peerconnection/RTCDtmfSender.h @@ -20,8 +20,9 @@ RTC_OBJC_EXPORT /** * Returns true if this RTCDtmfSender is capable of sending DTMF. Otherwise - * returns false. To be able to send DTMF, the associated RTCRtpSender must be - * able to send packets, and a "telephone-event" codec must be negotiated. + * returns false. To be able to send DTMF, the associated RTCRtpSender must + * be able to send packets, and a "telephone-event" codec must be + * negotiated. */ @property(nonatomic, readonly) BOOL canInsertDtmf; @@ -54,15 +55,16 @@ RTC_OBJC_EXPORT - (nonnull NSString *)remainingTones; /** - * The current tone duration value. This value will be the value last set via the - * insertDtmf method, or the default value of 100 ms if insertDtmf was never called. + * The current tone duration value. This value will be the value last set via + * the insertDtmf method, or the default value of 100 ms if insertDtmf was never + * called. */ - (NSTimeInterval)duration; /** - * The current value of the between-tone gap. This value will be the value last set - * via the insertDtmf() method, or the default value of 50 ms if insertDtmf() was never - * called. + * The current value of the between-tone gap. This value will be the value last + * set via the insertDtmf() method, or the default value of 50 ms if + * insertDtmf() was never called. */ - (NSTimeInterval)interToneGap; diff --git a/sdk/objc/api/peerconnection/RTCDtmfSender.mm b/sdk/objc/api/peerconnection/RTCDtmfSender.mm index 88a5505d51..484793e377 100644 --- a/sdk/objc/api/peerconnection/RTCDtmfSender.mm +++ b/sdk/objc/api/peerconnection/RTCDtmfSender.mm @@ -30,7 +30,8 @@ RTC_DCHECK(tones != nil); int durationMs = static_cast(duration * rtc::kNumMillisecsPerSec); - int interToneGapMs = static_cast(interToneGap * rtc::kNumMillisecsPerSec); + int interToneGapMs = + static_cast(interToneGap * rtc::kNumMillisecsPerSec); return _nativeDtmfSender->InsertDtmf( [NSString stdStringForString:tones], durationMs, interToneGapMs); } @@ -40,7 +41,8 @@ } - (NSTimeInterval)duration { - return static_cast(_nativeDtmfSender->duration()) / rtc::kNumMillisecsPerSec; + return static_cast(_nativeDtmfSender->duration()) / + rtc::kNumMillisecsPerSec; } - (NSTimeInterval)interToneGap { @@ -49,11 +51,13 @@ } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCDtmfSender) {\n remainingTones: %@\n " - @"duration: %f sec\n interToneGap: %f sec\n}", - [self remainingTones], - [self duration], - [self interToneGap]]; + return + [NSString stringWithFormat: + @"RTC_OBJC_TYPE(RTCDtmfSender) {\n remainingTones: %@\n " + @"duration: %f sec\n interToneGap: %f sec\n}", + [self remainingTones], + [self duration], + [self interToneGap]]; } #pragma mark - Private @@ -63,13 +67,14 @@ } - (instancetype)initWithNativeDtmfSender: - (rtc::scoped_refptr)nativeDtmfSender { + (rtc::scoped_refptr)nativeDtmfSender { NSParameterAssert(nativeDtmfSender); self = [super init]; if (self) { _nativeDtmfSender = nativeDtmfSender; - RTCLogInfo( - @"RTC_OBJC_TYPE(RTCDtmfSender)(%p): created DTMF sender: %@", self, self.description); + RTCLogInfo(@"RTC_OBJC_TYPE(RTCDtmfSender)(%p): created DTMF sender: %@", + self, + self.description); } return self; } diff --git a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.h b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.h index a078b0aded..e1daec5cae 100644 --- a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.h +++ b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCEncodedImage) (Private) - - (instancetype)initWithNativeEncodedImage : (const webrtc::EncodedImage &)encodedImage; + - (instancetype)initWithNativeEncodedImage + : (const webrtc::EncodedImage &)encodedImage; - (webrtc::EncodedImage)nativeEncodedImage; @end diff --git a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm index 43fb1b1167..b08015c251 100644 --- a/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm +++ b/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm @@ -15,13 +15,16 @@ #include "rtc_base/numerics/safe_conversions.h" namespace { -// An implementation of EncodedImageBufferInterface that doesn't perform any copies. +// An implementation of EncodedImageBufferInterface that doesn't perform any +// copies. class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { public: static rtc::scoped_refptr Create(NSData *data) { return rtc::make_ref_counted(data); } - const uint8_t *data() const override { return static_cast(data_.bytes); } + const uint8_t *data() const override { + return static_cast(data_.bytes); + } // TODO(bugs.webrtc.org/9378): delete this non-const data method. uint8_t *data() override { return const_cast(static_cast(data_.bytes)); @@ -34,12 +37,13 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { NSData *data_; }; -} +} // namespace -// A simple wrapper around webrtc::EncodedImageBufferInterface to make it usable with associated -// objects. +// A simple wrapper around webrtc::EncodedImageBufferInterface to make it usable +// with associated objects. @interface RTCWrappedEncodedImageBuffer : NSObject -@property(nonatomic) rtc::scoped_refptr buffer; +@property(nonatomic) rtc::scoped_refptr + buffer; - (instancetype)initWithEncodedImageBuffer: (rtc::scoped_refptr)buffer; @end @@ -64,7 +68,8 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { return wrappedBuffer.buffer; } -- (void)setEncodedData:(rtc::scoped_refptr)buffer { +- (void)setEncodedData: + (rtc::scoped_refptr)buffer { return objc_setAssociatedObject( self, @selector(encodedData), @@ -72,18 +77,20 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (instancetype)initWithNativeEncodedImage:(const webrtc::EncodedImage &)encodedImage { +- (instancetype)initWithNativeEncodedImage: + (const webrtc::EncodedImage &)encodedImage { 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. + // 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(); // Wrap the buffer in NSData without copying, do not take ownership. self.buffer = [NSData dataWithBytesNoCopy:self.encodedData->data() length:encodedImage.size() freeWhenDone:NO]; self.encodedWidth = rtc::dchecked_cast(encodedImage._encodedWidth); - self.encodedHeight = rtc::dchecked_cast(encodedImage._encodedHeight); + self.encodedHeight = + rtc::dchecked_cast(encodedImage._encodedHeight); self.timeStamp = encodedImage.RtpTimestamp(); self.captureTimeMs = encodedImage.capture_time_ms_; self.ntpTimeMs = encodedImage.ntp_time_ms_; @@ -93,7 +100,8 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { self.frameType = static_cast(encodedImage._frameType); self.rotation = static_cast(encodedImage.rotation_); self.qp = @(encodedImage.qp_); - self.contentType = (encodedImage.content_type_ == webrtc::VideoContentType::SCREENSHARE) ? + self.contentType = + (encodedImage.content_type_ == webrtc::VideoContentType::SCREENSHARE) ? RTCVideoContentTypeScreenshare : RTCVideoContentTypeUnspecified; } @@ -111,7 +119,8 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { } encodedImage.set_size(self.buffer.length); encodedImage._encodedWidth = rtc::dchecked_cast(self.encodedWidth); - encodedImage._encodedHeight = rtc::dchecked_cast(self.encodedHeight); + encodedImage._encodedHeight = + rtc::dchecked_cast(self.encodedHeight); encodedImage.SetRtpTimestamp(self.timeStamp); encodedImage.capture_time_ms_ = self.captureTimeMs; encodedImage.ntp_time_ms_ = self.ntpTimeMs; @@ -121,7 +130,8 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { encodedImage._frameType = webrtc::VideoFrameType(self.frameType); encodedImage.rotation_ = webrtc::VideoRotation(self.rotation); encodedImage.qp_ = self.qp ? self.qp.intValue : -1; - encodedImage.content_type_ = (self.contentType == RTCVideoContentTypeScreenshare) ? + encodedImage.content_type_ = + (self.contentType == RTCVideoContentTypeScreenshare) ? webrtc::VideoContentType::SCREENSHARE : webrtc::VideoContentType::UNSPECIFIED; diff --git a/sdk/objc/api/peerconnection/RTCFieldTrials.h b/sdk/objc/api/peerconnection/RTCFieldTrials.h index b92e70163a..a61a2b3f98 100644 --- a/sdk/objc/api/peerconnection/RTCFieldTrials.h +++ b/sdk/objc/api/peerconnection/RTCFieldTrials.h @@ -12,7 +12,8 @@ #import "sdk/objc/base/RTCMacros.h" -/** The only valid value for the following if set is kRTCFieldTrialEnabledValue. */ +/** The only valid value for the following if set is kRTCFieldTrialEnabledValue. + */ RTC_EXTERN NSString *const kRTCFieldTrialAudioForceABWENoTWCCKey; RTC_EXTERN NSString *const kRTCFieldTrialFlexFec03AdvertisedKey; RTC_EXTERN NSString *const kRTCFieldTrialFlexFec03Key; @@ -27,4 +28,5 @@ RTC_EXTERN NSString *const kRTCFieldTrialEnabledValue; * values. See above for valid keys and values. Must be called before any other * call into WebRTC. See: webrtc/system_wrappers/include/field_trial.h */ -RTC_EXTERN void RTCInitFieldTrialDictionary(NSDictionary *fieldTrials); +RTC_EXTERN void RTCInitFieldTrialDictionary( + NSDictionary *fieldTrials); diff --git a/sdk/objc/api/peerconnection/RTCFieldTrials.mm b/sdk/objc/api/peerconnection/RTCFieldTrials.mm index 193da9e4f7..80619b3291 100644 --- a/sdk/objc/api/peerconnection/RTCFieldTrials.mm +++ b/sdk/objc/api/peerconnection/RTCFieldTrials.mm @@ -16,29 +16,35 @@ #include "system_wrappers/include/field_trial.h" -NSString *const kRTCFieldTrialAudioForceABWENoTWCCKey = @"WebRTC-Audio-ABWENoTWCC"; -NSString * const kRTCFieldTrialFlexFec03AdvertisedKey = @"WebRTC-FlexFEC-03-Advertised"; -NSString * const kRTCFieldTrialFlexFec03Key = @"WebRTC-FlexFEC-03"; -NSString * const kRTCFieldTrialH264HighProfileKey = @"WebRTC-H264HighProfile"; -NSString * const kRTCFieldTrialMinimizeResamplingOnMobileKey = +NSString *const kRTCFieldTrialAudioForceABWENoTWCCKey = + @"WebRTC-Audio-ABWENoTWCC"; +NSString *const kRTCFieldTrialFlexFec03AdvertisedKey = + @"WebRTC-FlexFEC-03-Advertised"; +NSString *const kRTCFieldTrialFlexFec03Key = @"WebRTC-FlexFEC-03"; +NSString *const kRTCFieldTrialH264HighProfileKey = @"WebRTC-H264HighProfile"; +NSString *const kRTCFieldTrialMinimizeResamplingOnMobileKey = @"WebRTC-Audio-MinimizeResamplingOnMobile"; -NSString *const kRTCFieldTrialUseNWPathMonitor = @"WebRTC-Network-UseNWPathMonitor"; -NSString * const kRTCFieldTrialEnabledValue = @"Enabled"; +NSString *const kRTCFieldTrialUseNWPathMonitor = + @"WebRTC-Network-UseNWPathMonitor"; +NSString *const kRTCFieldTrialEnabledValue = @"Enabled"; // InitFieldTrialsFromString stores the char*, so the char array must outlive // the application. static char *gFieldTrialInitString = nullptr; -void RTCInitFieldTrialDictionary(NSDictionary *fieldTrials) { +void RTCInitFieldTrialDictionary( + NSDictionary *fieldTrials) { if (!fieldTrials) { RTCLogWarning(@"No fieldTrials provided."); return; } // Assemble the keys and values into the field trial string. - // We don't perform any extra format checking. That should be done by the underlying WebRTC calls. + // We don't perform any extra format checking. That should be done by the + // underlying WebRTC calls. NSMutableString *fieldTrialInitString = [NSMutableString string]; for (NSString *key in fieldTrials) { - NSString *fieldTrialEntry = [NSString stringWithFormat:@"%@/%@/", key, fieldTrials[key]]; + NSString *fieldTrialEntry = + [NSString stringWithFormat:@"%@/%@/", key, fieldTrials[key]]; [fieldTrialInitString appendString:fieldTrialEntry]; } size_t len = fieldTrialInitString.length + 1; diff --git a/sdk/objc/api/peerconnection/RTCFileLogger.h b/sdk/objc/api/peerconnection/RTCFileLogger.h index d42dcd33c4..37fe366667 100644 --- a/sdk/objc/api/peerconnection/RTCFileLogger.h +++ b/sdk/objc/api/peerconnection/RTCFileLogger.h @@ -52,11 +52,13 @@ RTC_OBJC_EXPORT - (instancetype)init; // Create file logger with default rotation type. -- (instancetype)initWithDirPath:(NSString *)dirPath maxFileSize:(NSUInteger)maxFileSize; +- (instancetype)initWithDirPath:(NSString *)dirPath + maxFileSize:(NSUInteger)maxFileSize; - (instancetype)initWithDirPath:(NSString *)dirPath maxFileSize:(NSUInteger)maxFileSize - rotationType:(RTCFileLoggerRotationType)rotationType NS_DESIGNATED_INITIALIZER; + rotationType:(RTCFileLoggerRotationType)rotationType + NS_DESIGNATED_INITIALIZER; // Starts writing WebRTC logs to disk if not already started. Overwrites any // existing file(s). diff --git a/sdk/objc/api/peerconnection/RTCFileLogger.mm b/sdk/objc/api/peerconnection/RTCFileLogger.mm index ee61cda943..75968d2dbf 100644 --- a/sdk/objc/api/peerconnection/RTCFileLogger.mm +++ b/sdk/objc/api/peerconnection/RTCFileLogger.mm @@ -18,7 +18,7 @@ #include "rtc_base/logging.h" NSString *const kDefaultLogDirName = @"webrtc_logs"; -NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. +NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; @implementation RTC_OBJC_TYPE (RTCFileLogger) { @@ -38,8 +38,7 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; NSString *documentsDirPath = [paths firstObject]; NSString *defaultDirPath = [documentsDirPath stringByAppendingPathComponent:kDefaultLogDirName]; - return [self initWithDirPath:defaultDirPath - maxFileSize:kDefaultMaxFileSize]; + return [self initWithDirPath:defaultDirPath maxFileSize:kDefaultMaxFileSize]; } - (instancetype)initWithDirPath:(NSString *)dirPath @@ -96,13 +95,13 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; _maxFileSize / 10)); break; case RTCFileLoggerTypeCall: - _logSink.reset( - new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, - _maxFileSize)); + _logSink.reset(new rtc::CallSessionFileRotatingLogSink( + _dirPath.UTF8String, _maxFileSize)); break; } if (!_logSink->Init()) { - RTC_LOG(LS_ERROR) << "Failed to open log files at path: " << _dirPath.UTF8String; + RTC_LOG(LS_ERROR) << "Failed to open log files at path: " + << _dirPath.UTF8String; _logSink.reset(); return; } @@ -129,15 +128,16 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; if (_hasStarted) { return nil; } - NSMutableData* logData = [NSMutableData data]; + NSMutableData *logData = [NSMutableData data]; std::unique_ptr stream; - switch(_rotationType) { + switch (_rotationType) { case RTCFileLoggerTypeApp: - stream = std::make_unique(_dirPath.UTF8String, - kRTCFileLoggerRotatingLogPrefix); + stream = std::make_unique( + _dirPath.UTF8String, kRTCFileLoggerRotatingLogPrefix); break; case RTCFileLoggerTypeCall: - stream = std::make_unique(_dirPath.UTF8String); + stream = std::make_unique( + _dirPath.UTF8String); break; } size_t bufferSize = stream->GetSize(); @@ -146,7 +146,7 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; } // Allocate memory using malloc so we can pass it direcly to NSData without // copying. - std::unique_ptr buffer(static_cast(malloc(bufferSize))); + std::unique_ptr buffer(static_cast(malloc(bufferSize))); size_t read = stream->ReadAll(buffer.get(), bufferSize); logData = [[NSMutableData alloc] initWithBytesNoCopy:buffer.release() length:read]; diff --git a/sdk/objc/api/peerconnection/RTCIceCandidate+Private.h b/sdk/objc/api/peerconnection/RTCIceCandidate+Private.h index 409e16b608..8399877838 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidate+Private.h +++ b/sdk/objc/api/peerconnection/RTCIceCandidate+Private.h @@ -23,13 +23,15 @@ NS_ASSUME_NONNULL_BEGIN * The native IceCandidateInterface representation of this RTCIceCandidate * object. This is needed to pass to the underlying C++ APIs. */ - @property(nonatomic, readonly) std::unique_ptr nativeCandidate; + @property(nonatomic, readonly) + std::unique_ptr nativeCandidate; /** * Initialize an RTCIceCandidate from a native IceCandidateInterface. No * ownership is taken of the native candidate. */ -- (instancetype)initWithNativeCandidate:(const webrtc::IceCandidateInterface *)candidate; +- (instancetype)initWithNativeCandidate: + (const webrtc::IceCandidateInterface *)candidate; @end diff --git a/sdk/objc/api/peerconnection/RTCIceCandidate.h b/sdk/objc/api/peerconnection/RTCIceCandidate.h index 8836e68d3b..d489b92a60 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidate.h +++ b/sdk/objc/api/peerconnection/RTCIceCandidate.h @@ -42,7 +42,8 @@ RTC_OBJC_EXPORT */ - (instancetype)initWithSdp:(NSString *)sdp sdpMLineIndex:(int)sdpMLineIndex - sdpMid:(nullable NSString *)sdpMid NS_DESIGNATED_INITIALIZER; + sdpMid:(nullable NSString *)sdpMid + NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCIceCandidate.mm b/sdk/objc/api/peerconnection/RTCIceCandidate.mm index 131c31993c..241af297e7 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidate.mm +++ b/sdk/objc/api/peerconnection/RTCIceCandidate.mm @@ -36,11 +36,12 @@ } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCIceCandidate):\n%@\n%d\n%@\n%@", - _sdpMid, - _sdpMLineIndex, - _sdp, - _serverUrl]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCIceCandidate):\n%@\n%d\n%@\n%@", + _sdpMid, + _sdpMLineIndex, + _sdp, + _serverUrl]; } #pragma mark - Private @@ -55,7 +56,8 @@ [self initWithSdp:[NSString stringForStdString:sdp] sdpMLineIndex:candidate->sdp_mline_index() sdpMid:[NSString stringForStdString:candidate->sdp_mid()]]; - rtcCandidate->_serverUrl = [NSString stringForStdString:candidate->server_url()]; + rtcCandidate->_serverUrl = + [NSString stringForStdString:candidate->server_url()]; return rtcCandidate; } diff --git a/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h b/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h index 8502da08a8..06962837fc 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h +++ b/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent+Private.h @@ -17,9 +17,9 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCIceCandidateErrorEvent) () - - (instancetype)initWithAddress : (const std::string&)address port : (const int)port url - : (const std::string&)url errorCode : (const int)errorCode errorText - : (const std::string&)errorText; + - (instancetype)initWithAddress : (const std::string&)address port + : (const int)port url : (const std::string&)url errorCode + : (const int)errorCode errorText : (const std::string&)errorText; @end diff --git a/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent.h b/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent.h index abb6d90b40..77fd2246ed 100644 --- a/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent.h +++ b/sdk/objc/api/peerconnection/RTCIceCandidateErrorEvent.h @@ -23,16 +23,19 @@ RTC_OBJC_EXPORT /** The port used to communicate with the STUN or TURN server. */ @property(nonatomic, readonly) int port; -/** The STUN or TURN URL that identifies the STUN or TURN server for which the failure occurred. */ +/** The STUN or TURN URL that identifies the STUN or TURN server for which the + * failure occurred. */ @property(nonatomic, readonly) NSString *url; -/** The numeric STUN error code returned by the STUN or TURN server. If no host candidate can reach - * the server, errorCode will be set to the value 701 which is outside the STUN error code range. - * This error is only fired once per server URL while in the RTCIceGatheringState of "gathering". */ +/** The numeric STUN error code returned by the STUN or TURN server. If no host + * candidate can reach the server, errorCode will be set to the value 701 which + * is outside the STUN error code range. This error is only fired once per + * server URL while in the RTCIceGatheringState of "gathering". */ @property(nonatomic, readonly) int errorCode; -/** The STUN reason text returned by the STUN or TURN server. If the server could not be reached, - * errorText will be set to an implementation-specific value providing details about the error. */ +/** The STUN reason text returned by the STUN or TURN server. If the server + * could not be reached, errorText will be set to an implementation-specific + * value providing details about the error. */ @property(nonatomic, readonly) NSString *errorText; - (instancetype)init NS_DESIGNATED_INITIALIZER; diff --git a/sdk/objc/api/peerconnection/RTCIceServer+Private.h b/sdk/objc/api/peerconnection/RTCIceServer+Private.h index 3eee819965..53a024c45d 100644 --- a/sdk/objc/api/peerconnection/RTCIceServer+Private.h +++ b/sdk/objc/api/peerconnection/RTCIceServer+Private.h @@ -21,10 +21,12 @@ NS_ASSUME_NONNULL_BEGIN * IceServer struct representation of this RTCIceServer object's data. * This is needed to pass to the underlying C++ APIs. */ - @property(nonatomic, readonly) webrtc::PeerConnectionInterface::IceServer nativeServer; + @property(nonatomic, + readonly) webrtc::PeerConnectionInterface::IceServer nativeServer; /** Initialize an RTCIceServer from a native IceServer. */ -- (instancetype)initWithNativeServer:(webrtc::PeerConnectionInterface::IceServer)nativeServer; +- (instancetype)initWithNativeServer: + (webrtc::PeerConnectionInterface::IceServer)nativeServer; @end diff --git a/sdk/objc/api/peerconnection/RTCIceServer.h b/sdk/objc/api/peerconnection/RTCIceServer.h index b3332317ed..9d66aed936 100644 --- a/sdk/objc/api/peerconnection/RTCIceServer.h +++ b/sdk/objc/api/peerconnection/RTCIceServer.h @@ -100,13 +100,14 @@ RTC_OBJC_EXPORT * optional credential, TLS cert policy, hostname, ALPN protocols and * elliptic curves. */ -- (instancetype)initWithURLStrings:(NSArray *)urlStrings - username:(nullable NSString *)username - credential:(nullable NSString *)credential - tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy - hostname:(nullable NSString *)hostname - tlsAlpnProtocols:(nullable NSArray *)tlsAlpnProtocols - tlsEllipticCurves:(nullable NSArray *)tlsEllipticCurves +- (instancetype) + initWithURLStrings:(NSArray *)urlStrings + username:(nullable NSString *)username + credential:(nullable NSString *)credential + tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy + hostname:(nullable NSString *)hostname + tlsAlpnProtocols:(nullable NSArray *)tlsAlpnProtocols + tlsEllipticCurves:(nullable NSArray *)tlsEllipticCurves NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCIceServer.mm b/sdk/objc/api/peerconnection/RTCIceServer.mm index d4b63306b6..96961e33d0 100644 --- a/sdk/objc/api/peerconnection/RTCIceServer.mm +++ b/sdk/objc/api/peerconnection/RTCIceServer.mm @@ -23,9 +23,7 @@ @synthesize tlsEllipticCurves = _tlsEllipticCurves; - (instancetype)initWithURLStrings:(NSArray *)urlStrings { - return [self initWithURLStrings:urlStrings - username:nil - credential:nil]; + return [self initWithURLStrings:urlStrings username:nil credential:nil]; } - (instancetype)initWithURLStrings:(NSArray *)urlStrings @@ -91,21 +89,25 @@ _credential = [credential copy]; _tlsCertPolicy = tlsCertPolicy; _hostname = [hostname copy]; - _tlsAlpnProtocols = [[NSArray alloc] initWithArray:tlsAlpnProtocols copyItems:YES]; - _tlsEllipticCurves = [[NSArray alloc] initWithArray:tlsEllipticCurves copyItems:YES]; + _tlsAlpnProtocols = [[NSArray alloc] initWithArray:tlsAlpnProtocols + copyItems:YES]; + _tlsEllipticCurves = [[NSArray alloc] initWithArray:tlsEllipticCurves + copyItems:YES]; } return self; } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCIceServer):\n%@\n%@\n%@\n%@\n%@\n%@\n%@", - _urlStrings, - _username, - _credential, - [self stringForTlsCertPolicy:_tlsCertPolicy], - _hostname, - _tlsAlpnProtocols, - _tlsEllipticCurves]; + return + [NSString stringWithFormat: + @"RTC_OBJC_TYPE(RTCIceServer):\n%@\n%@\n%@\n%@\n%@\n%@\n%@", + _urlStrings, + _username, + _credential, + [self stringForTlsCertPolicy:_tlsCertPolicy], + _hostname, + _tlsAlpnProtocols, + _tlsEllipticCurves]; } #pragma mark - Private @@ -126,19 +128,20 @@ iceServer.password = [NSString stdStringForString:_credential]; iceServer.hostname = [NSString stdStringForString:_hostname]; - [_tlsAlpnProtocols enumerateObjectsUsingBlock:^(NSString *proto, NSUInteger idx, BOOL *stop) { + [_tlsAlpnProtocols enumerateObjectsUsingBlock:^( + NSString *proto, NSUInteger idx, BOOL *stop) { iceServer.tls_alpn_protocols.push_back(proto.stdString); }]; - [_tlsEllipticCurves enumerateObjectsUsingBlock:^(NSString *curve, NSUInteger idx, BOOL *stop) { + [_tlsEllipticCurves enumerateObjectsUsingBlock:^( + NSString *curve, NSUInteger idx, BOOL *stop) { iceServer.tls_elliptic_curves.push_back(curve.stdString); }]; - [_urlStrings enumerateObjectsUsingBlock:^(NSString *url, - NSUInteger idx, - BOOL *stop) { - iceServer.urls.push_back(url.stdString); - }]; + [_urlStrings + enumerateObjectsUsingBlock:^(NSString *url, NSUInteger idx, BOOL *stop) { + iceServer.urls.push_back(url.stdString); + }]; switch (_tlsCertPolicy) { case RTCTlsCertPolicySecure: @@ -168,8 +171,8 @@ for (auto const &proto : nativeServer.tls_alpn_protocols) { [tlsAlpnProtocols addObject:[NSString stringForStdString:proto]]; } - NSMutableArray *tlsEllipticCurves = - [NSMutableArray arrayWithCapacity:nativeServer.tls_elliptic_curves.size()]; + NSMutableArray *tlsEllipticCurves = [NSMutableArray + arrayWithCapacity:nativeServer.tls_elliptic_curves.size()]; for (auto const &curve : nativeServer.tls_elliptic_curves) { [tlsEllipticCurves addObject:[NSString stringForStdString:curve]]; } diff --git a/sdk/objc/api/peerconnection/RTCLegacyStatsReport+Private.h b/sdk/objc/api/peerconnection/RTCLegacyStatsReport+Private.h index 7374b2b72f..098782d664 100644 --- a/sdk/objc/api/peerconnection/RTCLegacyStatsReport+Private.h +++ b/sdk/objc/api/peerconnection/RTCLegacyStatsReport+Private.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN () /** Initialize an RTCLegacyStatsReport object from a native StatsReport. */ - - (instancetype)initWithNativeReport : (const webrtc::StatsReport &)nativeReport; + - (instancetype)initWithNativeReport + : (const webrtc::StatsReport &)nativeReport; @end diff --git a/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm b/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm index 4b5c272b19..703b44c041 100644 --- a/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm +++ b/sdk/objc/api/peerconnection/RTCLegacyStatsReport.mm @@ -23,11 +23,12 @@ @synthesize values = _values; - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCLegacyStatsReport):\n%@\n%@\n%f\n%@", - _reportId, - _type, - _timestamp, - _values]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCLegacyStatsReport):\n%@\n%@\n%f\n%@", + _reportId, + _type, + _timestamp, + _values]; } #pragma mark - Private @@ -37,17 +38,16 @@ if (self) { _timestamp = nativeReport.timestamp(); _type = [NSString stringForStdString:nativeReport.TypeToString()]; - _reportId = [NSString stringForStdString: - nativeReport.id()->ToString()]; + _reportId = [NSString stringForStdString:nativeReport.id()->ToString()]; NSUInteger capacity = nativeReport.values().size(); NSMutableDictionary *values = [NSMutableDictionary dictionaryWithCapacity:capacity]; for (auto const &valuePair : nativeReport.values()) { - NSString *key = [NSString stringForStdString: - valuePair.second->display_name()]; - NSString *value = [NSString stringForStdString: - valuePair.second->ToString()]; + NSString *key = + [NSString stringForStdString:valuePair.second->display_name()]; + NSString *value = + [NSString stringForStdString:valuePair.second->ToString()]; // Not expecting duplicate keys. RTC_DCHECK(![values objectForKey:key]); diff --git a/sdk/objc/api/peerconnection/RTCMediaConstraints+Private.h b/sdk/objc/api/peerconnection/RTCMediaConstraints+Private.h index 97eee8307d..de472c0d73 100644 --- a/sdk/objc/api/peerconnection/RTCMediaConstraints+Private.h +++ b/sdk/objc/api/peerconnection/RTCMediaConstraints+Private.h @@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN () /** - * A MediaConstraints representation of this RTCMediaConstraints object. This is - * needed to pass to the underlying C++ APIs. + * A MediaConstraints representation of this RTCMediaConstraints object. + * This is needed to pass to the underlying C++ APIs. */ - (std::unique_ptr)nativeConstraints; diff --git a/sdk/objc/api/peerconnection/RTCMediaConstraints.h b/sdk/objc/api/peerconnection/RTCMediaConstraints.h index 15b9824a9b..3a92d4d5b2 100644 --- a/sdk/objc/api/peerconnection/RTCMediaConstraints.h +++ b/sdk/objc/api/peerconnection/RTCMediaConstraints.h @@ -36,10 +36,11 @@ RTC_OBJC_EXPORT - (instancetype)init NS_UNAVAILABLE; /** Initialize with mandatory and/or optional constraints. */ -- (instancetype) - initWithMandatoryConstraints:(nullable NSDictionary *)mandatory - optionalConstraints:(nullable NSDictionary *)optional - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithMandatoryConstraints: + (nullable NSDictionary *)mandatory + optionalConstraints: + (nullable NSDictionary *) + optional NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCMediaConstraints.mm b/sdk/objc/api/peerconnection/RTCMediaConstraints.mm index ac5fb64171..5158b5905b 100644 --- a/sdk/objc/api/peerconnection/RTCMediaConstraints.mm +++ b/sdk/objc/api/peerconnection/RTCMediaConstraints.mm @@ -17,7 +17,8 @@ NSString *const kRTCMediaConstraintsAudioNetworkAdaptorConfig = @(webrtc::MediaConstraints::kAudioNetworkAdaptorConfig); -NSString *const kRTCMediaConstraintsIceRestart = @(webrtc::MediaConstraints::kIceRestart); +NSString *const kRTCMediaConstraintsIceRestart = + @(webrtc::MediaConstraints::kIceRestart); NSString *const kRTCMediaConstraintsOfferToReceiveAudio = @(webrtc::MediaConstraints::kOfferToReceiveAudio); NSString *const kRTCMediaConstraintsOfferToReceiveVideo = @@ -25,8 +26,10 @@ NSString *const kRTCMediaConstraintsOfferToReceiveVideo = NSString *const kRTCMediaConstraintsVoiceActivityDetection = @(webrtc::MediaConstraints::kVoiceActivityDetection); -NSString *const kRTCMediaConstraintsValueTrue = @(webrtc::MediaConstraints::kValueTrue); -NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kValueFalse); +NSString *const kRTCMediaConstraintsValueTrue = + @(webrtc::MediaConstraints::kValueTrue); +NSString *const kRTCMediaConstraintsValueFalse = + @(webrtc::MediaConstraints::kValueFalse); @implementation RTC_OBJC_TYPE (RTCMediaConstraints) { NSDictionary *_mandatory; @@ -34,9 +37,9 @@ NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kVa } - (instancetype)initWithMandatoryConstraints: - (NSDictionary *)mandatory + (NSDictionary *)mandatory optionalConstraints: - (NSDictionary *)optional { + (NSDictionary *)optional { self = [super init]; if (self) { _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory @@ -48,8 +51,10 @@ NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kVa } - (NSString *)description { - return [NSString - stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaConstraints):\n%@\n%@", _mandatory, _optional]; + return + [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaConstraints):\n%@\n%@", + _mandatory, + _optional]; } #pragma mark - Private @@ -69,17 +74,20 @@ NSString *const kRTCMediaConstraintsValueFalse = @(webrtc::MediaConstraints::kVa (NSDictionary *)constraints { webrtc::MediaConstraints::Constraints nativeConstraints; for (NSString *key in constraints) { - NSAssert([key isKindOfClass:[NSString class]], - @"%@ is not an NSString.", key); + NSAssert( + [key isKindOfClass:[NSString class]], @"%@ is not an NSString.", key); NSString *value = [constraints objectForKey:key]; NSAssert([value isKindOfClass:[NSString class]], - @"%@ is not an NSString.", value); + @"%@ is not an NSString.", + value); if ([kRTCMediaConstraintsAudioNetworkAdaptorConfig isEqualToString:key]) { // This value is base64 encoded. - NSData *charData = [[NSData alloc] initWithBase64EncodedString:value options:0]; - std::string configValue = - std::string(reinterpret_cast(charData.bytes), charData.length); - nativeConstraints.push_back(webrtc::MediaConstraints::Constraint(key.stdString, configValue)); + NSData *charData = [[NSData alloc] initWithBase64EncodedString:value + options:0]; + std::string configValue = std::string( + reinterpret_cast(charData.bytes), charData.length); + nativeConstraints.push_back( + webrtc::MediaConstraints::Constraint(key.stdString, configValue)); } else { nativeConstraints.push_back( webrtc::MediaConstraints::Constraint(key.stdString, value.stdString)); diff --git a/sdk/objc/api/peerconnection/RTCMediaSource+Private.h b/sdk/objc/api/peerconnection/RTCMediaSource+Private.h index edda892e50..b552a17454 100644 --- a/sdk/objc/api/peerconnection/RTCMediaSource+Private.h +++ b/sdk/objc/api/peerconnection/RTCMediaSource+Private.h @@ -24,16 +24,20 @@ typedef NS_ENUM(NSInteger, RTCMediaSourceType) { @interface RTC_OBJC_TYPE (RTCMediaSource) () - @property(nonatomic, - readonly) rtc::scoped_refptr nativeMediaSource; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeMediaSource; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type NS_DESIGNATED_INITIALIZER; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type NS_DESIGNATED_INITIALIZER; -+ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState:(RTCSourceState)state; ++ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState: + (RTCSourceState)state; -+ (RTCSourceState)sourceStateForNativeState:(webrtc::MediaSourceInterface::SourceState)nativeState; ++ (RTCSourceState)sourceStateForNativeState: + (webrtc::MediaSourceInterface::SourceState)nativeState; + (NSString *)stringForState:(RTCSourceState)state; diff --git a/sdk/objc/api/peerconnection/RTCMediaSource.mm b/sdk/objc/api/peerconnection/RTCMediaSource.mm index 5a26e31669..caebd47423 100644 --- a/sdk/objc/api/peerconnection/RTCMediaSource.mm +++ b/sdk/objc/api/peerconnection/RTCMediaSource.mm @@ -19,9 +19,11 @@ @synthesize nativeMediaSource = _nativeMediaSource; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type { RTC_DCHECK(factory); RTC_DCHECK(nativeMediaSource); self = [super init]; diff --git a/sdk/objc/api/peerconnection/RTCMediaStream+Private.h b/sdk/objc/api/peerconnection/RTCMediaStream+Private.h index 6c8a602766..7c043815e8 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStream+Private.h +++ b/sdk/objc/api/peerconnection/RTCMediaStream+Private.h @@ -18,19 +18,22 @@ NS_ASSUME_NONNULL_BEGIN () /** - * MediaStreamInterface representation of this RTCMediaStream object. This is - * needed to pass to the underlying C++ APIs. + * MediaStreamInterface representation of this RTCMediaStream object. This + * is needed to pass to the underlying C++ APIs. */ - @property(nonatomic, - readonly) rtc::scoped_refptr nativeMediaStream; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeMediaStream; /** Initialize an RTCMediaStream with an id. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory streamId:(NSString *)streamId; /** Initialize an RTCMediaStream from a native MediaStreamInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaStream:(rtc::scoped_refptr)nativeMediaStream; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaStream: + (rtc::scoped_refptr)nativeMediaStream; @end diff --git a/sdk/objc/api/peerconnection/RTCMediaStream.h b/sdk/objc/api/peerconnection/RTCMediaStream.h index 8187472a47..2e4201e145 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStream.h +++ b/sdk/objc/api/peerconnection/RTCMediaStream.h @@ -25,7 +25,8 @@ RTC_OBJC_EXPORT @property(nonatomic, strong, readonly) NSArray *audioTracks; /** The video tracks in this stream. */ -@property(nonatomic, strong, readonly) NSArray *videoTracks; +@property(nonatomic, strong, readonly) + NSArray *videoTracks; /** An identifier for this media stream. */ @property(nonatomic, readonly) NSString *streamId; diff --git a/sdk/objc/api/peerconnection/RTCMediaStream.mm b/sdk/objc/api/peerconnection/RTCMediaStream.mm index 4a99bd5efd..d4b003c30c 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStream.mm +++ b/sdk/objc/api/peerconnection/RTCMediaStream.mm @@ -24,7 +24,8 @@ rtc::scoped_refptr _nativeMediaStream; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory streamId:(NSString *)streamId { NSParameterAssert(factory); NSParameterAssert(streamId.length); @@ -36,14 +37,16 @@ - (NSArray *)audioTracks { if (!_signalingThread->IsCurrent()) { - return _signalingThread->BlockingCall([self]() { return self.audioTracks; }); + return _signalingThread->BlockingCall( + [self]() { return self.audioTracks; }); } return [_audioTracks copy]; } - (NSArray *)videoTracks { if (!_signalingThread->IsCurrent()) { - return _signalingThread->BlockingCall([self]() { return self.videoTracks; }); + return _signalingThread->BlockingCall( + [self]() { return self.videoTracks; }); } return [_videoTracks copy]; } @@ -79,7 +82,8 @@ } NSUInteger index = [_audioTracks indexOfObjectIdenticalTo:audioTrack]; if (index == NSNotFound) { - RTC_LOG(LS_INFO) << "|removeAudioTrack| called on unexpected RTC_OBJC_TYPE(RTCAudioTrack)"; + RTC_LOG(LS_INFO) << "|removeAudioTrack| called on unexpected " + "RTC_OBJC_TYPE(RTCAudioTrack)"; return; } if (_nativeMediaStream->RemoveTrack(audioTrack.nativeAudioTrack)) { @@ -94,7 +98,8 @@ } NSUInteger index = [_videoTracks indexOfObjectIdenticalTo:videoTrack]; if (index == NSNotFound) { - RTC_LOG(LS_INFO) << "|removeVideoTrack| called on unexpected RTC_OBJC_TYPE(RTCVideoTrack)"; + RTC_LOG(LS_INFO) << "|removeVideoTrack| called on unexpected " + "RTC_OBJC_TYPE(RTCVideoTrack)"; return; } @@ -104,10 +109,11 @@ } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaStream):\n%@\nA=%lu\nV=%lu", - self.streamId, - (unsigned long)self.audioTracks.count, - (unsigned long)self.videoTracks.count]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaStream):\n%@\nA=%lu\nV=%lu", + self.streamId, + (unsigned long)self.audioTracks.count, + (unsigned long)self.videoTracks.count]; } #pragma mark - Private @@ -116,9 +122,10 @@ return _nativeMediaStream; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaStream: - (rtc::scoped_refptr)nativeMediaStream { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaStream: + (rtc::scoped_refptr)nativeMediaStream { NSParameterAssert(nativeMediaStream); self = [super init]; if (self) { diff --git a/sdk/objc/api/peerconnection/RTCMediaStreamTrack+Private.h b/sdk/objc/api/peerconnection/RTCMediaStreamTrack+Private.h index df45c79f44..9ee6b6bf12 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStreamTrack+Private.h +++ b/sdk/objc/api/peerconnection/RTCMediaStreamTrack+Private.h @@ -31,17 +31,23 @@ NS_ASSUME_NONNULL_BEGIN * The native MediaStreamTrackInterface passed in or created during * construction. */ -@property(nonatomic, readonly) rtc::scoped_refptr nativeTrack; +@property(nonatomic, readonly) + rtc::scoped_refptr + nativeTrack; /** * Initialize an RTCMediaStreamTrack from a native MediaStreamTrackInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack:(rtc::scoped_refptr)nativeTrack - type:(RTCMediaStreamTrackType)type NS_DESIGNATED_INITIALIZER; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack: + (rtc::scoped_refptr)nativeTrack + type:(RTCMediaStreamTrackType)type NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack:(rtc::scoped_refptr)nativeTrack; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack: + (rtc::scoped_refptr)nativeTrack; - (BOOL)isEqualToTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track; @@ -54,7 +60,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)stringForState:(RTCMediaStreamTrackState)state; + (RTC_OBJC_TYPE(RTCMediaStreamTrack) *) - mediaTrackForNativeTrack:(rtc::scoped_refptr)nativeTrack + mediaTrackForNativeTrack: + (rtc::scoped_refptr)nativeTrack factory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory; @end diff --git a/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm b/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm index 60deceea39..76f61d4ccd 100644 --- a/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm +++ b/sdk/objc/api/peerconnection/RTCMediaStreamTrack.mm @@ -14,9 +14,9 @@ #import "helpers/NSString+StdString.h" -NSString * const kRTCMediaStreamTrackKindAudio = +NSString *const kRTCMediaStreamTrackKindAudio = @(webrtc::MediaStreamTrackInterface::kAudioKind); -NSString * const kRTCMediaStreamTrackKindVideo = +NSString *const kRTCMediaStreamTrackKindVideo = @(webrtc::MediaStreamTrackInterface::kVideoKind); @implementation RTC_OBJC_TYPE (RTCMediaStreamTrack) { @@ -47,11 +47,12 @@ NSString * const kRTCMediaStreamTrackKindVideo = - (NSString *)description { NSString *readyState = [[self class] stringForState:self.readyState]; - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaStreamTrack):\n%@\n%@\n%@\n%@", - self.kind, - self.trackId, - self.isEnabled ? @"enabled" : @"disabled", - readyState]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCMediaStreamTrack):\n%@\n%@\n%@\n%@", + self.kind, + self.trackId, + self.isEnabled ? @"enabled" : @"disabled", + readyState]; } - (BOOL)isEqual:(id)object { @@ -76,9 +77,11 @@ NSString * const kRTCMediaStreamTrackKindVideo = @synthesize factory = _factory; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack:(rtc::scoped_refptr)nativeTrack - type:(RTCMediaStreamTrackType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack: + (rtc::scoped_refptr)nativeTrack + type:(RTCMediaStreamTrackType)type { NSParameterAssert(nativeTrack); NSParameterAssert(factory); self = [super init]; @@ -90,16 +93,22 @@ NSString * const kRTCMediaStreamTrackKindVideo = return self; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack:(rtc::scoped_refptr)nativeTrack { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack: + (rtc::scoped_refptr)nativeTrack { NSParameterAssert(nativeTrack); if (nativeTrack->kind() == std::string(webrtc::MediaStreamTrackInterface::kAudioKind)) { - return [self initWithFactory:factory nativeTrack:nativeTrack type:RTCMediaStreamTrackTypeAudio]; + return [self initWithFactory:factory + nativeTrack:nativeTrack + type:RTCMediaStreamTrackTypeAudio]; } if (nativeTrack->kind() == std::string(webrtc::MediaStreamTrackInterface::kVideoKind)) { - return [self initWithFactory:factory nativeTrack:nativeTrack type:RTCMediaStreamTrackTypeVideo]; + return [self initWithFactory:factory + nativeTrack:nativeTrack + type:RTCMediaStreamTrackTypeVideo]; } return nil; } @@ -141,21 +150,27 @@ NSString * const kRTCMediaStreamTrackKindVideo = } + (RTC_OBJC_TYPE(RTCMediaStreamTrack) *) - mediaTrackForNativeTrack:(rtc::scoped_refptr)nativeTrack - factory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory { + mediaTrackForNativeTrack: + (rtc::scoped_refptr)nativeTrack + factory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory { NSParameterAssert(nativeTrack); NSParameterAssert(factory); if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kAudioKind) { - return [[RTC_OBJC_TYPE(RTCAudioTrack) alloc] initWithFactory:factory - nativeTrack:nativeTrack - type:RTCMediaStreamTrackTypeAudio]; - } else if (nativeTrack->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { - return [[RTC_OBJC_TYPE(RTCVideoTrack) alloc] initWithFactory:factory - nativeTrack:nativeTrack - type:RTCMediaStreamTrackTypeVideo]; + return [[RTC_OBJC_TYPE(RTCAudioTrack) alloc] + initWithFactory:factory + nativeTrack:nativeTrack + type:RTCMediaStreamTrackTypeAudio]; + } else if (nativeTrack->kind() == + webrtc::MediaStreamTrackInterface::kVideoKind) { + return [[RTC_OBJC_TYPE(RTCVideoTrack) alloc] + initWithFactory:factory + nativeTrack:nativeTrack + type:RTCMediaStreamTrackTypeVideo]; } else { - return [[RTC_OBJC_TYPE(RTCMediaStreamTrack) alloc] initWithFactory:factory - nativeTrack:nativeTrack]; + return [[RTC_OBJC_TYPE(RTCMediaStreamTrack) alloc] + initWithFactory:factory + nativeTrack:nativeTrack]; } } diff --git a/sdk/objc/api/peerconnection/RTCMetrics.h b/sdk/objc/api/peerconnection/RTCMetrics.h index 9b0ec58b17..e6f272f80b 100644 --- a/sdk/objc/api/peerconnection/RTCMetrics.h +++ b/sdk/objc/api/peerconnection/RTCMetrics.h @@ -20,4 +20,5 @@ RTC_EXTERN void RTCEnableMetrics(void); /** Gets and clears native histograms. */ -RTC_EXTERN NSArray* RTCGetAndResetMetrics(void); +RTC_EXTERN NSArray* + RTCGetAndResetMetrics(void); diff --git a/sdk/objc/api/peerconnection/RTCMetrics.mm b/sdk/objc/api/peerconnection/RTCMetrics.mm index 87eb8c0210..99bb129e49 100644 --- a/sdk/objc/api/peerconnection/RTCMetrics.mm +++ b/sdk/objc/api/peerconnection/RTCMetrics.mm @@ -19,7 +19,9 @@ void RTCEnableMetrics(void) { } NSArray *RTCGetAndResetMetrics(void) { - std::map, rtc::AbslStringViewCmp> + std::map, + rtc::AbslStringViewCmp> histograms; webrtc::metrics::GetAndReset(&histograms); @@ -27,7 +29,8 @@ NSArray *RTCGetAndResetMetrics(void) { [NSMutableArray arrayWithCapacity:histograms.size()]; for (auto const &histogram : histograms) { RTC_OBJC_TYPE(RTCMetricsSampleInfo) *metric = - [[RTC_OBJC_TYPE(RTCMetricsSampleInfo) alloc] initWithNativeSampleInfo:*histogram.second]; + [[RTC_OBJC_TYPE(RTCMetricsSampleInfo) alloc] + initWithNativeSampleInfo:*histogram.second]; [metrics addObject:metric]; } return metrics; diff --git a/sdk/objc/api/peerconnection/RTCMetricsSampleInfo+Private.h b/sdk/objc/api/peerconnection/RTCMetricsSampleInfo+Private.h index e4aa41f6c7..08ae4c026a 100644 --- a/sdk/objc/api/peerconnection/RTCMetricsSampleInfo+Private.h +++ b/sdk/objc/api/peerconnection/RTCMetricsSampleInfo+Private.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN () /** Initialize an RTCMetricsSampleInfo object from native SampleInfo. */ - - (instancetype)initWithNativeSampleInfo : (const webrtc::metrics::SampleInfo &)info; + - (instancetype)initWithNativeSampleInfo + : (const webrtc::metrics::SampleInfo &)info; @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+DataChannel.mm b/sdk/objc/api/peerconnection/RTCPeerConnection+DataChannel.mm index cb75f061d8..ea56598774 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+DataChannel.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+DataChannel.mm @@ -23,12 +23,14 @@ std::string labelString = [NSString stdStringForString:label]; const webrtc::DataChannelInit nativeInit = configuration.nativeDataChannelInit; - auto result = self.nativePeerConnection->CreateDataChannelOrError(labelString, &nativeInit); + auto result = self.nativePeerConnection->CreateDataChannelOrError( + labelString, &nativeInit); if (!result.ok()) { return nil; } - return [[RTC_OBJC_TYPE(RTCDataChannel) alloc] initWithFactory:self.factory - nativeDataChannel:result.MoveValue()]; + return [[RTC_OBJC_TYPE(RTCDataChannel) alloc] + initWithFactory:self.factory + nativeDataChannel:result.MoveValue()]; } @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h index 9714f504ac..e033af21ff 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h @@ -22,29 +22,36 @@ namespace webrtc { */ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { public: - PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection); + PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * + peerConnection); ~PeerConnectionDelegateAdapter() override; - void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override; + void OnSignalingChange( + PeerConnectionInterface::SignalingState new_state) override; void OnAddStream(rtc::scoped_refptr stream) override; void OnRemoveStream(rtc::scoped_refptr stream) override; - void OnTrack(rtc::scoped_refptr transceiver) override; + void OnTrack( + rtc::scoped_refptr transceiver) override; - void OnDataChannel(rtc::scoped_refptr data_channel) override; + void OnDataChannel( + rtc::scoped_refptr data_channel) override; void OnRenegotiationNeeded() override; - void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override; + void OnIceConnectionChange( + PeerConnectionInterface::IceConnectionState new_state) override; void OnStandardizedIceConnectionChange( PeerConnectionInterface::IceConnectionState new_state) override; - void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override; + void OnConnectionChange( + PeerConnectionInterface::PeerConnectionState new_state) override; - void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override; + void OnIceGatheringChange( + PeerConnectionInterface::IceGatheringState new_state) override; void OnIceCandidate(const IceCandidateInterface *candidate) override; @@ -54,14 +61,18 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { int error_code, const std::string &error_text) override; - void OnIceCandidatesRemoved(const std::vector &candidates) override; + void OnIceCandidatesRemoved( + const std::vector &candidates) override; - void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override; + void OnIceSelectedCandidatePairChanged( + const cricket::CandidatePairChangeEvent &event) override; void OnAddTrack(rtc::scoped_refptr receiver, - const std::vector> &streams) override; + const std::vector> + &streams) override; - void OnRemoveTrack(rtc::scoped_refptr receiver) override; + void OnRemoveTrack( + rtc::scoped_refptr receiver) override; private: __weak RTC_OBJC_TYPE(RTCPeerConnection) * peer_connection_; @@ -79,8 +90,9 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { factory; /** The native PeerConnectionInterface created during construction. */ -@property(nonatomic, readonly) rtc::scoped_refptr - nativePeerConnection; +@property(nonatomic, readonly) + rtc::scoped_refptr + nativePeerConnection; /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. @@ -89,8 +101,10 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - certificateVerifier:(nullable id)certificateVerifier - delegate:(nullable id)delegate; + certificateVerifier:(nullable id) + certificateVerifier + delegate:(nullable id) + delegate; /** Initialize an RTCPeerConnection with a configuration, constraints, * delegate and PeerConnectionDependencies. @@ -99,9 +113,10 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies:(std::unique_ptr)dependencies - delegate:(nullable id)delegate - NS_DESIGNATED_INITIALIZER; + dependencies:(std::unique_ptr) + dependencies + delegate:(nullable id) + delegate NS_DESIGNATED_INITIALIZER; + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState: (RTCSignalingState)state; @@ -111,11 +126,11 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { + (NSString *)stringForSignalingState:(RTCSignalingState)state; -+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState: - (RTCIceConnectionState)state; ++ (webrtc::PeerConnectionInterface::IceConnectionState) + nativeIceConnectionStateForState:(RTCIceConnectionState)state; -+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState: - (RTCPeerConnectionState)state; ++ (webrtc::PeerConnectionInterface::PeerConnectionState) + nativeConnectionStateForState:(RTCPeerConnectionState)state; + (RTCIceConnectionState)iceConnectionStateForNativeState: (webrtc::PeerConnectionInterface::IceConnectionState)nativeState; @@ -127,16 +142,16 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { + (NSString *)stringForConnectionState:(RTCPeerConnectionState)state; -+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState: - (RTCIceGatheringState)state; ++ (webrtc::PeerConnectionInterface::IceGatheringState) + nativeIceGatheringStateForState:(RTCIceGatheringState)state; + (RTCIceGatheringState)iceGatheringStateForNativeState: (webrtc::PeerConnectionInterface::IceGatheringState)nativeState; + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state; -+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel: - (RTCStatsOutputLevel)level; ++ (webrtc::PeerConnectionInterface::StatsOutputLevel) + nativeStatsOutputLevelForLevel:(RTCStatsOutputLevel)level; @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm b/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm index f8d38143f3..97e0fdea76 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+Stats.mm @@ -23,10 +23,12 @@ namespace webrtc { class StatsCollectorCallbackAdapter : public RTCStatsCollectorCallback { public: - StatsCollectorCallbackAdapter(RTCStatisticsCompletionHandler completion_handler) + StatsCollectorCallbackAdapter( + RTCStatisticsCompletionHandler completion_handler) : completion_handler_(completion_handler) {} - void OnStatsDelivered(const rtc::scoped_refptr &report) override { + void OnStatsDelivered( + const rtc::scoped_refptr &report) override { RTC_DCHECK(completion_handler_); RTC_OBJC_TYPE(RTCStatisticsReport) *statisticsReport = [[RTC_OBJC_TYPE(RTCStatisticsReport) alloc] initWithReport:*report]; @@ -40,19 +42,20 @@ class StatsCollectorCallbackAdapter : public RTCStatsCollectorCallback { class StatsObserverAdapter : public StatsObserver { public: - StatsObserverAdapter( - void (^completionHandler)(NSArray *stats)) { + StatsObserverAdapter(void (^completionHandler)( + NSArray *stats)) { completion_handler_ = completionHandler; } ~StatsObserverAdapter() override { completion_handler_ = nil; } - void OnComplete(const StatsReports& reports) override { + void OnComplete(const StatsReports &reports) override { RTC_DCHECK(completion_handler_); NSMutableArray *stats = [NSMutableArray arrayWithCapacity:reports.size()]; - for (const auto* report : reports) { + for (const auto *report : reports) { RTC_OBJC_TYPE(RTCLegacyStatsReport) *statsReport = - [[RTC_OBJC_TYPE(RTCLegacyStatsReport) alloc] initWithNativeReport:*report]; + [[RTC_OBJC_TYPE(RTCLegacyStatsReport) alloc] + initWithNativeReport:*report]; [stats addObject:statsReport]; } completion_handler_(stats); @@ -60,37 +63,45 @@ class StatsObserverAdapter : public StatsObserver { } private: - void (^completion_handler_)(NSArray *stats); + void (^completion_handler_)( + NSArray *stats); }; } // namespace webrtc @implementation RTC_OBJC_TYPE (RTCPeerConnection) (Stats) - - (void)statisticsForSender : (RTC_OBJC_TYPE(RTCRtpSender) *)sender completionHandler + - (void)statisticsForSender + : (RTC_OBJC_TYPE(RTCRtpSender) *)sender completionHandler : (RTCStatisticsCompletionHandler)completionHandler { rtc::scoped_refptr collector = - rtc::make_ref_counted(completionHandler); + rtc::make_ref_counted( + completionHandler); self.nativePeerConnection->GetStats(sender.nativeRtpSender, collector); } - (void)statisticsForReceiver:(RTC_OBJC_TYPE(RTCRtpReceiver) *)receiver - completionHandler:(RTCStatisticsCompletionHandler)completionHandler { + completionHandler: + (RTCStatisticsCompletionHandler)completionHandler { rtc::scoped_refptr collector = - rtc::make_ref_counted(completionHandler); + rtc::make_ref_counted( + completionHandler); self.nativePeerConnection->GetStats(receiver.nativeRtpReceiver, collector); } -- (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler { +- (void)statisticsWithCompletionHandler: + (RTCStatisticsCompletionHandler)completionHandler { rtc::scoped_refptr collector = - rtc::make_ref_counted(completionHandler); + rtc::make_ref_counted( + completionHandler); self.nativePeerConnection->GetStats(collector.get()); } - (void)statsForTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)mediaStreamTrack statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel completionHandler: - (void (^)(NSArray *stats))completionHandler { + (void (^)(NSArray *stats)) + completionHandler { rtc::scoped_refptr observer = rtc::make_ref_counted(completionHandler); webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel = diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.h b/sdk/objc/api/peerconnection/RTCPeerConnection.h index 8b663fad99..fb5c414815 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.h @@ -83,9 +83,11 @@ typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) { }; typedef void (^RTCCreateSessionDescriptionCompletionHandler)( - RTC_OBJC_TYPE(RTCSessionDescription) *_Nullable sdp, NSError *_Nullable error); + RTC_OBJC_TYPE(RTCSessionDescription) *_Nullable sdp, + NSError *_Nullable error); -typedef void (^RTCSetSessionDescriptionCompletionHandler)(NSError *_Nullable error); +typedef void (^RTCSetSessionDescriptionCompletionHandler)( + NSError *_Nullable error); @class RTC_OBJC_TYPE(RTCPeerConnection); @@ -109,7 +111,8 @@ RTC_OBJC_EXPORT didRemoveStream:(RTC_OBJC_TYPE(RTCMediaStream) *)stream; /** Called when negotiation is needed, for example ICE has restarted. */ -- (void)peerConnectionShouldNegotiate:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection; +- (void)peerConnectionShouldNegotiate: + (RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection; /** Called any time the IceConnectionState changes. */ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection @@ -125,7 +128,8 @@ RTC_OBJC_EXPORT /** Called when a group of local Ice candidates have been removed. */ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection - didRemoveIceCandidates:(NSArray *)candidates; + didRemoveIceCandidates: + (NSArray *)candidates; /** New data channel has been opened. */ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection @@ -146,7 +150,8 @@ RTC_OBJC_EXPORT didChangeConnectionState:(RTCPeerConnectionState)newState; - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection - didStartReceivingOnTransceiver:(RTC_OBJC_TYPE(RTCRtpTransceiver) *)transceiver; + didStartReceivingOnTransceiver: + (RTC_OBJC_TYPE(RTCRtpTransceiver) *)transceiver; /** Called when a receiver and its track are created. */ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection @@ -166,7 +171,8 @@ RTC_OBJC_EXPORT /** Called when gathering of an ICE candidate failed. */ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection - didFailToGatherIceCandidate:(RTC_OBJC_TYPE(RTCIceCandidateErrorEvent) *)event; + didFailToGatherIceCandidate: + (RTC_OBJC_TYPE(RTCIceCandidateErrorEvent) *)event; @end @@ -180,14 +186,18 @@ RTC_OBJC_EXPORT /** This property is not available with RTCSdpSemanticsUnifiedPlan. Please use * `senders` instead. */ -@property(nonatomic, readonly) NSArray *localStreams; -@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCSessionDescription) * localDescription; -@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCSessionDescription) * remoteDescription; +@property(nonatomic, readonly) + NSArray *localStreams; +@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCSessionDescription) * + localDescription; +@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCSessionDescription) * + remoteDescription; @property(nonatomic, readonly) RTCSignalingState signalingState; @property(nonatomic, readonly) RTCIceConnectionState iceConnectionState; @property(nonatomic, readonly) RTCPeerConnectionState connectionState; @property(nonatomic, readonly) RTCIceGatheringState iceGatheringState; -@property(nonatomic, readonly, copy) RTC_OBJC_TYPE(RTCConfiguration) * configuration; +@property(nonatomic, readonly, copy) RTC_OBJC_TYPE(RTCConfiguration) * + configuration; /** Gets all RTCRtpSenders associated with this peer connection. * Note: reading this property returns different instances of RTCRtpSender. @@ -199,7 +209,8 @@ RTC_OBJC_EXPORT * Note: reading this property returns different instances of RTCRtpReceiver. * Use isEqual: instead of == to compare RTCRtpReceiver instances. */ -@property(nonatomic, readonly) NSArray *receivers; +@property(nonatomic, readonly) + NSArray *receivers; /** Gets all RTCRtpTransceivers associated with this peer connection. * Note: reading this property returns different instances of @@ -207,7 +218,8 @@ RTC_OBJC_EXPORT * RTCRtpTransceiver instances. This is only available with * RTCSdpSemanticsUnifiedPlan specified. */ -@property(nonatomic, readonly) NSArray *transceivers; +@property(nonatomic, readonly) + NSArray *transceivers; - (instancetype)init NS_UNAVAILABLE; @@ -224,14 +236,16 @@ RTC_OBJC_EXPORT /** Provide a remote candidate to the ICE Agent. */ - (void)addIceCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)candidate - DEPRECATED_MSG_ATTRIBUTE("Please use addIceCandidate:completionHandler: instead"); + DEPRECATED_MSG_ATTRIBUTE( + "Please use addIceCandidate:completionHandler: instead"); /** Provide a remote candidate to the ICE Agent. */ - (void)addIceCandidate:(RTC_OBJC_TYPE(RTCIceCandidate) *)candidate completionHandler:(void (^)(NSError *_Nullable error))completionHandler; /** Remove a group of remote candidates from the ICE Agent. */ -- (void)removeIceCandidates:(NSArray *)candidates; +- (void)removeIceCandidates: + (NSArray *)candidates; /** Add a new media stream to be sent on this peer connection. * This method is not supported with RTCSdpSemanticsUnifiedPlan. Please use @@ -253,8 +267,9 @@ RTC_OBJC_EXPORT * - A sender already exists for the track. * - The peer connection is closed. */ -- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track - streamIds:(NSArray *)streamIds; +- (nullable RTC_OBJC_TYPE(RTCRtpSender) *) + addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track + streamIds:(NSArray *)streamIds; /** With PlanB semantics, removes an RTCRtpSender from this peer connection. * @@ -295,28 +310,32 @@ RTC_OBJC_EXPORT /** Adds a transceiver with the given kind. Can either be RTCRtpMediaTypeAudio * or RTCRtpMediaTypeVideo. */ -- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType; +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType: + (RTCRtpMediaType)mediaType; - (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) addTransceiverOfType:(RTCRtpMediaType)mediaType init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init; /** Tells the PeerConnection that ICE should be restarted. This triggers a need - * for negotiation and subsequent offerForConstraints:completionHandler call will act as if - * RTCOfferAnswerOptions::ice_restart is true. + * for negotiation and subsequent offerForConstraints:completionHandler call + * will act as if RTCOfferAnswerOptions::ice_restart is true. */ - (void)restartIce; /** Generate an SDP offer. */ - (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler; + completionHandler: + (RTCCreateSessionDescriptionCompletionHandler)completionHandler; /** Generate an SDP answer. */ - (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler; + completionHandler: + (RTCCreateSessionDescriptionCompletionHandler)completionHandler; /** Apply the supplied RTCSessionDescription as the local description. */ - (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp - completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler; + completionHandler: + (RTCSetSessionDescriptionCompletionHandler)completionHandler; /** Creates an offer or answer (depending on current signaling state) and sets * it as the local session description. */ @@ -325,7 +344,8 @@ RTC_OBJC_EXPORT /** Apply the supplied RTCSessionDescription as the remote description. */ - (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp - completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler; + completionHandler: + (RTCSetSessionDescriptionCompletionHandler)completionHandler; /** Limits the bandwidth allocated for all RTP streams sent by this * PeerConnection. Nil parameters will be unchanged. Setting @@ -337,7 +357,8 @@ RTC_OBJC_EXPORT maxBitrateBps:(nullable NSNumber *)maxBitrateBps; /** Start or stop recording an Rtc EventLog. */ -- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes; +- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath + maxSizeInBytes:(int64_t)maxSizeInBytes; - (void)stopRtcEventLog; @end @@ -360,25 +381,29 @@ RTC_OBJC_EXPORT /** Create a new data channel with the given label and configuration. */ - (nullable RTC_OBJC_TYPE(RTCDataChannel) *)dataChannelForLabel - : (NSString *)label configuration : (RTC_OBJC_TYPE(RTCDataChannelConfiguration) *)configuration; + : (NSString *)label configuration + : (RTC_OBJC_TYPE(RTCDataChannelConfiguration) *)configuration; @end -typedef void (^RTCStatisticsCompletionHandler)(RTC_OBJC_TYPE(RTCStatisticsReport) *); +typedef void (^RTCStatisticsCompletionHandler)( + RTC_OBJC_TYPE(RTCStatisticsReport) *); @interface RTC_OBJC_TYPE (RTCPeerConnection) (Stats) - /** Gather stats for the given RTCMediaStreamTrack. If `mediaStreamTrack` is nil - * statistics are gathered for all tracks. + /** Gather stats for the given RTCMediaStreamTrack. If `mediaStreamTrack` is + * nil statistics are gathered for all tracks. */ - - (void)statsForTrack - : (nullable RTC_OBJC_TYPE(RTCMediaStreamTrack) *)mediaStreamTrack statsOutputLevel + - (void)statsForTrack : (nullable RTC_OBJC_TYPE(RTCMediaStreamTrack) *) + mediaStreamTrack statsOutputLevel : (RTCStatsOutputLevel)statsOutputLevel completionHandler - : (nullable void (^)(NSArray *stats))completionHandler; + : (nullable void (^)(NSArray *stats)) + completionHandler; /** Gather statistic through the v2 statistics API. */ -- (void)statisticsWithCompletionHandler:(RTCStatisticsCompletionHandler)completionHandler; +- (void)statisticsWithCompletionHandler: + (RTCStatisticsCompletionHandler)completionHandler; /** Spec-compliant getStats() performing the stats selection algorithm with the * sender. diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index 5a9f14a50b..787434ac58 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -36,15 +36,18 @@ #include "rtc_base/numerics/safe_conversions.h" #include "sdk/objc/native/api/ssl_certificate_verifier.h" -NSString *const kRTCPeerConnectionErrorDomain = @"org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection)"; +NSString *const kRTCPeerConnectionErrorDomain = + @"org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection)"; int const kRTCPeerConnnectionSessionDescriptionError = -1; namespace { -class SetSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface, - public webrtc::SetRemoteDescriptionObserverInterface { +class SetSessionDescriptionObserver + : public webrtc::SetLocalDescriptionObserverInterface, + public webrtc::SetRemoteDescriptionObserverInterface { public: - SetSessionDescriptionObserver(RTCSetSessionDescriptionCompletionHandler completionHandler) { + SetSessionDescriptionObserver( + RTCSetSessionDescriptionCompletionHandler completionHandler) { completion_handler_ = completionHandler; } @@ -64,9 +67,10 @@ class SetSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserver } else { // TODO(hta): Add handling of error.type() NSString *str = [NSString stringForStdString:error.message()]; - NSError *err = [NSError errorWithDomain:kRTCPeerConnectionErrorDomain - code:kRTCPeerConnnectionSessionDescriptionError - userInfo:@{NSLocalizedDescriptionKey : str}]; + NSError *err = + [NSError errorWithDomain:kRTCPeerConnectionErrorDomain + code:kRTCPeerConnnectionSessionDescriptionError + userInfo:@{NSLocalizedDescriptionKey : str}]; completion_handler_(err); } completion_handler_ = nil; @@ -82,18 +86,22 @@ class CreateSessionDescriptionObserverAdapter : public CreateSessionDescriptionObserver { public: CreateSessionDescriptionObserverAdapter(void (^completionHandler)( - RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription, NSError *error)) { + RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription, + NSError *error)) { completion_handler_ = completionHandler; } - ~CreateSessionDescriptionObserverAdapter() override { completion_handler_ = nil; } + ~CreateSessionDescriptionObserverAdapter() override { + completion_handler_ = nil; + } void OnSuccess(SessionDescriptionInterface *desc) override { RTC_DCHECK(completion_handler_); std::unique_ptr description = std::unique_ptr(desc); RTC_OBJC_TYPE(RTCSessionDescription) *session = - [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description.get()]; + [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] + initWithNativeDescription:description.get()]; completion_handler_(session, nil); completion_handler_ = nil; } @@ -102,21 +110,22 @@ class CreateSessionDescriptionObserverAdapter RTC_DCHECK(completion_handler_); // TODO(hta): Add handling of error.type() NSString *str = [NSString stringForStdString:error.message()]; - NSError* err = + NSError *err = [NSError errorWithDomain:kRTCPeerConnectionErrorDomain code:kRTCPeerConnnectionSessionDescriptionError - userInfo:@{ NSLocalizedDescriptionKey : str }]; + userInfo:@{NSLocalizedDescriptionKey : str}]; completion_handler_(nil, err); completion_handler_ = nil; } private: - void (^completion_handler_)(RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription, + void (^completion_handler_)(RTC_OBJC_TYPE(RTCSessionDescription) * + sessionDescription, NSError *error); }; -PeerConnectionDelegateAdapter::PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * - peerConnection) { +PeerConnectionDelegateAdapter::PeerConnectionDelegateAdapter( + RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection) { peer_connection_ = peerConnection; } @@ -126,8 +135,8 @@ PeerConnectionDelegateAdapter::~PeerConnectionDelegateAdapter() { void PeerConnectionDelegateAdapter::OnSignalingChange( PeerConnectionInterface::SignalingState new_state) { - RTCSignalingState state = - [[RTC_OBJC_TYPE(RTCPeerConnection) class] signalingStateForNativeState:new_state]; + RTCSignalingState state = [[RTC_OBJC_TYPE(RTCPeerConnection) class] + signalingStateForNativeState:new_state]; RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; [peer_connection.delegate peerConnection:peer_connection didChangeSignalingState:state]; @@ -136,9 +145,8 @@ void PeerConnectionDelegateAdapter::OnSignalingChange( void PeerConnectionDelegateAdapter::OnAddStream( rtc::scoped_refptr stream) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; - RTC_OBJC_TYPE(RTCMediaStream) *mediaStream = - [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:peer_connection.factory - nativeMediaStream:stream]; + RTC_OBJC_TYPE(RTCMediaStream) *mediaStream = [[RTC_OBJC_TYPE(RTCMediaStream) + alloc] initWithFactory:peer_connection.factory nativeMediaStream:stream]; [peer_connection.delegate peerConnection:peer_connection didAddStream:mediaStream]; } @@ -146,9 +154,8 @@ void PeerConnectionDelegateAdapter::OnAddStream( void PeerConnectionDelegateAdapter::OnRemoveStream( rtc::scoped_refptr stream) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; - RTC_OBJC_TYPE(RTCMediaStream) *mediaStream = - [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:peer_connection.factory - nativeMediaStream:stream]; + RTC_OBJC_TYPE(RTCMediaStream) *mediaStream = [[RTC_OBJC_TYPE(RTCMediaStream) + alloc] initWithFactory:peer_connection.factory nativeMediaStream:stream]; [peer_connection.delegate peerConnection:peer_connection didRemoveStream:mediaStream]; @@ -158,10 +165,12 @@ void PeerConnectionDelegateAdapter::OnTrack( rtc::scoped_refptr nativeTransceiver) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; RTC_OBJC_TYPE(RTCRtpTransceiver) *transceiver = - [[RTC_OBJC_TYPE(RTCRtpTransceiver) alloc] initWithFactory:peer_connection.factory - nativeRtpTransceiver:nativeTransceiver]; + [[RTC_OBJC_TYPE(RTCRtpTransceiver) alloc] + initWithFactory:peer_connection.factory + nativeRtpTransceiver:nativeTransceiver]; if ([peer_connection.delegate - respondsToSelector:@selector(peerConnection:didStartReceivingOnTransceiver:)]) { + respondsToSelector:@selector(peerConnection: + didStartReceivingOnTransceiver:)]) { [peer_connection.delegate peerConnection:peer_connection didStartReceivingOnTransceiver:transceiver]; } @@ -170,9 +179,9 @@ void PeerConnectionDelegateAdapter::OnTrack( void PeerConnectionDelegateAdapter::OnDataChannel( rtc::scoped_refptr data_channel) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; - RTC_OBJC_TYPE(RTCDataChannel) *dataChannel = - [[RTC_OBJC_TYPE(RTCDataChannel) alloc] initWithFactory:peer_connection.factory - nativeDataChannel:data_channel]; + RTC_OBJC_TYPE(RTCDataChannel) *dataChannel = [[RTC_OBJC_TYPE(RTCDataChannel) + alloc] initWithFactory:peer_connection.factory + nativeDataChannel:data_channel]; [peer_connection.delegate peerConnection:peer_connection didOpenDataChannel:dataChannel]; } @@ -184,17 +193,19 @@ void PeerConnectionDelegateAdapter::OnRenegotiationNeeded() { void PeerConnectionDelegateAdapter::OnIceConnectionChange( PeerConnectionInterface::IceConnectionState new_state) { - RTCIceConnectionState state = - [RTC_OBJC_TYPE(RTCPeerConnection) iceConnectionStateForNativeState:new_state]; - [peer_connection_.delegate peerConnection:peer_connection_ didChangeIceConnectionState:state]; + RTCIceConnectionState state = [RTC_OBJC_TYPE(RTCPeerConnection) + iceConnectionStateForNativeState:new_state]; + [peer_connection_.delegate peerConnection:peer_connection_ + didChangeIceConnectionState:state]; } void PeerConnectionDelegateAdapter::OnStandardizedIceConnectionChange( PeerConnectionInterface::IceConnectionState new_state) { if ([peer_connection_.delegate - respondsToSelector:@selector(peerConnection:didChangeStandardizedIceConnectionState:)]) { - RTCIceConnectionState state = - [RTC_OBJC_TYPE(RTCPeerConnection) iceConnectionStateForNativeState:new_state]; + respondsToSelector:@selector(peerConnection: + didChangeStandardizedIceConnectionState:)]) { + RTCIceConnectionState state = [RTC_OBJC_TYPE(RTCPeerConnection) + iceConnectionStateForNativeState:new_state]; [peer_connection_.delegate peerConnection:peer_connection_ didChangeStandardizedIceConnectionState:state]; } @@ -202,18 +213,19 @@ void PeerConnectionDelegateAdapter::OnStandardizedIceConnectionChange( void PeerConnectionDelegateAdapter::OnConnectionChange( PeerConnectionInterface::PeerConnectionState new_state) { - if ([peer_connection_.delegate - respondsToSelector:@selector(peerConnection:didChangeConnectionState:)]) { - RTCPeerConnectionState state = - [RTC_OBJC_TYPE(RTCPeerConnection) connectionStateForNativeState:new_state]; - [peer_connection_.delegate peerConnection:peer_connection_ didChangeConnectionState:state]; + if ([peer_connection_.delegate respondsToSelector:@selector + (peerConnection:didChangeConnectionState:)]) { + RTCPeerConnectionState state = [RTC_OBJC_TYPE(RTCPeerConnection) + connectionStateForNativeState:new_state]; + [peer_connection_.delegate peerConnection:peer_connection_ + didChangeConnectionState:state]; } } void PeerConnectionDelegateAdapter::OnIceGatheringChange( PeerConnectionInterface::IceGatheringState new_state) { - RTCIceGatheringState state = - [[RTC_OBJC_TYPE(RTCPeerConnection) class] iceGatheringStateForNativeState:new_state]; + RTCIceGatheringState state = [[RTC_OBJC_TYPE(RTCPeerConnection) class] + iceGatheringStateForNativeState:new_state]; RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; [peer_connection.delegate peerConnection:peer_connection didChangeIceGatheringState:state]; @@ -222,38 +234,45 @@ void PeerConnectionDelegateAdapter::OnIceGatheringChange( void PeerConnectionDelegateAdapter::OnIceCandidate( const IceCandidateInterface *candidate) { RTC_OBJC_TYPE(RTCIceCandidate) *iceCandidate = - [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] initWithNativeCandidate:candidate]; + [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] + initWithNativeCandidate:candidate]; RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; [peer_connection.delegate peerConnection:peer_connection didGenerateIceCandidate:iceCandidate]; } -void PeerConnectionDelegateAdapter::OnIceCandidateError(const std::string &address, - int port, - const std::string &url, - int error_code, - const std::string &error_text) { +void PeerConnectionDelegateAdapter::OnIceCandidateError( + const std::string &address, + int port, + const std::string &url, + int error_code, + const std::string &error_text) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; RTC_OBJC_TYPE(RTCIceCandidateErrorEvent) *event = - [[RTC_OBJC_TYPE(RTCIceCandidateErrorEvent) alloc] initWithAddress:address - port:port - url:url - errorCode:error_code - errorText:error_text]; - if ([peer_connection.delegate respondsToSelector:@selector(peerConnection: - didFailToGatherIceCandidate:)]) { - [peer_connection.delegate peerConnection:peer_connection didFailToGatherIceCandidate:event]; + [[RTC_OBJC_TYPE(RTCIceCandidateErrorEvent) alloc] + initWithAddress:address + port:port + url:url + errorCode:error_code + errorText:error_text]; + if ([peer_connection.delegate + respondsToSelector:@selector(peerConnection: + didFailToGatherIceCandidate:)]) { + [peer_connection.delegate peerConnection:peer_connection + didFailToGatherIceCandidate:event]; } } void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved( - const std::vector& candidates) { - NSMutableArray* ice_candidates = + const std::vector &candidates) { + NSMutableArray *ice_candidates = [NSMutableArray arrayWithCapacity:candidates.size()]; - for (const auto& candidate : candidates) { - JsepIceCandidate candidate_wrapper(candidate.transport_name(), -1, candidate); + for (const auto &candidate : candidates) { + JsepIceCandidate candidate_wrapper( + candidate.transport_name(), -1, candidate); RTC_OBJC_TYPE(RTCIceCandidate) *ice_candidate = - [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] initWithNativeCandidate:&candidate_wrapper]; + [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] + initWithNativeCandidate:&candidate_wrapper]; [ice_candidates addObject:ice_candidate]; } RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; @@ -265,18 +284,26 @@ void PeerConnectionDelegateAdapter::OnIceSelectedCandidatePairChanged( const cricket::CandidatePairChangeEvent &event) { const auto &selected_pair = event.selected_candidate_pair; JsepIceCandidate local_candidate_wrapper( - selected_pair.local_candidate().transport_name(), -1, selected_pair.local_candidate()); + selected_pair.local_candidate().transport_name(), + -1, + selected_pair.local_candidate()); RTC_OBJC_TYPE(RTCIceCandidate) *local_candidate = - [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] initWithNativeCandidate:&local_candidate_wrapper]; + [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] + initWithNativeCandidate:&local_candidate_wrapper]; JsepIceCandidate remote_candidate_wrapper( - selected_pair.remote_candidate().transport_name(), -1, selected_pair.remote_candidate()); + selected_pair.remote_candidate().transport_name(), + -1, + selected_pair.remote_candidate()); RTC_OBJC_TYPE(RTCIceCandidate) *remote_candidate = - [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] initWithNativeCandidate:&remote_candidate_wrapper]; + [[RTC_OBJC_TYPE(RTCIceCandidate) alloc] + initWithNativeCandidate:&remote_candidate_wrapper]; RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; NSString *nsstr_reason = [NSString stringForStdString:event.reason]; if ([peer_connection.delegate respondsToSelector:@selector - (peerConnection:didChangeLocalCandidate:remoteCandidate:lastReceivedMs:changeReason:)]) { + (peerConnection: + didChangeLocalCandidate:remoteCandidate:lastReceivedMs + :changeReason:)]) { [peer_connection.delegate peerConnection:peer_connection didChangeLocalCandidate:local_candidate remoteCandidate:remote_candidate @@ -289,18 +316,20 @@ void PeerConnectionDelegateAdapter::OnAddTrack( rtc::scoped_refptr receiver, const std::vector> &streams) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; - if ([peer_connection.delegate respondsToSelector:@selector(peerConnection: - didAddReceiver:streams:)]) { - NSMutableArray *mediaStreams = [NSMutableArray arrayWithCapacity:streams.size()]; + if ([peer_connection.delegate respondsToSelector:@selector + (peerConnection:didAddReceiver:streams:)]) { + NSMutableArray *mediaStreams = + [NSMutableArray arrayWithCapacity:streams.size()]; for (const auto &nativeStream : streams) { RTC_OBJC_TYPE(RTCMediaStream) *mediaStream = - [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:peer_connection.factory - nativeMediaStream:nativeStream]; + [[RTC_OBJC_TYPE(RTCMediaStream) alloc] + initWithFactory:peer_connection.factory + nativeMediaStream:nativeStream]; [mediaStreams addObject:mediaStream]; } - RTC_OBJC_TYPE(RTCRtpReceiver) *rtpReceiver = - [[RTC_OBJC_TYPE(RTCRtpReceiver) alloc] initWithFactory:peer_connection.factory - nativeRtpReceiver:receiver]; + RTC_OBJC_TYPE(RTCRtpReceiver) *rtpReceiver = [[RTC_OBJC_TYPE(RTCRtpReceiver) + alloc] initWithFactory:peer_connection.factory + nativeRtpReceiver:receiver]; [peer_connection.delegate peerConnection:peer_connection didAddReceiver:rtpReceiver @@ -311,11 +340,13 @@ void PeerConnectionDelegateAdapter::OnAddTrack( void PeerConnectionDelegateAdapter::OnRemoveTrack( rtc::scoped_refptr receiver) { RTC_OBJC_TYPE(RTCPeerConnection) *peer_connection = peer_connection_; - if ([peer_connection.delegate respondsToSelector:@selector(peerConnection:didRemoveReceiver:)]) { - RTC_OBJC_TYPE(RTCRtpReceiver) *rtpReceiver = - [[RTC_OBJC_TYPE(RTCRtpReceiver) alloc] initWithFactory:peer_connection.factory - nativeRtpReceiver:receiver]; - [peer_connection.delegate peerConnection:peer_connection didRemoveReceiver:rtpReceiver]; + if ([peer_connection.delegate + respondsToSelector:@selector(peerConnection:didRemoveReceiver:)]) { + RTC_OBJC_TYPE(RTCRtpReceiver) *rtpReceiver = [[RTC_OBJC_TYPE(RTCRtpReceiver) + alloc] initWithFactory:peer_connection.factory + nativeRtpReceiver:receiver]; + [peer_connection.delegate peerConnection:peer_connection + didRemoveReceiver:rtpReceiver]; } } @@ -333,17 +364,19 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( @synthesize delegate = _delegate; @synthesize factory = _factory; -- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - certificateVerifier: - (nullable id)certificateVerifier - delegate:(id)delegate { +- (nullable instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + certificateVerifier:(nullable id) + certificateVerifier + delegate:(id)delegate { NSParameterAssert(factory); std::unique_ptr dependencies = std::make_unique(nullptr); if (certificateVerifier != nil) { - dependencies->tls_cert_verifier = webrtc::ObjCToNativeCertificateVerifier(certificateVerifier); + dependencies->tls_cert_verifier = + webrtc::ObjCToNativeCertificateVerifier(certificateVerifier); } return [self initWithDependencies:factory configuration:configuration @@ -356,8 +389,10 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies:(std::unique_ptr)dependencies - delegate:(id)delegate { + dependencies:(std::unique_ptr) + dependencies + delegate: + (id)delegate { NSParameterAssert(factory); NSParameterAssert(dependencies.get()); std::unique_ptr config( @@ -373,7 +408,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( webrtc::PeerConnectionDependencies deps = std::move(*dependencies); deps.observer = _observer.get(); - auto result = factory.nativeFactory->CreatePeerConnectionOrError(*config, std::move(deps)); + auto result = factory.nativeFactory->CreatePeerConnectionOrError( + *config, std::move(deps)); if (!result.ok()) { return nil; @@ -391,22 +427,26 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } - (RTC_OBJC_TYPE(RTCSessionDescription) *)localDescription { - // It's only safe to operate on SessionDescriptionInterface on the signaling thread. + // It's only safe to operate on SessionDescriptionInterface on the signaling + // thread. return _peerConnection->signaling_thread()->BlockingCall([self] { - const webrtc::SessionDescriptionInterface *description = _peerConnection->local_description(); - return description ? - [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] : - nil; + const webrtc::SessionDescriptionInterface *description = + _peerConnection->local_description(); + return description ? [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] + initWithNativeDescription:description] : + nil; }); } - (RTC_OBJC_TYPE(RTCSessionDescription) *)remoteDescription { - // It's only safe to operate on SessionDescriptionInterface on the signaling thread. + // It's only safe to operate on SessionDescriptionInterface on the signaling + // thread. return _peerConnection->signaling_thread()->BlockingCall([self] { - const webrtc::SessionDescriptionInterface *description = _peerConnection->remote_description(); - return description ? - [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] : - nil; + const webrtc::SessionDescriptionInterface *description = + _peerConnection->remote_description(); + return description ? [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] + initWithNativeDescription:description] : + nil; }); } @@ -416,17 +456,18 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } - (RTCIceConnectionState)iceConnectionState { - return [[self class] iceConnectionStateForNativeState: - _peerConnection->ice_connection_state()]; + return [[self class] + iceConnectionStateForNativeState:_peerConnection->ice_connection_state()]; } - (RTCPeerConnectionState)connectionState { - return [[self class] connectionStateForNativeState:_peerConnection->peer_connection_state()]; + return [[self class] + connectionStateForNativeState:_peerConnection->peer_connection_state()]; } - (RTCIceGatheringState)iceGatheringState { - return [[self class] iceGatheringStateForNativeState: - _peerConnection->ice_gathering_state()]; + return [[self class] + iceGatheringStateForNativeState:_peerConnection->ice_gathering_state()]; } - (BOOL)setConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration { @@ -435,15 +476,15 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( if (!config) { return NO; } - CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(), - config.get()); + CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(), config.get()); return _peerConnection->SetConfiguration(*config).ok(); } - (RTC_OBJC_TYPE(RTCConfiguration) *)configuration { webrtc::PeerConnectionInterface::RTCConfiguration config = - _peerConnection->GetConfiguration(); - return [[RTC_OBJC_TYPE(RTCConfiguration) alloc] initWithNativeConfiguration:config]; + _peerConnection->GetConfiguration(); + return [[RTC_OBJC_TYPE(RTCConfiguration) alloc] + initWithNativeConfiguration:config]; } - (void)close { @@ -464,14 +505,16 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( completionHandler(nil); } else { NSString *str = [NSString stringForStdString:error.message()]; - NSError *err = [NSError errorWithDomain:kRTCPeerConnectionErrorDomain - code:static_cast(error.type()) - userInfo:@{NSLocalizedDescriptionKey : str}]; + NSError *err = + [NSError errorWithDomain:kRTCPeerConnectionErrorDomain + code:static_cast(error.type()) + userInfo:@{NSLocalizedDescriptionKey : str}]; completionHandler(err); } }); } -- (void)removeIceCandidates:(NSArray *)iceCandidates { +- (void)removeIceCandidates: + (NSArray *)iceCandidates { std::vector candidates; for (RTC_OBJC_TYPE(RTCIceCandidate) * iceCandidate in iceCandidates) { std::unique_ptr candidate( @@ -500,24 +543,30 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( [_localStreams removeObject:stream]; } -- (nullable RTC_OBJC_TYPE(RTCRtpSender) *)addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track - streamIds:(NSArray *)streamIds { +- (nullable RTC_OBJC_TYPE(RTCRtpSender) *) + addTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track + streamIds:(NSArray *)streamIds { std::vector nativeStreamIds; for (NSString *streamId in streamIds) { nativeStreamIds.push_back([streamId UTF8String]); } - webrtc::RTCErrorOr> nativeSenderOrError = - _peerConnection->AddTrack(track.nativeTrack, nativeStreamIds); + webrtc::RTCErrorOr> + nativeSenderOrError = + _peerConnection->AddTrack(track.nativeTrack, nativeStreamIds); if (!nativeSenderOrError.ok()) { - RTCLogError(@"Failed to add track %@: %s", track, nativeSenderOrError.error().message()); + RTCLogError(@"Failed to add track %@: %s", + track, + nativeSenderOrError.error().message()); return nil; } - return [[RTC_OBJC_TYPE(RTCRtpSender) alloc] initWithFactory:self.factory - nativeRtpSender:nativeSenderOrError.MoveValue()]; + return [[RTC_OBJC_TYPE(RTCRtpSender) alloc] + initWithFactory:self.factory + nativeRtpSender:nativeSenderOrError.MoveValue()]; } - (BOOL)removeTrack:(RTC_OBJC_TYPE(RTCRtpSender) *)sender { - bool result = _peerConnection->RemoveTrackOrError(sender.nativeRtpSender).ok(); + bool result = + _peerConnection->RemoveTrackOrError(sender.nativeRtpSender).ok(); if (!result) { RTCLogError(@"Failed to remote track %@", sender); } @@ -527,17 +576,20 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( - (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverWithTrack: (RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track { return [self addTransceiverWithTrack:track - init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init]]; + init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) + alloc] init]]; } - (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) addTransceiverWithTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init { - webrtc::RTCErrorOr> nativeTransceiverOrError = - _peerConnection->AddTransceiver(track.nativeTrack, init.nativeInit); + webrtc::RTCErrorOr> + nativeTransceiverOrError = + _peerConnection->AddTransceiver(track.nativeTrack, init.nativeInit); if (!nativeTransceiverOrError.ok()) { - RTCLogError( - @"Failed to add transceiver %@: %s", track, nativeTransceiverOrError.error().message()); + RTCLogError(@"Failed to add transceiver %@: %s", + track, + nativeTransceiverOrError.error().message()); return nil; } return [[RTC_OBJC_TYPE(RTCRtpTransceiver) alloc] @@ -545,17 +597,20 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( nativeRtpTransceiver:nativeTransceiverOrError.MoveValue()]; } -- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType:(RTCRtpMediaType)mediaType { - return [self addTransceiverOfType:mediaType - init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init]]; +- (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *)addTransceiverOfType: + (RTCRtpMediaType)mediaType { + return [self + addTransceiverOfType:mediaType + init:[[RTC_OBJC_TYPE(RTCRtpTransceiverInit) alloc] init]]; } - (nullable RTC_OBJC_TYPE(RTCRtpTransceiver) *) addTransceiverOfType:(RTCRtpMediaType)mediaType init:(RTC_OBJC_TYPE(RTCRtpTransceiverInit) *)init { - webrtc::RTCErrorOr> nativeTransceiverOrError = - _peerConnection->AddTransceiver( - [RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType:mediaType], init.nativeInit); + webrtc::RTCErrorOr> + nativeTransceiverOrError = _peerConnection->AddTransceiver( + [RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType:mediaType], + init.nativeInit); if (!nativeTransceiverOrError.ok()) { RTCLogError(@"Failed to add transceiver %@: %s", [RTC_OBJC_TYPE(RTCRtpReceiver) stringForMediaType:mediaType], @@ -572,29 +627,36 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } - (void)offerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler { + completionHandler: + (RTCCreateSessionDescriptionCompletionHandler)completionHandler { RTC_DCHECK(completionHandler != nil); rtc::scoped_refptr observer = - rtc::make_ref_counted(completionHandler); + rtc::make_ref_counted( + completionHandler); webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options; - CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), &options); + CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), + &options); _peerConnection->CreateOffer(observer.get(), options); } - (void)answerForConstraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - completionHandler:(RTCCreateSessionDescriptionCompletionHandler)completionHandler { + completionHandler: + (RTCCreateSessionDescriptionCompletionHandler)completionHandler { RTC_DCHECK(completionHandler != nil); rtc::scoped_refptr observer = - rtc::make_ref_counted(completionHandler); + rtc::make_ref_counted( + completionHandler); webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options; - CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), &options); + CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), + &options); _peerConnection->CreateAnswer(observer.get(), options); } - (void)setLocalDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp - completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler { + completionHandler: + (RTCSetSessionDescriptionCompletionHandler)completionHandler { RTC_DCHECK(completionHandler != nil); rtc::scoped_refptr observer = rtc::make_ref_counted<::SetSessionDescriptionObserver>(completionHandler); @@ -610,7 +672,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } - (void)setRemoteDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)sdp - completionHandler:(RTCSetSessionDescriptionCompletionHandler)completionHandler { + completionHandler: + (RTCSetSessionDescriptionCompletionHandler)completionHandler { RTC_DCHECK(completionHandler != nil); rtc::scoped_refptr observer = rtc::make_ref_counted<::SetSessionDescriptionObserver>(completionHandler); @@ -648,8 +711,9 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( return NO; } // TODO(eladalon): It would be better to not allow negative values into PC. - const size_t max_size = (maxSizeInBytes < 0) ? webrtc::RtcEventLog::kUnlimitedOutput : - rtc::saturated_cast(maxSizeInBytes); + const size_t max_size = (maxSizeInBytes < 0) ? + webrtc::RtcEventLog::kUnlimitedOutput : + rtc::saturated_cast(maxSizeInBytes); _hasStartedRtcEventLog = _peerConnection->StartRtcEventLog( std::make_unique(f, max_size)); @@ -661,14 +725,16 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( _hasStartedRtcEventLog = NO; } -- (RTC_OBJC_TYPE(RTCRtpSender) *)senderWithKind:(NSString *)kind streamId:(NSString *)streamId { +- (RTC_OBJC_TYPE(RTCRtpSender) *)senderWithKind:(NSString *)kind + streamId:(NSString *)streamId { std::string nativeKind = [NSString stdStringForString:kind]; std::string nativeStreamId = [NSString stdStringForString:streamId]; rtc::scoped_refptr nativeSender( _peerConnection->CreateSender(nativeKind, nativeStreamId)); - return nativeSender ? [[RTC_OBJC_TYPE(RTCRtpSender) alloc] initWithFactory:self.factory - nativeRtpSender:nativeSender] : - nil; + return nativeSender ? + [[RTC_OBJC_TYPE(RTCRtpSender) alloc] initWithFactory:self.factory + nativeRtpSender:nativeSender] : + nil; } - (NSArray *)senders { @@ -698,13 +764,14 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } - (NSArray *)transceivers { - std::vector> nativeTransceivers( - _peerConnection->GetTransceivers()); + std::vector> + nativeTransceivers(_peerConnection->GetTransceivers()); NSMutableArray *transceivers = [[NSMutableArray alloc] init]; for (const auto &nativeTransceiver : nativeTransceivers) { RTC_OBJC_TYPE(RTCRtpTransceiver) *transceiver = - [[RTC_OBJC_TYPE(RTCRtpTransceiver) alloc] initWithFactory:self.factory - nativeRtpTransceiver:nativeTransceiver]; + [[RTC_OBJC_TYPE(RTCRtpTransceiver) alloc] + initWithFactory:self.factory + nativeRtpTransceiver:nativeTransceiver]; [transceivers addObject:transceiver]; } return transceivers; @@ -765,8 +832,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( } } -+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState: - (RTCPeerConnectionState)state { ++ (webrtc::PeerConnectionInterface::PeerConnectionState) + nativeConnectionStateForState:(RTCPeerConnectionState)state { switch (state) { case RTCPeerConnectionStateNew: return webrtc::PeerConnectionInterface::PeerConnectionState::kNew; @@ -777,14 +844,15 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( case RTCPeerConnectionStateFailed: return webrtc::PeerConnectionInterface::PeerConnectionState::kFailed; case RTCPeerConnectionStateDisconnected: - return webrtc::PeerConnectionInterface::PeerConnectionState::kDisconnected; + return webrtc::PeerConnectionInterface::PeerConnectionState:: + kDisconnected; case RTCPeerConnectionStateClosed: return webrtc::PeerConnectionInterface::PeerConnectionState::kClosed; } } + (RTCPeerConnectionState)connectionStateForNativeState: - (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState { + (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState { switch (nativeState) { case webrtc::PeerConnectionInterface::PeerConnectionState::kNew: return RTCPeerConnectionStateNew; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h index 8a49d03525..4dfeb6ef39 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h @@ -23,59 +23,79 @@ NS_ASSUME_NONNULL_BEGIN /** - * This class extension exposes methods that work directly with injectable C++ components. + * This class extension exposes methods that work directly with injectable C++ + * components. */ @interface RTC_OBJC_TYPE (RTCPeerConnectionFactory) () -/* Initializer used when WebRTC is compiled with no media support */ -- (instancetype)initWithNoMedia; + /* Initializer used when WebRTC is compiled with no media support */ + - (instancetype)initWithNoMedia; /* Initialize object with provided dependencies and with media support. */ - (instancetype)initWithMediaAndDependencies: (webrtc::PeerConnectionFactoryDependencies)dependencies; -/* Initialize object with injectable native audio/video encoder/decoder factories */ -- (instancetype)initWithNativeAudioEncoderFactory: - (rtc::scoped_refptr)audioEncoderFactory - nativeAudioDecoderFactory: - (rtc::scoped_refptr)audioDecoderFactory - nativeVideoEncoderFactory: - (std::unique_ptr)videoEncoderFactory - nativeVideoDecoderFactory: - (std::unique_ptr)videoDecoderFactory - audioDeviceModule: - (nullable webrtc::AudioDeviceModule *)audioDeviceModule - audioProcessingModule: - (rtc::scoped_refptr)audioProcessingModule; +/* Initialize object with injectable native audio/video encoder/decoder + * factories */ +- (instancetype) + initWithNativeAudioEncoderFactory: + (rtc::scoped_refptr)audioEncoderFactory + nativeAudioDecoderFactory: + (rtc::scoped_refptr) + audioDecoderFactory + nativeVideoEncoderFactory: + (std::unique_ptr) + videoEncoderFactory + nativeVideoDecoderFactory: + (std::unique_ptr) + videoDecoderFactory + audioDeviceModule: + (nullable webrtc::AudioDeviceModule *)audioDeviceModule + audioProcessingModule: + (rtc::scoped_refptr) + audioProcessingModule; - (instancetype) initWithNativeAudioEncoderFactory: (rtc::scoped_refptr)audioEncoderFactory nativeAudioDecoderFactory: - (rtc::scoped_refptr)audioDecoderFactory + (rtc::scoped_refptr) + audioDecoderFactory nativeVideoEncoderFactory: - (std::unique_ptr)videoEncoderFactory + (std::unique_ptr) + videoEncoderFactory nativeVideoDecoderFactory: - (std::unique_ptr)videoDecoderFactory - audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule + (std::unique_ptr) + videoDecoderFactory + audioDeviceModule: + (nullable webrtc::AudioDeviceModule *)audioDeviceModule audioProcessingModule: - (rtc::scoped_refptr)audioProcessingModule - networkControllerFactory:(std::unique_ptr) - networkControllerFactory; + (rtc::scoped_refptr) + audioProcessingModule + networkControllerFactory: + (std::unique_ptr) + networkControllerFactory; - (instancetype) - initWithEncoderFactory:(nullable id)encoderFactory - decoderFactory:(nullable id)decoderFactory; + initWithEncoderFactory: + (nullable id)encoderFactory + decoderFactory:(nullable id) + decoderFactory; /** Initialize an RTCPeerConnection with a configuration, constraints, and * dependencies. */ - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithDependencies:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies:(std::unique_ptr)dependencies - delegate:(nullable id)delegate; + peerConnectionWithDependencies: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + dependencies: + (std::unique_ptr) + dependencies + delegate:(nullable id)delegate; @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h index 822585ddc2..7913862402 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h @@ -24,8 +24,8 @@ NS_ASSUME_NONNULL_BEGIN * RTCPeerConnectionFactory object. This is needed to pass to the underlying * C++ APIs. */ - @property(nonatomic, - readonly) rtc::scoped_refptr nativeFactory; + @property(nonatomic, readonly) rtc::scoped_refptr< + webrtc::PeerConnectionFactoryInterface> nativeFactory; @property(nonatomic, readonly) rtc::Thread* signalingThread; @property(nonatomic, readonly) rtc::Thread* workerThread; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 9abee87c7e..abfa679a1c 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -41,40 +41,50 @@ RTC_OBJC_EXPORT /* Initialize object with default H264 video encoder/decoder factories and default ADM */ - (instancetype)init; -/* Initialize object with injectable video encoder/decoder factories and default ADM */ +/* Initialize object with injectable video encoder/decoder factories and default + * ADM */ - (instancetype) - initWithEncoderFactory:(nullable id)encoderFactory - decoderFactory:(nullable id)decoderFactory; + initWithEncoderFactory: + (nullable id)encoderFactory + decoderFactory:(nullable id) + decoderFactory; -/* Initialize object with injectable video encoder/decoder factories and injectable ADM */ +/* Initialize object with injectable video encoder/decoder factories and + * injectable ADM */ - (instancetype) - initWithEncoderFactory:(nullable id)encoderFactory - decoderFactory:(nullable id)decoderFactory - audioDevice:(nullable id)audioDevice; + initWithEncoderFactory: + (nullable id)encoderFactory + decoderFactory:(nullable id) + decoderFactory + audioDevice: + (nullable id)audioDevice; /** * Valid kind values are kRTCMediaStreamTrackKindAudio and * kRTCMediaStreamTrackKindVideo. */ -- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesForKind:(NSString *)kind; +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesForKind: + (NSString *)kind; /** * Valid kind values are kRTCMediaStreamTrackKindAudio and * kRTCMediaStreamTrackKindVideo. */ -- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesForKind:(NSString *)kind; +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesForKind: + (NSString *)kind; /** Initialize an RTCAudioSource with constraints. */ - (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: (nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints; -/** Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio source - * with no constraints. +/** Initialize an RTCAudioTrack with an id. Convenience ctor to use an audio + * source with no constraints. */ - (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithTrackId:(NSString *)trackId; /** Initialize an RTCAudioTrack with a source and an id. */ -- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithSource:(RTC_OBJC_TYPE(RTCAudioSource) *)source +- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithSource: + (RTC_OBJC_TYPE(RTCAudioSource) *)source trackId:(NSString *)trackId; /** Initialize a generic RTCVideoSource. The RTCVideoSource should be @@ -91,7 +101,8 @@ RTC_OBJC_EXPORT - (RTC_OBJC_TYPE(RTCVideoSource) *)videoSourceForScreenCast:(BOOL)forScreenCast; /** Initialize an RTCVideoTrack with a source and an id. */ -- (RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrackWithSource:(RTC_OBJC_TYPE(RTCVideoSource) *)source +- (RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrackWithSource: + (RTC_OBJC_TYPE(RTCVideoSource) *)source trackId:(NSString *)trackId; /** Initialize an RTCMediaStream with an id. */ @@ -101,22 +112,32 @@ RTC_OBJC_EXPORT * delegate. */ - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - delegate:(nullable id)delegate; + peerConnectionWithConfiguration: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + delegate:(nullable id)delegate; - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + peerConnectionWithConfiguration: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints certificateVerifier: - (id)certificateVerifier - delegate:(nullable id)delegate; + (id) + certificateVerifier + delegate:(nullable id)delegate; /** Set the options to be used for subsequently created RTCPeerConnections */ -- (void)setOptions:(nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options; +- (void)setOptions: + (nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options; -/** Start an AecDump recording. This API call will likely change in the future. */ -- (BOOL)startAecDumpWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes; +/** Start an AecDump recording. This API call will likely change in the future. + */ +- (BOOL)startAecDumpWithFilePath:(NSString *)filePath + maxSizeInBytes:(int64_t)maxSizeInBytes; /* Stop an active AecDump recording */ - (void)stopAecDump; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 0ebd7d2382..710ff3b480 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -72,8 +72,10 @@ - (instancetype)init { webrtc::PeerConnectionFactoryDependencies dependencies; - dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); - dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); + dependencies.audio_encoder_factory = + webrtc::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = + webrtc::CreateBuiltinAudioDecoderFactory(); dependencies.video_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory( [[RTC_OBJC_TYPE(RTCVideoEncoderFactoryH264) alloc] init]); dependencies.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory( @@ -83,26 +85,37 @@ } - (instancetype) - initWithEncoderFactory:(nullable id)encoderFactory - decoderFactory:(nullable id)decoderFactory { - return [self initWithEncoderFactory:encoderFactory decoderFactory:decoderFactory audioDevice:nil]; + initWithEncoderFactory: + (nullable id)encoderFactory + decoderFactory:(nullable id) + decoderFactory { + return [self initWithEncoderFactory:encoderFactory + decoderFactory:decoderFactory + audioDevice:nil]; } - (instancetype) - initWithEncoderFactory:(nullable id)encoderFactory - decoderFactory:(nullable id)decoderFactory - audioDevice:(nullable id)audioDevice { + initWithEncoderFactory: + (nullable id)encoderFactory + decoderFactory:(nullable id) + decoderFactory + audioDevice: + (nullable id)audioDevice { #ifdef HAVE_NO_MEDIA return [self initWithNoMedia]; #else webrtc::PeerConnectionFactoryDependencies dependencies; - dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); - dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); + dependencies.audio_encoder_factory = + webrtc::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = + webrtc::CreateBuiltinAudioDecoderFactory(); if (encoderFactory) { - dependencies.video_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory); + dependencies.video_encoder_factory = + webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory); } if (decoderFactory) { - dependencies.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory); + dependencies.video_decoder_factory = + webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory); } if (audioDevice) { dependencies.adm = webrtc::CreateAudioDeviceModule(audioDevice); @@ -113,7 +126,8 @@ #endif } -- (instancetype)initWithNativeDependencies:(webrtc::PeerConnectionFactoryDependencies)dependencies { +- (instancetype)initWithNativeDependencies: + (webrtc::PeerConnectionFactoryDependencies)dependencies { self = [super init]; if (self) { _networkThread = rtc::Thread::CreateWithSocketServer(); @@ -131,7 +145,8 @@ result = _signalingThread->Start(); RTC_DCHECK(result) << "Failed to start signaling thread."; - // Set fields that are relevant both to 'no media' and 'with media' scenarios. + // Set fields that are relevant both to 'no media' and 'with media' + // scenarios. dependencies.network_thread = _networkThread.get(); dependencies.worker_thread = _workerThread.get(); dependencies.signaling_thread = _signalingThread.get(); @@ -140,30 +155,39 @@ } if (dependencies.network_monitor_factory == nullptr && dependencies.trials->IsEnabled("WebRTC-Network-UseNWPathMonitor")) { - dependencies.network_monitor_factory = webrtc::CreateNetworkMonitorFactory(); + dependencies.network_monitor_factory = + webrtc::CreateNetworkMonitorFactory(); } - _nativeFactory = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); + _nativeFactory = + webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); } return self; } - (instancetype)initWithNoMedia { - return [self initWithNativeDependencies:webrtc::PeerConnectionFactoryDependencies()]; + return [self + initWithNativeDependencies:webrtc::PeerConnectionFactoryDependencies()]; } -- (instancetype)initWithNativeAudioEncoderFactory: - (rtc::scoped_refptr)audioEncoderFactory - nativeAudioDecoderFactory: - (rtc::scoped_refptr)audioDecoderFactory - nativeVideoEncoderFactory: - (std::unique_ptr)videoEncoderFactory - nativeVideoDecoderFactory: - (std::unique_ptr)videoDecoderFactory - audioDeviceModule:(webrtc::AudioDeviceModule *)audioDeviceModule - audioProcessingModule: - (rtc::scoped_refptr)audioProcessingModule { +- (instancetype) + initWithNativeAudioEncoderFactory: + (rtc::scoped_refptr)audioEncoderFactory + nativeAudioDecoderFactory: + (rtc::scoped_refptr) + audioDecoderFactory + nativeVideoEncoderFactory: + (std::unique_ptr) + videoEncoderFactory + nativeVideoDecoderFactory: + (std::unique_ptr) + videoDecoderFactory + audioDeviceModule: + (webrtc::AudioDeviceModule *)audioDeviceModule + audioProcessingModule: + (rtc::scoped_refptr) + audioProcessingModule { webrtc::PeerConnectionFactoryDependencies dependencies; dependencies.audio_encoder_factory = std::move(audioEncoderFactory); dependencies.audio_decoder_factory = std::move(audioDecoderFactory); @@ -171,25 +195,32 @@ dependencies.video_decoder_factory = std::move(videoDecoderFactory); dependencies.adm = std::move(audioDeviceModule); if (audioProcessingModule != nullptr) { - dependencies.audio_processing_builder = CustomAudioProcessing(std::move(audioProcessingModule)); + dependencies.audio_processing_builder = + CustomAudioProcessing(std::move(audioProcessingModule)); } return [self initWithMediaAndDependencies:std::move(dependencies)]; } -- (instancetype)initWithNativeAudioEncoderFactory: - (rtc::scoped_refptr)audioEncoderFactory - nativeAudioDecoderFactory: - (rtc::scoped_refptr)audioDecoderFactory - nativeVideoEncoderFactory: - (std::unique_ptr)videoEncoderFactory - nativeVideoDecoderFactory: - (std::unique_ptr)videoDecoderFactory - audioDeviceModule:(webrtc::AudioDeviceModule *)audioDeviceModule - audioProcessingModule: - (rtc::scoped_refptr)audioProcessingModule - networkControllerFactory: - (std::unique_ptr) - networkControllerFactory { +- (instancetype) + initWithNativeAudioEncoderFactory: + (rtc::scoped_refptr)audioEncoderFactory + nativeAudioDecoderFactory: + (rtc::scoped_refptr) + audioDecoderFactory + nativeVideoEncoderFactory: + (std::unique_ptr) + videoEncoderFactory + nativeVideoDecoderFactory: + (std::unique_ptr) + videoDecoderFactory + audioDeviceModule: + (webrtc::AudioDeviceModule *)audioDeviceModule + audioProcessingModule: + (rtc::scoped_refptr) + audioProcessingModule + networkControllerFactory: + (std::unique_ptr) + networkControllerFactory { webrtc::PeerConnectionFactoryDependencies dependencies; dependencies.adm = std::move(audioDeviceModule); dependencies.audio_encoder_factory = std::move(audioEncoderFactory); @@ -197,7 +228,8 @@ dependencies.video_encoder_factory = std::move(videoEncoderFactory); dependencies.video_decoder_factory = std::move(videoDecoderFactory); if (audioProcessingModule != nullptr) { - dependencies.audio_processing_builder = CustomAudioProcessing(std::move(audioProcessingModule)); + dependencies.audio_processing_builder = + CustomAudioProcessing(std::move(audioProcessingModule)); } dependencies.network_controller_factory = std::move(networkControllerFactory); return [self initWithMediaAndDependencies:std::move(dependencies)]; @@ -218,24 +250,31 @@ } #endif if (dependencies.event_log_factory == nullptr) { - dependencies.event_log_factory = std::make_unique(); + dependencies.event_log_factory = + std::make_unique(); } webrtc::EnableMedia(dependencies); return [self initWithNativeDependencies:std::move(dependencies)]; } -- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesForKind:(NSString *)kind { +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesForKind: + (NSString *)kind { cricket::MediaType mediaType = [[self class] mediaTypeForKind:kind]; - webrtc::RtpCapabilities rtpCapabilities = _nativeFactory->GetRtpSenderCapabilities(mediaType); - return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] initWithNativeRtpCapabilities:rtpCapabilities]; + webrtc::RtpCapabilities rtpCapabilities = + _nativeFactory->GetRtpSenderCapabilities(mediaType); + return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] + initWithNativeRtpCapabilities:rtpCapabilities]; } -- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesForKind:(NSString *)kind { +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesForKind: + (NSString *)kind { cricket::MediaType mediaType = [[self class] mediaTypeForKind:kind]; - webrtc::RtpCapabilities rtpCapabilities = _nativeFactory->GetRtpReceiverCapabilities(mediaType); - return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] initWithNativeRtpCapabilities:rtpCapabilities]; + webrtc::RtpCapabilities rtpCapabilities = + _nativeFactory->GetRtpReceiverCapabilities(mediaType); + return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] + initWithNativeRtpCapabilities:rtpCapabilities]; } - (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: @@ -249,46 +288,61 @@ rtc::scoped_refptr source = _nativeFactory->CreateAudioSource(options); - return [[RTC_OBJC_TYPE(RTCAudioSource) alloc] initWithFactory:self nativeAudioSource:source]; + return [[RTC_OBJC_TYPE(RTCAudioSource) alloc] initWithFactory:self + nativeAudioSource:source]; } - (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithTrackId:(NSString *)trackId { - RTC_OBJC_TYPE(RTCAudioSource) *audioSource = [self audioSourceWithConstraints:nil]; + RTC_OBJC_TYPE(RTCAudioSource) *audioSource = + [self audioSourceWithConstraints:nil]; return [self audioTrackWithSource:audioSource trackId:trackId]; } -- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithSource:(RTC_OBJC_TYPE(RTCAudioSource) *)source +- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithSource: + (RTC_OBJC_TYPE(RTCAudioSource) *)source trackId:(NSString *)trackId { - return [[RTC_OBJC_TYPE(RTCAudioTrack) alloc] initWithFactory:self source:source trackId:trackId]; + return [[RTC_OBJC_TYPE(RTCAudioTrack) alloc] initWithFactory:self + source:source + trackId:trackId]; } - (RTC_OBJC_TYPE(RTCVideoSource) *)videoSource { - return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self - signalingThread:_signalingThread.get() - workerThread:_workerThread.get()]; + return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] + initWithFactory:self + signalingThread:_signalingThread.get() + workerThread:_workerThread.get()]; } -- (RTC_OBJC_TYPE(RTCVideoSource) *)videoSourceForScreenCast:(BOOL)forScreenCast { - return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self - signalingThread:_signalingThread.get() - workerThread:_workerThread.get() - isScreenCast:forScreenCast]; +- (RTC_OBJC_TYPE(RTCVideoSource) *)videoSourceForScreenCast: + (BOOL)forScreenCast { + return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] + initWithFactory:self + signalingThread:_signalingThread.get() + workerThread:_workerThread.get() + isScreenCast:forScreenCast]; } -- (RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrackWithSource:(RTC_OBJC_TYPE(RTCVideoSource) *)source +- (RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrackWithSource: + (RTC_OBJC_TYPE(RTCVideoSource) *)source trackId:(NSString *)trackId { - return [[RTC_OBJC_TYPE(RTCVideoTrack) alloc] initWithFactory:self source:source trackId:trackId]; + return [[RTC_OBJC_TYPE(RTCVideoTrack) alloc] initWithFactory:self + source:source + trackId:trackId]; } -- (RTC_OBJC_TYPE(RTCMediaStream) *)mediaStreamWithStreamId:(NSString *)streamId { - return [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:self streamId:streamId]; +- (RTC_OBJC_TYPE(RTCMediaStream) *)mediaStreamWithStreamId: + (NSString *)streamId { + return [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:self + streamId:streamId]; } - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - delegate: - (nullable id)delegate { + peerConnectionWithConfiguration: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + delegate:(nullable id)delegate { return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self configuration:configuration constraints:constraints @@ -297,32 +351,44 @@ } - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + peerConnectionWithConfiguration: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints certificateVerifier: - (id)certificateVerifier - delegate: - (nullable id)delegate { - return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self - configuration:configuration - constraints:constraints - certificateVerifier:certificateVerifier - delegate:delegate]; + (id) + certificateVerifier + delegate:(nullable id)delegate { + return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] + initWithFactory:self + configuration:configuration + constraints:constraints + certificateVerifier:certificateVerifier + delegate:delegate]; } - (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) - peerConnectionWithDependencies:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - dependencies:(std::unique_ptr)dependencies - delegate:(id)delegate { - return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithDependencies:self - configuration:configuration - constraints:constraints - dependencies:std::move(dependencies) - delegate:delegate]; + peerConnectionWithDependencies: + (RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints: + (RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + dependencies: + (std::unique_ptr) + dependencies + delegate: + (id) + delegate { + return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] + initWithDependencies:self + configuration:configuration + constraints:constraints + dependencies:std::move(dependencies) + delegate:delegate]; } -- (void)setOptions:(nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options { +- (void)setOptions: + (nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options { RTC_DCHECK(options != nil); _nativeFactory->SetOptions(options.nativeOptions); } @@ -338,7 +404,8 @@ } FILE *f = fopen(filePath.UTF8String, "wb"); if (!f) { - RTCLogError(@"Error opening file: %@. Error: %s", filePath, strerror(errno)); + RTCLogError( + @"Error opening file: %@. Error: %s", filePath, strerror(errno)); return NO; } _hasStartedAecDump = _nativeFactory->StartAecDump(f, maxSizeInBytes); diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm index 522e520e12..e5eeba5992 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder+DefaultComponents.mm @@ -25,7 +25,8 @@ @implementation RTCPeerConnectionFactoryBuilder (DefaultComponents) + (RTCPeerConnectionFactoryBuilder *)defaultBuilder { - RTCPeerConnectionFactoryBuilder *builder = [[RTCPeerConnectionFactoryBuilder alloc] init]; + RTCPeerConnectionFactoryBuilder *builder = + [[RTCPeerConnectionFactoryBuilder alloc] init]; auto audioEncoderFactory = webrtc::CreateBuiltinAudioEncoderFactory(); [builder setAudioEncoderFactory:audioEncoderFactory]; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h index 5902ac3cd8..f81eab2873 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h @@ -29,20 +29,27 @@ NS_ASSUME_NONNULL_BEGIN - (void)setFieldTrials:(std::unique_ptr)fieldTrials; -- (void)setVideoEncoderFactory:(std::unique_ptr)videoEncoderFactory; +- (void)setVideoEncoderFactory: + (std::unique_ptr)videoEncoderFactory; -- (void)setVideoDecoderFactory:(std::unique_ptr)videoDecoderFactory; +- (void)setVideoDecoderFactory: + (std::unique_ptr)videoDecoderFactory; -- (void)setAudioEncoderFactory:(rtc::scoped_refptr)audioEncoderFactory; +- (void)setAudioEncoderFactory: + (rtc::scoped_refptr)audioEncoderFactory; -- (void)setAudioDecoderFactory:(rtc::scoped_refptr)audioDecoderFactory; +- (void)setAudioDecoderFactory: + (rtc::scoped_refptr)audioDecoderFactory; -- (void)setAudioDeviceModule:(rtc::scoped_refptr)audioDeviceModule; +- (void)setAudioDeviceModule: + (rtc::scoped_refptr)audioDeviceModule; -- (void)setAudioProcessingModule:(rtc::scoped_refptr)audioProcessingModule; +- (void)setAudioProcessingModule: + (rtc::scoped_refptr)audioProcessingModule; - (void)setAudioProcessingBuilder: - (std::unique_ptr)audioProcessingBuilder; + (std::unique_ptr) + audioProcessingBuilder; @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm index b3a9f8651a..53eac6df28 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.mm @@ -35,35 +35,40 @@ _dependencies.trials = std::move(fieldTrials); } -- (void)setVideoEncoderFactory:(std::unique_ptr)videoEncoderFactory { +- (void)setVideoEncoderFactory: + (std::unique_ptr)videoEncoderFactory { _dependencies.video_encoder_factory = std::move(videoEncoderFactory); } -- (void)setVideoDecoderFactory:(std::unique_ptr)videoDecoderFactory { +- (void)setVideoDecoderFactory: + (std::unique_ptr)videoDecoderFactory { _dependencies.video_decoder_factory = std::move(videoDecoderFactory); } - (void)setAudioEncoderFactory: - (rtc::scoped_refptr)audioEncoderFactory { + (rtc::scoped_refptr)audioEncoderFactory { _dependencies.audio_encoder_factory = std::move(audioEncoderFactory); } - (void)setAudioDecoderFactory: - (rtc::scoped_refptr)audioDecoderFactory { + (rtc::scoped_refptr)audioDecoderFactory { _dependencies.audio_decoder_factory = std::move(audioDecoderFactory); } -- (void)setAudioDeviceModule:(rtc::scoped_refptr)audioDeviceModule { +- (void)setAudioDeviceModule: + (rtc::scoped_refptr)audioDeviceModule { _dependencies.adm = std::move(audioDeviceModule); } - (void)setAudioProcessingModule: - (rtc::scoped_refptr)audioProcessingModule { - _dependencies.audio_processing_builder = CustomAudioProcessing(std::move(audioProcessingModule)); + (rtc::scoped_refptr)audioProcessingModule { + _dependencies.audio_processing_builder = + CustomAudioProcessing(std::move(audioProcessingModule)); } - (void)setAudioProcessingBuilder: - (std::unique_ptr)audioProcessingBuilder { + (std::unique_ptr) + audioProcessingBuilder { _dependencies.audio_processing_builder = std::move(audioProcessingBuilder); } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h index 8832b23695..fbc22fd2d9 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions+Private.h @@ -19,7 +19,8 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the equivalent native PeerConnectionFactoryInterface::Options * structure. */ - @property(nonatomic, readonly) webrtc::PeerConnectionFactoryInterface::Options nativeOptions; + @property(nonatomic, readonly) + webrtc::PeerConnectionFactoryInterface::Options nativeOptions; @end diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions.mm index 5467bd5fc9..6c89a2236b 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryOptions.mm @@ -44,11 +44,15 @@ void setNetworkBit(webrtc::PeerConnectionFactoryInterface::Options* options, options.disable_encryption = self.disableEncryption; options.disable_network_monitor = self.disableNetworkMonitor; - setNetworkBit(&options, rtc::ADAPTER_TYPE_LOOPBACK, self.ignoreLoopbackNetworkAdapter); + setNetworkBit( + &options, rtc::ADAPTER_TYPE_LOOPBACK, self.ignoreLoopbackNetworkAdapter); setNetworkBit(&options, rtc::ADAPTER_TYPE_VPN, self.ignoreVPNNetworkAdapter); - setNetworkBit(&options, rtc::ADAPTER_TYPE_CELLULAR, self.ignoreCellularNetworkAdapter); - setNetworkBit(&options, rtc::ADAPTER_TYPE_WIFI, self.ignoreWiFiNetworkAdapter); - setNetworkBit(&options, rtc::ADAPTER_TYPE_ETHERNET, self.ignoreEthernetNetworkAdapter); + setNetworkBit( + &options, rtc::ADAPTER_TYPE_CELLULAR, self.ignoreCellularNetworkAdapter); + setNetworkBit( + &options, rtc::ADAPTER_TYPE_WIFI, self.ignoreWiFiNetworkAdapter); + setNetworkBit( + &options, rtc::ADAPTER_TYPE_ETHERNET, self.ignoreEthernetNetworkAdapter); return options; } diff --git a/sdk/objc/api/peerconnection/RTCRtcpParameters+Private.h b/sdk/objc/api/peerconnection/RTCRtcpParameters+Private.h index c4d196cf79..571a52ac87 100644 --- a/sdk/objc/api/peerconnection/RTCRtcpParameters+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtcpParameters+Private.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtcpParameters nativeParameters; /** Initialize the object with a native RtcpParameters structure. */ -- (instancetype)initWithNativeParameters:(const webrtc::RtcpParameters &)nativeParameters - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNativeParameters: + (const webrtc::RtcpParameters &)nativeParameters NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtcpParameters.mm b/sdk/objc/api/peerconnection/RTCRtcpParameters.mm index 058600b340..7bb5d85594 100644 --- a/sdk/objc/api/peerconnection/RTCRtcpParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtcpParameters.mm @@ -22,7 +22,8 @@ return [self initWithNativeParameters:nativeParameters]; } -- (instancetype)initWithNativeParameters:(const webrtc::RtcpParameters &)nativeParameters { +- (instancetype)initWithNativeParameters: + (const webrtc::RtcpParameters &)nativeParameters { self = [super init]; if (self) { _cname = [NSString stringForStdString:nativeParameters.cname]; diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h index be51993f2f..2ccb642370 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h @@ -14,18 +14,21 @@ NS_ASSUME_NONNULL_BEGIN -@interface RTC_OBJC_TYPE (RTCRtpCapabilities)() +@interface RTC_OBJC_TYPE (RTCRtpCapabilities) +() -/** - * The native RtpCapabilities representation of this RTCRtpCapabilities - * object. This is needed to pass to the underlying C++ APIs. - */ -@property(nonatomic, readonly) webrtc::RtpCapabilities nativeRtpCapabilities; + /** + * The native RtpCapabilities representation of this RTCRtpCapabilities + * object. This is needed to pass to the underlying C++ APIs. + */ + @property(nonatomic, + readonly) webrtc::RtpCapabilities nativeRtpCapabilities; /** * Initialize an RTCRtpCapabilities from a native RtpCapabilities. */ -- (instancetype)initWithNativeRtpCapabilities:(const webrtc::RtpCapabilities &)rtpCapabilities; +- (instancetype)initWithNativeRtpCapabilities: + (const webrtc::RtpCapabilities &)rtpCapabilities; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm index b332181e8f..2f373590bc 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm @@ -38,9 +38,12 @@ _codecs = codecs; NSMutableArray *headerExtensions = [[NSMutableArray alloc] init]; - for (const auto &headerExtension : nativeRtpCapabilities.header_extensions) { - [headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] - initWithNativeRtpHeaderExtensionCapability:headerExtension]]; + for (const auto &headerExtension : + nativeRtpCapabilities.header_extensions) { + [headerExtensions + addObject: + [[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] + initWithNativeRtpHeaderExtensionCapability:headerExtension]]; } _headerExtensions = headerExtensions; } @@ -52,8 +55,10 @@ for (RTC_OBJC_TYPE(RTCRtpCodecCapability) * codec in _codecs) { rtpCapabilities.codecs.push_back(codec.nativeRtpCodecCapability); } - for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * headerExtension in _headerExtensions) { - rtpCapabilities.header_extensions.push_back(headerExtension.nativeRtpHeaderExtensionCapability); + for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * + headerExtension in _headerExtensions) { + rtpCapabilities.header_extensions.push_back( + headerExtension.nativeRtpHeaderExtensionCapability); } return rtpCapabilities; } diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h index 6af13b3b23..f880e30afd 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h @@ -14,13 +14,16 @@ NS_ASSUME_NONNULL_BEGIN -@interface RTC_OBJC_TYPE (RTCRtpCodecCapability)() +@interface RTC_OBJC_TYPE (RTCRtpCodecCapability) +() -/** - * The native RtpCodecCapability representation of this RTCRtpCodecCapability - * object. This is needed to pass to the underlying C++ APIs. - */ -@property(nonatomic, readonly) webrtc::RtpCodecCapability nativeRtpCodecCapability; + /** + * The native RtpCodecCapability representation of this + * RTCRtpCodecCapability object. This is needed to pass to the underlying + * C++ APIs. + */ + @property(nonatomic, + readonly) webrtc::RtpCodecCapability nativeRtpCodecCapability; /** * Initialize an RTCRtpCodecCapability from a native RtpCodecCapability. diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index cfce5e3dbd..f6f72e859b 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -36,8 +36,8 @@ self = [super init]; if (self) { if (nativeRtpCodecCapability.preferred_payload_type) { - _preferredPayloadType = - [NSNumber numberWithInt:*nativeRtpCodecCapability.preferred_payload_type]; + _preferredPayloadType = [NSNumber + numberWithInt:*nativeRtpCodecCapability.preferred_payload_type]; } _name = [NSString stringForStdString:nativeRtpCodecCapability.name]; switch (nativeRtpCodecCapability.kind) { @@ -55,10 +55,12 @@ break; } if (nativeRtpCodecCapability.clock_rate) { - _clockRate = [NSNumber numberWithInt:*nativeRtpCodecCapability.clock_rate]; + _clockRate = + [NSNumber numberWithInt:*nativeRtpCodecCapability.clock_rate]; } if (nativeRtpCodecCapability.num_channels) { - _numChannels = [NSNumber numberWithInt:*nativeRtpCodecCapability.num_channels]; + _numChannels = + [NSNumber numberWithInt:*nativeRtpCodecCapability.num_channels]; } NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; for (const auto ¶meter : nativeRtpCodecCapability.parameters) { @@ -66,29 +68,32 @@ forKey:[NSString stringForStdString:parameter.first]]; } _parameters = parameters; - _mimeType = [NSString stringForStdString:nativeRtpCodecCapability.mime_type()]; + _mimeType = + [NSString stringForStdString:nativeRtpCodecCapability.mime_type()]; } return self; } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpCodecCapability) {\n " - @"preferredPayloadType: %@\n name: %@\n kind: %@\n " - @"clockRate: %@\n numChannels: %@\n parameters: %@\n " - @"mimeType: %@\n}", - _preferredPayloadType, - _name, - _kind, - _clockRate, - _numChannels, - _parameters, - _mimeType]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpCodecCapability) {\n " + @"preferredPayloadType: %@\n name: %@\n kind: %@\n " + @"clockRate: %@\n numChannels: %@\n parameters: %@\n " + @"mimeType: %@\n}", + _preferredPayloadType, + _name, + _kind, + _clockRate, + _numChannels, + _parameters, + _mimeType]; } - (webrtc::RtpCodecCapability)nativeRtpCodecCapability { webrtc::RtpCodecCapability rtpCodecCapability; if (_preferredPayloadType != nil) { - rtpCodecCapability.preferred_payload_type = std::optional(_preferredPayloadType.intValue); + rtpCodecCapability.preferred_payload_type = + std::optional(_preferredPayloadType.intValue); } rtpCodecCapability.name = [NSString stdStringForString:_name]; // NSString pointer comparison is safe here since "kind" is readonly and only diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecParameters+Private.h b/sdk/objc/api/peerconnection/RTCRtpCodecParameters+Private.h index ff23cfd642..a67bd378e0 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters+Private.h @@ -21,7 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpCodecParameters nativeParameters; /** Initialize the object with a native RtpCodecParameters structure. */ -- (instancetype)initWithNativeParameters:(const webrtc::RtpCodecParameters &)nativeParameters +- (instancetype)initWithNativeParameters: + (const webrtc::RtpCodecParameters &)nativeParameters NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm index f01d367099..8684d4b61a 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm @@ -16,22 +16,22 @@ #include "media/base/media_constants.h" #include "rtc_base/checks.h" -const NSString * const kRTCRtxCodecName = @(cricket::kRtxCodecName); -const NSString * const kRTCRedCodecName = @(cricket::kRedCodecName); -const NSString * const kRTCUlpfecCodecName = @(cricket::kUlpfecCodecName); -const NSString * const kRTCFlexfecCodecName = @(cricket::kFlexfecCodecName); -const NSString * const kRTCOpusCodecName = @(cricket::kOpusCodecName); -const NSString * const kRTCL16CodecName = @(cricket::kL16CodecName); -const NSString * const kRTCG722CodecName = @(cricket::kG722CodecName); -const NSString * const kRTCIlbcCodecName = @(cricket::kIlbcCodecName); -const NSString * const kRTCPcmuCodecName = @(cricket::kPcmuCodecName); -const NSString * const kRTCPcmaCodecName = @(cricket::kPcmaCodecName); -const NSString * const kRTCDtmfCodecName = @(cricket::kDtmfCodecName); -const NSString * const kRTCComfortNoiseCodecName = +const NSString *const kRTCRtxCodecName = @(cricket::kRtxCodecName); +const NSString *const kRTCRedCodecName = @(cricket::kRedCodecName); +const NSString *const kRTCUlpfecCodecName = @(cricket::kUlpfecCodecName); +const NSString *const kRTCFlexfecCodecName = @(cricket::kFlexfecCodecName); +const NSString *const kRTCOpusCodecName = @(cricket::kOpusCodecName); +const NSString *const kRTCL16CodecName = @(cricket::kL16CodecName); +const NSString *const kRTCG722CodecName = @(cricket::kG722CodecName); +const NSString *const kRTCIlbcCodecName = @(cricket::kIlbcCodecName); +const NSString *const kRTCPcmuCodecName = @(cricket::kPcmuCodecName); +const NSString *const kRTCPcmaCodecName = @(cricket::kPcmaCodecName); +const NSString *const kRTCDtmfCodecName = @(cricket::kDtmfCodecName); +const NSString *const kRTCComfortNoiseCodecName = @(cricket::kComfortNoiseCodecName); -const NSString * const kRTCVp8CodecName = @(cricket::kVp8CodecName); -const NSString * const kRTCVp9CodecName = @(cricket::kVp9CodecName); -const NSString * const kRTCH264CodecName = @(cricket::kH264CodecName); +const NSString *const kRTCVp8CodecName = @(cricket::kVp8CodecName); +const NSString *const kRTCVp9CodecName = @(cricket::kVp9CodecName); +const NSString *const kRTCH264CodecName = @(cricket::kH264CodecName); @implementation RTC_OBJC_TYPE (RTCRtpCodecParameters) diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters+Private.h b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters+Private.h index d12ca624e3..a7607aacd2 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters+Private.h @@ -18,10 +18,12 @@ NS_ASSUME_NONNULL_BEGIN () /** Returns the equivalent native RtpEncodingParameters structure. */ - @property(nonatomic, readonly) webrtc::RtpEncodingParameters nativeParameters; + @property(nonatomic, + readonly) webrtc::RtpEncodingParameters nativeParameters; /** Initialize the object with a native RtpEncodingParameters structure. */ -- (instancetype)initWithNativeParameters:(const webrtc::RtpEncodingParameters &)nativeParameters +- (instancetype)initWithNativeParameters: + (const webrtc::RtpEncodingParameters &)nativeParameters NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h index 467b51de98..e1829ea164 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h @@ -66,7 +66,8 @@ RTC_OBJC_EXPORT @property(nonatomic, assign) RTCPriority networkPriority; /** Allow dynamic frame length changes for audio: - https://w3c.github.io/webrtc-extensions/#dom-rtcrtpencodingparameters-adaptiveptime */ + https://w3c.github.io/webrtc-extensions/#dom-rtcrtpencodingparameters-adaptiveptime + */ @property(nonatomic, assign) BOOL adaptiveAudioPacketTime; - (instancetype)init; diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm index 69f8885f4c..49ae8a192c 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm @@ -51,11 +51,12 @@ _maxFramerate = [NSNumber numberWithInt:*nativeParameters.max_framerate]; } if (nativeParameters.num_temporal_layers) { - _numTemporalLayers = [NSNumber numberWithInt:*nativeParameters.num_temporal_layers]; + _numTemporalLayers = + [NSNumber numberWithInt:*nativeParameters.num_temporal_layers]; } if (nativeParameters.scale_resolution_down_by) { - _scaleResolutionDownBy = - [NSNumber numberWithDouble:*nativeParameters.scale_resolution_down_by]; + _scaleResolutionDownBy = [NSNumber + numberWithDouble:*nativeParameters.scale_resolution_down_by]; } if (nativeParameters.ssrc) { _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; @@ -84,17 +85,19 @@ parameters.max_framerate = std::optional(_maxFramerate.intValue); } if (_numTemporalLayers != nil) { - parameters.num_temporal_layers = std::optional(_numTemporalLayers.intValue); + parameters.num_temporal_layers = + std::optional(_numTemporalLayers.intValue); } if (_scaleResolutionDownBy != nil) { - parameters.scale_resolution_down_by = std::optional(_scaleResolutionDownBy.doubleValue); + parameters.scale_resolution_down_by = + std::optional(_scaleResolutionDownBy.doubleValue); } if (_ssrc != nil) { parameters.ssrc = std::optional(_ssrc.unsignedLongValue); } parameters.bitrate_priority = _bitratePriority; - parameters.network_priority = - [RTC_OBJC_TYPE(RTCRtpEncodingParameters) nativePriorityFromPriority:_networkPriority]; + parameters.network_priority = [RTC_OBJC_TYPE(RTCRtpEncodingParameters) + nativePriorityFromPriority:_networkPriority]; parameters.adaptive_ptime = _adaptiveAudioPacketTime; return parameters; } diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension+Private.h b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension+Private.h index 0e0fbba5ac..ee2b083de2 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension+Private.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpExtension nativeParameters; /** Initialize the object with a native RtpExtension structure. */ -- (instancetype)initWithNativeParameters:(const webrtc::RtpExtension &)nativeParameters - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNativeParameters: + (const webrtc::RtpExtension &)nativeParameters NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm index 0cbdb787ee..c399619fee 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm @@ -23,7 +23,8 @@ return [self initWithNativeParameters:nativeExtension]; } -- (instancetype)initWithNativeParameters:(const webrtc::RtpExtension &)nativeParameters { +- (instancetype)initWithNativeParameters: + (const webrtc::RtpExtension &)nativeParameters { self = [super init]; if (self) { _uri = [NSString stringForStdString:nativeParameters.uri]; diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability+Private.h b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability+Private.h index 4e800bc996..3db2440304 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability+Private.h @@ -14,17 +14,20 @@ NS_ASSUME_NONNULL_BEGIN -@interface RTC_OBJC_TYPE (RTCRtpHeaderExtensionCapability)() +@interface RTC_OBJC_TYPE (RTCRtpHeaderExtensionCapability) +() + + /** + * The native RtpHeaderExtensionCapability representation of this + * RTCRtpHeaderExtensionCapability object. This is needed to pass to the + * underlying C++ APIs. + */ + @property(nonatomic, readonly) webrtc::RtpHeaderExtensionCapability + nativeRtpHeaderExtensionCapability; /** -* The native RtpHeaderExtensionCapability representation of this -* RTCRtpHeaderExtensionCapability object. This is needed to pass to the underlying C++ APIs. -*/ -@property(nonatomic, - readonly) webrtc::RtpHeaderExtensionCapability nativeRtpHeaderExtensionCapability; - -/** - * Initialize an RTCRtpHeaderExtensionCapability from a native RtpHeaderExtensionCapability. + * Initialize an RTCRtpHeaderExtensionCapability from a native + * RtpHeaderExtensionCapability. */ - (instancetype)initWithNativeRtpHeaderExtensionCapability: (const webrtc::RtpHeaderExtensionCapability &)rtpHeaderExtensionCapability; diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.h b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.h index e84fcd180f..37e7788018 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.h @@ -26,7 +26,8 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly, nullable) NSNumber* preferredId; /** Whether the header extension is encrypted or not. */ -@property(nonatomic, readonly, getter=isPreferredEncrypted) BOOL preferredEncrypted; +@property(nonatomic, readonly, getter=isPreferredEncrypted) + BOOL preferredEncrypted; /** Direction of the header extension. */ @property(nonatomic) RTCRtpTransceiverDirection direction; diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm index 9fe4a67b1e..9ecc3d0bc4 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtensionCapability.mm @@ -22,41 +22,48 @@ - (instancetype)init { webrtc::RtpHeaderExtensionCapability nativeRtpHeaderExtensionCapability; - return [self initWithNativeRtpHeaderExtensionCapability:nativeRtpHeaderExtensionCapability]; + return [self initWithNativeRtpHeaderExtensionCapability: + nativeRtpHeaderExtensionCapability]; } - (instancetype)initWithNativeRtpHeaderExtensionCapability: - (const webrtc::RtpHeaderExtensionCapability &)nativeRtpHeaderExtensionCapability { + (const webrtc::RtpHeaderExtensionCapability &) + nativeRtpHeaderExtensionCapability { self = [super init]; if (self) { _uri = [NSString stringForStdString:nativeRtpHeaderExtensionCapability.uri]; if (nativeRtpHeaderExtensionCapability.preferred_id) { - _preferredId = [NSNumber numberWithInt:*nativeRtpHeaderExtensionCapability.preferred_id]; + _preferredId = [NSNumber + numberWithInt:*nativeRtpHeaderExtensionCapability.preferred_id]; } _preferredEncrypted = nativeRtpHeaderExtensionCapability.preferred_encrypt; _direction = [RTC_OBJC_TYPE(RTCRtpTransceiver) - rtpTransceiverDirectionFromNativeDirection:nativeRtpHeaderExtensionCapability.direction]; + rtpTransceiverDirectionFromNativeDirection: + nativeRtpHeaderExtensionCapability.direction]; } return self; } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) {\n uri: " - @"%@\n preferredId: %@\n preferredEncrypted: %d\n}", - _uri, - _preferredId, - _preferredEncrypted]; + return + [NSString stringWithFormat: + @"RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) {\n uri: " + @"%@\n preferredId: %@\n preferredEncrypted: %d\n}", + _uri, + _preferredId, + _preferredEncrypted]; } - (webrtc::RtpHeaderExtensionCapability)nativeRtpHeaderExtensionCapability { webrtc::RtpHeaderExtensionCapability rtpHeaderExtensionCapability; rtpHeaderExtensionCapability.uri = [NSString stdStringForString:_uri]; if (_preferredId != nil) { - rtpHeaderExtensionCapability.preferred_id = std::optional(_preferredId.intValue); + rtpHeaderExtensionCapability.preferred_id = + std::optional(_preferredId.intValue); } rtpHeaderExtensionCapability.preferred_encrypt = _preferredEncrypted; - rtpHeaderExtensionCapability.direction = - [RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:_direction]; + rtpHeaderExtensionCapability.direction = [RTC_OBJC_TYPE(RTCRtpTransceiver) + nativeRtpTransceiverDirectionFromDirection:_direction]; return rtpHeaderExtensionCapability; } diff --git a/sdk/objc/api/peerconnection/RTCRtpParameters+Private.h b/sdk/objc/api/peerconnection/RTCRtpParameters+Private.h index 139617f727..48ebe07468 100644 --- a/sdk/objc/api/peerconnection/RTCRtpParameters+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpParameters+Private.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly) webrtc::RtpParameters nativeParameters; /** Initialize the object with a native RtpParameters structure. */ -- (instancetype)initWithNativeParameters:(const webrtc::RtpParameters &)nativeParameters - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNativeParameters: + (const webrtc::RtpParameters &)nativeParameters NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpParameters.h b/sdk/objc/api/peerconnection/RTCRtpParameters.h index 15cb0d335c..ee1c540829 100644 --- a/sdk/objc/api/peerconnection/RTCRtpParameters.h +++ b/sdk/objc/api/peerconnection/RTCRtpParameters.h @@ -40,10 +40,12 @@ RTC_OBJC_EXPORT NSArray *headerExtensions; /** The currently active encodings in the order of preference. */ -@property(nonatomic, copy) NSArray *encodings; +@property(nonatomic, copy) + NSArray *encodings; /** The negotiated set of send codecs in order of preference. */ -@property(nonatomic, copy) NSArray *codecs; +@property(nonatomic, copy) + NSArray *codecs; /** * Degradation preference in case of CPU adaptation or constrained bandwidth. diff --git a/sdk/objc/api/peerconnection/RTCRtpParameters.mm b/sdk/objc/api/peerconnection/RTCRtpParameters.mm index 1c2a94ffac..dd7b0deab5 100644 --- a/sdk/objc/api/peerconnection/RTCRtpParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpParameters.mm @@ -34,14 +34,16 @@ (const webrtc::RtpParameters &)nativeParameters { self = [super init]; if (self) { - _transactionId = [NSString stringForStdString:nativeParameters.transaction_id]; - _rtcp = - [[RTC_OBJC_TYPE(RTCRtcpParameters) alloc] initWithNativeParameters:nativeParameters.rtcp]; + _transactionId = + [NSString stringForStdString:nativeParameters.transaction_id]; + _rtcp = [[RTC_OBJC_TYPE(RTCRtcpParameters) alloc] + initWithNativeParameters:nativeParameters.rtcp]; NSMutableArray *headerExtensions = [[NSMutableArray alloc] init]; for (const auto &headerExtension : nativeParameters.header_extensions) { - [headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtension) alloc] - initWithNativeParameters:headerExtension]]; + [headerExtensions + addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtension) alloc] + initWithNativeParameters:headerExtension]]; } _headerExtensions = headerExtensions; @@ -54,14 +56,14 @@ NSMutableArray *codecs = [[NSMutableArray alloc] init]; for (const auto &codec : nativeParameters.codecs) { - [codecs - addObject:[[RTC_OBJC_TYPE(RTCRtpCodecParameters) alloc] initWithNativeParameters:codec]]; + [codecs addObject:[[RTC_OBJC_TYPE(RTCRtpCodecParameters) alloc] + initWithNativeParameters:codec]]; } _codecs = codecs; _degradationPreference = [RTC_OBJC_TYPE(RTCRtpParameters) - degradationPreferenceFromNativeDegradationPreference:nativeParameters - .degradation_preference]; + degradationPreferenceFromNativeDegradationPreference: + nativeParameters.degradation_preference]; } return self; } @@ -70,7 +72,8 @@ webrtc::RtpParameters parameters; parameters.transaction_id = [NSString stdStringForString:_transactionId]; parameters.rtcp = [_rtcp nativeParameters]; - for (RTC_OBJC_TYPE(RTCRtpHeaderExtension) * headerExtension in _headerExtensions) { + for (RTC_OBJC_TYPE(RTCRtpHeaderExtension) * + headerExtension in _headerExtensions) { parameters.header_extensions.push_back(headerExtension.nativeParameters); } for (RTC_OBJC_TYPE(RTCRtpEncodingParameters) * encoding in _encodings) { @@ -81,14 +84,15 @@ } if (_degradationPreference) { parameters.degradation_preference = [RTC_OBJC_TYPE(RTCRtpParameters) - nativeDegradationPreferenceFromDegradationPreference:(RTCDegradationPreference) - _degradationPreference.intValue]; + nativeDegradationPreferenceFromDegradationPreference: + (RTCDegradationPreference)_degradationPreference.intValue]; } return parameters; } -+ (webrtc::DegradationPreference)nativeDegradationPreferenceFromDegradationPreference: - (RTCDegradationPreference)degradationPreference { ++ (webrtc::DegradationPreference) + nativeDegradationPreferenceFromDegradationPreference: + (RTCDegradationPreference)degradationPreference { switch (degradationPreference) { case RTCDegradationPreferenceDisabled: return webrtc::DegradationPreference::DISABLED; diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h b/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h index c15ce70079..4d4dc3ba78 100644 --- a/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h +++ b/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h @@ -16,7 +16,8 @@ NS_ASSUME_NONNULL_BEGIN /** - * This class extension exposes methods that work directly with injectable C++ components. + * This class extension exposes methods that work directly with injectable C++ + * components. */ @interface RTC_OBJC_TYPE (RTCRtpReceiver) () @@ -25,7 +26,8 @@ NS_ASSUME_NONNULL_BEGIN * This will decrypt the entire frame using the user provided decryption * mechanism regardless of whether SRTP is enabled or not. */ - - (void)setFrameDecryptor : (rtc::scoped_refptr)frameDecryptor; + - (void)setFrameDecryptor + : (rtc::scoped_refptr)frameDecryptor; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver+Private.h b/sdk/objc/api/peerconnection/RTCRtpReceiver+Private.h index eccbcbc3a0..38bdea2721 100644 --- a/sdk/objc/api/peerconnection/RTCRtpReceiver+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpReceiver+Private.h @@ -33,15 +33,18 @@ class RtpReceiverDelegateAdapter : public RtpReceiverObserverInterface { @interface RTC_OBJC_TYPE (RTCRtpReceiver) () - @property(nonatomic, - readonly) rtc::scoped_refptr nativeRtpReceiver; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeRtpReceiver; /** Initialize an RTCRtpReceiver with a native RtpReceiverInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpReceiver:(rtc::scoped_refptr)nativeRtpReceiver +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpReceiver: + (rtc::scoped_refptr)nativeRtpReceiver NS_DESIGNATED_INITIALIZER; -+ (RTCRtpMediaType)mediaTypeForNativeMediaType:(cricket::MediaType)nativeMediaType; ++ (RTCRtpMediaType)mediaTypeForNativeMediaType: + (cricket::MediaType)nativeMediaType; + (cricket::MediaType)nativeMediaTypeForMediaType:(RTCRtpMediaType)mediaType; diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver.h b/sdk/objc/api/peerconnection/RTCRtpReceiver.h index 1fc09b5227..d0c79fece7 100644 --- a/sdk/objc/api/peerconnection/RTCRtpReceiver.h +++ b/sdk/objc/api/peerconnection/RTCRtpReceiver.h @@ -33,18 +33,19 @@ RTC_OBJC_EXPORT /** Called when the first RTP packet is received. * - * Note: Currently if there are multiple RtpReceivers of the same media type, - * they will all call OnFirstPacketReceived at once. + * Note: Currently if there are multiple RtpReceivers of the same media + * type, they will all call OnFirstPacketReceived at once. * - * For example, if we create three audio receivers, A/B/C, they will listen to - * the same signal from the underneath network layer. Whenever the first audio packet - * is received, the underneath signal will be fired. All the receivers A/B/C will be - * notified and the callback of the receiver's delegate will be called. + * For example, if we create three audio receivers, A/B/C, they will listen + * to the same signal from the underneath network layer. Whenever the first + * audio packet is received, the underneath signal will be fired. All the + * receivers A/B/C will be notified and the callback of the receiver's + * delegate will be called. * * The process is the same for video receivers. */ - - (void)rtpReceiver - : (RTC_OBJC_TYPE(RTCRtpReceiver) *)rtpReceiver didReceiveFirstPacketForMediaType + - (void)rtpReceiver : (RTC_OBJC_TYPE(RTCRtpReceiver) *) + rtpReceiver didReceiveFirstPacketForMediaType : (RTCRtpMediaType)mediaType; @end @@ -70,12 +71,13 @@ RTC_OBJC_EXPORT * RTCMediaStreamTrack. Use isEqual: instead of == to compare * RTCMediaStreamTrack instances. */ -@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCMediaStreamTrack) * track; +@property(nonatomic, readonly, nullable) RTC_OBJC_TYPE(RTCMediaStreamTrack) * + track; /** -Returns an array that contains an object for each unique SSRC (synchronization source) identifier -and for each unique CSRC (contributing source) received by the current RTCRtpReceiver in the last -ten seconds. +Returns an array that contains an object for each unique SSRC (synchronization +source) identifier and for each unique CSRC (contributing source) received by +the current RTCRtpReceiver in the last ten seconds. */ @property(nonatomic, readonly) NSArray *sources; diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver.mm b/sdk/objc/api/peerconnection/RTCRtpReceiver.mm index 02afaed7ba..bb5b01d16b 100644 --- a/sdk/objc/api/peerconnection/RTCRtpReceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpReceiver.mm @@ -21,7 +21,8 @@ namespace webrtc { -RtpReceiverDelegateAdapter::RtpReceiverDelegateAdapter(RTC_OBJC_TYPE(RTCRtpReceiver) * receiver) { +RtpReceiverDelegateAdapter::RtpReceiverDelegateAdapter( + RTC_OBJC_TYPE(RTCRtpReceiver) * receiver) { RTC_CHECK(receiver); receiver_ = receiver; } @@ -31,7 +32,8 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( RTCRtpMediaType packet_media_type = [RTC_OBJC_TYPE(RTCRtpReceiver) mediaTypeForNativeMediaType:media_type]; RTC_OBJC_TYPE(RTCRtpReceiver) *receiver = receiver_; - [receiver.delegate rtpReceiver:receiver didReceiveFirstPacketForMediaType:packet_media_type]; + [receiver.delegate rtpReceiver:receiver + didReceiveFirstPacketForMediaType:packet_media_type]; } } // namespace webrtc @@ -55,25 +57,29 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( - (nullable RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track { rtc::scoped_refptr nativeTrack( - _nativeRtpReceiver->track()); + _nativeRtpReceiver->track()); if (nativeTrack) { - return [RTC_OBJC_TYPE(RTCMediaStreamTrack) mediaTrackForNativeTrack:nativeTrack - factory:_factory]; + return + [RTC_OBJC_TYPE(RTCMediaStreamTrack) mediaTrackForNativeTrack:nativeTrack + factory:_factory]; } return nil; } - (NSString *)description { return [NSString - stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpReceiver) {\n receiverId: %@\n}", self.receiverId]; + stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpReceiver) {\n receiverId: %@\n}", + self.receiverId]; } - (NSArray *)sources { - std::vector nativeSources = _nativeRtpReceiver->GetSources(); + std::vector nativeSources = + _nativeRtpReceiver->GetSources(); NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:nativeSources.size()]; for (auto nativeSource : nativeSources) { - [result addObject:[[RTC_OBJC_TYPE(RTCRtpSource) alloc] initWithNativeRtpSource:nativeSource]]; + [result addObject:[[RTC_OBJC_TYPE(RTCRtpSource) alloc] + initWithNativeRtpSource:nativeSource]]; } return result; } @@ -94,7 +100,8 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( if (![object isMemberOfClass:[self class]]) { return NO; } - RTC_OBJC_TYPE(RTCRtpReceiver) *receiver = (RTC_OBJC_TYPE(RTCRtpReceiver) *)object; + RTC_OBJC_TYPE(RTCRtpReceiver) *receiver = + (RTC_OBJC_TYPE(RTCRtpReceiver) *)object; return _nativeRtpReceiver == receiver.nativeRtpReceiver; } @@ -104,7 +111,8 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( #pragma mark - Native -- (void)setFrameDecryptor:(rtc::scoped_refptr)frameDecryptor { +- (void)setFrameDecryptor: + (rtc::scoped_refptr)frameDecryptor { _nativeRtpReceiver->SetFrameDecryptor(frameDecryptor); } @@ -114,14 +122,17 @@ void RtpReceiverDelegateAdapter::OnFirstPacketReceived( return _nativeRtpReceiver; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpReceiver: - (rtc::scoped_refptr)nativeRtpReceiver { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpReceiver: + (rtc::scoped_refptr)nativeRtpReceiver { self = [super init]; if (self) { _factory = factory; _nativeRtpReceiver = nativeRtpReceiver; - RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpReceiver)(%p): created receiver: %@", self, self.description); + RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpReceiver)(%p): created receiver: %@", + self, + self.description); _observer.reset(new webrtc::RtpReceiverDelegateAdapter(self)); _nativeRtpReceiver->SetObserver(_observer.get()); } diff --git a/sdk/objc/api/peerconnection/RTCRtpSender+Native.h b/sdk/objc/api/peerconnection/RTCRtpSender+Native.h index 249d5c5e09..25d6f42549 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSender+Native.h +++ b/sdk/objc/api/peerconnection/RTCRtpSender+Native.h @@ -16,17 +16,19 @@ NS_ASSUME_NONNULL_BEGIN /** - * This class extension exposes methods that work directly with injectable C++ components. + * This class extension exposes methods that work directly with injectable C++ + * components. */ @interface RTC_OBJC_TYPE (RTCRtpSender) () /** Sets a defined frame encryptor that will encrypt the entire frame * before it is sent across the network. This will encrypt the entire frame - * using the user provided encryption mechanism regardless of whether SRTP is - * enabled or not. + * using the user provided encryption mechanism regardless of whether SRTP + * is enabled or not. */ - - (void)setFrameEncryptor : (rtc::scoped_refptr)frameEncryptor; + - (void)setFrameEncryptor + : (rtc::scoped_refptr)frameEncryptor; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpSender+Private.h b/sdk/objc/api/peerconnection/RTCRtpSender+Private.h index 6fdb42bb22..45e55ef896 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSender+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpSender+Private.h @@ -19,12 +19,14 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCRtpSender) () - @property(nonatomic, readonly) rtc::scoped_refptr nativeRtpSender; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeRtpSender; /** Initialize an RTCRtpSender with a native RtpSenderInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpSender:(rtc::scoped_refptr)nativeRtpSender - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpSender:(rtc::scoped_refptr) + nativeRtpSender NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpSender.h b/sdk/objc/api/peerconnection/RTCRtpSender.h index cf78be4358..3609b6720f 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSender.h +++ b/sdk/objc/api/peerconnection/RTCRtpSender.h @@ -40,7 +40,8 @@ RTC_OBJC_EXPORT @property(nonatomic, copy) NSArray *streamIds; /** The RTCDtmfSender accociated with the RTP sender. */ -@property(nonatomic, readonly, nullable) id dtmfSender; +@property(nonatomic, readonly, nullable) id + dtmfSender; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpSender.mm b/sdk/objc/api/peerconnection/RTCRtpSender.mm index 3d5702066a..08ab9ed404 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSender.mm +++ b/sdk/objc/api/peerconnection/RTCRtpSender.mm @@ -37,29 +37,36 @@ - (void)setParameters:(RTC_OBJC_TYPE(RTCRtpParameters) *)parameters { if (!_nativeRtpSender->SetParameters(parameters.nativeParameters).ok()) { - RTCLogError(@"RTC_OBJC_TYPE(RTCRtpSender)(%p): Failed to set parameters: %@", self, parameters); + RTCLogError( + @"RTC_OBJC_TYPE(RTCRtpSender)(%p): Failed to set parameters: %@", + self, + parameters); } } - (RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track { rtc::scoped_refptr nativeTrack( - _nativeRtpSender->track()); + _nativeRtpSender->track()); if (nativeTrack) { - return [RTC_OBJC_TYPE(RTCMediaStreamTrack) mediaTrackForNativeTrack:nativeTrack - factory:_factory]; + return + [RTC_OBJC_TYPE(RTCMediaStreamTrack) mediaTrackForNativeTrack:nativeTrack + factory:_factory]; } return nil; } - (void)setTrack:(RTC_OBJC_TYPE(RTCMediaStreamTrack) *)track { if (!_nativeRtpSender->SetTrack(track.nativeTrack.get())) { - RTCLogError(@"RTC_OBJC_TYPE(RTCRtpSender)(%p): Failed to set track %@", self, track); + RTCLogError(@"RTC_OBJC_TYPE(RTCRtpSender)(%p): Failed to set track %@", + self, + track); } } - (NSArray *)streamIds { std::vector nativeStreamIds = _nativeRtpSender->stream_ids(); - NSMutableArray *streamIds = [NSMutableArray arrayWithCapacity:nativeStreamIds.size()]; + NSMutableArray *streamIds = + [NSMutableArray arrayWithCapacity:nativeStreamIds.size()]; for (const auto &s : nativeStreamIds) { [streamIds addObject:[NSString stringForStdString:s]]; } @@ -76,7 +83,8 @@ - (NSString *)description { return [NSString - stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpSender) {\n senderId: %@\n}", self.senderId]; + stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpSender) {\n senderId: %@\n}", + self.senderId]; } - (BOOL)isEqual:(id)object { @@ -99,7 +107,8 @@ #pragma mark - Native -- (void)setFrameEncryptor:(rtc::scoped_refptr)frameEncryptor { +- (void)setFrameEncryptor: + (rtc::scoped_refptr)frameEncryptor { _nativeRtpSender->SetFrameEncryptor(frameEncryptor); } @@ -109,8 +118,10 @@ return _nativeRtpSender; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpSender:(rtc::scoped_refptr)nativeRtpSender { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpSender: + (rtc::scoped_refptr)nativeRtpSender { NSParameterAssert(factory); NSParameterAssert(nativeRtpSender); self = [super init]; @@ -121,11 +132,13 @@ rtc::scoped_refptr nativeDtmfSender( _nativeRtpSender->GetDtmfSender()); if (nativeDtmfSender) { - _dtmfSender = - [[RTC_OBJC_TYPE(RTCDtmfSender) alloc] initWithNativeDtmfSender:nativeDtmfSender]; + _dtmfSender = [[RTC_OBJC_TYPE(RTCDtmfSender) alloc] + initWithNativeDtmfSender:nativeDtmfSender]; } } - RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpSender)(%p): created sender: %@", self, self.description); + RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpSender)(%p): created sender: %@", + self, + self.description); } return self; } diff --git a/sdk/objc/api/peerconnection/RTCRtpSource.h b/sdk/objc/api/peerconnection/RTCRtpSource.h index 5b491234c9..2b63cf1987 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSource.h +++ b/sdk/objc/api/peerconnection/RTCRtpSource.h @@ -27,29 +27,30 @@ RTC_OBJC_EXPORT (RTCRtpSource) /** - A positive integer value specifying the CSRC identifier of the contributing source or SSRC - identifier of the synchronization source. This uniquely identifies the source of the particular - stream RTP packets. */ + A positive integer value specifying the CSRC identifier of the contributing + source or SSRC identifier of the synchronization source. This uniquely + identifies the source of the particular stream RTP packets. */ @property(nonatomic, readonly) uint32_t sourceId; @property(nonatomic, readonly) RTCRtpSourceType sourceType; /** -A floating-point value between 0.0 and 1.0 specifying the audio level contained in the last RTP -packet played from the contributing source. +A floating-point value between 0.0 and 1.0 specifying the audio level contained +in the last RTP packet played from the contributing source. */ @property(nonatomic, readonly, nullable) NSNumber *audioLevel; /** -A timestamp indicating the most recent time at which a frame originating from this source was -delivered to the receiver's track +A timestamp indicating the most recent time at which a frame originating from +this source was delivered to the receiver's track */ @property(nonatomic, readonly) CFTimeInterval timestampUs; /** -The RTP timestamp of the media. This source-generated timestamp indicates the time at which the -media in this packet, scheduled for play out at the time indicated by timestamp, was initially -sampled or generated. It may be useful for sequencing and synchronization purposes. +The RTP timestamp of the media. This source-generated timestamp indicates the +time at which the media in this packet, scheduled for play out at the time +indicated by timestamp, was initially sampled or generated. It may be useful for +sequencing and synchronization purposes. */ @property(nonatomic, readonly) uint32_t rtpTimestamp; diff --git a/sdk/objc/api/peerconnection/RTCRtpSource.mm b/sdk/objc/api/peerconnection/RTCRtpSource.mm index 52b0e862a1..dbeb6b3f3a 100644 --- a/sdk/objc/api/peerconnection/RTCRtpSource.mm +++ b/sdk/objc/api/peerconnection/RTCRtpSource.mm @@ -37,7 +37,8 @@ - (RTCRtpSourceType)sourceType { return [RTC_OBJC_TYPE(RTCRtpSource) - rtpSourceTypeForNativeRtpSourceType:_nativeRtpSource.value().source_type()]; + rtpSourceTypeForNativeRtpSourceType:_nativeRtpSource.value() + .source_type()]; } - (NSNumber *)audioLevel { @@ -59,12 +60,14 @@ - (NSString *)description { return [NSString - stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpSource) {\n sourceId: %d, sourceType: %@\n}", - self.sourceId, - [RTC_OBJC_TYPE(RTCRtpSource) stringForRtpSourceType:self.sourceType]]; + stringWithFormat: + @"RTC_OBJC_TYPE(RTCRtpSource) {\n sourceId: %d, sourceType: %@\n}", + self.sourceId, + [RTC_OBJC_TYPE(RTCRtpSource) stringForRtpSourceType:self.sourceType]]; } -- (instancetype)initWithNativeRtpSource:(const webrtc::RtpSource &)nativeRtpSource { +- (instancetype)initWithNativeRtpSource: + (const webrtc::RtpSource &)nativeRtpSource { self = [super init]; if (self) { _nativeRtpSource = nativeRtpSource; @@ -72,7 +75,8 @@ return self; } -+ (RTCRtpSourceType)rtpSourceTypeForNativeRtpSourceType:(webrtc::RtpSourceType)nativeRtpSourceType { ++ (RTCRtpSourceType)rtpSourceTypeForNativeRtpSourceType: + (webrtc::RtpSourceType)nativeRtpSourceType { switch (nativeRtpSourceType) { case webrtc::RtpSourceType::SSRC: return RTCRtpSourceTypeSSRC; diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver+Private.h b/sdk/objc/api/peerconnection/RTCRtpTransceiver+Private.h index 868cbd80fe..1717a2a710 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver+Private.h @@ -26,14 +26,14 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCRtpTransceiver) () - @property(nonatomic, - readonly) rtc::scoped_refptr nativeRtpTransceiver; + @property(nonatomic, readonly) rtc::scoped_refptr< + webrtc::RtpTransceiverInterface> nativeRtpTransceiver; /** Initialize an RTCRtpTransceiver with a native RtpTransceiverInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpTransceiver: - (rtc::scoped_refptr)nativeRtpTransceiver - NS_DESIGNATED_INITIALIZER; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpTransceiver:(rtc::scoped_refptr) + nativeRtpTransceiver NS_DESIGNATED_INITIALIZER; + (webrtc::RtpTransceiverDirection)nativeRtpTransceiverDirectionFromDirection: (RTCRtpTransceiverDirection)direction; diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h index f5923ed6bb..0e543a5bab 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h @@ -41,7 +41,8 @@ RTC_OBJC_EXPORT @property(nonatomic) NSArray *streamIds; /** TODO(bugs.webrtc.org/7600): Not implemented. */ -@property(nonatomic) NSArray *sendEncodings; +@property(nonatomic) + NSArray *sendEncodings; @end @@ -50,10 +51,10 @@ RTC_OBJC_EXPORT @class RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability); /** The RTCRtpTransceiver maps to the RTCRtpTransceiver defined by the - * WebRTC specification. A transceiver represents a combination of an RTCRtpSender - * and an RTCRtpReceiver that share a common mid. As defined in JSEP, an - * RTCRtpTransceiver is said to be associated with a media description if its - * mid property is non-nil; otherwise, it is said to be disassociated. + * WebRTC specification. A transceiver represents a combination of an + * RTCRtpSender and an RTCRtpReceiver that share a common mid. As defined in + * JSEP, an RTCRtpTransceiver is said to be associated with a media description + * if its mid property is non-nil; otherwise, it is said to be disassociated. * JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24 * * Note that RTCRtpTransceivers are only supported when using @@ -66,8 +67,8 @@ RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE (RTCRtpTransceiver) - /** Media type of the transceiver. The sender and receiver will also have this - * type. + /** Media type of the transceiver. The sender and receiver will also have + * this type. */ @property(nonatomic, readonly) RTCRtpMediaType mediaType; @@ -107,15 +108,18 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) RTCRtpTransceiverDirection direction; /** It will contain all the RTP header extensions that are supported. - * The direction attribute for all extensions that are mandatory to use MUST be initialized to an - * appropriate value other than RTCRtpTransceiverDirectionStopped. The direction attribute for - * extensions that will not be offered by default in an initial offer MUST be initialized to - * RTCRtpTransceiverDirectionStopped. + * The direction attribute for all extensions that are mandatory to use MUST be + * initialized to an appropriate value other than + * RTCRtpTransceiverDirectionStopped. The direction attribute for extensions + * that will not be offered by default in an initial offer MUST be initialized + * to RTCRtpTransceiverDirectionStopped. */ @property(nonatomic, readonly, copy) - NSArray *headerExtensionsToNegotiate; + NSArray + *headerExtensionsToNegotiate; @property(nonatomic, readonly, copy) - NSArray *negotiatedHeaderExtensions; + NSArray + *negotiatedHeaderExtensions; /** The currentDirection attribute indicates the current direction negotiated * for this transceiver. If this transceiver has never been represented in an @@ -135,19 +139,22 @@ RTC_OBJC_EXPORT * by WebRTC for this transceiver. * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences */ -- (BOOL)setCodecPreferences:(NSArray *_Nullable)codecs +- (BOOL)setCodecPreferences: + (NSArray *_Nullable)codecs error:(NSError **_Nullable)error; /** Deprecated version of [RTCRtpTransceiver setCodecPreferences:error:] */ -- (void)setCodecPreferences:(NSArray *_Nullable)codecs +- (void)setCodecPreferences: + (NSArray *_Nullable)codecs RTC_OBJC_DEPRECATED("Use setCodecPreferences:error: instead."); -/** The setHeaderExtensionsToNegotiate method overrides the default header extensions used - * by WebRTC for this transceiver. +/** The setHeaderExtensionsToNegotiate method overrides the default header + * extensions used by WebRTC for this transceiver. * https://w3c.github.io/webrtc-extensions/#ref-for-dom-rtcrtptransceiver-setheaderextensionstonegotiate */ - (BOOL)setHeaderExtensionsToNegotiate: - (NSArray *)extensions + (NSArray *) + extensions error:(NSError **)error; /** An update of directionality does not take effect immediately. Instead, @@ -155,7 +162,8 @@ RTC_OBJC_EXPORT * descriptions as sendrecv, sendonly, recvonly, or inactive. * https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction */ -- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error; +- (void)setDirection:(RTCRtpTransceiverDirection)direction + error:(NSError **)error; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index f696a634f8..16766623b8 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -39,12 +39,13 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; - (webrtc::RtpTransceiverInit)nativeInit { webrtc::RtpTransceiverInit init; - init.direction = - [RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:_direction]; + init.direction = [RTC_OBJC_TYPE(RTCRtpTransceiver) + nativeRtpTransceiverDirectionFromDirection:_direction]; for (NSString *streamId in _streamIds) { init.stream_ids.push_back([streamId UTF8String]); } - for (RTC_OBJC_TYPE(RTCRtpEncodingParameters) * sendEncoding in _sendEncodings) { + for (RTC_OBJC_TYPE(RTCRtpEncodingParameters) * + sendEncoding in _sendEncodings) { init.send_encodings.push_back(sendEncoding.nativeParameters); } return init; @@ -79,43 +80,53 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; - (RTCRtpTransceiverDirection)direction { return [RTC_OBJC_TYPE(RTCRtpTransceiver) - rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver->direction()]; + rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver + ->direction()]; } -- (NSArray *)headerExtensionsToNegotiate { +- (NSArray *) + headerExtensionsToNegotiate { std::vector nativeHeaderExtensions( _nativeRtpTransceiver->GetHeaderExtensionsToNegotiate()); NSMutableArray *headerExtensions = [NSMutableArray arrayWithCapacity:nativeHeaderExtensions.size()]; for (const auto &headerExtension : nativeHeaderExtensions) { - [headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] - initWithNativeRtpHeaderExtensionCapability:headerExtension]]; + [headerExtensions + addObject: + [[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] + initWithNativeRtpHeaderExtensionCapability:headerExtension]]; } return headerExtensions; } -- (NSArray *)negotiatedHeaderExtensions { +- (NSArray *) + negotiatedHeaderExtensions { std::vector nativeHeaderExtensions( _nativeRtpTransceiver->GetNegotiatedHeaderExtensions()); NSMutableArray *headerExtensions = [NSMutableArray arrayWithCapacity:nativeHeaderExtensions.size()]; for (const auto &headerExtension : nativeHeaderExtensions) { - [headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] - initWithNativeRtpHeaderExtensionCapability:headerExtension]]; + [headerExtensions + addObject: + [[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc] + initWithNativeRtpHeaderExtensionCapability:headerExtension]]; } return headerExtensions; } -- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error { +- (void)setDirection:(RTCRtpTransceiverDirection)direction + error:(NSError **)error { webrtc::RTCError nativeError = _nativeRtpTransceiver->SetDirectionWithError( - [RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:direction]); + [RTC_OBJC_TYPE(RTCRtpTransceiver) + nativeRtpTransceiverDirectionFromDirection:direction]); if (!nativeError.ok() && error) { NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey : [NSString stringWithCString:nativeError.message() - encoding:NSUTF8StringEncoding] + NSLocalizedDescriptionKey : + [NSString stringWithCString:nativeError.message() + encoding:NSUTF8StringEncoding] }; *error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain code:static_cast(nativeError.type()) @@ -126,7 +137,8 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; - (BOOL)currentDirection:(RTCRtpTransceiverDirection *)currentDirectionOut { if (_nativeRtpTransceiver->current_direction()) { *currentDirectionOut = [RTC_OBJC_TYPE(RTCRtpTransceiver) - rtpTransceiverDirectionFromNativeDirection:*_nativeRtpTransceiver->current_direction()]; + rtpTransceiverDirectionFromNativeDirection:*_nativeRtpTransceiver + ->current_direction()]; return YES; } else { return NO; @@ -137,7 +149,8 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; _nativeRtpTransceiver->StopInternal(); } -- (BOOL)setCodecPreferences:(NSArray *)codecs +- (BOOL)setCodecPreferences: + (NSArray *)codecs error:(NSError **)error { std::vector codecCapabilities; if (codecs) { @@ -145,34 +158,43 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; codecCapabilities.push_back(rtpCodecCapability.nativeRtpCodecCapability); } } - webrtc::RTCError nativeError = _nativeRtpTransceiver->SetCodecPreferences(codecCapabilities); + webrtc::RTCError nativeError = + _nativeRtpTransceiver->SetCodecPreferences(codecCapabilities); if (!nativeError.ok() && error) { - *error = [NSError - errorWithDomain:kRTCRtpTransceiverErrorDomain - code:static_cast(nativeError.type()) - userInfo:@{@"message" : [NSString stringWithUTF8String:nativeError.message()]}]; + *error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain + code:static_cast(nativeError.type()) + userInfo:@{ + @"message" : [NSString + stringWithUTF8String:nativeError.message()] + }]; } return nativeError.ok(); } -- (void)setCodecPreferences:(NSArray *)codecs { +- (void)setCodecPreferences: + (NSArray *)codecs { [self setCodecPreferences:codecs error:nil]; } - (BOOL)setHeaderExtensionsToNegotiate: - (NSArray *)extensions + (NSArray *) + extensions error:(NSError **)error { std::vector headerExtensionCapabilities; - for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * extension in extensions) { - headerExtensionCapabilities.push_back(extension.nativeRtpHeaderExtensionCapability); + for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * + extension in extensions) { + headerExtensionCapabilities.push_back( + extension.nativeRtpHeaderExtensionCapability); } webrtc::RTCError nativeError = - _nativeRtpTransceiver->SetHeaderExtensionsToNegotiate(headerExtensionCapabilities); + _nativeRtpTransceiver->SetHeaderExtensionsToNegotiate( + headerExtensionCapabilities); BOOL ok = nativeError.ok(); if (!ok && error) { NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey : [NSString stringWithCString:nativeError.message() - encoding:NSUTF8StringEncoding] + NSLocalizedDescriptionKey : + [NSString stringWithCString:nativeError.message() + encoding:NSUTF8StringEncoding] }; *error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain code:static_cast(nativeError.type()) @@ -182,10 +204,10 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; } - (NSString *)description { - return [NSString - stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpTransceiver) {\n sender: %@\n receiver: %@\n}", - _sender, - _receiver]; + return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCRtpTransceiver) {\n " + @"sender: %@\n receiver: %@\n}", + _sender, + _receiver]; } - (BOOL)isEqual:(id)object { @@ -198,7 +220,8 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; if (![object isMemberOfClass:[self class]]) { return NO; } - RTC_OBJC_TYPE(RTCRtpTransceiver) *transceiver = (RTC_OBJC_TYPE(RTCRtpTransceiver) *)object; + RTC_OBJC_TYPE(RTCRtpTransceiver) *transceiver = + (RTC_OBJC_TYPE(RTCRtpTransceiver) *)object; return _nativeRtpTransceiver == transceiver.nativeRtpTransceiver; } @@ -212,28 +235,31 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; return _nativeRtpTransceiver; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeRtpTransceiver: - (rtc::scoped_refptr)nativeRtpTransceiver { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeRtpTransceiver:(rtc::scoped_refptr) + nativeRtpTransceiver { NSParameterAssert(factory); NSParameterAssert(nativeRtpTransceiver); self = [super init]; if (self) { _factory = factory; _nativeRtpTransceiver = nativeRtpTransceiver; - _sender = [[RTC_OBJC_TYPE(RTCRtpSender) alloc] initWithFactory:_factory - nativeRtpSender:nativeRtpTransceiver->sender()]; - _receiver = - [[RTC_OBJC_TYPE(RTCRtpReceiver) alloc] initWithFactory:_factory - nativeRtpReceiver:nativeRtpTransceiver->receiver()]; - RTCLogInfo( - @"RTC_OBJC_TYPE(RTCRtpTransceiver)(%p): created transceiver: %@", self, self.description); + _sender = [[RTC_OBJC_TYPE(RTCRtpSender) alloc] + initWithFactory:_factory + nativeRtpSender:nativeRtpTransceiver->sender()]; + _receiver = [[RTC_OBJC_TYPE(RTCRtpReceiver) alloc] + initWithFactory:_factory + nativeRtpReceiver:nativeRtpTransceiver->receiver()]; + RTCLogInfo(@"RTC_OBJC_TYPE(RTCRtpTransceiver)(%p): created transceiver: %@", + self, + self.description); } return self; } + (webrtc::RtpTransceiverDirection)nativeRtpTransceiverDirectionFromDirection: - (RTCRtpTransceiverDirection)direction { + (RTCRtpTransceiverDirection)direction { switch (direction) { case RTCRtpTransceiverDirectionSendRecv: return webrtc::RtpTransceiverDirection::kSendRecv; @@ -249,7 +275,7 @@ NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver"; } + (RTCRtpTransceiverDirection)rtpTransceiverDirectionFromNativeDirection: - (webrtc::RtpTransceiverDirection)nativeDirection { + (webrtc::RtpTransceiverDirection)nativeDirection { switch (nativeDirection) { case webrtc::RtpTransceiverDirection::kSendRecv: return RTCRtpTransceiverDirectionSendRecv; diff --git a/sdk/objc/api/peerconnection/RTCSessionDescription+Private.h b/sdk/objc/api/peerconnection/RTCSessionDescription+Private.h index d01c04b0b5..4acc059728 100644 --- a/sdk/objc/api/peerconnection/RTCSessionDescription+Private.h +++ b/sdk/objc/api/peerconnection/RTCSessionDescription+Private.h @@ -19,11 +19,11 @@ NS_ASSUME_NONNULL_BEGIN /** * The native SessionDescriptionInterface representation of this - * RTCSessionDescription object. This is needed to pass to the underlying C++ - * APIs. + * RTCSessionDescription object. This is needed to pass to the underlying + * C++ APIs. */ - @property(nonatomic, - readonly) std::unique_ptr nativeDescription; + @property(nonatomic, readonly) + std::unique_ptr nativeDescription; /** * Initialize an RTCSessionDescription from a native diff --git a/sdk/objc/api/peerconnection/RTCSessionDescription.h b/sdk/objc/api/peerconnection/RTCSessionDescription.h index 525f3423cc..01878d525a 100644 --- a/sdk/objc/api/peerconnection/RTCSessionDescription.h +++ b/sdk/objc/api/peerconnection/RTCSessionDescription.h @@ -37,7 +37,8 @@ RTC_OBJC_EXPORT - (instancetype)init NS_UNAVAILABLE; /** Initialize a session description with a type and SDP string. */ -- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithType:(RTCSdpType)type + sdp:(NSString *)sdp NS_DESIGNATED_INITIALIZER; + (NSString *)stringForType:(RTCSdpType)type; diff --git a/sdk/objc/api/peerconnection/RTCSessionDescription.mm b/sdk/objc/api/peerconnection/RTCSessionDescription.mm index 25bf20e8d3..a62f4c7f29 100644 --- a/sdk/objc/api/peerconnection/RTCSessionDescription.mm +++ b/sdk/objc/api/peerconnection/RTCSessionDescription.mm @@ -41,9 +41,10 @@ } - (NSString *)description { - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCSessionDescription):\n%@\n%@", - [[self class] stringForType:_type], - _sdp]; + return [NSString + stringWithFormat:@"RTC_OBJC_TYPE(RTCSessionDescription):\n%@\n%@", + [[self class] stringForType:_type], + _sdp]; } #pragma mark - Private @@ -51,8 +52,9 @@ - (std::unique_ptr)nativeDescription { webrtc::SdpParseError error; - std::unique_ptr description(webrtc::CreateSessionDescription( - [[self class] nativeTypeForType:_type], _sdp.stdString, &error)); + std::unique_ptr description( + webrtc::CreateSessionDescription( + [[self class] nativeTypeForType:_type], _sdp.stdString, &error)); if (!description) { RTCLogError(@"Failed to create session description: %s\nline: %s", @@ -70,8 +72,7 @@ nativeDescription->ToString(&sdp); RTCSdpType type = [[self class] typeForStdString:nativeDescription->type()]; - return [self initWithType:type - sdp:[NSString stringForStdString:sdp]]; + return [self initWithType:type sdp:[NSString stringForStdString:sdp]]; } + (std::string)stdStringForType:(RTCSdpType)type { diff --git a/sdk/objc/api/peerconnection/RTCStatisticsReport.h b/sdk/objc/api/peerconnection/RTCStatisticsReport.h index 92181e3833..cda89686ae 100644 --- a/sdk/objc/api/peerconnection/RTCStatisticsReport.h +++ b/sdk/objc/api/peerconnection/RTCStatisticsReport.h @@ -24,7 +24,8 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) CFTimeInterval timestamp_us; /** RTCStatistics objects by id. */ -@property(nonatomic, readonly) NSDictionary *statistics; +@property(nonatomic, readonly) + NSDictionary *statistics; - (instancetype)init NS_UNAVAILABLE; @@ -37,15 +38,17 @@ RTC_OBJC_EXPORT /** The id of this subreport, e.g. "RTCMediaStreamTrack_receiver_2". */ @property(nonatomic, readonly) NSString *id; -/** The timestamp of the subreport in microseconds since 1970-01-01T00:00:00Z. */ +/** The timestamp of the subreport in microseconds since 1970-01-01T00:00:00Z. + */ @property(nonatomic, readonly) CFTimeInterval timestamp_us; /** The type of the subreport, e.g. "track", "codec". */ @property(nonatomic, readonly) NSString *type; /** The keys and values of the subreport, e.g. "totalFramesDuration = 5.551". - The values are either NSNumbers or NSStrings or NSArrays encapsulating NSNumbers - or NSStrings, or NSDictionary of NSString keys to NSNumber values. */ + The values are either NSNumbers or NSStrings or NSArrays encapsulating + NSNumbers or NSStrings, or NSDictionary of NSString keys to NSNumber values. + */ @property(nonatomic, readonly) NSDictionary *values; - (instancetype)init NS_UNAVAILABLE; diff --git a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm index 2622de8074..d09d4810b7 100644 --- a/sdk/objc/api/peerconnection/RTCStatisticsReport.mm +++ b/sdk/objc/api/peerconnection/RTCStatisticsReport.mm @@ -15,8 +15,9 @@ namespace webrtc { -/** Converts a single value to a suitable NSNumber, NSString or NSArray containing NSNumbers - or NSStrings, or NSDictionary of NSString keys to NSNumber values.*/ +/** Converts a single value to a suitable NSNumber, NSString or NSArray + containing NSNumbers or NSStrings, or NSDictionary of NSString keys to + NSNumber values.*/ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { if (!attribute.has_value()) { return nil; @@ -44,48 +45,56 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { return [array copy]; } else if (attribute.holds_alternative>()) { std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSNumber numberWithInt:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSNumber numberWithUnsignedInt:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSNumber numberWithLong:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSNumber numberWithUnsignedLong:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSNumber numberWithDouble:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { - std::vector sequence = attribute.get>(); - NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()]; + std::vector sequence = + attribute.get>(); + NSMutableArray *array = + [NSMutableArray arrayWithCapacity:sequence.size()]; for (const auto &item : sequence) { [array addObject:[NSString stringForStdString:item]]; } return [array copy]; } else if (attribute.holds_alternative>()) { - std::map map = attribute.get>(); + std::map map = + attribute.get>(); NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:map.size()]; for (const auto &item : map) { @@ -93,7 +102,8 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { } return [dictionary copy]; } else if (attribute.holds_alternative>()) { - std::map map = attribute.get>(); + std::map map = + attribute.get>(); NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:map.size()]; for (const auto &item : map) { @@ -118,9 +128,11 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { if (self) { _id = [NSString stringForStdString:statistics.id()]; _timestamp_us = statistics.timestamp().us(); - _type = [NSString stringWithCString:statistics.type() encoding:NSUTF8StringEncoding]; + _type = [NSString stringWithCString:statistics.type() + encoding:NSUTF8StringEncoding]; - NSMutableDictionary *values = [NSMutableDictionary dictionary]; + NSMutableDictionary *values = + [NSMutableDictionary dictionary]; for (const auto &attribute : statistics.Attributes()) { NSObject *value = ValueFromStatsAttribute(attribute); if (value) { @@ -138,11 +150,12 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { } - (NSString *)description { - return [NSString stringWithFormat:@"id = %@, type = %@, timestamp = %.0f, values = %@", - self.id, - self.type, - self.timestamp_us, - self.values]; + return [NSString + stringWithFormat:@"id = %@, type = %@, timestamp = %.0f, values = %@", + self.id, + self.type, + self.timestamp_us, + self.values]; } @end @@ -153,15 +166,17 @@ NSObject *ValueFromStatsAttribute(const Attribute &attribute) { @synthesize statistics = _statistics; - (NSString *)description { - return [NSString - stringWithFormat:@"timestamp = %.0f, statistics = %@", self.timestamp_us, self.statistics]; + return [NSString stringWithFormat:@"timestamp = %.0f, statistics = %@", + self.timestamp_us, + self.statistics]; } @end -@implementation RTC_OBJC_TYPE (RTCStatisticsReport) (Private) +@implementation RTC_OBJC_TYPE (RTCStatisticsReport) +(Private) -- (instancetype)initWithReport : (const webrtc::RTCStatsReport &)report { + - (instancetype)initWithReport : (const webrtc::RTCStatsReport &)report { self = [super init]; if (self) { _timestamp_us = report.timestamp().us(); diff --git a/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h b/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h index 5eff996c4f..aa77520e8e 100644 --- a/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h +++ b/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCVideoCodecInfo) (Private) - - (instancetype)initWithNativeSdpVideoFormat : (webrtc::SdpVideoFormat)format; + - (instancetype)initWithNativeSdpVideoFormat + : (webrtc::SdpVideoFormat)format; - (webrtc::SdpVideoFormat)nativeSdpVideoFormat; @end diff --git a/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm b/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm index dd45ef053e..8a977a3447 100644 --- a/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm +++ b/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm @@ -17,16 +17,20 @@ @implementation RTC_OBJC_TYPE (RTCVideoCodecInfo) (Private) - - (instancetype)initWithNativeSdpVideoFormat : (webrtc::SdpVideoFormat)format { + - (instancetype)initWithNativeSdpVideoFormat + : (webrtc::SdpVideoFormat)format { NSMutableDictionary* params = [NSMutableDictionary dictionary]; for (const auto& [key, value] : format.parameters) { - [params setObject:[NSString stringForStdString:value] forKey:[NSString stringForStdString:key]]; + [params setObject:[NSString stringForStdString:value] + forKey:[NSString stringForStdString:key]]; } NSMutableArray* scalabilityModes = [NSMutableArray arrayWithCapacity:format.scalability_modes.size()]; for (webrtc::ScalabilityMode mode : format.scalability_modes) { - [scalabilityModes addObject:[NSString stringForAbslStringView:ScalabilityModeToString(mode)]]; + [scalabilityModes + addObject:[NSString + stringForAbslStringView:ScalabilityModeToString(mode)]]; } return [self initWithName:[NSString stringForStdString:format.name] @@ -36,16 +40,18 @@ - (webrtc::SdpVideoFormat)nativeSdpVideoFormat { std::map parameters; - for (NSString *paramKey in self.parameters.allKeys) { + for (NSString* paramKey in self.parameters.allKeys) { std::string key = [NSString stdStringForString:paramKey]; std::string value = [NSString stdStringForString:self.parameters[paramKey]]; parameters[key] = value; } - absl::InlinedVector scalability_modes; + absl::InlinedVector + scalability_modes; for (NSString* mode_name in self.scalabilityModes) { std::optional mode = - webrtc::ScalabilityModeStringToEnum([NSString stdStringForString:mode_name]); + webrtc::ScalabilityModeStringToEnum( + [NSString stdStringForString:mode_name]); if (mode.has_value()) { scalability_modes.push_back(*mode); } diff --git a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h index 8323b18dc1..14102f9ff5 100644 --- a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h +++ b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCVideoEncoderSettings) (Private) - - (instancetype)initWithNativeVideoCodec : (const webrtc::VideoCodec *__nullable)videoCodec; + - (instancetype)initWithNativeVideoCodec + : (const webrtc::VideoCodec *__nullable)videoCodec; - (webrtc::VideoCodec)nativeVideoCodec; @end diff --git a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm index fb93948153..44df191717 100644 --- a/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm +++ b/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm @@ -15,7 +15,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoEncoderSettings) (Private) - - (instancetype)initWithNativeVideoCodec : (const webrtc::VideoCodec *)videoCodec { + - (instancetype)initWithNativeVideoCodec + : (const webrtc::VideoCodec *)videoCodec { self = [super init]; if (self) { if (videoCodec) { diff --git a/sdk/objc/api/peerconnection/RTCVideoSource+Private.h b/sdk/objc/api/peerconnection/RTCVideoSource+Private.h index 8e475dd21e..7278506b2d 100644 --- a/sdk/objc/api/peerconnection/RTCVideoSource+Private.h +++ b/sdk/objc/api/peerconnection/RTCVideoSource+Private.h @@ -24,24 +24,29 @@ NS_ASSUME_NONNULL_BEGIN * The VideoTrackSourceInterface object passed to this RTCVideoSource during * construction. */ - @property(nonatomic, - readonly) rtc::scoped_refptr nativeVideoSource; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeVideoSource; /** Initialize an RTCVideoSource from a native VideoTrackSourceInterface. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeVideoSource: - (rtc::scoped_refptr)nativeVideoSource +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeVideoSource: + (rtc::scoped_refptr)nativeVideoSource NS_DESIGNATED_INITIALIZER; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type NS_UNAVAILABLE; +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type NS_UNAVAILABLE; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory signalingThread:(rtc::Thread *)signalingThread workerThread:(rtc::Thread *)workerThread; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory signalingThread:(rtc::Thread *)signalingThread workerThread:(rtc::Thread *)workerThread isScreenCast:(BOOL)isScreenCast; diff --git a/sdk/objc/api/peerconnection/RTCVideoSource.mm b/sdk/objc/api/peerconnection/RTCVideoSource.mm index de718fb570..5099b23285 100644 --- a/sdk/objc/api/peerconnection/RTCVideoSource.mm +++ b/sdk/objc/api/peerconnection/RTCVideoSource.mm @@ -28,9 +28,10 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( rtc::scoped_refptr _nativeVideoSource; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeVideoSource: - (rtc::scoped_refptr)nativeVideoSource { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeVideoSource:(rtc::scoped_refptr) + nativeVideoSource { RTC_DCHECK(factory); RTC_DCHECK(nativeVideoSource); self = [super initWithFactory:factory @@ -42,14 +43,17 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( return self; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeMediaSource:(rtc::scoped_refptr)nativeMediaSource - type:(RTCMediaSourceType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeMediaSource: + (rtc::scoped_refptr)nativeMediaSource + type:(RTCMediaSourceType)type { RTC_DCHECK_NOTREACHED(); return nil; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory signalingThread:(rtc::Thread *)signalingThread workerThread:(rtc::Thread *)workerThread { return [self initWithFactory:factory @@ -58,7 +62,8 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( isScreenCast:NO]; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory signalingThread:(rtc::Thread *)signalingThread workerThread:(rtc::Thread *)workerThread isScreenCast:(BOOL)isScreenCast { @@ -67,12 +72,16 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( return [self initWithFactory:factory nativeVideoSource:webrtc::VideoTrackSourceProxy::Create( - signalingThread, workerThread, objCVideoTrackSource)]; + signalingThread, + workerThread, + objCVideoTrackSource)]; } - (NSString *)description { NSString *stateString = [[self class] stringForState:self.state]; - return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCVideoSource)( %p ): %@", self, stateString]; + return [NSString stringWithFormat:@"RTC_OBJC_TYPE(RTCVideoSource)( %p ): %@", + self, + stateString]; } - (void)capturer:(RTC_OBJC_TYPE(RTCVideoCapturer) *)capturer @@ -81,7 +90,8 @@ static webrtc::ObjCVideoTrackSource *getObjCVideoSource( } - (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps { - getObjCVideoSource(_nativeVideoSource)->OnOutputFormatRequest(width, height, fps); + getObjCVideoSource(_nativeVideoSource) + ->OnOutputFormatRequest(width, height, fps); } #pragma mark - Private diff --git a/sdk/objc/api/peerconnection/RTCVideoTrack+Private.h b/sdk/objc/api/peerconnection/RTCVideoTrack+Private.h index f1a8d7e4ed..5f7cedd34f 100644 --- a/sdk/objc/api/peerconnection/RTCVideoTrack+Private.h +++ b/sdk/objc/api/peerconnection/RTCVideoTrack+Private.h @@ -18,10 +18,12 @@ NS_ASSUME_NONNULL_BEGIN () /** VideoTrackInterface created or passed in at construction. */ - @property(nonatomic, readonly) rtc::scoped_refptr nativeVideoTrack; + @property(nonatomic, readonly) + rtc::scoped_refptr nativeVideoTrack; /** Initialize an RTCVideoTrack with its source and an id. */ -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory source:(RTC_OBJC_TYPE(RTCVideoSource) *)source trackId:(NSString *)trackId; diff --git a/sdk/objc/api/peerconnection/RTCVideoTrack.mm b/sdk/objc/api/peerconnection/RTCVideoTrack.mm index 811d5f04fa..fcdfbb1dde 100644 --- a/sdk/objc/api/peerconnection/RTCVideoTrack.mm +++ b/sdk/objc/api/peerconnection/RTCVideoTrack.mm @@ -23,7 +23,8 @@ @synthesize source = _source; -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory +- (instancetype)initWithFactory: + (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory source:(RTC_OBJC_TYPE(RTCVideoSource) *)source trackId:(NSString *)trackId { NSParameterAssert(factory); @@ -31,18 +32,22 @@ NSParameterAssert(trackId.length); std::string nativeId = [NSString stdStringForString:trackId]; rtc::scoped_refptr track = - factory.nativeFactory->CreateVideoTrack(source.nativeVideoSource, nativeId); - self = [self initWithFactory:factory nativeTrack:track type:RTCMediaStreamTrackTypeVideo]; + factory.nativeFactory->CreateVideoTrack(source.nativeVideoSource, + nativeId); + self = [self initWithFactory:factory + nativeTrack:track + type:RTCMediaStreamTrackTypeVideo]; if (self) { _source = source; } return self; } -- (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - nativeTrack: - (rtc::scoped_refptr)nativeMediaTrack - type:(RTCMediaStreamTrackType)type { +- (instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + nativeTrack:(rtc::scoped_refptr) + nativeMediaTrack + type:(RTCMediaStreamTrackType)type { NSParameterAssert(factory); NSParameterAssert(nativeMediaTrack); NSParameterAssert(type == RTCMediaStreamTrackTypeVideo); @@ -65,8 +70,9 @@ rtc::scoped_refptr source( self.nativeVideoTrack->GetSource()); if (source) { - _source = [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self.factory - nativeVideoSource:source]; + _source = + [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self.factory + nativeVideoSource:source]; } } return _source; @@ -74,7 +80,8 @@ - (void)addRenderer:(id)renderer { if (!_workerThread->IsCurrent()) { - _workerThread->BlockingCall([renderer, self] { [self addRenderer:renderer]; }); + _workerThread->BlockingCall( + [renderer, self] { [self addRenderer:renderer]; }); return; } @@ -86,7 +93,7 @@ } } // Create a wrapper that provides a native pointer for us. - RTCVideoRendererAdapter* adapter = + RTCVideoRendererAdapter *adapter = [[RTCVideoRendererAdapter alloc] initWithNativeRenderer:renderer]; [_adapters addObject:adapter]; self.nativeVideoTrack->AddOrUpdateSink(adapter.nativeVideoRenderer, @@ -95,20 +102,21 @@ - (void)removeRenderer:(id)renderer { if (!_workerThread->IsCurrent()) { - _workerThread->BlockingCall([renderer, self] { [self removeRenderer:renderer]; }); + _workerThread->BlockingCall( + [renderer, self] { [self removeRenderer:renderer]; }); return; } __block NSUInteger indexToRemove = NSNotFound; - [_adapters enumerateObjectsUsingBlock:^(RTCVideoRendererAdapter *adapter, - NSUInteger idx, - BOOL *stop) { + [_adapters enumerateObjectsUsingBlock:^( + RTCVideoRendererAdapter *adapter, NSUInteger idx, BOOL *stop) { if (adapter.videoRenderer == renderer) { indexToRemove = idx; *stop = YES; } }]; if (indexToRemove == NSNotFound) { - RTC_LOG(LS_INFO) << "removeRenderer called with a renderer that has not been previously added"; + RTC_LOG(LS_INFO) << "removeRenderer called with a renderer that has not " + "been previously added"; return; } RTCVideoRendererAdapter *adapterToRemove = diff --git a/sdk/objc/api/video_codec/RTCNativeVideoDecoderBuilder+Native.h b/sdk/objc/api/video_codec/RTCNativeVideoDecoderBuilder+Native.h index 0c946a6213..ef91fc808f 100644 --- a/sdk/objc/api/video_codec/RTCNativeVideoDecoderBuilder+Native.h +++ b/sdk/objc/api/video_codec/RTCNativeVideoDecoderBuilder+Native.h @@ -20,6 +20,7 @@ @protocol RTC_OBJC_TYPE (RTCNativeVideoDecoderBuilder) - - (std::unique_ptr)build : (const webrtc::Environment&)env; + - (std::unique_ptr)build + : (const webrtc::Environment&)env; @end diff --git a/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm index 595b590387..91cf1c14d8 100644 --- a/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm +++ b/sdk/objc/api/video_codec/RTCNativeVideoEncoder.mm @@ -20,7 +20,8 @@ RTC_DCHECK_NOTREACHED(); } -- (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings +- (NSInteger)startEncodeWithSettings: + (RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings numberOfCores:(int)numberOfCores { RTC_DCHECK_NOTREACHED(); return 0; diff --git a/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h b/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h index 34bc6bc860..0bcb7c61ff 100644 --- a/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h +++ b/sdk/objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h @@ -20,6 +20,7 @@ @protocol RTC_OBJC_TYPE (RTCNativeVideoEncoderBuilder) - - (std::unique_ptr)build : (const webrtc::Environment&)env; + - (std::unique_ptr)build + : (const webrtc::Environment&)env; @end diff --git a/sdk/objc/api/video_codec/RTCVideoDecoderAV1.mm b/sdk/objc/api/video_codec/RTCVideoDecoderAV1.mm index 1f334a6cc4..47ed45a239 100644 --- a/sdk/objc/api/video_codec/RTCVideoDecoderAV1.mm +++ b/sdk/objc/api/video_codec/RTCVideoDecoderAV1.mm @@ -24,7 +24,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoDecoderAV1Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::CreateDav1dDecoder(); } diff --git a/sdk/objc/api/video_codec/RTCVideoDecoderVP8.mm b/sdk/objc/api/video_codec/RTCVideoDecoderVP8.mm index 1de21d843b..dd59c02cc0 100644 --- a/sdk/objc/api/video_codec/RTCVideoDecoderVP8.mm +++ b/sdk/objc/api/video_codec/RTCVideoDecoderVP8.mm @@ -24,7 +24,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoDecoderVP8Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::CreateVp8Decoder(env); } diff --git a/sdk/objc/api/video_codec/RTCVideoDecoderVP9.mm b/sdk/objc/api/video_codec/RTCVideoDecoderVP9.mm index ebe3e7680a..996adc3acc 100644 --- a/sdk/objc/api/video_codec/RTCVideoDecoderVP9.mm +++ b/sdk/objc/api/video_codec/RTCVideoDecoderVP9.mm @@ -24,7 +24,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoDecoderVP9Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::VP9Decoder::Create(); } diff --git a/sdk/objc/api/video_codec/RTCVideoEncoderAV1.mm b/sdk/objc/api/video_codec/RTCVideoEncoderAV1.mm index 490fedf74a..cca4da4a8b 100644 --- a/sdk/objc/api/video_codec/RTCVideoEncoderAV1.mm +++ b/sdk/objc/api/video_codec/RTCVideoEncoderAV1.mm @@ -27,7 +27,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoEncoderAV1Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::CreateLibaomAv1Encoder(env); } @@ -40,12 +41,14 @@ } + (NSArray*)supportedScalabilityModes { - // `LibaomAv1EncoderSupportedScalabilityModes` returns an std::vector-like container, but - // exact type might change, thus use `auto`. + // `LibaomAv1EncoderSupportedScalabilityModes` returns an std::vector-like + // container, but exact type might change, thus use `auto`. auto modes = webrtc::LibaomAv1EncoderSupportedScalabilityModes(); - NSMutableArray* result = [NSMutableArray arrayWithCapacity:std::size(modes)]; + NSMutableArray* result = + [NSMutableArray arrayWithCapacity:std::size(modes)]; for (webrtc::ScalabilityMode mode : modes) { - [result addObject:[NSString stringForAbslStringView:webrtc::ScalabilityModeToString(mode)]]; + [result addObject:[NSString stringForAbslStringView: + webrtc::ScalabilityModeToString(mode)]]; } return result; } diff --git a/sdk/objc/api/video_codec/RTCVideoEncoderVP8.mm b/sdk/objc/api/video_codec/RTCVideoEncoderVP8.mm index c74edd215f..af5c1a3582 100644 --- a/sdk/objc/api/video_codec/RTCVideoEncoderVP8.mm +++ b/sdk/objc/api/video_codec/RTCVideoEncoderVP8.mm @@ -27,7 +27,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoEncoderVP8Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::CreateVp8Encoder(env); } @@ -40,10 +41,12 @@ } + (NSArray*)supportedScalabilityModes { - NSMutableArray* result = - [NSMutableArray arrayWithCapacity:std::size(webrtc::kVP8SupportedScalabilityModes)]; - for (webrtc::ScalabilityMode mode : webrtc::kVP8SupportedScalabilityModes) { - [result addObject:[NSString stringForAbslStringView:webrtc::ScalabilityModeToString(mode)]]; + NSMutableArray* result = [NSMutableArray + arrayWithCapacity:std::size(webrtc::kVP8SupportedScalabilityModes)]; + for (webrtc::ScalabilityMode mode : + webrtc::kVP8SupportedScalabilityModes) { + [result addObject:[NSString stringForAbslStringView: + webrtc::ScalabilityModeToString(mode)]]; } return result; } diff --git a/sdk/objc/api/video_codec/RTCVideoEncoderVP9.mm b/sdk/objc/api/video_codec/RTCVideoEncoderVP9.mm index ddab023b6f..68b54f4314 100644 --- a/sdk/objc/api/video_codec/RTCVideoEncoderVP9.mm +++ b/sdk/objc/api/video_codec/RTCVideoEncoderVP9.mm @@ -26,7 +26,8 @@ @implementation RTC_OBJC_TYPE (RTCVideoEncoderVP9Builder) - - (std::unique_ptr)build:(const webrtc::Environment&)env { + - (std::unique_ptr)build: + (const webrtc::Environment&)env { return webrtc::CreateVp9Encoder(env); } @@ -47,7 +48,8 @@ for (webrtc::ScalabilityMode mode : webrtc::kAllScalabilityModes) { if (webrtc::VP9Encoder::SupportsScalabilityMode(mode)) { [result - addObject:[NSString stringForAbslStringView:webrtc::ScalabilityModeToString(mode)]]; + addObject:[NSString stringForAbslStringView: + webrtc::ScalabilityModeToString(mode)]]; } } return result; diff --git a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h index 20dc807991..c1aa7a99f6 100644 --- a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h +++ b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer+Private.h @@ -21,7 +21,8 @@ NS_ASSUME_NONNULL_BEGIN } /** Initialize an RTCI420Buffer with its backing I420BufferInterface. */ -- (instancetype)initWithFrameBuffer:(rtc::scoped_refptr)i420Buffer; +- (instancetype)initWithFrameBuffer: + (rtc::scoped_refptr)i420Buffer; - (rtc::scoped_refptr)nativeI420Buffer; @end diff --git a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm index bbf2708ac7..c931000a7f 100644 --- a/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm +++ b/sdk/objc/api/video_frame_buffer/RTCNativeI420Buffer.mm @@ -34,8 +34,14 @@ dataV:(const uint8_t *)dataV { self = [super init]; if (self) { - _i420Buffer = webrtc::I420Buffer::Copy( - width, height, dataY, width, dataU, (width + 1) / 2, dataV, (width + 1) / 2); + _i420Buffer = webrtc::I420Buffer::Copy(width, + height, + dataY, + width, + dataU, + (width + 1) / 2, + dataV, + (width + 1) / 2); } return self; } @@ -47,12 +53,14 @@ strideV:(int)strideV { self = [super init]; if (self) { - _i420Buffer = webrtc::I420Buffer::Create(width, height, strideY, strideU, strideV); + _i420Buffer = + webrtc::I420Buffer::Create(width, height, strideY, strideU, strideV); } return self; } -- (instancetype)initWithFrameBuffer:(rtc::scoped_refptr)i420Buffer { +- (instancetype)initWithFrameBuffer: + (rtc::scoped_refptr)i420Buffer { self = [super init]; if (self) { _i420Buffer = i420Buffer; @@ -107,10 +115,12 @@ scaleWidth:(int)scaleWidth scaleHeight:(int)scaleHeight { rtc::scoped_refptr scaled_buffer = - _i420Buffer->CropAndScale(offsetX, offsetY, cropWidth, cropHeight, scaleWidth, scaleHeight); + _i420Buffer->CropAndScale( + offsetX, offsetY, cropWidth, cropHeight, scaleWidth, scaleHeight); RTC_DCHECK_EQ(scaled_buffer->type(), webrtc::VideoFrameBuffer::Type::kI420); // Calling ToI420() doesn't do any conversions. - rtc::scoped_refptr buffer = scaled_buffer->ToI420(); + rtc::scoped_refptr buffer = + scaled_buffer->ToI420(); RTC_OBJC_TYPE(RTCI420Buffer) *result = [[RTC_OBJC_TYPE(RTCI420Buffer) alloc] initWithFrameBuffer:buffer]; return result; @@ -130,7 +140,8 @@ #if !defined(NDEBUG) && defined(WEBRTC_IOS) - (id)debugQuickLookObject { - UIGraphicsBeginImageContext(CGSizeMake(_i420Buffer->width(), _i420Buffer->height())); + UIGraphicsBeginImageContext( + CGSizeMake(_i420Buffer->width(), _i420Buffer->height())); CGContextRef c = UIGraphicsGetCurrentContext(); uint8_t *ctxData = (uint8_t *)CGBitmapContextGetData(c);