sip-lab 1.38.0 → 1.40.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/DEV.md +2 -2
- package/binding.gyp +6 -1
- package/build_deps.sh +2 -1
- package/index.js +2 -0
- package/package.json +2 -2
- package/prebuilds/linux-x64/node.abi102.node +0 -0
- package/prebuilds/linux-x64/node.abi108.node +0 -0
- package/prebuilds/linux-x64/node.abi111.node +0 -0
- package/prebuilds/linux-x64/node.abi115.node +0 -0
- package/prebuilds/linux-x64/node.abi120.node +0 -0
- package/prebuilds/linux-x64/node.abi88.node +0 -0
- package/prebuilds/linux-x64/node.abi93.node +0 -0
- package/runtests +112 -36
- package/samples/gsm.js +230 -0
- package/samples/ilbc.js +230 -0
- package/samples/mrcp_and_audio.no_rest_between_msgs.js +254 -0
- package/samples/opus.wideband.js +247 -0
- package/samples/secure_websocket.js +156 -0
- package/samples/secure_websocket_opus_srtp_ice.js +170 -0
- package/samples/simple.js +26 -0
- package/samples/t +239 -0
- package/samples/websocket.js +156 -0
- package/src/addon.cpp +27 -0
- package/src/pjsip/include/pjsip/sip_transport_ws.h +89 -0
- package/src/pjsip/src/pjsip/sip_transport_ws.c +867 -0
- package/src/sip.cpp +497 -61
- package/src/sip.hpp +2 -0
- package/samples/ic.wav +0 -0
- package/samples/oc.wav +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
var sip = require ('../index.js')
|
|
2
|
+
var Zeq = require('@mayama/zeq')
|
|
3
|
+
var z = new Zeq()
|
|
4
|
+
var m = require('data-matching')
|
|
5
|
+
var sip_msg = require('sip-matching')
|
|
6
|
+
var sdp = require('sdp-matching')
|
|
7
|
+
|
|
8
|
+
var assert = require('assert')
|
|
9
|
+
|
|
10
|
+
async function test() {
|
|
11
|
+
//sip.set_log_level(6)
|
|
12
|
+
sip.dtmf_aggregation_on(500)
|
|
13
|
+
|
|
14
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
15
|
+
var e = evt.args[0]
|
|
16
|
+
return e
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
console.log(sip.start((data) => { console.log(data)} ))
|
|
20
|
+
|
|
21
|
+
t1 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
|
|
22
|
+
t2 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
|
|
23
|
+
|
|
24
|
+
console.log("t1", t1)
|
|
25
|
+
console.log("t2", t2)
|
|
26
|
+
|
|
27
|
+
console.log(sip.get_codecs())
|
|
28
|
+
|
|
29
|
+
sip.set_codecs("opus/48000/2:128")
|
|
30
|
+
|
|
31
|
+
sip.set_opus_config({
|
|
32
|
+
sample_rate: 48000,
|
|
33
|
+
channel_cnt: 2,
|
|
34
|
+
bit_rate: 16000,
|
|
35
|
+
packet_loss: 77,
|
|
36
|
+
complexity: 9,
|
|
37
|
+
cbr: true,
|
|
38
|
+
frm_ptime: 20
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
flags = 0
|
|
42
|
+
|
|
43
|
+
oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
|
|
44
|
+
|
|
45
|
+
await z.wait([
|
|
46
|
+
{
|
|
47
|
+
event: "incoming_call",
|
|
48
|
+
call_id: m.collect("call_id"),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
event: 'response',
|
|
52
|
+
call_id: oc.id,
|
|
53
|
+
method: 'INVITE',
|
|
54
|
+
msg: sip_msg({
|
|
55
|
+
$rs: '100',
|
|
56
|
+
$rr: 'Trying',
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
], 1000)
|
|
60
|
+
|
|
61
|
+
ic = {
|
|
62
|
+
id: z.$call_id,
|
|
63
|
+
sip_call_id: z.$sip_call_id,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
67
|
+
|
|
68
|
+
await z.wait([
|
|
69
|
+
{
|
|
70
|
+
event: 'media_update',
|
|
71
|
+
call_id: oc.id,
|
|
72
|
+
status: 'ok',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
event: 'media_update',
|
|
76
|
+
call_id: ic.id,
|
|
77
|
+
status: 'ok',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
event: 'response',
|
|
81
|
+
call_id: oc.id,
|
|
82
|
+
method: 'INVITE',
|
|
83
|
+
msg: sip_msg({
|
|
84
|
+
$rs: '200',
|
|
85
|
+
$rr: 'OK',
|
|
86
|
+
'hdr_content_type': 'application/sdp',
|
|
87
|
+
$rb: '!{_}a=sendrecv!{_}',
|
|
88
|
+
}),
|
|
89
|
+
},
|
|
90
|
+
], 1000)
|
|
91
|
+
|
|
92
|
+
sip.call.start_record_wav(oc.id, {file: './oc.wav'})
|
|
93
|
+
sip.call.start_record_wav(ic.id, {file: './ic.wav'})
|
|
94
|
+
|
|
95
|
+
sip.call.start_play_wav(oc.id, {file: 'samples/artifacts/hello_good_morning.wav', end_of_file_event: true, no_loop: true})
|
|
96
|
+
sip.call.start_play_wav(ic.id, {file: 'samples/artifacts/hello_good_morning.wav', end_of_file_event: true, no_loop: true})
|
|
97
|
+
|
|
98
|
+
await z.wait([
|
|
99
|
+
{
|
|
100
|
+
event: 'end_of_file',
|
|
101
|
+
call_id: oc.id,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
event: 'end_of_file',
|
|
105
|
+
call_id: ic.id,
|
|
106
|
+
},
|
|
107
|
+
], 5000)
|
|
108
|
+
|
|
109
|
+
sip.call.reinvite(oc.id)
|
|
110
|
+
|
|
111
|
+
await z.wait([
|
|
112
|
+
{
|
|
113
|
+
event: 'reinvite',
|
|
114
|
+
call_id: ic.id
|
|
115
|
+
},
|
|
116
|
+
], 1000)
|
|
117
|
+
|
|
118
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
119
|
+
|
|
120
|
+
await z.wait([
|
|
121
|
+
{
|
|
122
|
+
event: 'response',
|
|
123
|
+
call_id: oc.id,
|
|
124
|
+
method: 'INVITE',
|
|
125
|
+
msg: sip_msg({
|
|
126
|
+
$rs: '100',
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
event: 'response',
|
|
131
|
+
call_id: oc.id,
|
|
132
|
+
method: 'INVITE',
|
|
133
|
+
msg: sip_msg({
|
|
134
|
+
$rs: '200',
|
|
135
|
+
$rr: 'OK',
|
|
136
|
+
$rb: '!{_}a=sendrecv!{_}',
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
event: 'media_update',
|
|
141
|
+
call_id: oc.id,
|
|
142
|
+
status: 'ok',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
event: 'media_update',
|
|
146
|
+
call_id: ic.id,
|
|
147
|
+
status: 'ok',
|
|
148
|
+
},
|
|
149
|
+
], 500)
|
|
150
|
+
|
|
151
|
+
sip.call.reinvite(oc.id, false, 0)
|
|
152
|
+
|
|
153
|
+
await z.wait([
|
|
154
|
+
{
|
|
155
|
+
event: 'reinvite',
|
|
156
|
+
call_id: ic.id
|
|
157
|
+
},
|
|
158
|
+
], 1000)
|
|
159
|
+
|
|
160
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
161
|
+
|
|
162
|
+
await z.wait([
|
|
163
|
+
{
|
|
164
|
+
event: 'response',
|
|
165
|
+
call_id: oc.id,
|
|
166
|
+
method: 'INVITE',
|
|
167
|
+
msg: sip_msg({
|
|
168
|
+
$rs: '100',
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
event: 'response',
|
|
173
|
+
call_id: oc.id,
|
|
174
|
+
method: 'INVITE',
|
|
175
|
+
msg: sip_msg({
|
|
176
|
+
$rs: '200',
|
|
177
|
+
$rr: 'OK',
|
|
178
|
+
$rb: '!{_}a=sendrecv!{_}',
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
event: 'media_update',
|
|
183
|
+
call_id: oc.id,
|
|
184
|
+
status: 'ok',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
event: 'media_update',
|
|
188
|
+
call_id: ic.id,
|
|
189
|
+
status: 'ok',
|
|
190
|
+
},
|
|
191
|
+
], 500)
|
|
192
|
+
|
|
193
|
+
oc_stat = sip.call.get_stream_stat(oc.id, {media_id: 0})
|
|
194
|
+
ic_stat = sip.call.get_stream_stat(ic.id, {media_id: 0})
|
|
195
|
+
|
|
196
|
+
console.log(oc_stat)
|
|
197
|
+
console.log(ic_stat)
|
|
198
|
+
|
|
199
|
+
oc_stat = JSON.parse(oc_stat)
|
|
200
|
+
ic_stat = JSON.parse(ic_stat)
|
|
201
|
+
|
|
202
|
+
assert(oc_stat.CodecInfo == 'opus/48000/2')
|
|
203
|
+
assert(ic_stat.CodecInfo == 'opus/48000/2')
|
|
204
|
+
|
|
205
|
+
await z.sleep(100)
|
|
206
|
+
|
|
207
|
+
sip.call.send_dtmf(oc.id, {digits: '12', mode: 1})
|
|
208
|
+
sip.call.send_dtmf(ic.id, {digits: '21', mode: 1})
|
|
209
|
+
|
|
210
|
+
await z.sleep(1000)
|
|
211
|
+
|
|
212
|
+
sip.call.stop_record_wav(oc.id)
|
|
213
|
+
sip.call.stop_record_wav(ic.id)
|
|
214
|
+
|
|
215
|
+
sip.call.terminate(oc.id)
|
|
216
|
+
|
|
217
|
+
await z.wait([
|
|
218
|
+
{
|
|
219
|
+
event: 'call_ended',
|
|
220
|
+
call_id: oc.id,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
event: 'call_ended',
|
|
224
|
+
call_id: ic.id,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
event: 'response',
|
|
228
|
+
call_id: oc.id,
|
|
229
|
+
method: 'BYE',
|
|
230
|
+
msg: sip_msg({
|
|
231
|
+
$rs: '200',
|
|
232
|
+
$rr: 'OK',
|
|
233
|
+
}),
|
|
234
|
+
},
|
|
235
|
+
], 1000)
|
|
236
|
+
|
|
237
|
+
console.log("Success")
|
|
238
|
+
|
|
239
|
+
sip.stop()
|
|
240
|
+
process.exit(0)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
test()
|
|
244
|
+
.catch(e => {
|
|
245
|
+
console.error(e)
|
|
246
|
+
process.exit(1)
|
|
247
|
+
})
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const sip = require('../index.js')
|
|
2
|
+
const Zeq = require('@mayama/zeq')
|
|
3
|
+
const m = require('data-matching')
|
|
4
|
+
const sip_msg = require('sip-matching')
|
|
5
|
+
|
|
6
|
+
var z = new Zeq()
|
|
7
|
+
|
|
8
|
+
async function test() {
|
|
9
|
+
sip.dtmf_aggregation_on(500)
|
|
10
|
+
|
|
11
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
12
|
+
return evt.args[0]
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
sip.set_codecs("pcmu/8000/1:128,pcma/8000/1:128")
|
|
16
|
+
|
|
17
|
+
console.log(sip.start((data) => { console.log(data) }))
|
|
18
|
+
|
|
19
|
+
// Create a WSS server transport (secure WebSocket listener)
|
|
20
|
+
const t2 = sip.transport.create({
|
|
21
|
+
address: "127.0.0.1",
|
|
22
|
+
port: 6062,
|
|
23
|
+
type: "wss",
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// Create a WSS client transport connecting to our server
|
|
27
|
+
const t1 = sip.transport.create({
|
|
28
|
+
address: "127.0.0.1",
|
|
29
|
+
type: "wss",
|
|
30
|
+
ws_url: "wss://127.0.0.1:6062/sip",
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
console.log("t1", t1)
|
|
34
|
+
console.log("t2", t2)
|
|
35
|
+
|
|
36
|
+
// Make the call from t1 to t2 over Secure WebSocket
|
|
37
|
+
const oc = sip.call.create(t1.id, {
|
|
38
|
+
from_uri: 'sip:alice@test.com',
|
|
39
|
+
to_uri: 'sip:bob@127.0.0.1:6062',
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// Wait for the call to arrive at t2 and 100 Trying response at t1
|
|
43
|
+
await z.wait([
|
|
44
|
+
{
|
|
45
|
+
event: "incoming_call",
|
|
46
|
+
call_id: m.collect("call_id"),
|
|
47
|
+
transport_id: t2.id,
|
|
48
|
+
msg: sip_msg({
|
|
49
|
+
$rU: 'bob',
|
|
50
|
+
$fU: 'alice',
|
|
51
|
+
$tU: 'bob',
|
|
52
|
+
$fd: 'test.com',
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
event: 'response',
|
|
57
|
+
call_id: oc.id,
|
|
58
|
+
method: 'INVITE',
|
|
59
|
+
msg: sip_msg({
|
|
60
|
+
$rs: '100',
|
|
61
|
+
$rr: 'Trying',
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
], 2000)
|
|
65
|
+
|
|
66
|
+
const ic = {
|
|
67
|
+
id: z.$call_id,
|
|
68
|
+
sip_call_id: z.$sip_call_id,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Answer the call at t2 side
|
|
72
|
+
sip.call.respond(ic.id, {
|
|
73
|
+
code: 200,
|
|
74
|
+
reason: 'OK',
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// Wait for 200 OK at t1 side and media setups
|
|
78
|
+
await z.wait([
|
|
79
|
+
{
|
|
80
|
+
event: 'response',
|
|
81
|
+
call_id: oc.id,
|
|
82
|
+
method: 'INVITE',
|
|
83
|
+
msg: sip_msg({
|
|
84
|
+
$rs: '200',
|
|
85
|
+
$rr: 'OK',
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
event: 'media_update',
|
|
90
|
+
call_id: oc.id,
|
|
91
|
+
status: 'ok',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
event: 'media_update',
|
|
95
|
+
call_id: ic.id,
|
|
96
|
+
status: 'ok',
|
|
97
|
+
},
|
|
98
|
+
], 2000)
|
|
99
|
+
|
|
100
|
+
sip.call.start_inband_dtmf_detection(oc.id)
|
|
101
|
+
sip.call.start_inband_dtmf_detection(ic.id)
|
|
102
|
+
|
|
103
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 1})
|
|
104
|
+
sip.call.send_dtmf(ic.id, {digits: '1234', mode: 1})
|
|
105
|
+
|
|
106
|
+
await z.wait([
|
|
107
|
+
{
|
|
108
|
+
event: 'dtmf',
|
|
109
|
+
call_id: ic.id,
|
|
110
|
+
digits: '1234',
|
|
111
|
+
mode: 1,
|
|
112
|
+
media_id: 0,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
event: 'dtmf',
|
|
116
|
+
call_id: oc.id,
|
|
117
|
+
digits: '1234',
|
|
118
|
+
mode: 1,
|
|
119
|
+
media_id: 0,
|
|
120
|
+
},
|
|
121
|
+
], 2000)
|
|
122
|
+
|
|
123
|
+
// Terminate the call from t1 side
|
|
124
|
+
sip.call.terminate(oc.id)
|
|
125
|
+
|
|
126
|
+
// Wait for call termination
|
|
127
|
+
await z.wait([
|
|
128
|
+
{
|
|
129
|
+
event: 'response',
|
|
130
|
+
call_id: oc.id,
|
|
131
|
+
method: 'BYE',
|
|
132
|
+
msg: sip_msg({
|
|
133
|
+
$rs: '200',
|
|
134
|
+
$rr: 'OK',
|
|
135
|
+
}),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
event: 'call_ended',
|
|
139
|
+
call_id: oc.id,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
event: 'call_ended',
|
|
143
|
+
call_id: ic.id,
|
|
144
|
+
},
|
|
145
|
+
], 2000)
|
|
146
|
+
|
|
147
|
+
console.log("Secure WebSocket test successful")
|
|
148
|
+
|
|
149
|
+
sip.stop()
|
|
150
|
+
process.exit(0)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
test().catch(e => {
|
|
154
|
+
console.error(e)
|
|
155
|
+
process.exit(1)
|
|
156
|
+
})
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const sip = require('../index.js')
|
|
2
|
+
const Zeq = require('@mayama/zeq')
|
|
3
|
+
const m = require('data-matching')
|
|
4
|
+
const sip_msg = require('sip-matching')
|
|
5
|
+
const assert = require('assert')
|
|
6
|
+
|
|
7
|
+
var z = new Zeq()
|
|
8
|
+
|
|
9
|
+
async function test() {
|
|
10
|
+
sip.dtmf_aggregation_on(500)
|
|
11
|
+
|
|
12
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
13
|
+
return evt.args[0]
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
sip.set_codecs("opus/48000/2:128,pcmu/8000/1:128")
|
|
17
|
+
|
|
18
|
+
console.log(sip.start((data) => { console.log(data) }))
|
|
19
|
+
|
|
20
|
+
// Create a WSS server transport (secure WebSocket listener)
|
|
21
|
+
const t2 = sip.transport.create({
|
|
22
|
+
address: "127.0.0.1",
|
|
23
|
+
port: 6062,
|
|
24
|
+
type: "wss",
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Create a WSS client transport connecting to our server
|
|
28
|
+
const t1 = sip.transport.create({
|
|
29
|
+
address: "127.0.0.1",
|
|
30
|
+
type: "wss",
|
|
31
|
+
ws_url: "wss://127.0.0.1:6062/sip",
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
console.log("t1", t1)
|
|
35
|
+
console.log("t2", t2)
|
|
36
|
+
|
|
37
|
+
// Make the call from t1 to t2 over Secure WebSocket
|
|
38
|
+
// Use OPUS codec with SRTP and ICE
|
|
39
|
+
const oc = sip.call.create(t1.id, {
|
|
40
|
+
from_uri: 'sip:alice@test.com',
|
|
41
|
+
to_uri: 'sip:bob@127.0.0.1:6062',
|
|
42
|
+
media: [{type: "audio", secure: true, ice: true}],
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Wait for the call to arrive at t2 and 100 Trying response at t1
|
|
46
|
+
await z.wait([
|
|
47
|
+
{
|
|
48
|
+
event: "incoming_call",
|
|
49
|
+
call_id: m.collect("call_id"),
|
|
50
|
+
transport_id: t2.id,
|
|
51
|
+
msg: sip_msg({
|
|
52
|
+
$rU: 'bob',
|
|
53
|
+
$fU: 'alice',
|
|
54
|
+
$tU: 'bob',
|
|
55
|
+
$fd: 'test.com',
|
|
56
|
+
})
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
event: 'response',
|
|
60
|
+
call_id: oc.id,
|
|
61
|
+
method: 'INVITE',
|
|
62
|
+
msg: sip_msg({
|
|
63
|
+
$rs: '100',
|
|
64
|
+
$rr: 'Trying',
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
], 2000)
|
|
68
|
+
|
|
69
|
+
const ic = {
|
|
70
|
+
id: z.$call_id,
|
|
71
|
+
sip_call_id: z.$sip_call_id,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Answer the call at t2 side with matching media config
|
|
75
|
+
sip.call.respond(ic.id, {
|
|
76
|
+
code: 200,
|
|
77
|
+
reason: 'OK',
|
|
78
|
+
media: [{type: "audio", secure: true, ice: true}],
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// Wait for 200 OK at t1 side and media setups
|
|
82
|
+
await z.wait([
|
|
83
|
+
{
|
|
84
|
+
event: 'response',
|
|
85
|
+
call_id: oc.id,
|
|
86
|
+
method: 'INVITE',
|
|
87
|
+
msg: sip_msg({
|
|
88
|
+
$rs: '200',
|
|
89
|
+
$rr: 'OK',
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
event: 'media_update',
|
|
94
|
+
call_id: oc.id,
|
|
95
|
+
status: 'ok',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
event: 'media_update',
|
|
99
|
+
call_id: ic.id,
|
|
100
|
+
status: 'ok',
|
|
101
|
+
},
|
|
102
|
+
], 5000)
|
|
103
|
+
|
|
104
|
+
sip.call.start_inband_dtmf_detection(oc.id)
|
|
105
|
+
sip.call.start_inband_dtmf_detection(ic.id)
|
|
106
|
+
|
|
107
|
+
// using 1234 fails frequently as we get things like '12334'
|
|
108
|
+
sip.call.send_dtmf(oc.id, {digits: '12', mode: 1})
|
|
109
|
+
sip.call.send_dtmf(ic.id, {digits: '12', mode: 1})
|
|
110
|
+
|
|
111
|
+
await z.wait([
|
|
112
|
+
{
|
|
113
|
+
event: 'dtmf',
|
|
114
|
+
call_id: ic.id,
|
|
115
|
+
digits: '12',
|
|
116
|
+
mode: 1,
|
|
117
|
+
media_id: 0,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
event: 'dtmf',
|
|
121
|
+
call_id: oc.id,
|
|
122
|
+
digits: '12',
|
|
123
|
+
mode: 1,
|
|
124
|
+
media_id: 0,
|
|
125
|
+
},
|
|
126
|
+
], 2000)
|
|
127
|
+
|
|
128
|
+
stat1 = JSON.parse(sip.call.get_stream_stat(oc.id, {media_id: 0}))
|
|
129
|
+
stat2 = JSON.parse(sip.call.get_stream_stat(ic.id, {media_id: 0}))
|
|
130
|
+
|
|
131
|
+
console.log("stat1", stat1)
|
|
132
|
+
console.log("stat2", stat2)
|
|
133
|
+
|
|
134
|
+
assert(stat1.CodecInfo == "opus/8000/1")
|
|
135
|
+
assert(stat2.CodecInfo == "opus/8000/1")
|
|
136
|
+
|
|
137
|
+
// Terminate the call from t1 side
|
|
138
|
+
sip.call.terminate(oc.id)
|
|
139
|
+
|
|
140
|
+
// Wait for call termination
|
|
141
|
+
await z.wait([
|
|
142
|
+
{
|
|
143
|
+
event: 'response',
|
|
144
|
+
call_id: oc.id,
|
|
145
|
+
method: 'BYE',
|
|
146
|
+
msg: sip_msg({
|
|
147
|
+
$rs: '200',
|
|
148
|
+
$rr: 'OK',
|
|
149
|
+
}),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
event: 'call_ended',
|
|
153
|
+
call_id: oc.id,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
event: 'call_ended',
|
|
157
|
+
call_id: ic.id,
|
|
158
|
+
},
|
|
159
|
+
], 2000)
|
|
160
|
+
|
|
161
|
+
console.log("Secure WebSocket + OPUS + SRTP + ICE test successful")
|
|
162
|
+
|
|
163
|
+
sip.stop()
|
|
164
|
+
process.exit(0)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
test().catch(e => {
|
|
168
|
+
console.error(e)
|
|
169
|
+
process.exit(1)
|
|
170
|
+
})
|
package/samples/simple.js
CHANGED
|
@@ -10,6 +10,9 @@ var z = new Zeq()
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
async function test() {
|
|
13
|
+
// here we set DTMF aggregation mode to 500 ms
|
|
14
|
+
sip.dtmf_aggregation_on(500)
|
|
15
|
+
|
|
13
16
|
// here we set our Zeq instance to trap events generated by sip-lab event_source
|
|
14
17
|
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
15
18
|
var e = evt.args[0]
|
|
@@ -147,6 +150,29 @@ async function test() {
|
|
|
147
150
|
},
|
|
148
151
|
], 1000)
|
|
149
152
|
|
|
153
|
+
sip.call.start_inband_dtmf_detection(oc.id)
|
|
154
|
+
sip.call.start_inband_dtmf_detection(ic.id)
|
|
155
|
+
|
|
156
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 1})
|
|
157
|
+
sip.call.send_dtmf(ic.id, {digits: '1234', mode: 1})
|
|
158
|
+
|
|
159
|
+
await z.wait([
|
|
160
|
+
{
|
|
161
|
+
event: 'dtmf',
|
|
162
|
+
call_id: ic.id,
|
|
163
|
+
digits: '1234',
|
|
164
|
+
mode: 1,
|
|
165
|
+
media_id: 0,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
event: 'dtmf',
|
|
169
|
+
call_id: oc.id,
|
|
170
|
+
digits: '1234',
|
|
171
|
+
mode: 1,
|
|
172
|
+
media_id: 0,
|
|
173
|
+
},
|
|
174
|
+
], 2000)
|
|
175
|
+
|
|
150
176
|
// now we terminate the call from t1 side
|
|
151
177
|
sip.call.terminate(oc.id)
|
|
152
178
|
|