Skip to content

Instantly share code, notes, and snippets.

@Sean-Der
Created May 28, 2022 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sean-Der/c3cfa5506ff3edac9486fd2d57ca89ab to your computer and use it in GitHub Desktop.
Save Sean-Der/c3cfa5506ff3edac9486fd2d57ca89ab to your computer and use it in GitHub Desktop.
Example of Preferring H264 as a Receiver in JS
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