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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const gfx::Size& natural_size, 140 const gfx::Size& natural_size,
141 int32 y_stride, 141 int32 y_stride,
142 int32 u_stride, 142 int32 u_stride,
143 int32 v_stride, 143 int32 v_stride,
144 uint8* y_data, 144 uint8* y_data,
145 uint8* u_data, 145 uint8* u_data,
146 uint8* v_data, 146 uint8* v_data,
147 base::TimeDelta timestamp, 147 base::TimeDelta timestamp,
148 const base::Closure& no_longer_needed_cb); 148 const base::Closure& no_longer_needed_cb);
149 149
150 // Similar to the above function except with const pointers. The pointers will
151 // be protected with run-time checks.
152 static scoped_refptr<VideoFrame> WrapExternalYuvConstData(
153 Format format,
154 const gfx::Size& coded_size,
155 const gfx::Rect& visible_rect,
156 const gfx::Size& natural_size,
157 int32 y_stride,
158 int32 u_stride,
159 int32 v_stride,
160 const uint8* y_data,
161 const uint8* u_data,
162 const uint8* v_data,
163 base::TimeDelta timestamp,
164 const base::Closure& no_longer_needed_cb);
165
150 #if defined(OS_POSIX) 166 #if defined(OS_POSIX)
151 // Wraps provided dmabufs 167 // Wraps provided dmabufs
152 // (https://www.kernel.org/doc/Documentation/dma-buf-sharing.txt) with a 168 // (https://www.kernel.org/doc/Documentation/dma-buf-sharing.txt) with a
153 // VideoFrame. The dmabuf fds are dup()ed on creation, so that the VideoFrame 169 // VideoFrame. The dmabuf fds are dup()ed on creation, so that the VideoFrame
154 // retains a reference to them, and are automatically close()d on destruction, 170 // retains a reference to them, and are automatically close()d on destruction,
155 // dropping the reference. The caller may safely close() its reference after 171 // dropping the reference. The caller may safely close() its reference after
156 // calling WrapExternalDmabufs(). 172 // calling WrapExternalDmabufs().
157 // The image data is only accessible via dmabuf fds, which are usually passed 173 // The image data is only accessible via dmabuf fds, which are usually passed
158 // directly to a hardware device and/or to another process, or can also be 174 // directly to a hardware device and/or to another process, or can also be
159 // mapped via mmap() for CPU access. 175 // mapped via mmap() for CPU access.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // Returns the number of bytes per row and number of rows for a given plane. 278 // Returns the number of bytes per row and number of rows for a given plane.
263 // 279 //
264 // As opposed to stride(), row_bytes() refers to the bytes representing 280 // As opposed to stride(), row_bytes() refers to the bytes representing
265 // frame data scanlines (coded_size.width() pixels, without stride padding). 281 // frame data scanlines (coded_size.width() pixels, without stride padding).
266 int row_bytes(size_t plane) const; 282 int row_bytes(size_t plane) const;
267 int rows(size_t plane) const; 283 int rows(size_t plane) const;
268 284
269 // Returns pointer to the buffer for a given plane. The memory is owned by 285 // Returns pointer to the buffer for a given plane. The memory is owned by
270 // VideoFrame object and must not be freed by the caller. 286 // VideoFrame object and must not be freed by the caller.
271 const uint8* data(size_t plane) const; 287 const uint8* data(size_t plane) const;
288 // Non-const data access is only allowed if |is_read_only_| is false.
272 uint8* data(size_t plane); 289 uint8* data(size_t plane);
273 290
274 // Returns pointer to the data in the visible region of the frame. I.e. the 291 // Returns pointer to the data in the visible region of the frame. I.e. the
275 // returned pointer is offsetted into the plane buffer specified by 292 // returned pointer is offsetted into the plane buffer specified by
276 // visible_rect().origin(). Memory is owned by VideoFrame object and must not 293 // visible_rect().origin(). Memory is owned by VideoFrame object and must not
277 // be freed by the caller. 294 // be freed by the caller.
278 const uint8* visible_data(size_t plane) const; 295 const uint8* visible_data(size_t plane) const;
296 // Non-const data access is only allowed if |is_read_only_| is false.
279 uint8* visible_data(size_t plane); 297 uint8* visible_data(size_t plane);
280 298
281 // Returns the mailbox holder of the native texture wrapped by this frame. 299 // Returns the mailbox holder of the native texture wrapped by this frame.
282 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the 300 // Only valid to call if this is a NATIVE_TEXTURE frame. Before using the
283 // mailbox, the caller must wait for the included sync point. 301 // mailbox, the caller must wait for the included sync point.
284 const gpu::MailboxHolder* mailbox_holder() const; 302 const gpu::MailboxHolder* mailbox_holder() const;
285 303
286 // Returns the shared-memory handle, if present 304 // Returns the shared-memory handle, if present
287 base::SharedMemoryHandle shared_memory_handle() const; 305 base::SharedMemoryHandle shared_memory_handle() const;
288 306
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // (|visible_rect_.size()|) with aspect ratio taken into account. 393 // (|visible_rect_.size()|) with aspect ratio taken into account.
376 const gfx::Size natural_size_; 394 const gfx::Size natural_size_;
377 395
378 // Array of strides for each plane, typically greater or equal to the width 396 // Array of strides for each plane, typically greater or equal to the width
379 // of the surface divided by the horizontal sampling period. Note that 397 // of the surface divided by the horizontal sampling period. Note that
380 // strides can be negative. 398 // strides can be negative.
381 int32 strides_[kMaxPlanes]; 399 int32 strides_[kMaxPlanes];
382 400
383 // Array of data pointers to each plane. 401 // Array of data pointers to each plane.
384 uint8* data_[kMaxPlanes]; 402 uint8* data_[kMaxPlanes];
403 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
385 404
386 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. 405 // Native texture mailbox, if this is a NATIVE_TEXTURE frame.
387 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_; 406 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_;
388 ReleaseMailboxCB mailbox_holder_release_cb_; 407 ReleaseMailboxCB mailbox_holder_release_cb_;
389 408
390 // Shared memory handle, if this frame was allocated from shared memory. 409 // Shared memory handle, if this frame was allocated from shared memory.
391 base::SharedMemoryHandle shared_memory_handle_; 410 base::SharedMemoryHandle shared_memory_handle_;
392 411
393 // Offset in shared memory buffer. 412 // Offset in shared memory buffer.
394 size_t shared_memory_offset_; 413 size_t shared_memory_offset_;
(...skipping 21 matching lines...) Expand all
416 VideoFrameMetadata metadata_; 435 VideoFrameMetadata metadata_;
417 436
418 bool allow_overlay_; 437 bool allow_overlay_;
419 438
420 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 439 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
421 }; 440 };
422 441
423 } // namespace media 442 } // namespace media
424 443
425 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 444 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698