手机锁定时,在接听电话时,iOS音频无法正常工作.用于呼叫的WebRTC [英] iOS Audio not working during call answered when phone is locked. WebRTC used for calling

查看:186
本文介绍了手机锁定时,在接听电话时,iOS音频无法正常工作.用于呼叫的WebRTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将Callkit与WebRTC一起用于VOIP通话时,在从锁定屏幕接听电话时,我遇到音频问题.

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

常规功能:

我的应用在启动时会激活audioSession.对于来电,SDP Offer&生成并交换答案.对等连接已建立.无论是音频通话还是视频通话,都会生成音频和视频流.然后使用以下代码将呼叫报告给callkit:

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.

我还提到了Apple员工提供的以下解决方法.但是,即使它也不起作用.

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

正如我提到的,我正在使用WebRTC进行呼叫.如果我在用户接听电话后仍在锁定屏幕上交换媒体流,并且此时已建立对等连接.它可以正常工作(但会增加建立呼叫连接的延迟).

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).

但是,如果在显示呼叫之前建立了对等连接(例如,在向Callkit报告呼叫之前),则音频将停止工作.

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

推荐答案

我能够解决此问题.

我遵循的步骤-

  • 我检查了与WebRTC相关的代码此处

我添加了RTCAudioSession头文件,该头文件实际上是Webrtc的私有类.因此,每次我收到来自信令的呼叫事件时,都会启用RTCAudiosession,并在呼叫结束时将其禁用.

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.

这篇关于手机锁定时,在接听电话时,iOS音频无法正常工作.用于呼叫的WebRTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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