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 | |
| 14 | #include <string> |
| 15 | |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 16 | #include "webrtc/base/platform_file.h" |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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: |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 35 | virtual ~RtcEventLog() {} |
| 36 | |
| 37 | static rtc::scoped_ptr<RtcEventLog> Create(); |
| 38 | |
terelius | 1adce14 | 2015-10-16 08:51:08 -0700 | [diff] [blame] | 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 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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 | |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 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 | |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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 | |
terelius | 2f9fd5d | 2015-09-04 03:39:42 -0700 | [diff] [blame] | 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. |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 66 | virtual void LogRtpHeader(bool incoming, |
| 67 | MediaType media_type, |
| 68 | const uint8_t* header, |
terelius | 2f9fd5d | 2015-09-04 03:39:42 -0700 | [diff] [blame] | 69 | size_t packet_length) = 0; |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 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 | |
Ivo Creusen | ae856f2 | 2015-09-17 16:30:16 +0200 | [diff] [blame] | 77 | // Logs an audio playout event |
| 78 | virtual void LogAudioPlayout(uint32_t ssrc) = 0; |
Bjorn Terelius | 3641185 | 2015-07-30 12:45:18 +0200 | [diff] [blame] | 79 | |
| 80 | // Reads an RtcEventLog file and returns true when reading was successful. |
| 81 | // The result is stored in the given EventStream object. |
| 82 | static bool ParseRtcEventLog(const std::string& file_name, |
| 83 | rtclog::EventStream* result); |
| 84 | }; |
| 85 | |
| 86 | } // namespace webrtc |
| 87 | |
Peter Boström | 5c389d3 | 2015-09-25 13:58:30 +0200 | [diff] [blame] | 88 | #endif // WEBRTC_CALL_RTC_EVENT_LOG_H_ |