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

Side by Side Diff: content/renderer/media/video_capture_impl.cc

Issue 312803002: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ios build Created 6 years, 5 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 // Notes about usage of this object by VideoCaptureImplManager. 5 // Notes about usage of this object by VideoCaptureImplManager.
6 // 6 //
7 // VideoCaptureImplManager access this object by using a Unretained() 7 // VideoCaptureImplManager access this object by using a Unretained()
8 // binding and tasks on the IO thread. It is then important that 8 // binding and tasks on the IO thread. It is then important that
9 // VideoCaptureImpl never post task to itself. All operations must be 9 // VideoCaptureImpl never post task to itself. All operations must be
10 // synchronous. 10 // synchronous.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 void VideoCaptureImpl::OnBufferReceived(int buffer_id, 207 void VideoCaptureImpl::OnBufferReceived(int buffer_id,
208 const media::VideoCaptureFormat& format, 208 const media::VideoCaptureFormat& format,
209 base::TimeTicks timestamp) { 209 base::TimeTicks timestamp) {
210 DCHECK(thread_checker_.CalledOnValidThread()); 210 DCHECK(thread_checker_.CalledOnValidThread());
211 211
212 // The capture pipeline supports only I420 for now. 212 // The capture pipeline supports only I420 for now.
213 DCHECK_EQ(format.pixel_format, media::PIXEL_FORMAT_I420); 213 DCHECK_EQ(format.pixel_format, media::PIXEL_FORMAT_I420);
214 214
215 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 215 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
216 Send(new VideoCaptureHostMsg_BufferReady( 216 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
217 device_id_, buffer_id, std::vector<uint32>()));
218 return; 217 return;
219 } 218 }
220 219
221 last_frame_format_ = format; 220 last_frame_format_ = format;
222 if (first_frame_timestamp_.is_null()) 221 if (first_frame_timestamp_.is_null())
223 first_frame_timestamp_ = timestamp; 222 first_frame_timestamp_ = timestamp;
224 223
225 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc 224 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc
226 TRACE_EVENT_INSTANT2( 225 TRACE_EVENT_INSTANT2(
227 "cast_perf_test", "OnBufferReceived", 226 "cast_perf_test", "OnBufferReceived",
(...skipping 12 matching lines...) Expand all
240 last_frame_format_.frame_size, 239 last_frame_format_.frame_size,
241 reinterpret_cast<uint8*>(buffer->buffer->memory()), 240 reinterpret_cast<uint8*>(buffer->buffer->memory()),
242 buffer->buffer_size, 241 buffer->buffer_size,
243 buffer->buffer->handle(), 242 buffer->buffer->handle(),
244 timestamp - first_frame_timestamp_, 243 timestamp - first_frame_timestamp_,
245 media::BindToCurrentLoop( 244 media::BindToCurrentLoop(
246 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, 245 base::Bind(&VideoCaptureImpl::OnClientBufferFinished,
247 weak_factory_.GetWeakPtr(), 246 weak_factory_.GetWeakPtr(),
248 buffer_id, 247 buffer_id,
249 buffer, 248 buffer,
250 std::vector<uint32>()))); 249 0)));
251 250
252 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); 251 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
253 ++it) { 252 ++it) {
254 it->second.deliver_frame_cb.Run(frame, format, timestamp); 253 it->second.deliver_frame_cb.Run(frame, format, timestamp);
255 } 254 }
256 } 255 }
257 256
258 static void NullReadPixelsCB(const SkBitmap& bitmap) { NOTIMPLEMENTED(); } 257 static void NullReadPixelsCB(const SkBitmap& bitmap) { NOTIMPLEMENTED(); }
259 258
260 void VideoCaptureImpl::OnMailboxBufferReceived( 259 void VideoCaptureImpl::OnMailboxBufferReceived(
261 int buffer_id, 260 int buffer_id,
262 const gpu::MailboxHolder& mailbox_holder, 261 const gpu::MailboxHolder& mailbox_holder,
263 const media::VideoCaptureFormat& format, 262 const media::VideoCaptureFormat& format,
264 base::TimeTicks timestamp) { 263 base::TimeTicks timestamp) {
265 DCHECK(thread_checker_.CalledOnValidThread()); 264 DCHECK(thread_checker_.CalledOnValidThread());
266 265
267 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 266 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
268 Send(new VideoCaptureHostMsg_BufferReady( 267 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
269 device_id_, buffer_id, std::vector<uint32>()));
270 return; 268 return;
271 } 269 }
272 270
273 last_frame_format_ = format; 271 last_frame_format_ = format;
274 if (first_frame_timestamp_.is_null()) 272 if (first_frame_timestamp_.is_null())
275 first_frame_timestamp_ = timestamp; 273 first_frame_timestamp_ = timestamp;
276 274
277 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( 275 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture(
278 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), 276 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)),
279 media::BindToCurrentLoop( 277 media::BindToCurrentLoop(
280 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, 278 base::Bind(&VideoCaptureImpl::OnClientBufferFinished,
281 weak_factory_.GetWeakPtr(), 279 weak_factory_.GetWeakPtr(),
282 buffer_id, 280 buffer_id,
283 scoped_refptr<ClientBuffer>())), 281 scoped_refptr<ClientBuffer>())),
284 last_frame_format_.frame_size, 282 last_frame_format_.frame_size,
285 gfx::Rect(last_frame_format_.frame_size), 283 gfx::Rect(last_frame_format_.frame_size),
286 last_frame_format_.frame_size, 284 last_frame_format_.frame_size,
287 timestamp - first_frame_timestamp_, 285 timestamp - first_frame_timestamp_,
288 base::Bind(&NullReadPixelsCB)); 286 base::Bind(&NullReadPixelsCB));
289 287
290 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); 288 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
291 ++it) { 289 ++it) {
292 it->second.deliver_frame_cb.Run(frame, format, timestamp); 290 it->second.deliver_frame_cb.Run(frame, format, timestamp);
293 } 291 }
294 } 292 }
295 293
296 void VideoCaptureImpl::OnClientBufferFinished( 294 void VideoCaptureImpl::OnClientBufferFinished(
297 int buffer_id, 295 int buffer_id,
298 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, 296 const scoped_refptr<ClientBuffer>& /* ignored_buffer */,
299 const std::vector<uint32>& release_sync_points) { 297 uint32 release_sync_point) {
300 DCHECK(thread_checker_.CalledOnValidThread()); 298 DCHECK(thread_checker_.CalledOnValidThread());
301 Send(new VideoCaptureHostMsg_BufferReady( 299 Send(new VideoCaptureHostMsg_BufferReady(
302 device_id_, buffer_id, release_sync_points)); 300 device_id_, buffer_id, release_sync_point));
303 } 301 }
304 302
305 void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) { 303 void VideoCaptureImpl::OnStateChanged(VideoCaptureState state) {
306 DCHECK(thread_checker_.CalledOnValidThread()); 304 DCHECK(thread_checker_.CalledOnValidThread());
307 305
308 switch (state) { 306 switch (state) {
309 case VIDEO_CAPTURE_STATE_STARTED: 307 case VIDEO_CAPTURE_STATE_STARTED:
310 // Camera has started in the browser process. Since we have already 308 // Camera has started in the browser process. Since we have already
311 // told all clients that we have started there's nothing to do. 309 // told all clients that we have started there's nothing to do.
312 break; 310 break;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ClientInfoMap::iterator it = clients->find(client_id); 433 ClientInfoMap::iterator it = clients->find(client_id);
436 if (it != clients->end()) { 434 if (it != clients->end()) {
437 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); 435 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
438 clients->erase(it); 436 clients->erase(it);
439 found = true; 437 found = true;
440 } 438 }
441 return found; 439 return found;
442 } 440 }
443 441
444 } // namespace content 442 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.h ('k') | content/renderer/media/video_capture_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698