disable audio gain processing and prefer H264
This commit is contained in:
1 parent
1fc8f0d469
commit
ee81c519a1
1 file changed
+23
-2
+23
-2
@@ -156,6 +156,26 @@ function preferOpus(pc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function preferH264(pc) {
|
||||||
|
const capabilities = globalThis.RTCRtpReceiver?.getCapabilities?.('video');
|
||||||
|
const codecs = capabilities?.codecs || [];
|
||||||
|
const rank = (codec) => {
|
||||||
|
const mime = codec.mimeType?.toLowerCase() || '';
|
||||||
|
if (mime === 'video/h264') return 0;
|
||||||
|
if (mime === 'video/vp8') return 1;
|
||||||
|
if (mime === 'video/vp9') return 2;
|
||||||
|
return 3;
|
||||||
|
};
|
||||||
|
const ordered = [...codecs].sort((a, b) => rank(a) - rank(b));
|
||||||
|
for (const transceiver of pc.getTransceivers()) {
|
||||||
|
if (transceiver.receiver?.track?.kind === 'video' || transceiver.sender?.track?.kind === 'video') {
|
||||||
|
try { transceiver.setCodecPreferences(ordered); } catch (err) {
|
||||||
|
captureRumIssue('Could not prefer H.264 video codec', 'WARNING', { error: err?.message || String(err) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function monitorPeerQuality(peer) {
|
function monitorPeerQuality(peer) {
|
||||||
if (peer.qualityTimer) clearInterval(peer.qualityTimer);
|
if (peer.qualityTimer) clearInterval(peer.qualityTimer);
|
||||||
peer.qualityTimer = setInterval(async () => {
|
peer.qualityTimer = setInterval(async () => {
|
||||||
@@ -265,8 +285,8 @@ function effectiveIce() {
|
|||||||
function microphoneConstraints(deviceId = localStorage.getItem(LS_AUDIO_INPUT)) {
|
function microphoneConstraints(deviceId = localStorage.getItem(LS_AUDIO_INPUT)) {
|
||||||
const audio = {
|
const audio = {
|
||||||
echoCancellation: true,
|
echoCancellation: true,
|
||||||
noiseSuppression: true,
|
noiseSuppression: false,
|
||||||
autoGainControl: true,
|
autoGainControl: false,
|
||||||
channelCount: 1,
|
channelCount: 1,
|
||||||
sampleRate: 48000,
|
sampleRate: 48000,
|
||||||
sampleSize: 16,
|
sampleSize: 16,
|
||||||
@@ -1029,6 +1049,7 @@ function addScreenToPeer(peer) {
|
|||||||
}
|
}
|
||||||
peerSenders.set(streamId, senders);
|
peerSenders.set(streamId, senders);
|
||||||
}
|
}
|
||||||
|
preferH264(peer.pc);
|
||||||
S.screenSenders.set(peer.id, peerSenders); // renegotiation fires automatically
|
S.screenSenders.set(peer.id, peerSenders); // renegotiation fires automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user