| OLD | NEW |
| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 webrtc::EncodedImageCallback::Result result = | 213 webrtc::EncodedImageCallback::Result result = |
| 214 webrtc_transport_->video_encoder_factory()->SendEncodedFrame( | 214 webrtc_transport_->video_encoder_factory()->SendEncodedFrame( |
| 215 *frame.frame, frame.timestamps->capture_started_time); | 215 *frame.frame, frame.timestamps->capture_started_time); |
| 216 if (result.error != webrtc::EncodedImageCallback::Result::OK) { | 216 if (result.error != webrtc::EncodedImageCallback::Result::OK) { |
| 217 // TODO(sergeyu): Stop the stream. | 217 // TODO(sergeyu): Stop the stream. |
| 218 LOG(ERROR) << "Failed to send video frame."; | 218 LOG(ERROR) << "Failed to send video frame."; |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 scheduler_->OnFrameEncoded(*frame.frame, result); | 222 HostFrameStats stats; |
| 223 scheduler_->OnFrameEncoded(*frame.frame, result, &stats); |
| 223 | 224 |
| 224 // Send FrameStats message. | 225 // Send FrameStats message. |
| 225 if (video_stats_dispatcher_.is_connected()) { | 226 if (video_stats_dispatcher_.is_connected()) { |
| 226 HostFrameStats stats; | |
| 227 stats.frame_size = frame.frame->data.size(); | 227 stats.frame_size = frame.frame->data.size(); |
| 228 | 228 |
| 229 if (!frame.timestamps->input_event_timestamps.is_null()) { | 229 if (!frame.timestamps->input_event_timestamps.is_null()) { |
| 230 stats.capture_pending_delay = | 230 stats.capture_pending_delay = |
| 231 frame.timestamps->capture_started_time - | 231 frame.timestamps->capture_started_time - |
| 232 frame.timestamps->input_event_timestamps.host_timestamp; | 232 frame.timestamps->input_event_timestamps.host_timestamp; |
| 233 stats.latest_event_timestamp = | 233 stats.latest_event_timestamp = |
| 234 frame.timestamps->input_event_timestamps.client_timestamp; | 234 frame.timestamps->input_event_timestamps.client_timestamp; |
| 235 } | 235 } |
| 236 | 236 |
| 237 stats.capture_delay = frame.timestamps->capture_delay; | 237 stats.capture_delay = frame.timestamps->capture_delay; |
| 238 | 238 |
| 239 // Total overhead time for IPC and threading when capturing frames. | 239 // Total overhead time for IPC and threading when capturing frames. |
| 240 stats.capture_overhead_delay = (frame.timestamps->capture_ended_time - | 240 stats.capture_overhead_delay = (frame.timestamps->capture_ended_time - |
| 241 frame.timestamps->capture_started_time) - | 241 frame.timestamps->capture_started_time) - |
| 242 stats.capture_delay; | 242 stats.capture_delay; |
| 243 | 243 |
| 244 stats.encode_pending_delay = frame.timestamps->encode_started_time - | 244 stats.encode_pending_delay = frame.timestamps->encode_started_time - |
| 245 frame.timestamps->capture_ended_time; | 245 frame.timestamps->capture_ended_time; |
| 246 | 246 |
| 247 stats.encode_delay = frame.timestamps->encode_ended_time - | 247 stats.encode_delay = frame.timestamps->encode_ended_time - |
| 248 frame.timestamps->encode_started_time; | 248 frame.timestamps->encode_started_time; |
| 249 | 249 |
| 250 // TODO(sergeyu): Figure out how to measure send_pending time with WebRTC | |
| 251 // and set it here. | |
| 252 stats.send_pending_delay = base::TimeDelta(); | |
| 253 | |
| 254 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats); | 250 video_stats_dispatcher_.OnVideoFrameStats(result.frame_id, stats); |
| 255 } | 251 } |
| 256 } | 252 } |
| 257 | 253 |
| 258 } // namespace protocol | 254 } // namespace protocol |
| 259 } // namespace remoting | 255 } // namespace remoting |
| OLD | NEW |