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_ 6 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. UMA stats. 11 // 3. Tracing of raw events. 12 13 #include "base/memory/ref_counted.h" 14 #include "base/task_runner.h" 15 #include "media/cast/cast_config.h" 16 #include "media/cast/logging/logging_defines.h" 17 #include "media/cast/logging/logging_raw.h" 18 #include "media/cast/logging/logging_stats.h" 19 20 namespace media { 21 namespace cast { 22 23 // Should only be called from the main thread. 24 class LoggingImpl : public base::NonThreadSafe { 25 public: 26 LoggingImpl(base::TickClock* clock, 27 scoped_refptr<base::TaskRunner> main_thread_proxy, 28 const CastLoggingConfig& config); 29 30 ~LoggingImpl(); 31 32 // TODO(pwestin): Add argument to API to send in time of event instead of 33 // grabbing now. 34 void InsertFrameEvent(CastLoggingEvent event, 35 uint32 rtp_timestamp, 36 uint32 frame_id); 37 void InsertFrameEventWithSize(CastLoggingEvent event, 38 uint32 rtp_timestamp, 39 uint32 frame_id, 40 int frame_size); 41 void InsertFrameEventWithDelay(CastLoggingEvent event, 42 uint32 rtp_timestamp, 43 uint32 frame_id, 44 base::TimeDelta delay); 45 void InsertPacketListEvent(CastLoggingEvent event, const PacketList& packets); 46 47 void InsertPacketEvent(CastLoggingEvent event, 48 uint32 rtp_timestamp, 49 uint32 frame_id, 50 uint16 packet_id, 51 uint16 max_packet_id, 52 size_t size); 53 void InsertGenericEvent(CastLoggingEvent event, int value); 54 55 // Get raw data. 56 FrameRawMap GetFrameRawData(); 57 PacketRawMap GetPacketRawData(); 58 GenericRawMap GetGenericRawData(); 59 // Get stats only (computed when called). Triggers UMA stats when enabled. 60 const FrameStatsMap* GetFrameStatsData(); 61 const PacketStatsMap* GetPacketStatsData(); 62 const GenericStatsMap* GetGenericStatsData(); 63 64 void Reset(); 65 66 private: 67 scoped_refptr<base::TaskRunner> main_thread_proxy_; 68 const CastLoggingConfig config_; 69 LoggingRaw raw_; 70 LoggingStats stats_; 71 72 DISALLOW_COPY_AND_ASSIGN(LoggingImpl); 73 }; 74 75 } // namespace cast 76 } // namespace media 77 78 #endif // MEDIA_CAST_LOGGING_LOGGING_IMPL_H_ 79