OLD | NEW |
| (Empty) |
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_INTERNAL_H_ | |
6 #define MEDIA_CAST_LOGGING_LOGGING_INTERNAL_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/time/tick_clock.h" | |
14 #include "base/time/time.h" | |
15 | |
16 namespace media { | |
17 namespace cast { | |
18 | |
19 // TODO(mikhal): Consider storing only the delta time and not absolute time. | |
20 struct FrameEvent { | |
21 uint32 frame_id; | |
22 int size; | |
23 base::TimeTicks timestamp; | |
24 base::TimeDelta delay_delta; // render/playout delay. | |
25 }; | |
26 | |
27 struct PacketEvent { | |
28 uint32 frame_id; | |
29 int max_packet_id; | |
30 size_t size; | |
31 base::TimeTicks timestamp; | |
32 }; | |
33 | |
34 // Frame and packet maps are sorted based on the rtp_timestamp. | |
35 typedef std::map<uint32, FrameEvent> FrameMap; | |
36 typedef std::map<uint16, PacketEvent> BasePacketMap; | |
37 typedef std::map<uint32, BasePacketMap> PacketMap; | |
38 | |
39 class FrameLogData { | |
40 public: | |
41 explicit FrameLogData(base::TickClock* clock); | |
42 ~FrameLogData(); | |
43 void Insert(uint32 rtp_timestamp, uint32 frame_id); | |
44 // Include size for encoded images (compute bitrate), | |
45 void InsertWithSize(uint32 rtp_timestamp, uint32 frame_id, int size); | |
46 // Include playout/render delay info. | |
47 void InsertWithDelay( | |
48 uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay); | |
49 void Reset(); | |
50 | |
51 private: | |
52 void InsertBase(uint32 rtp_timestamp, uint32 frame_id, FrameEvent info); | |
53 | |
54 base::TickClock* const clock_; // Not owned by this class. | |
55 FrameMap frame_map_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(FrameLogData); | |
58 }; | |
59 | |
60 // TODO(mikhal): Should be able to handle packet bursts. | |
61 class PacketLogData { | |
62 public: | |
63 explicit PacketLogData(base::TickClock* clock); | |
64 ~PacketLogData(); | |
65 void Insert(uint32 rtp_timestamp, uint32 frame_id, uint16 packet_id, | |
66 uint16 max_packet_id, int size); | |
67 void Reset(); | |
68 | |
69 private: | |
70 base::TickClock* const clock_; // Not owned by this class. | |
71 PacketMap packet_map_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(PacketLogData); | |
74 }; | |
75 | |
76 class GenericLogData { | |
77 public: | |
78 explicit GenericLogData(base::TickClock* clock); | |
79 ~GenericLogData(); | |
80 void Insert(int value); | |
81 void Reset(); | |
82 | |
83 private: | |
84 base::TickClock* const clock_; // Not owned by this class. | |
85 std::vector<int> data_; | |
86 std::vector<base::TimeTicks> timestamp_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(GenericLogData); | |
89 }; | |
90 | |
91 | |
92 } // namespace cast | |
93 } // namespace media | |
94 | |
95 #endif // MEDIA_CAST_LOGGING_LOGGING_INTERNAL_H_ | |
OLD | NEW |