sip-lab 1.14.0 → 1.16.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/package.json +4 -3
- package/prebuilds/linux-x64/node.abi102.node +0 -0
- package/prebuilds/linux-x64/node.abi108.node +0 -0
- package/prebuilds/linux-x64/node.abi88.node +0 -0
- package/prebuilds/linux-x64/node.abi93.node +0 -0
- package/prebuilds/linux-x64/sip-lab.node +0 -0
- package/samples/{t → 183_session_progress.js} +98 -160
- package/samples/rtp_and_srtp.js +466 -0
- package/samples/rtp_and_srtp.rtp_refused.js +430 -0
- package/samples/rtp_and_srtp.unbalanced_sdp_answer.js.future +189 -0
- package/samples/srtp.js +344 -0
- package/src/sip.cpp +137 -30
- package/samples/183_session_progress.js.future +0 -246
|
@@ -1,246 +0,0 @@
|
|
|
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
|
-
async function test() {
|
|
9
|
-
sip.set_log_level(9)
|
|
10
|
-
|
|
11
|
-
//sip.set_log_level(6)
|
|
12
|
-
sip.dtmf_aggregation_on(500)
|
|
13
|
-
|
|
14
|
-
// Let's ignore '100 Trying'
|
|
15
|
-
z.add_event_filter({
|
|
16
|
-
event: 'response',
|
|
17
|
-
msg: sip_msg({
|
|
18
|
-
$rs: '100',
|
|
19
|
-
}),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
23
|
-
var e = evt.args[0]
|
|
24
|
-
return e
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
console.log(sip.start((data) => { console.log(data)} ))
|
|
28
|
-
|
|
29
|
-
t1 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
|
|
30
|
-
t2 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
|
|
31
|
-
|
|
32
|
-
console.log("t1", t1)
|
|
33
|
-
console.log("t2", t2)
|
|
34
|
-
|
|
35
|
-
oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
|
|
36
|
-
|
|
37
|
-
await z.wait([
|
|
38
|
-
{
|
|
39
|
-
event: "incoming_call",
|
|
40
|
-
call_id: m.collect("call_id"),
|
|
41
|
-
},
|
|
42
|
-
], 1000)
|
|
43
|
-
|
|
44
|
-
ic = {
|
|
45
|
-
id: z.store.call_id,
|
|
46
|
-
sip_call_id: z.store.sip_call_id,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
sip.call.respond(ic.id, {code: 183, reason: 'Session Progress'})
|
|
50
|
-
|
|
51
|
-
await z.wait([
|
|
52
|
-
{
|
|
53
|
-
event: 'response',
|
|
54
|
-
call_id: oc.id,
|
|
55
|
-
method: 'INVITE',
|
|
56
|
-
msg: sip_msg({
|
|
57
|
-
$rs: '183',
|
|
58
|
-
$rr: 'Session Progress',
|
|
59
|
-
'$(hdrcnt(VIA))': 1,
|
|
60
|
-
$fU: 'alice',
|
|
61
|
-
$fd: 'test.com',
|
|
62
|
-
$tU: 'bob',
|
|
63
|
-
'$hdr(content-type)': 'application/sdp',
|
|
64
|
-
$rb: '!{_}a=sendrecv',
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
event: 'media_update',
|
|
69
|
-
call_id: oc.id,
|
|
70
|
-
status: 'ok',
|
|
71
|
-
media: [
|
|
72
|
-
{
|
|
73
|
-
type: 'audio',
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
event: 'media_update',
|
|
79
|
-
call_id: ic.id,
|
|
80
|
-
status: 'ok',
|
|
81
|
-
media: [
|
|
82
|
-
{
|
|
83
|
-
type: 'audio',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
], 1000)
|
|
88
|
-
|
|
89
|
-
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
90
|
-
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
91
|
-
|
|
92
|
-
await z.wait([
|
|
93
|
-
{
|
|
94
|
-
event: 'dtmf',
|
|
95
|
-
call_id: ic.id,
|
|
96
|
-
digits: '1234',
|
|
97
|
-
mode: 0,
|
|
98
|
-
media_id: 0
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
event: 'dtmf',
|
|
102
|
-
call_id: oc.id,
|
|
103
|
-
digits: '4321',
|
|
104
|
-
mode: 1,
|
|
105
|
-
media_id: 0
|
|
106
|
-
},
|
|
107
|
-
], 2000)
|
|
108
|
-
|
|
109
|
-
await z.sleep(1000)
|
|
110
|
-
|
|
111
|
-
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
112
|
-
|
|
113
|
-
await z.wait([
|
|
114
|
-
{
|
|
115
|
-
event: 'response',
|
|
116
|
-
call_id: oc.id,
|
|
117
|
-
method: 'INVITE',
|
|
118
|
-
msg: sip_msg({
|
|
119
|
-
$rs: '183',
|
|
120
|
-
$rr: 'Session Progress',
|
|
121
|
-
'$(hdrcnt(VIA))': 1,
|
|
122
|
-
$fU: 'alice',
|
|
123
|
-
$fd: 'test.com',
|
|
124
|
-
$tU: 'bob',
|
|
125
|
-
'$hdr(content-type)': 'application/sdp',
|
|
126
|
-
$rb: '!{_}a=sendrecv',
|
|
127
|
-
}),
|
|
128
|
-
},
|
|
129
|
-
], 1000)
|
|
130
|
-
|
|
131
|
-
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
132
|
-
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
133
|
-
|
|
134
|
-
await z.wait([
|
|
135
|
-
{
|
|
136
|
-
event: 'dtmf',
|
|
137
|
-
call_id: ic.id,
|
|
138
|
-
digits: '1234',
|
|
139
|
-
mode: 0,
|
|
140
|
-
media_id: 0
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
event: 'dtmf',
|
|
144
|
-
call_id: oc.id,
|
|
145
|
-
digits: '4321',
|
|
146
|
-
mode: 1,
|
|
147
|
-
media_id: 0
|
|
148
|
-
},
|
|
149
|
-
], 2000)
|
|
150
|
-
|
|
151
|
-
sip.call.reinvite(oc.id)
|
|
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: '200',
|
|
169
|
-
}),
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
event: 'media_update',
|
|
173
|
-
call_id: ic.id,
|
|
174
|
-
status: 'ok',
|
|
175
|
-
media: [
|
|
176
|
-
{
|
|
177
|
-
type: 'audio',
|
|
178
|
-
},
|
|
179
|
-
]
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
event: 'media_update',
|
|
183
|
-
call_id: oc.id,
|
|
184
|
-
status: 'ok',
|
|
185
|
-
media: [
|
|
186
|
-
{
|
|
187
|
-
type: 'audio',
|
|
188
|
-
},
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
], 1000)
|
|
192
|
-
|
|
193
|
-
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
194
|
-
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
195
|
-
|
|
196
|
-
await z.wait([
|
|
197
|
-
{
|
|
198
|
-
event: 'dtmf',
|
|
199
|
-
call_id: ic.id,
|
|
200
|
-
digits: '1234',
|
|
201
|
-
mode: 0,
|
|
202
|
-
media_id: 0
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
event: 'dtmf',
|
|
206
|
-
call_id: oc.id,
|
|
207
|
-
digits: '4321',
|
|
208
|
-
mode: 1,
|
|
209
|
-
media_id: 0
|
|
210
|
-
},
|
|
211
|
-
], 2000)
|
|
212
|
-
|
|
213
|
-
sip.call.terminate(oc.id)
|
|
214
|
-
|
|
215
|
-
await z.wait([
|
|
216
|
-
{
|
|
217
|
-
event: 'call_ended',
|
|
218
|
-
call_id: oc.id,
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
event: 'call_ended',
|
|
222
|
-
call_id: ic.id,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
event: 'response',
|
|
226
|
-
call_id: oc.id,
|
|
227
|
-
method: 'BYE',
|
|
228
|
-
msg: sip_msg({
|
|
229
|
-
$rs: '200',
|
|
230
|
-
$rr: 'OK',
|
|
231
|
-
}),
|
|
232
|
-
},
|
|
233
|
-
], 1000)
|
|
234
|
-
|
|
235
|
-
console.log("Success")
|
|
236
|
-
|
|
237
|
-
sip.stop()
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
test()
|
|
242
|
-
.catch(e => {
|
|
243
|
-
console.error(e)
|
|
244
|
-
process.exit(1)
|
|
245
|
-
})
|
|
246
|
-
|