diff --git a/examples/objc/AppRTCMobile/ARDAppClient+Internal.h b/examples/objc/AppRTCMobile/ARDAppClient+Internal.h index 31e0e4dd7c..4a0f9dc669 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient+Internal.h +++ b/examples/objc/AppRTCMobile/ARDAppClient+Internal.h @@ -18,7 +18,8 @@ @class RTC_OBJC_TYPE(RTCPeerConnectionFactory); -@interface ARDAppClient () +@interface ARDAppClient () // All properties should only be mutated from the main queue. @property(nonatomic, strong) id roomServerClient; @@ -42,7 +43,8 @@ @property(nonatomic, strong) NSURL *webSocketRestURL; @property(nonatomic, readonly) BOOL isLoopback; -@property(nonatomic, strong) RTC_OBJC_TYPE(RTCMediaConstraints) * defaultPeerConnectionConstraints; +@property(nonatomic, strong) RTC_OBJC_TYPE(RTCMediaConstraints) * + defaultPeerConnectionConstraints; - (instancetype)initWithRoomServerClient:(id)rsClient signalingChannel:(id)channel diff --git a/examples/objc/AppRTCMobile/ARDAppClient.h b/examples/objc/AppRTCMobile/ARDAppClient.h index 91d2cef1ce..49571d3a2f 100644 --- a/examples/objc/AppRTCMobile/ARDAppClient.h +++ b/examples/objc/AppRTCMobile/ARDAppClient.h @@ -33,12 +33,15 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) { // main queue. @protocol ARDAppClientDelegate -- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state; - -- (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state; +- (void)appClient:(ARDAppClient *)client + didChangeState:(ARDAppClientState)state; - (void)appClient:(ARDAppClient *)client - didCreateLocalCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer; + didChangeConnectionState:(RTCIceConnectionState)state; + +- (void)appClient:(ARDAppClient *)client + didCreateLocalCapturer: + (RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer; - (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack; @@ -48,14 +51,17 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) { - (void)appClient:(ARDAppClient *)client didError:(NSError *)error; -- (void)appClient:(ARDAppClient *)client didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats; +- (void)appClient:(ARDAppClient *)client + didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats; @optional - (void)appClient:(ARDAppClient *)client - didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer; + didCreateLocalFileCapturer: + (RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer; - (void)appClient:(ARDAppClient *)client - didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer; + didCreateLocalExternalSampleCapturer: + (ARDExternalSampleCapturer *)externalSampleCapturer; @end diff --git a/examples/objc/AppRTCMobile/ARDCaptureController.h b/examples/objc/AppRTCMobile/ARDCaptureController.h index 4febccee96..a94f460af6 100644 --- a/examples/objc/AppRTCMobile/ARDCaptureController.h +++ b/examples/objc/AppRTCMobile/ARDCaptureController.h @@ -15,7 +15,8 @@ // Controls the camera. Handles starting the capture, switching cameras etc. @interface ARDCaptureController : NSObject -- (instancetype)initWithCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer +- (instancetype)initWithCapturer: + (RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)capturer settings:(ARDSettingsModel *)settings; - (void)startCapture; - (void)startCapture:(void (^)(NSError *))completion; diff --git a/examples/objc/AppRTCMobile/ARDRoomServerClient.h b/examples/objc/AppRTCMobile/ARDRoomServerClient.h index 3a5818d6d6..70694a8c9f 100644 --- a/examples/objc/AppRTCMobile/ARDRoomServerClient.h +++ b/examples/objc/AppRTCMobile/ARDRoomServerClient.h @@ -18,12 +18,14 @@ - (void)joinRoomWithRoomId:(NSString *)roomId isLoopback:(BOOL)isLoopback - completionHandler:(void (^)(ARDJoinResponse *response, NSError *error))completionHandler; + completionHandler:(void (^)(ARDJoinResponse *response, + NSError *error))completionHandler; - (void)sendMessage:(ARDSignalingMessage *)message forRoomId:(NSString *)roomId clientId:(NSString *)clientId - completionHandler:(void (^)(ARDMessageResponse *response, NSError *error))completionHandler; + completionHandler:(void (^)(ARDMessageResponse *response, + NSError *error))completionHandler; - (void)leaveRoomWithRoomId:(NSString *)roomId clientId:(NSString *)clientId diff --git a/examples/objc/AppRTCMobile/ARDSettingsModel.h b/examples/objc/AppRTCMobile/ARDSettingsModel.h index 47c7defacd..117040a1c2 100644 --- a/examples/objc/AppRTCMobile/ARDSettingsModel.h +++ b/examples/objc/AppRTCMobile/ARDSettingsModel.h @@ -34,7 +34,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Returns current video resolution string. * If no resolution is in store, default value of 640x480 is returned. - * When defaulting to value, the default is saved in store for consistency reasons. + * When defaulting to value, the default is saved in store for consistency + * reasons. */ - (NSString *)currentVideoResolutionSettingFromStore; - (int)currentVideoResolutionWidthFromStore; @@ -56,7 +57,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSArray *)availableVideoCodecs; /** - * Returns current video codec setting from store if present or default (H264) otherwise. + * Returns current video codec setting from store if present or default (H264) + * otherwise. */ - (RTC_OBJC_TYPE(RTCVideoCodecInfo) *)currentVideoCodecSettingFromStore; @@ -83,7 +85,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)storeMaxBitrateSetting:(nullable NSNumber *)bitrate; /** - * Returns current audio only setting from store if present or default (NO) otherwise. + * Returns current audio only setting from store if present or default (NO) + * otherwise. */ - (BOOL)currentAudioOnlySettingFromStore; @@ -95,7 +98,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)storeAudioOnlySetting:(BOOL)audioOnly; /** - * Returns current create AecDump setting from store if present or default (NO) otherwise. + * Returns current create AecDump setting from store if present or default (NO) + * otherwise. */ - (BOOL)currentCreateAecDumpSettingFromStore; @@ -107,8 +111,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)storeCreateAecDumpSetting:(BOOL)createAecDump; /** - * Returns current setting whether to use manual audio config from store if present or default (YES) - * otherwise. + * Returns current setting whether to use manual audio config from store if + * present or default (YES) otherwise. */ - (BOOL)currentUseManualAudioConfigSettingFromStore; diff --git a/examples/objc/AppRTCMobile/ARDSignalingChannel.h b/examples/objc/AppRTCMobile/ARDSignalingChannel.h index 396b117b17..c484d71e54 100644 --- a/examples/objc/AppRTCMobile/ARDSignalingChannel.h +++ b/examples/objc/AppRTCMobile/ARDSignalingChannel.h @@ -26,9 +26,11 @@ typedef NS_ENUM(NSInteger, ARDSignalingChannelState) { @protocol ARDSignalingChannel; @protocol ARDSignalingChannelDelegate -- (void)channel:(id)channel didChangeState:(ARDSignalingChannelState)state; +- (void)channel:(id)channel + didChangeState:(ARDSignalingChannelState)state; -- (void)channel:(id)channel didReceiveMessage:(ARDSignalingMessage *)message; +- (void)channel:(id)channel + didReceiveMessage:(ARDSignalingMessage *)message; @end diff --git a/examples/objc/AppRTCMobile/ARDSignalingMessage.h b/examples/objc/AppRTCMobile/ARDSignalingMessage.h index ac19e8fba7..b9c75f27f6 100644 --- a/examples/objc/AppRTCMobile/ARDSignalingMessage.h +++ b/examples/objc/AppRTCMobile/ARDSignalingMessage.h @@ -40,17 +40,21 @@ typedef enum { @interface ARDICECandidateRemovalMessage : ARDSignalingMessage -@property(nonatomic, readonly) NSArray *candidates; +@property(nonatomic, readonly) + NSArray *candidates; -- (instancetype)initWithRemovedCandidates:(NSArray *)candidates; +- (instancetype)initWithRemovedCandidates: + (NSArray *)candidates; @end @interface ARDSessionDescriptionMessage : ARDSignalingMessage -@property(nonatomic, readonly) RTC_OBJC_TYPE(RTCSessionDescription) * sessionDescription; +@property(nonatomic, readonly) RTC_OBJC_TYPE(RTCSessionDescription) * + sessionDescription; -- (instancetype)initWithDescription:(RTC_OBJC_TYPE(RTCSessionDescription) *)description; +- (instancetype)initWithDescription: + (RTC_OBJC_TYPE(RTCSessionDescription) *)description; @end diff --git a/examples/objc/AppRTCMobile/ARDTURNClient.h b/examples/objc/AppRTCMobile/ARDTURNClient.h index 0399736f03..13368a108d 100644 --- a/examples/objc/AppRTCMobile/ARDTURNClient.h +++ b/examples/objc/AppRTCMobile/ARDTURNClient.h @@ -17,7 +17,7 @@ @protocol ARDTURNClient // Returns TURN server urls if successful. -- (void)requestServersWithCompletionHandler:(void (^)(NSArray *turnServers, - NSError *error))completionHandler; +- (void)requestServersWithCompletionHandler: + (void (^)(NSArray *turnServers, NSError *error))completionHandler; @end diff --git a/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h b/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h index 5fd823f2de..7f02710ef3 100644 --- a/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h +++ b/examples/objc/AppRTCMobile/RTCIceCandidate+JSON.h @@ -13,10 +13,12 @@ @interface RTC_OBJC_TYPE (RTCIceCandidate) (JSON) - + (RTC_OBJC_TYPE(RTCIceCandidate) *)candidateFromJSONDictionary : (NSDictionary *)dictionary; + + (RTC_OBJC_TYPE(RTCIceCandidate) *)candidateFromJSONDictionary + : (NSDictionary *)dictionary; + (NSArray *)candidatesFromJSONDictionary: (NSDictionary *)dictionary; -+ (NSData *)JSONDataForIceCandidates:(NSArray *)candidates ++ (NSData *)JSONDataForIceCandidates: + (NSArray *)candidates withType:(NSString *)typeValue; - (NSData *)JSONData; diff --git a/examples/objc/AppRTCMobile/RTCIceServer+JSON.h b/examples/objc/AppRTCMobile/RTCIceServer+JSON.h index 35f6af7583..4106470c48 100644 --- a/examples/objc/AppRTCMobile/RTCIceServer+JSON.h +++ b/examples/objc/AppRTCMobile/RTCIceServer+JSON.h @@ -13,6 +13,7 @@ @interface RTC_OBJC_TYPE (RTCIceServer) (JSON) - + (RTC_OBJC_TYPE(RTCIceServer) *)serverFromJSONDictionary : (NSDictionary *)dictionary; + + (RTC_OBJC_TYPE(RTCIceServer) *)serverFromJSONDictionary + : (NSDictionary *)dictionary; @end diff --git a/examples/objc/AppRTCMobile/common/ARDUtilities.h b/examples/objc/AppRTCMobile/common/ARDUtilities.h index 5f0d7dbef7..25f786017d 100644 --- a/examples/objc/AppRTCMobile/common/ARDUtilities.h +++ b/examples/objc/AppRTCMobile/common/ARDUtilities.h @@ -22,13 +22,15 @@ // Issues an asynchronous request that calls back on main queue. + (void)sendAsyncRequest:(NSURLRequest *)request - completionHandler: - (void (^)(NSURLResponse *response, NSData *data, NSError *error))completionHandler; + completionHandler:(void (^)(NSURLResponse *response, + NSData *data, + NSError *error))completionHandler; // Posts data to the specified URL. + (void)sendAsyncPostToURL:(NSURL *)url withData:(NSData *)data - completionHandler:(void (^)(BOOL succeeded, NSData *data))completionHandler; + completionHandler: + (void (^)(BOOL succeeded, NSData *data))completionHandler; @end diff --git a/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.h b/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.h index 82f8fcdd1b..b20aec283c 100644 --- a/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.h +++ b/examples/objc/AppRTCMobile/ios/ARDFileCaptureController.h @@ -25,7 +25,8 @@ NS_CLASS_AVAILABLE_IOS(10) * * @param capturer The capturer to be controlled. */ -- (instancetype)initWithCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)capturer; +- (instancetype)initWithCapturer: + (RTC_OBJC_TYPE(RTCFileVideoCapturer) *)capturer; /** * Starts the file capturer. diff --git a/examples/objc/AppRTCMobile/ios/ARDMainView.h b/examples/objc/AppRTCMobile/ios/ARDMainView.h index c6691c2d84..f9404a2952 100644 --- a/examples/objc/AppRTCMobile/ios/ARDMainView.h +++ b/examples/objc/AppRTCMobile/ios/ARDMainView.h @@ -14,7 +14,9 @@ @protocol ARDMainViewDelegate -- (void)mainView:(ARDMainView *)mainView didInputRoom:(NSString *)room isLoopback:(BOOL)isLoopback; +- (void)mainView:(ARDMainView *)mainView + didInputRoom:(NSString *)room + isLoopback:(BOOL)isLoopback; - (void)mainViewDidToggleAudioLoop:(ARDMainView *)mainView; @end diff --git a/examples/objc/AppRTCMobile/ios/ARDVideoCallView.h b/examples/objc/AppRTCMobile/ios/ARDVideoCallView.h index a31c7fe742..8af8756abd 100644 --- a/examples/objc/AppRTCMobile/ios/ARDVideoCallView.h +++ b/examples/objc/AppRTCMobile/ios/ARDVideoCallView.h @@ -39,8 +39,10 @@ @interface ARDVideoCallView : UIView @property(nonatomic, readonly) UILabel *statusLabel; -@property(nonatomic, readonly) RTC_OBJC_TYPE(RTCCameraPreviewView) * localVideoView; -@property(nonatomic, readonly) __kindof UIView *remoteVideoView; +@property(nonatomic, readonly) RTC_OBJC_TYPE(RTCCameraPreviewView) * + localVideoView; +@property(nonatomic, readonly) + __kindof UIView *remoteVideoView; @property(nonatomic, readonly) ARDStatsView *statsView; @property(nonatomic, weak) id delegate; diff --git a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.h b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.h index 2c4a56368a..cfc92b1e67 100644 --- a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.h +++ b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSampleHandler.h @@ -17,7 +17,8 @@ @protocol ARDExternalSampleDelegate; API_AVAILABLE(ios(10.0)) -@interface ARDBroadcastSampleHandler : RPBroadcastSampleHandler +@interface ARDBroadcastSampleHandler + : RPBroadcastSampleHandler @property(nonatomic, strong) id capturer; diff --git a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSetupViewController.h b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSetupViewController.h index bbf397d8a9..aba4dbe971 100644 --- a/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSetupViewController.h +++ b/examples/objc/AppRTCMobile/ios/broadcast_extension/ARDBroadcastSetupViewController.h @@ -12,6 +12,7 @@ #import API_AVAILABLE(ios(11.0)) -@interface ARDBroadcastSetupViewController : UIViewController +@interface ARDBroadcastSetupViewController + : UIViewController @end diff --git a/examples/objc/AppRTCMobile/tests/ARDAppClient_xctest.mm b/examples/objc/AppRTCMobile/tests/ARDAppClient_xctest.mm index 2694e49914..e480a2451b 100644 --- a/examples/objc/AppRTCMobile/tests/ARDAppClient_xctest.mm +++ b/examples/objc/AppRTCMobile/tests/ARDAppClient_xctest.mm @@ -35,7 +35,7 @@ isInitiator:(BOOL)isInitiator messages:(NSArray *)messages messageHandler: - (void (^)(ARDSignalingMessage *))messageHandler { + (void (^)(ARDSignalingMessage *))messageHandler { id mockRoomServerClient = [OCMockObject mockForProtocol:@protocol(ARDRoomServerClient)]; @@ -69,9 +69,9 @@ messageHandler(message); completionHandler(messageResponse, nil); }] sendMessage:[OCMArg any] - forRoomId:roomId - clientId:clientId - completionHandler:[OCMArg any]]; + forRoomId:roomId + clientId:clientId + completionHandler:[OCMArg any]]; // Do nothing on leave. [[[mockRoomServerClient stub] andDo:^(NSInvocation *invocation) { @@ -89,8 +89,8 @@ - (id)mockSignalingChannelForRoomId:(NSString *)roomId clientId:(NSString *)clientId - messageHandler: - (void (^)(ARDSignalingMessage *message))messageHandler { + messageHandler:(void (^)(ARDSignalingMessage *message)) + messageHandler { id mockSignalingChannel = [OCMockObject niceMockForProtocol:@protocol(ARDSignalingChannel)]; [[mockSignalingChannel stub] registerForRoomId:roomId clientId:clientId]; @@ -103,8 +103,7 @@ } - (id)mockTURNClient { - id mockTURNClient = - [OCMockObject mockForProtocol:@protocol(ARDTURNClient)]; + id mockTURNClient = [OCMockObject mockForProtocol:@protocol(ARDTURNClient)]; [[[mockTURNClient stub] andDo:^(NSInvocation *invocation) { // Don't return anything in TURN response. __unsafe_unretained void (^completionHandler)(NSArray *turnServers, @@ -124,24 +123,24 @@ return model; } -- (ARDAppClient *)createAppClientForRoomId:(NSString *)roomId - clientId:(NSString *)clientId - isInitiator:(BOOL)isInitiator - messages:(NSArray *)messages - messageHandler: - (void (^)(ARDSignalingMessage *message))messageHandler - connectedHandler:(void (^)(void))connectedHandler - localVideoTrackHandler:(void (^)(void))localVideoTrackHandler { +- (ARDAppClient *) + createAppClientForRoomId:(NSString *)roomId + clientId:(NSString *)clientId + isInitiator:(BOOL)isInitiator + messages:(NSArray *)messages + messageHandler: + (void (^)(ARDSignalingMessage *message))messageHandler + connectedHandler:(void (^)(void))connectedHandler + localVideoTrackHandler:(void (^)(void))localVideoTrackHandler { id turnClient = [self mockTURNClient]; id signalingChannel = [self mockSignalingChannelForRoomId:roomId clientId:clientId messageHandler:messageHandler]; - id roomServerClient = - [self mockRoomServerClientForRoomId:roomId - clientId:clientId - isInitiator:isInitiator - messages:messages - messageHandler:messageHandler]; + id roomServerClient = [self mockRoomServerClientForRoomId:roomId + clientId:clientId + isInitiator:isInitiator + messages:messages + messageHandler:messageHandler]; id delegate = [OCMockObject niceMockForProtocol:@protocol(ARDAppClientDelegate)]; [[[delegate stub] andDo:^(NSInvocation *invocation) { @@ -150,8 +149,7 @@ didChangeConnectionState:RTCIceConnectionStateConnected]; [[[delegate stub] andDo:^(NSInvocation *invocation) { localVideoTrackHandler(); - }] appClient:[OCMArg any] - didReceiveLocalVideoTrack:[OCMArg any]]; + }] appClient:[OCMArg any] didReceiveLocalVideoTrack:[OCMArg any]]; return [[ARDAppClient alloc] initWithRoomServerClient:roomServerClient signalingChannel:signalingChannel @@ -183,55 +181,68 @@ [self expectationWithDescription:@"Answerer PC connected"]; caller = [self createAppClientForRoomId:roomId - clientId:callerId - isInitiator:YES - messages:[NSArray array] - messageHandler:^(ARDSignalingMessage *message) { - ARDAppClient *strongAnswerer = weakAnswerer; - [strongAnswerer channel:strongAnswerer.channel didReceiveMessage:message]; - } connectedHandler:^{ - [callerConnectionExpectation fulfill]; - } localVideoTrackHandler:^{ - }]; + clientId:callerId + isInitiator:YES + messages:[NSArray array] + messageHandler:^(ARDSignalingMessage *message) { + ARDAppClient *strongAnswerer = weakAnswerer; + [strongAnswerer channel:strongAnswerer.channel + didReceiveMessage:message]; + } + connectedHandler:^{ + [callerConnectionExpectation fulfill]; + } + localVideoTrackHandler:^{ + }]; // TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion // crash in Debug. - caller.defaultPeerConnectionConstraints = - [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:nil - optionalConstraints:nil]; + caller.defaultPeerConnectionConstraints = [[RTC_OBJC_TYPE(RTCMediaConstraints) + alloc] initWithMandatoryConstraints:nil optionalConstraints:nil]; weakCaller = caller; answerer = [self createAppClientForRoomId:roomId - clientId:answererId - isInitiator:NO - messages:[NSArray array] - messageHandler:^(ARDSignalingMessage *message) { - ARDAppClient *strongCaller = weakCaller; - [strongCaller channel:strongCaller.channel didReceiveMessage:message]; - } connectedHandler:^{ - [answererConnectionExpectation fulfill]; - } localVideoTrackHandler:^{ - }]; + clientId:answererId + isInitiator:NO + messages:[NSArray array] + messageHandler:^(ARDSignalingMessage *message) { + ARDAppClient *strongCaller = weakCaller; + [strongCaller channel:strongCaller.channel didReceiveMessage:message]; + } + connectedHandler:^{ + [answererConnectionExpectation fulfill]; + } + localVideoTrackHandler:^{ + }]; // TODO(tkchin): Figure out why DTLS-SRTP constraint causes thread assertion // crash in Debug. answerer.defaultPeerConnectionConstraints = - [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:nil - optionalConstraints:nil]; + [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] + initWithMandatoryConstraints:nil + optionalConstraints:nil]; weakAnswerer = answerer; // Kick off connection. - [caller connectToRoomWithId:roomId settings:[self mockSettingsModel] isLoopback:NO]; - [answerer connectToRoomWithId:roomId settings:[self mockSettingsModel] isLoopback:NO]; - [self waitForExpectationsWithTimeout:20 handler:^(NSError *error) { - if (error) { - XCTFail(@"Expectation failed with error %@.", error); - } - }]; + [caller connectToRoomWithId:roomId + settings:[self mockSettingsModel] + isLoopback:NO]; + [answerer connectToRoomWithId:roomId + settings:[self mockSettingsModel] + isLoopback:NO]; + [self waitForExpectationsWithTimeout:20 + handler:^(NSError *error) { + if (error) { + XCTFail(@"Expectation failed with error %@.", + error); + } + }]; } // Test to see that we get a local video connection // Note this will currently pass even when no camera is connected as a local -// video track is created regardless (Perhaps there should be a test for that...) -#if !TARGET_IPHONE_SIMULATOR // Expect to fail on simulator due to no camera support +// video track is created regardless (Perhaps there should be a test for +// that...) +#if !TARGET_IPHONE_SIMULATOR // Expect to fail on simulator due to no camera + // support - (void)testSessionShouldGetLocalVideoTrackCallback { ARDAppClient *caller = nil; NSString *roomId = @"testRoom"; @@ -241,25 +252,31 @@ [self expectationWithDescription:@"Caller got local video."]; caller = [self createAppClientForRoomId:roomId - clientId:callerId - isInitiator:YES - messages:[NSArray array] - messageHandler:^(ARDSignalingMessage *message) {} - connectedHandler:^{} - localVideoTrackHandler:^{ [localVideoTrackExpectation fulfill]; }]; - caller.defaultPeerConnectionConstraints = - [[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:nil - optionalConstraints:nil]; + clientId:callerId + isInitiator:YES + messages:[NSArray array] + messageHandler:^(ARDSignalingMessage *message) { + } + connectedHandler:^{ + } + localVideoTrackHandler:^{ + [localVideoTrackExpectation fulfill]; + }]; + caller.defaultPeerConnectionConstraints = [[RTC_OBJC_TYPE(RTCMediaConstraints) + alloc] initWithMandatoryConstraints:nil optionalConstraints:nil]; // Kick off connection. [caller connectToRoomWithId:roomId settings:[self mockSettingsModel] isLoopback:NO]; - [self waitForExpectationsWithTimeout:20 handler:^(NSError *error) { - if (error) { - XCTFail("Expectation timed out with error: %@.", error); - } - }]; + [self waitForExpectationsWithTimeout:20 + handler:^(NSError *error) { + if (error) { + XCTFail( + "Expectation timed out with error: %@.", + error); + } + }]; } #endif diff --git a/examples/objc/AppRTCMobile/tests/ARDFileCaptureController_xctest.mm b/examples/objc/AppRTCMobile/tests/ARDFileCaptureController_xctest.mm index 2e39834190..0a057cb20f 100644 --- a/examples/objc/AppRTCMobile/tests/ARDFileCaptureController_xctest.mm +++ b/examples/objc/AppRTCMobile/tests/ARDFileCaptureController_xctest.mm @@ -31,7 +31,8 @@ NS_CLASS_AVAILABLE_IOS(10) - (void)setUp { [super setUp]; - self.fileCapturerMock = OCMClassMock([RTC_OBJC_TYPE(RTCFileVideoCapturer) class]); + self.fileCapturerMock = + OCMClassMock([RTC_OBJC_TYPE(RTCFileVideoCapturer) class]); self.fileCaptureController = [[ARDFileCaptureController alloc] initWithCapturer:self.fileCapturerMock]; } @@ -44,7 +45,8 @@ NS_CLASS_AVAILABLE_IOS(10) } - (void)testCaptureIsStarted { - [[self.fileCapturerMock expect] startCapturingFromFileNamed:[OCMArg any] onError:[OCMArg any]]; + [[self.fileCapturerMock expect] startCapturingFromFileNamed:[OCMArg any] + onError:[OCMArg any]]; [self.fileCaptureController startCapture]; diff --git a/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm b/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm index dc62798963..c435d65c7d 100644 --- a/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm +++ b/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm @@ -17,7 +17,6 @@ #import "ARDSettingsModel+Private.h" #import "ARDSettingsStore.h" - @interface ARDSettingsModelTests : XCTestCase { ARDSettingsModel *_model; } @@ -50,13 +49,13 @@ - (void)testStoringInvalidConstraintReturnsNo { id storeMock = [self setupMockStore]; - [([[storeMock stub] andReturn:@"960x480"])videoResolution]; + [([[storeMock stub] andReturn:@"960x480"]) videoResolution]; XCTAssertFalse([_model storeVideoResolutionSetting:@"960x480"]); } - (void)testWidthConstraintFromStore { id storeMock = [self setupMockStore]; - [([[storeMock stub] andReturn:@"1270x480"])videoResolution]; + [([[storeMock stub] andReturn:@"1270x480"]) videoResolution]; int width = [_model currentVideoResolutionWidthFromStore]; XCTAssertEqual(width, 1270); @@ -64,7 +63,7 @@ - (void)testHeightConstraintFromStore { id storeMock = [self setupMockStore]; - [([[storeMock stub] andReturn:@"960x540"])videoResolution]; + [([[storeMock stub] andReturn:@"960x540"]) videoResolution]; int height = [_model currentVideoResolutionHeightFromStore]; XCTAssertEqual(height, 540); @@ -72,7 +71,7 @@ - (void)testConstraintComponentIsNilWhenInvalidConstraintString { id storeMock = [self setupMockStore]; - [([[storeMock stub] andReturn:@"invalid"])videoResolution]; + [([[storeMock stub] andReturn:@"invalid"]) videoResolution]; int width = [_model currentVideoResolutionWidthFromStore]; XCTAssertEqual(width, 0); diff --git a/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h b/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h index a230646073..06d745a0fa 100644 --- a/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h +++ b/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h @@ -59,7 +59,8 @@ extern NSString *const SRHTTPResponseErrorKey; // It will be nil until after the handshake completes. @property(nonatomic, readonly, copy) NSString *protocol; -// Protocols should be an array of strings that turn into Sec-WebSocket-Protocol. +// Protocols should be an array of strings that turn into +// Sec-WebSocket-Protocol. - (id)initWithURLRequest:(NSURLRequest *)request protocols:(NSArray *)protocols; - (id)initWithURLRequest:(NSURLRequest *)request; @@ -72,11 +73,13 @@ extern NSString *const SRHTTPResponseErrorKey; - (void)setDelegateOperationQueue:(NSOperationQueue *)queue; - (void)setDelegateDispatchQueue:(dispatch_queue_t)queue; -// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using defaultModes. +// By default, it will schedule itself on +[NSRunLoop SR_networkRunLoop] using +// defaultModes. - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; - (void)unscheduleFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode; -// SRWebSockets are intended for one-time-use only. Open should be called once and only once. +// SRWebSockets are intended for one-time-use only. Open should be called once +// and only once. - (void)open; - (void)close; diff --git a/examples/objcnativeapi/objc/NADViewController.mm b/examples/objcnativeapi/objc/NADViewController.mm index fd244799f8..679949b47d 100644 --- a/examples/objcnativeapi/objc/NADViewController.mm +++ b/examples/objcnativeapi/objc/NADViewController.mm @@ -23,7 +23,8 @@ @property(nonatomic) RTC_OBJC_TYPE(RTCCameraVideoCapturer) * capturer; @property(nonatomic) RTC_OBJC_TYPE(RTCCameraPreviewView) * localVideoView; -@property(nonatomic) __kindof UIView *remoteVideoView; +@property(nonatomic) + __kindof UIView *remoteVideoView; @property(nonatomic) UIButton *callButton; @property(nonatomic) UIButton *hangUpButton; @@ -46,18 +47,22 @@ - (void)loadView { _view = [[UIView alloc] initWithFrame:CGRectZero]; - _remoteVideoView = [[RTC_OBJC_TYPE(RTCMTLVideoView) alloc] initWithFrame:CGRectZero]; + _remoteVideoView = + [[RTC_OBJC_TYPE(RTCMTLVideoView) alloc] initWithFrame:CGRectZero]; _remoteVideoView.translatesAutoresizingMaskIntoConstraints = NO; [_view addSubview:_remoteVideoView]; - _localVideoView = [[RTC_OBJC_TYPE(RTCCameraPreviewView) alloc] initWithFrame:CGRectZero]; + _localVideoView = + [[RTC_OBJC_TYPE(RTCCameraPreviewView) alloc] initWithFrame:CGRectZero]; _localVideoView.translatesAutoresizingMaskIntoConstraints = NO; [_view addSubview:_localVideoView]; _callButton = [UIButton buttonWithType:UIButtonTypeSystem]; _callButton.translatesAutoresizingMaskIntoConstraints = NO; [_callButton setTitle:@"Call" forState:UIControlStateNormal]; - [_callButton addTarget:self action:@selector(call:) forControlEvents:UIControlEventTouchUpInside]; + [_callButton addTarget:self + action:@selector(call:) + forControlEvents:UIControlEventTouchUpInside]; [_view addSubview:_callButton]; _hangUpButton = [UIButton buttonWithType:UIButtonTypeSystem]; @@ -69,27 +74,40 @@ [_view addSubview:_hangUpButton]; UILayoutGuide *margin = _view.layoutMarginsGuide; - [_remoteVideoView.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor].active = YES; - [_remoteVideoView.topAnchor constraintEqualToAnchor:margin.topAnchor].active = YES; - [_remoteVideoView.trailingAnchor constraintEqualToAnchor:margin.trailingAnchor].active = YES; - [_remoteVideoView.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor].active = YES; - - [_localVideoView.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor constant:8.0].active = + [_remoteVideoView.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor] + .active = YES; + [_remoteVideoView.topAnchor constraintEqualToAnchor:margin.topAnchor].active = YES; - [_localVideoView.topAnchor constraintEqualToAnchor:margin.topAnchor constant:8.0].active = YES; + [_remoteVideoView.trailingAnchor + constraintEqualToAnchor:margin.trailingAnchor] + .active = YES; + [_remoteVideoView.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor] + .active = YES; + + [_localVideoView.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor + constant:8.0] + .active = YES; + [_localVideoView.topAnchor constraintEqualToAnchor:margin.topAnchor + constant:8.0] + .active = YES; [_localVideoView.widthAnchor constraintEqualToConstant:60].active = YES; [_localVideoView.heightAnchor constraintEqualToConstant:60].active = YES; - [_callButton.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor constant:8.0].active = - YES; - [_callButton.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor constant:8.0].active = YES; + [_callButton.leadingAnchor constraintEqualToAnchor:margin.leadingAnchor + constant:8.0] + .active = YES; + [_callButton.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor + constant:8.0] + .active = YES; [_callButton.widthAnchor constraintEqualToConstant:100].active = YES; [_callButton.heightAnchor constraintEqualToConstant:40].active = YES; - [_hangUpButton.trailingAnchor constraintEqualToAnchor:margin.trailingAnchor constant:8.0].active = - YES; - [_hangUpButton.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor constant:8.0].active = - YES; + [_hangUpButton.trailingAnchor constraintEqualToAnchor:margin.trailingAnchor + constant:8.0] + .active = YES; + [_hangUpButton.bottomAnchor constraintEqualToAnchor:margin.bottomAnchor + constant:8.0] + .active = YES; [_hangUpButton.widthAnchor constraintEqualToConstant:100].active = YES; [_hangUpButton.heightAnchor constraintEqualToConstant:40].active = YES; @@ -120,20 +138,27 @@ int targetHeight = 480; int currentDiff = INT_MAX; NSArray *formats = - [RTC_OBJC_TYPE(RTCCameraVideoCapturer) supportedFormatsForDevice:selectedDevice]; + [RTC_OBJC_TYPE(RTCCameraVideoCapturer) + supportedFormatsForDevice:selectedDevice]; for (AVCaptureDeviceFormat *format in formats) { - CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription); - FourCharCode pixelFormat = CMFormatDescriptionGetMediaSubType(format.formatDescription); - int diff = abs(targetWidth - dimension.width) + abs(targetHeight - dimension.height); + CMVideoDimensions dimension = + CMVideoFormatDescriptionGetDimensions(format.formatDescription); + FourCharCode pixelFormat = + CMFormatDescriptionGetMediaSubType(format.formatDescription); + int diff = abs(targetWidth - dimension.width) + + abs(targetHeight - dimension.height); if (diff < currentDiff) { selectedFormat = format; currentDiff = diff; - } else if (diff == currentDiff && pixelFormat == [_capturer preferredOutputPixelFormat]) { + } else if (diff == currentDiff && + pixelFormat == [_capturer preferredOutputPixelFormat]) { selectedFormat = format; } } - [self.capturer startCaptureWithDevice:selectedDevice format:selectedFormat fps:30]; + [self.capturer startCaptureWithDevice:selectedDevice + format:selectedFormat + fps:30]; } - (void)didReceiveMemoryWarning { diff --git a/examples/objcnativeapi/objc/objc_call_client.h b/examples/objcnativeapi/objc/objc_call_client.h index cb8501d9ce..5f429be7b0 100644 --- a/examples/objcnativeapi/objc/objc_call_client.h +++ b/examples/objcnativeapi/objc/objc_call_client.h @@ -40,14 +40,17 @@ class ObjCCallClient { public: explicit PCObserver(ObjCCallClient* client); - void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override; - void OnDataChannel(rtc::scoped_refptr data_channel) override; + void OnSignalingChange( + webrtc::PeerConnectionInterface::SignalingState new_state) override; + void OnDataChannel( + rtc::scoped_refptr data_channel) override; void OnRenegotiationNeeded() override; void OnIceConnectionChange( webrtc::PeerConnectionInterface::IceConnectionState new_state) override; void OnIceGatheringChange( webrtc::PeerConnectionInterface::IceGatheringState new_state) override; - void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; + void OnIceCandidate( + const webrtc::IceCandidateInterface* candidate) override; private: ObjCCallClient* const client_; @@ -63,10 +66,12 @@ class ObjCCallClient { const std::unique_ptr pc_observer_; - rtc::scoped_refptr pcf_ RTC_GUARDED_BY(thread_checker_); + rtc::scoped_refptr pcf_ + RTC_GUARDED_BY(thread_checker_); std::unique_ptr network_thread_ RTC_GUARDED_BY(thread_checker_); std::unique_ptr worker_thread_ RTC_GUARDED_BY(thread_checker_); - std::unique_ptr signaling_thread_ RTC_GUARDED_BY(thread_checker_); + std::unique_ptr signaling_thread_ + RTC_GUARDED_BY(thread_checker_); std::unique_ptr> remote_sink_ RTC_GUARDED_BY(thread_checker_); @@ -74,7 +79,8 @@ class ObjCCallClient { RTC_GUARDED_BY(thread_checker_); webrtc::Mutex pc_mutex_; - rtc::scoped_refptr pc_ RTC_GUARDED_BY(pc_mutex_); + rtc::scoped_refptr pc_ + RTC_GUARDED_BY(pc_mutex_); }; } // namespace webrtc_examples diff --git a/examples/objcnativeapi/objc/objc_call_client.mm b/examples/objcnativeapi/objc/objc_call_client.mm index 2f37286e94..f2582c4113 100644 --- a/examples/objcnativeapi/objc/objc_call_client.mm +++ b/examples/objcnativeapi/objc/objc_call_client.mm @@ -37,7 +37,8 @@ namespace { class CreateOfferObserver : public webrtc::CreateSessionDescriptionObserver { public: - explicit CreateOfferObserver(rtc::scoped_refptr pc); + explicit CreateOfferObserver( + rtc::scoped_refptr pc); void OnSuccess(webrtc::SessionDescriptionInterface* desc) override; void OnFailure(webrtc::RTCError error) override; @@ -46,12 +47,14 @@ class CreateOfferObserver : public webrtc::CreateSessionDescriptionObserver { const rtc::scoped_refptr pc_; }; -class SetRemoteSessionDescriptionObserver : public webrtc::SetRemoteDescriptionObserverInterface { +class SetRemoteSessionDescriptionObserver + : public webrtc::SetRemoteDescriptionObserverInterface { public: void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override; }; -class SetLocalSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface { +class SetLocalSessionDescriptionObserver + : public webrtc::SetLocalDescriptionObserverInterface { public: void OnSetLocalDescriptionComplete(webrtc::RTCError error) override; }; @@ -77,8 +80,8 @@ void ObjCCallClient::Call(RTC_OBJC_TYPE(RTCVideoCapturer) * capturer, remote_sink_ = webrtc::ObjCToNativeVideoRenderer(remote_renderer); - video_source_ = - webrtc::ObjCToNativeVideoCapturer(capturer, signaling_thread_.get(), worker_thread_.get()); + video_source_ = webrtc::ObjCToNativeVideoCapturer( + capturer, signaling_thread_.get(), worker_thread_.get()); CreatePeerConnection(); Connect(); @@ -119,15 +122,19 @@ void ObjCCallClient::CreatePeerConnectionFactory() { dependencies.worker_thread = worker_thread_.get(); dependencies.signaling_thread = signaling_thread_.get(); dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - 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(RTCDefaultVideoEncoderFactory) alloc] init]); dependencies.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory( [[RTC_OBJC_TYPE(RTCDefaultVideoDecoderFactory) alloc] init]); - dependencies.audio_processing_builder = std::make_unique(); + dependencies.audio_processing_builder = + std::make_unique(); webrtc::EnableMedia(dependencies); - dependencies.event_log_factory = std::make_unique(); + dependencies.event_log_factory = + std::make_unique(); pcf_ = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_.get(); } @@ -141,7 +148,8 @@ void ObjCCallClient::CreatePeerConnection() { options.disable_encryption = true; pcf_->SetOptions(options); webrtc::PeerConnectionDependencies pc_dependencies(pc_observer_.get()); - pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(pc_dependencies)).MoveValue(); + pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(pc_dependencies)) + .MoveValue(); RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_.get(); rtc::scoped_refptr local_video_track = @@ -151,8 +159,10 @@ void ObjCCallClient::CreatePeerConnection() { for (const rtc::scoped_refptr& tranceiver : pc_->GetTransceivers()) { - rtc::scoped_refptr track = tranceiver->receiver()->track(); - if (track && track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { + rtc::scoped_refptr track = + tranceiver->receiver()->track(); + if (track && + track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { static_cast(track.get()) ->AddOrUpdateSink(remote_sink_.get(), rtc::VideoSinkWants()); RTC_LOG(LS_INFO) << "Remote video sink set up: " << track.get(); @@ -167,7 +177,8 @@ void ObjCCallClient::Connect() { webrtc::PeerConnectionInterface::RTCOfferAnswerOptions()); } -ObjCCallClient::PCObserver::PCObserver(ObjCCallClient* client) : client_(client) {} +ObjCCallClient::PCObserver::PCObserver(ObjCCallClient* client) + : client_(client) {} void ObjCCallClient::PCObserver::OnSignalingChange( webrtc::PeerConnectionInterface::SignalingState new_state) { @@ -193,14 +204,16 @@ void ObjCCallClient::PCObserver::OnIceGatheringChange( RTC_LOG(LS_INFO) << "OnIceGatheringChange: " << new_state; } -void ObjCCallClient::PCObserver::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { +void ObjCCallClient::PCObserver::OnIceCandidate( + const webrtc::IceCandidateInterface* candidate) { RTC_LOG(LS_INFO) << "OnIceCandidate: " << candidate->server_url(); webrtc::MutexLock lock(&client_->pc_mutex_); RTC_DCHECK(client_->pc_ != nullptr); client_->pc_->AddIceCandidate(candidate); } -CreateOfferObserver::CreateOfferObserver(rtc::scoped_refptr pc) +CreateOfferObserver::CreateOfferObserver( + rtc::scoped_refptr pc) : pc_(pc) {} void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) { @@ -209,25 +222,29 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) { RTC_LOG(LS_INFO) << "Created offer: " << sdp; // Ownership of desc was transferred to us, now we transfer it forward. - pc_->SetLocalDescription(absl::WrapUnique(desc), - rtc::make_ref_counted()); + pc_->SetLocalDescription( + absl::WrapUnique(desc), + rtc::make_ref_counted()); // Generate a fake answer. std::unique_ptr answer( webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp)); - pc_->SetRemoteDescription(std::move(answer), - rtc::make_ref_counted()); + pc_->SetRemoteDescription( + std::move(answer), + rtc::make_ref_counted()); } void CreateOfferObserver::OnFailure(webrtc::RTCError error) { RTC_LOG(LS_INFO) << "Failed to create offer: " << error.message(); } -void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete(webrtc::RTCError error) { +void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete( + webrtc::RTCError error) { RTC_LOG(LS_INFO) << "Set remote description: " << error.message(); } -void SetLocalSessionDescriptionObserver::OnSetLocalDescriptionComplete(webrtc::RTCError error) { +void SetLocalSessionDescriptionObserver::OnSetLocalDescriptionComplete( + webrtc::RTCError error) { RTC_LOG(LS_INFO) << "Set local description: " << error.message(); } diff --git a/examples/peerconnection/server/data_socket.h b/examples/peerconnection/server/data_socket.h index 63d808f239..326ecc075b 100644 --- a/examples/peerconnection/server/data_socket.h +++ b/examples/peerconnection/server/data_socket.h @@ -33,7 +33,6 @@ typedef int NativeSocket; #endif #endif - class SocketBase { public: SocketBase() : socket_(INVALID_SOCKET) {}