【问题标题】:DTLS Support for WebRTC iOS LibrariesWebRTC iOS 库的 DTLS 支持
【发布时间】:2014-02-20 09:52:01
【问题描述】:

我正在尝试使用来自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;
}

有人能告诉我吗?

【问题讨论】:

  • 你好,你能分享一些在原生 iOS 应用中使用 webrtc 的代码或示例/教程吗?找了4天,还是没看懂。我构建了所有库并将其集成到我的自定义项目中,但我不知道应该执行哪些步骤才能使其正常工作。我在代码示例\解释中发现的唯一内容是 tech.appear.in/2015/05/25/Getting-started-with-WebRTC-on-iOS ,但它对我来说很差而且不清楚。谢谢。

标签: ios webrtc


【解决方案1】:

这在我在创建 PeerConnection 对象时传递了 dtlsSrtpKeyAgreement 约束之后起作用,而不是在创建报价期间,即在上面的 createOfferWithDelegate 调用期间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2017-12-16
    • 1970-01-01
    • 1970-01-01
    • 2020-08-04
    相关资源
    最近更新 更多