我正在创建一个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