On STP 111, I am trying to change the default order of codecs in the offer/answer SDP by calling setCodecPreferences on the video transceiver. It doesn't seem to have any effect on the order of the codecs in the subsequent offer/answer generated by the browser. setCodecPreferences is working on Chrome 85 in Unified plan. Steps to reproduce: Modify https://webrtc.github.io/samples/src/content/peerconnection/pc1/ to include the following line before calling offer on pc1. //localStream.getTracks().forEach(track => pc1.addT(track, localStream)); const audio = pc1.addTransceiver('audio', localStream.getAudioTracks()[0]); const video = pc1.addTransceiver('video', localStream.getVideoTracks()[0]); const capabilities = RTCRtpSender.getCapabilities('video').codecs; capabilities.forEach((codec, idx) => { if (codec.mimeType === 'video/VP8') { capabilities.splice(idx, 1); capabilities.unshift(codec); } }); video.setCodecPreferences(capabilities);
<rdar://problem/67277554>
Created attachment 407754 [details] Patch
Created attachment 407758 [details] Patch
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/25360
Committed r266508: <https://trac.webkit.org/changeset/266508> All reviewed patches have been landed. Closing bug and clearing flags on attachment 407758 [details].
Comment on attachment 407758 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=407758&action=review > Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:413 > + if (hasParameter) > + sdpFmtpLine.append(";"); > + else > + hasParameter = true; > + sdpFmtpLine.append(StringView(parameter.first.data(), parameter.first.length())); > + sdpFmtpLine.append("="); > + sdpFmtpLine.append(StringView(parameter.second.data(), parameter.second.length())); Here’s a more efficient way to do this: const char* separator = hasParameter ? ";" : ""; hasParameter = true; sdpFmtpLine.append(separator, StringView(parameter.first.data(), parameter.first.length()), '=', StringView(parameter.second.data(), parameter.second.length())); A single call to append is more efficient than four separate calls to append.
Or if you prefer, like this: sdpFmtpLine.append(hasParameter ? ";" : "", StringView(parameter.first.data(), parameter.first.length()), '=', StringView(parameter.second.data(), parameter.second.length())); hasParameter = true; Or even this: sdpFmtpLine.append(std::exchange(hasParameter, true) ? ";" : "", StringView(parameter.first.data(), parameter.first.length()), '=', StringView(parameter.second.data(), parameter.second.length()));