| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const media::VideoCaptureParams& params) { | 211 const media::VideoCaptureParams& params) { |
| 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_format == media::PIXEL_FORMAT_Y16) || |
| 222 params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU) { | 223 params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU) { |
| 223 // Crash in debug builds since the renderer should not have asked for | 224 // Crash in debug builds since the renderer should not have asked for |
| 224 // invalid or unsupported parameters. | 225 // invalid or unsupported parameters. |
| 225 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " | 226 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " |
| 226 << media::VideoCaptureFormat::ToString(params.requested_format); | 227 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 227 event_handler->OnError(id); | 228 event_handler->OnError(id); |
| 228 return; | 229 return; |
| 229 } | 230 } |
| 230 | 231 |
| 231 // If this is the first client added to the controller, cache the parameters. | 232 // If this is the first client added to the controller, cache the parameters. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 int count = 0; | 415 int count = 0; |
| 415 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 416 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 416 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 417 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
| 417 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 418 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
| 418 video_capture_format_.frame_rate); | 419 video_capture_format_.frame_rate); |
| 419 } | 420 } |
| 420 std::unique_ptr<base::DictionaryValue> metadata( | 421 std::unique_ptr<base::DictionaryValue> metadata( |
| 421 new base::DictionaryValue()); | 422 new base::DictionaryValue()); |
| 422 frame->metadata()->MergeInternalValuesInto(metadata.get()); | 423 frame->metadata()->MergeInternalValuesInto(metadata.get()); |
| 423 | 424 |
| 424 // Only I420 pixel format is currently supported. | 425 // Only I420 and Y16 pixel formats are currently supported. |
| 425 DCHECK_EQ(frame->format(), media::PIXEL_FORMAT_I420) | 426 DCHECK(frame->format() == media::PIXEL_FORMAT_I420 || |
| 427 frame->format() == media::PIXEL_FORMAT_Y16) |
| 426 << "Unsupported pixel format: " | 428 << "Unsupported pixel format: " |
| 427 << media::VideoPixelFormatToString(frame->format()); | 429 << media::VideoPixelFormatToString(frame->format()); |
| 428 | 430 |
| 429 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. | 431 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. |
| 430 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM); | 432 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM); |
| 431 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && | 433 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && |
| 432 (frame->data(media::VideoFrame::kYPlane) < | 434 (frame->data(media::VideoFrame::kYPlane) < |
| 433 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + | 435 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + |
| 434 buffer->mapped_size()))) | 436 buffer->mapped_size()))) |
| 435 << "VideoFrame does not appear to be backed by Buffer"; | 437 << "VideoFrame does not appear to be backed by Buffer"; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 int session_id, | 536 int session_id, |
| 535 const ControllerClients& clients) { | 537 const ControllerClients& clients) { |
| 536 for (const auto& client : clients) { | 538 for (const auto& client : clients) { |
| 537 if (client->session_id == session_id) | 539 if (client->session_id == session_id) |
| 538 return client.get(); | 540 return client.get(); |
| 539 } | 541 } |
| 540 return nullptr; | 542 return nullptr; |
| 541 } | 543 } |
| 542 | 544 |
| 543 } // namespace content | 545 } // namespace content |
| OLD | NEW |