| OLD | NEW |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 int length, | 114 int length, |
| 115 base::TimeTicks 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::TimeTicks timestamp, | 122 base::TimeTicks timestamp, |
| 123 int frame_rate) OVERRIDE; | 123 int frame_rate) OVERRIDE; |
| 124 virtual void OnError() OVERRIDE; | 124 virtual void OnError(const std::string& reason) 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 |
| 133 // The pool of shared-memory buffers used for capturing. | 133 // The pool of shared-memory buffers used for capturing. |
| 134 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 134 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 FROM_HERE, | 421 FROM_HERE, |
| 422 base::Bind( | 422 base::Bind( |
| 423 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread, | 423 &VideoCaptureController::DoIncomingCapturedI420BufferOnIOThread, |
| 424 controller_, | 424 controller_, |
| 425 buffer, | 425 buffer, |
| 426 dimensions, | 426 dimensions, |
| 427 frame_rate, | 427 frame_rate, |
| 428 timestamp)); | 428 timestamp)); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void VideoCaptureController::VideoCaptureDeviceClient::OnError() { | 431 void VideoCaptureController::VideoCaptureDeviceClient::OnError( |
| 432 const std::string& reason) { |
| 433 MediaStreamManager::SendMessageToNativeLog( |
| 434 "Error on video capture: " + reason); |
| 432 BrowserThread::PostTask(BrowserThread::IO, | 435 BrowserThread::PostTask(BrowserThread::IO, |
| 433 FROM_HERE, | 436 FROM_HERE, |
| 434 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 437 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
| 435 } | 438 } |
| 436 | 439 |
| 437 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> | 440 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> |
| 438 VideoCaptureController::VideoCaptureDeviceClient::DoReserveOutputBuffer( | 441 VideoCaptureController::VideoCaptureDeviceClient::DoReserveOutputBuffer( |
| 439 media::VideoFrame::Format format, | 442 media::VideoFrame::Format format, |
| 440 const gfx::Size& dimensions) { | 443 const gfx::Size& dimensions) { |
| 441 // The capture pipeline expects I420 for now. | 444 // The capture pipeline expects I420 for now. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 573 } |
| 571 return NULL; | 574 return NULL; |
| 572 } | 575 } |
| 573 | 576 |
| 574 int VideoCaptureController::GetClientCount() { | 577 int VideoCaptureController::GetClientCount() { |
| 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 578 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 576 return controller_clients_.size(); | 579 return controller_clients_.size(); |
| 577 } | 580 } |
| 578 | 581 |
| 579 } // namespace content | 582 } // namespace content |
| OLD | NEW |