summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authoranandc <anandc@chromium.org>2015-08-13 20:44:48 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-14 03:45:26 +0000
commitd4abf8724d7dc81eb816d86c8ae82d799aafabda (patch)
treeacf71073b34e874372c5b673619e0edc5d5fcf36 /remoting
parentfd90be6f6840b1dd82fcfec15a9304af62a72d97 (diff)
downloadchromium_src-d4abf8724d7dc81eb816d86c8ae82d799aafabda.zip
chromium_src-d4abf8724d7dc81eb816d86c8ae82d799aafabda.tar.gz
chromium_src-d4abf8724d7dc81eb816d86c8ae82d799aafabda.tar.bz2
Implement common stats-update method for use by multiple video-renderers.
Move driving of uploading UMA stats to ChromotingStats, using callbacks defined in ChromotingInstance. Also add UMA histograms for latency metrics. BUG=508602 Review URL: https://codereview.chromium.org/1253193003 Cr-Commit-Position: refs/heads/master@{#343339}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/chromoting_stats.cc133
-rw-r--r--remoting/client/chromoting_stats.h73
-rw-r--r--remoting/client/plugin/chromoting_instance.cc79
-rw-r--r--remoting/client/plugin/chromoting_instance.h15
-rw-r--r--remoting/client/plugin/pepper_video_renderer_2d.cc2
-rw-r--r--remoting/client/plugin/pepper_video_renderer_3d.cc28
-rw-r--r--remoting/client/plugin/pepper_video_renderer_3d.h1
-rw-r--r--remoting/client/server_log_entry_client.cc12
-rw-r--r--remoting/client/software_video_renderer.cc34
-rw-r--r--remoting/client/software_video_renderer.h3
10 files changed, 265 insertions, 115 deletions
diff --git a/remoting/client/chromoting_stats.cc b/remoting/client/chromoting_stats.cc
index 01c67df..fc7b8a47 100644
--- a/remoting/client/chromoting_stats.cc
+++ b/remoting/client/chromoting_stats.cc
@@ -3,12 +3,55 @@
// found in the LICENSE file.
#include "remoting/client/chromoting_stats.h"
+#include "remoting/proto/video.pb.h"
namespace {
// We take the last 10 latency numbers and report the average.
const int kLatencySampleSize = 10;
+// UMA histogram names.
+const char kRoundTripLatencyHistogram[] = "Chromoting.Video.RoundTripLatency";
+const char kVideoCaptureLatencyHistogram[] = "Chromoting.Video.CaptureLatency";
+const char kVideoEncodeLatencyHistogram[] = "Chromoting.Video.EncodeLatency";
+const char kVideoDecodeLatencyHistogram[] = "Chromoting.Video.DecodeLatency";
+const char kVideoPaintLatencyHistogram[] = "Chromoting.Video.PaintLatency";
+const char kVideoFrameRateHistogram[] = "Chromoting.Video.FrameRate";
+const char kVideoPacketRateHistogram[] = "Chromoting.Video.PacketRate";
+const char kVideoBandwidthHistogram[] = "Chromoting.Video.Bandwidth";
+
+// Custom count and custom time histograms are log-scaled by default. This
+// results in fine-grained buckets at lower values and wider-ranged buckets
+// closer to the maximum.
+// The values defined for each histogram below are based on the 99th percentile
+// numbers for the corresponding metric over a recent 28-day period.
+// Values above the maximum defined for a histogram end up in the max-bucket.
+// If the minimum for a UMA histogram is set to be < 1, it is implicitly
+// normalized to 1.
+// See $/src/base/metrics/histogram.h for more details.
+
+// Video-specific metrics are stored in a custom times histogram.
+const int kVideoActionsHistogramsMinMs = 1;
+const int kVideoActionsHistogramsMaxMs = 250;
+const int kVideoActionsHistogramsBuckets = 50;
+
+// Round-trip latency values are stored in a custom times histogram.
+const int kLatencyHistogramMinMs = 1;
+const int kLatencyHistogramMaxMs = 20000;
+const int kLatencyHistogramBuckets = 50;
+
+// Bandwidth statistics are stored in a custom counts histogram.
+const int kBandwidthHistogramMinBps = 0;
+const int kBandwidthHistogramMaxBps = 10 * 1000 * 1000;
+const int kBandwidthHistogramBuckets = 100;
+
+// Frame rate is stored in a custom enum histogram, because we we want to record
+// the frequency of each discrete value, rather than using log-scaled buckets.
+// We don't expect video frame rate to be greater than 40fps. Setting a maximum
+// of 100fps will leave some room for future improvements, and account for any
+// bursts of packets. Enum histograms expect samples to be less than the
+// boundary value, so set to 101.
+const int kMaxFramesPerSec = 101;
} // namespace
namespace remoting {
@@ -24,10 +67,96 @@ ChromotingStats::ChromotingStats()
video_encode_ms_(kLatencySampleSize),
video_decode_ms_(kLatencySampleSize),
video_paint_ms_(kLatencySampleSize),
- round_trip_ms_(kLatencySampleSize) {
-}
+ round_trip_ms_(kLatencySampleSize) {}
ChromotingStats::~ChromotingStats() {
}
+void ChromotingStats::SetUpdateUmaCallbacks(
+ UpdateUmaCustomHistogramCallback update_uma_custom_counts_callback,
+ UpdateUmaCustomHistogramCallback update_uma_custom_times_callback,
+ UpdateUmaEnumHistogramCallback update_uma_enum_histogram_callback) {
+ uma_custom_counts_updater_ = update_uma_custom_counts_callback;
+ uma_custom_times_updater_ = update_uma_custom_times_callback;
+ uma_enum_histogram_updater_ = update_uma_enum_histogram_callback;
+}
+
+void ChromotingStats::RecordVideoPacketStats(const VideoPacket& packet) {
+ // Record this received packet, even if it is empty.
+ video_packet_rate_.Record(1);
+
+ // If the packet is empty, there are no other stats to update.
+ if (!packet.data().size())
+ return;
+
+ video_frame_rate_.Record(1);
+ video_bandwidth_.Record(packet.data().size());
+
+ if (packet.has_capture_time_ms()) {
+ video_capture_ms_.Record(packet.capture_time_ms());
+ if (!uma_custom_times_updater_.is_null())
+ uma_custom_times_updater_.Run(
+ kVideoCaptureLatencyHistogram, packet.capture_time_ms(),
+ kVideoActionsHistogramsMinMs, kVideoActionsHistogramsMaxMs,
+ kVideoActionsHistogramsBuckets);
+ }
+
+ if (packet.has_encode_time_ms()) {
+ video_encode_ms_.Record(packet.encode_time_ms());
+ if (!uma_custom_times_updater_.is_null())
+ uma_custom_times_updater_.Run(
+ kVideoEncodeLatencyHistogram, packet.encode_time_ms(),
+ kVideoActionsHistogramsMinMs, kVideoActionsHistogramsMaxMs,
+ kVideoActionsHistogramsBuckets);
+ }
+
+ if (packet.has_latest_event_timestamp() &&
+ packet.latest_event_timestamp() > latest_input_event_timestamp_) {
+ // If the timestamp in this video packet has changed from the one we stored
+ // for the previous input event, then it is the first video packet following
+ // that event. We'll use that timestamp to record round-trip latency.
+ latest_input_event_timestamp_ = packet.latest_event_timestamp();
+
+ base::TimeDelta round_trip_latency =
+ base::Time::Now() -
+ base::Time::FromInternalValue(packet.latest_event_timestamp());
+
+ round_trip_ms_.Record(round_trip_latency.InMilliseconds());
+
+ if (!uma_custom_times_updater_.is_null())
+ uma_custom_times_updater_.Run(
+ kRoundTripLatencyHistogram, round_trip_latency.InMilliseconds(),
+ kLatencyHistogramMinMs, kLatencyHistogramMaxMs,
+ kLatencyHistogramBuckets);
+ }
+}
+
+void ChromotingStats::RecordDecodeTime(double value) {
+ video_decode_ms_.Record(value);
+ if (!uma_custom_times_updater_.is_null())
+ uma_custom_times_updater_.Run(
+ kVideoDecodeLatencyHistogram, value, kVideoActionsHistogramsMinMs,
+ kVideoActionsHistogramsMaxMs, kVideoActionsHistogramsBuckets);
+}
+
+void ChromotingStats::RecordPaintTime(double value) {
+ video_paint_ms_.Record(value);
+ if (!uma_custom_times_updater_.is_null())
+ uma_custom_times_updater_.Run(
+ kVideoPaintLatencyHistogram, value, kVideoActionsHistogramsMinMs,
+ kVideoActionsHistogramsMaxMs, kVideoActionsHistogramsBuckets);
+}
+
+void ChromotingStats::UploadRateStatsToUma() {
+ if (!uma_enum_histogram_updater_.is_null()) {
+ uma_enum_histogram_updater_.Run(kVideoFrameRateHistogram,
+ video_frame_rate(), kMaxFramesPerSec);
+ uma_enum_histogram_updater_.Run(kVideoPacketRateHistogram,
+ video_packet_rate(), kMaxFramesPerSec);
+ uma_custom_counts_updater_.Run(
+ kVideoBandwidthHistogram, video_bandwidth(), kBandwidthHistogramMinBps,
+ kBandwidthHistogramMaxBps, kBandwidthHistogramBuckets);
+ }
+}
+
} // namespace remoting
diff --git a/remoting/client/chromoting_stats.h b/remoting/client/chromoting_stats.h
index 2826034..5e8a93b 100644
--- a/remoting/client/chromoting_stats.h
+++ b/remoting/client/chromoting_stats.h
@@ -8,13 +8,29 @@
#ifndef REMOTING_CLIENT_CHROMOTING_STATS_H_
#define REMOTING_CLIENT_CHROMOTING_STATS_H_
+#include "base/callback.h"
#include "remoting/base/rate_counter.h"
#include "remoting/base/running_average.h"
namespace remoting {
+class VideoPacket;
+
class ChromotingStats {
public:
+ // Callback that updates UMA custom counts or custom times histograms.
+ typedef base::Callback<void(const std::string& histogram_name,
+ int64 value,
+ int histogram_min,
+ int histogram_max,
+ int histogram_buckets)>
+ UpdateUmaCustomHistogramCallback;
+
+ // Callback that updates UMA enumeration histograms.
+ typedef base::Callback<
+ void(const std::string& histogram_name, int64 value, int histogram_max)>
+ UpdateUmaEnumHistogramCallback;
+
ChromotingStats();
virtual ~ChromotingStats();
@@ -22,39 +38,64 @@ class ChromotingStats {
// plugin for the frequency at which stats should be updated.
static const int kStatsUpdateFrequencyInSeconds = 1;
+ // Return rates and running-averages for different metrics.
+ double video_bandwidth() { return video_bandwidth_.Rate(); }
+ double video_frame_rate() { return video_frame_rate_.Rate(); }
+ double video_packet_rate() { return video_packet_rate_.Rate(); }
+ double video_capture_ms() { return video_capture_ms_.Average(); }
+ double video_encode_ms() { return video_encode_ms_.Average(); }
+ double video_decode_ms() { return video_decode_ms_.Average(); }
+ double video_paint_ms() { return video_paint_ms_.Average(); }
+ double round_trip_ms() { return round_trip_ms_.Average(); }
+
+ // Record stats for a video-packet.
+ void RecordVideoPacketStats(const VideoPacket& packet);
+
+ void RecordDecodeTime(double value);
+ void RecordPaintTime(double value);
+
+ // Sets callbacks in ChromotingInstance to update a UMA custom counts, custom
+ // times or enum histogram.
+ void SetUpdateUmaCallbacks(
+ UpdateUmaCustomHistogramCallback update_uma_custom_counts_callback,
+ UpdateUmaCustomHistogramCallback update_uma_custom_times_callback,
+ UpdateUmaEnumHistogramCallback update_uma_enum_histogram_callback);
+
+ // Updates frame-rate, packet-rate and bandwidth UMA statistics.
+ void UploadRateStatsToUma();
+
+ private:
// The video and packet rate metrics below are updated per video packet
// received and then, for reporting, averaged over a 1s time-window.
// Bytes per second for non-empty video-packets.
- RateCounter* video_bandwidth() { return &video_bandwidth_; }
+ RateCounter video_bandwidth_;
// Frames per second for non-empty video-packets.
- RateCounter* video_frame_rate() { return &video_frame_rate_; }
+ RateCounter video_frame_rate_;
// Video packets per second, including empty video-packets.
// This will be greater than the frame rate, as individual frames are
// contained in packets, some of which might be empty (e.g. when there are no
// screen changes).
- RateCounter* video_packet_rate() { return &video_packet_rate_; }
-
- // The latency metrics below are recorded per video packet received and, for
- // reporting, averaged over the N most recent samples.
- // N is defined by kLatencySampleSize.
- RunningAverage* video_capture_ms() { return &video_capture_ms_; }
- RunningAverage* video_encode_ms() { return &video_encode_ms_; }
- RunningAverage* video_decode_ms() { return &video_decode_ms_; }
- RunningAverage* video_paint_ms() { return &video_paint_ms_; }
- RunningAverage* round_trip_ms() { return &round_trip_ms_; }
-
- private:
- RateCounter video_bandwidth_;
- RateCounter video_frame_rate_;
RateCounter video_packet_rate_;
+
+ // The following running-averages are uploaded to UMA per video packet and
+ // also used for display to users, averaged over the N most recent samples.
+ // N = kLatencySampleSize.
RunningAverage video_capture_ms_;
RunningAverage video_encode_ms_;
RunningAverage video_decode_ms_;
RunningAverage video_paint_ms_;
RunningAverage round_trip_ms_;
+ // Used to update UMA stats, if set.
+ UpdateUmaCustomHistogramCallback uma_custom_counts_updater_;
+ UpdateUmaCustomHistogramCallback uma_custom_times_updater_;
+ UpdateUmaEnumHistogramCallback uma_enum_histogram_updater_;
+
+ // The latest input timestamp that a VideoPacket was seen annotated with.
+ int64 latest_input_event_timestamp_ = 0;
+
DISALLOW_COPY_AND_ASSIGN(ChromotingStats);
};
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index fb29170..28edc49 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -61,25 +61,6 @@ namespace {
// Default DPI to assume for old clients that use notifyClientResolution.
const int kDefaultDPI = 96;
-// The boundary value for the FPS histogram: we don't expect video frame-rate to
-// be greater than 40fps. Leaving some room for future improvements, we'll set
-// the max frame rate to 60fps.
-// Histograms expect samples to be less than the boundary value, so set to 61.
-const int kMaxFramesPerSec = 61;
-
-// For bandwidth, based on expected real-world numbers, we'll use a histogram
-// ranging from 0 to 10MB/s, spread across 100 buckets.
-// Histograms are log-scaled by default. This results in fine-grained buckets at
-// lower values and wider-ranged buckets closer to the maximum.
-// Values above the maximum defined here are not discarded; they end up in the
-// max-bucket.
-// Note: if the minimum for a UMA histogram is set to be < 1, it is implicitly
-// normalized to 1.
-// See $/src/base/metrics/histogram.h for more details.
-const int kBandwidthHistogramMinBps = 0;
-const int kBandwidthHistogramMaxBps = 10 * 1000 * 1000;
-const int kBandwidthHistogramBuckets = 100;
-
// Size of the random seed blob used to initialize RNG in libjingle. OpenSSL
// needs at least 32 bytes of entropy (see
// http://wiki.openssl.org/index.php/Random_Numbers), but stores 1039 bytes of
@@ -592,6 +573,14 @@ void ChromotingInstance::HandleConnect(const base::DictionaryValue& data) {
CHECK(video_renderer_);
+ video_renderer_->GetStats()->SetUpdateUmaCallbacks(
+ base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram,
+ weak_factory_.GetWeakPtr(), true),
+ base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram,
+ weak_factory_.GetWeakPtr(), false),
+ base::Bind(&ChromotingInstance::UpdateUmaEnumHistogram,
+ weak_factory_.GetWeakPtr()));
+
if (!plugin_view_.is_null())
video_renderer_->OnViewChanged(plugin_view_);
@@ -977,26 +966,19 @@ void ChromotingInstance::SendPerfStats() {
// for display to users.
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
ChromotingStats* stats = video_renderer_->GetStats();
- data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate());
- data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate());
- data->SetDouble("captureLatency", stats->video_capture_ms()->Average());
- data->SetDouble("encodeLatency", stats->video_encode_ms()->Average());
- data->SetDouble("decodeLatency", stats->video_decode_ms()->Average());
- data->SetDouble("renderLatency", stats->video_paint_ms()->Average());
- data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average());
+ data->SetDouble("videoBandwidth", stats->video_bandwidth());
+ data->SetDouble("videoFrameRate", stats->video_frame_rate());
+ data->SetDouble("captureLatency", stats->video_capture_ms());
+ data->SetDouble("encodeLatency", stats->video_encode_ms());
+ data->SetDouble("decodeLatency", stats->video_decode_ms());
+ data->SetDouble("renderLatency", stats->video_paint_ms());
+ data->SetDouble("roundtripLatency", stats->round_trip_ms());
PostLegacyJsonMessage("onPerfStats", data.Pass());
// Record the video frame-rate, packet-rate and bandwidth stats to UMA.
- pp::UMAPrivate uma(this);
- uma.HistogramEnumeration("Chromoting.Video.FrameRate",
- stats->video_frame_rate()->Rate(), kMaxFramesPerSec);
- uma.HistogramEnumeration("Chromoting.Video.PacketRate",
- stats->video_packet_rate()->Rate(),
- kMaxFramesPerSec);
- uma.HistogramCustomCounts(
- "Chromoting.Video.Bandwidth", stats->video_bandwidth()->Rate(),
- kBandwidthHistogramMinBps, kBandwidthHistogramMaxBps,
- kBandwidthHistogramBuckets);
+ // TODO(anandc): Create a timer in ChromotingStats to do this work.
+ // See http://crbug/508602.
+ stats->UploadRateStatsToUma();
}
// static
@@ -1069,4 +1051,29 @@ bool ChromotingInstance::IsConnected() {
(client_->connection_state() == protocol::ConnectionToHost::CONNECTED);
}
+void ChromotingInstance::UpdateUmaEnumHistogram(
+ const std::string& histogram_name,
+ int64 value,
+ int histogram_max) {
+ pp::UMAPrivate uma(this);
+ uma.HistogramEnumeration(histogram_name, value, histogram_max);
+}
+
+void ChromotingInstance::UpdateUmaCustomHistogram(
+ bool is_custom_counts_histogram,
+ const std::string& histogram_name,
+ int64 value,
+ int histogram_min,
+ int histogram_max,
+ int histogram_buckets) {
+ pp::UMAPrivate uma(this);
+
+ if (is_custom_counts_histogram)
+ uma.HistogramCustomCounts(histogram_name, value, histogram_min,
+ histogram_max, histogram_buckets);
+ else
+ uma.HistogramCustomTimes(histogram_name, value, histogram_min,
+ histogram_max, histogram_buckets);
+}
+
} // namespace remoting
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index 9df624e..09c2252 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -17,6 +17,7 @@
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/text_input_controller.h"
#include "ppapi/cpp/var.h"
+#include "remoting/client/chromoting_stats.h"
#include "remoting/client/client_context.h"
#include "remoting/client/client_user_interface.h"
#include "remoting/client/empty_cursor_filter.h"
@@ -164,6 +165,20 @@ class ChromotingInstance : public ClientUserInterface,
const std::string& scope,
const base::WeakPtr<TokenFetcherProxy> pepper_token_fetcher);
+ // Updates the specified UMA enumeration histogram with the input value.
+ void UpdateUmaEnumHistogram(const std::string& histogram_name,
+ int64 value,
+ int histogram_max);
+
+ // Updates the specified UMA custom counts or custom times histogram with the
+ // input value.
+ void UpdateUmaCustomHistogram(bool is_custom_counts_histogram,
+ const std::string& histogram_name,
+ int64 value,
+ int histogram_min,
+ int histogram_max,
+ int histogram_buckets);
+
private:
FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup);
diff --git a/remoting/client/plugin/pepper_video_renderer_2d.cc b/remoting/client/plugin/pepper_video_renderer_2d.cc
index e7d6f24..feca26b 100644
--- a/remoting/client/plugin/pepper_video_renderer_2d.cc
+++ b/remoting/client/plugin/pepper_video_renderer_2d.cc
@@ -361,7 +361,7 @@ void PepperVideoRenderer2D::OnFlushDone(int result,
DCHECK(CalledOnValidThread());
DCHECK(flush_pending_);
- software_video_renderer_->GetStats()->video_paint_ms()->Record(
+ software_video_renderer_->GetStats()->RecordPaintTime(
(base::Time::Now() - paint_start).InMilliseconds());
flush_pending_ = false;
diff --git a/remoting/client/plugin/pepper_video_renderer_3d.cc b/remoting/client/plugin/pepper_video_renderer_3d.cc
index 4aec10f..31bebc1 100644
--- a/remoting/client/plugin/pepper_video_renderer_3d.cc
+++ b/remoting/client/plugin/pepper_video_renderer_3d.cc
@@ -13,6 +13,7 @@
#include "ppapi/cpp/instance.h"
#include "ppapi/lib/gl/include/GLES2/gl2.h"
#include "ppapi/lib/gl/include/GLES2/gl2ext.h"
+#include "remoting/client/chromoting_stats.h"
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/session_config.h"
@@ -57,7 +58,6 @@ PepperVideoRenderer3D::FrameDecodeTimestamp::FrameDecodeTimestamp(
PepperVideoRenderer3D::PepperVideoRenderer3D()
: event_handler_(nullptr),
- latest_input_event_timestamp_(0),
initialization_finished_(false),
decode_pending_(false),
get_picture_pending_(false),
@@ -189,31 +189,13 @@ void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
const base::Closure& done) {
base::ScopedClosureRunner done_runner(done);
- // Record this received packet, even if it is empty.
- stats_.video_packet_rate()->Record(1);
+ stats_.RecordVideoPacketStats(*packet);
// Don't need to do anything if the packet is empty. Host sends empty video
// packets when the screen is not changing.
if (!packet->data().size())
return;
- // Update statistics.
- // TODO(anandc): Move to ChromotingStats - see http://crbug/508602
- stats_.video_frame_rate()->Record(1);
- stats_.video_bandwidth()->Record(packet->data().size());
- if (packet->has_capture_time_ms())
- stats_.video_capture_ms()->Record(packet->capture_time_ms());
- if (packet->has_encode_time_ms())
- stats_.video_encode_ms()->Record(packet->encode_time_ms());
- if (packet->has_latest_event_timestamp() &&
- packet->latest_event_timestamp() > latest_input_event_timestamp_) {
- latest_input_event_timestamp_ = packet->latest_event_timestamp();
- base::TimeDelta round_trip_latency =
- base::Time::Now() -
- base::Time::FromInternalValue(packet->latest_event_timestamp());
- stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
- }
-
bool resolution_changed = false;
if (packet->format().has_screen_width() &&
@@ -352,7 +334,8 @@ void PepperVideoRenderer3D::OnPictureReady(int32_t result,
base::TimeDelta decode_time =
base::TimeTicks::Now() - frame_timer.decode_started_time;
- stats_.video_decode_ms()->Record(decode_time.InMilliseconds());
+ stats_.RecordDecodeTime(decode_time.InMilliseconds());
+
frame_decode_timestamps_.pop_front();
next_picture_.reset(new Picture(&video_decoder_, picture));
@@ -433,8 +416,7 @@ void PepperVideoRenderer3D::OnPaintDone(int32_t result) {
paint_pending_ = false;
base::TimeDelta paint_time =
base::TimeTicks::Now() - latest_paint_started_time_;
- stats_.video_paint_ms()->Record(paint_time.InMilliseconds());
-
+ stats_.RecordPaintTime(paint_time.InMilliseconds());
PaintIfNeeded();
}
diff --git a/remoting/client/plugin/pepper_video_renderer_3d.h b/remoting/client/plugin/pepper_video_renderer_3d.h
index 5783c44..3e0889f 100644
--- a/remoting/client/plugin/pepper_video_renderer_3d.h
+++ b/remoting/client/plugin/pepper_video_renderer_3d.h
@@ -108,7 +108,6 @@ class PepperVideoRenderer3D : public PepperVideoRenderer,
webrtc::DesktopSize view_size_;
ChromotingStats stats_;
- int64 latest_input_event_timestamp_ ;
bool initialization_finished_;
bool decode_pending_;
diff --git a/remoting/client/server_log_entry_client.cc b/remoting/client/server_log_entry_client.cc
index 2f781502..5d1a1a9 100644
--- a/remoting/client/server_log_entry_client.cc
+++ b/remoting/client/server_log_entry_client.cc
@@ -115,17 +115,17 @@ scoped_ptr<ServerLogEntry> MakeLogEntryForStatistics(
entry->AddEventNameField(kValueEventNameStatistics);
entry->Set("video-bandwidth",
- StringPrintf("%.2f", statistics->video_bandwidth()->Rate()));
+ StringPrintf("%.2f", statistics->video_bandwidth()));
entry->Set("capture-latency",
- StringPrintf("%.2f", statistics->video_capture_ms()->Average()));
+ StringPrintf("%.2f", statistics->video_capture_ms()));
entry->Set("encode-latency",
- StringPrintf("%.2f", statistics->video_encode_ms()->Average()));
+ StringPrintf("%.2f", statistics->video_encode_ms()));
entry->Set("decode-latency",
- StringPrintf("%.2f", statistics->video_decode_ms()->Average()));
+ StringPrintf("%.2f", statistics->video_decode_ms()));
entry->Set("render-latency",
- StringPrintf("%.2f", statistics->video_frame_rate()->Rate()));
+ StringPrintf("%.2f", statistics->video_frame_rate()));
entry->Set("roundtrip-latency",
- StringPrintf("%.2f", statistics->round_trip_ms()->Average()));
+ StringPrintf("%.2f", statistics->round_trip_ms()));
return entry.Pass();
}
diff --git a/remoting/client/software_video_renderer.cc b/remoting/client/software_video_renderer.cc
index 05edf5b..c8e2573 100644
--- a/remoting/client/software_video_renderer.cc
+++ b/remoting/client/software_video_renderer.cc
@@ -317,7 +317,6 @@ SoftwareVideoRenderer::SoftwareVideoRenderer(
scoped_ptr<FrameConsumerProxy> consumer)
: decode_task_runner_(decode_task_runner),
core_(new Core(main_task_runner, decode_task_runner, consumer.Pass())),
- latest_event_timestamp_(0),
weak_factory_(this) {
DCHECK(CalledOnValidThread());
}
@@ -346,37 +345,18 @@ protocol::VideoStub* SoftwareVideoRenderer::GetVideoStub() {
}
void SoftwareVideoRenderer::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
- const base::Closure& done) {
+ const base::Closure& done) {
DCHECK(CalledOnValidThread());
- // Record this received packet, even if it is empty.
- stats_.video_packet_rate()->Record(1);
+ stats_.RecordVideoPacketStats(*packet);
// If the video packet is empty then drop it. Empty packets are used to
// maintain activity on the network.
if (!packet->has_data() || packet->data().size() == 0) {
- done.Run();
+ decode_task_runner_->PostTask(FROM_HERE, done);
return;
}
- // Add one frame to the video frame rate counter.
- stats_.video_frame_rate()->Record(1);
-
- // Record other statistics received from host.
- stats_.video_bandwidth()->Record(packet->data().size());
- if (packet->has_capture_time_ms())
- stats_.video_capture_ms()->Record(packet->capture_time_ms());
- if (packet->has_encode_time_ms())
- stats_.video_encode_ms()->Record(packet->encode_time_ms());
- if (packet->has_latest_event_timestamp() &&
- packet->latest_event_timestamp() > latest_event_timestamp_) {
- latest_event_timestamp_ = packet->latest_event_timestamp();
- base::TimeDelta round_trip_latency =
- base::Time::Now() -
- base::Time::FromInternalValue(packet->latest_event_timestamp());
- stats_.round_trip_ms()->Record(round_trip_latency.InMilliseconds());
- }
-
// Measure the latency between the last packet being received and presented.
base::Time decode_start = base::Time::Now();
@@ -419,14 +399,14 @@ void SoftwareVideoRenderer::SetOutputSizeAndClip(
}
void SoftwareVideoRenderer::OnPacketDone(base::Time decode_start,
- const base::Closure& done) {
+ const base::Closure& done) {
DCHECK(CalledOnValidThread());
// Record the latency between the packet being received and presented.
- stats_.video_decode_ms()->Record(
- (base::Time::Now() - decode_start).InMilliseconds());
+ base::TimeDelta decode_time = base::Time::Now() - decode_start;
+ stats_.RecordDecodeTime(decode_time.InMilliseconds());
- done.Run();
+ decode_task_runner_->PostTask(FROM_HERE, done);
}
} // namespace remoting
diff --git a/remoting/client/software_video_renderer.h b/remoting/client/software_video_renderer.h
index e6a9a5e..4fbf7fd 100644
--- a/remoting/client/software_video_renderer.h
+++ b/remoting/client/software_video_renderer.h
@@ -76,9 +76,6 @@ class SoftwareVideoRenderer : public VideoRenderer,
ChromotingStats stats_;
- // Keep track of the latest event timestamp bounced back from the host.
- int64 latest_event_timestamp_;
-
base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer);