I'm fairly new to webrtc, and quite experienced in iOS.
We have a media server setup on AWS (all ports open), with kurento one2one client. Everything is working well when I call from desktop to desktop. when I call from desktop to iOS it works (i.e. incoming calls to iOS).
Issue is when I make an outgoing call from iOS to desktop, it doesn't work.
Below are the server logs, so I think call is getting connected...
Received message: {"id":"incomingCall","from":"qqq"}
spec: {"audio":true,"video":{"width":640,"framerate":15}}
chrome: {"audio":true,"video":{"optional":[{"minWidth":640},{"maxWidth":640},{"minFramerate":15},{"maxFramerate":15}]}}
Sending message:{"id":"incomingCallResponse","from":"qqq","callResponse":"accept","sdpOffer”:”huge text, so removed”}
Received message: {"id":"startCommunication","sdpAnswer":"huge text, so removed”}
When call is clicked I'm doing below on iOS:
[peerConnection offerForConstraints:[self defaultOfferConstraints] completionHandler:^(RTCSessionDescription * _Nullable sdp, NSError * _Nullable error) {
[peerConnection setLocalDescription:sdp completionHandler:^(NSError * _Nullable error) {
NSLog(@"%@",error.description);
}];
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
NSDictionary *registerMessage = @{
@"id": @"call",
@"from": @"qqq",
@"to": @"www",
@"sdpOffer" : sdp.description,
};
NSData *messageData = [NSJSONSerialization dataWithJSONObject:registerMessage
options:NSJSONWritingPrettyPrinted
error:nil];
NSString *messageString =
[[NSString alloc] initWithData:messageData encoding:NSUTF8StringEncoding];
[webSocket send:messageString];
}];
}];
and after I get accept response I do below,
if ([answerID isEqualToString:@"callResponse"]) {
NSString *answerRespose = [wssMessage objectForKey:@"response"];
if ([answerRespose isEqualToString:@"accepted"]) {
description = [[RTCSessionDescription alloc] initWithType:RTCSdpTypeAnswer sdp:sdpAnswer];
[peerConnection setRemoteDescription:description completionHandler:^(NSError * _Nullable error) {
}];
}
}
I'm also taking care of ICECandidates...
As incoming works without any issue, I'm assuming that no mistake was made in creating stream. Am I missing something for outgoing call?
I finally found it out. Issue was with ICECandidates, I came to know that adding ICECandidate after setting remote description works. Made an array ICECandidates collected from web socket and added them once I got remote RemoteDescription :)
I hope this helps someone in future.