| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if (buffers_in_use_entry_iter == std::end(client->buffers_in_use)) { | 364 if (buffers_in_use_entry_iter == std::end(client->buffers_in_use)) { |
| 365 NOTREACHED(); | 365 NOTREACHED(); |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 client->buffers_in_use.erase(buffers_in_use_entry_iter); | 368 client->buffers_in_use.erase(buffers_in_use_entry_iter); |
| 369 | 369 |
| 370 OnClientFinishedConsumingBuffer(client, buffer_id, | 370 OnClientFinishedConsumingBuffer(client, buffer_id, |
| 371 consumer_resource_utilization); | 371 consumer_resource_utilization); |
| 372 } | 372 } |
| 373 | 373 |
| 374 const media::VideoCaptureFormat& VideoCaptureController::GetVideoCaptureFormat() | 374 const base::Optional<media::VideoCaptureFormat> |
| 375 const { | 375 VideoCaptureController::GetVideoCaptureFormat() const { |
| 376 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 376 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 377 return video_capture_format_; | 377 return video_capture_format_; |
| 378 } | 378 } |
| 379 | 379 |
| 380 void VideoCaptureController::OnNewBufferHandle( | 380 void VideoCaptureController::OnNewBufferHandle( |
| 381 int buffer_id, | 381 int buffer_id, |
| 382 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer::HandleProvider> | 382 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer::HandleProvider> |
| 383 handle_provider) { | 383 handle_provider) { |
| 384 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 384 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 385 DCHECK(FindUnretiredBufferContextFromBufferId(buffer_id) == | 385 DCHECK(FindUnretiredBufferContextFromBufferId(buffer_id) == |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 442 |
| 443 if (!has_received_frames_) { | 443 if (!has_received_frames_) { |
| 444 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", | 444 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", |
| 445 frame_info->coded_size.width()); | 445 frame_info->coded_size.width()); |
| 446 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Height", | 446 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Height", |
| 447 frame_info->coded_size.height()); | 447 frame_info->coded_size.height()); |
| 448 UMA_HISTOGRAM_ASPECT_RATIO("Media.VideoCapture.AspectRatio", | 448 UMA_HISTOGRAM_ASPECT_RATIO("Media.VideoCapture.AspectRatio", |
| 449 frame_info->coded_size.width(), | 449 frame_info->coded_size.width(), |
| 450 frame_info->coded_size.height()); | 450 frame_info->coded_size.height()); |
| 451 double frame_rate = 0.0f; | 451 double frame_rate = 0.0f; |
| 452 media::VideoFrameMetadata metadata; | 452 if (video_capture_format_) { |
| 453 metadata.MergeInternalValuesFrom(*frame_info->metadata); | 453 media::VideoFrameMetadata metadata; |
| 454 if (!metadata.GetDouble(VideoFrameMetadata::FRAME_RATE, &frame_rate)) { | 454 metadata.MergeInternalValuesFrom(*frame_info->metadata); |
| 455 frame_rate = video_capture_format_.frame_rate; | 455 if (!metadata.GetDouble(VideoFrameMetadata::FRAME_RATE, &frame_rate)) { |
| 456 frame_rate = video_capture_format_->frame_rate; |
| 457 } |
| 456 } | 458 } |
| 457 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate", frame_rate); | 459 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate", frame_rate); |
| 458 has_received_frames_ = true; | 460 has_received_frames_ = true; |
| 459 } | 461 } |
| 460 } | 462 } |
| 461 | 463 |
| 462 void VideoCaptureController::OnBufferRetired(int buffer_id) { | 464 void VideoCaptureController::OnBufferRetired(int buffer_id) { |
| 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 465 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 464 | 466 |
| 465 auto buffer_context_iter = FindUnretiredBufferContextFromBufferId(buffer_id); | 467 auto buffer_context_iter = FindUnretiredBufferContextFromBufferId(buffer_id); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 EventHandlerAction action) { | 624 EventHandlerAction action) { |
| 623 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 625 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 624 for (const auto& client : controller_clients_) { | 626 for (const auto& client : controller_clients_) { |
| 625 if (client->session_closed) | 627 if (client->session_closed) |
| 626 continue; | 628 continue; |
| 627 action.Run(client->event_handler, client->controller_id); | 629 action.Run(client->event_handler, client->controller_id); |
| 628 } | 630 } |
| 629 } | 631 } |
| 630 | 632 |
| 631 } // namespace content | 633 } // namespace content |
| OLD | NEW |