fix(screen-share): use sender capabilities for codec preference

setCodecPreferences requires codecs from RTCRtpSender.getCapabilities;
feeding it RTCRtpReceiver.getCapabilities throws InvalidModificationError
in Chrome and the swallowed exception left VP8 as the negotiated codec.
Switch the capability source so H264/AV1 preferences actually apply.
This commit is contained in:
LainHE committed 2026-10-10 18:02:36 +08:00
1 parent 1c328995aa
commit 20bde72c8b
1 file changed
+1 -1
+1 -1
View File
@@ -415,7 +415,7 @@ export function createScreenShareController(transport: ScreenShareTransport) {
function preferScreenShareCodecs(peer: RTCPeerConnection): void {
const transceiver = peer.getTransceivers().find((candidate) => candidate.sender.track?.kind === "video" || candidate.receiver.track?.kind === "video");
const capabilities = typeof RTCRtpReceiver !== "undefined" ? RTCRtpReceiver.getCapabilities?.("video") : null;
const capabilities = typeof RTCRtpSender !== "undefined" ? RTCRtpSender.getCapabilities?.("video") : null;
if (!transceiver?.setCodecPreferences || !capabilities?.codecs?.length) return;
// Prefer H.264/AV1 for screen content: both compress text/UI far better
// than VP8 at the bitrates typical of relayed screen shares. VP8 stays as