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 "content/browser/media/capture/content_video_capture_device_core.h" | 5 #include "content/browser/media/capture/content_video_capture_device_core.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time); | 82 oracle_->ObserveEventAndDecideCapture(event, damage_rect, event_time); |
83 const bool content_is_dirty = | 83 const bool content_is_dirty = |
84 (event == VideoCaptureOracle::kCompositorUpdate || | 84 (event == VideoCaptureOracle::kCompositorUpdate || |
85 event == VideoCaptureOracle::kSoftwarePaint); | 85 event == VideoCaptureOracle::kSoftwarePaint); |
86 const char* event_name = | 86 const char* event_name = |
87 (event == VideoCaptureOracle::kTimerPoll ? "poll" : | 87 (event == VideoCaptureOracle::kTimerPoll ? "poll" : |
88 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" : | 88 (event == VideoCaptureOracle::kCompositorUpdate ? "gpu" : |
89 "paint")); | 89 "paint")); |
90 | 90 |
91 // Consider the various reasons not to initiate a capture. | 91 // Consider the various reasons not to initiate a capture. |
92 if (should_capture && !output_buffer) { | 92 if (should_capture && !output_buffer.get()) { |
93 TRACE_EVENT_INSTANT1("mirroring", | 93 TRACE_EVENT_INSTANT1("mirroring", |
94 "PipelineLimited", | 94 "PipelineLimited", |
95 TRACE_EVENT_SCOPE_THREAD, | 95 TRACE_EVENT_SCOPE_THREAD, |
96 "trigger", | 96 "trigger", |
97 event_name); | 97 event_name); |
98 return false; | 98 return false; |
99 } else if (!should_capture && output_buffer) { | 99 } else if (!should_capture && output_buffer.get()) { |
100 if (content_is_dirty) { | 100 if (content_is_dirty) { |
101 // This is a normal and acceptable way to drop a frame. We've hit our | 101 // This is a normal and acceptable way to drop a frame. We've hit our |
102 // capture rate limit: for example, the content is animating at 60fps but | 102 // capture rate limit: for example, the content is animating at 60fps but |
103 // we're capturing at 30fps. | 103 // we're capturing at 30fps. |
104 TRACE_EVENT_INSTANT1("mirroring", "FpsRateLimited", | 104 TRACE_EVENT_INSTANT1("mirroring", "FpsRateLimited", |
105 TRACE_EVENT_SCOPE_THREAD, | 105 TRACE_EVENT_SCOPE_THREAD, |
106 "trigger", event_name); | 106 "trigger", event_name); |
107 } | 107 } |
108 return false; | 108 return false; |
109 } else if (!should_capture && !output_buffer) { | 109 } else if (!should_capture && !output_buffer.get()) { |
110 // We decided not to capture, but we wouldn't have been able to if we wanted | 110 // We decided not to capture, but we wouldn't have been able to if we wanted |
111 // to because no output buffer was available. | 111 // to because no output buffer was available. |
112 TRACE_EVENT_INSTANT1("mirroring", "NearlyPipelineLimited", | 112 TRACE_EVENT_INSTANT1("mirroring", "NearlyPipelineLimited", |
113 TRACE_EVENT_SCOPE_THREAD, | 113 TRACE_EVENT_SCOPE_THREAD, |
114 "trigger", event_name); | 114 "trigger", event_name); |
115 return false; | 115 return false; |
116 } | 116 } |
117 int frame_number = oracle_->RecordCapture(); | 117 int frame_number = oracle_->RecordCapture(); |
118 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(), | 118 TRACE_EVENT_ASYNC_BEGIN2("mirroring", "Capture", output_buffer.get(), |
119 "frame_number", frame_number, | 119 "frame_number", frame_number, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 state_ = next_state; | 328 state_ = next_state; |
329 } | 329 } |
330 | 330 |
331 void ContentVideoCaptureDeviceCore::Error(const std::string& reason) { | 331 void ContentVideoCaptureDeviceCore::Error(const std::string& reason) { |
332 DCHECK(thread_checker_.CalledOnValidThread()); | 332 DCHECK(thread_checker_.CalledOnValidThread()); |
333 | 333 |
334 if (state_ == kIdle) | 334 if (state_ == kIdle) |
335 return; | 335 return; |
336 | 336 |
337 if (oracle_proxy_) | 337 if (oracle_proxy_.get()) |
338 oracle_proxy_->ReportError(reason); | 338 oracle_proxy_->ReportError(reason); |
339 | 339 |
340 StopAndDeAllocate(); | 340 StopAndDeAllocate(); |
341 TransitionStateTo(kError); | 341 TransitionStateTo(kError); |
342 } | 342 } |
343 | 343 |
344 } // namespace content | 344 } // namespace content |
OLD | NEW |