| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 const media::VideoCaptureParams& params) { | 206 const media::VideoCaptureParams& params) { |
| 207 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 207 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 208 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id | 208 DVLOG(1) << "VideoCaptureController::AddClient() -- id=" << id |
| 209 << ", session_id=" << session_id | 209 << ", session_id=" << session_id |
| 210 << ", params.requested_format=" | 210 << ", params.requested_format=" |
| 211 << media::VideoCaptureFormat::ToString(params.requested_format); | 211 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 212 | 212 |
| 213 // Check that requested VideoCaptureParams are valid and supported. If not, | 213 // Check that requested VideoCaptureParams are valid and supported. If not, |
| 214 // report an error immediately and punt. | 214 // report an error immediately and punt. |
| 215 if (!params.IsValid() || | 215 if (!params.IsValid() || |
| 216 params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 || | 216 !(params.requested_format.pixel_format == media::PIXEL_FORMAT_I420 || |
| 217 params.requested_format.pixel_format == media::PIXEL_FORMAT_Y16) || |
| 217 params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU) { | 218 params.requested_format.pixel_storage != media::PIXEL_STORAGE_CPU) { |
| 218 // Crash in debug builds since the renderer should not have asked for | 219 // Crash in debug builds since the renderer should not have asked for |
| 219 // invalid or unsupported parameters. | 220 // invalid or unsupported parameters. |
| 220 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " | 221 LOG(DFATAL) << "Invalid or unsupported video capture parameters requested: " |
| 221 << media::VideoCaptureFormat::ToString(params.requested_format); | 222 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 222 event_handler->OnError(id); | 223 event_handler->OnError(id); |
| 223 return; | 224 return; |
| 224 } | 225 } |
| 225 | 226 |
| 226 // If this is the first client added to the controller, cache the parameters. | 227 // 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... |
| 409 int count = 0; | 410 int count = 0; |
| 410 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 411 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 411 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 412 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
| 412 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 413 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
| 413 video_capture_format_.frame_rate); | 414 video_capture_format_.frame_rate); |
| 414 } | 415 } |
| 415 std::unique_ptr<base::DictionaryValue> metadata( | 416 std::unique_ptr<base::DictionaryValue> metadata( |
| 416 new base::DictionaryValue()); | 417 new base::DictionaryValue()); |
| 417 frame->metadata()->MergeInternalValuesInto(metadata.get()); | 418 frame->metadata()->MergeInternalValuesInto(metadata.get()); |
| 418 | 419 |
| 419 // Only I420 pixel format is currently supported. | 420 // Only I420 and Y16 pixel formats are currently supported. |
| 420 DCHECK_EQ(frame->format(), media::PIXEL_FORMAT_I420) | 421 DCHECK(frame->format() == media::PIXEL_FORMAT_I420 || |
| 422 frame->format() == media::PIXEL_FORMAT_Y16) |
| 421 << "Unsupported pixel format: " | 423 << "Unsupported pixel format: " |
| 422 << media::VideoPixelFormatToString(frame->format()); | 424 << media::VideoPixelFormatToString(frame->format()); |
| 423 | 425 |
| 424 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. | 426 // Sanity-checks to confirm |frame| is actually being backed by |buffer|. |
| 425 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM); | 427 DCHECK(frame->storage_type() == media::VideoFrame::STORAGE_SHMEM); |
| 426 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && | 428 DCHECK(frame->data(media::VideoFrame::kYPlane) >= buffer->data(0) && |
| 427 (frame->data(media::VideoFrame::kYPlane) < | 429 (frame->data(media::VideoFrame::kYPlane) < |
| 428 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + | 430 (reinterpret_cast<const uint8_t*>(buffer->data(0)) + |
| 429 buffer->mapped_size()))) | 431 buffer->mapped_size()))) |
| 430 << "VideoFrame does not appear to be backed by Buffer"; | 432 << "VideoFrame does not appear to be backed by Buffer"; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 int session_id, | 530 int session_id, |
| 529 const ControllerClients& clients) { | 531 const ControllerClients& clients) { |
| 530 for (const auto& client : clients) { | 532 for (const auto& client : clients) { |
| 531 if (client->session_id == session_id) | 533 if (client->session_id == session_id) |
| 532 return client.get(); | 534 return client.get(); |
| 533 } | 535 } |
| 534 return nullptr; | 536 return nullptr; |
| 535 } | 537 } |
| 536 | 538 |
| 537 } // namespace content | 539 } // namespace content |
| OLD | NEW |