- add sources.
[platform/framework/web/crosswalk.git] / src / media / cast / logging / logging_raw.h
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_RAW_H_
6 #define MEDIA_CAST_LOGGING_LOGGING_RAW_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "base/time/tick_clock.h"
17 #include "media/cast/logging/logging_defines.h"
18
19 namespace media {
20 namespace cast {
21
22 // This class is not thread safe, and should only be called from the main
23 // thread.
24 class LoggingRaw : public base::NonThreadSafe,
25                    public base::SupportsWeakPtr<LoggingRaw> {
26  public:
27   explicit LoggingRaw(base::TickClock* clock);
28   ~LoggingRaw();
29
30   // Inform of new event: three types of events: frame, packets and generic.
31   // Frame events can be inserted with different parameters.
32   void InsertFrameEvent(CastLoggingEvent event,
33                         uint32 rtp_timestamp,
34                         uint8 frame_id);
35
36   // Size - Inserting the size implies that this is an encoded frame.
37   void InsertFrameEventWithSize(CastLoggingEvent event,
38                                 uint32 rtp_timestamp,
39                                 uint8 frame_id,
40                                 int frame_size);
41
42   // Render/playout delay
43   void InsertFrameEventWithDelay(CastLoggingEvent event,
44                                  uint32 rtp_timestamp,
45                                  uint8 frame_id,
46                                  base::TimeDelta delay);
47
48   // Insert a packet event.
49   void InsertPacketEvent(CastLoggingEvent event,
50                          uint32 rtp_timestamp,
51                          uint8 frame_id,
52                          uint16 packet_id,
53                          uint16 max_packet_id,
54                          int size);
55
56   void InsertGenericEvent(CastLoggingEvent event, int value);
57
58   // Get raw log data.
59   FrameRawMap GetFrameData() const;
60   PacketRawMap GetPacketData() const;
61   GenericRawMap GetGenericData() const;
62
63
64   // Reset all log data.
65   void Reset();
66
67  private:
68   void InsertBaseFrameEvent(CastLoggingEvent event,
69                             uint8 frame_id,
70                             uint32 rtp_timestamp);
71
72   base::WeakPtrFactory<LoggingRaw> weak_factory_;
73   base::TickClock* const clock_;  // Not owned by this class.
74   FrameRawMap frame_map_;
75   PacketRawMap packet_map_;
76   GenericRawMap generic_map_;
77
78   DISALLOW_COPY_AND_ASSIGN(LoggingRaw);
79 };
80
81 }  // namespace cast
82 }  // namespace media
83
84 #endif  // MEDIA_CAST_LOGGING_LOGGING_RAW_H_
85