sip-lab 1.31.0 → 1.33.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.
Files changed (65) hide show
  1. package/README.md +5 -0
  2. package/binding.gyp +1 -0
  3. package/index.js +4 -5
  4. package/package.json +1 -1
  5. package/prebuilds/linux-x64/node.abi102.node +0 -0
  6. package/prebuilds/linux-x64/node.abi108.node +0 -0
  7. package/prebuilds/linux-x64/node.abi111.node +0 -0
  8. package/prebuilds/linux-x64/node.abi115.node +0 -0
  9. package/prebuilds/linux-x64/node.abi120.node +0 -0
  10. package/prebuilds/linux-x64/node.abi88.node +0 -0
  11. package/prebuilds/linux-x64/node.abi93.node +0 -0
  12. package/samples/100_calls.js +7 -4
  13. package/samples/16_audio_streams.js +1 -0
  14. package/samples/183_session_progress.js +1 -0
  15. package/samples/custom_call_id.js +1 -0
  16. package/samples/delayed_media.js +1 -0
  17. package/samples/four_audio_streams_two_refused.js +1 -0
  18. package/samples/g729.js +1 -0
  19. package/samples/media_fields.js +1 -0
  20. package/samples/mrcp_and_audio.js +1 -0
  21. package/samples/mrcp_and_audio.simplified_media.js +1 -0
  22. package/samples/multiple_audio_streams.js +1 -0
  23. package/samples/options.js +1 -0
  24. package/samples/pcma.js +1 -0
  25. package/samples/play_wav_and_speech_recog.bad_transcript.pcmu8000.js +1 -0
  26. package/samples/refer.js +1 -0
  27. package/samples/refuse_telephone_event.js +1 -0
  28. package/samples/register_no_expires.js +1 -0
  29. package/samples/register_subscribe.js +1 -0
  30. package/samples/reinvite_and_dtmf.js +1 -0
  31. package/samples/reinvite_audio_audio.js +1 -0
  32. package/samples/reinvite_with_hold_unhold.js +1 -0
  33. package/samples/rtp_and_srtp.js +1 -0
  34. package/samples/rtp_and_srtp.rtp_refused.js +1 -0
  35. package/samples/rtp_and_srtp.unbalanced_sdp_answer.js.future +1 -0
  36. package/samples/{send_and_receive_bfsk.js.future → send_and_receive_bfsk.js} +25 -27
  37. package/samples/send_and_receive_fax.js +1 -0
  38. package/samples/session_expires.update.js.future +1 -0
  39. package/samples/session_expires.update.with_sipjs-lab.js +64 -47
  40. package/samples/simple.js +1 -0
  41. package/samples/sip_cancel.js +1 -0
  42. package/samples/speech_synth_and_recog.speex16000.js +1 -0
  43. package/samples/srtp.js +1 -0
  44. package/samples/start_play_wav_with_end_of_file_event.js +1 -0
  45. package/samples/start_play_wav_with_no_loop.js +1 -0
  46. package/samples/stop_with_cleanup.js +134 -0
  47. package/samples/tcp.js +1 -0
  48. package/samples/text_to_speech.js +1 -0
  49. package/samples/tls.js +1 -0
  50. package/samples/two_audio_streams.js +1 -0
  51. package/samples/two_audio_streams.port_zero.js +1 -0
  52. package/samples_extra/ws_speech_server.bfsk.js +1 -0
  53. package/samples_extra/ws_speech_server.dtmf.js +1 -0
  54. package/samples_extra/ws_speech_server.google.js +1 -0
  55. package/samples_extra/ws_speech_server.send_bfsk.js +1 -0
  56. package/samples_extra/{ws_speech_server.start_bfsk_detection.js.future → ws_speech_server.start_bfsk_detection.js} +1 -0
  57. package/src/addon.cpp +9 -1
  58. package/src/idmanager.cpp +4 -0
  59. package/src/idmanager.hpp +1 -0
  60. package/src/pjmedia/include/pjmedia/bfsk_det2.h +23 -0
  61. package/src/pjmedia/src/pjmedia/bfsk_det.c +124 -131
  62. package/src/pjmedia/src/pjmedia/bfsk_det2.c +226 -0
  63. package/src/pjmedia/src/pjmedia/ws_speech_port.cpp +16 -1
  64. package/src/sip.cpp +114 -108
  65. package/src/sip.hpp +1 -1
package/README.md CHANGED
@@ -8,6 +8,7 @@ It uses pjproject for SIP and media processing.
8
8
  It permits to:
9
9
  - make audio calls using UDP, TCP and TLS transports
10
10
  - send/receive DTMF inband/RFC2833/INFO.
11
+ - send/receive [BFSK](https://en.wikipedia.org/wiki/Frequency-shift_keying) bits.
11
12
  - play/record audio on a call from/to a wav file
12
13
  - send/receive fax (T.30 only)
13
14
  - send/receive MRCPv2 messages (TCP only, no TLS)
@@ -87,4 +88,8 @@ Although the code in written in *.cpp/*.hpp named files, this is not actually a
87
88
 
88
89
  It is mostly written in C using some C++ facilities.
89
90
 
91
+ ### Release Notes
92
+
93
+ [ReleaseNotes](https://github.com/MayamaTakeshi/sip-lab/blob/master/RELEASE_NOTES.md)
94
+
90
95
 
package/binding.gyp CHANGED
@@ -120,6 +120,7 @@
120
120
  'src/addon.cpp',
121
121
  'src/pjmedia/src/pjmedia/dtmfdet.c',
122
122
  'src/pjmedia/src/pjmedia/bfsk_det.c',
123
+ 'src/pjmedia/src/pjmedia/bfsk_det2.c',
123
124
  'src/pjmedia/src/pjmedia/fax_port.c',
124
125
  'src/pjmedia/src/pjmedia/flite_port.c',
125
126
  'src/pjmedia/src/pjmedia/pocketsphinx_port.c',
package/index.js CHANGED
@@ -6,8 +6,8 @@ var eventEmitter = new events.EventEmitter();
6
6
 
7
7
  process.on('SIGINT', function() {
8
8
  console.log("SIGINT");
9
- var res = addon.shutdown()
10
- process.exit(0)
9
+ var res = addon.shutdown(1)
10
+ process.exit(1)
11
11
  });
12
12
 
13
13
  addon.event_source = eventEmitter
@@ -32,10 +32,9 @@ var timerId = setInterval(() => {
32
32
  }
33
33
  }, 50)
34
34
 
35
- addon.stop = () => {
35
+ addon.stop = (clean_up = false) => {
36
36
  clearInterval(timerId)
37
- var res = addon.shutdown()
38
- process.exit(0)
37
+ var res = addon.shutdown(clean_up ? 1 : 0)
39
38
  }
40
39
 
41
40
  addon.transport = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sip-lab",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
Binary file
Binary file
@@ -80,6 +80,11 @@ async function test() {
80
80
 
81
81
  await z.wait(events, 50000)
82
82
 
83
+ ocs.forEach(oc => {
84
+ sip.call.start_inband_dtmf_detection(oc.id)
85
+ })
86
+
87
+ // first send RFC2833 DTMF digits
83
88
  ocs.forEach(oc => {
84
89
  sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
85
90
  })
@@ -92,10 +97,7 @@ async function test() {
92
97
  media_id: 0,
93
98
  })).value(), 50000)
94
99
 
95
- ocs.forEach(oc => {
96
- sip.call.start_inband_dtmf_detection(oc.id)
97
- })
98
-
100
+ // now send inband DTMF digits
99
101
  z.store.ic_ids.forEach(ic_id => {
100
102
  sip.call.send_dtmf(ic_id, {digits: '4321', mode: 1})
101
103
  })
@@ -139,6 +141,7 @@ async function test() {
139
141
  console.log("Success")
140
142
 
141
143
  sip.stop()
144
+ process.exit(0)
142
145
  }
143
146
 
144
147
 
@@ -139,6 +139,7 @@ async function test() {
139
139
  console.log("Success")
140
140
 
141
141
  sip.stop()
142
+ process.exit(0)
142
143
  }
143
144
 
144
145
 
@@ -374,6 +374,7 @@ async function test() {
374
374
  console.log("Success")
375
375
 
376
376
  sip.stop()
377
+ process.exit(0)
377
378
  }
378
379
 
379
380
 
@@ -208,6 +208,7 @@ async function test() {
208
208
  console.log("Success")
209
209
 
210
210
  sip.stop()
211
+ process.exit(0)
211
212
  }
212
213
 
213
214
 
@@ -315,6 +315,7 @@ async function test() {
315
315
  console.log("Success")
316
316
 
317
317
  sip.stop()
318
+ process.exit(0)
318
319
  }
319
320
 
320
321
  test()
@@ -314,6 +314,7 @@ async function test() {
314
314
  console.log("Success")
315
315
 
316
316
  sip.stop()
317
+ process.exit(0)
317
318
  }
318
319
 
319
320
 
package/samples/g729.js CHANGED
@@ -198,6 +198,7 @@ async function test() {
198
198
  console.log("Success")
199
199
 
200
200
  sip.stop()
201
+ process.exit(0)
201
202
  }
202
203
 
203
204
  test()
@@ -179,6 +179,7 @@ async function test() {
179
179
  console.log("Success")
180
180
 
181
181
  sip.stop()
182
+ process.exit(0)
182
183
  }
183
184
 
184
185
 
@@ -411,6 +411,7 @@ async function test() {
411
411
  console.log("Success")
412
412
 
413
413
  sip.stop()
414
+ process.exit(0)
414
415
  }
415
416
 
416
417
 
@@ -254,6 +254,7 @@ async function test() {
254
254
  console.log("Success")
255
255
 
256
256
  sip.stop()
257
+ process.exit(0)
257
258
  }
258
259
 
259
260
 
@@ -144,6 +144,7 @@ async function test() {
144
144
  console.log("Success")
145
145
 
146
146
  sip.stop()
147
+ process.exit(0)
147
148
  }
148
149
 
149
150
 
@@ -72,6 +72,7 @@ async function test() {
72
72
  console.log("Success")
73
73
 
74
74
  sip.stop()
75
+ process.exit(0)
75
76
  }
76
77
 
77
78
 
package/samples/pcma.js CHANGED
@@ -197,6 +197,7 @@ async function test() {
197
197
  console.log("Success")
198
198
 
199
199
  sip.stop()
200
+ process.exit(0)
200
201
  }
201
202
 
202
203
  test()
@@ -148,6 +148,7 @@ async function test() {
148
148
  console.log("Success")
149
149
 
150
150
  sip.stop()
151
+ process.exit(0)
151
152
  }
152
153
 
153
154
 
package/samples/refer.js CHANGED
@@ -206,6 +206,7 @@ async function test() {
206
206
  console.log("Success")
207
207
 
208
208
  sip.stop()
209
+ process.exit(0)
209
210
  }
210
211
 
211
212
 
@@ -148,6 +148,7 @@ async function test() {
148
148
  console.log("Success")
149
149
 
150
150
  sip.stop()
151
+ process.exit(0)
151
152
  }
152
153
 
153
154
 
@@ -72,6 +72,7 @@ async function test() {
72
72
  console.log("Success")
73
73
 
74
74
  sip.stop()
75
+ process.exit(0)
75
76
  }
76
77
 
77
78
 
@@ -189,6 +189,7 @@ async function test() {
189
189
  console.log("Success")
190
190
 
191
191
  sip.stop()
192
+ process.exit(0)
192
193
  }
193
194
 
194
195
 
@@ -435,6 +435,7 @@ async function test() {
435
435
  console.log("Success")
436
436
 
437
437
  sip.stop()
438
+ process.exit(0)
438
439
  }
439
440
 
440
441
 
@@ -301,6 +301,7 @@ async function test() {
301
301
  console.log("Success")
302
302
 
303
303
  sip.stop()
304
+ process.exit(0)
304
305
  }
305
306
 
306
307
 
@@ -393,6 +393,7 @@ async function test() {
393
393
  console.log("Success")
394
394
 
395
395
  sip.stop()
396
+ process.exit(0)
396
397
  }
397
398
 
398
399
 
@@ -452,6 +452,7 @@ async function test() {
452
452
  console.log("Success")
453
453
 
454
454
  sip.stop()
455
+ process.exit(0)
455
456
  }
456
457
 
457
458
 
@@ -416,6 +416,7 @@ async function test() {
416
416
  console.log("Success")
417
417
 
418
418
  sip.stop()
419
+ process.exit(0)
419
420
  }
420
421
 
421
422
 
@@ -178,6 +178,7 @@ a=crypto:1 AES_256_CM_HMAC_SHA1_80 inline:s6nwVuVNxwupG0Cls+/4X4L46Mx/fqoEMolllU
178
178
  console.log("Success")
179
179
 
180
180
  sip.stop()
181
+ process.exit(0)
181
182
  }
182
183
 
183
184
 
@@ -71,11 +71,9 @@ async function test() {
71
71
  {
72
72
  type: 'audio',
73
73
  local: {
74
- port: 10000,
75
74
  mode: 'sendrecv'
76
75
  },
77
76
  remote: {
78
- port: 10002,
79
77
  mode: 'sendrecv'
80
78
  },
81
79
  },
@@ -89,11 +87,9 @@ async function test() {
89
87
  {
90
88
  type: 'audio',
91
89
  local: {
92
- port: 10002,
93
90
  mode: 'sendrecv'
94
91
  },
95
92
  remote: {
96
- port: 10000,
97
93
  mode: 'sendrecv'
98
94
  },
99
95
  }
@@ -104,33 +100,34 @@ async function test() {
104
100
  sip.call.start_record_wav(oc.id, {file: 'oc.wav'})
105
101
  sip.call.start_record_wav(ic.id, {file: 'ic.wav'})
106
102
 
107
- await z.sleep(100)
108
-
109
- sip.call.start_bfsk_detection(oc.id, {freq_zero: 880, freq_one: 1280})
110
- //sip.call.start_bfsk_detection(ic.id, {freq_zero: 880, freq_one: 1280})
103
+ sip.call.start_bfsk_detection(oc.id, {freq_zero: 500, freq_one: 2000})
104
+ sip.call.start_bfsk_detection(ic.id, {freq_zero: 500, freq_one: 2000})
111
105
 
112
106
  oc_bits = '1010'
113
107
  ic_bits = '1100'
114
108
 
115
- sip.call.send_bfsk(ic.id, {bits: ic_bits, freq_zero: 880, freq_one: 1280})
116
- //sip.call.send_bfsk(oc.id, {bits: oc_bits, freq_zero: 880, freq_one: 1280})
117
-
118
- await z.wait([
119
- {
120
- event: 'bfsk',
121
- call_id: ic.id,
122
- bits: oc_bits,
123
- media_id: 0
124
- },
125
- {
126
- event: 'bfsk',
127
- call_id: oc.id,
128
- bits: ic_bits,
129
- media_id: 0
130
- },
131
- ], 10000)
132
-
133
- await z.sleep(1000)
109
+ // wait a little for voice path to open
110
+ await z.sleep(50)
111
+
112
+ for(var i=0 ; i<5 ; i++) {
113
+ sip.call.send_bfsk(ic.id, {bits: ic_bits, freq_zero: 500, freq_one: 2000})
114
+ sip.call.send_bfsk(oc.id, {bits: oc_bits, freq_zero: 500, freq_one: 2000})
115
+
116
+ await z.wait([
117
+ {
118
+ event: 'bfsk',
119
+ call_id: ic.id,
120
+ bits: oc_bits,
121
+ media_id: 0
122
+ },
123
+ {
124
+ event: 'bfsk',
125
+ call_id: oc.id,
126
+ bits: ic_bits,
127
+ media_id: 0
128
+ },
129
+ ], 10000)
130
+ }
134
131
 
135
132
  sip.call.stop_record_wav(oc.id)
136
133
  sip.call.stop_record_wav(ic.id)
@@ -160,6 +157,7 @@ async function test() {
160
157
  console.log("Success")
161
158
 
162
159
  sip.stop()
160
+ process.exit(0)
163
161
  }
164
162
 
165
163
 
@@ -117,6 +117,7 @@ async function test() {
117
117
  console.log(`Success. Fax file ${in_file} was transmitted and received as ${out_file}`)
118
118
 
119
119
  sip.stop()
120
+ process.exit(0)
120
121
  }
121
122
 
122
123
 
@@ -257,6 +257,7 @@ async function test() {
257
257
  console.log("Success")
258
258
 
259
259
  sip.stop()
260
+ process.exit(0)
260
261
  }
261
262
 
262
263
 
@@ -5,7 +5,7 @@ const sip_msg = require('sip-matching')
5
5
  const uuid = require('uuid')
6
6
 
7
7
  const sipjs = require('sipjs-lab')
8
- const {endpoint, dialog} = require('sipjs-lab')
8
+ const {endpoint, dialog, sip_msg: sipjs_sip_msg} = require('sipjs-lab')
9
9
 
10
10
  // here we create our Zeq instance
11
11
 
@@ -28,8 +28,6 @@ async function test() {
28
28
 
29
29
  const address = "127.0.0.1"
30
30
 
31
- const t1 = sip.transport.create({address})
32
-
33
31
  const e1_port = 7070
34
32
  const e1 = endpoint.create({
35
33
  address,
@@ -37,6 +35,11 @@ async function test() {
37
35
  publicAddress: address
38
36
  })
39
37
 
38
+ // hack to not lose first INVITE
39
+ await z.sleep(0)
40
+
41
+ const t1 = sip.transport.create({address})
42
+
40
43
  const sip_call_id = uuid.v4()
41
44
 
42
45
  var oc = sip.call.create(t1.id, {
@@ -46,28 +49,19 @@ async function test() {
46
49
  'Call-ID': sip_call_id,
47
50
  'Supported': 'timer',
48
51
  'Min-SE': '180',
49
- 'Session-Expires': '180',
52
+ 'Session-Expires': '180;refresher=uac',
50
53
  },
51
54
  })
52
55
 
53
56
  await z.wait([
54
57
  {
55
58
  source: 'sip_endpoint',
56
- req: m.collect('req', {
57
- method: 'INVITE',
58
- uri: `sip:bob@${address}:${e1_port}`,
59
- headers: {
60
- from: {
61
- uri: 'sip:alice@test.com',
62
- },
63
- to: {
64
- uri: `sip:bob@${address}`,
65
- },
66
- supported: 'timer',
67
- 'min-se': '180',
68
- 'session-expires': '180',
69
- },
70
- }),
59
+ req: m.collect('req', sipjs_sip_msg({
60
+ $rm: 'INVITE',
61
+ hdr_supported: 'timer',
62
+ hdr_min_se: '180',
63
+ hdr_session_expires: '180;refresher=uac',
64
+ })),
71
65
  event: 'dialog_offer',
72
66
  dialog_id: m.collect('dialog_id'),
73
67
  },
@@ -107,8 +101,6 @@ async function test() {
107
101
 
108
102
  delete z.store.dialog_id
109
103
 
110
- await z.sleep(1000)
111
-
112
104
  oc = sip.call.create(t1.id, {
113
105
  from_uri: 'sip:alice@test.com',
114
106
  to_uri: `sip:bob@${address}:${e1_port}`,
@@ -116,7 +108,7 @@ async function test() {
116
108
  'Call-ID': sip_call_id,
117
109
  'Supported': 'timer',
118
110
  'Min-SE': '300',
119
- 'Session-Expires': '300',
111
+ 'Session-Expires': '300;refresher=uac',
120
112
  },
121
113
  })
122
114
 
@@ -125,18 +117,12 @@ async function test() {
125
117
  await z.wait([
126
118
  {
127
119
  source: 'sip_endpoint',
128
- req: m.collect('req', {
129
- method: 'INVITE',
130
- uri: `sip:bob@${address}:${e1_port}`,
131
- headers: {
132
- from: {
133
- uri: 'sip:alice@test.com',
134
- },
135
- to: {
136
- uri: `sip:bob@${address}`,
137
- },
138
- },
139
- }),
120
+ req: m.collect('req', sipjs_sip_msg({
121
+ $rm: 'INVITE',
122
+ hdr_supported: 'timer',
123
+ hdr_min_se: '300',
124
+ hdr_session_expires: '300;refresher=uac'
125
+ })),
140
126
  event: 'dialog_offer',
141
127
  dialog_id: m.collect('dialog_id'),
142
128
  },
@@ -154,6 +140,36 @@ a=rtpmap:101 telephone-event/8000
154
140
  a=fmtp:101 0-15
155
141
  a=ptime:20`.replace(/\n/g, "\r\n")
156
142
 
143
+ dialog.send_reply(
144
+ z.store.dialog_id,
145
+ z.store.req,
146
+ {
147
+ status: 183,
148
+ reason: 'Session Progress',
149
+ headers: {
150
+ 'content-type': 'application/sdp',
151
+ },
152
+ content: sdp_answer,
153
+ }
154
+ )
155
+
156
+ await z.wait([
157
+ {
158
+ event: 'response',
159
+ call_id: oc.id,
160
+ method: 'INVITE',
161
+ msg: sip_msg({
162
+ $rs: '183',
163
+ $rr: 'Session Progress',
164
+ }),
165
+ },
166
+ {
167
+ event: 'media_update',
168
+ call_id: oc.id,
169
+ status: 'ok',
170
+ },
171
+ ], 1000)
172
+
157
173
  dialog.send_reply(
158
174
  z.store.dialog_id,
159
175
  z.store.req,
@@ -199,14 +215,16 @@ a=ptime:20`.replace(/\n/g, "\r\n")
199
215
  },
200
216
  ], 1000)
201
217
 
202
-
203
218
  for(var i=0 ; i<5 ; i++) {
204
219
 
220
+ // sleep here as much as you like
221
+ await z.sleep(0)
222
+
205
223
  sip.call.update(oc.id, {
206
224
  headers: {
207
225
  'Supported': 'timer',
208
226
  'Min-SE': '300',
209
- 'Session-Expires': '300',
227
+ 'Session-Expires': '300;refresher=uac',
210
228
  },
211
229
  })
212
230
 
@@ -215,14 +233,12 @@ a=ptime:20`.replace(/\n/g, "\r\n")
215
233
  await z.wait([
216
234
  {
217
235
  source: 'sip_endpoint',
218
- req: m.collect('req', {
219
- method: 'UPDATE',
220
- headers: {
221
- 'supported': 'timer',
222
- 'min-se': '300',
223
- 'session-expires': '300',
224
- },
225
- }),
236
+ req: m.collect('req', sipjs_sip_msg({
237
+ $rm: 'UPDATE',
238
+ hdr_supported: 'timer',
239
+ hdr_min_se: '300',
240
+ hdr_session_expires: '300;refresher=uac'
241
+ })),
226
242
  event: 'in_dialog_request',
227
243
  dialog_id: z.store.dialog_id
228
244
  },
@@ -266,9 +282,9 @@ a=ptime:20`.replace(/\n/g, "\r\n")
266
282
  await z.wait([
267
283
  {
268
284
  source: 'sip_endpoint',
269
- req: m.collect('req', {
270
- method: 'BYE',
271
- }),
285
+ req: m.collect('req', sipjs_sip_msg({
286
+ $rm: 'BYE',
287
+ })),
272
288
  },
273
289
  ], 1000)
274
290
 
@@ -302,6 +318,7 @@ a=ptime:20`.replace(/\n/g, "\r\n")
302
318
  console.log("Success")
303
319
 
304
320
  sip.stop()
321
+ process.exit(0)
305
322
  }
306
323
 
307
324
  test()
package/samples/simple.js CHANGED
@@ -170,6 +170,7 @@ async function test() {
170
170
  console.log("Success")
171
171
 
172
172
  sip.stop()
173
+ process.exit(0)
173
174
  }
174
175
 
175
176
 
@@ -104,6 +104,7 @@ async function test() {
104
104
  console.log("Success")
105
105
 
106
106
  sip.stop()
107
+ process.exit(0)
107
108
  }
108
109
 
109
110
  test()
@@ -154,6 +154,7 @@ async function test() {
154
154
  console.log("Success")
155
155
 
156
156
  sip.stop()
157
+ process.exit(0)
157
158
  }
158
159
 
159
160
 
package/samples/srtp.js CHANGED
@@ -330,6 +330,7 @@ async function test() {
330
330
  console.log("Success")
331
331
 
332
332
  sip.stop()
333
+ process.exit(0)
333
334
  }
334
335
 
335
336