sip-lab 1.5.0 → 1.6.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/package.json +2 -2
- package/samples/g729.js +174 -164
- package/samples/late_negotiation.js +281 -270
- package/samples/simple.js +284 -272
- package/samples/sip_cancel.js +113 -102
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sip-lab",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"data-matching": "^1.23.7",
|
|
26
26
|
"sip-matching": "^1.3.12",
|
|
27
27
|
"string-matching": "^1.11.8",
|
|
28
|
-
"zester": "^
|
|
28
|
+
"zester": "^4.0.0"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/samples/g729.js
CHANGED
|
@@ -4,169 +4,179 @@ var z = new Zester()
|
|
|
4
4
|
var m = require('data-matching')
|
|
5
5
|
var sip_msg = require('sip-matching')
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
sip.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
console.log("
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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("127.0.0.1", 5090, 1)
|
|
19
|
+
t2 = sip.transport.create("127.0.0.1", 5092, 1)
|
|
20
|
+
|
|
21
|
+
console.log("t1", t1)
|
|
22
|
+
console.log("t2", t2)
|
|
23
|
+
|
|
24
|
+
sip.set_codecs("g729/8000/1:128")
|
|
25
|
+
|
|
26
|
+
flags = 0
|
|
27
|
+
|
|
28
|
+
oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
|
|
29
|
+
|
|
30
|
+
await z.wait([
|
|
31
|
+
{
|
|
32
|
+
event: "incoming_call",
|
|
33
|
+
call_id: m.collect("call_id"),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
event: 'response',
|
|
37
|
+
call_id: oc.id,
|
|
38
|
+
method: 'INVITE',
|
|
39
|
+
msg: sip_msg({
|
|
40
|
+
$rs: '100',
|
|
41
|
+
$rr: 'Trying',
|
|
42
|
+
'$(hdrcnt(via))': 1,
|
|
43
|
+
'$hdr(call-id)': m.collect('sip_call_id'),
|
|
44
|
+
$fU: 'a',
|
|
45
|
+
$fd: 't',
|
|
46
|
+
$tU: 'b',
|
|
47
|
+
'$hdr(l)': '0',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
], 1000)
|
|
51
|
+
|
|
52
|
+
ic = {
|
|
53
|
+
id: z.store.call_id,
|
|
54
|
+
sip_call_id: z.store.sip_call_id,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
sip.call.respond(ic.id, 200, 'OK')
|
|
58
|
+
|
|
59
|
+
await z.wait([
|
|
60
|
+
{
|
|
61
|
+
event: 'media_status',
|
|
62
|
+
call_id: oc.id,
|
|
63
|
+
status: 'setup_ok',
|
|
64
|
+
local_mode: 'sendrecv',
|
|
65
|
+
remote_mode: 'sendrecv',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
event: 'media_status',
|
|
69
|
+
call_id: ic.id,
|
|
70
|
+
status: 'setup_ok',
|
|
71
|
+
local_mode: 'sendrecv',
|
|
72
|
+
remote_mode: 'sendrecv',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
event: 'response',
|
|
76
|
+
call_id: oc.id,
|
|
77
|
+
method: 'INVITE',
|
|
78
|
+
msg: sip_msg({
|
|
79
|
+
$rs: '200',
|
|
80
|
+
$rr: 'OK',
|
|
81
|
+
'$(hdrcnt(VIA))': 1,
|
|
82
|
+
$fU: 'a',
|
|
83
|
+
$fd: 't',
|
|
84
|
+
$tU: 'b',
|
|
85
|
+
'$hdr(content-type)': 'application/sdp',
|
|
86
|
+
$rb: '!{_}a=sendrecv',
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
], 1000)
|
|
90
|
+
|
|
91
|
+
sip.call.reinvite(oc.id, true, 0)
|
|
92
|
+
|
|
93
|
+
await z.wait([
|
|
94
|
+
{
|
|
95
|
+
event: 'response',
|
|
96
|
+
call_id: oc.id,
|
|
97
|
+
method: 'INVITE',
|
|
98
|
+
msg: sip_msg({
|
|
99
|
+
$rs: '200',
|
|
100
|
+
$rr: 'OK',
|
|
101
|
+
$rb: '!{_}a=recvonly',
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
event: 'media_status',
|
|
106
|
+
call_id: oc.id,
|
|
107
|
+
status: 'setup_ok',
|
|
108
|
+
local_mode: 'sendonly',
|
|
109
|
+
remote_mode: 'recvonly',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
event: 'media_status',
|
|
113
|
+
call_id: ic.id,
|
|
114
|
+
status: 'setup_ok',
|
|
115
|
+
local_mode: 'recvonly',
|
|
116
|
+
remote_mode: 'sendonly',
|
|
117
|
+
},
|
|
118
|
+
], 500)
|
|
119
|
+
|
|
120
|
+
sip.call.reinvite(oc.id, false, 0)
|
|
121
|
+
|
|
122
|
+
await z.wait([
|
|
123
|
+
{
|
|
124
|
+
event: 'response',
|
|
125
|
+
call_id: oc.id,
|
|
126
|
+
method: 'INVITE',
|
|
127
|
+
msg: sip_msg({
|
|
128
|
+
$rs: '200',
|
|
129
|
+
$rr: 'OK',
|
|
130
|
+
$rb: '!{_}a=sendrecv',
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
event: 'media_status',
|
|
135
|
+
call_id: oc.id,
|
|
136
|
+
status: 'setup_ok',
|
|
137
|
+
local_mode: 'sendrecv',
|
|
138
|
+
remote_mode: 'sendrecv',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
event: 'media_status',
|
|
142
|
+
call_id: ic.id,
|
|
143
|
+
status: 'setup_ok',
|
|
144
|
+
local_mode: 'sendrecv',
|
|
145
|
+
remote_mode: 'sendrecv',
|
|
146
|
+
},
|
|
147
|
+
], 500)
|
|
148
|
+
|
|
149
|
+
sip.call.terminate(oc.id)
|
|
150
|
+
|
|
151
|
+
await z.wait([
|
|
152
|
+
{
|
|
153
|
+
event: 'call_ended',
|
|
154
|
+
call_id: oc.id,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
event: 'call_ended',
|
|
158
|
+
call_id: ic.id,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
event: 'response',
|
|
162
|
+
call_id: oc.id,
|
|
163
|
+
method: 'BYE',
|
|
164
|
+
msg: sip_msg({
|
|
165
|
+
$rs: '200',
|
|
166
|
+
$rr: 'OK',
|
|
167
|
+
}),
|
|
168
|
+
},
|
|
169
|
+
], 1000)
|
|
170
|
+
|
|
171
|
+
await z.sleep(1000)
|
|
172
|
+
|
|
173
|
+
console.log("Success")
|
|
174
|
+
|
|
175
|
+
sip.stop()
|
|
54
176
|
}
|
|
55
177
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
call_id: oc.id,
|
|
62
|
-
status: 'setup_ok',
|
|
63
|
-
local_mode: 'sendrecv',
|
|
64
|
-
remote_mode: 'sendrecv',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
event: 'media_status',
|
|
68
|
-
call_id: ic.id,
|
|
69
|
-
status: 'setup_ok',
|
|
70
|
-
local_mode: 'sendrecv',
|
|
71
|
-
remote_mode: 'sendrecv',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
event: 'response',
|
|
75
|
-
call_id: oc.id,
|
|
76
|
-
method: 'INVITE',
|
|
77
|
-
msg: sip_msg({
|
|
78
|
-
$rs: '200',
|
|
79
|
-
$rr: 'OK',
|
|
80
|
-
'$(hdrcnt(VIA))': 1,
|
|
81
|
-
$fU: 'a',
|
|
82
|
-
$fd: 't',
|
|
83
|
-
$tU: 'b',
|
|
84
|
-
'$hdr(content-type)': 'application/sdp',
|
|
85
|
-
$rb: '!{_}a=sendrecv',
|
|
86
|
-
}),
|
|
87
|
-
},
|
|
88
|
-
], 1000)
|
|
89
|
-
|
|
90
|
-
sip.call.reinvite(oc.id, true, 0)
|
|
91
|
-
|
|
92
|
-
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
|
-
$rb: '!{_}a=recvonly',
|
|
101
|
-
}),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
event: 'media_status',
|
|
105
|
-
call_id: oc.id,
|
|
106
|
-
status: 'setup_ok',
|
|
107
|
-
local_mode: 'sendonly',
|
|
108
|
-
remote_mode: 'recvonly',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
event: 'media_status',
|
|
112
|
-
call_id: ic.id,
|
|
113
|
-
status: 'setup_ok',
|
|
114
|
-
local_mode: 'recvonly',
|
|
115
|
-
remote_mode: 'sendonly',
|
|
116
|
-
},
|
|
117
|
-
], 500)
|
|
118
|
-
|
|
119
|
-
sip.call.reinvite(oc.id, false, 0)
|
|
120
|
-
|
|
121
|
-
z.wait([
|
|
122
|
-
{
|
|
123
|
-
event: 'response',
|
|
124
|
-
call_id: oc.id,
|
|
125
|
-
method: 'INVITE',
|
|
126
|
-
msg: sip_msg({
|
|
127
|
-
$rs: '200',
|
|
128
|
-
$rr: 'OK',
|
|
129
|
-
$rb: '!{_}a=sendrecv',
|
|
130
|
-
}),
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
event: 'media_status',
|
|
134
|
-
call_id: oc.id,
|
|
135
|
-
status: 'setup_ok',
|
|
136
|
-
local_mode: 'sendrecv',
|
|
137
|
-
remote_mode: 'sendrecv',
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
event: 'media_status',
|
|
141
|
-
call_id: ic.id,
|
|
142
|
-
status: 'setup_ok',
|
|
143
|
-
local_mode: 'sendrecv',
|
|
144
|
-
remote_mode: 'sendrecv',
|
|
145
|
-
},
|
|
146
|
-
], 500)
|
|
147
|
-
|
|
148
|
-
sip.call.terminate(oc.id)
|
|
149
|
-
|
|
150
|
-
z.wait([
|
|
151
|
-
{
|
|
152
|
-
event: 'call_ended',
|
|
153
|
-
call_id: oc.id,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
event: 'call_ended',
|
|
157
|
-
call_id: ic.id,
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
event: 'response',
|
|
161
|
-
call_id: oc.id,
|
|
162
|
-
method: 'BYE',
|
|
163
|
-
msg: sip_msg({
|
|
164
|
-
$rs: '200',
|
|
165
|
-
$rr: 'OK',
|
|
166
|
-
}),
|
|
167
|
-
},
|
|
168
|
-
], 1000)
|
|
169
|
-
|
|
170
|
-
z.sleep(1000)
|
|
171
|
-
|
|
172
|
-
sip.stop()
|
|
178
|
+
test()
|
|
179
|
+
.catch(e => {
|
|
180
|
+
console.error(e)
|
|
181
|
+
process.exit(1)
|
|
182
|
+
})
|