关于PJSUA和编解码器的问题

时间:2017-09-27 09:11:17

标签: python asterisk pjsip

我在Raspberrypi上使用PJSIP 2.7和Python,我有两个问题:

问题1:

我怎么知道可用的编解码器? 我使用 enum_codecs()方法列出编解码器,但它返回一个十六进制字符串数组:

infos = lib.enum_codecs()
print infos

codec:[<pjsua.CodecInfo instance at 0xb64c2620>, <pjsua.CodecInfo instance at 0xb64c2648>, <pjsua.CodecInfo instance at 0xb64c2670>, <pjsua.CodecInfo instance at 0xb64c2698>, <pjsua.CodecInfo instance at 0xb64c26c0>, <pjsua.CodecInfo instance at 0xb64c26e8>, <pjsua.CodecInfo instance at 0xb64c2710>, <pjsua.CodecInfo instance at 0xb64c2738>, <pjsua.CodecInfo instance at 0xb64c2760>, <pjsua.CodecInfo instance at 0xb64c2788>, <pjsua.CodecInfo instance at 0xb64c27b0>, <pjsua.CodecInfo instance at 0xb64c27d8>, <pjsua.CodecInfo instance at 0xb64c2800>, <pjsua.CodecInfo instance at 0xb64c2828>, <pjsua.CodecInfo instance at 0xb64c2850>]

我如何知道哪一个是G711和G722?我希望我的终端使用G722编解码器。 关于课程的文档在这里:http://www.pjsip.org/python/pjsua.htm

问题2:

如果我想在Python代码中使用与pjsip相同的音频设备,为什么设备会忙?我也尝试过DMIX而没有成功。

os.system("aplay -f S16_LE -c 2 -D plughw:1,0 /home/pi/beep.wav")
aplay: main:722: audio open error: Device or resource busy

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

我终于找到了问题1和2的答案:

问题1的答案: 我可以通过在Asterisk的一侧设置正确的编解码器来使用g722编解码器。

问题2的答案:

我的麦克风是一个usb设备(hw 1),我的声卡是另一个(hw 0)。 我不得不编辑我的.asound.conf文件并使用dmix设备进行播放。 这是我最后工作的.asound.conf文件:

pcm.!default
{
type asym
playback.pcm
{
    type plug
    slave.pcm "dmix"
}
capture.pcm 
{
    type plug
    slave.pcm "hw:1,0"
}
}

我现在可以在使用pjsua进行通话时播放声音。 这篇文章帮助我弄明白了:

Raspberry forum