1 /* 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_CALL_RTC_EVENT_LOG_H_ 12 #define WEBRTC_CALL_RTC_EVENT_LOG_H_ 13 14 #include <string> 15 16 #include "webrtc/base/platform_file.h" 17 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/video_receive_stream.h" 19 #include "webrtc/video_send_stream.h" 20 21 namespace webrtc { 22 23 // Forward declaration of storage class that is automatically generated from 24 // the protobuf file. 25 namespace rtclog { 26 class EventStream; 27 } // namespace rtclog 28 29 class RtcEventLogImpl; 30 31 enum class MediaType; 32 33 class RtcEventLog { 34 public: ~RtcEventLog()35 virtual ~RtcEventLog() {} 36 37 static rtc::scoped_ptr<RtcEventLog> Create(); 38 39 // Sets the time that events are stored in the internal event buffer 40 // before the user calls StartLogging. The default is 10 000 000 us = 10 s 41 virtual void SetBufferDuration(int64_t buffer_duration_us) = 0; 42 43 // Starts logging for the specified duration to the specified file. 44 // The logging will stop automatically after the specified duration. 45 // If the file already exists it will be overwritten. 46 // If the file cannot be opened, the RtcEventLog will not start logging. 47 virtual void StartLogging(const std::string& file_name, int duration_ms) = 0; 48 49 // Starts logging until either the 10 minute timer runs out or the StopLogging 50 // function is called. The RtcEventLog takes ownership of the supplied 51 // rtc::PlatformFile. 52 virtual bool StartLogging(rtc::PlatformFile log_file) = 0; 53 54 virtual void StopLogging() = 0; 55 56 // Logs configuration information for webrtc::VideoReceiveStream 57 virtual void LogVideoReceiveStreamConfig( 58 const webrtc::VideoReceiveStream::Config& config) = 0; 59 60 // Logs configuration information for webrtc::VideoSendStream 61 virtual void LogVideoSendStreamConfig( 62 const webrtc::VideoSendStream::Config& config) = 0; 63 64 // Logs the header of an incoming or outgoing RTP packet. packet_length 65 // is the total length of the packet, including both header and payload. 66 virtual void LogRtpHeader(bool incoming, 67 MediaType media_type, 68 const uint8_t* header, 69 size_t packet_length) = 0; 70 71 // Logs an incoming or outgoing RTCP packet. 72 virtual void LogRtcpPacket(bool incoming, 73 MediaType media_type, 74 const uint8_t* packet, 75 size_t length) = 0; 76 77 // Logs an audio playout event 78 virtual void LogAudioPlayout(uint32_t ssrc) = 0; 79 80 // Logs a bitrate update from the bandwidth estimator based on packet loss. 81 virtual void LogBwePacketLossEvent(int32_t bitrate, 82 uint8_t fraction_loss, 83 int32_t total_packets) = 0; 84 85 // Reads an RtcEventLog file and returns true when reading was successful. 86 // The result is stored in the given EventStream object. 87 static bool ParseRtcEventLog(const std::string& file_name, 88 rtclog::EventStream* result); 89 }; 90 91 } // namespace webrtc 92 93 #endif // WEBRTC_CALL_RTC_EVENT_LOG_H_ 94