Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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 | |
Peter Boström | 5c389d3 | 2015-09-25 13:58:30 +0200 | [diff] [blame] | 11 | #ifndef WEBRTC_CALL_RTC_EVENT_LOG_H_ |
| 12 | #define WEBRTC_CALL_RTC_EVENT_LOG_H_ |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 13 | |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 14 | #include <memory> |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 15 | #include <string> |
| 16 | |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 17 | #include "webrtc/base/platform_file.h" |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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 | |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 33 | enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket }; |
| 34 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 35 | class RtcEventLog { |
| 36 | public: |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 37 | virtual ~RtcEventLog() {} |
| 38 | |
kwiberg | b25345e | 2016-03-12 06:10:44 -0800 | [diff] [blame] | 39 | static std::unique_ptr<RtcEventLog> Create(); |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 40 | |
terelius | 1adce14 | 2015-10-16 08:51:08 -0700 | [diff] [blame] | 41 | // Sets the time that events are stored in the internal event buffer |
| 42 | // before the user calls StartLogging. The default is 10 000 000 us = 10 s |
| 43 | virtual void SetBufferDuration(int64_t buffer_duration_us) = 0; |
| 44 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 45 | // Starts logging for the specified duration to the specified file. |
| 46 | // The logging will stop automatically after the specified duration. |
| 47 | // If the file already exists it will be overwritten. |
| 48 | // If the file cannot be opened, the RtcEventLog will not start logging. |
| 49 | virtual void StartLogging(const std::string& file_name, int duration_ms) = 0; |
| 50 | |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 51 | // Starts logging until either the 10 minute timer runs out or the StopLogging |
| 52 | // function is called. The RtcEventLog takes ownership of the supplied |
| 53 | // rtc::PlatformFile. |
| 54 | virtual bool StartLogging(rtc::PlatformFile log_file) = 0; |
| 55 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 56 | virtual void StopLogging() = 0; |
| 57 | |
| 58 | // Logs configuration information for webrtc::VideoReceiveStream |
| 59 | virtual void LogVideoReceiveStreamConfig( |
| 60 | const webrtc::VideoReceiveStream::Config& config) = 0; |
| 61 | |
| 62 | // Logs configuration information for webrtc::VideoSendStream |
| 63 | virtual void LogVideoSendStreamConfig( |
| 64 | const webrtc::VideoSendStream::Config& config) = 0; |
| 65 | |
terelius | 2f9fd5d | 2015-09-04 03:39:42 -0700 | [diff] [blame] | 66 | // Logs the header of an incoming or outgoing RTP packet. packet_length |
| 67 | // is the total length of the packet, including both header and payload. |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 68 | virtual void LogRtpHeader(PacketDirection direction, |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 69 | MediaType media_type, |
| 70 | const uint8_t* header, |
terelius | 2f9fd5d | 2015-09-04 03:39:42 -0700 | [diff] [blame] | 71 | size_t packet_length) = 0; |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 72 | |
| 73 | // Logs an incoming or outgoing RTCP packet. |
terelius | 429c345 | 2016-01-21 05:42:04 -0800 | [diff] [blame] | 74 | virtual void LogRtcpPacket(PacketDirection direction, |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 75 | MediaType media_type, |
| 76 | const uint8_t* packet, |
| 77 | size_t length) = 0; |
| 78 | |
Ivo Creusen | ae856f2 | 2015-09-17 16:30:16 +0200 | [diff] [blame] | 79 | // Logs an audio playout event |
| 80 | virtual void LogAudioPlayout(uint32_t ssrc) = 0; |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 81 | |
terelius | 006d93d | 2015-11-05 12:02:15 -0800 | [diff] [blame] | 82 | // Logs a bitrate update from the bandwidth estimator based on packet loss. |
| 83 | virtual void LogBwePacketLossEvent(int32_t bitrate, |
| 84 | uint8_t fraction_loss, |
| 85 | int32_t total_packets) = 0; |
| 86 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 87 | // Reads an RtcEventLog file and returns true when reading was successful. |
| 88 | // The result is stored in the given EventStream object. |
| 89 | static bool ParseRtcEventLog(const std::string& file_name, |
| 90 | rtclog::EventStream* result); |
| 91 | }; |
| 92 | |
| 93 | } // namespace webrtc |
| 94 | |
Peter Boström | 5c389d3 | 2015-09-25 13:58:30 +0200 | [diff] [blame] | 95 | #endif // WEBRTC_CALL_RTC_EVENT_LOG_H_ |