summaryrefslogtreecommitdiff
path: root/media/cast/logging/logging_stats.h
blob: 65dccbd7b4d8d482250aa392ffa66b73c2f34559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_CAST_LOGGING_LOGGING_STATS_H_
#define MEDIA_CAST_LOGGING_LOGGING_STATS_H_

#include "base/basictypes.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "media/cast/logging/logging_defines.h"

namespace media {
namespace cast {

const int kNumberOfEvents = 19;

class LoggingStats {
 public:
  explicit LoggingStats(base::TickClock* clock);

  ~LoggingStats();

  void Reset();

  void InsertFrameEvent(CastLoggingEvent event,
                        uint32 rtp_timestamp,
                        uint8 frame_id);

  void InsertFrameEventWithSize(CastLoggingEvent event,
                                uint32 rtp_timestamp,
                                uint8 frame_id,
                                int frame_size);

  void InsertFrameEventWithDelay(CastLoggingEvent event,
                                 uint32 rtp_timestamp,
                                 uint8 frame_id,
                                 base::TimeDelta delay);

  void InsertPacketEvent(CastLoggingEvent event,
                         uint32 rtp_timestamp,
                         uint8 frame_id,
                         uint16 packet_id,
                         uint16 max_packet_id,
                         int size);

  void InsertGenericEvent(CastLoggingEvent event, int value);

  // Get log stats: some of the values, such as frame rate and bit rates are
  // computed at the time of the call.
  const FrameStatsMap* GetFrameStatsData();

  const PacketStatsMap* GetPacketStatsData();

  const GenericStatsMap* GetGenericStatsData();

 private:
  void InsertBaseFrameEvent(CastLoggingEvent event,
                            uint8 frame_id,
                            uint32 rtp_timestamp);
  FrameStatsMap frame_stats_;
  PacketStatsMap packet_stats_;
  GenericStatsMap generic_stats_;
  // Every event has an individual start time
  base::TimeTicks start_time_[kNumberOfEvents];
  // Keep track of event counts.
  int counts_[kNumberOfEvents];
  base::TickClock* const clock_;  // Not owned by this class.

  DISALLOW_COPY_AND_ASSIGN(LoggingStats);
 };

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_LOGGING_LOGGING_STATS_H_