我已使用以下参考在iOS应用中实现了WebRTC: AppRTC reference code by Google for iOS
我已经成功实现了语音/视频聊天,并使用以下网址进行了检查:https://appr.tc/
上面的URL仅用于演示目的,因为连接将持续长达一分钟。
因此,我的后端团队决定创建自己的STUN和TURN服务器。
我们根据以下链接生成了自己的STUN&TURN服务器,并将其安装在我们的服务器上: STUN & TURN server reference
在这里,我们在生成对等连接对象时发现了一个新问题,当在配置中添加到我们的STUN和TURN服务器时,它会生成一个nil对象。
请从以下位置找到我的代码段:
// Create peer connection.
NSString *value = _isLoopback ? @"false" : @"true";
NSDictionary *optionalConstraints = @{ @"DtlsSrtpKeyAgreement" : value };
RTCMediaConstraints *constraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:nil
optionalConstraints:optionalConstraints];
RTCConfiguration *config = [[RTCConfiguration alloc] init];
RTCCertificate *pcert = [RTCCertificate generateCertificateWithParams:@{
@"expires" : @100000,
@"name" : @"RSASSA-PKCS1-v1_5"
}];
config.iceServers = _iceServers; // OWN STUN & STUN servers
config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
config.certificate = pcert;
config.bundlePolicy = RTCBundlePolicyMaxBundle; // For checking purpose
config.iceTransportPolicy = RTCIceTransportPolicyAll; // Default value
_peerConnection = [_factory peerConnectionWithConfiguration:config
constraints:constraints
delegate:self];
观察:
注意: