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

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

Issue 101843005: Convert video capture pipline to base::TimeTicks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 9890509b Rebase, Windows compile fixes Created 6 years, 11 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 | Annotate | Revision Log
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 #include "content/browser/renderer_host/media/video_capture_controller.h" 5 #include "content/browser/renderer_host/media/video_capture_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const base::WeakPtr<VideoCaptureController>& controller, 105 const base::WeakPtr<VideoCaptureController>& controller,
106 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool); 106 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool);
107 virtual ~VideoCaptureDeviceClient(); 107 virtual ~VideoCaptureDeviceClient();
108 108
109 // VideoCaptureDevice::Client implementation. 109 // VideoCaptureDevice::Client implementation.
110 virtual scoped_refptr<Buffer> ReserveOutputBuffer( 110 virtual scoped_refptr<Buffer> ReserveOutputBuffer(
111 media::VideoFrame::Format format, 111 media::VideoFrame::Format format,
112 const gfx::Size& size) OVERRIDE; 112 const gfx::Size& size) OVERRIDE;
113 virtual void OnIncomingCapturedFrame(const uint8* data, 113 virtual void OnIncomingCapturedFrame(const uint8* data,
114 int length, 114 int length,
115 base::Time timestamp, 115 base::TimeTicks timestamp,
116 int rotation, 116 int rotation,
117 const VideoCaptureFormat& frame_format) 117 const VideoCaptureFormat& frame_format)
118 OVERRIDE; 118 OVERRIDE;
119 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer, 119 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer,
120 media::VideoFrame::Format format, 120 media::VideoFrame::Format format,
121 const gfx::Size& dimensions, 121 const gfx::Size& dimensions,
122 base::Time timestamp, 122 base::TimeTicks timestamp,
123 int frame_rate) OVERRIDE; 123 int frame_rate) OVERRIDE;
124 virtual void OnError() OVERRIDE; 124 virtual void OnError() OVERRIDE;
125 125
126 private: 126 private:
127 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, 127 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format,
128 const gfx::Size& dimensions); 128 const gfx::Size& dimensions);
129 129
130 // The controller to which we post events. 130 // The controller to which we post events.
131 const base::WeakPtr<VideoCaptureController> controller_; 131 const base::WeakPtr<VideoCaptureController> controller_;
132 132
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> 260 scoped_refptr<media::VideoCaptureDevice::Client::Buffer>
261 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( 261 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer(
262 media::VideoFrame::Format format, 262 media::VideoFrame::Format format,
263 const gfx::Size& size) { 263 const gfx::Size& size) {
264 return DoReserveOutputBuffer(format, size); 264 return DoReserveOutputBuffer(format, size);
265 } 265 }
266 266
267 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( 267 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame(
268 const uint8* data, 268 const uint8* data,
269 int length, 269 int length,
270 base::Time timestamp, 270 base::TimeTicks timestamp,
271 int rotation, 271 int rotation,
272 const VideoCaptureFormat& frame_format) { 272 const VideoCaptureFormat& frame_format) {
273 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedFrame"); 273 TRACE_EVENT0("video", "VideoCaptureController::OnIncomingCapturedFrame");
274 274
275 if (!frame_format.IsValid()) 275 if (!frame_format.IsValid())
276 return; 276 return;
277 277
278 // Chopped pixels in width/height in case video capture device has odd 278 // Chopped pixels in width/height in case video capture device has odd
279 // numbers for width/height. 279 // numbers for width/height.
280 int chopped_width = 0; 280 int chopped_width = 0;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 buffer, 403 buffer,
404 dimensions, 404 dimensions,
405 frame_format.frame_rate, 405 frame_format.frame_rate,
406 timestamp)); 406 timestamp));
407 } 407 }
408 408
409 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedBuffer( 409 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedBuffer(
410 const scoped_refptr<Buffer>& buffer, 410 const scoped_refptr<Buffer>& buffer,
411 media::VideoFrame::Format format, 411 media::VideoFrame::Format format,
412 const gfx::Size& dimensions, 412 const gfx::Size& dimensions,
413 base::Time timestamp, 413 base::TimeTicks timestamp,
414 int frame_rate) { 414 int frame_rate) {
415 // The capture pipeline expects I420 for now. 415 // The capture pipeline expects I420 for now.
416 DCHECK_EQ(format, media::VideoFrame::I420) 416 DCHECK_EQ(format, media::VideoFrame::I420)
417 << "Non-I420 output buffer returned"; 417 << "Non-I420 output buffer returned";
418 418
419 BrowserThread::PostTask( 419 BrowserThread::PostTask(
420 BrowserThread::IO, 420 BrowserThread::IO,
421 FROM_HERE, 421 FROM_HERE,
422 base::Bind( 422 base::Bind(
423 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread, 423 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 VideoCaptureController::~VideoCaptureController() { 470 VideoCaptureController::~VideoCaptureController() {
471 STLDeleteContainerPointers(controller_clients_.begin(), 471 STLDeleteContainerPointers(controller_clients_.begin(),
472 controller_clients_.end()); 472 controller_clients_.end());
473 } 473 }
474 474
475 void VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread( 475 void VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread(
476 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, 476 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer,
477 const gfx::Size& dimensions, 477 const gfx::Size& dimensions,
478 int frame_rate, 478 int frame_rate,
479 base::Time timestamp) { 479 base::TimeTicks timestamp) {
480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
481 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId); 481 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId);
482 482
483 VideoCaptureFormat frame_format( 483 VideoCaptureFormat frame_format(
484 dimensions, frame_rate, media::PIXEL_FORMAT_I420); 484 dimensions, frame_rate, media::PIXEL_FORMAT_I420);
485 485
486 int count = 0; 486 int count = 0;
487 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { 487 if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
488 for (ControllerClients::iterator client_it = controller_clients_.begin(); 488 for (ControllerClients::iterator client_it = controller_clients_.begin();
489 client_it != controller_clients_.end(); ++client_it) { 489 client_it != controller_clients_.end(); ++client_it) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 } 570 }
571 return NULL; 571 return NULL;
572 } 572 }
573 573
574 int VideoCaptureController::GetClientCount() { 574 int VideoCaptureController::GetClientCount() {
575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
576 return controller_clients_.size(); 576 return controller_clients_.size();
577 } 577 }
578 578
579 } // namespace content 579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698