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@5518 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m b/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
index 65cdd09..9b8c96d 100644
--- a/talk/examples/ios/AppRTCDemo/APPRTCAppDelegate.m
+++ b/talk/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];
+ }
}
});
}