CallKit:使用WebRTC时无声音 [英] CallKit:No sound when I use WebRTC

查看:1188
本文介绍了CallKit:使用WebRTC时无声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目使用WebRTC进行VOIP呼叫,并且在访问CallKit框架之前运行良好.但是当我尝试访问CallKit框架时,有一种情况,双方都听不到对方的讲话.当我删除CallKit时,一切恢复正常.

Our project uses WebRTC for VOIP calls and it works fine before accessing the CallKit framework. But when I tried to access the CallKit framework, there was a situation where neither side could hear each other's speech. When I removed CallKit, everything returned to normal.

CallKit的应答按钮与项目中的原始应答按钮具有相同的功能.

CallKit's answer button is the same function as the original answer button in the project.

令我惊讶的是,没有必要听不到声音.有时一切正常,但有时会出现问题.好吧,出现问题的可能性更大.

And what amazed me was that it was not necessary to hear no sound. Sometimes everything is normal, but sometimes there will be problems. Well, the probability of a problem is greater.

我找到了以下流程图,我怀疑问题出在函数调用的顺序上.但是我不知道WebRTC如何与图中的功能相对应.

I found the following flowchart, I suspect the problem lies in the order of function calls. But I do not know how WebRTC corresponds to the functions in the diagram.

此外,我很好奇套接字不稳定是否会导致CallKit框架异常工作

In addition, I am curious whether socket instability will cause the CallKit framework to work abnormally

请原谅我英语不好,但是这个问题困扰了我好几天,我不知道到底是哪里出了问题,是不是与CallKit框架有冲突?

Please forgive me English is not good, but this problem has been haunted me for several days, I do not know where exactly a problem, is not where the conflict with the CallKit framework?

希望您能帮助我,非常感谢!

Hope you can help me, thank you very much!

推荐答案

只需执行几步即可以正确的方式连接webrtc和callkit: 首先,您必须使用RTCAudioTrack并添加RTCAudioSession来处理音频.直接添加到RTCPeerConnection的旧式RTCAudioSession可以正常工作,但是不希望这样做. 第二件事是使用manualAudio.启动应用程序后,您应该在RTCAudioSession上更改useManualAudio标志:

Few steps need to be done to connect webrtc and callkit in proper way: First of all, you have to use the RTCAudioTrack and add the RTCAudioSession for handling the audio. Old legacy RTCAudioSession added directly into RTCPeerConnection works but it's not prefered a way to do that. Second thing is to use manualAudio. When app is booted you should change useManualAudio flag on RTCAudioSession:

RTCAudioSession.sharedSession().useManaulAudio = true

这使您可以推迟音频,直到CallKit通知已激活音频会话为止,因此在ProviderDelegate内部,您应该实现以下方法:

which gives you possibility to postpone the audio until CallKit informs that audio session was activated, so inside the ProviderDelegate you should implement following method:

(void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession
RTCAudioSession.sharedSession().didActivecated(audioSession)
RTCAudioSession.sharedSession().isAudioEnabled = true

第二种音频委托方法请不要忘记添加:

and for second audio delegate method don't forget to add:

(void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession
RTCAudioSession.sharedSession().didDeactivecated(audioSession)
RTCAudioSession.sharedSession().isAudioEnabled = false

这篇关于CallKit:使用WebRTC时无声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆