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-05-22 03:26:49 -07:00
|
|
|
#include <vector>
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2017-09-11 07:25:26 -07:00
|
|
|
// TODO(eladalon): Get rid of this later in the CL-stack.
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/rtpparameters.h"
|
|
|
|
|
#include "common_types.h"
|
2017-09-11 07:25:26 -07:00
|
|
|
// TODO(eladalon): Get rid of this later in the CL-stack.
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_stream_config.h"
|
|
|
|
|
#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.
|
2015-07-30 12:45:18 +02:00
|
|
|
} // namespace rtclog
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
class Clock;
|
2017-04-06 05:59:10 -07:00
|
|
|
struct AudioEncoderRuntimeConfig;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
|
|
|
|
enum class MediaType;
|
2017-04-11 00:49:44 -07:00
|
|
|
enum class BandwidthUsage;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2016-01-21 05:42:04 -08:00
|
|
|
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
|
2017-02-27 02:18:46 -08:00
|
|
|
enum ProbeFailureReason {
|
|
|
|
|
kInvalidSendReceiveInterval,
|
|
|
|
|
kInvalidSendReceiveRatio,
|
|
|
|
|
kTimeout
|
|
|
|
|
};
|
2016-01-21 05:42:04 -08:00
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
class RtcEventLog {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RtcEventLog() {}
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Factory method to create an RtcEventLog object.
|
2016-12-20 05:03:58 -08:00
|
|
|
static std::unique_ptr<RtcEventLog> Create();
|
|
|
|
|
// TODO(nisse): webrtc::Clock is deprecated. Delete this method and
|
|
|
|
|
// above forward declaration of Clock when
|
|
|
|
|
// webrtc/system_wrappers/include/clock.h is deleted.
|
|
|
|
|
static std::unique_ptr<RtcEventLog> Create(const Clock* clock) {
|
|
|
|
|
return Create();
|
|
|
|
|
}
|
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();
|
|
|
|
|
|
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.
|
|
|
|
|
virtual bool StartLogging(const std::string& file_name,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
|
|
|
|
|
|
|
|
|
// Same as above. The RtcEventLog takes ownership of the file if the call
|
|
|
|
|
// is successful, i.e. if it returns true.
|
|
|
|
|
virtual bool StartLogging(rtc::PlatformFile platform_file,
|
|
|
|
|
int64_t max_size_bytes) = 0;
|
|
|
|
|
|
|
|
|
|
// 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-05-22 04:08:28 -07:00
|
|
|
// Logs configuration information for a video receive stream.
|
2015-07-30 12:45:18 +02:00
|
|
|
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.
|
|
|
|
|
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.
|
2016-10-10 05:12:51 -07:00
|
|
|
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.
|
|
|
|
|
virtual void LogAudioSendStreamConfig(const rtclog::StreamConfig& config) = 0;
|
2016-10-10 05:12:51 -07:00
|
|
|
|
2015-09-04 03:39:42 -07:00
|
|
|
// Logs the header of an incoming or outgoing RTP packet. packet_length
|
|
|
|
|
// is the total length of the packet, including both header and payload.
|
2016-01-21 05:42:04 -08:00
|
|
|
virtual void LogRtpHeader(PacketDirection direction,
|
2015-07-30 12:45:18 +02:00
|
|
|
const uint8_t* header,
|
2015-09-04 03:39:42 -07:00
|
|
|
size_t packet_length) = 0;
|
2015-07-30 12:45:18 +02:00
|
|
|
|
2017-02-27 02:18:46 -08:00
|
|
|
// Same as above but used on the sender side to log packets that are part of
|
|
|
|
|
// a probe cluster.
|
|
|
|
|
virtual void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length,
|
|
|
|
|
int probe_cluster_id) = 0;
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
// Logs an incoming or outgoing RTCP packet.
|
2016-01-21 05:42:04 -08:00
|
|
|
virtual void LogRtcpPacket(PacketDirection direction,
|
2015-07-30 12:45:18 +02:00
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) = 0;
|
|
|
|
|
|
2016-04-22 12:40:37 -07:00
|
|
|
// Logs an audio playout event.
|
2015-09-17 16:30:16 +02:00
|
|
|
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-02-20 05:14:41 -08:00
|
|
|
virtual void LogLossBasedBweUpdate(int32_t bitrate_bps,
|
2015-11-05 12:02:15 -08:00
|
|
|
uint8_t fraction_loss,
|
|
|
|
|
int32_t total_packets) = 0;
|
|
|
|
|
|
2017-02-17 03:38:28 -08:00
|
|
|
// Logs a bitrate update from the bandwidth estimator based on delay changes.
|
2017-02-20 05:14:41 -08:00
|
|
|
virtual void LogDelayBasedBweUpdate(int32_t bitrate_bps,
|
2017-02-17 03:38:28 -08:00
|
|
|
BandwidthUsage detector_state) = 0;
|
|
|
|
|
|
2017-01-24 04:54:59 -08:00
|
|
|
// Logs audio encoder re-configuration driven by audio network adaptor.
|
|
|
|
|
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.
|
|
|
|
|
virtual void LogProbeClusterCreated(int id,
|
|
|
|
|
int bitrate_bps,
|
|
|
|
|
int min_probes,
|
|
|
|
|
int min_bytes) = 0;
|
|
|
|
|
|
|
|
|
|
// Logs the result of a successful probing attempt.
|
|
|
|
|
virtual void LogProbeResultSuccess(int id, int bitrate_bps) = 0;
|
|
|
|
|
|
|
|
|
|
// Logs the result of an unsuccessful probing attempt.
|
|
|
|
|
virtual void LogProbeResultFailure(int id,
|
|
|
|
|
ProbeFailureReason failure_reason) = 0;
|
|
|
|
|
|
2015-07-30 12:45:18 +02:00
|
|
|
// Reads an RtcEventLog file and returns true when reading was successful.
|
|
|
|
|
// The result is stored in the given EventStream object.
|
2016-04-22 12:40:37 -07:00
|
|
|
// The order of the events in the EventStream is implementation defined.
|
|
|
|
|
// The current implementation writes a LOG_START event, then the old
|
|
|
|
|
// configurations, then the remaining events in timestamp order and finally
|
|
|
|
|
// a LOG_END event. However, this might change without further notice.
|
|
|
|
|
// TODO(terelius): Change result type to a vector?
|
2015-07-30 12:45:18 +02:00
|
|
|
static bool ParseRtcEventLog(const std::string& file_name,
|
|
|
|
|
rtclog::EventStream* result);
|
|
|
|
|
};
|
|
|
|
|
|
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:
|
|
|
|
|
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 {}
|
|
|
|
|
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 {}
|
2016-07-29 14:48:54 +02:00
|
|
|
void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length) override {}
|
2017-02-27 02:18:46 -08:00
|
|
|
void LogRtpHeader(PacketDirection direction,
|
|
|
|
|
const uint8_t* header,
|
|
|
|
|
size_t packet_length,
|
|
|
|
|
int probe_cluster_id) override {}
|
2016-07-29 14:48:54 +02:00
|
|
|
void LogRtcpPacket(PacketDirection direction,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) override {}
|
|
|
|
|
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_
|