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

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

Issue 2398813002: Cleanup of video capture into GpuMemoryBuffer (Closed)
Patch Set: Rebase Created 4 years, 2 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
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 <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
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
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
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
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_buffer_tracker_factory_impl.cc ('k') | media/base/media_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698