@babblevoice/babble-drachtio-callmanager 1.6.9 → 1.6.11

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 CHANGED
@@ -275,6 +275,9 @@ class call {
275
275
  */
276
276
  this._em = new events.EventEmitter()
277
277
 
278
+ /* copy default */
279
+ this.options = { ...callmanager.options }
280
+
278
281
  /**
279
282
  @member
280
283
  @private
@@ -1019,36 +1022,9 @@ class call {
1019
1022
 
1020
1023
  this.sdp.remote = sdpgen.create( this._req.msg.body )
1021
1024
 
1022
- let alegremotesdp
1023
- if( this.parent ) {
1024
- if( this.parent.established ) {
1025
- alegremotesdp = this.parent.sdp.remote
1026
- } else {
1027
- alegremotesdp = sdpgen.create( this.parent._req.msg.body )
1028
- }
1029
- let alegpossiblecodecs = alegremotesdp.intersection( this.options.preferedcodecs )
1030
- if( !alegpossiblecodecs ) alegpossiblecodecs = alegremotesdp.intersection( callmanager.options.preferedcodecs )
1031
- if( !alegpossiblecodecs ) {
1032
- return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1033
- }
1034
-
1035
- this.selectedcodec = this.sdp.remote.intersection( alegpossiblecodecs, true )
1036
- /* if this doesn't work - then we will have to transcode if we can find a codec which works */
1037
- if( this.selectedcodec ) {
1038
- this.parent.selectedcodec = this.selectedcodec
1039
- } else {
1040
- this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1041
- if( !this.selectedcodec ) this.selectedcodec = this.sdp.remote.intersection( callmanager.options.preferedcodecs )
1042
- if( !this.selectedcodec ) {
1043
- return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1044
- }
1045
- }
1046
- } else {
1047
- /* no parent - just pick our prefered codec */
1048
- this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1049
- if( !this.selectedcodec ) {
1050
- return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1051
- }
1025
+ this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1026
+ if( !this.selectedcodec ) {
1027
+ return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1052
1028
  }
1053
1029
 
1054
1030
  let target = this.sdp.remote.getaudio()
@@ -1433,13 +1409,11 @@ class call {
1433
1409
 
1434
1410
  if( this.canceled || this.established ) return
1435
1411
 
1436
- options = { ...callmanager.options, ...this.options, ...options }
1412
+ this.options = { ...this.options, ...options }
1437
1413
 
1438
1414
  let channeldef
1439
1415
  if( this._req.msg && this._req.msg.body ) {
1440
- /* options.preferedcodecs may have been narrowed down so we still check callmanager as well */
1441
- this.selectedcodec = this.sdp.remote.intersection( options.preferedcodecs, true )
1442
- if( !this.selectedcodec ) this.selectedcodec = this.sdp.remote.intersection( callmanager.options.preferedcodecs, true )
1416
+ this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1443
1417
  if( !this.selectedcodec ) {
1444
1418
  return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1445
1419
  }
@@ -1476,7 +1450,7 @@ class call {
1476
1450
  .setconnectionaddress( ch.local.address )
1477
1451
  .setaudioport( ch.local.port )
1478
1452
 
1479
- if( callmanager.options.rfc2833 ) {
1453
+ if( this.options.rfc2833 ) {
1480
1454
  this.sdp.local.addcodecs( "2833" )
1481
1455
  }
1482
1456
 
@@ -1490,7 +1464,7 @@ class call {
1490
1464
  if( this.canceled ) return
1491
1465
  }
1492
1466
 
1493
- if( options.early ) {
1467
+ if( this.options.early ) {
1494
1468
  this.state.early = true
1495
1469
  this._em.emit( "call.early", this )
1496
1470
  callmanager.options.em.emit( "call.early", this )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -99,6 +99,9 @@ describe( "call object", function() {
99
99
 
100
100
  expect( call.state.cleaned ).to.be.true
101
101
 
102
+ /* defaults are loaded from call manager */
103
+ expect( call.options.preferedcodecs ).to.equal( "g722 ilbc pcmu pcma" )
104
+
102
105
  } )
103
106
 
104
107
  it( `uas.newuac - create uac`, async function() {
@@ -448,8 +448,8 @@ a=sendrecv`.replace(/(\r\n|\n|\r)/gm, "\r\n")
448
448
  expect( channelmessages[ 2 ].remote.address ).to.equal( "82.19.206.102" )
449
449
  expect( channelmessages[ 3 ].channel ).to.equal( "mix" )
450
450
 
451
+ expect( channelmessages[ 6 ].channel ).to.equal( "close" )
451
452
  expect( channelmessages[ 7 ].channel ).to.equal( "close" )
452
- expect( channelmessages[ 8 ].channel ).to.equal( "close" )
453
453
 
454
454
  expect( msginfo.body ).to.include( "UDP/TLS/RTP/SAVPF" )
455
455
 
@@ -292,6 +292,9 @@ describe( "xfer", function() {
292
292
  srfscenario.inbound()
293
293
  } )
294
294
 
295
+ /* needed for _dialog.on... */
296
+ await b_2.answer()
297
+
295
298
  let c_1 = await b_2.newuac( { "contact": "1001@dummy" } )
296
299
 
297
300
  /* now we refer b_2 to b_1 */