sip-lab 1.2.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/binding.gyp +5 -0
- package/install.sh +3 -2
- package/install_bcg729.sh +18 -0
- package/package.json +6 -6
- package/{a.js → samples/g729.js} +5 -113
- package/samples/late_negotiation.js +2 -1
- package/samples/simple.js +2 -1
- package/samples/sip_cancel.js +2 -1
- package/src/sip.cpp +34 -0
- package/src/README +0 -3
package/README.md
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
## sip-lab
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Overview
|
|
4
|
+
|
|
5
|
+
A nodejs module that helps to write functional tests for SIP systems (including media operations).
|
|
4
6
|
It uses pjproject for SIP and media processing.
|
|
5
7
|
|
|
8
|
+
### Installation
|
|
9
|
+
|
|
6
10
|
This will require for you to have some libraries installed. So do:
|
|
7
11
|
```
|
|
8
12
|
apt install build-essential automake autoconf libtool libspeex-dev libopus-dev libsdl2-dev libavdevice-dev libswscale-dev libv4l-dev libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev libopus-dev libsdl2-dev libopencore-amrnb-dev libopencore-amrwb-dev libvo-amrwbenc-dev libboost-dev libspandsp-dev libpcap-dev libssl-dev uuid-dev
|
|
9
13
|
```
|
|
10
14
|
|
|
15
|
+
We will also support G729 codec by installing bcg729.
|
|
16
|
+
|
|
17
|
+
There is a helper script that you can use:
|
|
18
|
+
```
|
|
19
|
+
./install_bcg729.sh
|
|
20
|
+
```
|
|
21
|
+
|
|
11
22
|
Then install sip-lab by doing:
|
|
12
23
|
```
|
|
13
24
|
npm install sip-lab
|
|
@@ -25,12 +36,12 @@ But if you do so, you will need to set NODE_PATH for node to find it by doing:
|
|
|
25
36
|
|
|
26
37
|
To test from within this repo just run:
|
|
27
38
|
```
|
|
39
|
+
npm install -g node-gyp
|
|
28
40
|
npm install --unsafe-perm
|
|
29
41
|
|
|
30
42
|
node samples/simple.js
|
|
31
43
|
```
|
|
32
44
|
|
|
33
|
-
|
|
34
45
|
The module is known to work properly in Ubuntu 18.04.4, Debian 8 and Debian 10 (and it is expected to work in Debian 9).
|
|
35
46
|
It was originally developed with node v.10 and tested with v.12 and it is expected to work with latest versions of node.
|
|
36
47
|
(it is known to not work with node v.8)
|
package/binding.gyp
CHANGED
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
'-Wno-maybe-uninitialized',
|
|
39
39
|
'-fPIC',
|
|
40
40
|
],
|
|
41
|
+
'ldflags_cc': [
|
|
42
|
+
'-all-static',
|
|
43
|
+
]
|
|
41
44
|
}
|
|
42
45
|
]
|
|
43
46
|
],
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
'-L ../pjproject/pjmedia/lib',
|
|
51
54
|
'-L ../pjproject/pjsip/lib',
|
|
52
55
|
'-L ../pjproject/third_party/lib',
|
|
56
|
+
'-L ../bcg729/src',
|
|
53
57
|
'-l pjnath-x86_64-unknown-linux-gnu',
|
|
54
58
|
'-l ilbccodec-x86_64-unknown-linux-gnu',
|
|
55
59
|
'-l srtp-x86_64-unknown-linux-gnu',
|
|
@@ -94,6 +98,7 @@
|
|
|
94
98
|
'-lopencore-amrwb',
|
|
95
99
|
'-lvo-amrwbenc',
|
|
96
100
|
'-lspeex',
|
|
101
|
+
'-lbcg729',
|
|
97
102
|
],
|
|
98
103
|
},
|
|
99
104
|
},
|
package/install.sh
CHANGED
|
@@ -8,7 +8,8 @@ if [[ ! -d pjproject ]]
|
|
|
8
8
|
then
|
|
9
9
|
git clone https://github.com/pjsip/pjproject
|
|
10
10
|
cd pjproject
|
|
11
|
-
git checkout de3d744c2e1188b59bb907b6ee32ef83740ebc64
|
|
11
|
+
#git checkout de3d744c2e1188b59bb907b6ee32ef83740ebc64
|
|
12
|
+
git checkout 33a3c9e0a5eb84426edef05a9aa98af17d8011c3 # required for bcg729
|
|
12
13
|
|
|
13
14
|
#echo "Patching sip_transaction.c to avoid problems with CANCEL"
|
|
14
15
|
sed -i -r 's|event->body.tx_msg.tdata == tsx->last_tx,|\t\t\t1, /* \0 */|' pjsip/src/pjsip/sip_transaction.c
|
|
@@ -18,7 +19,7 @@ then
|
|
|
18
19
|
export LDFLAGS +=
|
|
19
20
|
EOF
|
|
20
21
|
|
|
21
|
-
./configure
|
|
22
|
+
./configure --with-bcg729
|
|
22
23
|
cat > pjlib/include/pj/config_site.h <<EOF
|
|
23
24
|
#define PJMEDIA_HAS_SRTP 0
|
|
24
25
|
EOF
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -o errexit
|
|
4
|
+
set -o nounset
|
|
5
|
+
set -o pipefail
|
|
6
|
+
|
|
7
|
+
if [[ ! -d bcg729 ]]
|
|
8
|
+
then
|
|
9
|
+
git clone https://github.com/MayamaTakeshi/bcg729
|
|
10
|
+
cd bcg729
|
|
11
|
+
git checkout faaa895862165acde6df8add722ba4f85a25007d
|
|
12
|
+
cmake .
|
|
13
|
+
make
|
|
14
|
+
sudo make install
|
|
15
|
+
sudo ldconfig
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
echo success
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-lab",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"homepage": "https://github.com/MayamaTakeshi/sip-lab",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"node-addon-api": "^1.7.2",
|
|
22
|
-
"node-gyp": "^
|
|
22
|
+
"node-gyp": "^8.4.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"data-matching": "^1.23.
|
|
26
|
-
"sip-matching": "^1.3.
|
|
27
|
-
"string-matching": "^1.11.
|
|
28
|
-
"zester": "^
|
|
25
|
+
"data-matching": "^1.23.7",
|
|
26
|
+
"sip-matching": "^1.3.12",
|
|
27
|
+
"string-matching": "^1.11.8",
|
|
28
|
+
"zester": "^3.0.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/{a.js → samples/g729.js}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
var sip = require ('
|
|
2
|
-
var
|
|
1
|
+
var sip = require ('../index.js')
|
|
2
|
+
var Zester = require('zester')
|
|
3
|
+
var z = new Zester()
|
|
3
4
|
var m = require('data-matching')
|
|
4
5
|
var sip_msg = require('sip-matching')
|
|
5
6
|
|
|
@@ -19,6 +20,8 @@ t2 = sip.transport.create("127.0.0.1", 5092, 1)
|
|
|
19
20
|
console.log("t1", t1)
|
|
20
21
|
console.log("t2", t2)
|
|
21
22
|
|
|
23
|
+
sip.set_codecs("g729/8000/1:128")
|
|
24
|
+
|
|
22
25
|
flags = 0
|
|
23
26
|
|
|
24
27
|
oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
|
|
@@ -84,25 +87,6 @@ z.wait([
|
|
|
84
87
|
},
|
|
85
88
|
], 1000)
|
|
86
89
|
|
|
87
|
-
sip.call.send_dtmf(oc.id, '1234', 0)
|
|
88
|
-
sip.call.send_dtmf(ic.id, '4321', 1)
|
|
89
|
-
|
|
90
|
-
z.wait([
|
|
91
|
-
{
|
|
92
|
-
event: 'dtmf',
|
|
93
|
-
call_id: ic.id,
|
|
94
|
-
digits: '1234',
|
|
95
|
-
mode: 0,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
event: 'dtmf',
|
|
99
|
-
call_id: oc.id,
|
|
100
|
-
digits: '4321',
|
|
101
|
-
mode: 1,
|
|
102
|
-
},
|
|
103
|
-
], 2000)
|
|
104
|
-
|
|
105
|
-
|
|
106
90
|
sip.call.reinvite(oc.id, true, 0)
|
|
107
91
|
|
|
108
92
|
z.wait([
|
|
@@ -132,80 +116,6 @@ z.wait([
|
|
|
132
116
|
},
|
|
133
117
|
], 500)
|
|
134
118
|
|
|
135
|
-
sip.call.send_dtmf(oc.id, '1234', 0)
|
|
136
|
-
sip.call.send_dtmf(ic.id, '4321', 1) // this will not generate event 'dtmf' as the call is on hold
|
|
137
|
-
|
|
138
|
-
z.wait([
|
|
139
|
-
{
|
|
140
|
-
event: 'dtmf',
|
|
141
|
-
call_id: ic.id,
|
|
142
|
-
digits: '1234',
|
|
143
|
-
mode: 0,
|
|
144
|
-
},
|
|
145
|
-
], 2000)
|
|
146
|
-
|
|
147
|
-
sip.call.reinvite(ic.id, false, 0)
|
|
148
|
-
|
|
149
|
-
z.wait([
|
|
150
|
-
{
|
|
151
|
-
event: 'response',
|
|
152
|
-
call_id: ic.id,
|
|
153
|
-
method: 'INVITE',
|
|
154
|
-
msg: sip_msg({
|
|
155
|
-
$rs: '200',
|
|
156
|
-
$rr: 'OK',
|
|
157
|
-
$rb: '!{_}a=sendonly',
|
|
158
|
-
}),
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
event: 'media_status',
|
|
162
|
-
call_id: oc.id,
|
|
163
|
-
status: 'setup_ok',
|
|
164
|
-
local_mode: 'sendonly',
|
|
165
|
-
remote_mode: 'recvonly',
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
event: 'media_status',
|
|
169
|
-
call_id: ic.id,
|
|
170
|
-
status: 'setup_ok',
|
|
171
|
-
local_mode: 'recvonly',
|
|
172
|
-
remote_mode: 'sendonly',
|
|
173
|
-
},
|
|
174
|
-
], 500)
|
|
175
|
-
|
|
176
|
-
sip.call.send_dtmf(oc.id, '1234', 0)
|
|
177
|
-
sip.call.send_dtmf(ic.id, '4321', 1) // this will not generate event 'dtmf' as the call is on hold
|
|
178
|
-
|
|
179
|
-
z.wait([
|
|
180
|
-
{
|
|
181
|
-
event: 'dtmf',
|
|
182
|
-
call_id: ic.id,
|
|
183
|
-
digits: '1234',
|
|
184
|
-
mode: 0,
|
|
185
|
-
},
|
|
186
|
-
], 2000)
|
|
187
|
-
|
|
188
|
-
sip.call.send_request(oc.id, 'INFO')
|
|
189
|
-
|
|
190
|
-
z.wait([
|
|
191
|
-
{
|
|
192
|
-
event: 'request',
|
|
193
|
-
call_id: ic.id,
|
|
194
|
-
msg: sip_msg({
|
|
195
|
-
$rm: 'INFO',
|
|
196
|
-
}),
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
event: 'response',
|
|
200
|
-
call_id: oc.id,
|
|
201
|
-
method: 'INFO',
|
|
202
|
-
msg: sip_msg({
|
|
203
|
-
$rs: '200',
|
|
204
|
-
$rr: 'OK',
|
|
205
|
-
}),
|
|
206
|
-
},
|
|
207
|
-
], 500)
|
|
208
|
-
|
|
209
119
|
sip.call.reinvite(oc.id, false, 0)
|
|
210
120
|
|
|
211
121
|
z.wait([
|
|
@@ -235,24 +145,6 @@ z.wait([
|
|
|
235
145
|
},
|
|
236
146
|
], 500)
|
|
237
147
|
|
|
238
|
-
sip.call.send_dtmf(oc.id, '1234', 0)
|
|
239
|
-
sip.call.send_dtmf(ic.id, '4321', 1)
|
|
240
|
-
|
|
241
|
-
z.wait([
|
|
242
|
-
{
|
|
243
|
-
event: 'dtmf',
|
|
244
|
-
call_id: ic.id,
|
|
245
|
-
digits: '1234',
|
|
246
|
-
mode: 0,
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
event: 'dtmf',
|
|
250
|
-
call_id: oc.id,
|
|
251
|
-
digits: '4321',
|
|
252
|
-
mode: 1,
|
|
253
|
-
},
|
|
254
|
-
], 2000)
|
|
255
|
-
|
|
256
148
|
sip.call.terminate(oc.id)
|
|
257
149
|
|
|
258
150
|
z.wait([
|
package/samples/simple.js
CHANGED
package/samples/sip_cancel.js
CHANGED
package/src/sip.cpp
CHANGED
|
@@ -527,6 +527,16 @@ int __pjw_init()
|
|
|
527
527
|
return 1;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
g_pool = pj_pool_create(&cp.factory, "tester", 1000, 1000, NULL);
|
|
531
|
+
|
|
532
|
+
/* Create event manager */
|
|
533
|
+
status = pjmedia_event_mgr_create(g_pool, 0, NULL);
|
|
534
|
+
if(status != PJ_SUCCESS)
|
|
535
|
+
{
|
|
536
|
+
addon_log(LOG_LEVEL_DEBUG, "pjmedia_event_mgr_create failed\n");
|
|
537
|
+
return 1;
|
|
538
|
+
}
|
|
539
|
+
|
|
530
540
|
const pj_str_t msg_tag = { "MESSAGE", 7 };
|
|
531
541
|
const pj_str_t STR_MIME_TEXT_PLAIN = { "text/plain", 10 };
|
|
532
542
|
const pj_str_t STR_MIME_APP_ISCOMPOSING = { "application/im-iscomposing+xml", 30 };
|
|
@@ -693,6 +703,22 @@ int __pjw_init()
|
|
|
693
703
|
}
|
|
694
704
|
#endif
|
|
695
705
|
|
|
706
|
+
#if defined(PJMEDIA_HAS_OPUS_CODEC) && PJMEDIA_HAS_OPUS_CODEC!=0
|
|
707
|
+
status = pjmedia_codec_opus_init(g_med_endpt);
|
|
708
|
+
if(status != PJ_SUCCESS)
|
|
709
|
+
{
|
|
710
|
+
addon_log(LOG_LEVEL_DEBUG, "pjmedia_codec_opus_init failed\n");
|
|
711
|
+
return 1;
|
|
712
|
+
}
|
|
713
|
+
#endif
|
|
714
|
+
|
|
715
|
+
status = pjmedia_codec_bcg729_init(g_med_endpt);
|
|
716
|
+
if(status != PJ_SUCCESS)
|
|
717
|
+
{
|
|
718
|
+
printf("pjmedia_codec_bcg729_init failed\n");
|
|
719
|
+
return 1;
|
|
720
|
+
}
|
|
721
|
+
|
|
696
722
|
status = pj_thread_register("main_thread", g_main_thread_descriptor, &g_main_thread);
|
|
697
723
|
if(status != PJ_SUCCESS)
|
|
698
724
|
{
|
|
@@ -2251,6 +2277,9 @@ static void on_media_update( pjsip_inv_session *inv, pj_status_t status){
|
|
|
2251
2277
|
return;
|
|
2252
2278
|
}
|
|
2253
2279
|
|
|
2280
|
+
/* Start the UDP media transport */
|
|
2281
|
+
pjmedia_transport_media_start(call->med_transport, 0, 0, 0, 0);
|
|
2282
|
+
|
|
2254
2283
|
pjmedia_port *stream_port;
|
|
2255
2284
|
status = pjmedia_stream_get_port(call->med_stream, &stream_port);
|
|
2256
2285
|
if(status != PJ_SUCCESS){
|
|
@@ -3478,6 +3507,11 @@ void close_media_transport(pjmedia_transport *med_transport) {
|
|
|
3478
3507
|
g_PacketDumper->remove_endpoint( tpinfo.sock_info.rtcp_addr_name.ipv4.sin_addr.s_addr, tpinfo.sock_info.rtcp_addr_name.ipv4.sin_port );
|
|
3479
3508
|
}
|
|
3480
3509
|
|
|
3510
|
+
status = pjmedia_transport_media_stop(med_transport);
|
|
3511
|
+
if( status != PJ_SUCCESS ) {
|
|
3512
|
+
addon_log(LOG_LEVEL_DEBUG, "Critical Error: pjmedia_transport_media_stop failed. status=%d\n", status);
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3481
3515
|
status = pjmedia_transport_close(med_transport);
|
|
3482
3516
|
if( status != PJ_SUCCESS ) {
|
|
3483
3517
|
addon_log(LOG_LEVEL_DEBUG, "Critical Error: pjmedia_transport_close failed. status=%d\n", status);
|
package/src/README
DELETED