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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 media::VideoFrameMetadata metadata; |
453 metadata.MergeInternalValuesFrom(*frame_info->metadata); | 453 metadata.MergeInternalValuesFrom(*frame_info->metadata); |
454 if (!metadata.GetDouble(VideoFrameMetadata::FRAME_RATE, &frame_rate)) { | 454 if (!metadata.GetDouble(VideoFrameMetadata::FRAME_RATE, &frame_rate)) { |
455 frame_rate = video_capture_format_.frame_rate; | 455 frame_rate = video_capture_format_->frame_rate; |
chfremer
2017/04/10 17:24:03
Could it happen that |video_capture_format_| is no
Chandan
2017/04/11 07:45:07
Right, its safe to add a check for video_capture_f
| |
456 } | 456 } |
457 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate", frame_rate); | 457 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate", frame_rate); |
458 has_received_frames_ = true; | 458 has_received_frames_ = true; |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
462 void VideoCaptureController::OnBufferRetired(int buffer_id) { | 462 void VideoCaptureController::OnBufferRetired(int buffer_id) { |
463 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
464 | 464 |
465 auto buffer_context_iter = FindUnretiredBufferContextFromBufferId(buffer_id); | 465 auto buffer_context_iter = FindUnretiredBufferContextFromBufferId(buffer_id); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 EventHandlerAction action) { | 622 EventHandlerAction action) { |
623 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 623 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
624 for (const auto& client : controller_clients_) { | 624 for (const auto& client : controller_clients_) { |
625 if (client->session_closed) | 625 if (client->session_closed) |
626 continue; | 626 continue; |
627 action.Run(client->event_handler, client->controller_id); | 627 action.Run(client->event_handler, client->controller_id); |
628 } | 628 } |
629 } | 629 } |
630 | 630 |
631 } // namespace content | 631 } // namespace content |
OLD | NEW |