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

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

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests: cc, skcanvas_video_renderer, wrtcrecorder... Fake capture supports Y16. 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const media::VideoCaptureParams& params) { 159 const media::VideoCaptureParams& params) {
160 DCHECK_CURRENTLY_ON(BrowserThread::IO); 160 DCHECK_CURRENTLY_ON(BrowserThread::IO);
161 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id 161 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id
162 << ", session_id=" << session_id 162 << ", session_id=" << session_id
163 << ", params.requested_format=" 163 << ", params.requested_format="
164 << media::VideoCaptureFormat::ToString(params.requested_format); 164 << media::VideoCaptureFormat::ToString(params.requested_format);
165 165
166 // Check that requested VideoCaptureParams are valid and supported. If not, 166 // Check that requested VideoCaptureParams are valid and supported. If not,
167 // report an error immediately and punt. 167 // report an error immediately and punt.
168 if (!params.IsValid() || 168 if (!params.IsValid() ||
169 params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 || 169 !(params.requested_format.pixel_format == media::PIXEL_FORMAT_I420 ||
170 params.requested_format.pixel_format == media::PIXEL_FORMAT_Y8 ||
171 params.requested_format.pixel_format == media::PIXEL_FORMAT_Y16) ||
170 (params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU && 172 (params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU &&
171 params.requested_format.pixel_storage != 173 params.requested_format.pixel_storage !=
172 media::PIXEL_STORAGE_GPUMEMORYBUFFER)) { 174 media::PIXEL_STORAGE_GPUMEMORYBUFFER)) {
173 // Crash in debug builds since the renderer should not have asked for 175 // Crash in debug builds since the renderer should not have asked for
174 // invalid or unsupported parameters. 176 // invalid or unsupported parameters.
175 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " 177 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: "
176 << media::VideoCaptureFormat::ToString(params.requested_format); 178 << media::VideoCaptureFormat::ToString(params.requested_format);
177 event_handler->OnError(id); 179 event_handler->OnError(id);
178 return; 180 return;
179 } 181 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { 367 if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
366 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { 368 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) {
367 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, 369 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE,
368 video_capture_format_.frame_rate); 370 video_capture_format_.frame_rate);
369 } 371 }
370 std::unique_ptr<base::DictionaryValue> metadata( 372 std::unique_ptr<base::DictionaryValue> metadata(
371 new base::DictionaryValue()); 373 new base::DictionaryValue());
372 frame->metadata()->MergeInternalValuesInto(metadata.get()); 374 frame->metadata()->MergeInternalValuesInto(metadata.get());
373 375
374 // Only I420 pixel format is currently supported. 376 // Only I420 pixel format is currently supported.
375 DCHECK_EQ(frame->format(), media::PIXEL_FORMAT_I420) 377 DCHECK(frame->format() == media::PIXEL_FORMAT_I420 ||
378 frame->format() == media::PIXEL_FORMAT_Y8 ||
379 frame->format() == media::PIXEL_FORMAT_Y16)
376 << "Unsupported pixel format: " 380 << "Unsupported pixel format: "
377 << media::VideoPixelFormatToString(frame->format()); 381 << media::VideoPixelFormatToString(frame->format());
378 382
379 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. 383 // Sanity-checks to confirm |frame| is actually being backed by |buffer|.
380 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM || 384 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM ||
381 (frame->storage_type() == 385 (frame->storage_type() ==
382 media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS)); 386 media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS));
383 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && 387 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) &&
384 (frame->data(media::VideoFrame::kYPlane) < 388 (frame->data(media::VideoFrame::kYPlane) <
385 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + 389 (reinterpret_cast<const uint8_t*>(buffer->data(0)) +
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: { 471 case media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS: {
468 std::vector<gfx::GpuMemoryBufferHandle> handles; 472 std::vector<gfx::GpuMemoryBufferHandle> handles;
469 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format()); 473 const size_t num_planes = media::VideoFrame::NumPlanes(frame->format());
470 for (size_t i = 0; i < num_planes; ++i) { 474 for (size_t i = 0; i < num_planes; ++i) {
471 gfx::GpuMemoryBufferHandle remote_handle; 475 gfx::GpuMemoryBufferHandle remote_handle;
472 buffer_pool_->ShareToProcess2( 476 buffer_pool_->ShareToProcess2(
473 buffer_id, i, client->render_process_handle, &remote_handle); 477 buffer_id, i, client->render_process_handle, &remote_handle);
474 handles.push_back(remote_handle); 478 handles.push_back(remote_handle);
475 } 479 }
476 client->event_handler->OnBufferCreated2(client->controller_id, handles, 480 client->event_handler->OnBufferCreated2(client->controller_id, handles,
477 buffer->dimensions(), buffer_id); 481 buffer->dimensions(),
482 frame->format(), buffer_id);
478 break; 483 break;
479 } 484 }
480 case media::VideoFrame::STORAGE_SHMEM: { 485 case media::VideoFrame::STORAGE_SHMEM: {
481 base::SharedMemoryHandle remote_handle; 486 base::SharedMemoryHandle remote_handle;
482 buffer_pool_->ShareToProcess(buffer_id, client->render_process_handle, 487 buffer_pool_->ShareToProcess(buffer_id, client->render_process_handle,
483 &remote_handle); 488 &remote_handle);
484 client->event_handler->OnBufferCreated( 489 client->event_handler->OnBufferCreated(
485 client->controller_id, remote_handle, buffer->mapped_size(), 490 client->controller_id, remote_handle, buffer->mapped_size(),
486 buffer_id); 491 buffer_id);
487 break; 492 break;
(...skipping 19 matching lines...) Expand all
507 int session_id, 512 int session_id,
508 const ControllerClients& clients) { 513 const ControllerClients& clients) {
509 for (auto* client : clients) { 514 for (auto* client : clients) {
510 if (client->session_id == session_id) 515 if (client->session_id == session_id)
511 return client; 516 return client;
512 } 517 }
513 return NULL; 518 return NULL;
514 } 519 }
515 520
516 } // namespace content 521 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698