@babblevoice/babble-drachtio-callmanager 2.1.0 → 2.1.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 +34 -14
  2. package/package.json +1 -1
package/lib/call.js CHANGED
@@ -1037,10 +1037,8 @@ class call {
1037
1037
  } else {
1038
1038
  channeldef = call._createchannelremotedef( target.address, target.port, target.audio.payloads[ 0 ] )
1039
1039
  }
1040
-
1041
- const other = this.other
1042
- if( other && other.channels.audio ) this.channels.audio = await other.channels.audio.openchannel( channeldef, this._handlechannelevents.bind( this ) )
1043
- else this.channels.audio = await projectrtp.openchannel( channeldef, this._handlechannelevents.bind( this ) )
1040
+
1041
+ await this.#openrelatedchannel()
1044
1042
 
1045
1043
  this.sdp.local = sdpgen.create()
1046
1044
  .addcodecs( this.selectedcodec )
@@ -1069,7 +1067,7 @@ class call {
1069
1067
 
1070
1068
  /**
1071
1069
  Sometimes we don't care who if we are the parent or child - we just want the other party
1072
- @return {object|bool} returns call object or if none false
1070
+ @return { object|bool } returns call object or if none false
1073
1071
  */
1074
1072
  get other() {
1075
1073
  if( this.parent ) return this.parent
@@ -1347,23 +1345,25 @@ class call {
1347
1345
  */
1348
1346
  async #openchannelsforanswer( channeldef ) {
1349
1347
  if( this.channels.audio ) {
1348
+ /* we have already opened a channel (probably early now answering) */
1350
1349
  this.channels.audio.remote( channeldef.remote )
1351
1350
  } else {
1352
- const ch = await projectrtp.openchannel( channeldef, this._handlechannelevents.bind( this ) )
1353
- this.channels.audio = ch
1351
+
1352
+ await this.#openrelatedchannel( channeldef )
1353
+
1354
1354
  this.sdp.local = sdpgen.create()
1355
1355
  .addcodecs( this.selectedcodec )
1356
- .setconnectionaddress( ch.local.address )
1357
- .setaudioport( ch.local.port )
1356
+ .setconnectionaddress( this.channels.audio.local.address )
1357
+ .setaudioport( this.channels.audio.local.port )
1358
1358
 
1359
1359
  if( this.options.rfc2833 ) {
1360
1360
  this.sdp.local.addcodecs( "2833" )
1361
1361
  }
1362
1362
 
1363
1363
  if( this._iswebrtc ) {
1364
- this.sdp.local.addssrc( ch.local.ssrc )
1365
- .secure( ch.local.dtls.fingerprint, channeldef.remote.dtls.mode )
1366
- .addicecandidates( ch.local.address, ch.local.port, ch.local.icepwd )
1364
+ this.sdp.local.addssrc( this.channels.audio.local.ssrc )
1365
+ .secure( this.channels.audio.local.dtls.fingerprint, channeldef.remote.dtls.mode )
1366
+ .addicecandidates( this.channels.audio.local.address, this.channels.audio.local.port, this.channels.audio.local.icepwd )
1367
1367
  .rtcpmux()
1368
1368
  }
1369
1369
  }
@@ -2478,6 +2478,22 @@ class call {
2478
2478
  return child
2479
2479
  }
2480
2480
 
2481
+ /**
2482
+ * If any of our one of our related calls has a channel open
2483
+ * try and use it. NB (other favours the answered if not then the first)
2484
+ * It will use the channel on that call.
2485
+ * @param { object } [ channeldef ]
2486
+ */
2487
+ async #openrelatedchannel( channeldef ) {
2488
+
2489
+ const relatedcall = this.other
2490
+ if( relatedcall && relatedcall.channels.audio )
2491
+ this.channels.audio = await relatedcall.channels.audio.openchannel( channeldef, this._handlechannelevents.bind( this ) )
2492
+ else
2493
+ this.channels.audio = await projectrtp.openchannel( channeldef, this._handlechannelevents.bind( this ) )
2494
+
2495
+ }
2496
+
2481
2497
  /**
2482
2498
  *
2483
2499
  */
@@ -2485,13 +2501,17 @@ class call {
2485
2501
  if( this.options.late ) {
2486
2502
  this.options.noAck = true /* this is a MUST for late negotiation */
2487
2503
  } else {
2488
- if( this.options.parent && this.options.parent.channels.audio ) this.channels.audio = await this.options.parent.channels.audio.openchannel( this._handlechannelevents.bind( this ) )
2489
- else this.channels.audio = await projectrtp.openchannel( this._handlechannelevents.bind( this ) )
2504
+
2505
+ await this.#openrelatedchannel()
2490
2506
 
2491
2507
  this.sdp.local = sdpgen.create().addcodecs( this.options.preferedcodecs )
2492
2508
  this.sdp.local.setaudioport( this.channels.audio.local.port )
2493
2509
  .setconnectionaddress( this.channels.audio.local.address )
2494
2510
 
2511
+ if( this.options.rfc2833 ) {
2512
+ this.sdp.local.addcodecs( "2833" )
2513
+ }
2514
+
2495
2515
  /* DTLS is only supported ( outbound ) on websocket connections */
2496
2516
  this.sip.contact = this.options.contact
2497
2517
  if( this._iswebrtc ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {