iOS Audio not working during call answered when phone is locked. WebRTC used for calling

孤人 提交于 2019-12-13 14:14:47

问题


I am facing a problem with Audio When using Callkit with WebRTC for VOIP call, While answering the call from Lock Screen.

General Functionality :

My app activates the audioSession when it's launched. For an incoming call, SDP Offer & Answer are generated and exchanged. Peer Connection is set up. Both audio and video streams are generated, whether it's audio call or video call. Then Call is reported to callkit by using the following code:

    callProvider.reportNewIncomingCall(with: currentCallUUID!, update: update) { error in }

If app is in the foreground, it works fine.

But, when the phone is locked, and user answers the call from lock screen, the Streams are exchanged but no audio comes on either end until user enters into the app himself.

As the user enters into the App, audio becomes active on both the ends.

All the background settings and capabilities are set properly.

I have also referred to the following work around provided by Apple staff. But even it does not work.

https://forums.developer.apple.com/thread/64544

As I mentioned, I am using WebRTC for calling. If I exchange the media streams after the user answers the call( still on Lock Screen) and peer connection is set at that time. It works fine (But it adds the delay in making the call connection).

But if Peer Connection is made before displaying call (say before reporting call to callkit), the audio stops working.


回答1:


I am able to resolve this issue.

Steps that I followed -

  • I checked the code related to WebRTC here

  • I added RTCAudioSession header file which is actually a private class of Webrtc. So every time I receive a call event from signaling, I enable RTCAudiosession and on end of the call, I disable it.

  • I have to render the incoming streams to a dummy view (Although it is not displayed when the call is going and the app is not yet open, but it is required to make audio working).

I hope this will help if someone is facing the same issue.




回答2:


@abhimanyu are you still facing the issue or you made it work. I am facing same issue with CallKit.

As per my understanding in WebRTC M60 release they have fixed on issue related to CallKit, which I think created a side effect and caused this issue.

The issue which they have fixed is related to System AudioSession, when ever CallKit presents incoming call UI and play ringer tone CallKit takes control of AudioSession and after user action (accept/ decline) it releases control. In WebRTC M60 release, now they have added observers for this control exchange. That's why it is working if app is in foreground, but if phone is locked and any incoming call is accepted then (I am assuming you are using CallKit UI for call and not redirecting user to App on accept from lock screen) due to Native UI of call it is not possible for WebRTC to activate its own AudioSession instance as call is going through CallKit Screen.

Link for bug which has been fixed on WebRTC M60: https://bugs.chromium.org/p/webrtc/issues/detail?id=7446

If you found any workaround for this issue please let me know.



来源:https://stackoverflow.com/questions/45366289/ios-audio-not-working-during-call-answered-when-phone-is-locked-webrtc-used-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!