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

Unified Diff: remoting/host/video_frame_pump.h

Issue 1365663003: Add UMA histograms for more detailed latency tracking on the CRD host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests Created 5 years, 3 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
« no previous file with comments | « remoting/host/client_session.cc ('k') | remoting/host/video_frame_pump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/video_frame_pump.h
diff --git a/remoting/host/video_frame_pump.h b/remoting/host/video_frame_pump.h
index 5bafa3e17fefe6e5af27dac1c39743538d948648..f4542cafc0939da6f347c4738509092c15db432e 100644
--- a/remoting/host/video_frame_pump.h
+++ b/remoting/host/video_frame_pump.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -82,9 +83,8 @@ class VideoFramePump : public webrtc::DesktopCapturer::Callback {
// only affects capture scheduling and does not stop/start the capturer.
void Pause(bool pause);
- // Updates event timestamp from the last event received from the client. This
- // value is sent back to the client for roundtrip latency estimates.
- void SetLatestEventTimestamp(int64 latest_event_timestamp);
+ // Called whenever input event is received.
+ void OnInputEventReceived(int64_t event_timestamp);
// Sets whether the video encoder should be requested to encode losslessly,
// or to use a lossless color space (typically requiring higher bandwidth).
@@ -96,6 +96,33 @@ class VideoFramePump : public webrtc::DesktopCapturer::Callback {
}
private:
+ struct FrameTimestamps {
+ FrameTimestamps();
+ ~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;
+
+ base::TimeTicks capture_started_time;
+ base::TimeTicks capture_ended_time;
+ base::TimeTicks encode_started_time;
+ base::TimeTicks encode_ended_time;
+ base::TimeTicks can_send_time;
+ };
+
+ struct PacketWithTimestamps {
+ PacketWithTimestamps(scoped_ptr<VideoPacket> packet,
+ scoped_ptr<FrameTimestamps> timestamps);
+ ~PacketWithTimestamps();
+
+ scoped_ptr<VideoPacket> packet;
+ scoped_ptr<FrameTimestamps> timestamps;
+ };
+
// webrtc::DesktopCapturer::Callback interface.
webrtc::SharedMemory* CreateSharedMemory(size_t size) override;
void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
@@ -103,10 +130,21 @@ class VideoFramePump : public webrtc::DesktopCapturer::Callback {
// Callback for CaptureScheduler.
void CaptureNextFrame();
- // Sends encoded frame
- void SendEncodedFrame(int64 latest_event_timestamp,
- base::TimeTicks timestamp,
- scoped_ptr<VideoPacket> packet);
+ // Task running on the encoder thread to encode the |frame|.
+ static scoped_ptr<PacketWithTimestamps> EncodeFrame(
+ VideoEncoder* encoder,
+ scoped_ptr<webrtc::DesktopFrame> frame,
+ scoped_ptr<FrameTimestamps> timestamps);
+
+ // Task called when a frame has finished encoding.
+ void OnFrameEncoded(scoped_ptr<PacketWithTimestamps> packet);
+
+ // Sends |packet| to the client.
+ void SendPacket(scoped_ptr<PacketWithTimestamps> packet);
+
+ // Helper called from SendPacket() to calculate timing fields in the |packet|
+ // before sending it.
+ void UpdateFrameTimers(VideoPacket* packet, FrameTimestamps* timestamps);
// Callback passed to |video_stub_|.
void OnVideoPacketSent();
@@ -137,8 +175,15 @@ class VideoFramePump : public webrtc::DesktopCapturer::Callback {
// captured.
CaptureScheduler capture_scheduler_;
- // Number updated by the caller to trace performance.
- int64 latest_event_timestamp_;
+ // Timestamps for the frame to be captured next.
+ scoped_ptr<FrameTimestamps> next_frame_timestamps_;
+
+ // Timestamps for the frame that's being captured.
+ scoped_ptr<FrameTimestamps> captured_frame_timestamps_;
+
+ bool send_pending_ = false;
+
+ ScopedVector<PacketWithTimestamps> pending_packets_;
base::ThreadChecker thread_checker_;
« no previous file with comments | « remoting/host/client_session.cc ('k') | remoting/host/video_frame_pump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698