@babblevoice/babble-drachtio-callmanager 2.3.13 → 2.3.14

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 +32 -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 )
@@ -1986,8 +1996,10 @@ class call {
1986
1996
 
1987
1997
  /* this was tested against jssip - which I don't think is correct. It was sending us
1988
1998
  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()
1999
+ let d = sdp.media.direction
2000
+ if( "0.0.0.0" === sdp.ip ) d = "inactive"
2001
+ if( ( "inactive" === d || "sendonly" === d ) && !this.state.held ) {
2002
+ this._hold( d )
1991
2003
  res.send( 200, {
1992
2004
  "headers": {
1993
2005
  "Subject" : "Call on hold",
@@ -2090,13 +2102,16 @@ class call {
2090
2102
  othercall.state.refered = true
2091
2103
 
2092
2104
  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
- ] )
2105
+ if( this.channels.audio ) {
2106
+ this.channels.audio.direction( { "send": true, "recv": true } )
2107
+ this.channels.audio.unmix()
2108
+ await this.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 )
2109
+ }
2110
+ if( othercall.channels.audio ) {
2111
+ othercall.channels.audio.direction( { "send": true, "recv": true } )
2112
+ othercall.channels.audio.unmix()
2113
+ await othercall.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 )
2114
+ }
2100
2115
 
2101
2116
  if( othercall.channels.audio && this.moh ) othercall.channels.audio.play( this.moh )
2102
2117
 
@@ -2194,6 +2209,11 @@ class call {
2194
2209
  b_1.detach()
2195
2210
  b_2.detach()
2196
2211
 
2212
+ a_1._unhold()
2213
+ b_1._unhold()
2214
+ b_2._unhold()
2215
+ c_1._unhold()
2216
+
2197
2217
  a_1.channels.audio.unmix()
2198
2218
  b_1.channels.audio.unmix()
2199
2219
  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.14",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {