sip-lab 1.7.1 → 1.7.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/package.json +1 -1
- package/samples/g729.js +14 -0
- package/src/sip.cpp +65 -70
package/package.json
CHANGED
package/samples/g729.js
CHANGED
|
@@ -4,6 +4,8 @@ var z = new Zester()
|
|
|
4
4
|
var m = require('data-matching')
|
|
5
5
|
var sip_msg = require('sip-matching')
|
|
6
6
|
|
|
7
|
+
var assert = require('assert')
|
|
8
|
+
|
|
7
9
|
async function test() {
|
|
8
10
|
//sip.set_log_level(6)
|
|
9
11
|
sip.dtmf_aggregation_on(500)
|
|
@@ -146,6 +148,18 @@ async function test() {
|
|
|
146
148
|
},
|
|
147
149
|
], 500)
|
|
148
150
|
|
|
151
|
+
oc_stat = sip.call.get_stream_stat(oc.id)
|
|
152
|
+
ic_stat = sip.call.get_stream_stat(ic.id)
|
|
153
|
+
|
|
154
|
+
console.log(oc_stat)
|
|
155
|
+
console.log(ic_stat)
|
|
156
|
+
|
|
157
|
+
oc_stat = JSON.parse(oc_stat)
|
|
158
|
+
ic_stat = JSON.parse(ic_stat)
|
|
159
|
+
|
|
160
|
+
assert(oc_stat.CodecInfo == 'G729/8000/1')
|
|
161
|
+
assert(ic_stat.CodecInfo == 'G729/8000/1')
|
|
162
|
+
|
|
149
163
|
sip.call.terminate(oc.id)
|
|
150
164
|
|
|
151
165
|
await z.wait([
|
package/src/sip.cpp
CHANGED
|
@@ -346,7 +346,7 @@ void process_in_dialog_subscribe(pjsip_dialog *dlg, pjsip_rx_data *rdata);
|
|
|
346
346
|
|
|
347
347
|
static pj_bool_t set_ports(Call *call, pjmedia_port *stream_port, pjmedia_port *media_port);
|
|
348
348
|
//static pj_bool_t stop_media_operation(Call *call);
|
|
349
|
-
static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat,
|
|
349
|
+
static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat, pjmedia_stream_info *stream_info);
|
|
350
350
|
|
|
351
351
|
bool init_media_ports(Call *c, unsigned sampling_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample);
|
|
352
352
|
void connect_media_ports(Call *c);
|
|
@@ -1417,7 +1417,7 @@ out:
|
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
1419
|
|
|
1420
|
-
bool
|
|
1420
|
+
bool dlg_set_transport(pjsip_transport *sip_transport, pjsip_dialog *dlg) {
|
|
1421
1421
|
//Maybe we don't need to allocation sel from the pool
|
|
1422
1422
|
pjsip_tpselector *sel = (pjsip_tpselector*)pj_pool_zalloc(dlg->pool, sizeof(pjsip_tpselector));
|
|
1423
1423
|
//pjsip_tpselector sel;
|
|
@@ -1434,7 +1434,7 @@ bool set_transport(pjsip_transport *sip_transport, pjsip_dialog *dlg) {
|
|
|
1434
1434
|
return true;
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
|
-
bool
|
|
1437
|
+
bool dlg_set_transport_by_t(Transport *t, pjsip_dialog *dlg) {
|
|
1438
1438
|
//Maybe we don't need to allocation sel from the pool
|
|
1439
1439
|
pjsip_tpselector *sel = (pjsip_tpselector*)pj_pool_zalloc(dlg->pool, sizeof(pjsip_tpselector));
|
|
1440
1440
|
//pjsip_tpselector sel;
|
|
@@ -1662,7 +1662,7 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg, const char *pro
|
|
|
1662
1662
|
return -1;
|
|
1663
1663
|
}
|
|
1664
1664
|
|
|
1665
|
-
if(!
|
|
1665
|
+
if(!dlg_set_transport_by_t(t, dlg)){
|
|
1666
1666
|
return -1;
|
|
1667
1667
|
}
|
|
1668
1668
|
addon_log(LOG_LEVEL_DEBUG, "inv=%x tdata=%x\n",inv,tdata);
|
|
@@ -2151,7 +2151,7 @@ int pjw_call_get_stream_stat(long call_id, char *out_stats){
|
|
|
2151
2151
|
pj_status_t status;
|
|
2152
2152
|
|
|
2153
2153
|
pjmedia_rtcp_stat stat;
|
|
2154
|
-
|
|
2154
|
+
pjmedia_stream_info stream_info;
|
|
2155
2155
|
|
|
2156
2156
|
status = pjmedia_stream_get_stat(call->med_stream, &stat);
|
|
2157
2157
|
if(status != PJ_SUCCESS){
|
|
@@ -2160,15 +2160,15 @@ int pjw_call_get_stream_stat(long call_id, char *out_stats){
|
|
|
2160
2160
|
return -1;
|
|
2161
2161
|
}
|
|
2162
2162
|
|
|
2163
|
-
status =
|
|
2163
|
+
status = pjmedia_stream_get_info(call->med_stream, &stream_info);
|
|
2164
2164
|
if(status != PJ_SUCCESS){
|
|
2165
2165
|
PJW_UNLOCK();
|
|
2166
|
-
set_error("Could not get stream
|
|
2166
|
+
set_error("Could not get stream info. Call to pjmedia_stream_get_info failed.");
|
|
2167
2167
|
return -1;
|
|
2168
2168
|
}
|
|
2169
2169
|
|
|
2170
2170
|
ostringstream oss;
|
|
2171
|
-
build_stream_stat(oss, &stat,
|
|
2171
|
+
build_stream_stat(oss, &stat, &stream_info);
|
|
2172
2172
|
|
|
2173
2173
|
PJW_UNLOCK();
|
|
2174
2174
|
|
|
@@ -2752,7 +2752,7 @@ static pj_bool_t on_rx_request( pjsip_rx_data *rdata ){
|
|
|
2752
2752
|
return PJ_TRUE;
|
|
2753
2753
|
}
|
|
2754
2754
|
|
|
2755
|
-
if(!
|
|
2755
|
+
if(!dlg_set_transport(t, dlg)) {
|
|
2756
2756
|
close_media_transport(med_transport);
|
|
2757
2757
|
reason = pj_str("Internal Server Error (set_transport failed)");
|
|
2758
2758
|
pjsip_endpt_respond_stateless(g_sip_endpt, rdata, 500, &reason, NULL, NULL);
|
|
@@ -3384,7 +3384,7 @@ static const char *good_number(char *buf, pj_int32_t val)
|
|
|
3384
3384
|
return buf;
|
|
3385
3385
|
}
|
|
3386
3386
|
|
|
3387
|
-
static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat,
|
|
3387
|
+
static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat, pjmedia_stream_info *stream_info)
|
|
3388
3388
|
{
|
|
3389
3389
|
char temp[200];
|
|
3390
3390
|
char duration[80], last_update[80];
|
|
@@ -3396,7 +3396,7 @@ static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat, pjmed
|
|
|
3396
3396
|
oss << "{ ";
|
|
3397
3397
|
|
|
3398
3398
|
PJ_TIME_VAL_SUB(now, stat->start);
|
|
3399
|
-
sprintf(duration, "
|
|
3399
|
+
sprintf(duration, "\"Duration\": \"%02ld:%02ld:%02ld.%03ld\"",
|
|
3400
3400
|
now.sec / 3600,
|
|
3401
3401
|
(now.sec % 3600) / 60,
|
|
3402
3402
|
(now.sec % 60),
|
|
@@ -3404,59 +3404,54 @@ static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat, pjmed
|
|
|
3404
3404
|
|
|
3405
3405
|
oss << duration;
|
|
3406
3406
|
|
|
3407
|
-
sprintf(temp, ",
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
*/
|
|
3413
|
-
/* lets put fake info for now */
|
|
3414
|
-
4,
|
|
3415
|
-
"FAKE",
|
|
3416
|
-
0);
|
|
3407
|
+
sprintf(temp, ", \"CodecInfo\": \"%.*s/%d/%d\"",
|
|
3408
|
+
stream_info->fmt.encoding_name.slen,
|
|
3409
|
+
stream_info->fmt.encoding_name.ptr,
|
|
3410
|
+
stream_info->fmt.clock_rate,
|
|
3411
|
+
stream_info->fmt.channel_cnt);
|
|
3417
3412
|
|
|
3418
3413
|
oss << temp << ",";
|
|
3419
3414
|
|
|
3420
|
-
oss << "
|
|
3415
|
+
oss << " \"RX\": { "; //Opening RX
|
|
3421
3416
|
|
|
3422
3417
|
if (stat->rx.update_cnt == 0)
|
|
3423
|
-
strcpy(last_update, "
|
|
3418
|
+
strcpy(last_update, "\"LastUpdate\": \"\"");
|
|
3424
3419
|
else {
|
|
3425
|
-
sprintf(last_update, "
|
|
3420
|
+
sprintf(last_update, "\"LastUpdate\": \"%ld.%ld\"",
|
|
3426
3421
|
stat->rx.update.sec,
|
|
3427
3422
|
stat->rx.update.msec);
|
|
3428
3423
|
}
|
|
3429
3424
|
|
|
3430
3425
|
oss << last_update;
|
|
3431
3426
|
|
|
3432
|
-
oss << ",
|
|
3433
|
-
oss << ",
|
|
3434
|
-
oss << ",
|
|
3435
|
-
oss << ",
|
|
3436
|
-
|
|
3437
|
-
oss << ",
|
|
3438
|
-
oss << "
|
|
3439
|
-
oss << ",
|
|
3440
|
-
oss << ",
|
|
3441
|
-
oss << ",
|
|
3442
|
-
oss << ",
|
|
3443
|
-
|
|
3444
|
-
oss << ",
|
|
3445
|
-
oss << "
|
|
3446
|
-
oss << ",
|
|
3447
|
-
oss << ",
|
|
3448
|
-
oss << ",
|
|
3449
|
-
oss << ",
|
|
3427
|
+
oss << ", \"Packets\": " << good_number(packets, stat->rx.pkt);
|
|
3428
|
+
oss << ", \"Loss\": " << stat->rx.loss;
|
|
3429
|
+
oss << ", \"Dup\": " << stat->rx.dup;
|
|
3430
|
+
oss << ", \"Reorder\": " << stat->rx.reorder;
|
|
3431
|
+
|
|
3432
|
+
oss << ", \"LossPeriod\": {";
|
|
3433
|
+
oss << "\"Min\": " << stat->rx.loss_period.min / 1000.0;
|
|
3434
|
+
oss << ", \"Mean\": " << stat->rx.loss_period.mean / 1000.0;
|
|
3435
|
+
oss << ", \"Max\": " << stat->rx.loss_period.max / 1000.0;
|
|
3436
|
+
oss << ", \"Last\": " << stat->rx.loss_period.last / 1000.0;
|
|
3437
|
+
oss << ", \"StandardDeviation\": " << pj_math_stat_get_stddev(&stat->rx.loss_period) / 1000.0 << " }";
|
|
3438
|
+
|
|
3439
|
+
oss << ", \"Jitter\": { ";
|
|
3440
|
+
oss << "\"Min\": " << stat->rx.jitter.min / 1000.0;
|
|
3441
|
+
oss << ", \"Mean\": " << stat->rx.jitter.mean / 1000.0;
|
|
3442
|
+
oss << ", \"Max\": " << stat->rx.jitter.max / 1000.0;
|
|
3443
|
+
oss << ", \"Last\": " << stat->rx.jitter.last / 1000.0;
|
|
3444
|
+
oss << ", \"StandardDeviation\": " << pj_math_stat_get_stddev(&stat->rx.jitter) / 1000.0 << " }";
|
|
3450
3445
|
|
|
3451
3446
|
oss << " }"; //Closing RX
|
|
3452
3447
|
|
|
3453
3448
|
|
|
3454
|
-
oss << ",
|
|
3449
|
+
oss << ", \"TX\": { "; //Opening TX
|
|
3455
3450
|
|
|
3456
3451
|
if (stat->tx.update_cnt == 0)
|
|
3457
|
-
strcpy(last_update, "
|
|
3452
|
+
strcpy(last_update, "\"LastUpdate\": \"\"");
|
|
3458
3453
|
else {
|
|
3459
|
-
sprintf(last_update, "
|
|
3454
|
+
sprintf(last_update, "\"LastUpdate\": \"%ld.%ld\"",
|
|
3460
3455
|
stat->tx.update.sec,
|
|
3461
3456
|
stat->tx.update.msec);
|
|
3462
3457
|
}
|
|
@@ -3464,34 +3459,34 @@ static void build_stream_stat(ostringstream &oss, pjmedia_rtcp_stat *stat, pjmed
|
|
|
3464
3459
|
|
|
3465
3460
|
oss << last_update;
|
|
3466
3461
|
|
|
3467
|
-
oss << ",
|
|
3468
|
-
oss << ",
|
|
3469
|
-
oss << ",
|
|
3470
|
-
oss << ",
|
|
3471
|
-
|
|
3472
|
-
oss << ",
|
|
3473
|
-
oss << "
|
|
3474
|
-
oss << ",
|
|
3475
|
-
oss << ",
|
|
3476
|
-
oss << ",
|
|
3477
|
-
oss << ",
|
|
3478
|
-
|
|
3479
|
-
oss << ",
|
|
3480
|
-
oss << "
|
|
3481
|
-
oss << ",
|
|
3482
|
-
oss << ",
|
|
3483
|
-
oss << ",
|
|
3484
|
-
oss << ",
|
|
3462
|
+
oss << ", \"Packets\": " << good_number(packets, stat->tx.pkt);
|
|
3463
|
+
oss << ", \"Loss\": " << stat->tx.loss;
|
|
3464
|
+
oss << ", \"Dup\": " << stat->tx.dup;
|
|
3465
|
+
oss << ", \"Reorder\": " << stat->tx.reorder;
|
|
3466
|
+
|
|
3467
|
+
oss << ", \"LossPeriod\": { ";
|
|
3468
|
+
oss << "\"Min\": " << stat->tx.loss_period.min / 1000.0;
|
|
3469
|
+
oss << ", \"Mean\": " << stat->tx.loss_period.mean / 1000.0;
|
|
3470
|
+
oss << ", \"Max\": " << stat->tx.loss_period.max / 1000.0;
|
|
3471
|
+
oss << ", \"Last\":" << stat->tx.loss_period.last / 1000.0;
|
|
3472
|
+
oss << ", \"StandardDeviation\": " << pj_math_stat_get_stddev(&stat->tx.loss_period) / 1000.0 << " }";
|
|
3473
|
+
|
|
3474
|
+
oss << ", \"Jitter\": { ";
|
|
3475
|
+
oss << "\"Min\": " << stat->tx.jitter.min / 1000.0;
|
|
3476
|
+
oss << ", \"Mean\": " << stat->tx.jitter.mean / 1000.0;
|
|
3477
|
+
oss << ", \"Max\": " << stat->tx.jitter.max / 1000.0;
|
|
3478
|
+
oss << ", \"Last\": " << stat->tx.jitter.last / 1000.0;
|
|
3479
|
+
oss << ", \"StandardDeviation\": " << pj_math_stat_get_stddev(&stat->tx.jitter) / 1000.0 << " }";
|
|
3485
3480
|
|
|
3486
3481
|
oss << " }"; //Closing TX
|
|
3487
3482
|
|
|
3488
|
-
oss << ",
|
|
3483
|
+
oss << ", \"RTT\": { "; // Opening RTT
|
|
3489
3484
|
|
|
3490
|
-
oss << "
|
|
3491
|
-
oss << ",
|
|
3492
|
-
oss << ",
|
|
3493
|
-
oss << ",
|
|
3494
|
-
oss << ",
|
|
3485
|
+
oss << "\"Min\": " << stat->rtt.min / 1000.0;
|
|
3486
|
+
oss << ", \"Mean\": " << stat->rtt.mean / 1000.0;
|
|
3487
|
+
oss << ", \"Max\": " << stat->rtt.max / 1000.0;
|
|
3488
|
+
oss << ", \"Last\": " << stat->rtt.last / 1000.0;
|
|
3489
|
+
oss << ", \"StandardDeviation\": " << pj_math_stat_get_stddev(&stat->rtt) / 1000.0;
|
|
3495
3490
|
oss << " }"; //Closing RTT
|
|
3496
3491
|
oss << " }";
|
|
3497
3492
|
}
|
|
@@ -4642,7 +4637,7 @@ int pjw_subscription_create(long transport_id, const char *event, const char *ac
|
|
|
4642
4637
|
goto out;
|
|
4643
4638
|
}
|
|
4644
4639
|
|
|
4645
|
-
if(!
|
|
4640
|
+
if(!dlg_set_transport_by_t(t, dlg)){
|
|
4646
4641
|
goto out;
|
|
4647
4642
|
}
|
|
4648
4643
|
|