sip-lab 1.17.7 → 1.17.9
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 +1 -1
- package/prebuilds/linux-x64/sip-lab.node +0 -0
- package/samples/reinvite_and_dtmf.js +94 -5
- package/samples/simple.js +2 -0
- package/src/sip.cpp +27 -14
package/package.json
CHANGED
|
Binary file
|
|
@@ -16,6 +16,8 @@ async function test() {
|
|
|
16
16
|
return e
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
+
sip.set_codecs("pcmu/8000/1:128,pcma/8000/1:128,gsm/8000/1:128")
|
|
20
|
+
|
|
19
21
|
console.log(sip.start((data) => { console.log(data)} ))
|
|
20
22
|
|
|
21
23
|
t1 = sip.transport.create({address: "127.0.0.1", type: 'udp'})
|
|
@@ -53,6 +55,9 @@ async function test() {
|
|
|
53
55
|
sip_call_id: z.store.sip_call_id,
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
// force answer with pcma
|
|
59
|
+
sip.set_codecs("pcma/8000/1:128")
|
|
60
|
+
|
|
56
61
|
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
57
62
|
|
|
58
63
|
await z.wait([
|
|
@@ -85,8 +90,12 @@ async function test() {
|
|
|
85
90
|
remote: {
|
|
86
91
|
port: 10002,
|
|
87
92
|
mode: 'sendrecv'
|
|
88
|
-
}
|
|
89
|
-
|
|
93
|
+
},
|
|
94
|
+
fmt: [
|
|
95
|
+
'8 PCMA/8000',
|
|
96
|
+
'120 telephone-event/8000',
|
|
97
|
+
],
|
|
98
|
+
},
|
|
90
99
|
],
|
|
91
100
|
},
|
|
92
101
|
{
|
|
@@ -103,7 +112,11 @@ async function test() {
|
|
|
103
112
|
remote: {
|
|
104
113
|
port: 10000,
|
|
105
114
|
mode: 'sendrecv'
|
|
106
|
-
}
|
|
115
|
+
},
|
|
116
|
+
fmt: [
|
|
117
|
+
'8 PCMA/8000',
|
|
118
|
+
'120 telephone-event/8000',
|
|
119
|
+
],
|
|
107
120
|
}
|
|
108
121
|
],
|
|
109
122
|
},
|
|
@@ -130,7 +143,8 @@ async function test() {
|
|
|
130
143
|
], 1500)
|
|
131
144
|
|
|
132
145
|
for(i=0 ;i< 3; i++) {
|
|
133
|
-
|
|
146
|
+
sip.set_codecs("pcmu/8000/1:128,pcma/8000/1:128,gsm/8000/1:128")
|
|
147
|
+
|
|
134
148
|
sip.call.reinvite(oc.id)
|
|
135
149
|
|
|
136
150
|
await z.wait([
|
|
@@ -140,6 +154,9 @@ async function test() {
|
|
|
140
154
|
},
|
|
141
155
|
], 500)
|
|
142
156
|
|
|
157
|
+
// force answer with pcma
|
|
158
|
+
sip.set_codecs("pcma/8000/1:128")
|
|
159
|
+
|
|
143
160
|
sip.call.respond(ic.id, {code: 200, reason: 'OK'})
|
|
144
161
|
|
|
145
162
|
await z.wait([
|
|
@@ -165,15 +182,50 @@ async function test() {
|
|
|
165
182
|
event: 'media_update',
|
|
166
183
|
call_id: oc.id,
|
|
167
184
|
status: 'ok',
|
|
185
|
+
media: [
|
|
186
|
+
{
|
|
187
|
+
type: 'audio',
|
|
188
|
+
local: {
|
|
189
|
+
port: 10000,
|
|
190
|
+
mode: 'sendrecv'
|
|
191
|
+
},
|
|
192
|
+
remote: {
|
|
193
|
+
port: 10002,
|
|
194
|
+
mode: 'sendrecv'
|
|
195
|
+
},
|
|
196
|
+
fmt: [
|
|
197
|
+
'8 PCMA/8000',
|
|
198
|
+
'120 telephone-event/8000',
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
168
202
|
},
|
|
169
203
|
{
|
|
170
204
|
event: 'media_update',
|
|
171
205
|
call_id: ic.id,
|
|
172
206
|
status: 'ok',
|
|
207
|
+
media: [
|
|
208
|
+
{
|
|
209
|
+
type: 'audio',
|
|
210
|
+
local: {
|
|
211
|
+
port: 10002,
|
|
212
|
+
mode: 'sendrecv'
|
|
213
|
+
},
|
|
214
|
+
remote: {
|
|
215
|
+
port: 10000,
|
|
216
|
+
mode: 'sendrecv'
|
|
217
|
+
},
|
|
218
|
+
fmt: [
|
|
219
|
+
'8 PCMA/8000',
|
|
220
|
+
'120 telephone-event/8000',
|
|
221
|
+
],
|
|
222
|
+
}
|
|
223
|
+
],
|
|
173
224
|
},
|
|
174
225
|
], 500)
|
|
175
226
|
|
|
176
|
-
|
|
227
|
+
sip.set_codecs("pcmu/8000/1:128,pcma/8000/1:128,gsm/8000/1:128")
|
|
228
|
+
|
|
177
229
|
sip.call.reinvite(ic.id)
|
|
178
230
|
|
|
179
231
|
await z.wait([
|
|
@@ -183,6 +235,9 @@ async function test() {
|
|
|
183
235
|
},
|
|
184
236
|
], 500)
|
|
185
237
|
|
|
238
|
+
// force answer with pcma
|
|
239
|
+
sip.set_codecs("pcma/8000/1:128")
|
|
240
|
+
|
|
186
241
|
sip.call.respond(oc.id, {code: 200, reason: 'OK'})
|
|
187
242
|
|
|
188
243
|
await z.wait([
|
|
@@ -207,11 +262,45 @@ async function test() {
|
|
|
207
262
|
event: 'media_update',
|
|
208
263
|
call_id: oc.id,
|
|
209
264
|
status: 'ok',
|
|
265
|
+
media: [
|
|
266
|
+
{
|
|
267
|
+
type: 'audio',
|
|
268
|
+
local: {
|
|
269
|
+
port: 10000,
|
|
270
|
+
mode: 'sendrecv'
|
|
271
|
+
},
|
|
272
|
+
remote: {
|
|
273
|
+
port: 10002,
|
|
274
|
+
mode: 'sendrecv'
|
|
275
|
+
},
|
|
276
|
+
fmt: [
|
|
277
|
+
'8 PCMA/8000',
|
|
278
|
+
'120 telephone-event/8000',
|
|
279
|
+
],
|
|
280
|
+
},
|
|
281
|
+
],
|
|
210
282
|
},
|
|
211
283
|
{
|
|
212
284
|
event: 'media_update',
|
|
213
285
|
call_id: ic.id,
|
|
214
286
|
status: 'ok',
|
|
287
|
+
media: [
|
|
288
|
+
{
|
|
289
|
+
type: 'audio',
|
|
290
|
+
local: {
|
|
291
|
+
port: 10002,
|
|
292
|
+
mode: 'sendrecv'
|
|
293
|
+
},
|
|
294
|
+
remote: {
|
|
295
|
+
port: 10000,
|
|
296
|
+
mode: 'sendrecv'
|
|
297
|
+
},
|
|
298
|
+
fmt: [
|
|
299
|
+
'8 PCMA/8000',
|
|
300
|
+
'120 telephone-event/8000',
|
|
301
|
+
],
|
|
302
|
+
}
|
|
303
|
+
],
|
|
215
304
|
},
|
|
216
305
|
], 500)
|
|
217
306
|
|
package/samples/simple.js
CHANGED
package/src/sip.cpp
CHANGED
|
@@ -5446,9 +5446,12 @@ int pjw_set_codecs(const char *in_codec_info) {
|
|
|
5446
5446
|
// char error[1000];
|
|
5447
5447
|
pjmedia_codec_mgr *codec_mgr;
|
|
5448
5448
|
pj_status_t status;
|
|
5449
|
-
char codec_info[
|
|
5449
|
+
char codec_info[1024];
|
|
5450
5450
|
pj_str_t codec_id;
|
|
5451
|
-
|
|
5451
|
+
|
|
5452
|
+
char *token_comma;
|
|
5453
|
+
|
|
5454
|
+
char *saveptr;
|
|
5452
5455
|
|
|
5453
5456
|
PJW_LOCK();
|
|
5454
5457
|
|
|
@@ -5467,26 +5470,36 @@ int pjw_set_codecs(const char *in_codec_info) {
|
|
|
5467
5470
|
|
|
5468
5471
|
strcpy(codec_info, in_codec_info);
|
|
5469
5472
|
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5473
|
+
printf("in_codec_info='%s'\n", in_codec_info);
|
|
5474
|
+
printf(" codec_info='%s'\n", codec_info);
|
|
5475
|
+
|
|
5476
|
+
token_comma = strtok_r(codec_info, ",", &saveptr);
|
|
5477
|
+
|
|
5478
|
+
while (token_comma != NULL) {
|
|
5479
|
+
printf("Token: '%s'\n", token_comma);
|
|
5480
|
+
|
|
5481
|
+
char *colon_position = strchr(token_comma, ':');
|
|
5482
|
+
if (colon_position == NULL) {
|
|
5478
5483
|
set_error("malformed argument codec_info");
|
|
5479
|
-
|
|
5484
|
+
break;
|
|
5480
5485
|
}
|
|
5481
5486
|
|
|
5482
|
-
|
|
5487
|
+
*colon_position = '\0'; // Replace colon with null terminator
|
|
5488
|
+
char *codec_id_s = token_comma;
|
|
5489
|
+
char *prio = colon_position + 1;
|
|
5490
|
+
|
|
5491
|
+
printf("codec_id=%s prio=%s\n", codec_id_s, prio);
|
|
5492
|
+
|
|
5493
|
+
codec_id = pj_str(codec_id_s);
|
|
5494
|
+
|
|
5483
5495
|
status =
|
|
5484
5496
|
pjmedia_codec_mgr_set_codec_priority(codec_mgr, &codec_id, atoi(prio));
|
|
5485
5497
|
if (status != PJ_SUCCESS) {
|
|
5486
5498
|
set_error("pjmedia_codec_mgr_set_codec_priority failed");
|
|
5487
|
-
|
|
5499
|
+
break;
|
|
5488
5500
|
}
|
|
5489
|
-
|
|
5501
|
+
|
|
5502
|
+
token_comma = strtok_r(NULL, ",", &saveptr);
|
|
5490
5503
|
}
|
|
5491
5504
|
|
|
5492
5505
|
out:
|