commit 9fd746606b4dd7bbde2203fdee339727d9f133aa parent b1283b86c642a9cfbf0bd4f50f23b326ca786645 Author: Dan Baker <dbaker@mozilla.com> Date: Thu, 23 Oct 2025 17:21:37 -0600 Bug 1995393 - Vendor libwebrtc from 234b25c51d Upstream commit: https://webrtc.googlesource.com/src/+/234b25c51d81f4d207963c118686c70ee6d66e77 Discourage use of non-const EncodedImageBufferInterface::data Update webrtc to work when such non-const accessor is absent, Remove override of it in WebRTC classes, add a default implementation so that downstream code can stop overriding it too. Bug: webrtc:42234570 Change-Id: Iced9fca652f0385742cc4ee9310db78cf55aca71 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/404020 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45377} Diffstat:
6 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T23:19:06.241495+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T23:21:24.737541+00:00. # base of lastest vendoring -23a70510ae +234b25c51d diff --git a/third_party/libwebrtc/api/video/encoded_image.h b/third_party/libwebrtc/api/video/encoded_image.h @@ -43,9 +43,13 @@ class EncodedImageBufferInterface : public RefCountInterface { using value_type = uint8_t; virtual const uint8_t* data() const = 0; - // TODO(bugs.webrtc.org/9378): Make interface essentially read-only, delete - // this non-const data method. - virtual uint8_t* data() = 0; + // TODO: bugs.webrtc.org/42234570 - Make interface essentially read-only, + // delete this non-const data method when an implementation in chromium is + // updated not to override it. + virtual uint8_t* data() { + return const_cast<uint8_t*>( + static_cast<const EncodedImageBufferInterface*>(this)->data()); + } virtual size_t size() const = 0; const uint8_t* begin() const { return data(); } diff --git a/third_party/libwebrtc/api/video/rtp_video_frame_assembler_unittests.cc b/third_party/libwebrtc/api/video/rtp_video_frame_assembler_unittests.cc @@ -139,8 +139,8 @@ ArrayView<int64_t> References(const std::unique_ptr<EncodedFrame>& frame) { return MakeArrayView(frame->references, frame->num_references); } -ArrayView<uint8_t> Payload(const std::unique_ptr<EncodedFrame>& frame) { - return ArrayView<uint8_t>(*frame->GetEncodedData()); +ArrayView<const uint8_t> Payload(const std::unique_ptr<EncodedFrame>& frame) { + return *frame->GetEncodedData(); } TEST(RtpVideoFrameAssembler, Vp8Packetization) { diff --git a/third_party/libwebrtc/api/video/rtp_video_frame_h265_assembler_unittests.cc b/third_party/libwebrtc/api/video/rtp_video_frame_h265_assembler_unittests.cc @@ -107,8 +107,8 @@ ArrayView<int64_t> References(const std::unique_ptr<EncodedFrame>& frame) { return MakeArrayView(frame->references, frame->num_references); } -ArrayView<uint8_t> Payload(const std::unique_ptr<EncodedFrame>& frame) { - return ArrayView<uint8_t>(*frame->GetEncodedData()); +ArrayView<const uint8_t> Payload(const std::unique_ptr<EncodedFrame>& frame) { + return *frame->GetEncodedData(); } TEST(RtpVideoFrameH265Assembler, H265Packetization) { diff --git a/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm b/third_party/libwebrtc/sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm @@ -25,10 +25,6 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { const uint8_t *data() const override { return static_cast<const uint8_t *>(data_.bytes); } - // TODO(bugs.webrtc.org/9378): delete this non-const data method. - uint8_t *data() override { - return const_cast<uint8_t *>(static_cast<const uint8_t *>(data_.bytes)); - } size_t size() const override { return data_.length; } protected: @@ -85,9 +81,15 @@ class ObjCEncodedImageBuffer : public webrtc::EncodedImageBufferInterface { // long self.buffer references its underlying data. self.encodedData = encodedImage.GetEncodedData(); // Wrap the buffer in NSData without copying, do not take ownership. - self.buffer = [NSData dataWithBytesNoCopy:self.encodedData->data() - length:encodedImage.size() - freeWhenDone:NO]; + // `NSData` provides interface that allows to write into the buffer, + // `EncodedImageBufferInterface` gives read-only access to the buffer. + // As of now write part of ths NSData interface are not used when accessing + // `buffer`, however it might be safer to refactor RTCEncodedImage not + // to expose buffer as NSData, and then remove this unsafe const_cast. + self.buffer = [NSData + dataWithBytesNoCopy:const_cast<uint8_t *>(self.encodedData->data()) + length:encodedImage.size() + freeWhenDone:NO]; self.encodedWidth = webrtc::dchecked_cast<int32_t>(encodedImage._encodedWidth); self.encodedHeight = diff --git a/third_party/libwebrtc/video/frame_encode_metadata_writer.cc b/third_party/libwebrtc/video/frame_encode_metadata_writer.cc @@ -51,7 +51,6 @@ class EncodedImageBufferWrapper : public EncodedImageBufferInterface { : buffer_(std::move(buffer)) {} const uint8_t* data() const override { return buffer_.data(); } - uint8_t* data() override { return buffer_.data(); } size_t size() const override { return buffer_.size(); } private: