Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: webrtc/common_video/interface/video_frame_buffer.h

Issue 1304143003: VideoFrameBuffer: Make non-const data access explicit (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_video/i420_buffer_pool_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_video/interface/video_frame_buffer.h
diff --git a/webrtc/common_video/interface/video_frame_buffer.h b/webrtc/common_video/interface/video_frame_buffer.h
index a7ac8d84d708b7f22b62f38251c86cab6f795a2e..ed1df488c2c58f635cec0352cab3680ef443ff50 100644
--- a/webrtc/common_video/interface/video_frame_buffer.h
+++ b/webrtc/common_video/interface/video_frame_buffer.h
@@ -42,8 +42,9 @@ class VideoFrameBuffer : public rtc::RefCountInterface {
// the VideoFrameBuffer object and must not be freed by the caller.
virtual const uint8_t* data(PlaneType type) const = 0;
- // Non-const data access is only allowed if |HasOneRef| is true.
- virtual uint8_t* data(PlaneType type) = 0;
+ // Non-const data access is disallowed by default. You need to make sure you
+ // have exclusive access and a writable buffer before calling this function.
+ virtual uint8_t* MutableData(PlaneType type);
// Returns the number of bytes between successive rows for a given plane.
virtual int stride(PlaneType type) const = 0;
@@ -69,7 +70,9 @@ class I420Buffer : public VideoFrameBuffer {
int width() const override;
int height() const override;
const uint8_t* data(PlaneType type) const override;
- uint8_t* data(PlaneType type) override;
+ // Non-const data access is only allowed if HasOneRef() is true to protect
+ // against unexpected overwrites.
+ uint8_t* MutableData(PlaneType type) override;
int stride(PlaneType type) const override;
void* native_handle() const override;
rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
@@ -97,7 +100,6 @@ class NativeHandleBuffer : public VideoFrameBuffer {
int width() const override;
int height() const override;
const uint8_t* data(PlaneType type) const override;
- uint8_t* data(PlaneType type) override;
int stride(PlaneType type) const override;
void* native_handle() const override;
@@ -122,7 +124,6 @@ class WrappedI420Buffer : public webrtc::VideoFrameBuffer {
int height() const override;
const uint8_t* data(PlaneType type) const override;
- uint8_t* data(PlaneType type) override;
int stride(PlaneType type) const override;
void* native_handle() const override;
« no previous file with comments | « webrtc/common_video/i420_buffer_pool_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698