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

Unified Diff: media/base/video_frame.h

Issue 877283004: MediaStreamRemoteVideoSource: Wrap cricket::VideoFrame instead of copying. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce |is_read_only_| to media::VideoFrame Created 5 years, 9 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
Index: media/base/video_frame.h
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index cebed0af11a47aea5537b92346d97cebae1ef05f..784ef9db06c293b4bfa93ec5248b09ee4609ef53 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -147,6 +147,22 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
base::TimeDelta timestamp,
const base::Closure& no_longer_needed_cb);
+ // Similar to the above function except with const pointers. The pointers will
+ // be protected with run-time checks.
+ static scoped_refptr<VideoFrame> WrapExternalYuvConstData(
+ Format format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ int32 y_stride,
+ int32 u_stride,
+ int32 v_stride,
+ const uint8* y_data,
+ const uint8* u_data,
+ const uint8* v_data,
+ base::TimeDelta timestamp,
+ const base::Closure& no_longer_needed_cb);
+
#if defined(OS_POSIX)
// Wraps provided dmabufs
// (https://www.kernel.org/doc/Documentation/dma-buf-sharing.txt) with a
@@ -269,6 +285,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Returns pointer to the buffer for a given plane. The memory is owned by
// VideoFrame object and must not be freed by the caller.
const uint8* data(size_t plane) const;
+ // Non-const data access is only allowed if |is_read_only_| is false.
uint8* data(size_t plane);
// Returns pointer to the data in the visible region of the frame. I.e. the
@@ -276,6 +293,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// visible_rect().origin(). Memory is owned by VideoFrame object and must not
// be freed by the caller.
const uint8* visible_data(size_t plane) const;
+ // Non-const data access is only allowed if |is_read_only_| is false.
uint8* visible_data(size_t plane);
// Returns the mailbox holder of the native texture wrapped by this frame.
@@ -382,6 +400,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Array of data pointers to each plane.
uint8* data_[kMaxPlanes];
+ bool is_read_only_;
mcasas 2015/03/06 17:29:59 Having a flag and |data_[]| separated might be an
magjed_chromium 2015/03/07 14:15:10 DCHECKing a read_only flag adds enough to find pla
// Native texture mailbox, if this is a NATIVE_TEXTURE frame.
const scoped_ptr<gpu::MailboxHolder> mailbox_holder_;

Powered by Google App Engine
This is Rietveld 408576698