diff options
author | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-02-10 18:47:11 +0000 |
---|---|---|
committer | fischman@webrtc.org <fischman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-02-10 18:47:11 +0000 |
commit | d1acbe9c82e0d48ee6960a78022f83f6459d083e (patch) | |
tree | 300012ff31253b8b21076d5d120cf94fd81d78e3 /examples | |
parent | 493b4d89f3be9f9686f0ce36e68f729479b11f72 (diff) | |
download | talk-d1acbe9c82e0d48ee6960a78022f83f6459d083e.tar.gz |
Add ability to receive calls for iOS
BUG=2701
R=fischman@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/7989005
Patch from Sajid Hussain <shussain@temasys.com.sg>.
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@5518 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ios/AppRTCDemo/APPRTCAppClient.h | 1 | ||||
-rw-r--r-- | examples/ios/AppRTCDemo/APPRTCAppClient.m | 2 | ||||
-rw-r--r-- | examples/ios/AppRTCDemo/APPRTCAppDelegate.m | 36 |
3 files changed, 35 insertions, 4 deletions
diff --git a/examples/ios/AppRTCDemo/APPRTCAppClient.h b/examples/ios/AppRTCDemo/APPRTCAppClient.h index c737bea..608ed05 100644 --- a/examples/ios/AppRTCDemo/APPRTCAppClient.h +++ b/examples/ios/AppRTCDemo/APPRTCAppClient.h @@ -47,6 +47,7 @@ @property(nonatomic, assign) id<ICEServerDelegate> ICEServerDelegate; @property(nonatomic, assign) id<GAEMessageHandler> messageHandler; +@property(nonatomic, assign) BOOL initiator; - (void)connectToRoom:(NSURL *)room; - (void)sendData:(NSData *)data; diff --git a/examples/ios/AppRTCDemo/APPRTCAppClient.m b/examples/ios/AppRTCDemo/APPRTCAppClient.m index d6c86d8..c01ee25 100644 --- a/examples/ios/AppRTCDemo/APPRTCAppClient.m +++ b/examples/ios/AppRTCDemo/APPRTCAppClient.m @@ -61,6 +61,7 @@ @synthesize sendQueue = _sendQueue; @synthesize token = _token; @synthesize verboseLogging = _verboseLogging; +@synthesize initiator = _initiator; - (id)init { if (self = [super init]) { @@ -272,6 +273,7 @@ [self maybeLogMessage: [NSString stringWithFormat:@"Base URL: %@", self.baseURL]]; + self.initiator = [[self findVar:@"initiator" strippingQuotes:NO] boolValue]; self.token = [self findVar:@"channelToken" strippingQuotes:YES]; if (!self.token) return; diff --git a/examples/ios/AppRTCDemo/APPRTCAppDelegate.m b/examples/ios/AppRTCDemo/APPRTCAppDelegate.m index 65cdd09..9b8c96d 100644 --- a/examples/ios/AppRTCDemo/APPRTCAppDelegate.m +++ b/examples/ios/AppRTCDemo/APPRTCAppDelegate.m @@ -229,6 +229,10 @@ #pragma mark - GAEMessageHandler methods - (void)onOpen { + if (!self.client.initiator) { + [self displayLogMessage:@"Callee; waiting for remote offer"]; + return; + } [self displayLogMessage:@"GAE onOpen - create offer."]; RTCPair *audio = [[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"]; @@ -400,10 +404,34 @@ [self displayLogMessage:@"SDP onSuccess() - possibly drain candidates"]; dispatch_async(dispatch_get_main_queue(), ^(void) { - // TODO(hughv): Handle non-initiator case. http://s10/46622051 - if (self.peerConnection.remoteDescription) { - [self displayLogMessage:@"SDP onSuccess - drain candidates"]; - [self drainRemoteCandidates]; + if (!self.client.initiator) { + if (self.peerConnection.remoteDescription + && !self.peerConnection.localDescription) { + [self displayLogMessage:@"Callee, setRemoteDescription succeeded"]; + RTCPair *audio = + [[RTCPair alloc] + initWithKey:@"OfferToReceiveAudio" value:@"true"]; + // TODO(hughv): Add video. + // RTCPair *video = + // [[RTCPair alloc] + // initWithKey:@"OfferToReceiveVideo" value:@"true"]; + NSArray *mandatory = @[ audio /*, video*/ ]; + RTCMediaConstraints *constraints = + [[RTCMediaConstraints alloc] + initWithMandatoryConstraints:mandatory + optionalConstraints:nil]; + [self.peerConnection + createAnswerWithDelegate:self constraints:constraints]; + [self displayLogMessage:@"PC - createAnswer."]; + } else { + [self displayLogMessage:@"SDP onSuccess - drain candidates"]; + [self drainRemoteCandidates]; + } + } else { + if (self.peerConnection.remoteDescription) { + [self displayLogMessage:@"SDP onSuccess - drain candidates"]; + [self drainRemoteCandidates]; + } } }); } |