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 <vector> 9 10#include "base/basictypes.h" 11#include "base/memory/linked_ptr.h" 12#include "base/threading/non_thread_safe.h" 13#include "base/time/tick_clock.h" 14#include "media/cast/logging/logging_defines.h" 15#include "media/cast/logging/raw_event_subscriber.h" 16 17namespace media { 18namespace cast { 19 20// This class is not thread safe, and should only be called from the main 21// thread. 22class LoggingRaw : public base::NonThreadSafe { 23 public: 24 LoggingRaw(); 25 ~LoggingRaw(); 26 27 // Inform of new event: two types of events: frame and packet. 28 // Frame events can be inserted with different parameters. 29 void InsertFrameEvent(const base::TimeTicks& time_of_event, 30 CastLoggingEvent event, EventMediaType event_media_type, 31 uint32 rtp_timestamp, uint32 frame_id); 32 33 // This function is only applicable for FRAME_ENCODED event. 34 // |size| - Size of encoded frame. 35 // |key_frame| - Whether the frame is a key frame. This field is only 36 // applicable for video event. 37 // |target_bitrate| - The target bitrate of the encoder the time the frame 38 // was encoded. Only applicable for video event. 39 void InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, 40 CastLoggingEvent event, 41 EventMediaType event_media_type, 42 uint32 rtp_timestamp, uint32 frame_id, 43 int size, bool key_frame, 44 int target_bitrate); 45 46 // Render/playout delay 47 // This function is only applicable for FRAME_PLAYOUT event. 48 void InsertFrameEventWithDelay(const base::TimeTicks& time_of_event, 49 CastLoggingEvent event, 50 EventMediaType event_media_type, 51 uint32 rtp_timestamp, 52 uint32 frame_id, base::TimeDelta delay); 53 54 // Insert a packet event. 55 void InsertPacketEvent(const base::TimeTicks& time_of_event, 56 CastLoggingEvent event, 57 EventMediaType event_media_type, uint32 rtp_timestamp, 58 uint32 frame_id, uint16 packet_id, 59 uint16 max_packet_id, size_t size); 60 61 // Adds |subscriber| so that it will start receiving events on main thread. 62 // Note that this class does not own |subscriber|. 63 // It is a no-op to add a subscriber that already exists. 64 void AddSubscriber(RawEventSubscriber* subscriber); 65 66 // Removes |subscriber| so that it will stop receiving events. 67 // Note that this class does NOT own the subscribers. This function MUST be 68 // called before |subscriber| is destroyed if it was previously added. 69 // It is a no-op to remove a subscriber that doesn't exist. 70 void RemoveSubscriber(RawEventSubscriber* subscriber); 71 72 private: 73 void InsertBaseFrameEvent(const base::TimeTicks& time_of_event, 74 CastLoggingEvent event, 75 EventMediaType event_media_type, 76 uint32 frame_id, uint32 rtp_timestamp, 77 base::TimeDelta delay, int size, bool key_frame, 78 int target_bitrate); 79 80 // List of subscriber pointers. This class does not own the subscribers. 81 std::vector<RawEventSubscriber*> subscribers_; 82 83 DISALLOW_COPY_AND_ASSIGN(LoggingRaw); 84}; 85 86} // namespace cast 87} // namespace media 88 89#endif // MEDIA_CAST_LOGGING_LOGGING_RAW_H_ 90