Home | History | Annotate | Download | only in logging
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MEDIA_CAST_LOGGING_LOGGING_STATS_H_
      6 #define MEDIA_CAST_LOGGING_LOGGING_STATS_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/time/tick_clock.h"
     10 #include "base/time/time.h"
     11 #include "media/cast/logging/logging_defines.h"
     12 
     13 namespace media {
     14 namespace cast {
     15 
     16 class LoggingStats {
     17  public:
     18   explicit LoggingStats(base::TickClock* clock);
     19 
     20   ~LoggingStats();
     21 
     22   void Reset();
     23 
     24   void InsertFrameEvent(CastLoggingEvent event,
     25                         uint32 rtp_timestamp,
     26                         uint32 frame_id);
     27 
     28   void InsertFrameEventWithSize(CastLoggingEvent event,
     29                                 uint32 rtp_timestamp,
     30                                 uint32 frame_id,
     31                                 int frame_size);
     32 
     33   void InsertFrameEventWithDelay(CastLoggingEvent event,
     34                                  uint32 rtp_timestamp,
     35                                  uint32 frame_id,
     36                                  base::TimeDelta delay);
     37 
     38   void InsertPacketEvent(CastLoggingEvent event,
     39                          uint32 rtp_timestamp,
     40                          uint32 frame_id,
     41                          uint16 packet_id,
     42                          uint16 max_packet_id,
     43                          size_t size);
     44 
     45   void InsertGenericEvent(CastLoggingEvent event, int value);
     46 
     47   // Get log stats: some of the values, such as frame rate and bit rates are
     48   // computed at the time of the call.
     49   const FrameStatsMap* GetFrameStatsData();
     50 
     51   const PacketStatsMap* GetPacketStatsData();
     52 
     53   const GenericStatsMap* GetGenericStatsData();
     54 
     55  private:
     56   void InsertBaseFrameEvent(CastLoggingEvent event,
     57                             uint32 frame_id,
     58                             uint32 rtp_timestamp);
     59   FrameStatsMap frame_stats_;
     60   PacketStatsMap packet_stats_;
     61   GenericStatsMap generic_stats_;
     62   // Every event has an individual start time
     63   base::TimeTicks start_time_[kNumOfLoggingEvents];
     64   // Keep track of event counts.
     65   int counts_[kNumOfLoggingEvents];
     66   base::TickClock* const clock_;  // Not owned by this class.
     67 
     68   DISALLOW_COPY_AND_ASSIGN(LoggingStats);
     69  };
     70 
     71 }  // namespace cast
     72 }  // namespace media
     73 
     74 #endif  // MEDIA_CAST_LOGGING_LOGGING_STATS_H_
     75 
     76