summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-03 04:32:09 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-03 04:32:09 +0000
commit71b1f1137f981ecb8e4770e281308cb8af0b2ab1 (patch)
treef599dac75f298ae826a447c4b63ff1fed45360b2 /media
parent7f5b3cc0e1dcb11b6e584fd349f889af90b1084e (diff)
downloadchromium_src-71b1f1137f981ecb8e4770e281308cb8af0b2ab1.zip
chromium_src-71b1f1137f981ecb8e4770e281308cb8af0b2ab1.tar.gz
chromium_src-71b1f1137f981ecb8e4770e281308cb8af0b2ab1.tar.bz2
Make VideoCaptureBufferPool agnostic to media::VideoFrame
VideoCaptureBufferPool should only be concerned with managing a pool of byte buffers; the details of constructing media::VideoFrames from the buffers should be marginalized and encapsulated. * VideoBufferPool now returns indices on the range of [0, count()), with -1 reserved as the failure index. * Logic surrounding the construction of media::VideoFrame from a base::SharedMemory object is moved to a utility function in VideoCaptureBufferPool; the main interface runs using buffer indices. BUG=chromium:221441 TEST=build, run on Linux desktop + content_unittests Change-Id: Id5f72b884476b4d5947b94a53f4ce520884837c9 Review URL: https://chromiumcodereview.appspot.com/16760002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/video_frame.cc7
-rw-r--r--media/base/video_frame.h8
2 files changed, 15 insertions, 0 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index db82649..de7440a 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -97,10 +97,12 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalYuvData(
int32 y_stride, int32 u_stride, int32 v_stride,
uint8* y_data, uint8* u_data, uint8* v_data,
base::TimeDelta timestamp,
+ base::SharedMemoryHandle shm_handle,
const base::Closure& no_longer_needed_cb) {
DCHECK(format == YV12 || format == YV16 || format == I420) << format;
scoped_refptr<VideoFrame> frame(new VideoFrame(
format, coded_size, visible_rect, natural_size, timestamp));
+ frame->shared_memory_handle_ = shm_handle;
frame->strides_[kYPlane] = y_stride;
frame->strides_[kUPlane] = u_stride;
frame->strides_[kVPlane] = v_stride;
@@ -268,6 +270,7 @@ VideoFrame::VideoFrame(VideoFrame::Format format,
visible_rect_(visible_rect),
natural_size_(natural_size),
texture_target_(0),
+ shared_memory_handle_(base::SharedMemory::NULLHandle()),
timestamp_(timestamp) {
memset(&strides_, 0, sizeof(strides_));
memset(&data_, 0, sizeof(data_));
@@ -351,6 +354,10 @@ uint32 VideoFrame::texture_target() const {
return texture_target_;
}
+base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
+ return shared_memory_handle_;
+}
+
bool VideoFrame::IsEndOfStream() const {
return format_ == VideoFrame::EMPTY;
}
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index bfde2ef..7f37f10c 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "base/md5.h"
+#include "base/shared_memory.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "media/base/buffers.h"
#include "ui/gfx/rect.h"
@@ -148,6 +149,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
uint8* u_data,
uint8* v_data,
base::TimeDelta timestamp,
+ base::SharedMemoryHandle shm_handle, // may be NULLHandle()
const base::Closure& no_longer_needed_cb);
// Creates a frame with format equals to VideoFrame::EMPTY, width, height,
@@ -198,6 +200,9 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Returns the texture target. Only valid for NATIVE_TEXTURE frames.
uint32 texture_target() const;
+ // Returns the shared-memory handle, if present
+ base::SharedMemoryHandle shared_memory_handle() const;
+
// Returns true if this VideoFrame represents the end of the stream.
bool IsEndOfStream() const;
@@ -255,6 +260,9 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
uint32 texture_target_;
ReadPixelsCB read_pixels_cb_;
+ // Shared memory handle, if this frame was allocated from shared memory.
+ base::SharedMemoryHandle shared_memory_handle_;
+
base::Closure no_longer_needed_cb_;
base::TimeDelta timestamp_;