2017-09-27 105 views
1

我使用PJSIP 2.7与Python的树莓派和问题我有2个问题:约PJSUA和编解码器

问题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:

为什么我得到一个设备忙,如果我想使用相同的音频设备PJSIP在我的Python代码?我也试过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 

任何帮助将不胜感激。

回答

0

我终于找到我的问题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