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 #ifndef MEDIA_CAST_LOGGING_LOGGING_IMPL_H_
5 #define MEDIA_CAST_LOGGING_LOGGING_IMPL_H_
7 // Generic class that handles event logging for the cast library.
8 // Logging has three possible optional forms:
9 // 1. Raw data and stats accessible by the application.
10 // 2. Tracing of raw events.
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
14 #include "media/cast/cast_config.h"
15 #include "media/cast/logging/logging_defines.h"
16 #include "media/cast/logging/logging_raw.h"
17 #include "media/cast/logging/logging_stats.h"
22 // Should only be called from the main thread.
23 class LoggingImpl : public base::NonThreadSafe {
25 LoggingImpl(scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy,
26 const CastLoggingConfig& config);
30 void InsertFrameEvent(const base::TimeTicks& time_of_event,
31 CastLoggingEvent event, uint32 rtp_timestamp,
34 void InsertFrameEventWithSize(const base::TimeTicks& time_of_event,
35 CastLoggingEvent event, uint32 rtp_timestamp,
36 uint32 frame_id, int frame_size);
38 void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event,
39 CastLoggingEvent event, uint32 rtp_timestamp,
40 uint32 frame_id, base::TimeDelta delay);
42 void InsertPacketListEvent(const base::TimeTicks& time_of_event,
43 CastLoggingEvent event, const PacketList& packets);
45 void InsertPacketEvent(const base::TimeTicks& time_of_event,
46 CastLoggingEvent event, uint32 rtp_timestamp,
47 uint32 frame_id, uint16 packet_id,
48 uint16 max_packet_id, size_t size);
50 void InsertGenericEvent(const base::TimeTicks& time_of_event,
51 CastLoggingEvent event, int value);
54 // Delegates to |LoggingRaw::AddRawEventSubscriber()|.
55 void AddRawEventSubscriber(RawEventSubscriber* subscriber);
57 // Delegates to |LoggingRaw::RemoveRawEventSubscriber()|.
58 void RemoveRawEventSubscriber(RawEventSubscriber* subscriber);
61 FrameStatsMap GetFrameStatsData() const;
62 PacketStatsMap GetPacketStatsData() const;
63 GenericStatsMap GetGenericStatsData() const;
65 // Reset stats logging data.
69 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_;
70 const CastLoggingConfig config_;
74 DISALLOW_COPY_AND_ASSIGN(LoggingImpl);
80 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_