@babblevoice/babble-drachtio-callmanager 1.6.8 → 1.6.9

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
@@ -953,7 +953,7 @@ class call {
953
953
 
954
954
  this.sdp.remote = sdpgen.create( this._dialog.remote.sdp )
955
955
  this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
956
- if( "" == this.selectedcodec ) {
956
+ if( !this.selectedcodec ) {
957
957
  return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
958
958
  }
959
959
 
@@ -1026,23 +1026,27 @@ class call {
1026
1026
  } else {
1027
1027
  alegremotesdp = sdpgen.create( this.parent._req.msg.body )
1028
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
+ }
1029
1034
 
1030
- this.selectedcodec = this.sdp.remote.intersection(
1031
- alegremotesdp.intersection( this.options.preferedcodecs ), true )
1032
-
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 */
1033
1037
  if( this.selectedcodec ) {
1034
1038
  this.parent.selectedcodec = this.selectedcodec
1035
1039
  } else {
1036
- /* Ok - transcode */
1037
1040
  this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1038
- if( "" == this.selectedcodec || "" == this.parent.selectedcodec ) {
1041
+ if( !this.selectedcodec ) this.selectedcodec = this.sdp.remote.intersection( callmanager.options.preferedcodecs )
1042
+ if( !this.selectedcodec ) {
1039
1043
  return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1040
1044
  }
1041
1045
  }
1042
1046
  } else {
1043
1047
  /* no parent - just pick our prefered codec */
1044
1048
  this.selectedcodec = this.sdp.remote.intersection( this.options.preferedcodecs, true )
1045
- if( "" == this.selectedcodec ) {
1049
+ if( !this.selectedcodec ) {
1046
1050
  return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1047
1051
  }
1048
1052
  }
@@ -1088,7 +1092,7 @@ class call {
1088
1092
 
1089
1093
  if( this.parent ) {
1090
1094
  if( !this.parent.established ) {
1091
- await this.parent.answer( { "preferedcodecs": this.selectedcodec } )
1095
+ await this.parent.answer()
1092
1096
  .catch( ( err ) => {
1093
1097
  console.trace( err )
1094
1098
  } )
@@ -1435,9 +1439,11 @@ class call {
1435
1439
  if( this._req.msg && this._req.msg.body ) {
1436
1440
  /* options.preferedcodecs may have been narrowed down so we still check callmanager as well */
1437
1441
  this.selectedcodec = this.sdp.remote.intersection( options.preferedcodecs, true )
1438
- if( false === this.selectedcodec ) {
1439
- this.selectedcodec = this.sdp.remote.intersection( callmanager.options.preferedcodecs, true )
1442
+ if( !this.selectedcodec ) this.selectedcodec = this.sdp.remote.intersection( callmanager.options.preferedcodecs, true )
1443
+ if( !this.selectedcodec ) {
1444
+ return this.hangup( hangupcodes.INCOMPATIBLE_DESTINATION )
1440
1445
  }
1446
+
1441
1447
  let remoteaudio = this.sdp.remote.getaudio()
1442
1448
  if( !remoteaudio ) return
1443
1449
 
package/lib/sdp.js CHANGED
@@ -431,7 +431,10 @@ class sdp {
431
431
  if ( undefined != codecconv[ codec ] ) a[ i ] = codecconv[ codec ]
432
432
  } )
433
433
 
434
- return retval.join( " " )
434
+ let full = retval.join( " " )
435
+ if( !full ) return false
436
+
437
+ return full
435
438
  }
436
439
 
437
440
  toString() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -330,4 +330,41 @@ a=rtpmap:8 PCMA/8000`
330
330
  expect( def.remote.port ).to.equal( 48380 )
331
331
  expect( def.remote.codec ).to.equal( 8 )
332
332
  } )
333
+
334
+ it( `another real life example`, async function() {
335
+ const testsdp = `v=0
336
+ o=MTLSBC 1664810796 1664810796 IN IP4 213.166.4.133
337
+ s=SIP Call
338
+ c=IN IP4 213.166.4.133
339
+ t=0 0
340
+ m=audio 52290 RTP/AVP 8 101 13 0 3 18
341
+ a=rtpmap:8 PCMA/8000
342
+ a=rtpmap:0 PCMU/8000
343
+ a=rtpmap:3 GSM/8000
344
+ a=rtpmap:18 G729/8000
345
+ a=fmtp:18 annexb=no
346
+ a=rtpmap:101 telephone-event/8000
347
+ a=fmtp:101 0-16
348
+ a=rtpmap:13 CN/8000
349
+ a=ptime:20`
350
+
351
+ let oursdp = sdp.create( testsdp )
352
+
353
+ let selectedcodec = oursdp.intersection( "g722", true )
354
+ console.log("selectedcodec",selectedcodec)
355
+ return
356
+ selectedcodec = oursdp.intersection( "g722", true )
357
+ let remoteaudio = oursdp.getaudio()
358
+
359
+ oursdp.select( selectedcodec )
360
+
361
+ let ourlocalsdp = sdp.create()
362
+ .addcodecs( selectedcodec )
363
+ .addcodecs( "2833" )
364
+ .setconnectionaddress( "1.1.1.1" )
365
+ .setaudioport( 1000 )
366
+
367
+ console.log(ourlocalsdp.toString())
368
+
369
+ } )
333
370
  } )