sip-lab 1.11.2 → 1.12.1

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
@@ -6,14 +6,19 @@ A nodejs module that helps to write functional tests for SIP systems (including
6
6
  It uses pjproject for SIP and media processing.
7
7
 
8
8
  It permits to:
9
+ - make audio calls using UDP, TCP and TLS transports
9
10
  - send and receive DTMF inband/RFC2833/INFO.
10
11
  - play/record wav file on a call
11
12
  - send/receive fax (T.30 only)
12
13
 
14
+ TODO:
15
+ - add suport for T.38 fax
16
+ - add support for WebRTC
17
+ - add support for video playing/recording from/to file
13
18
 
14
19
  ### Installation
15
20
 
16
- This will require for you to have some libraries installed. So do:
21
+ This will require you to have some libraries installed. So do:
17
22
  ```
18
23
  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
19
24
  ```
@@ -33,7 +38,7 @@ Then install sip-lab by doing:
33
38
  To test from within this repo just build and install by doing:
34
39
  ```
35
40
  npm install -g node-gyp
36
- npm install --unsafe-perm
41
+ npm install
37
42
  ```
38
43
  And run some sample script from subfolder samples:
39
44
  ```
@@ -41,7 +46,7 @@ And run some sample script from subfolder samples:
41
46
  ```
42
47
 
43
48
  The module is known to work properly in Ubuntu 18.04.4, Ubuntu 20.04.4, Debian 8 and Debian 10 (and it is expected to work in Debian 9).
44
- It was originally developed with node v.10 and tested with v.12 and it is expected to work with latest versions of node.
49
+ It was originally developed with node v.10 and tested with v.12 and v16.13.1 and it is expected to work with latest versions of node.
45
50
  (it is known to not work with node v.8)
46
51
 
47
52
 
package/binding.gyp CHANGED
@@ -26,6 +26,7 @@
26
26
  "src/pjmedia/include",
27
27
  "src/pjmedia/include/pjmedia",
28
28
  "src/pjmedia/include/chainlink",
29
+ "rapidjson/include",
29
30
  "<!@(node -p \"require('node-addon-api').include\")",
30
31
  ],
31
32
  "dependencies": [
package/index.js CHANGED
@@ -39,32 +39,42 @@ addon.stop = () => {
39
39
  }
40
40
 
41
41
  addon.transport = {
42
- create: addon.transport_create,
42
+ create: (params) => { return addon.transport_create(JSON.stringify(params)) },
43
43
  }
44
44
 
45
45
  addon.account = {
46
- create: addon.account_create,
47
- register: addon.account_register,
46
+ create: (t_id, params) => { return addon.account_create(t_id, JSON.stringify(params)) },
47
+ register: (a_id, params) => { return addon.account_register(a_id, JSON.stringify(params ? params : {})) },
48
48
  unregister: addon.account_unregister,
49
49
  }
50
50
 
51
51
  addon.call = {
52
- create: addon.call_create,
53
- respond: addon.call_respond,
54
- terminate: addon.call_terminate,
55
- send_dtmf: addon.call_send_dtmf,
56
- reinvite: addon.call_reinvite,
57
- send_request: addon.call_send_request,
58
- start_recording: addon.call_start_record_wav,
59
- start_playing: addon.call_start_play_wav,
52
+ create: (t_id, params) => { return addon.call_create(t_id, JSON.stringify(params)) },
53
+ respond: (c_id, params) => { return addon.call_respond(c_id, JSON.stringify(params)) },
54
+ terminate: (c_id, params) => { return addon.call_terminate(c_id, JSON.stringify(params ? params : {})) },
55
+ send_dtmf: (c_id, params) => { return addon.call_send_dtmf(c_id, JSON.stringify(params)) },
56
+ reinvite: (c_id, params) => { return addon.call_reinvite(c_id, JSON.stringify(params ? params : {})) },
57
+ send_request: (c_id, params) => { return addon.call_send_request(c_id, JSON.stringify(params)) },
58
+ start_recording: (c_id, params) => { return addon.call_start_record_wav(c_id, JSON.stringify(params)) },
59
+ start_playing: (c_id, params) => { return addon.call_start_play_wav(c_id, JSON.stringify(params)) },
60
60
  stop_recording: addon.call_stop_record_wav,
61
61
  stop_playing: addon.call_stop_play_wav,
62
- start_fax: addon.call_start_fax,
62
+ start_fax: (c_id, params) => { return addon.call_start_fax(c_id, JSON.stringify(params)) },
63
63
  stop_fax: addon.call_stop_fax,
64
64
  get_stream_stat: addon.call_get_stream_stat,
65
- refer: addon.call_refer,
65
+ refer: (c_id, params) => { return addon.call_refer(c_id, JSON.stringify(params)) },
66
66
  get_info: addon.call_get_info,
67
67
  gen_string_replaces: addon.call_gen_string_replaces,
68
68
  }
69
69
 
70
+ addon.subscriber = {
71
+ notify: (s_id, params) => { return addon.notify(s_id, JSON.stringify(params)) },
72
+ notify_xfer: (s_id, params) => { return addon.notify_xfer(s_id, JSON.stringify(params)) },
73
+ }
74
+
75
+ addon.subscription = {
76
+ create: (t_id, params) => { return addon.subscription_create(t_id, JSON.stringify(params)) },
77
+ subscribe: (s_id, params) => { return addon.subscription_subscribe(s_id, JSON.stringify(params)) },
78
+ }
79
+
70
80
  module.exports = addon;
package/install.sh CHANGED
@@ -4,6 +4,8 @@ set -o errexit
4
4
  set -o nounset
5
5
  set -o pipefail
6
6
 
7
+ START_DIR=`pwd`
8
+
7
9
  if [[ ! -d pjproject ]]
8
10
  then
9
11
  git clone https://github.com/pjsip/pjproject
@@ -24,10 +26,19 @@ EOF
24
26
  #define PJMEDIA_HAS_SRTP 0
25
27
  EOF
26
28
  make dep && make clean && make
29
+ fi
30
+
31
+ cd $START_DIR
27
32
 
28
- cd ..
33
+ if [[ ! -d rapidjson ]]
34
+ then
35
+ git clone https://github.com/Tencent/rapidjson
36
+ cd rapidjson
37
+ git checkout 27c3a8dc0e2c9218fe94986d249a12b5ed838f1d
29
38
  fi
30
39
 
40
+ cd $START_DIR
41
+
31
42
  node-gyp configure
32
43
 
33
44
  node-gyp build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-lab",
3
- "version": "1.11.2",
3
+ "version": "1.12.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -18,6 +18,7 @@
18
18
  "gypfile": true,
19
19
  "homepage": "https://github.com/MayamaTakeshi/sip-lab",
20
20
  "dependencies": {
21
+ "-": "^0.0.1",
21
22
  "node-addon-api": "^1.7.2",
22
23
  "node-gyp": "^8.4.1"
23
24
  },
@@ -15,15 +15,13 @@ async function test() {
15
15
 
16
16
  console.log(sip.start((data) => { console.log(data)} ))
17
17
 
18
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
18
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
19
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
20
20
 
21
21
  console.log("t1", t1)
22
22
  console.log("t2", t2)
23
23
 
24
- flags = 1 // late negotiation
25
-
26
- oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
24
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`, delayed_media: true})
27
25
 
28
26
  await z.wait([
29
27
  {
@@ -39,9 +37,9 @@ async function test() {
39
37
  $rr: 'Trying',
40
38
  '$(hdrcnt(via))': 1,
41
39
  '$hdr(call-id)': m.collect('sip_call_id'),
42
- $fU: 'a',
43
- $fd: 't',
44
- $tU: 'b',
40
+ $fU: 'alice',
41
+ $fd: 'test.com',
42
+ $tU: 'bob',
45
43
  '$hdr(l)': '0',
46
44
  }),
47
45
  },
@@ -52,7 +50,7 @@ async function test() {
52
50
  sip_call_id: z.store.sip_call_id,
53
51
  }
54
52
 
55
- sip.call.respond(ic.id, 200, 'OK')
53
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
56
54
 
57
55
  await z.wait([
58
56
  {
@@ -77,17 +75,17 @@ async function test() {
77
75
  $rs: '200',
78
76
  $rr: 'OK',
79
77
  '$(hdrcnt(VIA))': 1,
80
- $fU: 'a',
81
- $fd: 't',
82
- $tU: 'b',
78
+ $fU: 'alice',
79
+ $fd: 'test.com',
80
+ $tU: 'bob',
83
81
  '$hdr(content-type)': 'application/sdp',
84
82
  $rb: '!{_}a=sendrecv',
85
83
  }),
86
84
  },
87
85
  ], 1000)
88
86
 
89
- sip.call.send_dtmf(oc.id, '1234', 0)
90
- sip.call.send_dtmf(ic.id, '4321', 1)
87
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
88
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
91
89
 
92
90
  await z.wait([
93
91
  {
@@ -105,7 +103,7 @@ async function test() {
105
103
  ], 2000)
106
104
 
107
105
 
108
- sip.call.reinvite(oc.id, true, flags)
106
+ sip.call.reinvite(oc.id, {hold: true, delayed_media: true})
109
107
 
110
108
  await z.wait([
111
109
  {
@@ -134,8 +132,8 @@ async function test() {
134
132
  },
135
133
  ], 500)
136
134
 
137
- sip.call.send_dtmf(oc.id, '1234', 0)
138
- sip.call.send_dtmf(ic.id, '4321', 1) // This will not generate event 'dtmf'
135
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
136
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // This will not generate event 'dtmf'
139
137
 
140
138
  await z.wait([
141
139
  {
@@ -146,7 +144,7 @@ async function test() {
146
144
  },
147
145
  ], 2000)
148
146
 
149
- sip.call.reinvite(ic.id, false, flags)
147
+ sip.call.reinvite(ic.id, {hold: false, delayed_media: true})
150
148
 
151
149
  await z.wait([
152
150
  {
@@ -175,8 +173,8 @@ async function test() {
175
173
  },
176
174
  ], 500)
177
175
 
178
- sip.call.send_dtmf(oc.id, '1234', 0)
179
- sip.call.send_dtmf(ic.id, '4321', 1) // This will not generate event 'dtmf'
176
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
177
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // This will not generate event 'dtmf'
180
178
 
181
179
  await z.wait([
182
180
  {
@@ -187,7 +185,7 @@ async function test() {
187
185
  },
188
186
  ], 2000)
189
187
 
190
- sip.call.send_request(oc.id, 'INFO')
188
+ sip.call.send_request(oc.id, {method: 'INFO'})
191
189
 
192
190
  await z.wait([
193
191
  {
@@ -208,7 +206,7 @@ async function test() {
208
206
  },
209
207
  ], 500)
210
208
 
211
- sip.call.reinvite(oc.id, false, flags)
209
+ sip.call.reinvite(oc.id, {hold: false, delayed_media: true})
212
210
 
213
211
  await z.wait([
214
212
  {
@@ -238,8 +236,8 @@ async function test() {
238
236
  ], 500)
239
237
 
240
238
 
241
- sip.call.send_dtmf(oc.id, '1234', 0)
242
- sip.call.send_dtmf(ic.id, '4321', 1) // This will not generate event 'dtmf'
239
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
240
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // This will not generate event 'dtmf'
243
241
 
244
242
  await z.wait([
245
243
  {
@@ -250,7 +248,6 @@ async function test() {
250
248
  },
251
249
  ], 2000)
252
250
 
253
-
254
251
  sip.call.terminate(oc.id)
255
252
 
256
253
  await z.wait([
package/samples/g729.js CHANGED
@@ -17,8 +17,8 @@ async function test() {
17
17
 
18
18
  console.log(sip.start((data) => { console.log(data)} ))
19
19
 
20
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
21
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
20
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
21
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
22
22
 
23
23
  console.log("t1", t1)
24
24
  console.log("t2", t2)
@@ -27,7 +27,7 @@ async function test() {
27
27
 
28
28
  flags = 0
29
29
 
30
- oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
30
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
31
31
 
32
32
  await z.wait([
33
33
  {
@@ -43,9 +43,9 @@ async function test() {
43
43
  $rr: 'Trying',
44
44
  '$(hdrcnt(via))': 1,
45
45
  '$hdr(call-id)': m.collect('sip_call_id'),
46
- $fU: 'a',
47
- $fd: 't',
48
- $tU: 'b',
46
+ $fU: 'alice',
47
+ $fd: 'test.com',
48
+ $tU: 'bob',
49
49
  '$hdr(l)': '0',
50
50
  }),
51
51
  },
@@ -56,7 +56,7 @@ async function test() {
56
56
  sip_call_id: z.store.sip_call_id,
57
57
  }
58
58
 
59
- sip.call.respond(ic.id, 200, 'OK')
59
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
60
60
 
61
61
  await z.wait([
62
62
  {
@@ -81,16 +81,16 @@ async function test() {
81
81
  $rs: '200',
82
82
  $rr: 'OK',
83
83
  '$(hdrcnt(VIA))': 1,
84
- $fU: 'a',
85
- $fd: 't',
86
- $tU: 'b',
84
+ $fU: 'alice',
85
+ $fd: 'test.com',
86
+ $tU: 'bob',
87
87
  '$hdr(content-type)': 'application/sdp',
88
88
  $rb: '!{_}a=sendrecv',
89
89
  }),
90
90
  },
91
91
  ], 1000)
92
92
 
93
- sip.call.reinvite(oc.id, true, 0)
93
+ sip.call.reinvite(oc.id, {hold: true})
94
94
 
95
95
  await z.wait([
96
96
  {
@@ -15,18 +15,27 @@ async function test() {
15
15
 
16
16
  console.log(sip.start((data) => { console.log(data)} ))
17
17
 
18
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
18
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
19
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
20
20
 
21
21
  console.log("t1", t1)
22
22
  console.log("t2", t2)
23
23
 
24
- var server = `${t2.ip}:${t2.port}`
24
+ var server = `${t2.address}:${t2.port}`
25
25
  var domain = 'test1.com'
26
26
 
27
- var a1 = sip.account.create(t1.id, domain, server, 'user1', 'pass1')
27
+ var a1 = sip.account.create(t1.id, {
28
+ domain,
29
+ server,
30
+ username: 'user1',
31
+ password: 'pass1',
32
+ headers: {
33
+ 'X-MyHeader1': 'aaa',
34
+ 'X-MyHeader2': 'bbb',
35
+ },
36
+ })
28
37
 
29
- sip.account.register(a1, true)
38
+ sip.account.register(a1, {auto_register: true})
30
39
 
31
40
  await z.wait([
32
41
  {
@@ -37,6 +46,8 @@ async function test() {
37
46
  $fd: domain,
38
47
  $tU: 'user1',
39
48
  $td: domain,
49
+ '$hdr(X-MyHeader1)': 'aaa',
50
+ '$hdr(X-MyHeader2)': 'bbb',
40
51
  }),
41
52
  },
42
53
  ], 1000)
@@ -53,9 +64,21 @@ async function test() {
53
64
  },
54
65
  ], 1000)
55
66
 
56
- const s1 = sip.subscription_create(t1.id, 'dialog', 'application/dialog-info+xml', '<sip:user1@test1.com>', '<sip:user1@test1.com>', 'sip:park1@test1.com', `sip:${server}`, 'test1.com', 'user1', 'user1')
67
+ const s1 = sip.subscription.create(t1.id, {
68
+ event: 'dialog',
69
+ accept: 'application/dialog-info+xml',
70
+ from_uri: '<sip:user1@test1.com>',
71
+ to_uri: '<sip:user1@test1.com>',
72
+ request_uri: 'sip:park1@test1.com',
73
+ proxy_uri: `sip:${server}`,
74
+ auth: {
75
+ realm: 'test1.com',
76
+ username: 'user1',
77
+ password: 'user1',
78
+ },
79
+ })
57
80
 
58
- sip.subscription_subscribe(s1, 120)
81
+ sip.subscription.subscribe(s1, {expires: 120})
59
82
 
60
83
  await z.wait([
61
84
  {
@@ -15,15 +15,13 @@ async function test() {
15
15
 
16
16
  console.log(sip.start((data) => { console.log(data)} ))
17
17
 
18
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
18
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
19
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
20
20
 
21
21
  console.log("t1", t1)
22
22
  console.log("t2", t2)
23
23
 
24
- flags = 0
25
-
26
- oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
24
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
27
25
 
28
26
  await z.wait([
29
27
  {
@@ -39,9 +37,9 @@ async function test() {
39
37
  $rr: 'Trying',
40
38
  '$(hdrcnt(via))': 1,
41
39
  '$hdr(call-id)': m.collect('sip_call_id'),
42
- $fU: 'a',
43
- $fd: 't',
44
- $tU: 'b',
40
+ $fU: 'alice',
41
+ $fd: 'test.com',
42
+ $tU: 'bob',
45
43
  '$hdr(l)': '0',
46
44
  }),
47
45
  },
@@ -52,7 +50,7 @@ async function test() {
52
50
  sip_call_id: z.store.sip_call_id,
53
51
  }
54
52
 
55
- sip.call.respond(ic.id, 200, 'OK')
53
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
56
54
 
57
55
  await z.wait([
58
56
  {
@@ -77,17 +75,17 @@ async function test() {
77
75
  $rs: '200',
78
76
  $rr: 'OK',
79
77
  '$(hdrcnt(VIA))': 1,
80
- $fU: 'a',
81
- $fd: 't',
82
- $tU: 'b',
78
+ $fU: 'alice',
79
+ $fd: 'test.com',
80
+ $tU: 'bob',
83
81
  '$hdr(content-type)': 'application/sdp',
84
82
  $rb: '!{_}a=sendrecv',
85
83
  }),
86
84
  },
87
85
  ], 1000)
88
86
 
89
- sip.call.send_dtmf(oc.id, '1234', 0)
90
- sip.call.send_dtmf(ic.id, '4321', 1)
87
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
88
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
91
89
 
92
90
  await z.wait([
93
91
  {
@@ -105,7 +103,7 @@ async function test() {
105
103
  ], 2000)
106
104
 
107
105
 
108
- sip.call.reinvite(oc.id, true, 0)
106
+ sip.call.reinvite(oc.id, {hold: true})
109
107
 
110
108
  await z.wait([
111
109
  {
@@ -134,8 +132,8 @@ async function test() {
134
132
  },
135
133
  ], 500)
136
134
 
137
- sip.call.send_dtmf(oc.id, '1234', 0)
138
- sip.call.send_dtmf(ic.id, '4321', 1) // this will not generate event 'dtmf' as the call is on hold
135
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
136
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // this will not generate event 'dtmf' as the call is on hold
139
137
 
140
138
  await z.wait([
141
139
  {
@@ -146,7 +144,7 @@ async function test() {
146
144
  },
147
145
  ], 2000)
148
146
 
149
- sip.call.reinvite(ic.id, false, 0)
147
+ sip.call.reinvite(ic.id, {hold: false})
150
148
 
151
149
  await z.wait([
152
150
  {
@@ -175,8 +173,8 @@ async function test() {
175
173
  },
176
174
  ], 500)
177
175
 
178
- sip.call.send_dtmf(oc.id, '1234', 0)
179
- sip.call.send_dtmf(ic.id, '4321', 1) // this will not generate event 'dtmf' as the call is on hold
176
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
177
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // this will not generate event 'dtmf' as the call is on hold
180
178
 
181
179
  await z.wait([
182
180
  {
@@ -187,7 +185,7 @@ async function test() {
187
185
  },
188
186
  ], 2000)
189
187
 
190
- sip.call.send_request(oc.id, 'INFO')
188
+ sip.call.send_request(oc.id, {method: 'INFO'})
191
189
 
192
190
  await z.wait([
193
191
  {
@@ -208,7 +206,7 @@ async function test() {
208
206
  },
209
207
  ], 500)
210
208
 
211
- sip.call.reinvite(oc.id, false, 0)
209
+ sip.call.reinvite(oc.id, {hold: false})
212
210
 
213
211
  await z.wait([
214
212
  {
@@ -237,8 +235,8 @@ async function test() {
237
235
  },
238
236
  ], 500)
239
237
 
240
- sip.call.send_dtmf(oc.id, '1234', 0)
241
- sip.call.send_dtmf(ic.id, '4321', 1)
238
+ sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
239
+ sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
242
240
 
243
241
  await z.wait([
244
242
  {
@@ -15,15 +15,13 @@ async function test() {
15
15
 
16
16
  console.log(sip.start((data) => { console.log(data)} ))
17
17
 
18
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
18
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
19
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
20
20
 
21
21
  console.log("t1", t1)
22
22
  console.log("t2", t2)
23
23
 
24
- flags = 0
25
-
26
- oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
24
+ oc = sip.call.create(t1.id, {from_uri: 'sip:a@t', to_uri: 'sip:b@127.0.0.1:5092'})
27
25
 
28
26
  await z.wait([
29
27
  {
@@ -52,7 +50,7 @@ async function test() {
52
50
  sip_call_id: z.store.sip_call_id,
53
51
  }
54
52
 
55
- sip.call.respond(ic.id, 200, 'OK')
53
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
56
54
 
57
55
  await z.wait([
58
56
  {
@@ -88,13 +86,11 @@ async function test() {
88
86
 
89
87
  await z.sleep(1000)
90
88
 
91
- var is_sender = true
92
-
93
89
  var in_file = 'samples/artifacts/this-is-never-ok.tiff'
94
90
  var out_file = "received.tiff"
95
91
 
96
- sip.call.start_fax(oc.id, is_sender, in_file)
97
- sip.call.start_fax(ic.id, !is_sender, out_file)
92
+ sip.call.start_fax(oc.id, {is_sender: true, file: in_file})
93
+ sip.call.start_fax(ic.id, {is_sender: false, file: out_file})
98
94
 
99
95
  await z.wait([
100
96
  {
@@ -131,7 +127,7 @@ async function test() {
131
127
  },
132
128
  ], 1000)
133
129
 
134
- console.log(`Success. Fax was transmitted as ${in_file} and received as ${out_file}`)
130
+ console.log(`Success. Fax file ${in_file} was transmitted and received as ${out_file}`)
135
131
 
136
132
  sip.stop()
137
133
  }
package/samples/simple.js CHANGED
@@ -15,15 +15,13 @@ async function test() {
15
15
 
16
16
  console.log(sip.start((data) => { console.log(data)} ))
17
17
 
18
- t1 = sip.transport.create("127.0.0.1", 5090, 1)
19
- t2 = sip.transport.create("127.0.0.1", 5092, 1)
18
+ t1 = sip.transport.create({address: "127.0.0.1", port: 5090, type: 'udp'})
19
+ t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'udp'})
20
20
 
21
21
  console.log("t1", t1)
22
22
  console.log("t2", t2)
23
23
 
24
- flags = 0
25
-
26
- oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
24
+ oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
27
25
 
28
26
  await z.wait([
29
27
  {
@@ -39,9 +37,9 @@ async function test() {
39
37
  $rr: 'Trying',
40
38
  '$(hdrcnt(via))': 1,
41
39
  '$hdr(call-id)': m.collect('sip_call_id'),
42
- $fU: 'a',
43
- $fd: 't',
44
- $tU: 'b',
40
+ $fU: 'alice',
41
+ $fd: 'test.com',
42
+ $tU: 'bob',
45
43
  '$hdr(l)': '0',
46
44
  }),
47
45
  },
@@ -52,7 +50,7 @@ async function test() {
52
50
  sip_call_id: z.store.sip_call_id,
53
51
  }
54
52
 
55
- sip.call.respond(ic.id, 200, 'OK')
53
+ sip.call.respond(ic.id, {code: 200, reason: 'OK'})
56
54
 
57
55
  await z.wait([
58
56
  {
@@ -77,9 +75,9 @@ async function test() {
77
75
  $rs: '200',
78
76
  $rr: 'OK',
79
77
  '$(hdrcnt(VIA))': 1,
80
- $fU: 'a',
81
- $fd: 't',
82
- $tU: 'b',
78
+ $fU: 'alice',
79
+ $fd: 'test.com',
80
+ $tU: 'bob',
83
81
  '$hdr(content-type)': 'application/sdp',
84
82
  $rb: '!{_}a=sendrecv',
85
83
  }),