@babblevoice/babble-drachtio-callmanager 3.3.3 → 3.3.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.
- package/lib/call.js +78 -29
- package/package.json +1 -1
package/lib/call.js
CHANGED
|
@@ -218,7 +218,8 @@ class call {
|
|
|
218
218
|
"audio": undefined,
|
|
219
219
|
"closed": {
|
|
220
220
|
"audio": []
|
|
221
|
-
}
|
|
221
|
+
},
|
|
222
|
+
"count": 0
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
/**
|
|
@@ -1717,13 +1718,20 @@ class call {
|
|
|
1717
1718
|
this.channels.closed.audio.push( e )
|
|
1718
1719
|
}
|
|
1719
1720
|
|
|
1720
|
-
this.channels.
|
|
1721
|
-
if( this._state._onhangup ) {
|
|
1722
|
-
this._cleanup()
|
|
1723
|
-
return
|
|
1724
|
-
}
|
|
1721
|
+
this.channels.count--
|
|
1725
1722
|
|
|
1726
|
-
this.
|
|
1723
|
+
if ( 0 === this.channels.count ) {
|
|
1724
|
+
this.channels.audio = false
|
|
1725
|
+
|
|
1726
|
+
if( this._state._onhangup ) {
|
|
1727
|
+
this._cleanup()
|
|
1728
|
+
return
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// This will handle _cleanup() later
|
|
1732
|
+
// based on the above flag
|
|
1733
|
+
this.hangup()
|
|
1734
|
+
}
|
|
1727
1735
|
}
|
|
1728
1736
|
|
|
1729
1737
|
/**
|
|
@@ -2010,9 +2018,13 @@ class call {
|
|
|
2010
2018
|
same as used elsewhere. If a bond has been attached to the call, we will
|
|
2011
2019
|
try to reuse an existing channel.
|
|
2012
2020
|
@param { object } [ channeldef ]
|
|
2021
|
+
@param { object } [ newchannel ]
|
|
2013
2022
|
@private
|
|
2014
2023
|
*/
|
|
2015
|
-
async reinvite( channeldef ) {
|
|
2024
|
+
async reinvite( channeldef, newchannel ) {
|
|
2025
|
+
|
|
2026
|
+
if ( newchannel )
|
|
2027
|
+
this.channels.audio = newchannel
|
|
2016
2028
|
|
|
2017
2029
|
if ( !channeldef )
|
|
2018
2030
|
channeldef = await this.#createchannelremotedef()
|
|
@@ -2045,17 +2057,43 @@ class call {
|
|
|
2045
2057
|
const channeldef = await othercall.#createchannelremotedef()
|
|
2046
2058
|
|
|
2047
2059
|
const oldchannel = othercall.channels.audio
|
|
2048
|
-
|
|
2049
|
-
othercall.channels.audio = await this.channels.audio.openchannel( channeldef, othercall._handlechannelevents.bind( othercall ) )
|
|
2060
|
+
const newchannel = await this.#openchannel( channeldef, othercall )
|
|
2050
2061
|
|
|
2051
|
-
await othercall.bond( this ).reinvite( channeldef )
|
|
2062
|
+
await othercall.bond( this ).reinvite( channeldef, newchannel )
|
|
2052
2063
|
|
|
2053
|
-
await oldchannel.
|
|
2064
|
+
await oldchannel.unmix()
|
|
2065
|
+
oldchannel.close()
|
|
2054
2066
|
}
|
|
2055
2067
|
|
|
2056
2068
|
await this.channels.audio.mix( othercall.channels.audio )
|
|
2057
2069
|
}
|
|
2058
2070
|
|
|
2071
|
+
/**
|
|
2072
|
+
Mix two calls. If the two calls are on a different node
|
|
2073
|
+
the second call is bonded and reinvited.
|
|
2074
|
+
@param { object } channeldef - our call object which is early
|
|
2075
|
+
@param { call } bindcall - the call which will own the channel
|
|
2076
|
+
*/
|
|
2077
|
+
async #openchannel( channeldef, bindcall ) {
|
|
2078
|
+
|
|
2079
|
+
let chan = undefined
|
|
2080
|
+
|
|
2081
|
+
if ( !bindcall || !this.channels.audio ) {
|
|
2082
|
+
chan = await projectrtp.openchannel(
|
|
2083
|
+
channeldef, this._handlechannelevents.bind( this ) )
|
|
2084
|
+
} else {
|
|
2085
|
+
chan = await this.channels.audio.openchannel(
|
|
2086
|
+
channeldef, bindcall._handlechannelevents.bind( bindcall ) )
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
if ( bindcall )
|
|
2090
|
+
bindcall.channels.count++
|
|
2091
|
+
else
|
|
2092
|
+
this.channels.count++
|
|
2093
|
+
|
|
2094
|
+
return chan
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2059
2097
|
/**
|
|
2060
2098
|
*
|
|
2061
2099
|
* @param { object } req
|
|
@@ -2156,20 +2194,32 @@ class call {
|
|
|
2156
2194
|
RTP stall timer will kick in first, but if a call is placed on hold followed
|
|
2157
2195
|
by AWOL... */
|
|
2158
2196
|
this._timers.seinterval = setInterval( async () => {
|
|
2159
|
-
const opts = {
|
|
2160
|
-
"method": "INVITE",
|
|
2161
|
-
"body": this.sdp.local.toString()
|
|
2162
|
-
}
|
|
2163
2197
|
|
|
2164
|
-
|
|
2165
|
-
.catch( ( e ) => {
|
|
2166
|
-
console.trace( e )
|
|
2167
|
-
this.hangup( hangupcodes.USER_GONE )
|
|
2168
|
-
} )
|
|
2198
|
+
try{
|
|
2169
2199
|
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2200
|
+
if( this.destroyed ) {
|
|
2201
|
+
/* this should be done - but we are still running */
|
|
2202
|
+
clearInterval( this._timers.seinterval )
|
|
2203
|
+
return
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
if( "function" != typeof dialog.request ) return
|
|
2207
|
+
|
|
2208
|
+
const opts = {
|
|
2209
|
+
"method": "INVITE",
|
|
2210
|
+
"body": this.sdp.local.toString()
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
const res = await dialog.request( opts )
|
|
2214
|
+
.catch( ( e ) => {
|
|
2215
|
+
console.trace( e )
|
|
2216
|
+
this.hangup( hangupcodes.USER_GONE )
|
|
2217
|
+
} )
|
|
2218
|
+
|
|
2219
|
+
if( !this.destroyed && 200 != res.msg.status ) {
|
|
2220
|
+
this.hangup( hangupcodes.USER_GONE )
|
|
2221
|
+
}
|
|
2222
|
+
} catch( e ) { /* empty */ }
|
|
2173
2223
|
|
|
2174
2224
|
}, callmanager.options.seexpire )
|
|
2175
2225
|
|
|
@@ -2567,7 +2617,6 @@ class call {
|
|
|
2567
2617
|
@private
|
|
2568
2618
|
*/
|
|
2569
2619
|
_cleanup() {
|
|
2570
|
-
|
|
2571
2620
|
if( this.state.cleaned ) return
|
|
2572
2621
|
this.state.cleaned = true
|
|
2573
2622
|
|
|
@@ -2643,7 +2692,7 @@ class call {
|
|
|
2643
2692
|
if( this.channels.audio ) {
|
|
2644
2693
|
this.channels.audio.close()
|
|
2645
2694
|
this._timers.cleanup = setTimeout( () => {
|
|
2646
|
-
console.trace( "Timeout waiting for channel close, cleaning up anyway
|
|
2695
|
+
console.trace( this.uuid + " Timeout waiting for channel close, cleaning up anyway, chan uuid: " + this.channels.audio.uuid + ", channel count: " + this.channels.count )
|
|
2647
2696
|
this._cleanup()
|
|
2648
2697
|
}, 60 * 1000 )
|
|
2649
2698
|
|
|
@@ -2896,18 +2945,18 @@ class call {
|
|
|
2896
2945
|
detect which mode the channel is in - but the channels property will exist on a connect
|
|
2897
2946
|
style channel. projectrtp will getrelatives a rewrite to support only one. */
|
|
2898
2947
|
if( relatedcall && relatedcall.channels.audio && relatedcall.channels.audio.channels ) {
|
|
2899
|
-
this.channels.audio = await this
|
|
2948
|
+
this.channels.audio = await this.#openchannel( channeldef, this )
|
|
2900
2949
|
return
|
|
2901
2950
|
}
|
|
2902
2951
|
|
|
2903
2952
|
for( const other of this.relatives ) {
|
|
2904
2953
|
if( other.channels && other.channels.audio ) {
|
|
2905
|
-
this.channels.audio = await other
|
|
2954
|
+
this.channels.audio = await other.#openchannel( channeldef, this )
|
|
2906
2955
|
return
|
|
2907
2956
|
}
|
|
2908
2957
|
}
|
|
2909
2958
|
|
|
2910
|
-
this.channels.audio = await
|
|
2959
|
+
this.channels.audio = await this.#openchannel( channeldef )
|
|
2911
2960
|
}
|
|
2912
2961
|
|
|
2913
2962
|
/**
|