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

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

Issue 2757923004: Fix failed capture handling in WebrtcVideoStream (Closed)
Patch Set: . Created 3 years, 9 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
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 webrtc::DesktopVector dpi = 153 webrtc::DesktopVector dpi =
154 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi) 154 frame->dpi().is_zero() ? webrtc::DesktopVector(kDefaultDpi, kDefaultDpi)
155 : frame->dpi(); 155 : frame->dpi();
156 156
157 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) { 157 if (!frame_size_.equals(frame->size()) || !frame_dpi_.equals(dpi)) {
158 frame_size_ = frame->size(); 158 frame_size_ = frame->size();
159 frame_dpi_ = dpi; 159 frame_dpi_ = dpi;
160 if (observer_) 160 if (observer_)
161 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_); 161 observer_->OnVideoSizeChanged(this, frame_size_, frame_dpi_);
162 } 162 }
163 } else {
164 // Save event timestamps to be used for the next frame.
165 next_frame_input_event_timestamps_ =
166 captured_frame_timestamps_->input_event_timestamps;
167 captured_frame_timestamps_->input_event_timestamps = InputEventTimestamps();
168 } 163 }
169 164
170 base::PostTaskAndReplyWithResult( 165 base::PostTaskAndReplyWithResult(
171 encode_task_runner_.get(), FROM_HERE, 166 encode_task_runner_.get(), FROM_HERE,
172 base::Bind(&WebrtcVideoStream::EncodeFrame, encoder_.get(), 167 base::Bind(&WebrtcVideoStream::EncodeFrame, encoder_.get(),
173 base::Passed(std::move(frame)), frame_params, 168 base::Passed(std::move(frame)), frame_params,
174 base::Passed(std::move(captured_frame_timestamps_))), 169 base::Passed(std::move(captured_frame_timestamps_))),
175 base::Bind(&WebrtcVideoStream::OnFrameEncoded, 170 base::Bind(&WebrtcVideoStream::OnFrameEncoded,
176 weak_factory_.GetWeakPtr())); 171 weak_factory_.GetWeakPtr()));
177 } 172 }
178 173
179 void WebrtcVideoStream::OnChannelInitialized( 174 void WebrtcVideoStream::OnChannelInitialized(
180 ChannelDispatcherBase* channel_dispatcher) { 175 ChannelDispatcherBase* channel_dispatcher) {
181 DCHECK(&video_stats_dispatcher_ == channel_dispatcher); 176 DCHECK(&video_stats_dispatcher_ == channel_dispatcher);
182 } 177 }
183 void WebrtcVideoStream::OnChannelClosed( 178 void WebrtcVideoStream::OnChannelClosed(
184 ChannelDispatcherBase* channel_dispatcher) { 179 ChannelDispatcherBase* channel_dispatcher) {
185 DCHECK(&video_stats_dispatcher_ == channel_dispatcher); 180 DCHECK(&video_stats_dispatcher_ == channel_dispatcher);
186 LOG(WARNING) << "video_stats channel was closed."; 181 LOG(WARNING) << "video_stats channel was closed.";
187 } 182 }
188 183
189 void WebrtcVideoStream::CaptureNextFrame() { 184 void WebrtcVideoStream::CaptureNextFrame() {
190 DCHECK(thread_checker_.CalledOnValidThread()); 185 DCHECK(thread_checker_.CalledOnValidThread());
191 186
192 captured_frame_timestamps_.reset(new FrameTimestamps()); 187 captured_frame_timestamps_.reset(new FrameTimestamps());
193 captured_frame_timestamps_->capture_started_time = base::TimeTicks::Now(); 188 captured_frame_timestamps_->capture_started_time = base::TimeTicks::Now();
194 189 captured_frame_timestamps_->input_event_timestamps =
195 if (!next_frame_input_event_timestamps_.is_null()) { 190 event_timestamps_source_->TakeLastEventTimestamps();
196 captured_frame_timestamps_->input_event_timestamps =
197 next_frame_input_event_timestamps_;
198 next_frame_input_event_timestamps_ = InputEventTimestamps();
199 } else if (event_timestamps_source_) {
200 captured_frame_timestamps_->input_event_timestamps =
201 event_timestamps_source_->TakeLastEventTimestamps();
202 }
203 191
204 capturer_->CaptureFrame(); 192 capturer_->CaptureFrame();
205 } 193 }
206 194
207 // static 195 // static
208 WebrtcVideoStream::EncodedFrameWithTimestamps WebrtcVideoStream::EncodeFrame( 196 WebrtcVideoStream::EncodedFrameWithTimestamps WebrtcVideoStream::EncodeFrame(
209 WebrtcVideoEncoder* encoder, 197 WebrtcVideoEncoder* encoder,
210 std::unique_ptr<webrtc::DesktopFrame> frame, 198 std::unique_ptr<webrtc::DesktopFrame> frame,
211 WebrtcVideoEncoder::FrameParams params, 199 WebrtcVideoEncoder::FrameParams params,
212 std::unique_ptr<WebrtcVideoStream::FrameTimestamps> timestamps) { 200 std::unique_ptr<WebrtcVideoStream::FrameTimestamps> timestamps) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 249
262 stats.encode_delay = frame.timestamps->encode_ended_time - 250 stats.encode_delay = frame.timestamps->encode_ended_time -
263 frame.timestamps->encode_started_time; 251 frame.timestamps->encode_started_time;
264 252
265 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats); 253 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats);
266 } 254 }
267 } 255 }
268 256
269 } // namespace protocol 257 } // namespace protocol
270 } // namespace remoting 258 } // namespace remoting
OLDNEW
« remoting/protocol/webrtc_frame_scheduler_simple.cc ('K') | « remoting/protocol/webrtc_video_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698