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

Side by Side Diff: remoting/protocol/video_frame_pump.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/video_frame_pump.h ('k') | remoting/protocol/video_stream.h » ('j') | 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/video_frame_pump.h" 5 #include "remoting/protocol/video_frame_pump.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 void VideoFramePump::SetLosslessColor(bool want_lossless) { 102 void VideoFramePump::SetLosslessColor(bool want_lossless) {
103 DCHECK(thread_checker_.CalledOnValidThread()); 103 DCHECK(thread_checker_.CalledOnValidThread());
104 104
105 encode_task_runner_->PostTask( 105 encode_task_runner_->PostTask(
106 FROM_HERE, base::Bind(&VideoEncoder::SetLosslessColor, 106 FROM_HERE, base::Bind(&VideoEncoder::SetLosslessColor,
107 base::Unretained(encoder_.get()), want_lossless)); 107 base::Unretained(encoder_.get()), want_lossless));
108 } 108 }
109 109
110 void VideoFramePump::SetSizeCallback(const SizeCallback& size_callback) { 110 void VideoFramePump::SetObserver(Observer* observer) {
111 DCHECK(thread_checker_.CalledOnValidThread()); 111 DCHECK(thread_checker_.CalledOnValidThread());
112 size_callback_ = size_callback; 112 observer_ = observer;
113 } 113 }
114 114
115 void VideoFramePump::OnCaptureResult( 115 void VideoFramePump::OnCaptureResult(
116 webrtc::DesktopCapturer::Result result, 116 webrtc::DesktopCapturer::Result result,
117 std::unique_ptr<webrtc::DesktopFrame> frame) { 117 std::unique_ptr<webrtc::DesktopFrame> frame) {
118 DCHECK(thread_checker_.CalledOnValidThread()); 118 DCHECK(thread_checker_.CalledOnValidThread());
119 119
120 capture_scheduler_.OnCaptureCompleted(); 120 capture_scheduler_.OnCaptureCompleted();
121 121
122 captured_frame_timestamps_->capture_ended_time = base::TimeTicks::Now(); 122 captured_frame_timestamps_->capture_ended_time = base::TimeTicks::Now();
123 123
124 if (frame) { 124 if (frame) {
125 webrtc::DesktopVector dpi = 125 webrtc::DesktopVector dpi =
126 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi) 126 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi)
127 : frame->dpi(); 127 : frame->dpi();
128 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) { 128 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) {
129 frame_size_ = frame->size(); 129 frame_size_ = frame->size();
130 frame_dpi_ = dpi; 130 frame_dpi_ = dpi;
131 if (!size_callback_.is_null()) 131 if (observer_)
132 size_callback_.Run(frame_size_, frame_dpi_); 132 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_);
133 } 133 }
134 } 134 }
135 135
136 // Even when |frame| is nullptr we still need to post it to the encode thread 136 // Even when |frame| is nullptr we still need to post it to the encode thread
137 // to make sure frames are freed in the same order they are received and 137 // to make sure frames are freed in the same order they are received and
138 // that we don't start capturing frame n+2 before frame n is freed. 138 // that we don't start capturing frame n+2 before frame n is freed.
139 base::PostTaskAndReplyWithResult( 139 base::PostTaskAndReplyWithResult(
140 encode_task_runner_.get(), FROM_HERE, 140 encode_task_runner_.get(), FROM_HERE,
141 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(), 141 base::Bind(&VideoFramePump::EncodeFrame, encoder_.get(),
142 base::Passed(&frame), 142 base::Passed(&frame),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 } 202 }
203 203
204 void VideoFramePump::SendPacket(std::unique_ptr<PacketWithTimestamps> packet) { 204 void VideoFramePump::SendPacket(std::unique_ptr<PacketWithTimestamps> packet) {
205 DCHECK(thread_checker_.CalledOnValidThread()); 205 DCHECK(thread_checker_.CalledOnValidThread());
206 DCHECK(!send_pending_); 206 DCHECK(!send_pending_);
207 207
208 packet->timestamps->can_send_time = base::TimeTicks::Now(); 208 packet->timestamps->can_send_time = base::TimeTicks::Now();
209 UpdateFrameTimers(packet->packet.get(), packet->timestamps.get()); 209 UpdateFrameTimers(packet->packet.get(), packet->timestamps.get());
210 210
211 if (observer_) {
212 observer_->OnVideoFrameSent(
213 this, packet->packet->frame_id(),
214 packet->timestamps->input_event_client_timestamp);
215 }
216
211 send_pending_ = true; 217 send_pending_ = true;
212 video_stub_->ProcessVideoPacket(std::move(packet->packet), 218 video_stub_->ProcessVideoPacket(std::move(packet->packet),
213 base::Bind(&VideoFramePump::OnVideoPacketSent, 219 base::Bind(&VideoFramePump::OnVideoPacketSent,
214 weak_factory_.GetWeakPtr())); 220 weak_factory_.GetWeakPtr()));
215 } 221 }
216 222
217 void VideoFramePump::UpdateFrameTimers(VideoPacket* packet, 223 void VideoFramePump::UpdateFrameTimers(VideoPacket* packet,
218 FrameTimestamps* timestamps) { 224 FrameTimestamps* timestamps) {
219 if (g_enable_timestamps) 225 if (g_enable_timestamps)
220 packet->set_timestamp(timestamps->capture_ended_time.ToInternalValue()); 226 packet->set_timestamp(timestamps->capture_ended_time.ToInternalValue());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 273 }
268 274
269 void VideoFramePump::OnKeepAlivePacketSent() { 275 void VideoFramePump::OnKeepAlivePacketSent() {
270 DCHECK(thread_checker_.CalledOnValidThread()); 276 DCHECK(thread_checker_.CalledOnValidThread());
271 277
272 keep_alive_timer_.Reset(); 278 keep_alive_timer_.Reset();
273 } 279 }
274 280
275 } // namespace protocol 281 } // namespace protocol
276 } // namespace remoting 282 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/video_frame_pump.h ('k') | remoting/protocol/video_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698