@babblevoice/babble-drachtio-callmanager 1.4.0 → 1.4.1
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 +29 -4
- package/package.json +1 -1
package/lib/call.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
const { v4: uuidv4 } = require( "uuid" )
|
|
3
3
|
const events = require( "events" )
|
|
4
|
+
const dns = require( "node:dns" )
|
|
4
5
|
|
|
5
6
|
const projectrtp = require( "@babblevoice/projectrtp" ).projectrtp
|
|
6
7
|
|
|
@@ -854,6 +855,25 @@ class call {
|
|
|
854
855
|
return this
|
|
855
856
|
}
|
|
856
857
|
|
|
858
|
+
/* A simple implimentation if we are offered candidates */
|
|
859
|
+
static async _parsesdpcandidates( target, sdp ) {
|
|
860
|
+
|
|
861
|
+
if( Array.isArray( sdp.media[ 0 ].candidates ) ) {
|
|
862
|
+
let candidates = sdp.media[ 0 ].candidates
|
|
863
|
+
if( candidates.length > 0 ) {
|
|
864
|
+
candidates.sort( ( l, r ) => { return r.priority - l.priority } )
|
|
865
|
+
target.port = candidates[ 0 ].port
|
|
866
|
+
|
|
867
|
+
await new Promise( ( r ) => {
|
|
868
|
+
dns.lookup( candidates[ 0 ].ip, ( err, result ) => {
|
|
869
|
+
if( !err ) target.address = result
|
|
870
|
+
r()
|
|
871
|
+
} )
|
|
872
|
+
} )
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
857
877
|
/**
|
|
858
878
|
On an early negotiation we have already sent our sdp without
|
|
859
879
|
knowing what the otherside is going to offer. We now have the
|
|
@@ -878,11 +898,13 @@ class call {
|
|
|
878
898
|
let channeldef
|
|
879
899
|
if( this._iswebrtc ) {
|
|
880
900
|
let actpass = "active"
|
|
881
|
-
if( "
|
|
901
|
+
if( "active" == this.sdp.remote.sdp.media[ 0 ].setup ) actpass = "passive" /* act|pass|actpass */
|
|
902
|
+
|
|
903
|
+
await call._parsesdpcandidates( target, this.sdp.remote.sdp )
|
|
882
904
|
|
|
883
905
|
channeldef = call._createchannelremotedef(
|
|
884
|
-
target.address,
|
|
885
|
-
target.port,
|
|
906
|
+
target.address,
|
|
907
|
+
target.port,
|
|
886
908
|
target.audio.payloads[ 0 ],
|
|
887
909
|
this.sdp.remote.sdp.media[ 0 ].fingerprint.hash,
|
|
888
910
|
actpass ).remote
|
|
@@ -1300,6 +1322,9 @@ class call {
|
|
|
1300
1322
|
if( !remoteaudio ) return
|
|
1301
1323
|
|
|
1302
1324
|
this.sdp.remote.select( this.selectedcodec )
|
|
1325
|
+
|
|
1326
|
+
await call._parsesdpcandidates( remoteaudio, this.sdp.remote.sdp )
|
|
1327
|
+
|
|
1303
1328
|
let channeldef = call._createchannelremotedef( remoteaudio.address, remoteaudio.port, remoteaudio.audio.payloads[ 0 ] )
|
|
1304
1329
|
|
|
1305
1330
|
let iswebrtc = this._iswebrtc
|
|
@@ -2087,7 +2112,7 @@ class call {
|
|
|
2087
2112
|
|
|
2088
2113
|
} else if( "uac" === this.type ) {
|
|
2089
2114
|
try {
|
|
2090
|
-
this._req.cancel()
|
|
2115
|
+
if( this._req ) this._req.cancel()
|
|
2091
2116
|
} catch( e ) { console.error( e ) }
|
|
2092
2117
|
|
|
2093
2118
|
this.canceled = true
|