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

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

Issue 2083843002: Replace VideoStream::SizeCallback with VideoStream::Observer interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge-sched-stream
Patch Set: 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_video_stream.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_video_stream.h" 5 #include "remoting/protocol/webrtc_video_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) { 161 void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) {
162 NOTIMPLEMENTED(); 162 NOTIMPLEMENTED();
163 } 163 }
164 164
165 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) { 165 void WebrtcVideoStream::SetLosslessColor(bool want_lossless) {
166 NOTIMPLEMENTED(); 166 NOTIMPLEMENTED();
167 } 167 }
168 168
169 void WebrtcVideoStream::SetSizeCallback(const SizeCallback& size_callback) { 169 void WebrtcVideoStream::SetObserver(Observer* observer) {
170 DCHECK(thread_checker_.CalledOnValidThread()); 170 DCHECK(thread_checker_.CalledOnValidThread());
171 size_callback_ = size_callback; 171 observer_ = observer;
172 } 172 }
173 173
174 void WebrtcVideoStream::SetKeyFrameRequest() { 174 void WebrtcVideoStream::SetKeyFrameRequest() {
175 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
176 176
177 key_frame_request_ = true; 177 key_frame_request_ = true;
178 if (!received_first_frame_request_) { 178 if (!received_first_frame_request_) {
179 received_first_frame_request_ = true; 179 received_first_frame_request_ = true;
180 StartCaptureTimer(); 180 StartCaptureTimer();
181 main_task_runner_->PostTask( 181 main_task_runner_->PostTask(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 // TODO(sergeyu): Handle ERROR_PERMANENT result here. 224 // TODO(sergeyu): Handle ERROR_PERMANENT result here.
225 225
226 webrtc::DesktopVector dpi = 226 webrtc::DesktopVector dpi =
227 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi) 227 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi)
228 : frame->dpi(); 228 : frame->dpi();
229 229
230 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) { 230 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) {
231 frame_size_ = frame->size(); 231 frame_size_ = frame->size();
232 frame_dpi_ = dpi; 232 frame_dpi_ = dpi;
233 if (!size_callback_.is_null()) 233 if (observer_)
234 size_callback_.Run(frame_size_, frame_dpi_); 234 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_);
235 } 235 }
236 encode_pending_ = true; 236 encode_pending_ = true;
237 base::PostTaskAndReplyWithResult( 237 base::PostTaskAndReplyWithResult(
238 encode_task_runner_.get(), FROM_HERE, 238 encode_task_runner_.get(), FROM_HERE,
239 base::Bind(&EncodeFrame, encoder_.get(), base::Passed(std::move(frame)), 239 base::Bind(&EncodeFrame, encoder_.get(), base::Passed(std::move(frame)),
240 target_bitrate_kbps_, ClearAndGetKeyFrameRequest(), 240 target_bitrate_kbps_, ClearAndGetKeyFrameRequest(),
241 capture_timestamp_ms), 241 capture_timestamp_ms),
242 base::Bind(&WebrtcVideoStream::OnFrameEncoded, 242 base::Bind(&WebrtcVideoStream::OnFrameEncoded,
243 weak_factory_.GetWeakPtr())); 243 weak_factory_.GetWeakPtr()));
244 } 244 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } else { 279 } else {
280 LOG(ERROR) << "SendEncodedFrame() failed"; 280 LOG(ERROR) << "SendEncodedFrame() failed";
281 } 281 }
282 capture_timer_->Start(FROM_HERE, 282 capture_timer_->Start(FROM_HERE,
283 base::TimeDelta::FromMilliseconds(next_sched_ms), this, 283 base::TimeDelta::FromMilliseconds(next_sched_ms), this,
284 &WebrtcVideoStream::CaptureNextFrame); 284 &WebrtcVideoStream::CaptureNextFrame);
285 } 285 }
286 286
287 } // namespace protocol 287 } // namespace protocol
288 } // namespace remoting 288 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698