aboutsummaryrefslogtreecommitdiff
path: root/webrtc/call/rtc_event_log.h
blob: 85d752575244194a3de9fe20385474cf84e3488b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef WEBRTC_CALL_RTC_EVENT_LOG_H_
#define WEBRTC_CALL_RTC_EVENT_LOG_H_

#include <string>

#include "webrtc/base/platform_file.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"

namespace webrtc {

// Forward declaration of storage class that is automatically generated from
// the protobuf file.
namespace rtclog {
class EventStream;
}  // namespace rtclog

class RtcEventLogImpl;

enum class MediaType;

class RtcEventLog {
 public:
  virtual ~RtcEventLog() {}

  static rtc::scoped_ptr<RtcEventLog> Create();

  // Sets the time that events are stored in the internal event buffer
  // before the user calls StartLogging.  The default is 10 000 000 us = 10 s
  virtual void SetBufferDuration(int64_t buffer_duration_us) = 0;

  // Starts logging for the specified duration to the specified file.
  // The logging will stop automatically after the specified duration.
  // If the file already exists it will be overwritten.
  // If the file cannot be opened, the RtcEventLog will not start logging.
  virtual void StartLogging(const std::string& file_name, int duration_ms) = 0;

  // Starts logging until either the 10 minute timer runs out or the StopLogging
  // function is called. The RtcEventLog takes ownership of the supplied
  // rtc::PlatformFile.
  virtual bool StartLogging(rtc::PlatformFile log_file) = 0;

  virtual void StopLogging() = 0;

  // Logs configuration information for webrtc::VideoReceiveStream
  virtual void LogVideoReceiveStreamConfig(
      const webrtc::VideoReceiveStream::Config& config) = 0;

  // Logs configuration information for webrtc::VideoSendStream
  virtual void LogVideoSendStreamConfig(
      const webrtc::VideoSendStream::Config& config) = 0;

  // Logs the header of an incoming or outgoing RTP packet. packet_length
  // is the total length of the packet, including both header and payload.
  virtual void LogRtpHeader(bool incoming,
                            MediaType media_type,
                            const uint8_t* header,
                            size_t packet_length) = 0;

  // Logs an incoming or outgoing RTCP packet.
  virtual void LogRtcpPacket(bool incoming,
                             MediaType media_type,
                             const uint8_t* packet,
                             size_t length) = 0;

  // Logs an audio playout event
  virtual void LogAudioPlayout(uint32_t ssrc) = 0;

  // Reads an RtcEventLog file and returns true when reading was successful.
  // The result is stored in the given EventStream object.
  static bool ParseRtcEventLog(const std::string& file_name,
                               rtclog::EventStream* result);
};

}  // namespace webrtc

#endif  // WEBRTC_CALL_RTC_EVENT_LOG_H_