如果广播应用程序(Android)和客户端应用程序(IOS 和 Android)连接到同一网络中的 wifi,则一切正常。但是当广播者应用程序连接到移动数据连接时,客户端应用程序(IOS)显示黑屏,但 Android 仍然可以正常工作。我已经搜索了一些解决方法,他们建议在我的 peerConnection 中添加 STUN 和 TURN,但我之前已经添加了。在不同的网络连接上建立通信时似乎不起作用。这就是我设置 RTCPeerConnection 的方式。
var rtcIceServers: [RTCIceServer] = []
rtcIceServers.append(RTCIceServer(urlStrings: [turnUrl], username:"*****",credential: "*********"))
rtcIceServers.append(RTCIceServer(urlStrings: [stunUrl]))
let rtcConf = RTCConfiguration()
rtcConf.iceServers = rtcIceServers
rtcConf.tcpCandidatePolicy = .disabled
rtcConf.bundlePolicy = RTCBundlePolicy.maxBundle
rtcConf.rtcpMuxPolicy = RTCRtcpMuxPolicy.require
rtcConf.continualGatheringPolicy = RTCContinualGatheringPolicy.gatherContinually
rtcConf.keyType = .ECDSA
let mediaConstraints = RTCMediaConstraints.init(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
let pc = self.peerConnectionFactory.peerConnection(with: rtcConf, constraints: mediaConstraints, delegate: self)
客户端应用程序只需要接收视频轨道,强制约束中不添加音频。谢谢