blob: 518308bf2d2c3577c707837a835cbc6234fb671f [file] [log] [blame]
Bjorn Terelius36411852015-07-30 12:45:18 +02001/*
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öm5c389d32015-09-25 13:58:30 +020011#ifndef WEBRTC_CALL_RTC_EVENT_LOG_H_
12#define WEBRTC_CALL_RTC_EVENT_LOG_H_
Bjorn Terelius36411852015-07-30 12:45:18 +020013
kwibergb25345e2016-03-12 06:10:44 -080014#include <memory>
Bjorn Terelius36411852015-07-30 12:45:18 +020015#include <string>
16
ivoc112a3d82015-10-16 02:22:18 -070017#include "webrtc/base/platform_file.h"
Bjorn Terelius36411852015-07-30 12:45:18 +020018#include "webrtc/video_receive_stream.h"
19#include "webrtc/video_send_stream.h"
20
21namespace webrtc {
22
23// Forward declaration of storage class that is automatically generated from
24// the protobuf file.
25namespace rtclog {
26class EventStream;
27} // namespace rtclog
28
29class RtcEventLogImpl;
30
31enum class MediaType;
32
terelius429c3452016-01-21 05:42:04 -080033enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
34
Bjorn Terelius36411852015-07-30 12:45:18 +020035class RtcEventLog {
36 public:
Bjorn Terelius36411852015-07-30 12:45:18 +020037 virtual ~RtcEventLog() {}
38
kwibergb25345e2016-03-12 06:10:44 -080039 static std::unique_ptr<RtcEventLog> Create();
Bjorn Terelius36411852015-07-30 12:45:18 +020040
terelius1adce142015-10-16 08:51:08 -070041 // 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 Terelius36411852015-07-30 12:45:18 +020045 // 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
ivoc112a3d82015-10-16 02:22:18 -070051 // 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 Terelius36411852015-07-30 12:45:18 +020056 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
terelius2f9fd5d2015-09-04 03:39:42 -070066 // 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.
terelius429c3452016-01-21 05:42:04 -080068 virtual void LogRtpHeader(PacketDirection direction,
Bjorn Terelius36411852015-07-30 12:45:18 +020069 MediaType media_type,
70 const uint8_t* header,
terelius2f9fd5d2015-09-04 03:39:42 -070071 size_t packet_length) = 0;
Bjorn Terelius36411852015-07-30 12:45:18 +020072
73 // Logs an incoming or outgoing RTCP packet.
terelius429c3452016-01-21 05:42:04 -080074 virtual void LogRtcpPacket(PacketDirection direction,
Bjorn Terelius36411852015-07-30 12:45:18 +020075 MediaType media_type,
76 const uint8_t* packet,
77 size_t length) = 0;
78
Ivo Creusenae856f22015-09-17 16:30:16 +020079 // Logs an audio playout event
80 virtual void LogAudioPlayout(uint32_t ssrc) = 0;
Bjorn Terelius36411852015-07-30 12:45:18 +020081
terelius006d93d2015-11-05 12:02:15 -080082 // 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 Terelius36411852015-07-30 12:45:18 +020087 // 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öm5c389d32015-09-25 13:58:30 +020095#endif // WEBRTC_CALL_RTC_EVENT_LOG_H_