Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: remoting/protocol/webrtc_frame_scheduler_simple.cc

Issue 2398993004: DrMemory: Avoid capture with no capture callback set (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/protocol/webrtc_frame_scheduler_simple.h" 5 #include "remoting/protocol/webrtc_frame_scheduler_simple.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
10 10
(...skipping 26 matching lines...) Expand all
37 37
38 void WebrtcFrameSchedulerSimple::Start(const base::Closure& capture_callback) { 38 void WebrtcFrameSchedulerSimple::Start(const base::Closure& capture_callback) {
39 capture_callback_ = capture_callback; 39 capture_callback_ = capture_callback;
40 ScheduleNextFrame(base::TimeTicks::Now()); 40 ScheduleNextFrame(base::TimeTicks::Now());
41 } 41 }
42 42
43 void WebrtcFrameSchedulerSimple::Pause(bool pause) { 43 void WebrtcFrameSchedulerSimple::Pause(bool pause) {
44 paused_ = pause; 44 paused_ = pause;
45 if (paused_) { 45 if (paused_) {
46 capture_timer_.Stop(); 46 capture_timer_.Stop();
47 } else if (!capture_callback_.is_null()) { 47 } else {
48 ScheduleNextFrame(base::TimeTicks::Now()); 48 ScheduleNextFrame(base::TimeTicks::Now());
49 } 49 }
50 } 50 }
51 51
52 void WebrtcFrameSchedulerSimple::SetKeyFrameRequest() { 52 void WebrtcFrameSchedulerSimple::SetKeyFrameRequest() {
53 key_frame_request_ = true; 53 key_frame_request_ = true;
54 } 54 }
55 55
56 void WebrtcFrameSchedulerSimple::SetTargetBitrate(int bitrate_kbps) { 56 void WebrtcFrameSchedulerSimple::SetTargetBitrate(int bitrate_kbps) {
57 base::TimeTicks now = base::TimeTicks::Now(); 57 base::TimeTicks now = base::TimeTicks::Now();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 (now - last_capture_started_time_).InMicroseconds()); 105 (now - last_capture_started_time_).InMicroseconds());
106 106
107 // Top-off until the target quantizer value is reached. 107 // Top-off until the target quantizer value is reached.
108 top_off_is_active_ = encoded_frame.quantizer > kTargetQuantizerForVp8TopOff; 108 top_off_is_active_ = encoded_frame.quantizer > kTargetQuantizerForVp8TopOff;
109 } 109 }
110 110
111 ScheduleNextFrame(now); 111 ScheduleNextFrame(now);
112 } 112 }
113 113
114 void WebrtcFrameSchedulerSimple::ScheduleNextFrame(base::TimeTicks now) { 114 void WebrtcFrameSchedulerSimple::ScheduleNextFrame(base::TimeTicks now) {
115 // Don't capture frames when paused or target bitrate is 0. 115 // Don't capture frames when paused or target bitrate is 0 or there is
116 if (paused_ || pacing_bucket_.rate() == 0) 116 // no capture callback set.
117 if (paused_ || pacing_bucket_.rate() == 0 || capture_callback_.is_null())
117 return; 118 return;
118 119
119 // If this is not the first frame then capture next frame after the previous 120 // If this is not the first frame then capture next frame after the previous
120 // one has finished sending. 121 // one has finished sending.
121 base::TimeDelta expected_processing_time = 122 base::TimeDelta expected_processing_time =
122 base::TimeDelta::FromMicroseconds(frame_processing_delay_us_.Max()); 123 base::TimeDelta::FromMicroseconds(frame_processing_delay_us_.Max());
123 base::TimeTicks target_capture_time = 124 base::TimeTicks target_capture_time =
124 pacing_bucket_.GetEmptyTime() - expected_processing_time; 125 pacing_bucket_.GetEmptyTime() - expected_processing_time;
125 126
126 // Cap interval between frames to kTargetFrameInterval. 127 // Cap interval between frames to kTargetFrameInterval.
(...skipping 10 matching lines...) Expand all
137 base::Unretained(this))); 138 base::Unretained(this)));
138 } 139 }
139 140
140 void WebrtcFrameSchedulerSimple::CaptureNextFrame() { 141 void WebrtcFrameSchedulerSimple::CaptureNextFrame() {
141 last_capture_started_time_ = base::TimeTicks::Now(); 142 last_capture_started_time_ = base::TimeTicks::Now();
142 capture_callback_.Run(); 143 capture_callback_.Run();
143 } 144 }
144 145
145 } // namespace protocol 146 } // namespace protocol
146 } // namespace remoting 147 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698