我们创建了一个 VOIP 软电话,可将调用者连接到 session 桥。 session 桥提示,普通电话的调用者可以听到,但软电话的输入几乎听不见。
我们正在使用 PJSip、AVAudioSession、Objective C 和 IOS 10.2
我们尝试使用 AVAudioSession 设置输入增益,但增益不可设置。
有人有什么想法吗? 谢谢
最佳答案
您需要在这里混合 3 个 iOS 特定功能。
根据 documentation和代码,我在下面列出它们:
/* 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]
这些模式有助于自动设置适当的增益、回声消除和其他音频处理功能。
/* 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)
objective-c
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVideoChat error:&err]
默认情况下,对于大多数模式/类别,音频被路由到听筒/接收器。如果您正在查看扬声器模式,则必须使用
swift
AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker)
objective-c
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
关于ios - 带 IOS 的 PJSip,麦克风音量非常低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42683958/
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
Rails相对较新。我正在尝试调用一个API,它应该向我返回一个唯一的URL。我的应用程序中捆绑了HTTParty。我已经创建了一个UniqueNumberController,并且我已经阅读了几个HTTParty指南,直到我想要什么,但也许我只是有点迷路,真的不知道该怎么做。基本上,我需要做的就是调用API,获取它返回的URL,然后将该URL插入到用户的数据库中。谁能给我指出正确的方向或与我分享一些代码? 最佳答案 假设API为JSON格式并返回如下数据:{"url":"http://example.com/unique-url"
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
我想在ruby中生成一个64位整数。我知道在Java中你有很多渴望,但我不确定你会如何在Ruby中做到这一点。另外,64位数字中有多少个字符?这是我正在谈论的示例......123456789999。@num=Random.rand(9000)+Random.rand(9000)+Random.rand(9000)但我认为这是非常低效的,必须有一种更简单、更简洁的方法来做到这一点。谢谢! 最佳答案 rand可以将范围作为参数:pa=rand(2**32..2**64-1)#=>11093913376345012184putsa.
我刚刚在我的Ubuntu9.10服务器上安装了TeamBox。我使用提供的服务器脚本在端口3000上启动并运行它。它的运行速度非常慢,从另一台计算机连接时每个HTTP请求最多需要30秒。我使用链接从shell加载TeamBox,一点也不花时间。然后我设置了一个SSH隧道,它再次运行得非常快。我通过此服务器上的apache以及SAMBA等运行了大约30个虚拟主机,没有任何问题。我该如何解决这个问题? 最佳答案 我的redmine(ruby,webrick)太慢了。现在我解决了这个问题:apt-getinstallmongrelruby
我的生产Rails应用程序需要167秒来运行rakedb:migrate。可悲的是,没有要运行的迁移。我试图在检查是否有待处理的迁移时调整运行的迁移,但随后检查花费了同样长的时间。我心目中唯一的“借口”是数据库并不小,那里有1M条记录,但我看不出这有什么关系。我查看了日志,但没有任何迹象表明出了什么问题。我在运行ruby2.2.0rails4.2.0有没有人知道为什么会这样,是否有什么办法可以解决? 最佳答案 运行rakedb:migrate任务还会调用db:schema:dump任务,这将更新您的db/schema.rb。因此,即
当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#
当我尝试使用“套接字”库中的方法“read_nonblock”时出现以下错误IO::EAGAINWaitReadable:Resourcetemporarilyunavailable-readwouldblock但是当我通过终端上的IRB尝试时它工作正常如何让它读取缓冲区? 最佳答案 IgetthefollowingerrorwhenItrytousethemethod"read_nonblock"fromthe"socket"library当缓冲区中的数据未准备好时,这是预期的行为。由于异常IO::EAGAINWaitReadab