| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2  *  Copyright 2014 The WebRTC Project Authors. All rights reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 #import "ARDAppClient+Internal.h" | 11 #import "ARDAppClient+Internal.h" | 
| 12 | 12 | 
| 13 #import "WebRTC/RTCAVFoundationVideoSource.h" | 13 #import "WebRTC/RTCAVFoundationVideoSource.h" | 
| 14 #import "WebRTC/RTCAudioTrack.h" | 14 #import "WebRTC/RTCAudioTrack.h" | 
| 15 #import "WebRTC/RTCConfiguration.h" | 15 #import "WebRTC/RTCConfiguration.h" | 
| 16 #import "WebRTC/RTCFileLogger.h" | 16 #import "WebRTC/RTCFileLogger.h" | 
| 17 #import "WebRTC/RTCIceServer.h" | 17 #import "WebRTC/RTCIceServer.h" | 
| 18 #import "WebRTC/RTCLogging.h" | 18 #import "WebRTC/RTCLogging.h" | 
| 19 #import "WebRTC/RTCMediaConstraints.h" | 19 #import "WebRTC/RTCMediaConstraints.h" | 
| 20 #import "WebRTC/RTCMediaStream.h" | 20 #import "WebRTC/RTCMediaStream.h" | 
| 21 #import "WebRTC/RTCPeerConnectionFactory.h" | 21 #import "WebRTC/RTCPeerConnectionFactory.h" | 
| 22 #import "WebRTC/RTCRtpSender.h" | 22 #import "WebRTC/RTCRtpSender.h" | 
| 23 #import "WebRTC/RTCTracing.h" | 23 #import "WebRTC/RTCTracing.h" | 
| 24 | 24 | 
| 25 #import "ARDAppEngineClient.h" | 25 #import "ARDAppEngineClient.h" | 
| 26 #import "ARDCEODTURNClient.h" | 26 #import "ARDTURNClient+Internal.h" | 
| 27 #import "ARDJoinResponse.h" | 27 #import "ARDJoinResponse.h" | 
| 28 #import "ARDMessageResponse.h" | 28 #import "ARDMessageResponse.h" | 
| 29 #import "ARDSDPUtils.h" | 29 #import "ARDSDPUtils.h" | 
| 30 #import "ARDSignalingMessage.h" | 30 #import "ARDSignalingMessage.h" | 
| 31 #import "ARDUtilities.h" | 31 #import "ARDUtilities.h" | 
| 32 #import "ARDWebSocketChannel.h" | 32 #import "ARDWebSocketChannel.h" | 
| 33 #import "RTCIceCandidate+JSON.h" | 33 #import "RTCIceCandidate+JSON.h" | 
| 34 #import "RTCSessionDescription+JSON.h" | 34 #import "RTCSessionDescription+JSON.h" | 
| 35 | 35 | 
| 36 static NSString * const kARDDefaultSTUNServerUrl = | 36 static NSString * const kARDIceServerRequestUrl = @"https://appr.tc/params"; | 
| 37     @"stun:stun.l.google.com:19302"; |  | 
| 38 // TODO(tkchin): figure out a better username for CEOD statistics. |  | 
| 39 static NSString * const kARDTurnRequestUrl = |  | 
| 40     @"https://computeengineondemand.appspot.com" |  | 
| 41     @"/turn?username=iapprtc&key=4080218913"; |  | 
| 42 | 37 | 
| 43 static NSString * const kARDAppClientErrorDomain = @"ARDAppClient"; | 38 static NSString * const kARDAppClientErrorDomain = @"ARDAppClient"; | 
| 44 static NSInteger const kARDAppClientErrorUnknown = -1; | 39 static NSInteger const kARDAppClientErrorUnknown = -1; | 
| 45 static NSInteger const kARDAppClientErrorRoomFull = -2; | 40 static NSInteger const kARDAppClientErrorRoomFull = -2; | 
| 46 static NSInteger const kARDAppClientErrorCreateSDP = -3; | 41 static NSInteger const kARDAppClientErrorCreateSDP = -3; | 
| 47 static NSInteger const kARDAppClientErrorSetSDP = -4; | 42 static NSInteger const kARDAppClientErrorSetSDP = -4; | 
| 48 static NSInteger const kARDAppClientErrorInvalidClient = -5; | 43 static NSInteger const kARDAppClientErrorInvalidClient = -5; | 
| 49 static NSInteger const kARDAppClientErrorInvalidRoom = -6; | 44 static NSInteger const kARDAppClientErrorInvalidRoom = -6; | 
| 50 static NSString * const kARDMediaStreamId = @"ARDAMS"; | 45 static NSString * const kARDMediaStreamId = @"ARDAMS"; | 
| 51 static NSString * const kARDAudioTrackId = @"ARDAMSa0"; | 46 static NSString * const kARDAudioTrackId = @"ARDAMSa0"; | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 126 @synthesize webSocketURL = _websocketURL; | 121 @synthesize webSocketURL = _websocketURL; | 
| 127 @synthesize webSocketRestURL = _websocketRestURL; | 122 @synthesize webSocketRestURL = _websocketRestURL; | 
| 128 @synthesize defaultPeerConnectionConstraints = | 123 @synthesize defaultPeerConnectionConstraints = | 
| 129     _defaultPeerConnectionConstraints; | 124     _defaultPeerConnectionConstraints; | 
| 130 @synthesize isLoopback = _isLoopback; | 125 @synthesize isLoopback = _isLoopback; | 
| 131 @synthesize isAudioOnly = _isAudioOnly; | 126 @synthesize isAudioOnly = _isAudioOnly; | 
| 132 @synthesize shouldMakeAecDump = _shouldMakeAecDump; | 127 @synthesize shouldMakeAecDump = _shouldMakeAecDump; | 
| 133 @synthesize shouldUseLevelControl = _shouldUseLevelControl; | 128 @synthesize shouldUseLevelControl = _shouldUseLevelControl; | 
| 134 | 129 | 
| 135 - (instancetype)init { | 130 - (instancetype)init { | 
| 136   if (self = [super init]) { | 131   return [self initWithDelegate:nil]; | 
| 137     _roomServerClient = [[ARDAppEngineClient alloc] init]; |  | 
| 138     NSURL *turnRequestURL = [NSURL URLWithString:kARDTurnRequestUrl]; |  | 
| 139     _turnClient = [[ARDCEODTURNClient alloc] initWithURL:turnRequestURL]; |  | 
| 140     [self configure]; |  | 
| 141   } |  | 
| 142   return self; |  | 
| 143 } | 132 } | 
| 144 | 133 | 
| 145 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate { | 134 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate { | 
| 146   if (self = [super init]) { | 135   if (self = [super init]) { | 
| 147     _roomServerClient = [[ARDAppEngineClient alloc] init]; | 136     _roomServerClient = [[ARDAppEngineClient alloc] init]; | 
| 148     _delegate = delegate; | 137     _delegate = delegate; | 
| 149     NSURL *turnRequestURL = [NSURL URLWithString:kARDTurnRequestUrl]; | 138     NSURL *turnRequestURL = [NSURL URLWithString:kARDIceServerRequestUrl]; | 
| 150     _turnClient = [[ARDCEODTURNClient alloc] initWithURL:turnRequestURL]; | 139     _turnClient = [[ARDTURNClient alloc] initWithURL:turnRequestURL]; | 
| 151     [self configure]; | 140     [self configure]; | 
| 152   } | 141   } | 
| 153   return self; | 142   return self; | 
| 154 } | 143 } | 
| 155 | 144 | 
| 156 // TODO(tkchin): Provide signaling channel factory interface so we can recreate | 145 // TODO(tkchin): Provide signaling channel factory interface so we can recreate | 
| 157 // channel if we need to on network failure. Also, make this the default public | 146 // channel if we need to on network failure. Also, make this the default public | 
| 158 // constructor. | 147 // constructor. | 
| 159 - (instancetype)initWithRoomServerClient:(id<ARDRoomServerClient>)rsClient | 148 - (instancetype)initWithRoomServerClient:(id<ARDRoomServerClient>)rsClient | 
| 160                         signalingChannel:(id<ARDSignalingChannel>)channel | 149                         signalingChannel:(id<ARDSignalingChannel>)channel | 
| 161                               turnClient:(id<ARDTURNClient>)turnClient | 150                               turnClient:(id<ARDTURNClient>)turnClient | 
| 162                                 delegate:(id<ARDAppClientDelegate>)delegate { | 151                                 delegate:(id<ARDAppClientDelegate>)delegate { | 
| 163   NSParameterAssert(rsClient); | 152   NSParameterAssert(rsClient); | 
| 164   NSParameterAssert(channel); | 153   NSParameterAssert(channel); | 
| 165   NSParameterAssert(turnClient); | 154   NSParameterAssert(turnClient); | 
| 166   if (self = [super init]) { | 155   if (self = [super init]) { | 
| 167     _roomServerClient = rsClient; | 156     _roomServerClient = rsClient; | 
| 168     _channel = channel; | 157     _channel = channel; | 
| 169     _turnClient = turnClient; | 158     _turnClient = turnClient; | 
| 170     _delegate = delegate; | 159     _delegate = delegate; | 
| 171     [self configure]; | 160     [self configure]; | 
| 172   } | 161   } | 
| 173   return self; | 162   return self; | 
| 174 } | 163 } | 
| 175 | 164 | 
| 176 - (void)configure { | 165 - (void)configure { | 
| 177   _factory = [[RTCPeerConnectionFactory alloc] init]; | 166   _factory = [[RTCPeerConnectionFactory alloc] init]; | 
| 178   _messageQueue = [NSMutableArray array]; | 167   _messageQueue = [NSMutableArray array]; | 
| 179   _iceServers = [NSMutableArray arrayWithObject:[self defaultSTUNServer]]; | 168   _iceServers = [NSMutableArray array]; | 
| 180   _fileLogger = [[RTCFileLogger alloc] init]; | 169   _fileLogger = [[RTCFileLogger alloc] init]; | 
| 181   [_fileLogger start]; | 170   [_fileLogger start]; | 
| 182 } | 171 } | 
| 183 | 172 | 
| 184 - (void)dealloc { | 173 - (void)dealloc { | 
| 185   self.shouldGetStats = NO; | 174   self.shouldGetStats = NO; | 
| 186   [self disconnect]; | 175   [self disconnect]; | 
| 187 } | 176 } | 
| 188 | 177 | 
| 189 - (void)setShouldGetStats:(BOOL)shouldGetStats { | 178 - (void)setShouldGetStats:(BOOL)shouldGetStats { | 
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 807   } | 796   } | 
| 808   NSString *value = _isLoopback ? @"false" : @"true"; | 797   NSString *value = _isLoopback ? @"false" : @"true"; | 
| 809   NSDictionary *optionalConstraints = @{ @"DtlsSrtpKeyAgreement" : value }; | 798   NSDictionary *optionalConstraints = @{ @"DtlsSrtpKeyAgreement" : value }; | 
| 810   RTCMediaConstraints* constraints = | 799   RTCMediaConstraints* constraints = | 
| 811       [[RTCMediaConstraints alloc] | 800       [[RTCMediaConstraints alloc] | 
| 812           initWithMandatoryConstraints:nil | 801           initWithMandatoryConstraints:nil | 
| 813                    optionalConstraints:optionalConstraints]; | 802                    optionalConstraints:optionalConstraints]; | 
| 814   return constraints; | 803   return constraints; | 
| 815 } | 804 } | 
| 816 | 805 | 
| 817 - (RTCIceServer *)defaultSTUNServer { |  | 
| 818   return [[RTCIceServer alloc] initWithURLStrings:@[kARDDefaultSTUNServerUrl] |  | 
| 819                                          username:@"" |  | 
| 820                                        credential:@""]; |  | 
| 821 } |  | 
| 822 |  | 
| 823 #pragma mark - Errors | 806 #pragma mark - Errors | 
| 824 | 807 | 
| 825 + (NSError *)errorForJoinResultType:(ARDJoinResultType)resultType { | 808 + (NSError *)errorForJoinResultType:(ARDJoinResultType)resultType { | 
| 826   NSError *error = nil; | 809   NSError *error = nil; | 
| 827   switch (resultType) { | 810   switch (resultType) { | 
| 828     case kARDJoinResultTypeSuccess: | 811     case kARDJoinResultTypeSuccess: | 
| 829       break; | 812       break; | 
| 830     case kARDJoinResultTypeUnknown: { | 813     case kARDJoinResultTypeUnknown: { | 
| 831       error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain | 814       error = [[NSError alloc] initWithDomain:kARDAppClientErrorDomain | 
| 832                                          code:kARDAppClientErrorUnknown | 815                                          code:kARDAppClientErrorUnknown | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 871                                          code:kARDAppClientErrorInvalidRoom | 854                                          code:kARDAppClientErrorInvalidRoom | 
| 872                                      userInfo:@{ | 855                                      userInfo:@{ | 
| 873         NSLocalizedDescriptionKey: @"Invalid room.", | 856         NSLocalizedDescriptionKey: @"Invalid room.", | 
| 874       }]; | 857       }]; | 
| 875       break; | 858       break; | 
| 876   } | 859   } | 
| 877   return error; | 860   return error; | 
| 878 } | 861 } | 
| 879 | 862 | 
| 880 @end | 863 @end | 
| OLD | NEW | 
|---|