@babblevoice/babble-drachtio-callmanager 2.3.13 → 2.3.15

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 (3) hide show
  1. package/lib/call.js +43 -12
  2. package/lib/sdp.js +7 -1
  3. package/package.json +1 -1
package/lib/call.js CHANGED
@@ -1711,18 +1711,23 @@ class call {
1711
1711
 
1712
1712
  /**
1713
1713
  * If we have been placed on hold (and it has been neotiated) then configure audio to match.
1714
+ * @param { "inactive"|"sendonly" } direction
1714
1715
  * @private
1715
1716
  */
1716
- _hold() {
1717
+ _hold( direction = "inactive" ) {
1717
1718
 
1718
1719
  if( this.state.held ) return
1719
1720
  this.state.held = true
1720
1721
 
1721
- this.channels.audio.direction( { "send": false, "recv": false } )
1722
- this.sdp.local.setaudiodirection( "inactive" )
1722
+ const d = { "send": false, "recv": false }
1723
+ if( "sendonly" == direction ) d.send = true
1724
+
1725
+ this.channels.audio.direction( d )
1726
+ this.sdp.local.setaudiodirection( direction )
1723
1727
 
1724
1728
  const other = this.other
1725
1729
  if( other ) {
1730
+ this.channels.audio.unmix()
1726
1731
  other.channels.audio.unmix()
1727
1732
  other.channels.audio.play( this.moh )
1728
1733
  }
@@ -1745,6 +1750,11 @@ class call {
1745
1750
  const other = this.other
1746
1751
  if( other ) {
1747
1752
  this.channels.audio.mix( other.channels.audio )
1753
+
1754
+ this._em.emit( "call.mix", this )
1755
+ callmanager.options.em.emit( "call.mix", this )
1756
+ other._em.emit( "call.mix", other )
1757
+ callmanager.options.em.emit( "call.mix", other )
1748
1758
  }
1749
1759
 
1750
1760
  this._em.emit( "call.unhold", this )
@@ -1831,6 +1841,11 @@ class call {
1831
1841
  } )
1832
1842
  }
1833
1843
 
1844
+ /**
1845
+ *
1846
+ * @param { object } other
1847
+ * @returns { object }
1848
+ */
1834
1849
  swapchannel( other ){
1835
1850
 
1836
1851
  const this_audio = this.channels.audio
@@ -1845,6 +1860,12 @@ class call {
1845
1860
  other.channels.audio = this_audio
1846
1861
  other.channels.audio.em = other_chem
1847
1862
  other.sdp.local = this_sdp
1863
+
1864
+ /* reinvite will pick up on this */
1865
+ const selectedcodec = this.selectedcodec
1866
+ other.selectedcodec = this.selectedcodec
1867
+ this.selectedcodec = selectedcodec
1868
+ return this
1848
1869
  }
1849
1870
 
1850
1871
  /**
@@ -1986,8 +2007,10 @@ class call {
1986
2007
 
1987
2008
  /* this was tested against jssip - which I don't think is correct. It was sending us
1988
2009
  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!). */
1989
- if( ( "inactive" === sdp.media.direction || "sendonly" === sdp.media.direction || "0.0.0.0" === sdp.ip ) && !this.state.held ) {
1990
- this._hold()
2010
+ let d = sdp.media.direction
2011
+ if( "0.0.0.0" === sdp.ip ) d = "inactive"
2012
+ if( ( "inactive" === d || "sendonly" === d ) && !this.state.held ) {
2013
+ this._hold( d )
1991
2014
  res.send( 200, {
1992
2015
  "headers": {
1993
2016
  "Subject" : "Call on hold",
@@ -2090,13 +2113,16 @@ class call {
2090
2113
  othercall.state.refered = true
2091
2114
 
2092
2115
  this.detach()
2093
- if( this.channels.audio ) this.channels.audio.unmix()
2094
- if( othercall.channels.audio ) othercall.channels.audio.unmix()
2095
-
2096
- await Promise.all( [
2097
- this.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ),
2098
- othercall.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ),
2099
- ] )
2116
+ if( this.channels.audio ) {
2117
+ this.channels.audio.direction( { "send": true, "recv": true } )
2118
+ this.channels.audio.unmix()
2119
+ await this.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 )
2120
+ }
2121
+ if( othercall.channels.audio ) {
2122
+ othercall.channels.audio.direction( { "send": true, "recv": true } )
2123
+ othercall.channels.audio.unmix()
2124
+ await othercall.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 )
2125
+ }
2100
2126
 
2101
2127
  if( othercall.channels.audio && this.moh ) othercall.channels.audio.play( this.moh )
2102
2128
 
@@ -2194,6 +2220,11 @@ class call {
2194
2220
  b_1.detach()
2195
2221
  b_2.detach()
2196
2222
 
2223
+ a_1._unhold()
2224
+ b_1._unhold()
2225
+ b_2._unhold()
2226
+ c_1._unhold()
2227
+
2197
2228
  a_1.channels.audio.unmix()
2198
2229
  b_1.channels.audio.unmix()
2199
2230
  b_2.channels.audio.unmix()
package/lib/sdp.js CHANGED
@@ -288,8 +288,14 @@ class sdp {
288
288
  return m
289
289
  }
290
290
 
291
- setaudiodirection( direction /* sendrecv|inactive|sendonly|recvonly */ ) {
291
+ /**
292
+ *
293
+ * @param { "sendrecv"|"inactive"|"sendonly"|"recvonly" } direction
294
+ * @returns { object }
295
+ */
296
+ setaudiodirection( direction ) {
292
297
  this.getmedia().direction = direction
298
+ return this
293
299
  }
294
300
 
295
301
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "2.3.13",
3
+ "version": "2.3.15",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {