我正在尝试使用http://webrtc.googlecode.com/svn/trunk/中编译的WebRTC iOS库创建iOS应用程序,目前我的后端服务器仅支持DTLS。
现在,当我尝试设置远程描述时,它返回以下错误
Warning(webrtcsession.cc:146): Session description must have SDES when DTLS disabled.
Error(webrtcsession.cc:268): SetRemoteDescription failed: Called with an SDP without SDES crypto and DTLS disabled locally.
但我在创建对等连接时将DtlsSrtpKeyAgreement = true设置为可选约束,如下所示
RTCPair *audio = [[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"];
RTCPair *video = [[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"false"];
NSArray *mandatoryConstraints = @[ audio, video ];
RTCPair *dtlsSrtpKeyAgreement = [[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"];
NSArray *optionalConstraints = @[ dtlsSrtpKeyAgreement ];
RTCMediaConstraints *mediaConstraints = [[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatoryConstraints
optionalConstraints:optionalConstraints];
[self.peerConnection createOfferWithDelegate:self constraints:mediaConstraints];
我只是想知道WebRTC原生iOS库目前是否仅支持SDES而不支持DTLS?
由于http://webrtc.googlecode.com/svn/trunk/talk/app/webrtc/objc/RTCPeerConnectionFactory.mm
中的以下部分代码,我对此表示怀疑(RTCPeerConnection *)
peerConnectionWithICEServers:(NSArray *)servers
constraints:(RTCMediaConstraints *)constraints
delegate:(id<RTCPeerConnectionDelegate>)delegate {
webrtc::PeerConnectionInterface::IceServers iceServers;
for (RTCICEServer *server in servers) {
iceServers.push_back(server.iceServer);
}
webrtc::RTCPeerConnectionObserver *observer =
new webrtc::RTCPeerConnectionObserver(delegate);
webrtc::DTLSIdentityServiceInterface* dummy_dtls_identity_service = NULL;
talk_base::scoped_refptr<webrtc::PeerConnectionInterface> peerConnection =
self.nativeFactory->CreatePeerConnection(
iceServers, constraints.constraints, dummy_dtls_identity_service,
observer);
RTCPeerConnection *pc =
[[RTCPeerConnection alloc] initWithPeerConnection:peerConnection
observer:observer];
observer->SetPeerConnection(pc);
return pc;
}
有人可以启发我吗?
答案 0 :(得分:3)
在我创建PeerConnection对象时传递dtlsSrtpKeyAgreement约束,而不是在创建提议期间,即在createOfferWithDelegate调用期间,如上所述。