Нет звука в звонках с использованием Sipster - PullRequest
0 голосов
/ 30 мая 2019
var sipster = require('sipster');

var srv = '192.168.0.234';
var ext = '1010';
var pwd = 'passw0rd';

// initialize pjsip
sipster.init();

// set up a transport to listen for incoming connections, defaults to UDP
var transport = new sipster.Transport({ port: 5060 });

var acc = new sipster.Account({
    idUri: 'sip:' + ext + '@' + srv
    ,   regConfig: {
        registrarUri: 'sip:' + srv
    }
    ,   sipConfig: {
        authCreds:[{
            scheme:'digest'
            ,   realm: '*'
            ,   username: ext
            ,   dataType: 0
            ,   data: pwd
        }]
    }
});

acc.setRegistration(true);

acc.on('state', function(active, statusCode) {
    console.log ("STATUS:" + statusCode);
});

acc.on('call', function(info, call) {
    console.log('=== Incoming call from ' + info.remoteContact);

    // watch for call state changes
    call.on('state', function(state) {
        console.log('=== Call state is now: ' + state.toUpperCase());
    });

    // listen for DTMF digits
    call.on('dtmf', function(digit) {
        console.log('=== DTMF digit received: ' + digit);
    });

/*****  
    // audio stream(s) available
    call.on('media', function(medias) {
        // play looping .wav file to the first audio stream
        var player = sipster.createPlayer('sound.wav');
        player.startTransmitTo(medias[0]);

        // record the audio of the other side, this will not include the audio from
        // the player above.
        var recorder = sipster.createRecorder('call.wav');
        medias[0].startTransmitTo(recorder);
        // to include the player audio, you can mix the sources together simply
        // by transmitting to the same recorder:
        //   player.startTransmitTo(recorder);
    });
***/
    // answer the call (with default 200 OK)
    call.answer();
});

sipster.start();

// acc.makeCall('sip:1000@192.168.0.234');

Не слышен звук при приеме или совершении вызовов, это журнал:

Вот некоторые результаты.Я удалил большую часть разговоров SIP, так как считаю, что проблема не имеет отношения к делу.Я заметил, что аудиоканал работает, PJSIP обнаружил, что драйвер ALSA и соответствующие устройства

root@raspberrypi:~# node t1.js
18:55:41.206 os_core_unix.c !pjlib 2.8-svn for POSIX initialized
18:55:41.208 sip_endpoint.c  .Creating endpoint instance...
18:55:41.208          pjlib  .select() I/O Queue created (0x3b33770)
18:55:41.208 sip_endpoint.c  .Module "mod-msg-print" registered
18:55:41.208 sip_transport.  .Transport manager created.
18:55:41.208   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
18:55:41.208 sip_endpoint.c  .Module "mod-pjsua-log" registered
18:55:41.209 sip_endpoint.c  .Module "mod-tsx-layer" registered
18:55:41.209 sip_endpoint.c  .Module "mod-stateful-util" registered
18:55:41.209 sip_endpoint.c  .Module "mod-ua" registered
18:55:41.209 sip_endpoint.c  .Module "mod-100rel" registered
18:55:41.209 sip_endpoint.c  .Module "mod-pjsua" registered
18:55:41.209 sip_endpoint.c  .Module "mod-invite" registered
18:55:41.302     alsa_dev.c  ..ALSA driver found 14 devices
18:55:41.302     alsa_dev.c  ..ALSA initialized
18:55:41.302          pjlib  ..select() I/O Queue created (0x3b4f64c)
18:55:41.314 sip_endpoint.c  .Module "mod-evsub" registered
18:55:41.314 sip_endpoint.c  .Module "mod-presence" registered
18:55:41.314 sip_endpoint.c  .Module "mod-mwi" registered
18:55:41.314 sip_endpoint.c  .Module "mod-refer" registered
18:55:41.314 sip_endpoint.c  .Module "mod-pjsua-pres" registered
18:55:41.314 sip_endpoint.c  .Module "mod-pjsua-im" registered
18:55:41.314 sip_endpoint.c  .Module "mod-pjsua-options" registered
18:55:41.314   pjsua_core.c  .1 SIP worker threads created
18:55:41.314   pjsua_core.c  .pjsua version 2.8-svn for Linux-4.19.42/armv7l/glibc-2.24 initialized
18:55:41.314   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
18:55:41.314    pjsua_aud.c  Setting null sound device..
18:55:41.315    pjsua_aud.c  .Opening null sound device..
18:55:41.316   pjsua_core.c  SIP UDP socket reachable at 192.168.0.24:5060
18:55:41.316   udp0x3b72aa0  SIP UDP transport started, published address is 192.168.0.24:5060
18:55:41.317    pjsua_acc.c  Adding account: id=sip:1010@192.168.0.234
18:55:41.317    pjsua_acc.c  .Account sip:1010@192.168.0.234 added with id 0
18:55:41.317    pjsua_acc.c  Acc 0: setting registration..
18:55:41.318   pjsua_core.c  ..TX 485 bytes Request msg 

Код выше действителен для инициализации различных объектов.Обратите внимание на ссылку на драйверы ALSA, если для регистрации расширения Sipster:

REGISTER/cseq=37939 (tdta0x3b76e94) to UDP 192.168.0.234:5060:
REGISTER sip:192.168.0.234 SIP/2.0 ...

--end msg--
18:55:41.318    pjsua_acc.c  .Acc 0: Registration sent
18:55:41.318   pjsua_core.c  PJSUA state changed: INIT --> STARTING
18:55:41.319 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
18:55:41.319   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
18:55:41.325   pjsua_core.c  .RX 648 bytes Response msg 401/REGISTER/cseq=37939 (rdata0x3b740d4) from UDP 192.168.0.234:5060:
...

--end msg--
18:55:41.330   pjsua_core.c  ....TX 744 bytes Request msg REGISTER/cseq=37940 (tdta0x3b76e94) to UDP 192.168.0.234:5060:
REGISTER sip:192.168.0.234 SIP/2.0
...
--end msg--
18:55:41.338   pjsua_core.c  .RX 608 bytes Response msg 200/REGISTER/cseq=37940 (rdata0x7160129c) from UDP 192.168.0.234:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.24:5060;rport=5060;branch=z9hG4bKPj.XicpgD7rZ5URstdu899IaGdWZhFUOiC

--end msg--
18:55:41.343    pjsua_acc.c  ....SIP outbound status for acc 0 is not active
18:55:41.343    pjsua_acc.c  ....sip:1010@192.168.0.234: registration success, status=200 (OK), will re-register in 300 seconds
18:55:41.343    pjsua_acc.c  ....Keep-alive timer started for acc 0, destination:192.168.0.234:5060:15, interval:1s
18:55:41.370   pjsua_core.c  .RX 908 bytes Request msg NOTIFY/cseq=5065491 (rdata0x7160129c) from UDP 192.168.0.234:5060:
NOTIFY sip:1010@192.168.0.24:5060;ob SIP/2.0
...
--end msg--
18:55:41.376   pjsua_pres.c  .Got unsolicited NOTIFY from 192.168.0.234:5060..
18:55:41.377   pjsua_core.c  ...TX 306 bytes Response msg 200/NOTIFY/cseq=5065491 (tdta0x71603554) to UDP 192.168.0.234:5060:
SIP/2.0 200 OK
....
--end msg--
Registering ...
... Registered

STATUS:200
18:55:42.318    pjsua_aud.c  Closing sound device after idle for 1 second(s)
18:55:42.318    pjsua_aud.c  .Closing null sound device..
18:55:47.522   pjsua_core.c  .RX 1281 bytes Request msg 

Начало входящего вызова с обычного номера:

INVITE/cseq=5065494 (rdata0x7160129c) from UDP 192.168.0.234:5060:
INVITE sip:1010@192.168.0.24:5060;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.0.234;rport;branch=z9hG4bKDBpje8S4amrar
....

v=0
o=FreeSWITCH 1559210876 1559210877 IN IP4 192.168.0.234
s=FreeSWITCH
c=IN IP4 192.168.0.234
t=0 0
m=audio 27696 RTP/AVP 9 0 8 101
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20

--end msg--
18:55:47.522   pjsua_call.c  .Incoming Request msg INVITE/cseq=5065494 (rdata0x7160129c)
18:55:47.524  pjsua_media.c  ..Call 0: initializing media..
18:55:47.525  pjsua_media.c  ...RTP socket reachable at 192.168.0.24:4000
18:55:47.525  pjsua_media.c  ...RTCP socket reachable at 192.168.0.24:4001
18:55:47.525  pjsua_media.c  ...Media index 0 selected for audio call 0
=== Incoming call from <sip:mod_sofia@192.168.0.234:5060>
18:55:47.527   pjsua_call.c !Answering call 0: code=200
18:55:47.528   pjsua_core.c  .....TX 302 bytes Response msg 100/INVITE/cseq=5065494 (tdta0x716128f4) to UDP 192.168.0.234:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.234;rport=5060;received=192.168.0.234;branch=z9hG4bKDBpje8S4amrar
Call-ID: 1f1855d2-fda6-1237-62be-00fd45fc4abc
From: "Interno 1000" <sip:1000@192.168.0.234>;tag=3yBB1QFK9vBDr
To: <sip:1010@192.168.0.24;ob>
CSeq: 5065494 INVITE
Content-Length:  0


--end msg--
18:55:47.531  inv0x716008dc  ..SDP negotiation done: Success
18:55:47.531  pjsua_media.c  ...Call 0: updating media..
18:55:47.531  pjsua_media.c  .....Media stream call00:0 is destroyed
18:55:47.531    pjsua_aud.c  ....Audio channel update..
18:55:47.531  strm0x3b76e44  .....VAD temporarily disabled
18:55:47.532  strm0x3b76e44  .....Encoder stream started
18:55:47.532  strm0x3b76e44  .....Decoder stream started
18:55:47.532  pjsua_media.c  ....Audio updated, stream #0: G722 (sendrecv)
18:55:47.532   pjsua_core.c  ....TX 873 bytes Response msg 

Sipster отвечает на вызов согласно коду, но нет звука.

200/INVITE/cseq=5065494 (tdta0x3b718f4) to UDP 192.168.0.234:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.234;rport=5060;received=192.168.0.234;branch=z9hG4bKDBpje8S4amrar
Call-ID: 1f1855d2-fda6-1237-62be-00fd45fc4abc
From: "Interno 1000" <sip:1000@192.168.0.234>;tag=3yBB1QFK9vBDr
To: <sip:1010@192.168.0.24;ob>;tag=GlRjK-.n6i7GffuemwGd5ELoZq3icvj4
CSeq: 5065494 INVITE
Contact: <sip:1010@192.168.0.24:5060;ob>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Content-Type: application/sdp
Content-Length:   316

v=0
o=- 3768227747 3768227748 IN IP4 192.168.0.24
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 9 101
c=IN IP4 192.168.0.24
b=TIAS:64000
a=rtcp:4001 IN IP4 192.168.0.24
a=sendrecv
a=rtpmap:9 G722/8000
a=ssrc:1153692700 cname:3b0c6b47616e0ac7
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

--end msg--
=== Call state is now: INCOMING
...

--end msg--
=== Call state is now: CONNECTING
=== Call state is now: CONFIRMED
18:55:47.804       stream.c  G722 codec used, remote samples per frame detected = 80
18:55:51.297   pjsua_core.c  .RX 602 bytes Request msg BYE/cseq=5065495 (rdata0x7160129c) from UDP 192.168.0.234:5060:
...
--end msg--
18:55:51.298   pjsua_core.c  .......TX 332 bytes Response msg 200/BYE/cseq=5065495 (tdta0x716128f4) to UDP 192.168.0.234:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.234;rport=5060;received=192.168.0.234;branch=z9hG4bKg61vKScF2eU2a
...
--end msg--
18:55:51.299  pjsua_media.c  ......Call 0: deinitializing media..
18:55:51.300  pjsua_media.c  ........Media stream call00:0 is destroyed
=== Call state is now: DISCONNECTED

Вызов отключается, когда я вешаю трубку на другой добавочный номер

...