sip-lab 1.2.4 → 1.6.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 CHANGED
@@ -1,13 +1,24 @@
1
1
  ## sip-lab
2
2
 
3
- Node module that helps to write functional tests for SIP systems (including media operations).
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.2.4",
3
+ "version": "1.6.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": "^7.0.0"
22
+ "node-gyp": "^8.4.1"
23
23
  },
24
24
  "devDependencies": {
25
- "data-matching": "^1.23.6",
26
- "sip-matching": "^1.3.11",
27
- "string-matching": "^1.11.7",
28
- "zester": "^2.20.9"
25
+ "data-matching": "^1.23.7",
26
+ "sip-matching": "^1.3.12",
27
+ "string-matching": "^1.11.8",
28
+ "zester": "^4.0.0"
29
29
  }
30
30
  }
@@ -0,0 +1,182 @@
1
+ var sip = require ('../index.js')
2
+ var Zester = require('zester')
3
+ var z = new Zester()
4
+ var m = require('data-matching')
5
+ var sip_msg = require('sip-matching')
6
+
7
+ async function test() {
8
+ //sip.set_log_level(6)
9
+ sip.dtmf_aggregation_on(500)
10
+
11
+ z.trap_events(sip.event_source, 'event', (evt) => {
12
+ var e = evt.args[0]
13
+ return e
14
+ })
15
+
16
+ console.log(sip.start((data) => { console.log(data)} ))
17
+
18
+ t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
+ t2 = sip.transport.create("127.0.0.1", 5092, 1)
20
+
21
+ console.log("t1", t1)
22
+ console.log("t2", t2)
23
+
24
+ sip.set_codecs("g729/8000/1:128")
25
+
26
+ flags = 0
27
+
28
+ oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
29
+
30
+ await z.wait([
31
+ {
32
+ event: "incoming_call",
33
+ call_id: m.collect("call_id"),
34
+ },
35
+ {
36
+ event: 'response',
37
+ call_id: oc.id,
38
+ method: 'INVITE',
39
+ msg: sip_msg({
40
+ $rs: '100',
41
+ $rr: 'Trying',
42
+ '$(hdrcnt(via))': 1,
43
+ '$hdr(call-id)': m.collect('sip_call_id'),
44
+ $fU: 'a',
45
+ $fd: 't',
46
+ $tU: 'b',
47
+ '$hdr(l)': '0',
48
+ }),
49
+ },
50
+ ], 1000)
51
+
52
+ ic = {
53
+ id: z.store.call_id,
54
+ sip_call_id: z.store.sip_call_id,
55
+ }
56
+
57
+ sip.call.respond(ic.id, 200, 'OK')
58
+
59
+ await z.wait([
60
+ {
61
+ event: 'media_status',
62
+ call_id: oc.id,
63
+ status: 'setup_ok',
64
+ local_mode: 'sendrecv',
65
+ remote_mode: 'sendrecv',
66
+ },
67
+ {
68
+ event: 'media_status',
69
+ call_id: ic.id,
70
+ status: 'setup_ok',
71
+ local_mode: 'sendrecv',
72
+ remote_mode: 'sendrecv',
73
+ },
74
+ {
75
+ event: 'response',
76
+ call_id: oc.id,
77
+ method: 'INVITE',
78
+ msg: sip_msg({
79
+ $rs: '200',
80
+ $rr: 'OK',
81
+ '$(hdrcnt(VIA))': 1,
82
+ $fU: 'a',
83
+ $fd: 't',
84
+ $tU: 'b',
85
+ '$hdr(content-type)': 'application/sdp',
86
+ $rb: '!{_}a=sendrecv',
87
+ }),
88
+ },
89
+ ], 1000)
90
+
91
+ sip.call.reinvite(oc.id, true, 0)
92
+
93
+ await z.wait([
94
+ {
95
+ event: 'response',
96
+ call_id: oc.id,
97
+ method: 'INVITE',
98
+ msg: sip_msg({
99
+ $rs: '200',
100
+ $rr: 'OK',
101
+ $rb: '!{_}a=recvonly',
102
+ }),
103
+ },
104
+ {
105
+ event: 'media_status',
106
+ call_id: oc.id,
107
+ status: 'setup_ok',
108
+ local_mode: 'sendonly',
109
+ remote_mode: 'recvonly',
110
+ },
111
+ {
112
+ event: 'media_status',
113
+ call_id: ic.id,
114
+ status: 'setup_ok',
115
+ local_mode: 'recvonly',
116
+ remote_mode: 'sendonly',
117
+ },
118
+ ], 500)
119
+
120
+ sip.call.reinvite(oc.id, false, 0)
121
+
122
+ await z.wait([
123
+ {
124
+ event: 'response',
125
+ call_id: oc.id,
126
+ method: 'INVITE',
127
+ msg: sip_msg({
128
+ $rs: '200',
129
+ $rr: 'OK',
130
+ $rb: '!{_}a=sendrecv',
131
+ }),
132
+ },
133
+ {
134
+ event: 'media_status',
135
+ call_id: oc.id,
136
+ status: 'setup_ok',
137
+ local_mode: 'sendrecv',
138
+ remote_mode: 'sendrecv',
139
+ },
140
+ {
141
+ event: 'media_status',
142
+ call_id: ic.id,
143
+ status: 'setup_ok',
144
+ local_mode: 'sendrecv',
145
+ remote_mode: 'sendrecv',
146
+ },
147
+ ], 500)
148
+
149
+ sip.call.terminate(oc.id)
150
+
151
+ await z.wait([
152
+ {
153
+ event: 'call_ended',
154
+ call_id: oc.id,
155
+ },
156
+ {
157
+ event: 'call_ended',
158
+ call_id: ic.id,
159
+ },
160
+ {
161
+ event: 'response',
162
+ call_id: oc.id,
163
+ method: 'BYE',
164
+ msg: sip_msg({
165
+ $rs: '200',
166
+ $rr: 'OK',
167
+ }),
168
+ },
169
+ ], 1000)
170
+
171
+ await z.sleep(1000)
172
+
173
+ console.log("Success")
174
+
175
+ sip.stop()
176
+ }
177
+
178
+ test()
179
+ .catch(e => {
180
+ console.error(e)
181
+ process.exit(1)
182
+ })