pjsip无法播放音频:无法打开文件进行播放:找不到(PJ_ENOTFOUND)[status = 70006]

时间:2019-01-23 17:00:23

标签: python linux pjsip alsa ubuntu-18.04

这不是重复的问题,其他用户也有相同的问题,但是此问题添加了更多信息。我正在使用Ubuntu 18。

当我通过VoIP和星号服务器收到呼叫时,我的python脚本崩溃了。此python脚本可在其他计算机上使用,但不适用于我的计算机。所以我试图诊断pjsip依赖关系,因为问题出在那儿。

我使用pjsip作为Python Most Voip Library的依赖项

pjsip的安装过程如下:

mkdir -p pjsip
cd pjsip
svn co http://svn.pjsip.org/repos/pjproject/trunk/
cd trunk
./configure CFLAGS='-fPIC' -with-ffmpeg
make dep -j4
make clean
make -j4
sudo make install
cd pjsip-apps/src/python/
python2 setup.py install --user

之后,我使用测试二进制文件检查我的计算机:

./pjsip/trunk/pjsip-apps/bin/pjsystest-x86_64-unknown-linux-gnu

测试菜单如下:

17:54:00.264         os_core_unix.c !pjlib 2.8-svn for POSIX initialized
17:54:00.265         sip_endpoint.c  .Creating endpoint instance...
17:54:00.265                  pjlib  .select() I/O Queue created (0x55d462ccde00)
17:54:00.265         sip_endpoint.c  .Module "mod-msg-print" registered
17:54:00.265        sip_transport.c  .Transport manager created.
17:54:00.265           pjsua_core.c  .PJSUA state changed: NULL --> CREATED
17:54:00.266         sip_endpoint.c  .Module "mod-pjsua-log" registered
17:54:00.266         sip_endpoint.c  .Module "mod-tsx-layer" registered
17:54:00.266         sip_endpoint.c  .Module "mod-stateful-util" registered
17:54:00.266         sip_endpoint.c  .Module "mod-ua" registered
17:54:00.266         sip_endpoint.c  .Module "mod-100rel" registered
17:54:00.266         sip_endpoint.c  .Module "mod-pjsua" registered
17:54:00.266         sip_endpoint.c  .Module "mod-invite" registered
17:54:01.427             alsa_dev.c  ..ALSA driver found 32 devices
17:54:01.427             alsa_dev.c  ..ALSA initialized
17:54:01.427                  pjlib  ..select() I/O Queue created (0x55d462d58e28)
17:54:01.430         sip_endpoint.c  .Module "mod-evsub" registered
17:54:01.430         sip_endpoint.c  .Module "mod-presence" registered
17:54:01.430         sip_endpoint.c  .Module "mod-mwi" registered
17:54:01.430         sip_endpoint.c  .Module "mod-refer" registered
17:54:01.430         sip_endpoint.c  .Module "mod-pjsua-pres" registered
17:54:01.430         sip_endpoint.c  .Module "mod-pjsua-im" registered
17:54:01.430         sip_endpoint.c  .Module "mod-pjsua-options" registered
17:54:01.430           pjsua_core.c  .1 SIP worker threads created
17:54:01.430           pjsua_core.c  .pjsua version 2.8-svn for Linux-4.15.0.43/x86_64/glibc-2.27 initialized
17:54:01.430           pjsua_core.c  .PJSUA state changed: CREATED --> INIT
17:54:01.430           pjsua_core.c  PJSUA state changed: INIT --> STARTING
17:54:01.430         sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
17:54:01.430           pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
M E N U :
---------
0: Tests
  00: Run test wizard
  01: Device Test
  02: Play Tone
  03: Play WAV File1
  04: Play WAV File2
  05: Record Audio
  06: Latency Test
  07: AEC/AES Test

  09: Exit
1: Options
  10: View Devices
  11: View Settings

Enter the menu number: 03

选择选项03,我得到以下输出:

This test will play input.8.wav file to the speaker. Please listen carefully for audio impairments such as stutter. Let this test run for a while to make sure that everything is okay. Press OK to start, CANCEL to skip
1:OK  9:Cancel  
1
17:54:28.350              systest.c  Running WAV File Playback Test
17:54:28.350            pjsua_aud.c  Creating file player: input.8.wav..
17:54:28.350            pjsua_aud.c  .Unable to open file for playback: Not found (PJ_ENOTFOUND) [status=70006]
17:54:28.351            pjsua_aud.c  Creating file player: ../../tests/pjsua/wavs/input.8.wav..
17:54:28.351           wav_player.c  .File player '../../tests/pjsua/wavs/input.8.wav' created: samp.rate=8000, ch=1, bufsize=4KB, filesize=67KB
17:54:28.351            pjsua_aud.c  .Player created, id=0, slot=1
17:54:28.351            pjsua_aud.c  Conf connect: 1 --> 0
17:54:28.351            pjsua_aud.c  .Set sound device: capture=-1, playback=-2
17:54:28.351            pjsua_aud.c  ..Opening sound device (speaker + mic) PCM@8000/1/20ms
17:54:28.412           conference.c !.Port 1 (../../tests/pjsua/wavs/input.8.wav) transmitting to port 0 (default)

这是在我有来电时崩溃我的python脚本的相同问题:

Incoming call from "test_user" <sip:test_user@192.168.30.30>
in _start_call_sound_in
[Wed Jan 23 17:56:31 2019] 17:56:31.426            pjsua_aud.c  ...Unable to open file for playback: Not found (PJ_ENOTFOUND) [status=70006]
Unhandled exception in thread started by <function _worker_thread_main at 0x7fb34d50ba28>
Traceback (most recent call last):
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/pjsua.py", line 2951, in _worker_thread_main
    time.sleep(0.050)
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/pjsua.py", line 2899, in _cb_on_incoming_call
    _lib._cb_on_incoming_call(acc_id, call_id, rdata)
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/pjsua.py", line 2781, in _cb_on_incoming_call
    acc._cb.on_incoming_call( Call(self, call_id) )
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/most/voip/api_backend.py", line 602, in on_incoming_call
    _start_call_sound_in()
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/most/voip/api_backend.py", line 128, in _start_call_sound_in
    player_in_id = pj.Lib.instance().create_player(sound_file,loop=True)
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/pjsua.py", line 2579, in create_player
    self._err_check("create_player()", self, err)
  File "/home/ubuntu_user/.local/lib/python2.7/site-packages/pjsua.py", line 2723, in _err_check
    raise Error(op_name, obj, err_code, err_msg)
pjsua.Error: Object: Lib, operation=create_player(), error=Not found (PJ_ENOTFOUND)

问题出在pjsip,与播放流音频有关。

Ubuntu默认使用ALSA,看来一切正常。我有sox utils,可以正确播放wav文件。

  • 更新:看来PJ_ENOTFOUND只是一个常见错误,找不到要播放的文件。测试的问题只是路径。将文件wav移至二进制路径可直接运行而不会出错。 python包装器的问题是其他问题。

一些想法?

1 个答案:

答案 0 :(得分:1)

在调试python库后,我发现当调用到达时,将尝试使用wav文件。我使用--user选项安装了python库,并且该库查找文件的地方是错误的。

使用--user选项可在非标准系统路径中进行安装。如果有电话到达,将找不到wav文件,并且python库崩溃。要解决此问题,只需将符号链接添加到正确的路径即可:

sudo ln -s /usr/local/lib/python2.7/dist-packages/data/ ${HOME}/.local/lib/python2.7/site-packages/
ls # output shall contain sounds folder

通过此链接,库可以接受播放wav文件的调用。