mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
bugfix: rtpengine needs to transcode when different codecs are used on A and B legs
This commit is contained in:
@@ -554,8 +554,7 @@ class TaskDial extends Task {
|
|||||||
try {
|
try {
|
||||||
const aLegSdp = cs.ep.remote.sdp;
|
const aLegSdp = cs.ep.remote.sdp;
|
||||||
const bLegSdp = sd.dlg.remote.sdp;
|
const bLegSdp = sd.dlg.remote.sdp;
|
||||||
this.logger.debug({aLegSdp, bLegSdp}, 'Dial:_releaseMedia - releasing media from freewitch');
|
await Promise.all[sd.releaseMediaToSBC(aLegSdp, cs.ep.local.sdp), cs.releaseMediaToSBC(bLegSdp)];
|
||||||
await Promise.all[sd.releaseMediaToSBC(aLegSdp), cs.releaseMediaToSBC(bLegSdp)];
|
|
||||||
this.epOther = null;
|
this.epOther = null;
|
||||||
this.logger.info('Dial:_releaseMedia - successfully released media from freewitch');
|
this.logger.info('Dial:_releaseMedia - successfully released media from freewitch');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const ConfirmCallSession = require('../session/confirm-call-session');
|
|||||||
const AdultingCallSession = require('../session/adulting-call-session');
|
const AdultingCallSession = require('../session/adulting-call-session');
|
||||||
const deepcopy = require('deepcopy');
|
const deepcopy = require('deepcopy');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const stripCodecs = require('./strip-ancillary-codecs');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
const { v4: uuidv4 } = require('uuid');
|
||||||
|
|
||||||
class SingleDialer extends Emitter {
|
class SingleDialer extends Emitter {
|
||||||
@@ -316,9 +317,10 @@ class SingleDialer extends Emitter {
|
|||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
async releaseMediaToSBC(remoteSdp) {
|
async releaseMediaToSBC(remoteSdp, localSdp) {
|
||||||
assert(this.dlg && this.dlg.connected && this.ep && typeof remoteSdp === 'string');
|
assert(this.dlg && this.dlg.connected && this.ep && typeof remoteSdp === 'string');
|
||||||
await this.dlg.modify(remoteSdp, {
|
const sdp = stripCodecs(this.logger, remoteSdp, localSdp) || remoteSdp;
|
||||||
|
await this.dlg.modify(sdp, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Reason': 'release-media'
|
'X-Reason': 'release-media'
|
||||||
}
|
}
|
||||||
|
|||||||
30
lib/utils/strip-ancillary-codecs.js
Normal file
30
lib/utils/strip-ancillary-codecs.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
const sdpTransform = require('sdp-transform');
|
||||||
|
|
||||||
|
const stripCodecs = (logger, remoteSdp, localSdp) => {
|
||||||
|
try {
|
||||||
|
const sdp = sdpTransform.parse(remoteSdp);
|
||||||
|
const local = sdpTransform.parse(localSdp);
|
||||||
|
const m = local.media
|
||||||
|
.find((m) => 'audio' === m.type);
|
||||||
|
const pt = m.rtp[0].payload;
|
||||||
|
|
||||||
|
/* manipulate on the audio section */
|
||||||
|
const audio = sdp.media.find((m) => 'audio' === m.type);
|
||||||
|
|
||||||
|
/* discard all of the codecs except the first in our 200 OK, and telephony-events */
|
||||||
|
const ptSaves = audio.rtp
|
||||||
|
.filter((r) => r.codec === 'telephone-event' || r.payload === pt)
|
||||||
|
.map((r) => r.payload);
|
||||||
|
const rtp = audio.rtp.filter((r) => ptSaves.includes(r.payload));
|
||||||
|
|
||||||
|
/* reattach the new rtp sections and stripped payload list */
|
||||||
|
audio.rtp = rtp;
|
||||||
|
audio.payloads = rtp.map((r) => r.payload).join(' ');
|
||||||
|
return sdpTransform.write(sdp);
|
||||||
|
} catch (err) {
|
||||||
|
logger.error({err, remoteSdp, localSdp}, 'strip-ancillary-codecs error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = stripCodecs;
|
||||||
|
|
||||||
Reference in New Issue
Block a user