PJSip在IOS上,麦克风音量非常低

4
我们创建了一个VOIP软电话,将呼叫者连接到会议桥。会议桥提示,普通电话上的呼叫者可以很好地被听到,但是软电话的输入声音非常微弱。
我们使用PJSip、AVAudioSession、Objective C和IOS 10.2。
我们尝试使用AVAudioSession设置输入增益,但增益不能被设置。
有没有人有什么想法? 谢谢

这个问题也发生在我的应用程序上,iOS 9.3.5上也是如此。我已经发布了一个问题http://stackoverflow.com/questions/42681265/ios-mic-captured-voice-change-volume-reprocess-on-the-fly,也许有人可以给我们指出正确的方向,如何在运行时放大捕获的数据。 - Hashmat Khalil
你可以尝试这个链接:https://dev59.com/fWTWa4cB1Zd3GeqPEY2y - alinoz
1个回答

1

您需要在此处结合3个特定于iOS的功能。

1.音频会话类别

根据文档和代码,我列出了它们如下:

/*  Use this category for background sounds such as rain, car engine noise, etc.  
 Mixes with other music. */
public let AVAudioSessionCategoryAmbient: String

/*  Use this category for background sounds.  Other music will stop playing. */
public let AVAudioSessionCategorySoloAmbient: String

/* Use this category for music tracks.*/
public let AVAudioSessionCategoryPlayback: String

/*  Use this category when recording audio. */
public let AVAudioSessionCategoryRecord: String

/*  Use this category when recording and playing back audio. */
public let AVAudioSessionCategoryPlayAndRecord: String

/*  Use this category when using a hardware codec or signal processor while
 not playing or recording audio. */
@available(iOS, introduced: 3.0, deprecated: 10.0)
public let AVAudioSessionCategoryAudioProcessing: String

/*  Use this category to customize the usage of available audio accessories and built-in audio hardware.
 For example, this category provides an application with the ability to use an available USB output 
 and headphone output simultaneously for separate, distinct streams of audio data. Use of 
 this category by an application requires a more detailed knowledge of, and interaction with, 
 the capabilities of the available audio routes.  May be used for input, output, or both.
 Note that not all output types and output combinations are eligible for multi-route.  Input is limited
 to the last-in input port. Eligible inputs consist of the following:
    AVAudioSessionPortUSBAudio, AVAudioSessionPortHeadsetMic, and AVAudioSessionPortBuiltInMic.  
 Eligible outputs consist of the following: 
    AVAudioSessionPortUSBAudio, AVAudioSessionPortLineOut, AVAudioSessionPortHeadphones, AVAudioSessionPortHDMI, 
    and AVAudioSessionPortBuiltInSpeaker.  
 Note that AVAudioSessionPortBuiltInSpeaker is only allowed to be used when there are no other eligible 
 outputs connected.  */
@available(iOS 6.0, *)
public let AVAudioSessionCategoryMultiRoute: String

针对您的使用情况,我会选择 AVAudioSessionCategoryPlayAndRecord 并设置使用。

对于 Swift:

AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)

对于 Obj-c

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&err]

2.音频会话模式

这些模式有助于自动设置适当的增益、回声消除和其他音频处理功能。

/* The default mode */
/*!
@abstract      Modes modify the audio category in order to introduce behavior that is tailored to the specific
use of audio within an application.  Available in iOS 5.0 and greater.
 */
@available(iOS 5.0, *)
public let AVAudioSessionModeDefault: String

/* Only valid with AVAudioSessionCategoryPlayAndRecord.  Appropriate for Voice over IP
(VoIP) applications.  Reduces the number of allowable audio routes to be only those
that are appropriate for VoIP applications and may engage appropriate system-supplied
signal processing.  Has the side effect of setting AVAudioSessionCategoryOptionAllowBluetooth */
@available(iOS 5.0, *)
public let AVAudioSessionModeVoiceChat: String

/* Set by Game Kit on behalf of an application that uses a GKVoiceChat object; valid
 only with the AVAudioSessionCategoryPlayAndRecord category.
 Do not set this mode directly. If you need similar behavior and are not using
 a GKVoiceChat object, use AVAudioSessionModeVoiceChat instead. */
@available(iOS 5.0, *)
public let AVAudioSessionModeGameChat: String

/* Only valid with AVAudioSessionCategoryPlayAndRecord or AVAudioSessionCategoryRecord.
 Modifies the audio routing options and may engage appropriate system-supplied signal processing. */
@available(iOS 5.0, *)
public let AVAudioSessionModeVideoRecording: String

/* Appropriate for applications that wish to minimize the effect of system-supplied signal
processing for input and/or output audio signals. */
@available(iOS 5.0, *)
public let AVAudioSessionModeMeasurement: String

/* Engages appropriate output signal processing for movie playback scenarios.  Currently
only applied during playback over built-in speaker. */
@available(iOS 6.0, *)
public let AVAudioSessionModeMoviePlayback: String

/* Only valid with kAudioSessionCategory_PlayAndRecord. Reduces the number of allowable audio
routes to be only those that are appropriate for video chat applications. May engage appropriate
system-supplied signal processing.  Has the side effect of setting
AVAudioSessionCategoryOptionAllowBluetooth and AVAudioSessionCategoryOptionDefaultToSpeaker. */
@available(iOS 7.0, *)
public let AVAudioSessionModeVideoChat: String

/* Appropriate for applications which play spoken audio and wish to be paused (via audio session interruption) rather than ducked
if another app (such as a navigation app) plays a spoken audio prompt.  Examples of apps that would use this are podcast players and
audio books.  For more information, see the related category option AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers. */
@available(iOS 9.0, *)
public let AVAudioSessionModeSpokenAudio: String

我会为您的情况选择AVAudioSessionModeVideoChat并在Swift中进行设置。
AVAudioSession.sharedInstance().setMode(AVAudioSessionModeVideoChat)

Obj-c

[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVideoChat error:&err]

3. 音频路由

默认情况下,对于大多数模式/类别,音频会路由到听筒/接收器。如果您想使用扬声器模式,则必须手动设置相同内容。

Swift

AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker)

Obj-c

[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];

这些设置不会改变输入音量,我已经尝试过了。你有其他的建议吗? - Hashmat Khalil

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接