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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_Y16) || |
170 (params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU && | 171 (params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU && |
171 params.requested_format.pixel_storage != | 172 params.requested_format.pixel_storage != |
172 media::PIXEL_STORAGE_GPUMEMORYBUFFER)) { | 173 media::PIXEL_STORAGE_GPUMEMORYBUFFER)) { |
173 // Crash in debug builds since the renderer should not have asked for | 174 // Crash in debug builds since the renderer should not have asked for |
174 // invalid or unsupported parameters. | 175 // invalid or unsupported parameters. |
175 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " | 176 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " |
176 << media::VideoCaptureFormat::ToString(params.requested_format); | 177 << media::VideoCaptureFormat::ToString(params.requested_format); |
177 event_handler->OnError(id); | 178 event_handler->OnError(id); |
178 return; | 179 return; |
179 } | 180 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 366 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
366 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 367 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
367 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 368 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
368 video_capture_format_.frame_rate); | 369 video_capture_format_.frame_rate); |
369 } | 370 } |
370 std::unique_ptr<base::DictionaryValue> metadata( | 371 std::unique_ptr<base::DictionaryValue> metadata( |
371 new base::DictionaryValue()); | 372 new base::DictionaryValue()); |
372 frame->metadata()->MergeInternalValuesInto(metadata.get()); | 373 frame->metadata()->MergeInternalValuesInto(metadata.get()); |
373 | 374 |
374 // Only I420 pixel format is currently supported. | 375 // Only I420 pixel format is currently supported. |
375 DCHECK_EQ(frame->format(), media::PIXEL_FORMAT_I420) | 376 DCHECK(frame->format() == media::PIXEL_FORMAT_I420 || |
| 377 frame->format() == media::PIXEL_FORMAT_Y16) |
376 << "Unsupported pixel format: " | 378 << "Unsupported pixel format: " |
377 << media::VideoPixelFormatToString(frame->format()); | 379 << media::VideoPixelFormatToString(frame->format()); |
378 | 380 |
379 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. | 381 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. |
380 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM || | 382 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM || |
381 (frame->storage_type() == | 383 (frame->storage_type() == |
382 media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS)); | 384 media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS)); |
383 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && | 385 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && |
384 (frame->data(media::VideoFrame::kYPlane) < | 386 (frame->data(media::VideoFrame::kYPlane) < |
385 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + | 387 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 int session_id, | 509 int session_id, |
508 const ControllerClients& clients) { | 510 const ControllerClients& clients) { |
509 for (auto client : clients) { | 511 for (auto client : clients) { |
510 if (client->session_id == session_id) | 512 if (client->session_id == session_id) |
511 return client; | 513 return client; |
512 } | 514 } |
513 return NULL; | 515 return NULL; |
514 } | 516 } |
515 | 517 |
516 } // namespace content | 518 } // namespace content |
OLD | NEW |