summaryrefslogtreecommitdiff
path: root/media/cast/logging/logging_raw.h
blob: 91de12aaaaad3c548fd6884d4d0e34754a17334c (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
78
79
80
81
82
83
84
85
// 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_RAW_H_
#define MEDIA_CAST_LOGGING_LOGGING_RAW_H_

#include <map>
#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/time/tick_clock.h"
#include "media/cast/logging/logging_defines.h"

namespace media {
namespace cast {

// This class is not thread safe, and should only be called from the main
// thread.
class LoggingRaw : public base::NonThreadSafe,
                   public base::SupportsWeakPtr<LoggingRaw> {
 public:
  explicit LoggingRaw(base::TickClock* clock);
  ~LoggingRaw();

  // Inform of new event: three types of events: frame, packets and generic.
  // Frame events can be inserted with different parameters.
  void InsertFrameEvent(CastLoggingEvent event,
                        uint32 rtp_timestamp,
                        uint8 frame_id);

  // Size - Inserting the size implies that this is an encoded frame.
  void InsertFrameEventWithSize(CastLoggingEvent event,
                                uint32 rtp_timestamp,
                                uint8 frame_id,
                                int frame_size);

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

  // Insert a packet event.
  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 raw log data.
  FrameRawMap GetFrameData() const;
  PacketRawMap GetPacketData() const;
  GenericRawMap GetGenericData() const;


  // Reset all log data.
  void Reset();

 private:
  void InsertBaseFrameEvent(CastLoggingEvent event,
                            uint8 frame_id,
                            uint32 rtp_timestamp);

  base::WeakPtrFactory<LoggingRaw> weak_factory_;
  base::TickClock* const clock_;  // Not owned by this class.
  FrameRawMap frame_map_;
  PacketRawMap packet_map_;
  GenericRawMap generic_map_;

  DISALLOW_COPY_AND_ASSIGN(LoggingRaw);
};

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_LOGGING_LOGGING_RAW_H_