@babblevoice/babble-drachtio-callmanager 2.3.18 → 2.3.20
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 +33 -46
- package/package.json +1 -1
package/lib/call.js
CHANGED
|
@@ -1712,6 +1712,7 @@ class call {
|
|
|
1712
1712
|
/**
|
|
1713
1713
|
* If we have been placed on hold (and it has been neotiated) then configure audio to match.
|
|
1714
1714
|
* @param { "inactive"|"sendonly" } direction
|
|
1715
|
+
* @returns { Promise } resolves on timeout or when unmix happens
|
|
1715
1716
|
* @private
|
|
1716
1717
|
*/
|
|
1717
1718
|
_hold( direction = "inactive" ) {
|
|
@@ -1719,21 +1720,30 @@ class call {
|
|
|
1719
1720
|
if( this.state.held ) return
|
|
1720
1721
|
this.state.held = true
|
|
1721
1722
|
|
|
1723
|
+
const ourpromises = []
|
|
1724
|
+
|
|
1722
1725
|
const d = { "send": false, "recv": false }
|
|
1723
1726
|
if( "sendonly" == direction ) d.send = true
|
|
1724
1727
|
|
|
1725
|
-
this.channels.audio
|
|
1728
|
+
if( this.channels.audio ) {
|
|
1729
|
+
this.channels.audio.unmix()
|
|
1730
|
+
ourpromises.push( this.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ) )
|
|
1731
|
+
this.channels.audio.direction( d )
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1726
1734
|
this.sdp.local.setaudiodirection( direction )
|
|
1727
1735
|
|
|
1728
1736
|
const other = this.other
|
|
1729
|
-
if( other ) {
|
|
1730
|
-
this.channels.audio.unmix()
|
|
1737
|
+
if( other && other.channels.audio ) {
|
|
1731
1738
|
other.channels.audio.unmix()
|
|
1739
|
+
ourpromises.push( other.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ) )
|
|
1732
1740
|
other.channels.audio.play( this.moh )
|
|
1733
1741
|
}
|
|
1734
1742
|
|
|
1735
1743
|
this._em.emit( "call.hold", this )
|
|
1736
1744
|
callmanager.options.em.emit( "call.hold", this )
|
|
1745
|
+
|
|
1746
|
+
return Promise.all( ourpromises )
|
|
1737
1747
|
}
|
|
1738
1748
|
|
|
1739
1749
|
/**
|
|
@@ -1744,11 +1754,12 @@ class call {
|
|
|
1744
1754
|
if( !this.state.held ) return
|
|
1745
1755
|
this.state.held = false
|
|
1746
1756
|
|
|
1747
|
-
this.channels.audio
|
|
1757
|
+
if( this.channels.audio )
|
|
1758
|
+
this.channels.audio.direction( { "send": true, "recv": true } )
|
|
1748
1759
|
this.sdp.local.setaudiodirection( "sendrecv" )
|
|
1749
1760
|
|
|
1750
1761
|
const other = this.other
|
|
1751
|
-
if( other ) {
|
|
1762
|
+
if( other && other.channels.audio && this.channels.audio ) {
|
|
1752
1763
|
this.channels.audio.mix( other.channels.audio )
|
|
1753
1764
|
|
|
1754
1765
|
this._em.emit( "call.mix", this )
|
|
@@ -1841,35 +1852,11 @@ class call {
|
|
|
1841
1852
|
} )
|
|
1842
1853
|
}
|
|
1843
1854
|
|
|
1844
|
-
/**
|
|
1845
|
-
*
|
|
1846
|
-
* @param { object } other
|
|
1847
|
-
* @returns { object }
|
|
1848
|
-
*/
|
|
1849
|
-
swapchannel( other ){
|
|
1850
|
-
|
|
1851
|
-
const this_audio = this.channels.audio
|
|
1852
|
-
const this_sdp = this.sdp.local
|
|
1853
|
-
const this_chem = this.channels.audio.em
|
|
1854
|
-
const other_chem = other.channels.audio.em
|
|
1855
|
-
|
|
1856
|
-
this.channels.audio = other.channels.audio
|
|
1857
|
-
this.channels.audio.em = this_chem
|
|
1858
|
-
this.sdp.local = other.sdp.local
|
|
1859
|
-
|
|
1860
|
-
other.channels.audio = this_audio
|
|
1861
|
-
other.channels.audio.em = other_chem
|
|
1862
|
-
other.sdp.local = this_sdp
|
|
1863
|
-
|
|
1864
|
-
/* reinvite will pick up on this */
|
|
1865
|
-
const selectedcodec = other.selectedcodec
|
|
1866
|
-
other.selectedcodec = this.selectedcodec
|
|
1867
|
-
this.selectedcodec = selectedcodec
|
|
1868
|
-
return this
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
1855
|
/**
|
|
1872
1856
|
Send out modified SDP to get the audio to the new location.
|
|
1857
|
+
This method might be use, but there are problems - so when it is used
|
|
1858
|
+
it can be re-written but should use a mthod to create a codec - which is the
|
|
1859
|
+
same as used elsewhere.
|
|
1873
1860
|
@private
|
|
1874
1861
|
*/
|
|
1875
1862
|
async reinvite() {
|
|
@@ -2118,17 +2105,22 @@ class call {
|
|
|
2118
2105
|
othercall.state.refered = true
|
|
2119
2106
|
|
|
2120
2107
|
this.detach()
|
|
2108
|
+
|
|
2109
|
+
this._unhold()
|
|
2110
|
+
othercall._unhold()
|
|
2111
|
+
|
|
2112
|
+
const ourpromises = []
|
|
2121
2113
|
if( this.channels.audio ) {
|
|
2122
|
-
this.channels.audio.direction( { "send": true, "recv": true } )
|
|
2123
2114
|
this.channels.audio.unmix()
|
|
2124
|
-
|
|
2115
|
+
ourpromises.push( this.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ) )
|
|
2125
2116
|
}
|
|
2126
2117
|
if( othercall.channels.audio ) {
|
|
2127
|
-
othercall.channels.audio.direction( { "send": true, "recv": true } )
|
|
2128
2118
|
othercall.channels.audio.unmix()
|
|
2129
|
-
|
|
2119
|
+
ourpromises.push( othercall.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ) )
|
|
2130
2120
|
}
|
|
2131
2121
|
|
|
2122
|
+
await Promise.all( ourpromises )
|
|
2123
|
+
|
|
2132
2124
|
if( othercall.channels.audio && this.moh ) othercall.channels.audio.play( this.moh )
|
|
2133
2125
|
|
|
2134
2126
|
res.send( 202 )
|
|
@@ -2225,10 +2217,11 @@ class call {
|
|
|
2225
2217
|
b_1.detach()
|
|
2226
2218
|
b_2.detach()
|
|
2227
2219
|
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2220
|
+
await Promise.all( [
|
|
2221
|
+
a_1._unhold(),
|
|
2222
|
+
b_1._unhold(),
|
|
2223
|
+
b_2._unhold(),
|
|
2224
|
+
c_1._unhold() ] )
|
|
2232
2225
|
|
|
2233
2226
|
a_1.channels.audio.unmix()
|
|
2234
2227
|
b_1.channels.audio.unmix()
|
|
@@ -2242,8 +2235,6 @@ class call {
|
|
|
2242
2235
|
c_1.waitforanyevent( { "action": "mix", "event": "finished" }, 0.5 ),
|
|
2243
2236
|
] )
|
|
2244
2237
|
|
|
2245
|
-
a_1.swapchannel( b_2 )
|
|
2246
|
-
|
|
2247
2238
|
await new Promise( ( resolve ) => {
|
|
2248
2239
|
res.send( 202, "Refering", {}, ( /* err, response */ ) => {
|
|
2249
2240
|
resolve()
|
|
@@ -2259,10 +2250,6 @@ class call {
|
|
|
2259
2250
|
return
|
|
2260
2251
|
}
|
|
2261
2252
|
|
|
2262
|
-
/* modify ports and renegotiate codecs */
|
|
2263
|
-
await a_1.reinvite()
|
|
2264
|
-
|
|
2265
|
-
/* there might be situations where mix is not the correct thing - perhaps a pop push application? */
|
|
2266
2253
|
/* Link logically and mix */
|
|
2267
2254
|
a_1.adopt( c_1, true )
|
|
2268
2255
|
|