Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

[Do Not Land] audio_quality_enhancement #411

Open
wants to merge 1 commit into
base: 4.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/sdk/base/mediastream-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,26 @@ export class MediaStreamFactory {
}
} else {
if (constraints.audio.source === MediaFormatModule.AudioSourceInfo.SCREENCAST) {
mediaConstraints.audio = true;
mediaConstraints.audio = {};
if (constraints.audio.echoCancellation === false) {
mediaConstraints.audio.echoCancellation = constraints.audio.echoCancellation;
}
if (constraints.audio.autoGainControl === false) {
mediaConstraints.audio.autoGainControl = constraints.audio.autoGainControl;
}
if (constraints.audio.noiseSuppression === false) {
mediaConstraints.audio.noiseSuppression = constraints.audio.noiseSuppression;
}
if (constraints.audio.channelCount) {
mediaConstraints.audio.channelCount = constraints.audio.channelCount;
}
if (constraints.audio.sampleRate) {
mediaConstraints.audio.sampleRate = constraints.audio.sampleRate;
}
if (!constraints.audio.echoCancellation && !constraints.audio.autoGainControl && !constraints.audio.noiseSuppression && !constraints.audio.channelCount && !constraints.audio.sampleRate) {
mediaConstraints.audio = true;
}

} else {
mediaConstraints.audio = constraints.audio;
}
Expand Down
24 changes: 24 additions & 0 deletions src/sdk/base/sdputils.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,30 @@ export function addLegacySimulcast(sdp, type, numStreams) {
return sdp;
}

export function setOpusParam(sdp, audioOptions) {
let maxAverageBitrateKB;
if(audioOptions.__proto__ === Array.prototype){
if(audioOptions[0].maxAverageBitrate !== undefined){
maxAverageBitrateKB = audioOptions[0].maxAverageBitrate*1000;
sdp = setCodecParam(
sdp, 'opus/48000', 'maxaveragebitrate', maxAverageBitrateKB);
}
if(audioOptions[0].stereo && audioOptions[0].stereo === true){
sdp = maybeSetOpusOptions(sdp, {
opusStereo: 'true'
});
}
}
else{
if(audioOptions.stereo && audioOptions.stereo === true){
sdp = maybeSetOpusOptions(sdp, {
opusStereo: 'true'
});
}
}
return sdp;
}

export function setMaxBitrate(sdp, encodingParametersList) {
for (const encodingParameters of encodingParametersList) {
if (encodingParameters.maxBitrate) {
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/conference/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,12 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
return sdp;
}
sdp = this._setMaxBitrate(sdp, options);
sdp = SdpUtils.setOpusParam(sdp, options.audio);
return sdp;
}

_setRtpReceiverOptions(sdp, options) {
sdp = SdpUtils.setOpusParam(sdp, options.audio);
// Add legacy simulcast in SDP for safari.
if (this._isRtpEncodingParameters(options.video) && Utils.isSafari()) {
if (options.video.length > 1) {
Expand Down