2015-07-30 12:45:18 +02:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
|
|
|
|
#define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-03-12 06:10:44 -08:00
|
|
|
#include <memory>
|
2015-07-30 12:45:18 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-10-04 13:18:26 +02:00
|
|
|
// TODO(eladalon): Remove this include once LogIncomingRtcpPacket(), etc., have
|
|
|
|
|
// been removed (they are currently deprecated).
|
2017-09-29 21:01:42 +02:00
|
|
|
#include "api/array_view.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-10-04 13:18:26 +02:00
|
|
|
#include "logging/rtc_event_log/output/rtc_event_log_output.h"
|
2017-10-02 13:33:31 +02:00
|
|
|
// TODO(eladalon): This is here because of ProbeFailureReason; remove this
|
|
|
|
|
// dependency along with the deprecated LogProbeResultFailure().
|
|
|
|
|
#include "logging/rtc_event_log/events/rtc_event_probe_result_failure.h"
|
2017-10-04 13:18:26 +02:00
|
|
|
// TODO(eladalon): Remove this #include once the deprecated versions of
|
|
|
|
|
// StartLogging() have been removed.
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/platform_file.h"
|
2015-07-30 12:45:18 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace rtclog {
|
2017-09-11 07:25:26 -07:00
|
|
|
class EventStream; // Storage class automatically generated from protobuf.
|
2017-09-21 10:25:29 +02:00
|
|
|
// TODO(eladalon): Get rid of this when deprecated methods are removed.
|
|
|
|
|
struct StreamConfig;
|
2015-07-30 12:45:18 +02:00
|
|
|
} // namespace rtclog
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
class Clock;
|
2017-10-03 16:11:34 +02:00
|
|
|
// TODO(eladalon): The following may be removed when the deprecated methods
|
|
|
|
|
// are removed.
|
2017-04-06 05:59:10 -07:00
|
|
|
struct AudioEncoderRuntimeConfig;
|
2017-09-29 21:01:42 +02:00
|
|
|
class RtpPacketReceived;
|
|
|
|
|
class RtpPacketToSend;
|
2017-04-11 00:49:44 -07:00
|
|
|
enum class BandwidthUsage;
|
2016-01-21 05:42:04 -08:00
|
|
|
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
class RtcEventLog {
|
|
|
|
|
public:
|
2017-10-04 13:18:26 +02:00
|
|
|
enum : size_t { kUnlimitedOutput = 0 };
|
|
|
|
|
|
2017-10-03 16:11:34 +02:00
|
|
|
// TODO(eladalon): Two stages are upcoming.
|
|
|
|
|
// 1. Extend this to actually support the new encoding.
|
|
|
|
|
// 2. Get rid of the legacy encoding, allowing us to get rid of this enum.
|
|
|
|
|
enum class EncodingType { Legacy };
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual ~RtcEventLog() {}
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Factory method to create an RtcEventLog object.
|
2017-10-03 16:11:34 +02:00
|
|
|
// TODO(eladalon): Get rid of the default value after internal projects fixed.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> Create(
|
|
|
|
|
EncodingType encoding_type = EncodingType::Legacy);
|
2016-12-20 05:03:58 -08:00
|
|
|
// TODO(nisse): webrtc::Clock is deprecated. Delete this method and
|
|
|
|
|
// above forward declaration of Clock when
|
2017-10-03 16:11:34 +02:00
|
|
|
// webrtc/system_wrappers/include/clock.h is deleted.
|
|
|
|
|
// TODO(eladalon): Get rid of the default value after internal projects fixed.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> Create(
|
|
|
|
|
const Clock* clock,
|
|
|
|
|
EncodingType encoding_type = EncodingType::Legacy) {
|
|
|
|
|
return Create(encoding_type);
|
2016-12-20 05:03:58 -08:00
|
|
|
}
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-07-04 07:06:55 -07:00
|
|
|
// Create an RtcEventLog object that does nothing.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> CreateNull();
|
|
|
|
|
|
2017-10-04 13:18:26 +02:00
|
|
|
// Starts logging to a given output. The output might be limited in size,
|
|
|
|
|
// and may close itself once it has reached the maximum size.
|
|
|
|
|
virtual bool StartLogging(std::unique_ptr<RtcEventLogOutput> output) = 0;
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Starts logging a maximum of max_size_bytes bytes to the specified file.
|
2015-07-30 12:45:18 +02:00
|
|
|
// If the file already exists it will be overwritten.
|
2016-04-22 12:40:37 -07:00
|
|
|
// If max_size_bytes <= 0, logging will be active until StopLogging is called.
|
|
|
|
|
// The function has no effect and returns false if we can't start a new log
|
|
|
|
|
// e.g. because we are already logging or the file cannot be opened.
|
2017-10-04 13:18:26 +02:00
|
|
|
RTC_DEPRECATED virtual bool StartLogging(const std::string& file_name,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
2016-04-22 12:40:37 -07:00
|
|
|
|
|
|
|
|
// Same as above. The RtcEventLog takes ownership of the file if the call
|
|
|
|
|
// is successful, i.e. if it returns true.
|
2017-10-04 13:18:26 +02:00
|
|
|
RTC_DEPRECATED virtual bool StartLogging(rtc::PlatformFile platform_file,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
2016-04-22 12:40:37 -07:00
|
|
|
|
|
|
|
|
// Deprecated. Pass an explicit file size limit.
|
2017-09-06 05:18:15 -07:00
|
|
|
RTC_DEPRECATED bool StartLogging(const std::string& file_name) {
|
2016-04-22 12:40:37 -07:00
|
|
|
return StartLogging(file_name, 10000000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deprecated. Pass an explicit file size limit.
|
2017-09-06 05:18:15 -07:00
|
|
|
RTC_DEPRECATED bool StartLogging(rtc::PlatformFile platform_file) {
|
2016-04-22 12:40:37 -07:00
|
|
|
return StartLogging(platform_file, 10000000);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 05:18:15 -07:00
|
|
|
// Stops logging to file and waits until the file has been closed, after
|
|
|
|
|
// which it would be permissible to read and/or modify it.
|
2015-07-30 12:45:18 +02:00
|
|
|
virtual void StopLogging() = 0;
|
|
|
|
|
|
2017-10-03 16:11:34 +02:00
|
|
|
// Log an RTC event (the type of event is determined by the subclass).
|
|
|
|
|
virtual void Log(std::unique_ptr<RtcEvent> event) = 0;
|
|
|
|
|
|
2017-05-22 04:08:28 -07:00
|
|
|
// Logs configuration information for a video receive stream.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogVideoReceiveStreamConfig(
|
2017-05-22 03:26:49 -07:00
|
|
|
const rtclog::StreamConfig& config) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2017-05-22 04:08:28 -07:00
|
|
|
// Logs configuration information for a video send stream.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogVideoSendStreamConfig(
|
|
|
|
|
const rtclog::StreamConfig& config) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2017-05-22 09:36:28 -07:00
|
|
|
// Logs configuration information for an audio receive stream.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogAudioReceiveStreamConfig(
|
2017-05-22 09:36:28 -07:00
|
|
|
const rtclog::StreamConfig& config) = 0;
|
2016-10-10 05:12:51 -07:00
|
|
|
|
2017-05-22 10:12:26 -07:00
|
|
|
// Logs configuration information for an audio send stream.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogAudioSendStreamConfig(
|
|
|
|
|
const rtclog::StreamConfig& config) = 0;
|
2016-10-10 05:12:51 -07:00
|
|
|
|
2017-09-29 21:01:42 +02:00
|
|
|
RTC_DEPRECATED virtual void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length) {}
|
|
|
|
|
|
|
|
|
|
RTC_DEPRECATED virtual void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length,
|
|
|
|
|
int probe_cluster_id) {}
|
|
|
|
|
|
|
|
|
|
// Logs the header of an incoming RTP packet. |packet_length|
|
|
|
|
|
// is the total length of the packet, including both header and payload.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogIncomingRtpHeader(
|
|
|
|
|
const RtpPacketReceived& packet) = 0;
|
2017-09-29 21:01:42 +02:00
|
|
|
|
|
|
|
|
// Logs the header of an incoming RTP packet. |packet_length|
|
2015-09-04 03:39:42 -07:00
|
|
|
// is the total length of the packet, including both header and payload.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogOutgoingRtpHeader(
|
|
|
|
|
const RtpPacketToSend& packet,
|
|
|
|
|
int probe_cluster_id) = 0;
|
2017-09-29 21:01:42 +02:00
|
|
|
|
|
|
|
|
RTC_DEPRECATED virtual void LogRtcpPacket(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length) {}
|
|
|
|
|
|
|
|
|
|
// Logs an incoming RTCP packet.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogIncomingRtcpPacket(
|
|
|
|
|
rtc::ArrayView<const uint8_t> packet) = 0;
|
2017-09-29 21:01:42 +02:00
|
|
|
|
|
|
|
|
// Logs an outgoing RTCP packet.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogOutgoingRtcpPacket(
|
|
|
|
|
rtc::ArrayView<const uint8_t> packet) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Logs an audio playout event.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogAudioPlayout(uint32_t ssrc) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2015-11-05 12:02:15 -08:00
|
|
|
// Logs a bitrate update from the bandwidth estimator based on packet loss.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogLossBasedBweUpdate(int32_t bitrate_bps,
|
|
|
|
|
uint8_t fraction_loss,
|
|
|
|
|
int32_t total_packets) = 0;
|
2015-11-05 12:02:15 -08:00
|
|
|
|
2017-02-17 03:38:28 -08:00
|
|
|
// Logs a bitrate update from the bandwidth estimator based on delay changes.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogDelayBasedBweUpdate(
|
|
|
|
|
int32_t bitrate_bps,
|
|
|
|
|
BandwidthUsage detector_state) = 0;
|
2017-02-17 03:38:28 -08:00
|
|
|
|
2017-01-24 04:54:59 -08:00
|
|
|
// Logs audio encoder re-configuration driven by audio network adaptor.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogAudioNetworkAdaptation(
|
2017-04-06 05:59:10 -07:00
|
|
|
const AudioEncoderRuntimeConfig& config) = 0;
|
2017-01-24 04:54:59 -08:00
|
|
|
|
2017-02-27 02:18:46 -08:00
|
|
|
// Logs when a probe cluster is created.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogProbeClusterCreated(int id,
|
|
|
|
|
int bitrate_bps,
|
|
|
|
|
int min_probes,
|
|
|
|
|
int min_bytes) = 0;
|
2017-02-27 02:18:46 -08:00
|
|
|
|
|
|
|
|
// Logs the result of a successful probing attempt.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogProbeResultSuccess(int id,
|
|
|
|
|
int bitrate_bps) = 0;
|
2017-02-27 02:18:46 -08:00
|
|
|
|
|
|
|
|
// Logs the result of an unsuccessful probing attempt.
|
2017-10-03 16:11:34 +02:00
|
|
|
RTC_DEPRECATED virtual void LogProbeResultFailure(
|
|
|
|
|
int id,
|
|
|
|
|
ProbeFailureReason failure_reason) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
};
|
|
|
|
|
|
2016-07-29 14:48:54 +02:00
|
|
|
// No-op implementation is used if flag is not set, or in tests.
|
2017-05-29 02:46:05 -07:00
|
|
|
class RtcEventLogNullImpl : public RtcEventLog {
|
2016-07-29 14:48:54 +02:00
|
|
|
public:
|
2017-10-04 13:18:26 +02:00
|
|
|
bool StartLogging(std::unique_ptr<RtcEventLogOutput> output) override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-07-29 14:48:54 +02:00
|
|
|
bool StartLogging(const std::string& file_name,
|
|
|
|
|
int64_t max_size_bytes) override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool StartLogging(rtc::PlatformFile platform_file,
|
2017-06-15 12:52:32 -07:00
|
|
|
int64_t max_size_bytes) override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-07-29 14:48:54 +02:00
|
|
|
void StopLogging() override {}
|
2017-10-03 16:11:34 +02:00
|
|
|
void Log(std::unique_ptr<RtcEvent> event) override {}
|
2016-07-29 14:48:54 +02:00
|
|
|
void LogVideoReceiveStreamConfig(
|
2017-05-22 03:26:49 -07:00
|
|
|
const rtclog::StreamConfig& config) override {}
|
2017-05-22 04:08:28 -07:00
|
|
|
void LogVideoSendStreamConfig(const rtclog::StreamConfig& config) override {}
|
2016-10-10 05:12:51 -07:00
|
|
|
void LogAudioReceiveStreamConfig(
|
2017-05-22 09:36:28 -07:00
|
|
|
const rtclog::StreamConfig& config) override {}
|
2017-05-22 10:12:26 -07:00
|
|
|
void LogAudioSendStreamConfig(const rtclog::StreamConfig& config) override {}
|
2017-09-29 21:01:42 +02:00
|
|
|
void LogIncomingRtpHeader(const RtpPacketReceived& packet) override {}
|
|
|
|
|
void LogOutgoingRtpHeader(const RtpPacketToSend& packet,
|
|
|
|
|
int probe_cluster_id) override {}
|
|
|
|
|
void LogIncomingRtcpPacket(rtc::ArrayView<const uint8_t> packet) override {}
|
|
|
|
|
void LogOutgoingRtcpPacket(rtc::ArrayView<const uint8_t> packet) override {}
|
2016-07-29 14:48:54 +02:00
|
|
|
void LogAudioPlayout(uint32_t ssrc) override {}
|
2017-02-20 05:14:41 -08:00
|
|
|
void LogLossBasedBweUpdate(int32_t bitrate_bps,
|
2016-07-29 14:48:54 +02:00
|
|
|
uint8_t fraction_loss,
|
|
|
|
|
int32_t total_packets) override {}
|
2017-02-20 05:14:41 -08:00
|
|
|
void LogDelayBasedBweUpdate(int32_t bitrate_bps,
|
2017-02-17 03:38:28 -08:00
|
|
|
BandwidthUsage detector_state) override {}
|
2017-01-24 04:54:59 -08:00
|
|
|
void LogAudioNetworkAdaptation(
|
2017-04-06 05:59:10 -07:00
|
|
|
const AudioEncoderRuntimeConfig& config) override {}
|
2017-02-27 02:18:46 -08:00
|
|
|
void LogProbeClusterCreated(int id,
|
|
|
|
|
int bitrate_bps,
|
|
|
|
|
int min_probes,
|
|
|
|
|
int min_bytes) override{};
|
|
|
|
|
void LogProbeResultSuccess(int id, int bitrate_bps) override{};
|
|
|
|
|
void LogProbeResultFailure(int id,
|
|
|
|
|
ProbeFailureReason failure_reason) override{};
|
2016-07-29 14:48:54 +02:00
|
|
|
};
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_H_
|