1

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!

enter image description here

Lazar Kukolj
  • 696
  • 3
  • 15
  • 43

1 Answers1

1

You are getting compilation error because with latest libjingle version, peerconnection apis got change. e.g Setting remote description changed to below api

    [peerconnection setRemoteDescriptionWithDelegate:<#(id<RTCSessionDescriptionDelegate>)#> sessionDescription:<#(RTCSessionDescription *)#>]

You can check apprtc demo app provided by google to integrate webrtc apis in your app.

Harish Gupta
  • 782
  • 4
  • 12
  • oh, so the tutorial I am following is super out dated? – Lazar Kukolj Feb 06 '17 at 00:25
  • Yes. It is actually. – Harish Gupta Feb 06 '17 at 00:26
  • okay, thanks! Do you know of any tutorials to follow that includes the latest version of webRTC? How did you get webRTC to work with your project? – Lazar Kukolj Feb 06 '17 at 02:26
  • Wait how can my tutorial be old when [this](http://stackoverflow.com/questions/35826464/webrtc-ios-freeswitch-cant-hear-audio/35881785#35881785) question references the same tutorial as mine and the question is only 11 months old? – Lazar Kukolj Feb 06 '17 at 02:56
  • Normally, libjingle APIs also gets updated(sometime) with every chrome releases. Chrome releases normally happen after every month or two. These APIs changes happened in chrome 54 i guess which release Oct 2016. You can build the static lib/framework for webrtc by your own and can link that in your project if you dont want to use the pod. You can check https://webrtc.org/native-code/ios/ here for build steps. This also create a sample apprtc demo(Already provided in my answer) app which you can refer for your integration. – Harish Gupta Feb 06 '17 at 03:07
  • okay, this helped! but I'm still stuck on how to create a cross-platform video calling serves. You reference this website but I don't know how/where to start. – Lazar Kukolj Feb 06 '17 at 04:04
  • @LazarKukolj 11 months is a lot for a library that's only been out for a little over 5 years. The library is constantly being updated, the latest major revision came out 3 hours ago, the one before that december 12th. In between these major revision are usually about 1000-2000 commits. – Kevin Feb 14 '17 at 12:38