Add the internals of RtcEvent's subclasses

We're moving to an RtcEventLog interface that accepts std::unique_ptr<EventLog> and stores the event for encoding when encoding becomes necessary, rather than before. This will be useful while we maintain the legacy (current) encoding alongside the new encoding on which we're working.

This CL adds the internals of RtcEvent's subclasses - the actual data that they keep. (Work on this was broken down into several CLs in order to make reviewing easier.)

BUG=webrtc:8111

Change-Id: I402c9c64bffef6a5a6d227bde5da0fd3152daba1
Reviewed-on: https://webrtc-review.googlesource.com/1362
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20108}
This commit is contained in:
Elad Alon 2017-10-02 13:33:31 +02:00 committed by Commit Bot
parent d25fa78daf
commit 078a78120f
33 changed files with 248 additions and 16 deletions

View File

@ -69,6 +69,9 @@ rtc_source_set("rtc_event_log_api") {
"../api:array_view",
"../api:libjingle_peerconnection_api",
"../call:video_stream_api",
"../modules/audio_coding:audio_network_adaptor_config",
"../modules/remote_bitrate_estimator:remote_bitrate_estimator",
"../modules/rtp_rtcp:rtp_rtcp_format",
"../rtc_base:rtc_base_approved",
]
}

View File

@ -11,6 +11,10 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_H_
#include <typedefs.h>
#include "rtc_base/timeutils.h"
namespace webrtc {
// This class allows us to store unencoded RTC events. Subclasses of this class
@ -45,11 +49,14 @@ class RtcEvent {
VideoSendStreamConfig
};
RtcEvent() : timestamp_us_(rtc::TimeMicros()) {}
virtual ~RtcEvent() = default;
virtual Type GetType() const = 0;
virtual bool IsConfigEvent() const = 0;
const int64_t timestamp_us_;
};
} // namespace webrtc

View File

@ -10,8 +10,18 @@
#include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h"
#include <utility>
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
namespace webrtc {
RtcEventAudioNetworkAdaptation::RtcEventAudioNetworkAdaptation(
std::unique_ptr<AudioEncoderRuntimeConfig> config)
: config_(std::move(config)) {}
RtcEventAudioNetworkAdaptation::~RtcEventAudioNetworkAdaptation() = default;
RtcEvent::Type RtcEventAudioNetworkAdaptation::GetType() const {
return RtcEvent::Type::AudioNetworkAdaptation;
}

View File

@ -11,17 +11,25 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_H_
#include <memory>
#include "logging/rtc_event_log/events/rtc_event.h"
namespace webrtc {
struct AudioEncoderRuntimeConfig;
class RtcEventAudioNetworkAdaptation final : public RtcEvent {
public:
~RtcEventAudioNetworkAdaptation() override = default;
explicit RtcEventAudioNetworkAdaptation(
std::unique_ptr<AudioEncoderRuntimeConfig> config);
~RtcEventAudioNetworkAdaptation() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const std::unique_ptr<const AudioEncoderRuntimeConfig> config_;
};
} // namespace webrtc

View File

@ -12,6 +12,8 @@
namespace webrtc {
RtcEventAudioPlayout::RtcEventAudioPlayout(uint32_t ssrc) : ssrc_(ssrc) {}
RtcEvent::Type RtcEventAudioPlayout::GetType() const {
return RtcEvent::Type::AudioPlayout;
}

View File

@ -17,11 +17,14 @@ namespace webrtc {
class RtcEventAudioPlayout final : public RtcEvent {
public:
explicit RtcEventAudioPlayout(uint32_t ssrc);
~RtcEventAudioPlayout() override = default;
Type GetType() const override;
bool IsConfigEvent() const override;
const uint32_t ssrc_;
};
} // namespace webrtc

View File

@ -10,8 +10,18 @@
#include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h"
#include <utility>
#include "logging/rtc_event_log/rtc_stream_config.h"
namespace webrtc {
RtcEventAudioReceiveStreamConfig::RtcEventAudioReceiveStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config)
: config_(std::move(config)) {}
RtcEventAudioReceiveStreamConfig::~RtcEventAudioReceiveStreamConfig() = default;
RtcEvent::Type RtcEventAudioReceiveStreamConfig::GetType() const {
return RtcEvent::Type::AudioReceiveStreamConfig;
}

View File

@ -11,17 +11,27 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_RECEIVE_STREAM_CONFIG_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_RECEIVE_STREAM_CONFIG_H_
#include <memory>
#include "logging/rtc_event_log/events/rtc_event.h"
namespace webrtc {
namespace rtclog {
struct StreamConfig;
} // namespace rtclog
class RtcEventAudioReceiveStreamConfig final : public RtcEvent {
public:
~RtcEventAudioReceiveStreamConfig() override = default;
explicit RtcEventAudioReceiveStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config);
~RtcEventAudioReceiveStreamConfig() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const std::unique_ptr<const rtclog::StreamConfig> config_;
};
} // namespace webrtc

View File

@ -10,8 +10,18 @@
#include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h"
#include <utility>
#include "logging/rtc_event_log/rtc_stream_config.h"
namespace webrtc {
RtcEventAudioSendStreamConfig::RtcEventAudioSendStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config)
: config_(std::move(config)) {}
RtcEventAudioSendStreamConfig::~RtcEventAudioSendStreamConfig() = default;
RtcEvent::Type RtcEventAudioSendStreamConfig::GetType() const {
return RtcEvent::Type::AudioSendStreamConfig;
}

View File

@ -11,17 +11,27 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_SEND_STREAM_CONFIG_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_SEND_STREAM_CONFIG_H_
#include <memory>
#include "logging/rtc_event_log/events/rtc_event.h"
namespace webrtc {
namespace rtclog {
struct StreamConfig;
} // namespace rtclog
class RtcEventAudioSendStreamConfig final : public RtcEvent {
public:
~RtcEventAudioSendStreamConfig() override = default;
explicit RtcEventAudioSendStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config);
~RtcEventAudioSendStreamConfig() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const std::unique_ptr<const rtclog::StreamConfig> config_;
};
} // namespace webrtc

View File

@ -10,8 +10,17 @@
#include "logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h"
#include "modules/remote_bitrate_estimator/include/bwe_defines.h"
namespace webrtc {
RtcEventBweUpdateDelayBased::RtcEventBweUpdateDelayBased(
int32_t bitrate_bps,
BandwidthUsage detector_state)
: bitrate_bps_(bitrate_bps), detector_state_(detector_state) {}
RtcEventBweUpdateDelayBased::~RtcEventBweUpdateDelayBased() = default;
RtcEvent::Type RtcEventBweUpdateDelayBased::GetType() const {
return RtcEvent::Type::BweUpdateDelayBased;
}

View File

@ -15,13 +15,20 @@
namespace webrtc {
enum class BandwidthUsage;
class RtcEventBweUpdateDelayBased final : public RtcEvent {
public:
~RtcEventBweUpdateDelayBased() override = default;
RtcEventBweUpdateDelayBased(int32_t bitrate_bps,
BandwidthUsage detector_state);
~RtcEventBweUpdateDelayBased() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const int32_t bitrate_bps_;
const BandwidthUsage detector_state_;
};
} // namespace webrtc

View File

@ -12,6 +12,15 @@
namespace webrtc {
RtcEventBweUpdateLossBased::RtcEventBweUpdateLossBased(int32_t bitrate_bps,
uint8_t fraction_loss,
int32_t total_packets)
: bitrate_bps_(bitrate_bps),
fraction_loss_(fraction_loss),
total_packets_(total_packets) {}
RtcEventBweUpdateLossBased::~RtcEventBweUpdateLossBased() = default;
RtcEvent::Type RtcEventBweUpdateLossBased::GetType() const {
return RtcEvent::Type::BweUpdateLossBased;
}

View File

@ -17,11 +17,18 @@ namespace webrtc {
class RtcEventBweUpdateLossBased final : public RtcEvent {
public:
~RtcEventBweUpdateLossBased() override = default;
RtcEventBweUpdateLossBased(int32_t bitrate_bps_,
uint8_t fraction_loss_,
int32_t total_packets_);
~RtcEventBweUpdateLossBased() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const int32_t bitrate_bps_;
const uint8_t fraction_loss_;
const int32_t total_packets_;
};
} // namespace webrtc

View File

@ -12,6 +12,15 @@
namespace webrtc {
RtcEventProbeClusterCreated::RtcEventProbeClusterCreated(int id,
int bitrate_bps,
int min_probes,
int min_bytes)
: id_(id),
bitrate_bps_(bitrate_bps),
min_probes_(min_probes),
min_bytes_(min_bytes) {}
RtcEvent::Type RtcEventProbeClusterCreated::GetType() const {
return RtcEvent::Type::ProbeClusterCreated;
}

View File

@ -17,11 +17,20 @@ namespace webrtc {
class RtcEventProbeClusterCreated final : public RtcEvent {
public:
RtcEventProbeClusterCreated(int id,
int bitrate_bps,
int min_probes,
int min_bytes);
~RtcEventProbeClusterCreated() override = default;
Type GetType() const override;
bool IsConfigEvent() const override;
const int id_;
const int bitrate_bps_;
const int min_probes_;
const int min_bytes_;
};
} // namespace webrtc

View File

@ -12,6 +12,11 @@
namespace webrtc {
RtcEventProbeResultFailure::RtcEventProbeResultFailure(
int id,
ProbeFailureReason failure_reason)
: id_(id), failure_reason_(failure_reason) {}
RtcEvent::Type RtcEventProbeResultFailure::GetType() const {
return RtcEvent::Type::ProbeResultFailure;
}

View File

@ -15,13 +15,23 @@
namespace webrtc {
enum ProbeFailureReason {
kInvalidSendReceiveInterval,
kInvalidSendReceiveRatio,
kTimeout
};
class RtcEventProbeResultFailure final : public RtcEvent {
public:
RtcEventProbeResultFailure(int id, ProbeFailureReason failure_reason);
~RtcEventProbeResultFailure() override = default;
Type GetType() const override;
bool IsConfigEvent() const override;
const int id_;
const ProbeFailureReason failure_reason_;
};
} // namespace webrtc

View File

@ -12,6 +12,9 @@
namespace webrtc {
RtcEventProbeResultSuccess::RtcEventProbeResultSuccess(int id, int bitrate_bps)
: id_(id), bitrate_bps_(bitrate_bps) {}
RtcEvent::Type RtcEventProbeResultSuccess::GetType() const {
return RtcEvent::Type::ProbeResultSuccess;
}

View File

@ -17,11 +17,15 @@ namespace webrtc {
class RtcEventProbeResultSuccess final : public RtcEvent {
public:
RtcEventProbeResultSuccess(int id, int bitrate_bps);
~RtcEventProbeResultSuccess() override = default;
Type GetType() const override;
bool IsConfigEvent() const override;
const int id_;
const int bitrate_bps_;
};
} // namespace webrtc

View File

@ -12,6 +12,12 @@
namespace webrtc {
RtcEventRtcpPacketIncoming::RtcEventRtcpPacketIncoming(
rtc::ArrayView<const uint8_t> packet)
: packet_(packet.data(), packet.size()) {}
RtcEventRtcpPacketIncoming::~RtcEventRtcpPacketIncoming() = default;
RtcEvent::Type RtcEventRtcpPacketIncoming::GetType() const {
return RtcEvent::Type::RtcpPacketIncoming;
}

View File

@ -11,17 +11,22 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTCP_PACKET_INCOMING_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTCP_PACKET_INCOMING_H_
#include "api/array_view.h"
#include "logging/rtc_event_log/events/rtc_event.h"
#include "rtc_base/buffer.h"
namespace webrtc {
class RtcEventRtcpPacketIncoming final : public RtcEvent {
public:
~RtcEventRtcpPacketIncoming() override = default;
explicit RtcEventRtcpPacketIncoming(rtc::ArrayView<const uint8_t> packet);
~RtcEventRtcpPacketIncoming() override;
Type GetType() const override;
bool IsConfigEvent() const override;
rtc::Buffer packet_;
};
} // namespace webrtc

View File

@ -12,6 +12,12 @@
namespace webrtc {
RtcEventRtcpPacketOutgoing::RtcEventRtcpPacketOutgoing(
rtc::ArrayView<const uint8_t> packet)
: packet_(packet.data(), packet.size()) {}
RtcEventRtcpPacketOutgoing::~RtcEventRtcpPacketOutgoing() = default;
RtcEvent::Type RtcEventRtcpPacketOutgoing::GetType() const {
return RtcEvent::Type::RtcpPacketOutgoing;
}

View File

@ -11,17 +11,22 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTCP_PACKET_OUTGOING_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTCP_PACKET_OUTGOING_H_
#include "api/array_view.h"
#include "logging/rtc_event_log/events/rtc_event.h"
#include "rtc_base/buffer.h"
namespace webrtc {
class RtcEventRtcpPacketOutgoing final : public RtcEvent {
public:
~RtcEventRtcpPacketOutgoing() override = default;
explicit RtcEventRtcpPacketOutgoing(rtc::ArrayView<const uint8_t> packet);
~RtcEventRtcpPacketOutgoing() override;
Type GetType() const override;
bool IsConfigEvent() const override;
rtc::Buffer packet_;
};
} // namespace webrtc

View File

@ -10,8 +10,18 @@
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_incoming.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
namespace webrtc {
RtcEventRtpPacketIncoming::RtcEventRtpPacketIncoming(
const RtpPacketReceived& packet)
: packet_length_(packet.size()) {
header_.CopyHeaderFrom(packet);
}
RtcEventRtpPacketIncoming::~RtcEventRtpPacketIncoming() = default;
RtcEvent::Type RtcEventRtpPacketIncoming::GetType() const {
return RtcEvent::Type::RtpPacketIncoming;
}

View File

@ -12,16 +12,23 @@
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_INCOMING_H_
#include "logging/rtc_event_log/events/rtc_event.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
namespace webrtc {
class RtpPacketReceived;
class RtcEventRtpPacketIncoming final : public RtcEvent {
public:
~RtcEventRtpPacketIncoming() override = default;
explicit RtcEventRtpPacketIncoming(const RtpPacketReceived& packet);
~RtcEventRtpPacketIncoming() override;
Type GetType() const override;
bool IsConfigEvent() const override;
RtpPacket header_; // Only the packet's header will be stored here.
const size_t packet_length_; // Length before stripping away all but header.
};
} // namespace webrtc

View File

@ -10,8 +10,19 @@
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
namespace webrtc {
RtcEventRtpPacketOutgoing::RtcEventRtpPacketOutgoing(
const RtpPacketToSend& packet,
int probe_cluster_id)
: packet_length_(packet.size()), probe_cluster_id_(probe_cluster_id) {
header_.CopyHeaderFrom(packet);
}
RtcEventRtpPacketOutgoing::~RtcEventRtpPacketOutgoing() = default;
RtcEvent::Type RtcEventRtpPacketOutgoing::GetType() const {
return RtcEvent::Type::RtpPacketOutgoing;
}

View File

@ -12,16 +12,25 @@
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_OUTGOING_H_
#include "logging/rtc_event_log/events/rtc_event.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
namespace webrtc {
class RtpPacketToSend;
class RtcEventRtpPacketOutgoing final : public RtcEvent {
public:
~RtcEventRtpPacketOutgoing() override = default;
RtcEventRtpPacketOutgoing(const RtpPacketToSend& packet,
int probe_cluster_id);
~RtcEventRtpPacketOutgoing() override;
Type GetType() const override;
bool IsConfigEvent() const override;
RtpPacket header_; // Only the packet's header will be stored here.
const size_t packet_length_; // Length before stripping away all but header.
const int probe_cluster_id_;
};
} // namespace webrtc

View File

@ -10,8 +10,16 @@
#include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h"
#include <utility>
namespace webrtc {
RtcEventVideoReceiveStreamConfig::RtcEventVideoReceiveStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config)
: config_(std::move(config)) {}
RtcEventVideoReceiveStreamConfig::~RtcEventVideoReceiveStreamConfig() = default;
RtcEvent::Type RtcEventVideoReceiveStreamConfig::GetType() const {
return Type::VideoReceiveStreamConfig;
}

View File

@ -11,17 +11,24 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_VIDEO_RECEIVE_STREAM_CONFIG_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_VIDEO_RECEIVE_STREAM_CONFIG_H_
#include <memory>
#include "logging/rtc_event_log/events/rtc_event.h"
#include "logging/rtc_event_log/rtc_stream_config.h"
namespace webrtc {
class RtcEventVideoReceiveStreamConfig final : public RtcEvent {
public:
~RtcEventVideoReceiveStreamConfig() override = default;
explicit RtcEventVideoReceiveStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config);
~RtcEventVideoReceiveStreamConfig() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const std::unique_ptr<const rtclog::StreamConfig> config_;
};
} // namespace webrtc

View File

@ -10,8 +10,16 @@
#include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h"
#include <utility>
namespace webrtc {
RtcEventVideoSendStreamConfig::RtcEventVideoSendStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config)
: config_(std::move(config)) {}
RtcEventVideoSendStreamConfig::~RtcEventVideoSendStreamConfig() = default;
RtcEvent::Type RtcEventVideoSendStreamConfig::GetType() const {
return RtcEvent::Type::VideoSendStreamConfig;
}

View File

@ -11,17 +11,24 @@
#ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_VIDEO_SEND_STREAM_CONFIG_H_
#define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_VIDEO_SEND_STREAM_CONFIG_H_
#include <memory>
#include "logging/rtc_event_log/events/rtc_event.h"
#include "logging/rtc_event_log/rtc_stream_config.h"
namespace webrtc {
class RtcEventVideoSendStreamConfig final : public RtcEvent {
public:
~RtcEventVideoSendStreamConfig() override = default;
explicit RtcEventVideoSendStreamConfig(
std::unique_ptr<rtclog::StreamConfig> config);
~RtcEventVideoSendStreamConfig() override;
Type GetType() const override;
bool IsConfigEvent() const override;
const std::unique_ptr<const rtclog::StreamConfig> config_;
};
} // namespace webrtc

View File

@ -19,6 +19,9 @@
// TODO(eladalon): Get rid of this later in the CL-stack.
#include "api/rtpparameters.h"
#include "common_types.h" // NOLINT(build/include)
// 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"
#include "rtc_base/platform_file.h"
namespace webrtc {
@ -38,11 +41,6 @@ enum class MediaType;
enum class BandwidthUsage;
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
enum ProbeFailureReason {
kInvalidSendReceiveInterval,
kInvalidSendReceiveRatio,
kTimeout
};
class RtcEventLog {
public: