Created
May 28, 2022 18:26
-
-
Save Sean-Der/c3cfa5506ff3edac9486fd2d57ca89ab to your computer and use it in GitHub Desktop.
Example of Preferring H264 as a Receiver in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const H264Codecs = RTCRtpReceiver.getCapabilities('video').codecs.sort((a, b) => { | |
if (a.mimeType.includes('H264') && b.mimeType.includes('H264')) { | |
return 0 | |
} else if (a.mimeType.includes('H264')) { | |
return -1 | |
} else { | |
return 1 | |
} | |
}) | |
peerConnection.getTransceivers().forEach(transceiver => { | |
if (transceiver.sender.track.kind === 'video') { | |
transceiver.setCodecPreferences(H264Codecs) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment