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

Unified Diff: remoting/protocol/webrtc_video_stream.cc

Issue 2413553003: Add InputEventTimestampSource interface. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/webrtc_video_stream.cc
diff --git a/remoting/protocol/webrtc_video_stream.cc b/remoting/protocol/webrtc_video_stream.cc
index c797e89641538c251a523d0013c4b8bceab4e46f..476c85d1724c30305b39ebb41ff37d8ca78005b3 100644
--- a/remoting/protocol/webrtc_video_stream.cc
+++ b/remoting/protocol/webrtc_video_stream.cc
@@ -45,12 +45,9 @@ const char kStreamLabel[] = "screen_stream";
const char kVideoLabel[] = "screen_video";
struct WebrtcVideoStream::FrameTimestamps {
- // The following two fields are set only for one frame after each incoming
- // input event. |input_event_client_timestamp| is event timestamp
- // received from the client. |input_event_received_time| is local time when
- // the event was received.
- int64_t input_event_client_timestamp = -1;
- base::TimeTicks input_event_received_time;
+ // The following fields is not null only for one frame after each incoming
+ // input event.
+ InputEventTimestamps input_event_timestamps;
base::TimeTicks capture_started_time;
base::TimeTicks capture_ended_time;
@@ -142,18 +139,14 @@ void WebrtcVideoStream::Start(
scheduler_.reset(new WebrtcFrameSchedulerSimple());
}
-void WebrtcVideoStream::Pause(bool pause) {
- DCHECK(thread_checker_.CalledOnValidThread());
- scheduler_->Pause(pause);
+void WebrtcVideoStream::SetEventTimestampSource(
+ scoped_refptr<InputEventTimestampSource> event_timestamp_source) {
+ event_timestamp_source_ = event_timestamp_source;
}
-void WebrtcVideoStream::OnInputEventReceived(int64_t event_timestamp) {
+void WebrtcVideoStream::Pause(bool pause) {
DCHECK(thread_checker_.CalledOnValidThread());
-
- if (!next_frame_timestamps_)
- next_frame_timestamps_.reset(new FrameTimestamps());
- next_frame_timestamps_->input_event_client_timestamp = event_timestamp;
- next_frame_timestamps_->input_event_received_time = base::TimeTicks::Now();
+ scheduler_->Pause(pause);
}
void WebrtcVideoStream::SetLosslessEncode(bool want_lossless) {
@@ -237,15 +230,14 @@ void WebrtcVideoStream::OnChannelClosed(
void WebrtcVideoStream::CaptureNextFrame() {
DCHECK(thread_checker_.CalledOnValidThread());
- // |next_frame_timestamps_| is not set if no input events were received since
- // the previous frame. In that case create FrameTimestamps instance without
- // setting |input_event_client_timestamp| and |input_event_received_time|.
- if (!next_frame_timestamps_)
- next_frame_timestamps_.reset(new FrameTimestamps());
-
- captured_frame_timestamps_ = std::move(next_frame_timestamps_);
+ captured_frame_timestamps_.reset(new FrameTimestamps());
captured_frame_timestamps_->capture_started_time = base::TimeTicks::Now();
+ if (event_timestamp_source_) {
+ captured_frame_timestamps_->input_event_timestamps =
+ event_timestamp_source_->GetLastEventTimestamps();
+ }
+
capturer_->Capture(webrtc::DesktopRegion());
}
@@ -283,11 +275,12 @@ void WebrtcVideoStream::OnFrameEncoded(EncodedFrameWithTimestamps frame) {
HostFrameStats stats;
stats.frame_size = frame.frame->data.size();
- if (!frame.timestamps->input_event_received_time.is_null()) {
- stats.capture_pending_delay = frame.timestamps->capture_started_time -
- frame.timestamps->input_event_received_time;
- stats.latest_event_timestamp = base::TimeTicks::FromInternalValue(
- frame.timestamps->input_event_client_timestamp);
+ if (!frame.timestamps->input_event_timestamps.is_null()) {
+ stats.capture_pending_delay =
+ frame.timestamps->capture_started_time -
+ frame.timestamps->input_event_timestamps.host_timestamp;
+ stats.latest_event_timestamp =
+ frame.timestamps->input_event_timestamps.host_timestamp;
}
stats.capture_delay = frame.timestamps->capture_delay;
« remoting/protocol/video_frame_pump.h ('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