@babblevoice/babble-drachtio-callmanager 3.3.0 → 3.3.2

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 (2) hide show
  1. package/lib/call.js +32 -25
  2. package/package.json +1 -1
package/lib/call.js CHANGED
@@ -788,9 +788,6 @@ class call {
788
788
  }
789
789
 
790
790
  if( "uac" == this.type ) {
791
- if( Array.isArray( this.sip.contact ) ) {
792
- return parseuri( this.sip.contact[ 0 ].uri )
793
- }
794
791
  return parseuri( this.options.contact )
795
792
  }
796
793
 
@@ -1298,7 +1295,10 @@ class call {
1298
1295
  */
1299
1296
  async _onlatebridge() {
1300
1297
 
1301
- this.sdp.remote = sdpgen.create( this._req.msg.body )
1298
+ if ( this._dialog.res )
1299
+ this.sdp.remote = sdpgen.create( this._dialog.res.msg.body )
1300
+ else
1301
+ this.sdp.remote = sdpgen.create( this._req.msg.body )
1302
1302
 
1303
1303
  const selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1304
1304
  if( !selectedcodec ) {
@@ -1309,7 +1309,10 @@ class call {
1309
1309
  if( !channeldef )
1310
1310
  return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1311
1311
 
1312
- await this.#openrelatedchannel()
1312
+ if ( this.channels.audio )
1313
+ this.channels.audio.destroy()
1314
+
1315
+ await this.#openrelatedchannel( channeldef )
1313
1316
 
1314
1317
  this.sdp.local = sdpgen.create()
1315
1318
  .addcodecs( selectedcodec )
@@ -1590,7 +1593,7 @@ class call {
1590
1593
  }
1591
1594
  }
1592
1595
 
1593
- /**
1596
+ /**true
1594
1597
  Shortcut to hangup with the reason busy.
1595
1598
  */
1596
1599
  busy() {
@@ -1602,23 +1605,15 @@ class call {
1602
1605
  */
1603
1606
  get _iswebrtc() {
1604
1607
 
1605
- if( !this.sip || !this.sip.contact ) return false
1606
-
1607
- let contactstr
1608
- if( Array.isArray( this.sip.contact ) ) {
1609
- contactstr = this.sip.contact[ 0 ].uri
1610
- } else {
1611
- contactstr = this.sip.contact
1612
- }
1613
-
1614
1608
  /* Have we received remote SDP? */
1615
1609
  if( this.sdp.remote ) {
1616
1610
  return this.sdp.remote.sdp.media[ 0 ] &&
1617
1611
  -1 !== this.sdp.remote.sdp.media[ 0 ].protocol.toLowerCase().indexOf( "savpf" ) /* 'UDP/TLS/RTP/SAVPF' */
1618
1612
  }
1619
1613
 
1620
- return -1 !== contactstr.indexOf( ";transport=ws" )
1621
-
1614
+ if( !this.options || !this.options.contact ) return false
1615
+ return -1 !== this.options.contact.indexOf( ";transport=ws" )
1616
+
1622
1617
  }
1623
1618
 
1624
1619
  /**
@@ -2842,11 +2837,15 @@ class call {
2842
2837
  if( callbacks.fail ) callbacks.fail( c )
2843
2838
  }
2844
2839
 
2845
- ourcallbacks.confirm = ( c ) => {
2840
+ ourcallbacks.prebridge = ( c ) => {
2841
+ if( callbacks.prebridge ) return callbacks.prebridge( c )
2842
+ }
2843
+
2844
+ ourcallbacks.confirm = ( c, queuedcall ) => {
2846
2845
  if( false !== waitonchildrenresolve ) {
2847
2846
  waitonchildrenresolve( c )
2848
2847
  waitonchildrenresolve = false
2849
- if( callbacks.confirm ) callbacks.confirm( c )
2848
+ if( callbacks.confirm ) callbacks.confirm( c, queuedcall )
2850
2849
  }
2851
2850
  }
2852
2851
 
@@ -2932,11 +2931,11 @@ class call {
2932
2931
  this.#checkandadd2833()
2933
2932
 
2934
2933
  /* DTLS is only supported ( outbound ) on websocket connections */
2935
- this.sip.contact = this.options.contact
2936
2934
  if( this._iswebrtc ) {
2937
2935
  this.sdp.local
2938
2936
  .addssrc( this.channels.audio.local.ssrc )
2939
- .secure( this.channels.audio.local.dtls.fingerprint ,"passive" )
2937
+ /* ref: https://datatracker.ietf.org/doc/html/draft-ietf-rtcweb-jsep-14#page-34 offer MUST be actpass */
2938
+ .secure( this.channels.audio.local.dtls.fingerprint ,"actpass" )
2940
2939
  .addicecandidates( this.channels.audio.local.address, this.channels.audio.local.port, this.channels.audio.local.icepwd )
2941
2940
  .rtcpmux()
2942
2941
  }
@@ -2967,7 +2966,12 @@ class call {
2967
2966
 
2968
2967
  callstore.set( this )
2969
2968
 
2970
- this.sip.tags.remote = this._dialog.sip.remoteTag
2969
+ if ( this._dialog.sip )
2970
+ this.sip.tags.remote = this._dialog.sip.remoteTag
2971
+
2972
+ let cookie = undefined
2973
+ if( callbacks.prebridge )
2974
+ cookie = await callbacks.prebridge( this )
2971
2975
 
2972
2976
  if( true === this.#noack ) {
2973
2977
  await this._onlatebridge()
@@ -2975,7 +2979,7 @@ class call {
2975
2979
  await this._onearlybridge()
2976
2980
  }
2977
2981
 
2978
- if( callbacks.confirm ) await callbacks.confirm( this )
2982
+ if( callbacks.confirm ) await callbacks.confirm( this, cookie )
2979
2983
 
2980
2984
  this._em.emit( "call.answered", this )
2981
2985
  callmanager.options.em.emit( "call.answered", this )
@@ -3193,7 +3197,6 @@ class call {
3193
3197
  if( options.entity ) {
3194
3198
  newcall.entity = options.entity
3195
3199
  callstore.set( newcall )
3196
-
3197
3200
  }
3198
3201
 
3199
3202
  newcall.#configcalleridfornewuac()
@@ -3213,7 +3216,11 @@ class call {
3213
3216
  try {
3214
3217
  newdialog = await callmanager.options.srf.createUAC(
3215
3218
  options.contact + newcall.options.contactparams,
3216
- { ...newcall.options, ...{ localSdp: newcall.sdp.local?newcall.sdp.local.toString():"" } }, {
3219
+ {
3220
+ ...newcall.options,
3221
+ ...{ noAck: newcall.#noack },
3222
+ ...{ localSdp: newcall.sdp.local?newcall.sdp.local.toString():""
3223
+ } }, {
3217
3224
 
3218
3225
  cbRequest: ( err, req ) => {
3219
3226
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {