From 59b4e97923adb65edc74d4e619ca8ab188486a95 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Fri, 1 Nov 2024 11:52:32 +0700 Subject: [PATCH 1/3] support force opus pcmu transcode --- lib/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 42e8978..8e18c55 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -34,7 +34,8 @@ function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, teams = false) { 'call-id': req.get('Call-ID'), 'replace': ['origin', 'session-connection'], 'record call': process.env.JAMBONES_RECORD_ALL_CALLS ? 'yes' : 'no', - ...(process.env.JAMBONES_ACCEPT_G729 && { codec: { mask: 'g729', transcode: 'pcmu' } }) + ...(process.env.JAMBONES_ACCEPT_G729 && { codec: { mask: 'g729', transcode: 'pcmu' } }), + ...(process.env.JAMBONES_OPUS_PCMU_TRANSCODE && { codec: { mask: 'opus', transcode: 'pcmu' } }) }; return { common, From bf16ab07307b3c0c5d502cd81f07a289d648581f Mon Sep 17 00:00:00 2001 From: Quan HL Date: Mon, 4 Nov 2024 17:26:09 +0700 Subject: [PATCH 2/3] fix review comment --- lib/utils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 8e18c55..d995048 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -30,12 +30,14 @@ function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, teams = false) { dstOpts.flags.push('inject DTMF'); srcOpts.flags.push('inject DTMF'); } + const codecs = process.env.JAMBONES_ACCEPT_AND_TRANSCODE ? + process.env.JAMBONES_ACCEPT_AND_TRANSCODE : + process.env.JAMBONES_ACCEPT_G729 ? 'g729' : ''; const common = { 'call-id': req.get('Call-ID'), 'replace': ['origin', 'session-connection'], 'record call': process.env.JAMBONES_RECORD_ALL_CALLS ? 'yes' : 'no', - ...(process.env.JAMBONES_ACCEPT_G729 && { codec: { mask: 'g729', transcode: 'pcmu' } }), - ...(process.env.JAMBONES_OPUS_PCMU_TRANSCODE && { codec: { mask: 'opus', transcode: 'pcmu' } }) + ...(codecs && { codec: { mask: codecs, transcode: 'pcmu,pcma' } }) }; return { common, From 033d4dec284fe7191d0086e8d3b864f2c3c81346 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Mon, 4 Nov 2024 17:59:21 +0700 Subject: [PATCH 3/3] wip --- lib/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index d995048..c35be32 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -30,14 +30,14 @@ function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, teams = false) { dstOpts.flags.push('inject DTMF'); srcOpts.flags.push('inject DTMF'); } - const codecs = process.env.JAMBONES_ACCEPT_AND_TRANSCODE ? + const acceptCodecs = process.env.JAMBONES_ACCEPT_AND_TRANSCODE ? process.env.JAMBONES_ACCEPT_AND_TRANSCODE : process.env.JAMBONES_ACCEPT_G729 ? 'g729' : ''; const common = { 'call-id': req.get('Call-ID'), 'replace': ['origin', 'session-connection'], 'record call': process.env.JAMBONES_RECORD_ALL_CALLS ? 'yes' : 'no', - ...(codecs && { codec: { mask: codecs, transcode: 'pcmu,pcma' } }) + ...(acceptCodecs && { codec: { mask: acceptCodecs, transcode: 'pcmu,pcma' } }) }; return { common,