Remove RtcEventLogEncoder::Encode method.
Use EncodeBatch method in unittest. (Same as in production code.) Bug: webrtc:8111 Change-Id: Ia194f5138f244da7f348821277f6c712a3ffab0d Reviewed-on: https://webrtc-review.googlesource.com/34560 Commit-Queue: Björn Terelius <terelius@webrtc.org> Reviewed-by: Elad Alon <eladalon@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21696}
This commit is contained in:

committed by
Commit Bot

parent
565e3e07d7
commit
07b35bcd55
@ -25,8 +25,6 @@ class RtcEventLogEncoder {
|
|||||||
virtual std::string EncodeLogStart(int64_t timestamp_us) = 0;
|
virtual std::string EncodeLogStart(int64_t timestamp_us) = 0;
|
||||||
virtual std::string EncodeLogEnd(int64_t timestamp_us) = 0;
|
virtual std::string EncodeLogEnd(int64_t timestamp_us) = 0;
|
||||||
|
|
||||||
virtual std::string Encode(const RtcEvent& event) = 0;
|
|
||||||
|
|
||||||
virtual std::string EncodeBatch(
|
virtual std::string EncodeBatch(
|
||||||
std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
|
std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
|
||||||
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) = 0;
|
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) = 0;
|
||||||
|
@ -105,7 +105,6 @@ rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) {
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
std::string RtcEventLogEncoderLegacy::EncodeLogStart(int64_t timestamp_us) {
|
std::string RtcEventLogEncoderLegacy::EncodeLogStart(int64_t timestamp_us) {
|
||||||
rtclog::Event rtclog_event;
|
rtclog::Event rtclog_event;
|
||||||
rtclog_event.set_timestamp_us(timestamp_us);
|
rtclog_event.set_timestamp_us(timestamp_us);
|
||||||
|
@ -50,8 +50,6 @@ class RtcEventLogEncoderLegacy final : public RtcEventLogEncoder {
|
|||||||
public:
|
public:
|
||||||
~RtcEventLogEncoderLegacy() override = default;
|
~RtcEventLogEncoderLegacy() override = default;
|
||||||
|
|
||||||
std::string Encode(const RtcEvent& event) override;
|
|
||||||
|
|
||||||
std::string EncodeLogStart(int64_t timestamp_us) override;
|
std::string EncodeLogStart(int64_t timestamp_us) override;
|
||||||
std::string EncodeLogEnd(int64_t timestamp_us) override;
|
std::string EncodeLogEnd(int64_t timestamp_us) override;
|
||||||
|
|
||||||
@ -60,6 +58,7 @@ class RtcEventLogEncoderLegacy final : public RtcEventLogEncoder {
|
|||||||
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override;
|
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string Encode(const RtcEvent& event);
|
||||||
// Encoding entry-point for the various RtcEvent subclasses.
|
// Encoding entry-point for the various RtcEvent subclasses.
|
||||||
std::string EncodeAlrState(const RtcEventAlrState& event);
|
std::string EncodeAlrState(const RtcEventAlrState& event);
|
||||||
std::string EncodeAudioNetworkAdaptation(
|
std::string EncodeAudioNetworkAdaptation(
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <deque>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -117,6 +118,7 @@ class RtcEventLogEncoderTest : public testing::TestWithParam<int> {
|
|||||||
|
|
||||||
int RandomBitrate() { return RandomInt(); }
|
int RandomBitrate() { return RandomInt(); }
|
||||||
|
|
||||||
|
std::deque<std::unique_ptr<RtcEvent>> history_;
|
||||||
// TODO(eladalon): Once we have more than once possible encoder, parameterize
|
// TODO(eladalon): Once we have more than once possible encoder, parameterize
|
||||||
// encoder selection.
|
// encoder selection.
|
||||||
std::unique_ptr<RtcEventLogEncoder> encoder_;
|
std::unique_ptr<RtcEventLogEncoder> encoder_;
|
||||||
@ -126,12 +128,16 @@ class RtcEventLogEncoderTest : public testing::TestWithParam<int> {
|
|||||||
|
|
||||||
void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
|
void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
|
||||||
std::unique_ptr<AudioEncoderRuntimeConfig> runtime_config) {
|
std::unique_ptr<AudioEncoderRuntimeConfig> runtime_config) {
|
||||||
|
// This function is called repeatedly. Clear state between calls.
|
||||||
|
history_.clear();
|
||||||
auto original_runtime_config = *runtime_config;
|
auto original_runtime_config = *runtime_config;
|
||||||
auto event = rtc::MakeUnique<RtcEventAudioNetworkAdaptation>(
|
auto event = rtc::MakeUnique<RtcEventAudioNetworkAdaptation>(
|
||||||
std::move(runtime_config));
|
std::move(runtime_config));
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::AUDIO_NETWORK_ADAPTATION_EVENT);
|
ParsedRtcEventLog::AUDIO_NETWORK_ADAPTATION_EVENT);
|
||||||
@ -220,8 +226,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioPlayout) {
|
|||||||
const uint32_t ssrc = RandomSsrc();
|
const uint32_t ssrc = RandomSsrc();
|
||||||
auto event = rtc::MakeUnique<RtcEventAudioPlayout>(ssrc);
|
auto event = rtc::MakeUnique<RtcEventAudioPlayout>(ssrc);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT);
|
ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT);
|
||||||
@ -248,8 +256,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioReceiveStreamConfig) {
|
|||||||
auto event = rtc::MakeUnique<RtcEventAudioReceiveStreamConfig>(
|
auto event = rtc::MakeUnique<RtcEventAudioReceiveStreamConfig>(
|
||||||
std::move(stream_config));
|
std::move(stream_config));
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT);
|
ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT);
|
||||||
@ -271,8 +281,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioSendStreamConfig) {
|
|||||||
auto event =
|
auto event =
|
||||||
rtc::MakeUnique<RtcEventAudioSendStreamConfig>(std::move(stream_config));
|
rtc::MakeUnique<RtcEventAudioSendStreamConfig>(std::move(stream_config));
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT);
|
ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT);
|
||||||
@ -289,8 +301,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateDelayBased) {
|
|||||||
auto event =
|
auto event =
|
||||||
rtc::MakeUnique<RtcEventBweUpdateDelayBased>(bitrate_bps, detector_state);
|
rtc::MakeUnique<RtcEventBweUpdateDelayBased>(bitrate_bps, detector_state);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::DELAY_BASED_BWE_UPDATE);
|
ParsedRtcEventLog::DELAY_BASED_BWE_UPDATE);
|
||||||
@ -311,8 +325,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateLossBased) {
|
|||||||
auto event = rtc::MakeUnique<RtcEventBweUpdateLossBased>(
|
auto event = rtc::MakeUnique<RtcEventBweUpdateLossBased>(
|
||||||
bitrate_bps, fraction_loss, total_packets);
|
bitrate_bps, fraction_loss, total_packets);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE);
|
ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE);
|
||||||
@ -358,8 +374,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeClusterCreated) {
|
|||||||
auto event = rtc::MakeUnique<RtcEventProbeClusterCreated>(
|
auto event = rtc::MakeUnique<RtcEventProbeClusterCreated>(
|
||||||
id, bitrate_bps, min_probes, min_bytes);
|
id, bitrate_bps, min_probes, min_bytes);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::BWE_PROBE_CLUSTER_CREATED_EVENT);
|
ParsedRtcEventLog::BWE_PROBE_CLUSTER_CREATED_EVENT);
|
||||||
@ -380,8 +398,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultFailure) {
|
|||||||
|
|
||||||
auto event = rtc::MakeUnique<RtcEventProbeResultFailure>(id, failure_reason);
|
auto event = rtc::MakeUnique<RtcEventProbeResultFailure>(id, failure_reason);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
|
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
|
||||||
@ -401,8 +421,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {
|
|||||||
|
|
||||||
auto event = rtc::MakeUnique<RtcEventProbeResultSuccess>(id, bitrate_bps);
|
auto event = rtc::MakeUnique<RtcEventProbeResultSuccess>(id, bitrate_bps);
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
|
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
|
||||||
@ -428,8 +450,10 @@ void RtcEventLogEncoderTest::TestRtcEventRtcpPacket(PacketDirection direction) {
|
|||||||
event = rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(rtcp_packet);
|
event = rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(rtcp_packet);
|
||||||
}
|
}
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::RTCP_EVENT);
|
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::RTCP_EVENT);
|
||||||
|
|
||||||
@ -480,8 +504,10 @@ void RtcEventLogEncoderTest::TestRtcEventRtpPacket(PacketDirection direction) {
|
|||||||
probe_cluster_id);
|
probe_cluster_id);
|
||||||
}
|
}
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::RTP_EVENT);
|
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::RTP_EVENT);
|
||||||
|
|
||||||
@ -528,8 +554,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoReceiveStreamConfig) {
|
|||||||
auto event = rtc::MakeUnique<RtcEventVideoReceiveStreamConfig>(
|
auto event = rtc::MakeUnique<RtcEventVideoReceiveStreamConfig>(
|
||||||
std::move(stream_config));
|
std::move(stream_config));
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT);
|
ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT);
|
||||||
@ -552,8 +580,10 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoSendStreamConfig) {
|
|||||||
auto event =
|
auto event =
|
||||||
rtc::MakeUnique<RtcEventVideoSendStreamConfig>(std::move(stream_config));
|
rtc::MakeUnique<RtcEventVideoSendStreamConfig>(std::move(stream_config));
|
||||||
const int64_t timestamp_us = event->timestamp_us_;
|
const int64_t timestamp_us = event->timestamp_us_;
|
||||||
|
history_.push_back(std::move(event));
|
||||||
|
|
||||||
ASSERT_TRUE(parsed_log_.ParseString(encoder_->Encode(*event)));
|
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
|
||||||
|
ASSERT_TRUE(parsed_log_.ParseString(encoded));
|
||||||
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
|
||||||
ASSERT_EQ(parsed_log_.GetEventType(0),
|
ASSERT_EQ(parsed_log_.GetEventType(0),
|
||||||
ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT);
|
ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT);
|
||||||
|
Reference in New Issue
Block a user