sip-lab 1.33.0 → 1.34.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/build_deps.sh +3 -1
- package/package.json +1 -1
- 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/samples/g729.js +20 -0
- package/samples/opus.narrowband.js +236 -0
- package/src/sip.cpp +23 -0
package/build_deps.sh
CHANGED
|
@@ -39,7 +39,7 @@ then
|
|
|
39
39
|
git clone https://github.com/MayamaTakeshi/bcg729
|
|
40
40
|
cd bcg729
|
|
41
41
|
git checkout faaa895862165acde6df8add722ba4f85a25007d
|
|
42
|
-
cmake .
|
|
42
|
+
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .
|
|
43
43
|
make
|
|
44
44
|
mkdir -p lib
|
|
45
45
|
cp -f src/libbcg729.a lib
|
|
@@ -70,6 +70,8 @@ EOF
|
|
|
70
70
|
#define PJSUA_MAX_ACC (20000)
|
|
71
71
|
#define PJ_IOQUEUE_MAX_HANDLES (1024)
|
|
72
72
|
#define PJSUA_MAX_CALLS (20000)
|
|
73
|
+
|
|
74
|
+
#define PJMEDIA_HAS_OPUS_CODEC 1
|
|
73
75
|
EOF
|
|
74
76
|
make dep && make clean && make
|
|
75
77
|
fi
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/samples/g729.js
CHANGED
|
@@ -77,6 +77,23 @@ async function test() {
|
|
|
77
77
|
},
|
|
78
78
|
], 1000)
|
|
79
79
|
|
|
80
|
+
sip.call.start_record_wav(oc.id, {file: './oc.wav'})
|
|
81
|
+
sip.call.start_record_wav(ic.id, {file: './ic.wav'})
|
|
82
|
+
|
|
83
|
+
sip.call.start_play_wav(oc.id, {file: 'samples/artifacts/yosemitesam.wav', end_of_file_event: true, no_loop: true})
|
|
84
|
+
sip.call.start_play_wav(ic.id, {file: 'samples/artifacts/yosemitesam.wav', end_of_file_event: true, no_loop: true})
|
|
85
|
+
|
|
86
|
+
await z.wait([
|
|
87
|
+
{
|
|
88
|
+
event: 'end_of_file',
|
|
89
|
+
call_id: oc.id,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
event: 'end_of_file',
|
|
93
|
+
call_id: ic.id,
|
|
94
|
+
},
|
|
95
|
+
], 3000)
|
|
96
|
+
|
|
80
97
|
sip.call.reinvite(oc.id)
|
|
81
98
|
|
|
82
99
|
await z.wait([
|
|
@@ -173,6 +190,9 @@ async function test() {
|
|
|
173
190
|
assert(oc_stat.CodecInfo == 'G729/8000/1')
|
|
174
191
|
assert(ic_stat.CodecInfo == 'G729/8000/1')
|
|
175
192
|
|
|
193
|
+
sip.call.stop_record_wav(oc.id)
|
|
194
|
+
sip.call.stop_record_wav(ic.id)
|
|
195
|
+
|
|
176
196
|
sip.call.terminate(oc.id)
|
|
177
197
|
|
|
178
198
|
await z.wait([
|
|
@@ -0,0 +1,236 @@
|
|
|
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
|
+
sip.set_codecs("opus/48000/2:128")
|
|
29
|
+
|
|
30
|
+
flags = 0
|
|
31
|
+
|
|
32
|
+
oc = sip.call.create(t1.id, {from_uri: 'sip:alice@test.com', to_uri: `sip:bob@${t2.address}:${t2.port}`})
|
|
33
|
+
|
|
34
|
+
await z.wait([
|
|
35
|
+
{
|
|
36
|
+
event: "incoming_call",
|
|
37
|
+
call_id: m.collect("call_id"),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
event: 'response',
|
|
41
|
+
call_id: oc.id,
|
|
42
|
+
method: 'INVITE',
|
|
43
|
+
msg: sip_msg({
|
|
44
|
+
$rs: '100',
|
|
45
|
+
$rr: 'Trying',
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
], 1000)
|
|
49
|
+
|
|
50
|
+
ic = {
|
|
51
|
+
id: z.store.call_id,
|
|
52
|
+
sip_call_id: z.store.sip_call_id,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
56
|
+
|
|
57
|
+
await z.wait([
|
|
58
|
+
{
|
|
59
|
+
event: 'media_update',
|
|
60
|
+
call_id: oc.id,
|
|
61
|
+
status: 'ok',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
event: 'media_update',
|
|
65
|
+
call_id: ic.id,
|
|
66
|
+
status: 'ok',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
event: 'response',
|
|
70
|
+
call_id: oc.id,
|
|
71
|
+
method: 'INVITE',
|
|
72
|
+
msg: sip_msg({
|
|
73
|
+
$rs: '200',
|
|
74
|
+
$rr: 'OK',
|
|
75
|
+
'hdr_content_type': 'application/sdp',
|
|
76
|
+
$rb: '!{_}a=sendrecv',
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
], 1000)
|
|
80
|
+
|
|
81
|
+
sip.call.start_record_wav(oc.id, {file: './oc.wav'})
|
|
82
|
+
sip.call.start_record_wav(ic.id, {file: './ic.wav'})
|
|
83
|
+
|
|
84
|
+
sip.call.start_play_wav(oc.id, {file: 'samples/artifacts/yosemitesam.wav', end_of_file_event: true, no_loop: true})
|
|
85
|
+
sip.call.start_play_wav(ic.id, {file: 'samples/artifacts/yosemitesam.wav', end_of_file_event: true, no_loop: true})
|
|
86
|
+
|
|
87
|
+
await z.wait([
|
|
88
|
+
{
|
|
89
|
+
event: 'end_of_file',
|
|
90
|
+
call_id: oc.id,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
event: 'end_of_file',
|
|
94
|
+
call_id: ic.id,
|
|
95
|
+
},
|
|
96
|
+
], 3000)
|
|
97
|
+
|
|
98
|
+
sip.call.reinvite(oc.id)
|
|
99
|
+
|
|
100
|
+
await z.wait([
|
|
101
|
+
{
|
|
102
|
+
event: 'reinvite',
|
|
103
|
+
call_id: ic.id
|
|
104
|
+
},
|
|
105
|
+
], 1000)
|
|
106
|
+
|
|
107
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
108
|
+
|
|
109
|
+
await z.wait([
|
|
110
|
+
{
|
|
111
|
+
event: 'response',
|
|
112
|
+
call_id: oc.id,
|
|
113
|
+
method: 'INVITE',
|
|
114
|
+
msg: sip_msg({
|
|
115
|
+
$rs: '100',
|
|
116
|
+
}),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
event: 'response',
|
|
120
|
+
call_id: oc.id,
|
|
121
|
+
method: 'INVITE',
|
|
122
|
+
msg: sip_msg({
|
|
123
|
+
$rs: '200',
|
|
124
|
+
$rr: 'OK',
|
|
125
|
+
$rb: '!{_}a=sendrecv',
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
event: 'media_update',
|
|
130
|
+
call_id: oc.id,
|
|
131
|
+
status: 'ok',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
event: 'media_update',
|
|
135
|
+
call_id: ic.id,
|
|
136
|
+
status: 'ok',
|
|
137
|
+
},
|
|
138
|
+
], 500)
|
|
139
|
+
|
|
140
|
+
sip.call.reinvite(oc.id, false, 0)
|
|
141
|
+
|
|
142
|
+
await z.wait([
|
|
143
|
+
{
|
|
144
|
+
event: 'reinvite',
|
|
145
|
+
call_id: ic.id
|
|
146
|
+
},
|
|
147
|
+
], 1000)
|
|
148
|
+
|
|
149
|
+
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
150
|
+
|
|
151
|
+
await z.wait([
|
|
152
|
+
{
|
|
153
|
+
event: 'response',
|
|
154
|
+
call_id: oc.id,
|
|
155
|
+
method: 'INVITE',
|
|
156
|
+
msg: sip_msg({
|
|
157
|
+
$rs: '100',
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
event: 'response',
|
|
162
|
+
call_id: oc.id,
|
|
163
|
+
method: 'INVITE',
|
|
164
|
+
msg: sip_msg({
|
|
165
|
+
$rs: '200',
|
|
166
|
+
$rr: 'OK',
|
|
167
|
+
$rb: '!{_}a=sendrecv',
|
|
168
|
+
}),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
event: 'media_update',
|
|
172
|
+
call_id: oc.id,
|
|
173
|
+
status: 'ok',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
event: 'media_update',
|
|
177
|
+
call_id: ic.id,
|
|
178
|
+
status: 'ok',
|
|
179
|
+
},
|
|
180
|
+
], 500)
|
|
181
|
+
|
|
182
|
+
oc_stat = sip.call.get_stream_stat(oc.id, {media_id: 0})
|
|
183
|
+
ic_stat = sip.call.get_stream_stat(ic.id, {media_id: 0})
|
|
184
|
+
|
|
185
|
+
console.log(oc_stat)
|
|
186
|
+
console.log(ic_stat)
|
|
187
|
+
|
|
188
|
+
oc_stat = JSON.parse(oc_stat)
|
|
189
|
+
ic_stat = JSON.parse(ic_stat)
|
|
190
|
+
|
|
191
|
+
assert(oc_stat.CodecInfo == 'opus/8000/1')
|
|
192
|
+
assert(ic_stat.CodecInfo == 'opus/8000/1')
|
|
193
|
+
|
|
194
|
+
await z.sleep(100)
|
|
195
|
+
|
|
196
|
+
sip.call.send_dtmf(oc.id, {digits: '12', mode: 1})
|
|
197
|
+
sip.call.send_dtmf(ic.id, {digits: '21', mode: 1})
|
|
198
|
+
|
|
199
|
+
await z.sleep(1000)
|
|
200
|
+
|
|
201
|
+
sip.call.stop_record_wav(oc.id)
|
|
202
|
+
sip.call.stop_record_wav(ic.id)
|
|
203
|
+
|
|
204
|
+
sip.call.terminate(oc.id)
|
|
205
|
+
|
|
206
|
+
await z.wait([
|
|
207
|
+
{
|
|
208
|
+
event: 'call_ended',
|
|
209
|
+
call_id: oc.id,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
event: 'call_ended',
|
|
213
|
+
call_id: ic.id,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
event: 'response',
|
|
217
|
+
call_id: oc.id,
|
|
218
|
+
method: 'BYE',
|
|
219
|
+
msg: sip_msg({
|
|
220
|
+
$rs: '200',
|
|
221
|
+
$rr: 'OK',
|
|
222
|
+
}),
|
|
223
|
+
},
|
|
224
|
+
], 1000)
|
|
225
|
+
|
|
226
|
+
console.log("Success")
|
|
227
|
+
|
|
228
|
+
sip.stop()
|
|
229
|
+
process.exit(0)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
test()
|
|
233
|
+
.catch(e => {
|
|
234
|
+
console.error(e)
|
|
235
|
+
process.exit(1)
|
|
236
|
+
})
|
package/src/sip.cpp
CHANGED
|
@@ -1558,6 +1558,29 @@ int __pjw_init() {
|
|
|
1558
1558
|
addon_log(L_DBG, "pjmedia_codec_opus_init failed\n");
|
|
1559
1559
|
return 1;
|
|
1560
1560
|
}
|
|
1561
|
+
pjmedia_codec_param param;
|
|
1562
|
+
pjmedia_codec_opus_config opus_cfg;
|
|
1563
|
+
|
|
1564
|
+
pjmedia_codec_mgr *codec_mgr;
|
|
1565
|
+
codec_mgr = pjmedia_endpt_get_codec_mgr(g_med_endpt);
|
|
1566
|
+
|
|
1567
|
+
unsigned cnt = 1;
|
|
1568
|
+
const pjmedia_codec_info *pci;
|
|
1569
|
+
|
|
1570
|
+
pj_str_t codec_id = pj_str((char*)"opus/48000/2");
|
|
1571
|
+
pjmedia_codec_mgr_find_codecs_by_id(codec_mgr, &codec_id, &cnt, &pci, NULL);
|
|
1572
|
+
pjmedia_codec_mgr_get_default_param(codec_mgr, pci, ¶m);
|
|
1573
|
+
pjmedia_codec_opus_get_config(&opus_cfg);
|
|
1574
|
+
|
|
1575
|
+
opus_cfg.sample_rate = 8000;
|
|
1576
|
+
opus_cfg.channel_cnt = 1;
|
|
1577
|
+
opus_cfg.bit_rate = 8000;
|
|
1578
|
+
status = pjmedia_codec_opus_set_default_param(&opus_cfg, ¶m);
|
|
1579
|
+
if(status != PJ_SUCCESS)
|
|
1580
|
+
{
|
|
1581
|
+
addon_log(L_DBG, "pjmedia_codec_opus_set_default_param failed\n");
|
|
1582
|
+
return 1;
|
|
1583
|
+
}
|
|
1561
1584
|
#endif
|
|
1562
1585
|
|
|
1563
1586
|
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
|