| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/capture/content/thread_safe_capture_oracle.h" | 5 #include "device/capture/content/thread_safe_capture_oracle.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bits.h" | 13 #include "base/bits.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "media/base/video_capture_types.h" | 19 #include "media/base/video_capture_types.h" |
| 20 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
| 21 #include "media/base/video_frame_metadata.h" | 21 #include "media/base/video_frame_metadata.h" |
| 22 #include "media/base/video_util.h" | 22 #include "media/base/video_util.h" |
| 23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 24 | 24 |
| 25 namespace media { | 25 namespace device { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // The target maximum amount of the buffer pool to utilize. Actual buffer pool | 29 // The target maximum amount of the buffer pool to utilize. Actual buffer pool |
| 30 // utilization is attenuated by this amount before being reported to the | 30 // utilization is attenuated by this amount before being reported to the |
| 31 // VideoCaptureOracle. This value takes into account the maximum number of | 31 // VideoCaptureOracle. This value takes into account the maximum number of |
| 32 // buffer pool buffers and a desired safety margin. | 32 // buffer pool buffers and a desired safety margin. |
| 33 const int kTargetMaxPoolUtilizationPercent = 60; | 33 const int kTargetMaxPoolUtilizationPercent = 60; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 VideoCaptureOracle::Event event, | 54 VideoCaptureOracle::Event event, |
| 55 const gfx::Rect& damage_rect, | 55 const gfx::Rect& damage_rect, |
| 56 base::TimeTicks event_time, | 56 base::TimeTicks event_time, |
| 57 scoped_refptr<VideoFrame>* storage, | 57 scoped_refptr<VideoFrame>* storage, |
| 58 CaptureFrameCallback* callback) { | 58 CaptureFrameCallback* callback) { |
| 59 // Grab the current time before waiting to acquire the |lock_|. | 59 // Grab the current time before waiting to acquire the |lock_|. |
| 60 const base::TimeTicks capture_begin_time = base::TimeTicks::Now(); | 60 const base::TimeTicks capture_begin_time = base::TimeTicks::Now(); |
| 61 | 61 |
| 62 gfx::Size visible_size; | 62 gfx::Size visible_size; |
| 63 gfx::Size coded_size; | 63 gfx::Size coded_size; |
| 64 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer; | 64 std::unique_ptr<VideoCaptureDevice::Client::Buffer> output_buffer; |
| 65 double attenuated_utilization; | 65 double attenuated_utilization; |
| 66 int frame_number; | 66 int frame_number; |
| 67 base::TimeDelta estimated_frame_duration; | 67 base::TimeDelta estimated_frame_duration; |
| 68 { | 68 { |
| 69 base::AutoLock guard(lock_); | 69 base::AutoLock guard(lock_); |
| 70 | 70 |
| 71 if (!client_) | 71 if (!client_) |
| 72 return false; // Capture is stopped. | 72 return false; // Capture is stopped. |
| 73 | 73 |
| 74 if (!oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time)) { | 74 if (!oracle_.ObserveEventAndDecideCapture(event, damage_rect, event_time)) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Note: This function may be called on any thread by the VideoFrame | 242 // Note: This function may be called on any thread by the VideoFrame |
| 243 // destructor. |metadata| is still valid for read-access at this point. | 243 // destructor. |metadata| is still valid for read-access at this point. |
| 244 double utilization = -1.0; | 244 double utilization = -1.0; |
| 245 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 245 if (metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 246 &utilization)) { | 246 &utilization)) { |
| 247 base::AutoLock guard(lock_); | 247 base::AutoLock guard(lock_); |
| 248 oracle_.RecordConsumerFeedback(frame_number, utilization); | 248 oracle_.RecordConsumerFeedback(frame_number, utilization); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace media | 252 } // namespace device |
| OLD | NEW |