Chromium Code Reviews| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 if (client) { | 342 if (client) { |
| 345 client->session_closed = true; | 343 client->session_closed = true; |
| 346 client->event_handler->OnEnded(client->controller_id); | 344 client->event_handler->OnEnded(client->controller_id); |
| 347 } | 345 } |
| 348 } | 346 } |
| 349 | 347 |
| 350 void VideoCaptureController::ReturnBuffer( | 348 void VideoCaptureController::ReturnBuffer( |
| 351 VideoCaptureControllerID id, | 349 VideoCaptureControllerID id, |
| 352 VideoCaptureControllerEventHandler* event_handler, | 350 VideoCaptureControllerEventHandler* event_handler, |
| 353 int buffer_id, | 351 int buffer_id, |
| 354 const gpu::SyncToken& sync_token, | 352 const gpu::SyncToken& sync_token, |
|
mcasas
2016/10/07 00:56:16
We can also remove |sync_token| and associated
log
emircan
2016/10/07 17:40:12
As I noted earlier I am cleaning up IPC in CL#2, a
| |
| 355 double consumer_resource_utilization) { | 353 double consumer_resource_utilization) { |
| 356 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 354 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 357 | 355 |
| 358 ControllerClient* client = FindClient(id, event_handler, controller_clients_); | 356 ControllerClient* client = FindClient(id, event_handler, controller_clients_); |
| 359 | 357 |
| 360 // If this buffer is not held by this client, or this client doesn't exist | 358 // If this buffer is not held by this client, or this client doesn't exist |
| 361 // in controller, do nothing. | 359 // in controller, do nothing. |
| 362 ControllerClient::ActiveBufferMap::iterator iter; | 360 ControllerClient::ActiveBufferMap::iterator iter; |
| 363 if (!client || (iter = client->active_buffers.find(buffer_id)) == | 361 if (!client || (iter = client->active_buffers.find(buffer_id)) == |
| 364 client->active_buffers.end()) { | 362 client->active_buffers.end()) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 } | 506 } |
| 509 | 507 |
| 510 void VideoCaptureController::DoNewBufferOnIOThread( | 508 void VideoCaptureController::DoNewBufferOnIOThread( |
| 511 ControllerClient* client, | 509 ControllerClient* client, |
| 512 media::VideoCaptureDevice::Client::Buffer* buffer, | 510 media::VideoCaptureDevice::Client::Buffer* buffer, |
| 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: { |
|
chfremer
2016/10/06 16:45:00
I think it is okay to keep the switch, since we ar
emircan
2016/10/07 17:40:12
I am leaving cleaning up media::VideoFrame::STORAG
| |
| 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 |