blob: 85d752575244194a3de9fe20385474cf84e3488b [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
14#include <string>
15
ivoc112a3d82015-10-16 02:22:18 -070016#include "webrtc/base/platform_file.h"
Bjorn Terelius36411852015-07-30 12:45:18 +020017#include "webrtc/base/scoped_ptr.h"
18#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
33class RtcEventLog {
34 public:
Bjorn Terelius36411852015-07-30 12:45:18 +020035 virtual ~RtcEventLog() {}
36
37 static rtc::scoped_ptr<RtcEventLog> Create();
38
terelius1adce142015-10-16 08:51:08 -070039 // 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 Terelius36411852015-07-30 12:45:18 +020043 // 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
ivoc112a3d82015-10-16 02:22:18 -070049 // 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 Terelius36411852015-07-30 12:45:18 +020054 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
terelius2f9fd5d2015-09-04 03:39:42 -070064 // 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 Terelius36411852015-07-30 12:45:18 +020066 virtual void LogRtpHeader(bool incoming,
67 MediaType media_type,
68 const uint8_t* header,
terelius2f9fd5d2015-09-04 03:39:42 -070069 size_t packet_length) = 0;
Bjorn Terelius36411852015-07-30 12:45:18 +020070
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 Creusenae856f22015-09-17 16:30:16 +020077 // Logs an audio playout event
78 virtual void LogAudioPlayout(uint32_t ssrc) = 0;
Bjorn Terelius36411852015-07-30 12:45:18 +020079
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öm5c389d32015-09-25 13:58:30 +020088#endif // WEBRTC_CALL_RTC_EVENT_LOG_H_