maybe this fixes the poor audio idk loool
This commit is contained in:
@@ -23,7 +23,7 @@ socket.on('offer', (id, description) => {
|
||||
overlay.classList.add('hidden');
|
||||
};
|
||||
|
||||
// Auto-unmute when the user interacts with the document to bypass browser// Auto-unmute when the user interacts with the document to bypass browser
|
||||
// Auto-unmute when the user interacts with the document to bypass browser autoplay restrictions
|
||||
document.addEventListener('click', () => {
|
||||
remoteVideo.muted = false;
|
||||
// Set sink to max possible volume explicitly avoiding browser gain staging
|
||||
@@ -39,7 +39,30 @@ document.addEventListener('click', () => {
|
||||
peerConnection
|
||||
.setRemoteDescription(description)
|
||||
.then(() => peerConnection.createAnswer())
|
||||
.then(sdp => peerConnection.setLocalDescription(sdp))
|
||||
.then(sdp => {
|
||||
let sdpLines = sdp.sdp.split('\r\n');
|
||||
let opusPayloadType = null;
|
||||
for (let i = 0; i < sdpLines.length; i++) {
|
||||
if (sdpLines[i].includes('a=rtpmap:') && sdpLines[i].includes('opus/48000/2')) {
|
||||
const match = sdpLines[i].match(/a=rtpmap:(\d+) /);
|
||||
if (match) opusPayloadType = match[1];
|
||||
}
|
||||
}
|
||||
if (opusPayloadType) {
|
||||
let fmtpFound = false;
|
||||
for (let i = 0; i < sdpLines.length; i++) {
|
||||
if (sdpLines[i].startsWith(`a=fmtp:${opusPayloadType}`)) {
|
||||
sdpLines[i] = `a=fmtp:${opusPayloadType} minptime=10;useinbandfec=1;maxplaybackrate=48000;stereo=1;sprop-stereo=1;maxaveragebitrate=510000;cbr=1`;
|
||||
fmtpFound = true;
|
||||
}
|
||||
}
|
||||
if (!fmtpFound) {
|
||||
sdpLines.push(`a=fmtp:${opusPayloadType} minptime=10;useinbandfec=1;maxplaybackrate=48000;stereo=1;sprop-stereo=1;maxaveragebitrate=510000;cbr=1`);
|
||||
}
|
||||
}
|
||||
sdp.sdp = sdpLines.join('\r\n');
|
||||
return peerConnection.setLocalDescription(sdp);
|
||||
})
|
||||
.then(() => {
|
||||
socket.emit('answer', id, peerConnection.localDescription);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user