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

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

Issue 2050353002: Update webrtc::DesktopCapturer clients to implement OnCaptureResult(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix chromeos Created 4 years, 6 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 | « remoting/protocol/webrtc_frame_scheduler.h ('k') | 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.h" 5 #include "remoting/protocol/webrtc_frame_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 target_bitrate_kbps_ = target_bitrate_kbps; 111 target_bitrate_kbps_ = target_bitrate_kbps;
112 } 112 }
113 113
114 bool WebrtcFrameScheduler::ClearAndGetKeyFrameRequest() { 114 bool WebrtcFrameScheduler::ClearAndGetKeyFrameRequest() {
115 base::AutoLock lock(lock_); 115 base::AutoLock lock(lock_);
116 bool key_frame_request = key_frame_request_; 116 bool key_frame_request = key_frame_request_;
117 key_frame_request_ = false; 117 key_frame_request_ = false;
118 return key_frame_request; 118 return key_frame_request;
119 } 119 }
120 120
121 void WebrtcFrameScheduler::OnCaptureCompleted(webrtc::DesktopFrame* frame) { 121 void WebrtcFrameScheduler::OnCaptureResult(
122 webrtc::DesktopCapturer::Result result,
123 std::unique_ptr<webrtc::DesktopFrame> frame) {
122 DCHECK(thread_checker_.CalledOnValidThread()); 124 DCHECK(thread_checker_.CalledOnValidThread());
123 125
124 base::TimeTicks captured_ticks = base::TimeTicks::Now(); 126 base::TimeTicks captured_ticks = base::TimeTicks::Now();
125 int64_t capture_timestamp_ms = 127 int64_t capture_timestamp_ms =
126 (captured_ticks - base::TimeTicks()).InMilliseconds(); 128 (captured_ticks - base::TimeTicks()).InMilliseconds();
127 capture_pending_ = false; 129 capture_pending_ = false;
128 130
129 std::unique_ptr<webrtc::DesktopFrame> owned_frame(frame); 131 // TODO(sergeyu): Handle ERROR_PERMANENT result here.
130 132
131 if (encode_pending_) { 133 if (encode_pending_) {
132 // TODO(isheriff): consider queuing here 134 // TODO(isheriff): consider queuing here
133 VLOG(1) << "Dropping captured frame since encoder is still busy"; 135 VLOG(1) << "Dropping captured frame since encoder is still busy";
134 return; 136 return;
135 } 137 }
136 138
137 last_capture_completed_ticks_ = captured_ticks; 139 last_capture_completed_ticks_ = captured_ticks;
138 140
139 webrtc::DesktopVector dpi = 141 webrtc::DesktopVector dpi =
140 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi) 142 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi)
141 : frame->dpi(); 143 : frame->dpi();
142 144
143 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) { 145 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) {
144 frame_size_ = frame->size(); 146 frame_size_ = frame->size();
145 frame_dpi_ = dpi; 147 frame_dpi_ = dpi;
146 if (!size_callback_.is_null()) 148 if (!size_callback_.is_null())
147 size_callback_.Run(frame_size_, frame_dpi_); 149 size_callback_.Run(frame_size_, frame_dpi_);
148 } 150 }
149 encode_pending_ = true; 151 encode_pending_ = true;
150 task_tracker_.PostTaskAndReplyWithResult( 152 task_tracker_.PostTaskAndReplyWithResult(
151 encode_task_runner_.get(), FROM_HERE, 153 encode_task_runner_.get(), FROM_HERE,
152 base::Bind(&WebrtcFrameScheduler::EncodeFrame, encoder_.get(), 154 base::Bind(&WebrtcFrameScheduler::EncodeFrame, encoder_.get(),
153 base::Passed(std::move(owned_frame)), target_bitrate_kbps_, 155 base::Passed(&frame), target_bitrate_kbps_,
154 ClearAndGetKeyFrameRequest(), capture_timestamp_ms), 156 ClearAndGetKeyFrameRequest(), capture_timestamp_ms),
155 base::Bind(&WebrtcFrameScheduler::OnFrameEncoded, 157 base::Bind(&WebrtcFrameScheduler::OnFrameEncoded,
156 weak_factory_.GetWeakPtr())); 158 weak_factory_.GetWeakPtr()));
157 } 159 }
158 160
159 void WebrtcFrameScheduler::CaptureNextFrame() { 161 void WebrtcFrameScheduler::CaptureNextFrame() {
160 DCHECK(thread_checker_.CalledOnValidThread()); 162 DCHECK(thread_checker_.CalledOnValidThread());
161 163
162 if (capture_pending_ || encode_pending_) { 164 if (capture_pending_ || encode_pending_) {
163 VLOG(1) << "Capture/encode still pending.."; 165 VLOG(1) << "Capture/encode still pending..";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } else { 220 } else {
219 LOG(ERROR) << "SendEncodedFrame() failed"; 221 LOG(ERROR) << "SendEncodedFrame() failed";
220 } 222 }
221 capture_timer_->Start(FROM_HERE, 223 capture_timer_->Start(FROM_HERE,
222 base::TimeDelta::FromMilliseconds(next_sched_ms), this, 224 base::TimeDelta::FromMilliseconds(next_sched_ms), this,
223 &WebrtcFrameScheduler::CaptureNextFrame); 225 &WebrtcFrameScheduler::CaptureNextFrame);
224 } 226 }
225 227
226 } // namespace protocol 228 } // namespace protocol
227 } // namespace remoting 229 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_frame_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698