sip-lab 1.30.0 → 1.32.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.
Files changed (60) hide show
  1. package/index.js +5 -5
  2. package/package.json +2 -2
  3. package/prebuilds/linux-x64/node.abi102.node +0 -0
  4. package/prebuilds/linux-x64/node.abi108.node +0 -0
  5. package/prebuilds/linux-x64/node.abi111.node +0 -0
  6. package/prebuilds/linux-x64/node.abi115.node +0 -0
  7. package/prebuilds/linux-x64/node.abi120.node +0 -0
  8. package/prebuilds/linux-x64/node.abi88.node +0 -0
  9. package/prebuilds/linux-x64/node.abi93.node +0 -0
  10. package/samples/100_calls.js +1 -0
  11. package/samples/16_audio_streams.js +1 -0
  12. package/samples/183_session_progress.js +1 -0
  13. package/samples/custom_call_id.js +220 -0
  14. package/samples/custom_call_id_and_from_tag.js.future +224 -0
  15. package/samples/delayed_media.js +1 -0
  16. package/samples/four_audio_streams_two_refused.js +1 -0
  17. package/samples/g729.js +1 -0
  18. package/samples/media_fields.js +191 -0
  19. package/samples/mrcp_and_audio.js +1 -12
  20. package/samples/mrcp_and_audio.simplified_media.js +1 -0
  21. package/samples/multiple_audio_streams.js +1 -0
  22. package/samples/options.js +1 -0
  23. package/samples/pcma.js +1 -0
  24. package/samples/play_wav_and_speech_recog.bad_transcript.pcmu8000.js +1 -0
  25. package/samples/refer.js +1 -0
  26. package/samples/refuse_telephone_event.js +1 -0
  27. package/samples/register_no_expires.js +1 -0
  28. package/samples/register_subscribe.js +1 -0
  29. package/samples/reinvite_and_dtmf.js +1 -0
  30. package/samples/reinvite_audio_audio.js +1 -0
  31. package/samples/reinvite_with_hold_unhold.js +1 -0
  32. package/samples/rtp_and_srtp.js +1 -0
  33. package/samples/rtp_and_srtp.rtp_refused.js +1 -0
  34. package/samples/rtp_and_srtp.unbalanced_sdp_answer.js.future +1 -0
  35. package/samples/send_and_receive_bfsk.js.future +1 -0
  36. package/samples/send_and_receive_fax.js +1 -0
  37. package/samples/session_expires.update.js.future +269 -0
  38. package/samples/session_expires.update.with_sipjs-lab.js +329 -0
  39. package/samples/simple.js +1 -0
  40. package/samples/sip_cancel.js +1 -0
  41. package/samples/speech_synth_and_recog.speex16000.js +1 -0
  42. package/samples/srtp.js +1 -0
  43. package/samples/start_play_wav_with_end_of_file_event.js +1 -0
  44. package/samples/start_play_wav_with_no_loop.js +1 -0
  45. package/samples/stop_with_cleanup.js +127 -0
  46. package/samples/tcp.js +1 -0
  47. package/samples/text_to_speech.js +1 -0
  48. package/samples/tls.js +1 -0
  49. package/samples/two_audio_streams.js +1 -0
  50. package/samples/two_audio_streams.port_zero.js +1 -0
  51. package/samples_extra/ws_speech_server.bfsk.js +1 -0
  52. package/samples_extra/ws_speech_server.dtmf.js +1 -0
  53. package/samples_extra/ws_speech_server.google.js +1 -0
  54. package/samples_extra/ws_speech_server.send_bfsk.js +1 -0
  55. package/samples_extra/ws_speech_server.start_bfsk_detection.js.future +1 -0
  56. package/src/addon.cpp +44 -1
  57. package/src/idmanager.cpp +4 -0
  58. package/src/idmanager.hpp +1 -0
  59. package/src/sip.cpp +253 -141
  60. package/src/sip.hpp +3 -1
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
- if (code >= 200 && code < 300) {
2427
- call->pending_request = -1;
2430
+ call->pending_request = -1;
2428
2431
 
2429
- pjsip_msg_find_remove_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
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
- if (code >= 200 && code < 300) {
2452
- call->pending_request = -1;
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
- pjsip_msg *msg = tdata->msg;
2455
- pjsip_msg_find_remove_hdr(msg, PJSIP_H_SUPPORTED, NULL);
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 (!add_headers(dlg->pool, tdata, document)) {
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
 
@@ -6545,120 +6641,126 @@ int pjw_enable_telephone_event() {
6545
6641
  return 0;
6546
6642
  }
6547
6643
 
6548
- int __pjw_shutdown() {
6549
- // addon_log(L_DBG, "pjw_shutdown thread_id=%i\n", syscall(SYS_gettid));
6550
- PJW_LOCK();
6551
-
6552
- g_shutting_down = true;
6553
-
6554
- // disable auto cleanup
6555
-
6556
- /*
6557
- map<long, long>::iterator iter;
6558
- iter = g_call_ids.id_map.begin();
6559
- while(iter != g_call_ids.id_map.end()){
6560
- Call *call = (Call*)iter->second;
6561
-
6562
- addon_log(L_DBG, "Terminating call %d\n", iter->first);
6563
-
6564
- pjsip_tx_data *tdata;
6565
- pj_status_t status;
6566
- status = pjsip_inv_end_session(call->inv,
6567
- 603,
6568
- NULL,
6569
- &tdata); //Copied from pjsua
6570
- if(status != PJ_SUCCESS){
6571
- //ignore
6572
- char err[256];
6573
- pj_strerror(status, err, sizeof(err));
6574
- addon_log(L_DBG, "pjsip_inv_end_session failed statut=%i
6575
- (%s)\n", status, err);
6576
- ++iter;
6577
- continue;
6578
- }
6579
-
6580
- if(!tdata)
6581
- {
6582
- //if tdata was not set by pjsip_inv_end_session, it means
6583
- we didn't receive any response yet (100 Trying) and we cannot send CANCEL
6584
- in this situation. So we just can return here without calling
6585
- pjsip_inv_send_msg.
6586
- ++iter;
6587
- addon_log(L_DBG, "no tdata\n");
6588
- continue;
6589
- }
6590
-
6591
- status = pjsip_inv_send_msg(call->inv, tdata);
6592
- if(status != PJ_SUCCESS){
6593
- addon_log(L_DBG, "pjsip_inv_send_msg failed\n");
6594
- }
6595
- ++iter;
6596
- }
6597
-
6598
- iter = g_account_ids.id_map.begin();
6599
- while(iter != g_account_ids.id_map.end()){
6600
- pjsip_regc *regc = (pjsip_regc*)iter->second;
6601
-
6602
- addon_log(L_DBG, "Unregistering account %d\n", iter->first);
6603
-
6604
- pjsip_tx_data *tdata;
6605
- pj_status_t status;
6606
-
6607
- status = pjsip_regc_unregister(regc, &tdata);
6608
- if(status != PJ_SUCCESS)
6609
- {
6610
- addon_log(L_DBG, "pjsip_regc_unregister failed\n");
6611
- }
6644
+ int __pjw_shutdown(int clean_up) {
6645
+ addon_log(L_DBG, "pjw_shutdown thread_id=%i\n", syscall(SYS_gettid));
6612
6646
 
6613
- status = pjsip_regc_send(regc, tdata);
6614
- if(status != PJ_SUCCESS)
6615
- {
6616
- addon_log(L_DBG, "pjsip_regc_send failed\n");
6617
- }
6618
- ++iter;
6619
- }
6620
-
6621
- Subscription *subscription;
6622
- iter = g_subscription_ids.id_map.begin();
6623
- while(iter != g_subscription_ids.id_map.end()){
6624
- addon_log(L_DBG, "Unsubscribing subscription %d\n", iter->first);
6625
-
6626
- subscription = (Subscription*)iter->second;
6627
- if(!subscription_subscribe(subscription, 0, NULL)) {
6628
- addon_log(L_DBG, "Unsubscription failed failed\n");
6629
- }
6630
- ++iter;
6631
- }
6647
+ g_shutting_down = true;
6632
6648
 
6633
- PJW_UNLOCK();
6634
-
6635
- //uint32_t wait = 100000 * (g_call_ids.id_map.size() +
6636
- g_account_ids.id_map.size()));
6637
- //wait += 1000000; //Wait one whole second to permit packet capture to get
6638
- any final packets
6639
-
6640
- timeval tv_start;
6641
- timeval tv_end;
6642
- gettimeofday(&tv_start, NULL);
6643
- gettimeofday(&tv_end, NULL);
6649
+ if(!clean_up) {
6650
+ return 0;
6651
+ }
6644
6652
 
6645
- unsigned int start = tv_start.tv_sec * 1000 + (tv_start.tv_usec / 1000);
6646
- unsigned int end = tv_end.tv_sec * 1000 + (tv_end.tv_usec / 1000);
6653
+ addon_log(L_DBG, "INITIATING CLEANUP\n");
6647
6654
 
6648
- int DELAY = 2000; // 1000 ms delay
6649
- while(end - start < DELAY) {
6650
- pj_time_val tv = {0, 500};
6651
- pj_status_t status;
6652
- status = pjsip_endpt_handle_events(g_sip_endpt, &tv);
6655
+ PJW_LOCK();
6653
6656
 
6654
- gettimeofday(&tv_end, NULL);
6655
- end = tv_end.tv_sec * 1000 + (tv_end.tv_usec / 1000);
6656
- //time(&end);
6657
- }
6657
+ map<long, long>::iterator iter;
6658
+ iter = g_call_ids.id_map.begin();
6659
+ while(iter != g_call_ids.id_map.end()){
6660
+ Call *call = (Call*)iter->second;
6661
+
6662
+ addon_log(L_DBG, "Terminating call %d\n", iter->first);
6663
+
6664
+ pjsip_tx_data *tdata;
6665
+ pj_status_t status;
6666
+ status = pjsip_inv_end_session(call->inv,
6667
+ 603,
6668
+ NULL,
6669
+ &tdata); //Copied from pjsua
6670
+ if(status != PJ_SUCCESS){
6671
+ //ignore
6672
+ char err[256];
6673
+ pj_strerror(status, err, sizeof(err));
6674
+ addon_log(L_DBG, "pjsip_inv_end_session failed statut=%i (%s)\n", status, err);
6675
+ ++iter;
6676
+ continue;
6677
+ }
6678
+
6679
+ if(!tdata)
6680
+ {
6681
+ //if tdata was not set by pjsip_inv_end_session, it means we didn't receive any response yet (100 Trying) and we cannot send CANCEL in this situation. So we just can return here without calling pjsip_inv_send_msg.
6682
+ ++iter;
6683
+ addon_log(L_DBG, "no tdata\n");
6684
+ continue;
6685
+ }
6686
+
6687
+ status = pjsip_inv_send_msg(call->inv, tdata);
6688
+ if(status != PJ_SUCCESS){
6689
+ addon_log(L_DBG, "pjsip_inv_send_msg failed\n");
6690
+ }
6691
+ ++iter;
6692
+ }
6693
+
6694
+ iter = g_account_ids.id_map.begin();
6695
+ while(iter != g_account_ids.id_map.end()){
6696
+ pjsip_regc *regc = (pjsip_regc*)iter->second;
6697
+
6698
+ addon_log(L_DBG, "Unregistering account %d\n", iter->first);
6699
+
6700
+ pjsip_tx_data *tdata;
6701
+ pj_status_t status;
6702
+
6703
+ status = pjsip_regc_unregister(regc, &tdata);
6704
+ if(status != PJ_SUCCESS)
6705
+ {
6706
+ addon_log(L_DBG, "pjsip_regc_unregister failed\n");
6707
+ }
6708
+
6709
+ status = pjsip_regc_send(regc, tdata);
6710
+ if(status != PJ_SUCCESS)
6711
+ {
6712
+ addon_log(L_DBG, "pjsip_regc_send failed\n");
6713
+ }
6714
+ ++iter;
6715
+ }
6716
+
6717
+ Subscription *subscription;
6718
+ iter = g_subscription_ids.id_map.begin();
6719
+
6720
+ rapidjson::Document doc;
6721
+ doc.Parse("{\"expires\": 0}");
6722
+
6723
+ while(iter != g_subscription_ids.id_map.end()){
6724
+ addon_log(L_DBG, "Unsubscribing subscription %d\n", iter->first);
6725
+
6726
+ subscription = (Subscription*)iter->second;
6727
+ if(!subscription_subscribe(subscription, 0, doc)) {
6728
+ addon_log(L_DBG, "Unsubscription failed failed\n");
6729
+ }
6730
+ ++iter;
6731
+ }
6658
6732
 
6659
- */
6733
+ PJW_UNLOCK();
6660
6734
 
6661
- return 0;
6735
+ //uint32_t wait = 100000 * (g_call_ids.id_map.size() + g_account_ids.id_map.size()));
6736
+ //wait += 1000000; //Wait one whole second to permit packet capture to get any final packets
6737
+
6738
+ /*
6739
+ time_t end,start;
6740
+ time(&start);
6741
+ end = start;
6742
+ */
6743
+ timeval tv_start;
6744
+ timeval tv_end;
6745
+ gettimeofday(&tv_start, NULL);
6746
+ gettimeofday(&tv_end, NULL);
6747
+
6748
+ unsigned int start = tv_start.tv_sec * 1000 + (tv_start.tv_usec / 1000);
6749
+ unsigned int end = tv_end.tv_sec * 1000 + (tv_end.tv_usec / 1000);
6750
+
6751
+ int DELAY = 1000; // 1000 ms delay
6752
+ while(end - start < DELAY) {
6753
+ pj_time_val tv = {0, 500};
6754
+ pj_status_t status;
6755
+ status = pjsip_endpt_handle_events(g_sip_endpt, &tv);
6756
+
6757
+ gettimeofday(&tv_end, NULL);
6758
+ end = tv_end.tv_sec * 1000 + (tv_end.tv_usec / 1000);
6759
+ //time(&end);
6760
+ }
6761
+
6762
+ addon_log(L_DBG, "CLEANUP DONE\n");
6763
+ return 0;
6662
6764
  }
6663
6765
 
6664
6766
  // Copied from streamutil.c (pjsip sample)
@@ -8267,7 +8369,7 @@ bool notify(pjsip_evsub *evsub, const char *content_type, const char *body,
8267
8369
  }
8268
8370
  s_content_type_subtype = pj_str(tok);
8269
8371
 
8270
- if (!add_headers(tdata->pool, tdata, document)) {
8372
+ if (!add_headers(tdata->pool, tdata, document, NULL)) {
8271
8373
  return false;
8272
8374
  }
8273
8375
 
@@ -8444,7 +8546,7 @@ out:
8444
8546
  }
8445
8547
 
8446
8548
  pj_bool_t add_headers(pj_pool_t *pool, pjsip_tx_data *tdata,
8447
- Document &document) {
8549
+ Document &document, pjsip_dialog *dlg) {
8448
8550
  if (!document.HasMember("headers")) {
8449
8551
  return PJ_TRUE;
8450
8552
  }
@@ -8464,24 +8566,34 @@ pj_bool_t add_headers(pj_pool_t *pool, pjsip_tx_data *tdata,
8464
8566
  }
8465
8567
  printf("%s => '%s'\n", itr->name.GetString(), itr->value.GetString());
8466
8568
 
8467
- const char *name = itr->name.GetString();
8468
- if (!itr->value.IsString()) {
8469
- set_error("Parameter headers key '%s' found with non-string value", name);
8470
- return PJ_FALSE;
8471
- }
8569
+ if(stricmp(itr->name.GetString(), "call-id") == 0) {
8570
+ printf("Setting INVIITE call_id->id to %s\n", itr->value.GetString());
8571
+ pjsip_cid_hdr *call_id_hdr = (pjsip_cid_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CALL_ID, NULL);
8572
+ pj_strdup2(tdata->pool, &call_id_hdr->id, itr->value.GetString());
8573
+ if(dlg) {
8574
+ printf("Setting DLG call_id->id to %s\n", itr->value.GetString());
8575
+ pj_strdup2(dlg->pool, &dlg->call_id->id, itr->value.GetString());
8576
+ }
8577
+ } else {
8578
+ const char *name = itr->name.GetString();
8579
+ if (!itr->value.IsString()) {
8580
+ set_error("Parameter headers key '%s' found with non-string value", name);
8581
+ return PJ_FALSE;
8582
+ }
8472
8583
 
8473
- const char *value = itr->value.GetString();
8584
+ const char *value = itr->value.GetString();
8474
8585
 
8475
- pj_str_t hname = pj_str((char *)name);
8476
- pjsip_hdr *hdr = (pjsip_hdr *)pjsip_parse_hdr(pool, &hname, (char *)value,
8477
- strlen(value), NULL);
8586
+ pj_str_t hname = pj_str((char *)name);
8587
+ pjsip_hdr *hdr = (pjsip_hdr *)pjsip_parse_hdr(pool, &hname, (char *)value,
8588
+ strlen(value), NULL);
8478
8589
 
8479
- if (!hdr) {
8480
- set_error("Failed to parse header '%s' => '%s'", name, value);
8481
- return PJ_FALSE;
8590
+ if (!hdr) {
8591
+ set_error("Failed to parse header '%s' => '%s'", name, value);
8592
+ return PJ_FALSE;
8593
+ }
8594
+ pjsip_hdr *clone_hdr = (pjsip_hdr *)pjsip_hdr_clone(pool, hdr);
8595
+ pjsip_msg_add_hdr(tdata->msg, clone_hdr);
8482
8596
  }
8483
- pjsip_hdr *clone_hdr = (pjsip_hdr *)pjsip_hdr_clone(pool, hdr);
8484
- pjsip_msg_add_hdr(tdata->msg, clone_hdr);
8485
8597
  }
8486
8598
  return PJ_TRUE;
8487
8599
  }
@@ -8828,7 +8940,7 @@ bool subscription_subscribe(Subscription *s, int expires, Document &document) {
8828
8940
  return false;
8829
8941
  }
8830
8942
 
8831
- if (!add_headers(s->dlg->pool, tdata, document)) {
8943
+ if (!add_headers(s->dlg->pool, tdata, document, NULL)) {
8832
8944
  return false;
8833
8945
  }
8834
8946
 
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);
@@ -90,7 +92,7 @@ int pjw_get_codecs(char *out_codecs);
90
92
 
91
93
  int pjw_set_codecs(const char *in_codec_info);
92
94
 
93
- int __pjw_shutdown();
95
+ int __pjw_shutdown(int clean_up);
94
96
 
95
97
  int pjw_notify(long subscriber_id, const char *json);
96
98