webrtc对等连接不提供远程视频跟踪

时间:2016-09-26 15:19:34

标签: ios objective-c video-streaming webrtc

背景

我正在创建一个iOS应用,可以使用webrtc在iOS客户端和网络浏览器之间进行视频聊天(我使用的是this library for iOS)

问题

Given我在本地家庭网络中测试连接
已建立When rtc连接 Then我无法渲染远程视频

分析

对于RTCPeerConnection,有以下constraints

[[RTCMediaConstraints alloc]
            initWithMandatoryConstraints:nil
            optionalConstraints:@{@"DtlsSrtpKeyAgreement": @"true"}];

以及以下配置:

RTCConfiguration *config = [[RTCConfiguration alloc] init];
    config.iceServers = @[[self STUNServer]];

然后我添加本地流:

- (RTCMediaStream *)createLocalMediaStreamWithVideoTrack:(RTCVideoTrack *__autoreleasing *)videoTrack {
    RTCMediaStream* localStream = [self.factory mediaStreamWithStreamId:@"ARDAMS"];

    RTCVideoTrack *localVideoTrack = [self createLocalVideoTrack];
    if (localVideoTrack) {
        [localStream addVideoTrack:localVideoTrack];
    }
    if (videoTrack) {
        (*videoTrack) = localVideoTrack;
    }

    [localStream addAudioTrack:[self.factory audioTrackWithTrackId:@"ARDAMSa0"]];
    return localStream;
}
- (RTCVideoTrack *)createLocalVideoTrack {
    RTCVideoTrack *localVideoTrack = nil;
#if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE
    RTCMediaConstraints *mediaConstraints = [HAHRTCDefaults mediaStreamConstraints];
    RTCVideoSource *videoSource = [self.factory avFoundationVideoSourceWithConstraints:mediaConstraints];
    localVideoTrack = [self.factory videoTrackWithSource:videoSource trackId:@"ARDAMSv0"];
#endif
    return localVideoTrack;
}

一旦谈判需要我创建一个具有以下约束条件的商品:

NSDictionary *mandatoryConstraints = @{@"OfferToReceiveAudio": @"true",
                                       @"OfferToReceiveVideo": @"true"};
RTCMediaConstraints* constraints =
    [[RTCMediaConstraints alloc]
        initWithMandatoryConstraints:mandatoryConstraints
        optionalConstraints:nil];

Here是本地会话描述:

Here是本地冰雪候选人:

Here是远程会话描述

这是Remote的候选人:

audio
0
candidate:0 1 UDP 2122252543 192.168.0.100 57752 typ host

audio
0
candidate:1 1 UDP 1686052863 212.90.61.183 57752 typ srflx raddr 192.168.0.100 rport 57752

0 个答案:

没有答案
相关问题