@babblevoice/babble-drachtio-callmanager 2.3.22 → 2.3.24

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/lib/call.js CHANGED
@@ -334,6 +334,8 @@ class call {
334
334
  * @property { boolean } [ rfc2833 ] if set to true enable 2833
335
335
  * @property { string } [ display ] how the user should be displayed
336
336
  * @property { Array } [ headers ]
337
+ * @property { string } [ contactparams]
338
+ * @property { number | true } [ autoanswer ] autoanswer true or delay
337
339
  * @property { number } [ uactimeout ] timeout in mS
338
340
  * @property { boolean } [ late ] - do we use late negotiation
339
341
  * @property { boolean } [ noAck ] do not use - converts our options into Drachtio options
@@ -1650,7 +1652,7 @@ class call {
1650
1652
 
1651
1653
  /**
1652
1654
  * If we have been placed on hold (and it has been neotiated) then configure audio to match.
1653
- * @param { "inactive"|"sendonly" } direction
1655
+ * @param { "inactive"|"recvonly" } direction - from the other end
1654
1656
  * @returns { Promise } resolves on timeout or when unmix happens
1655
1657
  * @private
1656
1658
  */
@@ -1662,7 +1664,7 @@ class call {
1662
1664
  const ourpromises = []
1663
1665
 
1664
1666
  const d = { "send": false, "recv": false }
1665
- if( "sendonly" == direction ) d.send = true
1667
+ if( "recvonly" == direction ) d.send = true
1666
1668
 
1667
1669
  if( this.channels.audio ) {
1668
1670
  this.channels.audio.unmix()
@@ -1859,6 +1861,53 @@ class call {
1859
1861
  return { media, ip }
1860
1862
  }
1861
1863
 
1864
+ /**
1865
+ * We receive a modify to a dialgue (re-invite) and it looks like a hold
1866
+ * @param { string } direction
1867
+ * @param { object } res
1868
+ * @returns { boolean }
1869
+ */
1870
+ #handlehold( direction, res ) {
1871
+
1872
+ if( "inactive" !== direction && "sendonly" !== direction ) return false
1873
+
1874
+ if( "sendonly" === direction ) this._hold( "recvonly" )
1875
+ else this._hold( direction )
1876
+
1877
+ res.send( 200, {
1878
+ "headers": {
1879
+ "Subject" : "Call on hold",
1880
+ "User-Agent": "project",
1881
+ "Allow": "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY",
1882
+ "Supported": "replaces"
1883
+ },
1884
+ "body": this.sdp.local.toString()
1885
+ } )
1886
+
1887
+ return true
1888
+ }
1889
+
1890
+ /**
1891
+ * We erceive a request to unhold.
1892
+ * @param { string } direction
1893
+ * @param { object } res
1894
+ * @returns { boolean }
1895
+ */
1896
+ #handleoffhold( direction, res ) {
1897
+ if( "sendrecv" !== direction ) return false
1898
+
1899
+ this._unhold()
1900
+ res.send( 200, {
1901
+ "headers": {
1902
+ "Subject" : "Call off hold",
1903
+ "User-Agent": "project"
1904
+ },
1905
+ "body": this.sdp.local.toString()
1906
+ } )
1907
+
1908
+ return true
1909
+ }
1910
+
1862
1911
  /**
1863
1912
  Add events for the drachtio dialog object that this object requires.
1864
1913
  @private
@@ -1927,36 +1976,18 @@ class call {
1927
1976
  sendonly when placing the call on hold. It didn't change the connection IP (although it did set the rtcp connection ip to 0.0.0.0!). */
1928
1977
  let d = sdp.media.direction
1929
1978
  if( "0.0.0.0" === sdp.ip ) d = "inactive"
1930
- if( ( "inactive" === d || "sendonly" === d ) && !this.state.held ) {
1931
- this._hold( d )
1932
- res.send( 200, {
1933
- "headers": {
1934
- "Subject" : "Call on hold",
1935
- "User-Agent": "project",
1936
- "Allow": "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY",
1937
- "Supported": "replaces"
1938
- },
1939
- "body": this.sdp.local.toString()
1940
- } )
1941
- } else if( "inactive" !== sdp.media.direction && "sendonly" !== sdp.media.direction && "0.0.0.0" !== sdp.ip && this.state.held ) {
1942
- this._unhold()
1943
- res.send( 200, {
1944
- "headers": {
1945
- "Subject" : "Call off hold",
1946
- "User-Agent": "project"
1947
- },
1948
- "body": this.sdp.local.toString()
1949
- } )
1950
- } else {
1951
- /* Unknown - but respond to keep the call going */
1952
- res.send( 200, {
1953
- "headers": {
1954
- "Subject" : "Ok",
1955
- "User-Agent": "project"
1956
- },
1957
- "body": this.sdp.local.toString()
1958
- } )
1959
- }
1979
+ if( this.#handlehold( d, res ) ) return
1980
+ if( this.#handleoffhold( d, res ) ) return
1981
+
1982
+ /* Unknown - but respond to keep the call going */
1983
+ res.send( 200, {
1984
+ "headers": {
1985
+ "Subject" : "Ok",
1986
+ "User-Agent": "project"
1987
+ },
1988
+ "body": this.sdp.local.toString()
1989
+ } )
1990
+
1960
1991
  } )
1961
1992
 
1962
1993
 
@@ -2829,19 +2860,19 @@ class call {
2829
2860
 
2830
2861
  /**
2831
2862
  *
2832
- * @param { object } options
2833
- * @param { object } u
2863
+ * @param { string } contactstr
2834
2864
  */
2835
- #configautoanswerfornewuac( options, u ) {
2865
+ #configautoanswerfornewuac( contactstr ) {
2836
2866
 
2837
- if( !options.contactparams ) options.contactparams = ""
2867
+ const parts = parseuri( contactstr )
2838
2868
 
2839
- if( true === options.autoanswer ) {
2840
- this.options.headers[ "Call-Info" ] = `<sip:${u.user}@${u.realm}>;answer-after=0`
2841
- options.contactparams += ";intercom=true"
2842
- } else if ( "number" == typeof options.autoanswer ) {
2843
- this.options.headers[ "Call-Info" ] = `<sip:${u.user}@${u.realm}>;answer-after=${options.autoanswer}`
2844
- options.contactparams += ";intercom=true"
2869
+ if( !this.options.contactparams ) this.options.contactparams = ""
2870
+ if( true === this.options.autoanswer ) {
2871
+ this.options.headers[ "Call-Info" ] = `<sip:${parts.host}>;answer-after=0`
2872
+ this.options.contactparams += ";intercom=true"
2873
+ } else if ( "number" == typeof this.options.autoanswer ) {
2874
+ this.options.headers[ "Call-Info" ] = `<sip:${parts.host}>;answer-after=${this.options.autoanswer}`
2875
+ this.options.contactparams += ";intercom=true"
2845
2876
  }
2846
2877
  }
2847
2878
 
@@ -2855,6 +2886,7 @@ class call {
2855
2886
  this.propagate.headers[ header ] = options.headers[ header ]
2856
2887
  }
2857
2888
  }
2889
+ if ( options.autoanswer ) this.propagate.autoanswer = options.autoanswer
2858
2890
  }
2859
2891
 
2860
2892
  /**
@@ -2867,6 +2899,9 @@ class call {
2867
2899
  this.options.headers[ header ] = this.parent.propagate.headers[ header ]
2868
2900
  }
2869
2901
  }
2902
+ if( "autoanswer" in this.parent.propagate ) {
2903
+ this.options.autoanswer = this.parent.propagate.autoanswer
2904
+ }
2870
2905
  }
2871
2906
  }
2872
2907
 
@@ -2891,7 +2926,7 @@ class call {
2891
2926
  @param { string } [ options.auth.password ] - If SIP auth required password
2892
2927
  @param { object } [ options.headers ] - Object containing extra sip headers required.
2893
2928
  @param { object } [ options.uactimeout ] - override the deault timeout
2894
- @param { boolean | number } [ options.autoanswer ] - if true add call-info to auto answer, if number delay to add
2929
+ @param { true | number } [ options.autoanswer ] - if true add call-info to auto answer, if number delay to add
2895
2930
  @param { boolean } [ options.late ] - late negotiation
2896
2931
  @param { boolean } [ options.privacy ] - sets the privacy
2897
2932
  @param { entity } [ options.entity ] - used to store this call against and look up a contact string if not supplied.
@@ -2940,9 +2975,7 @@ class call {
2940
2975
 
2941
2976
  if( options.privacy ) this.privacy = true
2942
2977
 
2943
- const u = newcall.#configcalleridfornewuac( options )
2944
- newcall.#configautoanswerfornewuac( options, u )
2945
-
2978
+ newcall.#configcalleridfornewuac( options )
2946
2979
 
2947
2980
  // Polycom
2948
2981
  // Alert-Info: <https://www.babblevoice.com/polycom/LoudRing.wav>
@@ -2956,12 +2989,17 @@ class call {
2956
2989
  newcall.options.headers = tmpheaders
2957
2990
  newcall.import()
2958
2991
 
2992
+ newcall.#configautoanswerfornewuac( options.contact )
2993
+
2994
+ newcall.options.headers[ "Allow-Events" ] = "talk, hold, presence, as-feature-event, dialog, call-info, sla, include-session-description, message-summary, refer"
2995
+ newcall.options.headers[ "Allow" ] = "INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE"
2996
+
2959
2997
  newcall.#confignetwork( options )
2960
2998
  await newcall.#openchannelsfornewuac()
2961
2999
 
2962
3000
  let newdialog
2963
3001
  try {
2964
- newdialog = await callmanager.options.srf.createUAC( options.contact + options.contactparams, newcall.options, {
3002
+ newdialog = await callmanager.options.srf.createUAC( options.contact + newcall.options.contactparams, newcall.options, {
2965
3003
  cbRequest: ( err, req ) => {
2966
3004
 
2967
3005
  if( !req ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -858,7 +858,6 @@ describe( "call object", function() {
858
858
  "late": true
859
859
  }
860
860
 
861
- const earlycallbackcalled = false
862
861
  const c = await call.newuac( options )
863
862
 
864
863
  /* mock */
@@ -1015,7 +1014,7 @@ describe( "call object", function() {
1015
1014
  const c = await call.newuac( options )
1016
1015
 
1017
1016
  let eventfired = false
1018
- c.on( "call.pick", ( callobject ) => {
1017
+ c.on( "call.pick", ( /*callobject*/ ) => {
1019
1018
  eventfired = true
1020
1019
  } )
1021
1020