| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 has_received_frames_(false), | 137 has_received_frames_(false), |
| 138 weak_ptr_factory_(this) { | 138 weak_ptr_factory_(this) { |
| 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 140 } | 140 } |
| 141 | 141 |
| 142 base::WeakPtr<VideoCaptureController> | 142 base::WeakPtr<VideoCaptureController> |
| 143 VideoCaptureController::GetWeakPtrForIOThread() { | 143 VideoCaptureController::GetWeakPtrForIOThread() { |
| 144 return weak_ptr_factory_.GetWeakPtr(); | 144 return weak_ptr_factory_.GetWeakPtr(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 std::unique_ptr<media::VideoCaptureDevice::Client> | 147 std::unique_ptr<device::VideoCaptureDevice::Client> |
| 148 VideoCaptureController::NewDeviceClient() { | 148 VideoCaptureController::NewDeviceClient() { |
| 149 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 149 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 150 return base::WrapUnique(new VideoCaptureDeviceClient( | 150 return base::WrapUnique(new VideoCaptureDeviceClient( |
| 151 this->GetWeakPtrForIOThread(), buffer_pool_)); | 151 this->GetWeakPtrForIOThread(), buffer_pool_)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void VideoCaptureController::AddClient( | 154 void VideoCaptureController::AddClient( |
| 155 VideoCaptureControllerID id, | 155 VideoCaptureControllerID id, |
| 156 VideoCaptureControllerEventHandler* event_handler, | 156 VideoCaptureControllerEventHandler* event_handler, |
| 157 base::ProcessHandle render_process, | 157 base::ProcessHandle render_process, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 348 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 349 return video_capture_format_; | 349 return video_capture_format_; |
| 350 } | 350 } |
| 351 | 351 |
| 352 VideoCaptureController::~VideoCaptureController() { | 352 VideoCaptureController::~VideoCaptureController() { |
| 353 STLDeleteContainerPointers(controller_clients_.begin(), | 353 STLDeleteContainerPointers(controller_clients_.begin(), |
| 354 controller_clients_.end()); | 354 controller_clients_.end()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( | 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( |
| 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 358 std::unique_ptr<device::VideoCaptureDevice::Client::Buffer> buffer, |
| 359 const scoped_refptr<VideoFrame>& frame) { | 359 const scoped_refptr<VideoFrame>& frame) { |
| 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 361 const int buffer_id = buffer->id(); | 361 const int buffer_id = buffer->id(); |
| 362 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); | 362 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); |
| 363 | 363 |
| 364 int count = 0; | 364 int count = 0; |
| 365 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 365 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 366 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 366 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
| 367 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 367 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
| 368 video_capture_format_.frame_rate); | 368 video_capture_format_.frame_rate); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 if (client->known_buffers.erase(buffer_id_to_drop)) { | 452 if (client->known_buffers.erase(buffer_id_to_drop)) { |
| 453 client->event_handler->OnBufferDestroyed(client->controller_id, | 453 client->event_handler->OnBufferDestroyed(client->controller_id, |
| 454 buffer_id_to_drop); | 454 buffer_id_to_drop); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| 459 void VideoCaptureController::DoNewBufferOnIOThread( | 459 void VideoCaptureController::DoNewBufferOnIOThread( |
| 460 ControllerClient* client, | 460 ControllerClient* client, |
| 461 media::VideoCaptureDevice::Client::Buffer* buffer, | 461 device::VideoCaptureDevice::Client::Buffer* buffer, |
| 462 const scoped_refptr<media::VideoFrame>& frame) { | 462 const scoped_refptr<media::VideoFrame>& frame) { |
| 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 464 const int buffer_id = buffer->id(); | 464 const int buffer_id = buffer->id(); |
| 465 | 465 |
| 466 switch (frame->storage_type()) { | 466 switch (frame->storage_type()) { |
| 467 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: { | 467 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: { |
| 468 std::vector<gfx::GpuMemoryBufferHandle> handles; | 468 std::vector<gfx::GpuMemoryBufferHandle> handles; |
| 469 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format()); | 469 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format()); |
| 470 for (size_t i = 0; i < num_planes; ++i) { | 470 for (size_t i = 0; i < num_planes; ++i) { |
| 471 gfx::GpuMemoryBufferHandle remote_handle; | 471 gfx::GpuMemoryBufferHandle remote_handle; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 int session_id, | 507 int session_id, |
| 508 const ControllerClients& clients) { | 508 const ControllerClients& clients) { |
| 509 for (auto* client : clients) { | 509 for (auto* client : clients) { |
| 510 if (client->session_id == session_id) | 510 if (client->session_id == session_id) |
| 511 return client; | 511 return client; |
| 512 } | 512 } |
| 513 return NULL; | 513 return NULL; |
| 514 } | 514 } |
| 515 | 515 |
| 516 } // namespace content | 516 } // namespace content |
| OLD | NEW |