| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 212 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 213 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id | 213 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id |
| 214 << ", session_id=" << session_id | 214 << ", session_id=" << session_id |
| 215 << ", params.requested_format=" | 215 << ", params.requested_format=" |
| 216 << media::VideoCaptureFormat::ToString(params.requested_format); | 216 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 217 | 217 |
| 218 // Check that requested VideoCaptureParams are valid and supported. If not, | 218 // Check that requested VideoCaptureParams are valid and supported. If not, |
| 219 // report an error immediately and punt. | 219 // report an error immediately and punt. |
| 220 if (!params.IsValid() || | 220 if (!params.IsValid() || |
| 221 params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 || | 221 params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 || |
| 222 (params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU && | 222 params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU) { |
| 223 params.requested_format.pixel_storage != | |
| 224 media::PIXEL_STORAGE_GPUMEMORYBUFFER)) { | |
| 225 // Crash in debug builds since the renderer should not have asked for | 223 // Crash in debug builds since the renderer should not have asked for |
| 226 // invalid or unsupported parameters. | 224 // invalid or unsupported parameters. |
| 227 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " | 225 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " |
| 228 << media::VideoCaptureFormat::ToString(params.requested_format); | 226 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 229 event_handler->OnError(id); | 227 event_handler->OnError(id); |
| 230 return; | 228 return; |
| 231 } | 229 } |
| 232 | 230 |
| 233 // If this is the first client added to the controller, cache the parameters. | 231 // If this is the first client added to the controller, cache the parameters. |
| 234 if (controller_clients_.empty()) | 232 if (controller_clients_.empty()) |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 const scoped_refptr<media::VideoFrame>& frame) { | 511 const scoped_refptr<media::VideoFrame>& frame) { |
| 514 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 512 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 515 const int buffer_id = buffer->id(); | 513 const int buffer_id = buffer->id(); |
| 516 | 514 |
| 517 switch (frame->storage_type()) { | 515 switch (frame->storage_type()) { |
| 518 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: { | 516 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: { |
| 519 std::vector<gfx::GpuMemoryBufferHandle> handles; | 517 std::vector<gfx::GpuMemoryBufferHandle> handles; |
| 520 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format()); | 518 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format()); |
| 521 for (size_t i = 0; i < num_planes; ++i) { | 519 for (size_t i = 0; i < num_planes; ++i) { |
| 522 gfx::GpuMemoryBufferHandle remote_handle; | 520 gfx::GpuMemoryBufferHandle remote_handle; |
| 523 buffer_pool_->ShareToProcess2( | |
| 524 buffer_id, i, client->render_process_handle, &remote_handle); | |
| 525 handles.push_back(remote_handle); | 521 handles.push_back(remote_handle); |
| 526 } | 522 } |
| 527 client->event_handler->OnBufferCreated2(client->controller_id, handles, | 523 client->event_handler->OnBufferCreated2(client->controller_id, handles, |
| 528 buffer->dimensions(), buffer_id); | 524 buffer->dimensions(), buffer_id); |
| 529 break; | 525 break; |
| 530 } | 526 } |
| 531 case media::VideoFrame::STORAGE_SHMEM: { | 527 case media::VideoFrame::STORAGE_SHMEM: { |
| 532 base::SharedMemoryHandle remote_handle; | 528 base::SharedMemoryHandle remote_handle; |
| 533 buffer_pool_->ShareToProcess(buffer_id, client->render_process_handle, | 529 buffer_pool_->ShareToProcess(buffer_id, client->render_process_handle, |
| 534 &remote_handle); | 530 &remote_handle); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 558 int session_id, | 554 int session_id, |
| 559 const ControllerClients& clients) { | 555 const ControllerClients& clients) { |
| 560 for (const auto& client : clients) { | 556 for (const auto& client : clients) { |
| 561 if (client->session_id == session_id) | 557 if (client->session_id == session_id) |
| 562 return client.get(); | 558 return client.get(); |
| 563 } | 559 } |
| 564 return nullptr; | 560 return nullptr; |
| 565 } | 561 } |
| 566 | 562 |
| 567 } // namespace content | 563 } // namespace content |
| OLD | NEW |