sip-lab 1.30.0 → 1.31.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/index.js +1 -0
- package/package.json +2 -2
- 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/custom_call_id.js +219 -0
- package/samples/custom_call_id_and_from_tag.js.future +224 -0
- package/samples/media_fields.js +190 -0
- package/samples/mrcp_and_audio.js +0 -12
- package/samples/session_expires.update.js.future +268 -0
- package/samples/session_expires.update.with_sipjs-lab.js +312 -0
- package/src/addon.cpp +35 -0
- package/src/sip.cpp +140 -34
- package/src/sip.hpp +2 -0
package/src/sip.cpp
CHANGED
|
@@ -614,7 +614,7 @@ void build_local_contact_from_tpfactory(char *dest, pjsip_tpfactory *tpfactory,
|
|
|
614
614
|
// pj_bool_t add_additional_headers(pj_pool_t *pool, pjsip_tx_data *tdata, const
|
|
615
615
|
// char *additional_headers);
|
|
616
616
|
pj_bool_t add_headers(pj_pool_t *pool, pjsip_tx_data *tdata,
|
|
617
|
-
Document &document);
|
|
617
|
+
Document &document, pjsip_dialog *dlg);
|
|
618
618
|
|
|
619
619
|
pj_bool_t add_headers_for_account(pjsip_regc *regc, Document &document);
|
|
620
620
|
|
|
@@ -2361,6 +2361,10 @@ int pjw_call_respond(long call_id, const char *json) {
|
|
|
2361
2361
|
|
|
2362
2362
|
status = pjsip_dlg_send_response(call->inv->dlg, tsx, tdata);
|
|
2363
2363
|
|
|
2364
|
+
if (status != PJ_SUCCESS) {
|
|
2365
|
+
printf("Failed to send response, status=%d\n", status);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2364
2368
|
assert(status == PJ_SUCCESS);
|
|
2365
2369
|
|
|
2366
2370
|
if (code >= 200) {
|
|
@@ -2423,11 +2427,9 @@ int pjw_call_respond(long call_id, const char *json) {
|
|
|
2423
2427
|
}
|
|
2424
2428
|
call->pending_rdata = 0;
|
|
2425
2429
|
|
|
2426
|
-
|
|
2427
|
-
call->pending_request = -1;
|
|
2430
|
+
call->pending_request = -1;
|
|
2428
2431
|
|
|
2429
|
-
|
|
2430
|
-
}
|
|
2432
|
+
pjsip_msg_find_remove_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
|
|
2431
2433
|
}
|
|
2432
2434
|
} else {
|
|
2433
2435
|
status = pjsip_inv_answer(call->inv, code, &r,
|
|
@@ -2448,15 +2450,26 @@ int pjw_call_respond(long call_id, const char *json) {
|
|
|
2448
2450
|
call->pending_rdata = 0;
|
|
2449
2451
|
}
|
|
2450
2452
|
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
+
call->pending_request = -1;
|
|
2454
|
+
|
|
2455
|
+
/*
|
|
2456
|
+
int printed;
|
|
2457
|
+
char buf[2048];
|
|
2458
|
+
printed = pjsip_msg_print(tdata->msg, buf, sizeof(buf));
|
|
2459
|
+
printf("tdata before len=%i :\n%s\n", printed, buf);
|
|
2460
|
+
*/
|
|
2453
2461
|
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2462
|
+
// the below works (header Supported is removed)
|
|
2463
|
+
// but something (the 100rel module) adds 'Supported: 100rel' later.
|
|
2464
|
+
pjsip_msg_find_remove_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
|
|
2465
|
+
|
|
2466
|
+
/*
|
|
2467
|
+
printed = pjsip_msg_print(tdata->msg, buf, sizeof(buf));
|
|
2468
|
+
printf("tdata after len=%i :\n%s\n", printed, buf);
|
|
2469
|
+
*/
|
|
2457
2470
|
}
|
|
2458
2471
|
|
|
2459
|
-
if (!add_headers(call->inv->dlg->pool, tdata, document)) {
|
|
2472
|
+
if (!add_headers(call->inv->dlg->pool, tdata, document, NULL)) {
|
|
2460
2473
|
goto out;
|
|
2461
2474
|
}
|
|
2462
2475
|
}
|
|
@@ -2537,7 +2550,7 @@ int pjw_call_terminate(long call_id, const char *json) {
|
|
|
2537
2550
|
goto out;
|
|
2538
2551
|
}
|
|
2539
2552
|
|
|
2540
|
-
if (!add_headers(call->inv->dlg->pool, tdata, document)) {
|
|
2553
|
+
if (!add_headers(call->inv->dlg->pool, tdata, document, NULL)) {
|
|
2541
2554
|
goto out;
|
|
2542
2555
|
}
|
|
2543
2556
|
|
|
@@ -2674,7 +2687,7 @@ int pjw_request_create(long t_id, const char *json, long *out_request_id,
|
|
|
2674
2687
|
goto out;
|
|
2675
2688
|
}
|
|
2676
2689
|
|
|
2677
|
-
if (!add_headers(tdata->pool, tdata, document)) {
|
|
2690
|
+
if (!add_headers(tdata->pool, tdata, document, NULL)) {
|
|
2678
2691
|
goto out;
|
|
2679
2692
|
}
|
|
2680
2693
|
|
|
@@ -2774,7 +2787,7 @@ int pjw_request_respond(long request_id, const char *json) {
|
|
|
2774
2787
|
goto out;
|
|
2775
2788
|
}
|
|
2776
2789
|
|
|
2777
|
-
if (!add_headers(tdata->pool, tdata, document)) {
|
|
2790
|
+
if (!add_headers(tdata->pool, tdata, document, NULL)) {
|
|
2778
2791
|
goto out;
|
|
2779
2792
|
}
|
|
2780
2793
|
|
|
@@ -2843,7 +2856,7 @@ int pjw_call_create(long t_id, const char *json, long *out_call_id,
|
|
|
2843
2856
|
|
|
2844
2857
|
const char *valid_params[] = {"from_uri", "to_uri", "request_uri",
|
|
2845
2858
|
"proxy_uri", "auth", "delayed_media",
|
|
2846
|
-
"headers", "media", ""};
|
|
2859
|
+
"headers", "media", "from_tag", ""};
|
|
2847
2860
|
|
|
2848
2861
|
if (!g_transport_ids.get(t_id, val)) {
|
|
2849
2862
|
set_error("Invalid transport_id");
|
|
@@ -3244,7 +3257,22 @@ int call_create(Transport *t, unsigned flags, pjsip_dialog *dlg,
|
|
|
3244
3257
|
return -1;
|
|
3245
3258
|
}
|
|
3246
3259
|
|
|
3247
|
-
if (
|
|
3260
|
+
if (document.HasMember("from_tag")) {
|
|
3261
|
+
if (!document["from_tag"].IsString()) {
|
|
3262
|
+
g_call_ids.remove(call_id, (long&)call);
|
|
3263
|
+
close_media(call);
|
|
3264
|
+
status = pjsip_dlg_terminate(dlg); // ToDo:
|
|
3265
|
+
set_error("Parameter from_tag must be a string");
|
|
3266
|
+
return -1;
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
char *from_tag = (char *)document["from_tag"].GetString();
|
|
3270
|
+
|
|
3271
|
+
pjsip_from_hdr *from_hdr = (pjsip_from_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, NULL);
|
|
3272
|
+
pj_strdup2(tdata->pool, &from_hdr->tag, from_tag);
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
if (!add_headers(dlg->pool, tdata, document, dlg)) {
|
|
3248
3276
|
g_call_ids.remove(call_id, (long&)call);
|
|
3249
3277
|
close_media(call); // Todo:
|
|
3250
3278
|
status = pjsip_dlg_terminate(dlg); // ToDo:
|
|
@@ -3783,6 +3811,74 @@ out:
|
|
|
3783
3811
|
return 0;
|
|
3784
3812
|
}
|
|
3785
3813
|
|
|
3814
|
+
|
|
3815
|
+
int pjw_call_update(long call_id, const char *json) {
|
|
3816
|
+
addon_log(L_DBG, "pjw_call_update call_id=%d\n", call_id);
|
|
3817
|
+
|
|
3818
|
+
PJW_LOCK();
|
|
3819
|
+
clear_error();
|
|
3820
|
+
|
|
3821
|
+
unsigned flags = 0;
|
|
3822
|
+
|
|
3823
|
+
long val;
|
|
3824
|
+
Call *call;
|
|
3825
|
+
pjsip_inv_session *inv;
|
|
3826
|
+
|
|
3827
|
+
pj_status_t status;
|
|
3828
|
+
|
|
3829
|
+
pjsip_tx_data *tdata;
|
|
3830
|
+
// pjmedia_sdp_session *sdp = 0;
|
|
3831
|
+
|
|
3832
|
+
char buffer[MAX_JSON_INPUT];
|
|
3833
|
+
|
|
3834
|
+
Document document;
|
|
3835
|
+
|
|
3836
|
+
const char *valid_params[] = {"headers", ""};
|
|
3837
|
+
|
|
3838
|
+
if (!g_call_ids.get(call_id, val)) {
|
|
3839
|
+
set_error("Invalid call_id");
|
|
3840
|
+
goto out;
|
|
3841
|
+
}
|
|
3842
|
+
call = (Call *)val;
|
|
3843
|
+
|
|
3844
|
+
inv = call->inv;
|
|
3845
|
+
|
|
3846
|
+
if (!parse_json(document, json, buffer, MAX_JSON_INPUT)) {
|
|
3847
|
+
goto out;
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3850
|
+
if (!validate_params(document, valid_params)) {
|
|
3851
|
+
goto out;
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
status = pjsip_inv_update(call->inv, NULL, NULL, &tdata);
|
|
3855
|
+
printf("status=%d\n", status);
|
|
3856
|
+
if (status != PJ_SUCCESS) {
|
|
3857
|
+
set_error("pjsip_inv_update failed");
|
|
3858
|
+
goto out;
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3861
|
+
pjsip_msg_find_remove_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
|
|
3862
|
+
|
|
3863
|
+
if (!add_headers(call->inv->dlg->pool, tdata, document, NULL)) {
|
|
3864
|
+
goto out;
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
status = pjsip_inv_send_msg(call->inv, tdata);
|
|
3868
|
+
if (status != PJ_SUCCESS) {
|
|
3869
|
+
set_error("pjsip_inv_send_msg failed");
|
|
3870
|
+
goto out;
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
out:
|
|
3874
|
+
PJW_UNLOCK();
|
|
3875
|
+
if (pjw_errorstring[0]) {
|
|
3876
|
+
return -1;
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
return 0;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3786
3882
|
// To send INFO and other requests inside dialog
|
|
3787
3883
|
int pjw_call_send_request(long call_id, const char *json) {
|
|
3788
3884
|
PJW_LOCK();
|
|
@@ -3869,7 +3965,7 @@ int pjw_call_send_request(long call_id, const char *json) {
|
|
|
3869
3965
|
goto out;
|
|
3870
3966
|
}
|
|
3871
3967
|
|
|
3872
|
-
if (!add_headers(call->inv->dlg->pool, tdata, document)) {
|
|
3968
|
+
if (!add_headers(call->inv->dlg->pool, tdata, document, NULL)) {
|
|
3873
3969
|
goto out;
|
|
3874
3970
|
}
|
|
3875
3971
|
|
|
@@ -8267,7 +8363,7 @@ bool notify(pjsip_evsub *evsub, const char *content_type, const char *body,
|
|
|
8267
8363
|
}
|
|
8268
8364
|
s_content_type_subtype = pj_str(tok);
|
|
8269
8365
|
|
|
8270
|
-
if (!add_headers(tdata->pool, tdata, document)) {
|
|
8366
|
+
if (!add_headers(tdata->pool, tdata, document, NULL)) {
|
|
8271
8367
|
return false;
|
|
8272
8368
|
}
|
|
8273
8369
|
|
|
@@ -8444,7 +8540,7 @@ out:
|
|
|
8444
8540
|
}
|
|
8445
8541
|
|
|
8446
8542
|
pj_bool_t add_headers(pj_pool_t *pool, pjsip_tx_data *tdata,
|
|
8447
|
-
Document &document) {
|
|
8543
|
+
Document &document, pjsip_dialog *dlg) {
|
|
8448
8544
|
if (!document.HasMember("headers")) {
|
|
8449
8545
|
return PJ_TRUE;
|
|
8450
8546
|
}
|
|
@@ -8464,24 +8560,34 @@ pj_bool_t add_headers(pj_pool_t *pool, pjsip_tx_data *tdata,
|
|
|
8464
8560
|
}
|
|
8465
8561
|
printf("%s => '%s'\n", itr->name.GetString(), itr->value.GetString());
|
|
8466
8562
|
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8563
|
+
if(stricmp(itr->name.GetString(), "call-id") == 0) {
|
|
8564
|
+
printf("Setting INVIITE call_id->id to %s\n", itr->value.GetString());
|
|
8565
|
+
pjsip_cid_hdr *call_id_hdr = (pjsip_cid_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CALL_ID, NULL);
|
|
8566
|
+
pj_strdup2(tdata->pool, &call_id_hdr->id, itr->value.GetString());
|
|
8567
|
+
if(dlg) {
|
|
8568
|
+
printf("Setting DLG call_id->id to %s\n", itr->value.GetString());
|
|
8569
|
+
pj_strdup2(dlg->pool, &dlg->call_id->id, itr->value.GetString());
|
|
8570
|
+
}
|
|
8571
|
+
} else {
|
|
8572
|
+
const char *name = itr->name.GetString();
|
|
8573
|
+
if (!itr->value.IsString()) {
|
|
8574
|
+
set_error("Parameter headers key '%s' found with non-string value", name);
|
|
8575
|
+
return PJ_FALSE;
|
|
8576
|
+
}
|
|
8472
8577
|
|
|
8473
|
-
|
|
8578
|
+
const char *value = itr->value.GetString();
|
|
8474
8579
|
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8580
|
+
pj_str_t hname = pj_str((char *)name);
|
|
8581
|
+
pjsip_hdr *hdr = (pjsip_hdr *)pjsip_parse_hdr(pool, &hname, (char *)value,
|
|
8582
|
+
strlen(value), NULL);
|
|
8478
8583
|
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8584
|
+
if (!hdr) {
|
|
8585
|
+
set_error("Failed to parse header '%s' => '%s'", name, value);
|
|
8586
|
+
return PJ_FALSE;
|
|
8587
|
+
}
|
|
8588
|
+
pjsip_hdr *clone_hdr = (pjsip_hdr *)pjsip_hdr_clone(pool, hdr);
|
|
8589
|
+
pjsip_msg_add_hdr(tdata->msg, clone_hdr);
|
|
8482
8590
|
}
|
|
8483
|
-
pjsip_hdr *clone_hdr = (pjsip_hdr *)pjsip_hdr_clone(pool, hdr);
|
|
8484
|
-
pjsip_msg_add_hdr(tdata->msg, clone_hdr);
|
|
8485
8591
|
}
|
|
8486
8592
|
return PJ_TRUE;
|
|
8487
8593
|
}
|
|
@@ -8828,7 +8934,7 @@ bool subscription_subscribe(Subscription *s, int expires, Document &document) {
|
|
|
8828
8934
|
return false;
|
|
8829
8935
|
}
|
|
8830
8936
|
|
|
8831
|
-
if (!add_headers(s->dlg->pool, tdata, document)) {
|
|
8937
|
+
if (!add_headers(s->dlg->pool, tdata, document, NULL)) {
|
|
8832
8938
|
return false;
|
|
8833
8939
|
}
|
|
8834
8940
|
|
package/src/sip.hpp
CHANGED
|
@@ -45,6 +45,8 @@ int pjw_call_send_bfsk(long call_id, const char *json);
|
|
|
45
45
|
|
|
46
46
|
int pjw_call_reinvite(long call_id, const char *json);
|
|
47
47
|
|
|
48
|
+
int pjw_call_update(long call_id, const char *json);
|
|
49
|
+
|
|
48
50
|
int pjw_call_send_request(long call_id, const char *json);
|
|
49
51
|
|
|
50
52
|
int pjw_call_start_record_wav(long call_id, const char *file);
|