Index: media/cast/logging/stats_event_subscriber.h |
diff --git a/media/cast/logging/stats_event_subscriber.h b/media/cast/logging/stats_event_subscriber.h |
index 06ceaca9ed2f1ab51df576353c4ed0ff4c9a66d2..8e0029e573e8141dd91ec178892f7e470cd4f66b 100644 |
--- a/media/cast/logging/stats_event_subscriber.h |
+++ b/media/cast/logging/stats_event_subscriber.h |
@@ -6,6 +6,7 @@ |
#define MEDIA_CAST_LOGGING_STATS_EVENT_SUBSCRIBER_H_ |
#include "base/gtest_prod_util.h" |
+#include "base/memory/linked_ptr.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/threading/thread_checker.h" |
#include "base/time/tick_clock.h" |
@@ -15,6 +16,7 @@ |
namespace base { |
class DictionaryValue; |
+class ListValue; |
} |
namespace media { |
@@ -76,6 +78,34 @@ class StatsEventSubscriber : public RawEventSubscriber { |
size_t sum_size; |
}; |
+ class SimpleHistogram { |
+ public: |
+ // This will create N+2 buckets where N = (max - min) / width: |
+ // Underflow bucket: < min |
+ // Bucket 0: [min, min + width - 1] |
+ // Bucket 1: [min + width, min + 2 * width - 1] |
+ // ... |
+ // Bucket N-1: [max - width, max - 1] |
+ // Overflow bucket: >= max |
+ // |min| must be less than |max|. |
+ // |width| must divide |max - min| evenly. |
+ SimpleHistogram(int64 min, int64 max, int64 width); |
+ |
+ ~SimpleHistogram(); |
+ |
+ void Add(int64 sample); |
+ |
+ void Reset(); |
+ |
+ scoped_ptr<base::ListValue> GetHistogram() const; |
+ |
+ private: |
+ int64 min_; |
+ int64 max_; |
+ int64 width_; |
+ std::vector<int> buckets_; |
+ }; |
+ |
enum CastStat { |
// Capture frame rate. |
CAPTURE_FPS, |
@@ -116,17 +146,33 @@ class StatsEventSubscriber : public RawEventSubscriber { |
NUM_PACKETS_RETRANSMITTED, |
// Number of packets that had their retransmission cancelled. |
NUM_PACKETS_RTX_REJECTED, |
+ // Duration since last reset. |
+ DURATION_MS, |
+ // Unix time in milliseconds of first event since reset. |
+ FIRST_EVENT_TIME_MS, |
+ // Unix time in milliseconds of last event since reset. |
+ LAST_EVENT_TIME_MS, |
+ |
+ // Histograms |
+ CAPTURE_LATENCY_MS_HISTO, |
+ ENCODE_LATENCY_MS_HISTO, |
+ PACKET_LATENCY_MS_HISTO, |
+ FRAME_LATENCY_MS_HISTO, |
+ PLAYOUT_DELAY_MS_HISTO |
}; |
struct FrameInfo { |
- explicit FrameInfo(base::TimeTicks capture_time); |
+ FrameInfo(); |
~FrameInfo(); |
base::TimeTicks capture_time; |
+ base::TimeTicks capture_end_time; |
+ base::TimeTicks encode_time; |
bool encoded; |
}; |
typedef std::map<CastStat, double> StatsMap; |
+ typedef std::map<CastStat, linked_ptr<SimpleHistogram> > HistogramMap; |
typedef std::map<RtpTimestamp, FrameInfo> FrameInfoMap; |
typedef std::map< |
std::pair<RtpTimestamp, uint16>, |
@@ -137,12 +183,20 @@ class StatsEventSubscriber : public RawEventSubscriber { |
static const char* CastStatToString(CastStat stat); |
+ void InitHistograms(); |
+ |
// Assigns |stats_map| with stats data. Used for testing. |
void GetStatsInternal(StatsMap* stats_map) const; |
+ void UpdateFirstLastEventTime(base::TimeTicks timestamp, |
+ bool is_receiver_event); |
bool GetReceiverOffset(base::TimeDelta* offset); |
+ void MaybeInsertFrameInfo(RtpTimestamp rtp_timestamp, |
+ const FrameInfo& frame_info); |
void RecordFrameCaptureTime(const FrameEvent& frame_event); |
- void MarkAsEncoded(RtpTimestamp rtp_timestamp); |
+ void RecordCaptureLatency(const FrameEvent& frame_event); |
+ void RecordEncodeLatency(const FrameEvent& frame_event); |
+ void RecordFrameTxLatency(const FrameEvent& frame_event); |
void RecordE2ELatency(const FrameEvent& frame_event); |
void RecordPacketSentTime(const PacketEvent& packet_event); |
void ErasePacketSentTime(const PacketEvent& packet_event); |
@@ -189,13 +243,17 @@ class StatsEventSubscriber : public RawEventSubscriber { |
int num_frames_late_; |
// Fixed size map to record when recent frames were captured and other info. |
- FrameInfoMap recent_captured_frames_; |
+ FrameInfoMap recent_frame_infos_; |
// Fixed size map to record when recent packets were sent. |
PacketEventTimeMap packet_sent_times_; |
// Sender time assigned on creation and |Reset()|. |
base::TimeTicks start_time_; |
+ base::TimeTicks first_event_time_; |
+ base::TimeTicks last_event_time_; |
+ |
+ HistogramMap histograms_; |
base::ThreadChecker thread_checker_; |
DISALLOW_COPY_AND_ASSIGN(StatsEventSubscriber); |