2017-02-05 3 views
0

Я немного смущен тем, что нужно сделать здесь, чтобы включить webRTC в мое приложение. Я следил за этим tutorial на веб-сайте webRTC, чтобы сначала добавить webRTC в мое приложение IOS. Все прошло хорошо до конца, где я столкнулся с этими ошибками. К сожалению, я не могу найти какую-либо информацию в Интернете об этих ошибках или о том, как включить webRTC в IOS.Нет видимого @interface для 'RTCPeerConnection' объявляет селектор 'setLocalDescription:'

Конечная цель состоит в том, чтобы иметь кросс-платформенное видеовызовое обслуживание.

.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{ 

} 

любая помощь и информация, как документации или учебники очень полезны! Спасибо!

enter image description here

+0

Ваш учебник ссылки на изображение, можете ли вы его обновить –

ответ

1

Вы получаете ошибку компиляции, потому что с последней версией libjingle, PeerConnection APIs получил изменения. Настройка удаленного например описание изменено ниже апи

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

Вы можете проверить apprtc demo приложение предоставляемые Google интегрировать WebRTC APIs в вашем приложении.

+0

о, поэтому учебник, за которым я следую, является устаревшим? –

+0

Да. Это на самом деле. –

+0

ладно, спасибо! Знаете ли вы о каких-либо учебниках, которые следует соблюдать, включая последнюю версию webRTC? Как вы получили webRTC для работы с вашим проектом? –

Смежные вопросы