I'm a little confused on what needs to be done here to include webRTC into my app. I followed this tutorial on the webRTC website to add webRTC onto my IOS app first. Everything went well until the end where i came across these errors. Unfortunately, I can not find any information online about these errors or how to include webRTC on IOS.
The end goal is to have a cross-platform video calling service.
.h
#import "RTCPeerConnectionDelegate.h"
#import "RTCSessionDescriptionDelegate.h"
...
<RTCPeerConnectionDelegate, RTCSessionDescriptionDelegate>
.m
#import "RTCICEServer.h"
#import "RTCPeerConnectionFactory.h"
#import "RTCMediaStream.h"
#import "RTCVideoCapturer.h"
#import "RTCPeerConnection.h"
#import "RTCAudioSource.h"
#import "RTCAudioTrack.h"
#import "RTCMediaConstraints.h"
#import "RTCSessionDescription.h"
#import "RTCPair.h"
#import "RTCEAGLVideoView.h"
#import "RTCICECandidate.h"
//The code below is for the webRTC
RTCICEServer *iceServer;
RTCMediaConstraints *constraints;
RTCPeerConnection *peerConnectionRTC;
- (void) setUpVideoCall{
//Set up for my TURN and STUN servers
iceServer = [[RTCICEServer alloc] initWithURI:[NSURL URLWithString:@""]
username:@""
password:@""];
NSMutableArray *iceServers = [[NSMutableArray alloc] init];
[iceServers addObject: iceServer];
//Creating the RTCPeerConnection
// Enable SSL globally for WebRTC in our app
[RTCPeerConnectionFactory initializeSSL];
RTCPeerConnectionFactory *pcFactory = [[RTCPeerConnectionFactory alloc] init];
// Create the peer connection using the ICE server list and the current class as the delegate
peerConnectionRTC = [pcFactory peerConnectionWithICEServers: iceServers
constraints:nil delegate:self];
//Use this code when the call is ended or the app closes
//[RTCPeerConnectionFactory deinitializeSSL];
RTCMediaStream *localStream = [pcFactory mediaStreamWithLabel:@"uniqueStreamLabel"];
RTCAudioTrack *audioTrack = [pcFactory audioTrackWithID:@"audio0"];
[localStream addAudioTrack:audioTrack];
// Find the device that is the front facing camera
AVCaptureDevice *device;
for (AVCaptureDevice *captureDevice in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] ) {
if (captureDevice.position == AVCaptureDevicePositionFront) {
device = captureDevice;
break;
}
}
// Create a video track and add it to the media stream
if (device) {
RTCVideoSource *videoSource;
RTCVideoCapturer *capturer = [RTCVideoCapturer capturerWithDeviceName:device.localizedName];
videoSource = [pcFactory videoSourceWithCapturer:capturer constraints:nil];
RTCVideoTrack *videoTrack = [pcFactory videoTrackWithID: @"videoId" source:videoSource];
[localStream addVideoTrack:videoTrack];
}
[peerConnectionRTC addStream:localStream];
constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:
@[
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"],
[[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]
]
optionalConstraints: nil];
//[peerConnectionRTC createOfferWithConstraints:constraints];
}
//The two delaget methods below are for the RTCSessionDescriptionDelegate
- (void)peerConnection:(RTCPeerConnection *)peerConnection didCreateSessionDescription:(RTCSessionDescription *)sdp error:(NSError *)error;{
[peerConnection setLocalDescription:sdp];
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didSetSessionDescriptionWithError:(NSError *)error;{
if (peerConnection.signalingState == RTCSignalingHaveLocalOffer) {
RTCSessionDescription *remoteDesc = [[RTCSessionDescription alloc] initWithType:@"offer" sdp: @"sdp"];
[peerConnection setRemoteDescription:remoteDesc];
}
// If we have a local offer we should signal it
if (peerConnection.signalingState == RTCSignalingHaveLocalOffer) {
RTCSessionDescription *remoteDesc = [[RTCSessionDescription alloc] initWithType:@"answer" sdp:sdp];
[peerConnection setRemoteDescription:remoteDesc];
} else if (peerConnection.signalingState == RTCSignalingHaveRemoteOffer) {
// If we have a remote offer we should add it to the peer connection
[peerConnection createAnswerWithConstraints:constraints];
}
// If we have a local offer OR answer we should signal it
if ((peerConnection.signalingState == RTCSignalingHaveLocalOffer) | RTCSignalingHaveLocalPrAnswer ) {
// Send offer/answer through the signaling channel of our application
} else if (peerConnection.signalingState == RTCSignalingHaveRemoteOffer) {
// If we have a remote offer we should add it to the peer connection
[peerConnection createAnswerWithConstraints:constraints];
}
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection
gotICECandidate:(RTCICECandidate *)candidate
{
RTCICECandidate *candidate = [[RTCICECandidate alloc] initWithMid:SDP_MID
index:SDP_M_LINE_INDEX
sdp:SDP_CANDIDATE];
[self.rtcPeerConnection addICECandidate:candidate];
}
RTCEAGLVideoView *renderView;
- (void)peerConnection:(RTCPeerConnection *)peerConnection addedStream:(RTCMediaStream *)stream
{
// Create a new render view with a size of your choice
renderView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
[stream.videoTracks.lastObject addRenderer:self.renderView];
// RTCEAGLVideoView is a subclass of UIView, so renderView
// can be inserted into your view hierarchy where it suits your application.
}
//More RTC delagate methods below that i need
- (void)peerConnection:(RTCPeerConnection *)peerConnection iceConnectionChanged:(RTCICEConnectionState)newState{
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection iceGatheringChanged:(RTCICEGatheringState)newState{
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection removedStream:(RTCMediaStream *)stream{
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection signalingStateChanged:(RTCSignalingState)stateChanged{
}
- (void)peerConnection:(RTCPeerConnection *)peerConnection didOpenDataChannel:(RTCDataChannel *)dataChannel{
}
- (void)peerConnectionOnRenegotiationNeeded:(RTCPeerConnection *)peerConnection{
}
Any help is appreciated and information like documentation or tutorials are very helpful! Thank you!