sip-lab 1.28.2 → 1.28.4

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 (40) hide show
  1. package/package.json +5 -5
  2. package/prebuilds/linux-x64/sip-lab.node +0 -0
  3. package/samples/100_calls.js +0 -6
  4. package/samples/16_audio_streams.js +0 -31
  5. package/samples/183_session_progress.js +0 -12
  6. package/samples/artifacts/tls/cacert.pem +32 -0
  7. package/samples/artifacts/tls/cakey.pem +52 -0
  8. package/samples/delayed_media.js +0 -7
  9. package/samples/four_audio_streams_two_refused.js +0 -6
  10. package/samples/g729.js +0 -10
  11. package/samples/ic.wav +0 -0
  12. package/samples/mrcp_and_audio.js +0 -9
  13. package/samples/mrcp_and_audio.simplified_media.js +0 -9
  14. package/samples/multiple_audio_streams.js +0 -30
  15. package/samples/oc.wav +0 -0
  16. package/samples/pcma.js +0 -11
  17. package/samples/play_wav_and_speech_recog.bad_transcript.pcmu8000.js +0 -23
  18. package/samples/refer.js +0 -30
  19. package/samples/refuse_telephone_event.js +0 -11
  20. package/samples/reinvite_and_dtmf.js +0 -11
  21. package/samples/reinvite_audio_audio.js +0 -11
  22. package/samples/reinvite_with_hold_unhold.js +0 -11
  23. package/samples/rtp_and_srtp.js +0 -6
  24. package/samples/rtp_and_srtp.rtp_refused.js +0 -6
  25. package/samples/send_and_receive_fax.js +0 -11
  26. package/samples/simple.js +32 -8
  27. package/samples/sip_cancel.js +0 -9
  28. package/samples/speech_synth_and_recog.speex16000.js +2 -23
  29. package/samples/srtp.js +0 -6
  30. package/samples/start_play_wav_with_end_of_file_event.js +0 -23
  31. package/samples/start_play_wav_with_no_loop.js +0 -23
  32. package/samples/{tcp_and_extra_headers.js → tcp.js} +0 -23
  33. package/samples/text_to_speech.js +0 -23
  34. package/samples/tls.js +128 -0
  35. package/samples/two_audio_streams.js +0 -5
  36. package/samples/two_audio_streams.port_zero.js +0 -5
  37. package/samples_extra/ws_speech_server.dtmf.js +0 -24
  38. package/samples_extra/ws_speech_server.google.js +0 -24
  39. package/src/addon.cpp +35 -0
  40. package/src/sip.cpp +26 -9
package/src/addon.cpp CHANGED
@@ -773,6 +773,40 @@ Napi::Value call_stop_speech_synth(const Napi::CallbackInfo &info) {
773
773
  }
774
774
 
775
775
 
776
+ Napi::Value call_stop_speech_recog(const Napi::CallbackInfo &info) {
777
+ Napi::Env env = info.Env();
778
+
779
+ if (info.Length() != 2) {
780
+ Napi::Error::New(env, "Wrong number of arguments. Expected: call_id")
781
+ .ThrowAsJavaScriptException();
782
+ return env.Null();
783
+ }
784
+
785
+ if (!info[0].IsNumber()) {
786
+ Napi::TypeError::New(env, "call_id must be number.")
787
+ .ThrowAsJavaScriptException();
788
+ return env.Null();
789
+ }
790
+ int call_id = info[0].As<Napi::Number>().Int32Value();
791
+
792
+ if (!info[1].IsString()) {
793
+ Napi::TypeError::New(env, "params must be a JSON string.")
794
+ .ThrowAsJavaScriptException();
795
+ return env.Null();
796
+ }
797
+ const string json = info[1].As<Napi::String>().Utf8Value();
798
+
799
+ int res = pjw_call_stop_speech_recog(call_id, json.c_str());
800
+
801
+ if (res != 0) {
802
+ Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
803
+ return env.Null();
804
+ }
805
+
806
+ return env.Null();
807
+ }
808
+
809
+
776
810
  Napi::Value call_get_stream_stat(const Napi::CallbackInfo &info) {
777
811
  Napi::Env env = info.Env();
778
812
 
@@ -1379,6 +1413,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
1379
1413
  Napi::Function::New(env, call_stop_play_wav));
1380
1414
  exports.Set("call_stop_fax", Napi::Function::New(env, call_stop_fax));
1381
1415
  exports.Set("call_stop_speech_synth", Napi::Function::New(env, call_stop_speech_synth));
1416
+ exports.Set("call_stop_speech_recog", Napi::Function::New(env, call_stop_speech_recog));
1382
1417
  exports.Set("call_get_stream_stat",
1383
1418
  Napi::Function::New(env, call_get_stream_stat));
1384
1419
  // exports.Set("call_refer", Napi::Function::New(env, call_refer));
package/src/sip.cpp CHANGED
@@ -584,9 +584,9 @@ pjsip_transport *allocate_udp_transport(pjsip_endpoint *sip_endpt,
584
584
  pj_str_t *ipaddr, int port);
585
585
 
586
586
  pjsip_tpfactory *create_tls_tpfactory(pjsip_endpoint *sip_endpt,
587
- pj_str_t *ipaddr, int *allocated_port);
587
+ pj_str_t *ipaddr, int *allocated_port, char *cert_file, char *privkey_file);
588
588
  pjsip_tpfactory *allocate_tls_tpfactory(pjsip_endpoint *sip_endpt,
589
- pj_str_t *ipaddr, int port);
589
+ pj_str_t *ipaddr, int port, char *cert_file, char *privkey_file);
590
590
 
591
591
  pjsip_tpfactory *create_tcp_factory(pjsip_endpoint *sip_endpt, pj_str_t *ipaddr,
592
592
  int *allocated_port);
@@ -1683,7 +1683,7 @@ pjsip_tpfactory *create_tcp_tpfactory(pjsip_endpoint *sip_endpt,
1683
1683
  }
1684
1684
 
1685
1685
  pjsip_tpfactory *allocate_tls_tpfactory(pjsip_endpoint *sip_endpt,
1686
- pj_str_t *ipaddr, int port) {
1686
+ pj_str_t *ipaddr, int port, char *cert_file, char *privkey_file) {
1687
1687
  addon_log(L_DBG, "allocate_tls_tpfactory ipaddr=%.*s port=%i\n", ipaddr->slen,
1688
1688
  ipaddr->ptr, port);
1689
1689
  pj_status_t status;
@@ -1705,6 +1705,13 @@ pjsip_tpfactory *allocate_tls_tpfactory(pjsip_endpoint *sip_endpt,
1705
1705
  pjsip_tls_setting tls_opt;
1706
1706
  pjsip_tls_setting_default(&tls_opt);
1707
1707
 
1708
+ if(cert_file) {
1709
+ tls_opt.cert_file = pj_str(cert_file);
1710
+ }
1711
+ if(privkey_file) {
1712
+ tls_opt.privkey_file = pj_str(privkey_file);
1713
+ }
1714
+
1708
1715
  status = pjsip_tls_transport_start2(sip_endpt, &tls_opt, &local_addr, NULL, 1,
1709
1716
  &tpfactory);
1710
1717
  if (status != PJ_SUCCESS) {
@@ -1716,14 +1723,14 @@ pjsip_tpfactory *allocate_tls_tpfactory(pjsip_endpoint *sip_endpt,
1716
1723
  }
1717
1724
 
1718
1725
  pjsip_tpfactory *create_tls_tpfactory(pjsip_endpoint *sip_endpt,
1719
- pj_str_t *ipaddr, int *allocated_port) {
1726
+ pj_str_t *ipaddr, int *allocated_port, char *cert_file, char *privkey_file) {
1720
1727
  // pj_status_t status;
1721
1728
  pjsip_tpfactory *tpfactory;
1722
1729
 
1723
1730
  for (int i = 0; i < 1000; ++i) {
1724
1731
  int port = 6060;
1725
1732
  port += i;
1726
- tpfactory = allocate_tls_tpfactory(sip_endpt, ipaddr, port);
1733
+ tpfactory = allocate_tls_tpfactory(sip_endpt, ipaddr, port, cert_file, privkey_file);
1727
1734
  if (tpfactory) {
1728
1735
  *allocated_port = port;
1729
1736
  return tpfactory;
@@ -1752,7 +1759,7 @@ int pjw_transport_create(const char *json, int *out_t_id, char *out_t_address,
1752
1759
 
1753
1760
  char buffer[MAX_JSON_INPUT];
1754
1761
 
1755
- const char *valid_params[] = {"address", "port", "type", ""};
1762
+ const char *valid_params[] = {"address", "port", "type", "cert_file", "key_file", ""};
1756
1763
 
1757
1764
  Document document;
1758
1765
 
@@ -1861,12 +1868,22 @@ int pjw_transport_create(const char *json, int *out_t_id, char *out_t_address,
1861
1868
  }
1862
1869
  } else {
1863
1870
  pjsip_tpfactory *tpfactory;
1864
- // int af;
1871
+
1872
+ char *cert_file = NULL;
1873
+ char *key_file = NULL;
1865
1874
 
1875
+ if (document.HasMember("cert_file") && document["cert_file"].IsString()) {
1876
+ cert_file = (char*)document["cert_file"].GetString();
1877
+ }
1878
+
1879
+ if (document.HasMember("key_file") && document["key_file"].IsString()) {
1880
+ key_file = (char*)document["key_file"].GetString();
1881
+ }
1882
+
1866
1883
  if (port != 0) {
1867
- tpfactory = allocate_tls_tpfactory(g_sip_endpt, &address, port);
1884
+ tpfactory = allocate_tls_tpfactory(g_sip_endpt, &address, port, cert_file, key_file);
1868
1885
  } else {
1869
- tpfactory = create_tls_tpfactory(g_sip_endpt, &address, &port);
1886
+ tpfactory = create_tls_tpfactory(g_sip_endpt, &address, &port, cert_file, key_file);
1870
1887
  }
1871
1888
 
1872
1889
  if (!tpfactory) {