使用CallKit将GSM呼叫切换到VOIP呼叫会导致声音丢失

时间:2017-01-17 11:08:11

标签: ios voip callkit

我在我的VoIP应用程序中实现了CallKit,除了一种情况外,一切都很好:

当VoIP呼叫中断电话呼叫并且用户选择“结束并接听”时,电话呼叫结束,VoIP呼叫被应答,但几秒钟后声音丢失。

当电话被置于保持状态或VoIP呼叫中断另一个VoIP呼叫时(即使是来自另一个VoIP应用程序),也不会发生此行为

要恢复暂停和恢复通话所需的声音。

是否有人重现此问题或有想法?

提前致谢!

1 个答案:

答案 0 :(得分:0)

当您接听电话时..检查音频会话是否已激活,之后您需要激活您的呼叫媒体状态。

- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {

   NSLog(@"Provider perform Answer Call Action");

   // Retrieve the instance corresponding to the action's call UUID
   SIPCall *call = [_callManager callWithUUID:action.callUUID];
   if (!call) {
       [action fail];
       return;
   }

   /*
   Configure the audio session, but do not start call audio here, since it must be done once
   the audio session has been activated by the system after having its priority elevated.
   */
   [[AudioManager sharedManager] configureAudioSession];

   // Trigger the call to be answered via the underlying network service.
   [call answer];

   // Signal to the system that the action has been successfully performed.
   [action fulfill];
}

同时检查结束通话方法。

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
   NSLog(@"Provider perform End Call Action");
   // Retrieve the Voifinity PBX instance corresponding to the action's call UUID
   SIPCall *call = [_callManager callWithUUID:action.callUUID];
   if (!call) {
      [action fail];
      return;
   }

   // Stop call audio whenever ending the call.
   //[[AudioManager sharedManager] disableSoundDevices];

   // Trigger the call to be ended via the underlying network service.
   [call hangUp];

   // Signal to the system that the action has been successfully performed.
   [action fulfill];

   // Remove the ended call from the app's list of calls.
   [_callManager removeCall:call];

}

还可以添加以检查音频会话是否激活或取消激活。 您应该仅激活音频,并且仅在激活音频会话后激活音频。 添加以下代表以跟踪音频会话。

//激活会话

- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession {
   NSLog(@"Received: %s",__FUNCTION__);
}

//停用会话

- (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession {
NSLog(@"Received: %s",__FUNCTION__);
}