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

Side by Side Diff: content/browser/renderer_host/media/video_capture_buffer_pool.cc

Issue 22875047: EVEA cleanup: use video utility functions in media::* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: b2b1b2ee Last comments. Created 7 years, 3 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" 5 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 DCHECK(buffer->held_by_producer); 121 DCHECK(buffer->held_by_producer);
122 return buffer_id; 122 return buffer_id;
123 } 123 }
124 } 124 }
125 return -1; // Buffer is not from our pool. 125 return -1; // Buffer is not from our pool.
126 } 126 }
127 127
128 scoped_refptr<media::VideoFrame> VideoCaptureBufferPool::ReserveI420VideoFrame( 128 scoped_refptr<media::VideoFrame> VideoCaptureBufferPool::ReserveI420VideoFrame(
129 const gfx::Size& size, 129 const gfx::Size& size,
130 int rotation) { 130 int rotation) {
131 if (static_cast<size_t>(size.GetArea() * 3 / 2) != GetMemorySize()) 131 if (GetMemorySize() !=
132 media::VideoFrame::AllocationSize(media::VideoFrame::I420, size)) {
133 DCHECK_EQ(GetMemorySize(),
134 media::VideoFrame::AllocationSize(media::VideoFrame::I420, size));
132 return NULL; 135 return NULL;
136 }
133 137
134 base::AutoLock lock(lock_); 138 base::AutoLock lock(lock_);
135 139
136 int buffer_id = ReserveForProducerInternal(); 140 int buffer_id = ReserveForProducerInternal();
137 if (buffer_id < 0) 141 if (buffer_id < 0)
138 return NULL; 142 return NULL;
139 143
140 base::Closure disposal_handler = base::Bind( 144 base::Closure disposal_handler = base::Bind(
141 &VideoCaptureBufferPool::RelinquishProducerReservation, 145 &VideoCaptureBufferPool::RelinquishProducerReservation,
142 this, 146 this,
143 buffer_id); 147 buffer_id);
144 148
145 Buffer* buffer = buffers_[buffer_id]; 149 Buffer* buffer = buffers_[buffer_id];
146 // Wrap the buffer in a VideoFrame container. 150 // Wrap the buffer in a VideoFrame container.
147 scoped_refptr<media::VideoFrame> frame = 151 scoped_refptr<media::VideoFrame> frame =
148 media::VideoFrame::WrapExternalSharedMemory( 152 media::VideoFrame::WrapExternalSharedMemory(
149 media::VideoFrame::I420, 153 media::VideoFrame::I420,
150 size, 154 size,
151 gfx::Rect(size), 155 gfx::Rect(size),
152 size, 156 size,
153 static_cast<uint8*>(buffer->shared_memory.memory()), 157 static_cast<uint8*>(buffer->shared_memory.memory()),
158 GetMemorySize(),
154 buffer->shared_memory.handle(), 159 buffer->shared_memory.handle(),
155 base::TimeDelta(), 160 base::TimeDelta(),
156 disposal_handler); 161 disposal_handler);
157 162
158 if (buffer->rotation != rotation) { 163 if (buffer->rotation != rotation) {
159 // TODO(nick): Generalize the |rotation| mechanism. 164 // TODO(nick): Generalize the |rotation| mechanism.
160 media::FillYUV(frame.get(), 0, 128, 128); 165 media::FillYUV(frame.get(), 0, 128, 128);
161 buffer->rotation = rotation; 166 buffer->rotation = rotation;
162 } 167 }
163 168
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return buffer_id; 205 return buffer_id;
201 } 206 }
202 207
203 bool VideoCaptureBufferPool::IsAllocated() const { 208 bool VideoCaptureBufferPool::IsAllocated() const {
204 lock_.AssertAcquired(); 209 lock_.AssertAcquired();
205 return !buffers_.empty(); 210 return !buffers_.empty();
206 } 211 }
207 212
208 } // namespace content 213 } // namespace content
209 214
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698