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

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: 8 bpp support added. R200 camera supported. Created 4 years, 5 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 int session_id, 511 int session_id,
508 const ControllerClients& clients) { 512 const ControllerClients& clients) {
509 for (auto client : clients) { 513 for (auto client : clients) {
510 if (client->session_id == session_id) 514 if (client->session_id == session_id)
511 return client; 515 return client;
512 } 516 }
513 return NULL; 517 return NULL;
514 } 518 }
515 519
516 } // namespace content 520 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698