RESOLVED FIXED 215567
calling transceiver setCodecPreferences doesn't change the order of codecs in the offer/answer generated by the browser
https://bugs.webkit.org/show_bug.cgi?id=215567
Summary calling transceiver setCodecPreferences doesn't change the order of codecs in...
Jaya
Reported 2020-08-17 07:15:07 PDT
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);
Attachments
Patch (6.75 KB, patch)
2020-09-02 04:00 PDT, youenn fablet
no flags
Patch (10.66 KB, patch)
2020-09-02 05:30 PDT, youenn fablet
no flags
Radar WebKit Bug Importer
Comment 1 2020-08-17 16:03:24 PDT
youenn fablet
Comment 2 2020-09-02 04:00:17 PDT
youenn fablet
Comment 3 2020-09-02 05:30:59 PDT
EWS Watchlist
Comment 4 2020-09-02 05:31:43 PDT
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
youenn fablet
Comment 5 2020-09-02 05:31:55 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/25360
EWS
Comment 6 2020-09-03 01:38:55 PDT
Committed r266508: <https://trac.webkit.org/changeset/266508> All reviewed patches have been landed. Closing bug and clearing flags on attachment 407758 [details].
Darin Adler
Comment 7 2020-09-03 10:28:53 PDT
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.
Darin Adler
Comment 8 2020-09-03 10:32:35 PDT
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()));
Note You need to log in before you can comment on or make changes to this bug.