iOS - 仅使用 Opus 编解码器的 WebRTC 单向音频
iOS - WebRTC one way audio only with Opus Codec
我有一个使用 GoogleWebRTC pod 的 swift 项目。
在尝试为音频呼叫协商 OPUS 编解码器时,我发现对等连接已成功设置,但我遇到的是单向音频。 SRTP 正在从我的 iPhone 成功发送到另一方,并且 SRTP 正在从另一方发送到我的 iPhone,但是我的 phone/app 没有向用户播放传入的 SRTP .
如果我协商任何其他编解码器(例如 G722)然后我得到 2 路音频,就在我尝试协商 OPUS 时我在 iPhone.
上听不到任何传入音频
在日志中看不到任何相关内容,但正在寻找有关如何解决此问题或可能导致此问题的原因的一些指示。
我正在使用 google WebRTC iOS SDK。
这是我的 webrtc class 中的代码,如果有帮助,我会在其中初始化音频会话。
private func configureAudioSession() {
self.rtcAudioSession.lockForConfiguration()
do {
try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue)
try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
} catch let error {
debugPrint("Error changeing AVAudioSession category: \(error)")
}
self.rtcAudioSession.unlockForConfiguration()
}
对于偶然发现此问题的任何其他人,我没有在 callprovider 协议的 didActivate 方法中使用 callkit 提供的音频会话。
这是我修改后的 configureAudioSession
private func configureAudioSession() {
self.rtcAudioSession.lockForConfiguration()
do {
self.rtcAudioSession.useManualAudio = true
self.rtcAudioSession.isAudioEnabled = false
try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue)
try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
} catch let error {
debugPrint("Error changeing AVAudioSession category: \(error)")
}
self.rtcAudioSession.unlockForConfiguration()
}
然后在我的提供商委托中
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
print("Received \(#function)")
webRTCClient.rtcAudioSession.audioSessionDidActivate(audioSession)
webRTCClient.rtcAudioSession.isAudioEnabled = true
// Start call audio media, now that the audio session has been activated after having its priority boosted.
// startAudio()
}
我有一个使用 GoogleWebRTC pod 的 swift 项目。
在尝试为音频呼叫协商 OPUS 编解码器时,我发现对等连接已成功设置,但我遇到的是单向音频。 SRTP 正在从我的 iPhone 成功发送到另一方,并且 SRTP 正在从另一方发送到我的 iPhone,但是我的 phone/app 没有向用户播放传入的 SRTP . 如果我协商任何其他编解码器(例如 G722)然后我得到 2 路音频,就在我尝试协商 OPUS 时我在 iPhone.
上听不到任何传入音频在日志中看不到任何相关内容,但正在寻找有关如何解决此问题或可能导致此问题的原因的一些指示。
我正在使用 google WebRTC iOS SDK。
这是我的 webrtc class 中的代码,如果有帮助,我会在其中初始化音频会话。
private func configureAudioSession() {
self.rtcAudioSession.lockForConfiguration()
do {
try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue)
try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
} catch let error {
debugPrint("Error changeing AVAudioSession category: \(error)")
}
self.rtcAudioSession.unlockForConfiguration()
}
对于偶然发现此问题的任何其他人,我没有在 callprovider 协议的 didActivate 方法中使用 callkit 提供的音频会话。
这是我修改后的 configureAudioSession
private func configureAudioSession() {
self.rtcAudioSession.lockForConfiguration()
do {
self.rtcAudioSession.useManualAudio = true
self.rtcAudioSession.isAudioEnabled = false
try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue)
try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
} catch let error {
debugPrint("Error changeing AVAudioSession category: \(error)")
}
self.rtcAudioSession.unlockForConfiguration()
}
然后在我的提供商委托中
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
print("Received \(#function)")
webRTCClient.rtcAudioSession.audioSessionDidActivate(audioSession)
webRTCClient.rtcAudioSession.isAudioEnabled = true
// Start call audio media, now that the audio session has been activated after having its priority boosted.
// startAudio()
}