• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEFINES_H_
6 #define MEDIA_CAST_LOGGING_LOGGING_DEFINES_H_
7 
8 #include <map>
9 #include <string>
10 #include <vector>
11 
12 #include "base/memory/linked_ptr.h"
13 #include "base/time/time.h"
14 
15 namespace media {
16 namespace cast {
17 
18 static const uint32 kFrameIdUnknown = 0xFFFF;
19 
20 struct CastLoggingConfig {
21   CastLoggingConfig();
22   ~CastLoggingConfig();
23 
24   bool enable_data_collection;
25   bool enable_uma_stats;
26   bool enable_tracing;
27 };
28 
29 // By default, enable raw and stats data collection. Disable tracing and UMA.
30 CastLoggingConfig GetDefaultCastLoggingConfig();
31 
32 enum CastLoggingEvent {
33   // Generic events.
34   kUnknown,
35   kRttMs,
36   kPacketLoss,
37   kJitterMs,
38   kAckReceived,
39   kRembBitrate,
40   kAckSent,
41   kLastEvent,
42   // Audio sender.
43   kAudioFrameReceived,
44   kAudioFrameCaptured,
45   kAudioFrameEncoded,
46   // Audio receiver.
47   kAudioPlayoutDelay,
48   kAudioFrameDecoded,
49   // Video sender.
50   kVideoFrameCaptured,
51   kVideoFrameReceived,
52   kVideoFrameSentToEncoder,
53   kVideoFrameEncoded,
54   // Video receiver.
55   kVideoFrameDecoded,
56   kVideoRenderDelay,
57   // Send-side packet events.
58   kPacketSentToPacer,
59   kPacketSentToNetwork,
60   kPacketRetransmited,
61   // Receive-side packet events.
62   kPacketReceived,
63 
64   kNumOfLoggingEvents,
65 };
66 
67 std::string CastLoggingToString(CastLoggingEvent event);
68 
69 struct FrameEvent {
70   FrameEvent();
71   ~FrameEvent();
72 
73   uint32 frame_id;
74   size_t size;  // Encoded size only.
75   std::vector<base::TimeTicks> timestamp;
76   std::vector<CastLoggingEvent> type;
77   base::TimeDelta delay_delta;  // Render/playout delay.
78 };
79 
80 // Internal map sorted by packet id.
81 struct BasePacketInfo {
82   BasePacketInfo();
83   ~BasePacketInfo();
84 
85   size_t size;
86   std::vector<base::TimeTicks> timestamp;
87   std::vector<CastLoggingEvent> type;
88 };
89 
90 typedef std::map<uint16, BasePacketInfo> BasePacketMap;
91 
92 struct PacketEvent {
93   PacketEvent();
94   ~PacketEvent();
95   uint32 frame_id;
96   int max_packet_id;
97   BasePacketMap packet_map;
98 };
99 
100 struct GenericEvent {
101   GenericEvent();
102   ~GenericEvent();
103   std::vector<int> value;
104   std::vector<base::TimeTicks> timestamp;
105 };
106 
107 struct FrameLogStats {
108   FrameLogStats();
109   ~FrameLogStats();
110 
111   double framerate_fps;
112   double bitrate_kbps;
113   int max_delay_ms;
114   int min_delay_ms;
115   int avg_delay_ms;
116 };
117 
118 // Store all log types in a map based on the event.
119 typedef std::map<uint32, FrameEvent> FrameRawMap;
120 typedef std::map<uint32, PacketEvent> PacketRawMap;
121 typedef std::map<CastLoggingEvent, GenericEvent> GenericRawMap;
122 
123 typedef std::map<CastLoggingEvent, linked_ptr<FrameLogStats > > FrameStatsMap;
124 typedef std::map<CastLoggingEvent, double> PacketStatsMap;
125 typedef std::map<CastLoggingEvent, double> GenericStatsMap;
126 
127 }  // namespace cast
128 }  // namespace media
129 
130 #endif  // MEDIA_CAST_LOGGING_LOGGING_DEFINES_H_
131