sip-lab 1.11.4 → 1.12.2
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 +19 -3
- package/binding.gyp +1 -0
- package/index.js +23 -13
- package/install.sh +12 -1
- package/package.json +2 -1
- package/samples/{late_negotiation.js → delayed_media.js} +22 -25
- package/samples/g729.js +11 -11
- package/samples/register_subscribe.js +30 -7
- package/samples/reinvite_and_dtmf.js +22 -24
- package/samples/send_and_receive_fax.js +13 -17
- package/samples/simple.js +76 -39
- package/samples/sip_cancel.js +10 -12
- package/samples/tcp_and_extra_headers.js +333 -0
- package/src/addon.cpp +107 -498
- package/src/event_templates.cpp +22 -22
- package/src/event_templates.hpp +10 -10
- package/src/sip.cpp +1267 -599
- package/src/sip.hpp +58 -17
package/samples/simple.js
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// This test creates 2 UDP SIP endpoints, makes a call between them and disconeects.
|
|
2
|
+
|
|
3
|
+
const sip = require ('../index.js')
|
|
4
|
+
const Zester = require('zester')
|
|
5
|
+
const m = require('data-matching')
|
|
6
|
+
const sip_msg = require('sip-matching')
|
|
7
|
+
|
|
8
|
+
// here we create our Zester instance
|
|
3
9
|
var z = new Zester()
|
|
4
|
-
var m = require('data-matching')
|
|
5
|
-
var sip_msg = require('sip-matching')
|
|
6
10
|
|
|
7
|
-
async function test() {
|
|
8
|
-
//sip.set_log_level(6)
|
|
9
|
-
sip.dtmf_aggregation_on(500)
|
|
10
11
|
|
|
12
|
+
async function test() {
|
|
13
|
+
// here we set our zester instance to trap events generated by sip-lab event_source
|
|
11
14
|
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
12
15
|
var e = evt.args[0]
|
|
13
16
|
return e
|
|
14
17
|
})
|
|
15
18
|
|
|
19
|
+
// here we start sip-lab
|
|
16
20
|
console.log(sip.start((data) => { console.log(data)} ))
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
// Here we create the SIP endpoints (transports).
|
|
23
|
+
// Since we don't specify the port, an available port will be allocated.
|
|
24
|
+
// Since we don't specify the type ('udp' or 'tcp' or 'tls'), 'udp' will be used by default.
|
|
25
|
+
const t1 = sip.transport.create({address: "127.0.0.1"})
|
|
26
|
+
const t2 = sip.transport.create({address: "127.0.0.1"})
|
|
20
27
|
|
|
28
|
+
// here we just print the transports
|
|
21
29
|
console.log("t1", t1)
|
|
22
30
|
console.log("t2", t2)
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
|
|
32
|
+
// make the call from t1 to t2
|
|
33
|
+
const oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
|
|
27
34
|
|
|
35
|
+
// Here we will wait for the call to arrive at t2
|
|
36
|
+
// We will also get a '100 Trying' that is sent by sip-lab automatically
|
|
37
|
+
// We will wait for at most 1000ms. If all events don't arrive within 1000ms, an exception will be thrown and the test will fail due to timeout.
|
|
28
38
|
await z.wait([
|
|
29
39
|
{
|
|
30
40
|
event: "incoming_call",
|
|
31
41
|
call_id: m.collect("call_id"),
|
|
42
|
+
transport_id: t2.id,
|
|
32
43
|
},
|
|
33
44
|
{
|
|
34
45
|
event: 'response',
|
|
@@ -39,22 +50,61 @@ async function test() {
|
|
|
39
50
|
$rr: 'Trying',
|
|
40
51
|
'$(hdrcnt(via))': 1,
|
|
41
52
|
'$hdr(call-id)': m.collect('sip_call_id'),
|
|
42
|
-
$fU: '
|
|
43
|
-
$fd: '
|
|
44
|
-
$tU: '
|
|
53
|
+
$fU: 'alice',
|
|
54
|
+
$fd: 'test.com',
|
|
55
|
+
$tU: 'bob',
|
|
45
56
|
'$hdr(l)': '0',
|
|
46
57
|
}),
|
|
47
58
|
},
|
|
48
59
|
], 1000)
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
// Details about zester wait(list_of_events_to_wait_for, timeout_in_ms):
|
|
61
|
+
// The order of events in the list is irrelevant.
|
|
62
|
+
// What matters is that all events arrive within the specified timeout.
|
|
63
|
+
// When specifying events, you can be as detailed or succinct as you need.
|
|
64
|
+
// For example, the above event 'response' is waiting for a SIP '100 Trying' to arrive,
|
|
65
|
+
// but we are specifying things to match just to show that we can be very detailed when performing a match.
|
|
66
|
+
// But it could have been just like this:
|
|
67
|
+
//
|
|
68
|
+
// {
|
|
69
|
+
// event: 'response',
|
|
70
|
+
// call_id: oc.id,
|
|
71
|
+
// method: 'INVITE',
|
|
72
|
+
// msg: sip_msg({
|
|
73
|
+
// $rs: '100',
|
|
74
|
+
// }),
|
|
75
|
+
// }
|
|
76
|
+
// Regarding the function sip_msg() this is a special matching function provided by https://github.com/MayamaTakeshi/sip-matching that makes it
|
|
77
|
+
// easy to match a SIP message using openser/kamailio/opensips pseudo-variables syntax.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// Here we store data for the incoming call
|
|
81
|
+
// just to organize our code (not really needed)
|
|
82
|
+
const ic = {
|
|
51
83
|
id: z.store.call_id,
|
|
52
84
|
sip_call_id: z.store.sip_call_id,
|
|
53
85
|
}
|
|
54
86
|
|
|
55
|
-
|
|
87
|
+
// Now we answer the call at t2 side
|
|
88
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
56
89
|
|
|
90
|
+
// Then we wait for the '200 OK' at the t1 side
|
|
91
|
+
// We will also get event 'media_status' for both sides indicating media streams (RTP) were set up successfully
|
|
57
92
|
await z.wait([
|
|
93
|
+
{
|
|
94
|
+
event: 'response',
|
|
95
|
+
call_id: oc.id,
|
|
96
|
+
method: 'INVITE',
|
|
97
|
+
msg: sip_msg({
|
|
98
|
+
$rs: '200',
|
|
99
|
+
$rr: 'OK',
|
|
100
|
+
'$(hdrcnt(VIA))': 1,
|
|
101
|
+
$fU: 'alice',
|
|
102
|
+
$fd: 'test.com',
|
|
103
|
+
$tU: 'bob',
|
|
104
|
+
'$hdr(content-type)': 'application/sdp',
|
|
105
|
+
$rb: '!{_}a=sendrecv',
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
58
108
|
{
|
|
59
109
|
event: 'media_status',
|
|
60
110
|
call_id: oc.id,
|
|
@@ -69,26 +119,22 @@ async function test() {
|
|
|
69
119
|
local_mode: 'sendrecv',
|
|
70
120
|
remote_mode: 'sendrecv',
|
|
71
121
|
},
|
|
122
|
+
], 1000)
|
|
123
|
+
|
|
124
|
+
// now we terminate the call from t1 side
|
|
125
|
+
sip.call.terminate(oc.id)
|
|
126
|
+
|
|
127
|
+
// and wait for termination events
|
|
128
|
+
await z.wait([
|
|
72
129
|
{
|
|
73
130
|
event: 'response',
|
|
74
131
|
call_id: oc.id,
|
|
75
|
-
method: '
|
|
132
|
+
method: 'BYE',
|
|
76
133
|
msg: sip_msg({
|
|
77
134
|
$rs: '200',
|
|
78
135
|
$rr: 'OK',
|
|
79
|
-
'$(hdrcnt(VIA))': 1,
|
|
80
|
-
$fU: 'a',
|
|
81
|
-
$fd: 't',
|
|
82
|
-
$tU: 'b',
|
|
83
|
-
'$hdr(content-type)': 'application/sdp',
|
|
84
|
-
$rb: '!{_}a=sendrecv',
|
|
85
136
|
}),
|
|
86
137
|
},
|
|
87
|
-
], 1000)
|
|
88
|
-
|
|
89
|
-
sip.call.terminate(oc.id)
|
|
90
|
-
|
|
91
|
-
await z.wait([
|
|
92
138
|
{
|
|
93
139
|
event: 'call_ended',
|
|
94
140
|
call_id: oc.id,
|
|
@@ -97,15 +143,6 @@ async function test() {
|
|
|
97
143
|
event: 'call_ended',
|
|
98
144
|
call_id: ic.id,
|
|
99
145
|
},
|
|
100
|
-
{
|
|
101
|
-
event: 'response',
|
|
102
|
-
call_id: oc.id,
|
|
103
|
-
method: 'BYE',
|
|
104
|
-
msg: sip_msg({
|
|
105
|
-
$rs: '200',
|
|
106
|
-
$rr: 'OK',
|
|
107
|
-
}),
|
|
108
|
-
},
|
|
109
146
|
], 1000)
|
|
110
147
|
|
|
111
148
|
console.log("Success")
|
package/samples/sip_cancel.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,
|
|
19
|
-
t2 = sip.transport.create("127.0.0.1", 5092,
|
|
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
|
-
|
|
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: '
|
|
43
|
-
$fd: '
|
|
44
|
-
$tU: '
|
|
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, 180, 'Ringing')
|
|
53
|
+
sip.call.respond(ic.id, {code: 180, reason: 'Ringing'})
|
|
56
54
|
|
|
57
55
|
await z.wait([
|
|
58
56
|
{
|
|
@@ -63,9 +61,9 @@ async function test() {
|
|
|
63
61
|
$rs: '180',
|
|
64
62
|
$rr: 'Ringing',
|
|
65
63
|
'$(hdrcnt(VIA))': 1,
|
|
66
|
-
$fU: '
|
|
67
|
-
$fd: '
|
|
68
|
-
$tU: '
|
|
64
|
+
$fU: 'alice',
|
|
65
|
+
$fd: 'test.com',
|
|
66
|
+
$tU: 'bob',
|
|
69
67
|
}),
|
|
70
68
|
},
|
|
71
69
|
], 1000)
|
|
@@ -0,0 +1,333 @@
|
|
|
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({address: "127.0.0.1", port: 5090, type: 'tcp'})
|
|
19
|
+
t2 = sip.transport.create({address: "127.0.0.1", port: 5092, type: 'tcp'})
|
|
20
|
+
|
|
21
|
+
console.log("t1", t1)
|
|
22
|
+
console.log("t2", t2)
|
|
23
|
+
|
|
24
|
+
oc = sip.call.create(t1.id, {
|
|
25
|
+
from_uri: '"abc"<sip:alice@test.com>',
|
|
26
|
+
to_uri: `sip:bob@${t2.address}:${t2.port}`,
|
|
27
|
+
headers: {
|
|
28
|
+
'X-MyHeader1': 'abc',
|
|
29
|
+
'X-MyHeader2': 'def',
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
await z.wait([
|
|
34
|
+
{
|
|
35
|
+
event: "incoming_call",
|
|
36
|
+
call_id: m.collect("call_id"),
|
|
37
|
+
msg: sip_msg({
|
|
38
|
+
$rm: 'INVITE',
|
|
39
|
+
$fU: 'alice',
|
|
40
|
+
$fd: 'test.com',
|
|
41
|
+
$tU: 'bob',
|
|
42
|
+
'$hdr(X-MyHeader1)': 'abc',
|
|
43
|
+
'$hdr(X-MyHeader2)': 'def',
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
event: 'response',
|
|
48
|
+
call_id: oc.id,
|
|
49
|
+
method: 'INVITE',
|
|
50
|
+
msg: sip_msg({
|
|
51
|
+
$rs: '100',
|
|
52
|
+
$rr: 'Trying',
|
|
53
|
+
'$(hdrcnt(via))': 1,
|
|
54
|
+
'$hdr(call-id)': m.collect('sip_call_id'),
|
|
55
|
+
$fU: 'alice',
|
|
56
|
+
$fd: 'test.com',
|
|
57
|
+
$tU: 'bob',
|
|
58
|
+
'$hdr(l)': '0',
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
], 1000)
|
|
62
|
+
|
|
63
|
+
ic = {
|
|
64
|
+
id: z.store.call_id,
|
|
65
|
+
sip_call_id: z.store.sip_call_id,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
sip.call.respond(ic.id, {
|
|
69
|
+
code: 200,
|
|
70
|
+
reason:'OK',
|
|
71
|
+
headers: {
|
|
72
|
+
'X-MyHeader3': 'ghi',
|
|
73
|
+
'X-MyHeader4': 'jkl',
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
await z.wait([
|
|
78
|
+
{
|
|
79
|
+
event: 'media_status',
|
|
80
|
+
call_id: oc.id,
|
|
81
|
+
status: 'setup_ok',
|
|
82
|
+
local_mode: 'sendrecv',
|
|
83
|
+
remote_mode: 'sendrecv',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
event: 'media_status',
|
|
87
|
+
call_id: ic.id,
|
|
88
|
+
status: 'setup_ok',
|
|
89
|
+
local_mode: 'sendrecv',
|
|
90
|
+
remote_mode: 'sendrecv',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
event: 'response',
|
|
94
|
+
call_id: oc.id,
|
|
95
|
+
method: 'INVITE',
|
|
96
|
+
msg: sip_msg({
|
|
97
|
+
$rs: '200',
|
|
98
|
+
$rr: 'OK',
|
|
99
|
+
'$(hdrcnt(VIA))': 1,
|
|
100
|
+
$fU: 'alice',
|
|
101
|
+
$fd: 'test.com',
|
|
102
|
+
$tU: 'bob',
|
|
103
|
+
'$hdr(content-type)': 'application/sdp',
|
|
104
|
+
$rb: '!{_}a=sendrecv',
|
|
105
|
+
'$hdr(X-MyHeader3)': 'ghi',
|
|
106
|
+
'$hdr(X-MyHeader4)': 'jkl',
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
], 1000)
|
|
110
|
+
|
|
111
|
+
sip.call.start_recording(oc.id, {file: './oc.wav'})
|
|
112
|
+
sip.call.start_recording(ic.id, {file: './ic.wav'})
|
|
113
|
+
|
|
114
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
115
|
+
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
116
|
+
|
|
117
|
+
await z.wait([
|
|
118
|
+
{
|
|
119
|
+
event: 'dtmf',
|
|
120
|
+
call_id: ic.id,
|
|
121
|
+
digits: '1234',
|
|
122
|
+
mode: 0,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
event: 'dtmf',
|
|
126
|
+
call_id: oc.id,
|
|
127
|
+
digits: '4321',
|
|
128
|
+
mode: 1,
|
|
129
|
+
},
|
|
130
|
+
], 2000)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
sip.call.reinvite(oc.id, { hold: true })
|
|
134
|
+
|
|
135
|
+
await z.wait([
|
|
136
|
+
{
|
|
137
|
+
event: 'response',
|
|
138
|
+
call_id: oc.id,
|
|
139
|
+
method: 'INVITE',
|
|
140
|
+
msg: sip_msg({
|
|
141
|
+
$rs: '200',
|
|
142
|
+
$rr: 'OK',
|
|
143
|
+
$rb: '!{_}a=recvonly',
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
event: 'media_status',
|
|
148
|
+
call_id: oc.id,
|
|
149
|
+
status: 'setup_ok',
|
|
150
|
+
local_mode: 'sendonly',
|
|
151
|
+
remote_mode: 'recvonly',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
event: 'media_status',
|
|
155
|
+
call_id: ic.id,
|
|
156
|
+
status: 'setup_ok',
|
|
157
|
+
local_mode: 'recvonly',
|
|
158
|
+
remote_mode: 'sendonly',
|
|
159
|
+
},
|
|
160
|
+
], 500)
|
|
161
|
+
|
|
162
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
163
|
+
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 0}) // this will not generate event 'dtmf' as the call is on hold
|
|
164
|
+
|
|
165
|
+
await z.wait([
|
|
166
|
+
{
|
|
167
|
+
event: 'dtmf',
|
|
168
|
+
call_id: ic.id,
|
|
169
|
+
digits: '1234',
|
|
170
|
+
mode: 0,
|
|
171
|
+
},
|
|
172
|
+
], 2000)
|
|
173
|
+
|
|
174
|
+
sip.call.reinvite(ic.id)
|
|
175
|
+
|
|
176
|
+
await z.wait([
|
|
177
|
+
{
|
|
178
|
+
event: 'response',
|
|
179
|
+
call_id: ic.id,
|
|
180
|
+
method: 'INVITE',
|
|
181
|
+
msg: sip_msg({
|
|
182
|
+
$rs: '200',
|
|
183
|
+
$rr: 'OK',
|
|
184
|
+
$rb: '!{_}a=sendonly',
|
|
185
|
+
}),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
event: 'media_status',
|
|
189
|
+
call_id: oc.id,
|
|
190
|
+
status: 'setup_ok',
|
|
191
|
+
local_mode: 'sendonly',
|
|
192
|
+
remote_mode: 'recvonly',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
event: 'media_status',
|
|
196
|
+
call_id: ic.id,
|
|
197
|
+
status: 'setup_ok',
|
|
198
|
+
local_mode: 'recvonly',
|
|
199
|
+
remote_mode: 'sendonly',
|
|
200
|
+
},
|
|
201
|
+
], 500)
|
|
202
|
+
|
|
203
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
204
|
+
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1}) // this will not generate event 'dtmf' as the call is on hold
|
|
205
|
+
|
|
206
|
+
await z.wait([
|
|
207
|
+
{
|
|
208
|
+
event: 'dtmf',
|
|
209
|
+
call_id: ic.id,
|
|
210
|
+
digits: '1234',
|
|
211
|
+
mode: 0,
|
|
212
|
+
},
|
|
213
|
+
], 2000)
|
|
214
|
+
|
|
215
|
+
sip.call.send_request(oc.id, {method: 'INFO'})
|
|
216
|
+
|
|
217
|
+
await z.wait([
|
|
218
|
+
{
|
|
219
|
+
event: 'request',
|
|
220
|
+
call_id: ic.id,
|
|
221
|
+
msg: sip_msg({
|
|
222
|
+
$rm: 'INFO',
|
|
223
|
+
}),
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
event: 'response',
|
|
227
|
+
call_id: oc.id,
|
|
228
|
+
method: 'INFO',
|
|
229
|
+
msg: sip_msg({
|
|
230
|
+
$rs: '200',
|
|
231
|
+
$rr: 'OK',
|
|
232
|
+
}),
|
|
233
|
+
},
|
|
234
|
+
], 500)
|
|
235
|
+
|
|
236
|
+
sip.call.reinvite(oc.id)
|
|
237
|
+
|
|
238
|
+
await z.wait([
|
|
239
|
+
{
|
|
240
|
+
event: 'response',
|
|
241
|
+
call_id: oc.id,
|
|
242
|
+
method: 'INVITE',
|
|
243
|
+
msg: sip_msg({
|
|
244
|
+
$rs: '200',
|
|
245
|
+
$rr: 'OK',
|
|
246
|
+
$rb: '!{_}a=sendrecv',
|
|
247
|
+
}),
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
event: 'media_status',
|
|
251
|
+
call_id: oc.id,
|
|
252
|
+
status: 'setup_ok',
|
|
253
|
+
local_mode: 'sendrecv',
|
|
254
|
+
remote_mode: 'sendrecv',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
event: 'media_status',
|
|
258
|
+
call_id: ic.id,
|
|
259
|
+
status: 'setup_ok',
|
|
260
|
+
local_mode: 'sendrecv',
|
|
261
|
+
remote_mode: 'sendrecv',
|
|
262
|
+
},
|
|
263
|
+
], 500)
|
|
264
|
+
|
|
265
|
+
sip.call.send_dtmf(oc.id, {digits: '1234', mode: 0})
|
|
266
|
+
sip.call.send_dtmf(ic.id, {digits: '4321', mode: 1})
|
|
267
|
+
|
|
268
|
+
await z.wait([
|
|
269
|
+
{
|
|
270
|
+
event: 'dtmf',
|
|
271
|
+
call_id: ic.id,
|
|
272
|
+
digits: '1234',
|
|
273
|
+
mode: 0,
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
event: 'dtmf',
|
|
277
|
+
call_id: oc.id,
|
|
278
|
+
digits: '4321',
|
|
279
|
+
mode: 1,
|
|
280
|
+
},
|
|
281
|
+
], 2000)
|
|
282
|
+
|
|
283
|
+
sip.call.start_playing(oc.id, {file: '/home/takeshi/work/src/svn/brastel/SIP-Tools/trunk/sip-tester/yosemitesam.wav'})
|
|
284
|
+
sip.call.start_playing(ic.id, {file: '/home/takeshi/work/src/svn/brastel/SIP-Tools/trunk/sip-tester/yosemitesam.wav'})
|
|
285
|
+
|
|
286
|
+
await z.sleep(2000)
|
|
287
|
+
|
|
288
|
+
stat1 = sip.call.get_stream_stat(oc.id)
|
|
289
|
+
stat2 = sip.call.get_stream_stat(ic.id)
|
|
290
|
+
|
|
291
|
+
console.log("stat1", stat1)
|
|
292
|
+
console.log("stat2", stat2)
|
|
293
|
+
|
|
294
|
+
sip.call.stop_recording(oc.id)
|
|
295
|
+
sip.call.stop_recording(ic.id)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
sip.call.terminate(oc.id)
|
|
299
|
+
|
|
300
|
+
await z.wait([
|
|
301
|
+
{
|
|
302
|
+
event: 'call_ended',
|
|
303
|
+
call_id: oc.id,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
event: 'call_ended',
|
|
307
|
+
call_id: ic.id,
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
event: 'response',
|
|
311
|
+
call_id: oc.id,
|
|
312
|
+
method: 'BYE',
|
|
313
|
+
msg: sip_msg({
|
|
314
|
+
$rs: '200',
|
|
315
|
+
$rr: 'OK',
|
|
316
|
+
}),
|
|
317
|
+
},
|
|
318
|
+
], 1000)
|
|
319
|
+
|
|
320
|
+
await z.sleep(1000)
|
|
321
|
+
|
|
322
|
+
console.log("Success")
|
|
323
|
+
|
|
324
|
+
sip.stop()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
test()
|
|
329
|
+
.catch(e => {
|
|
330
|
+
console.error(e)
|
|
331
|
+
process.exit(1)
|
|
332
|
+
})
|
|
333
|
+
|