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}
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder.h b/logging/rtc_event_log/encoder/rtc_event_log_encoder.h
index 8f509ce..beb711c 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder.h
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder.h
@@ -25,8 +25,6 @@
virtual std::string EncodeLogStart(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(
std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) = 0;
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
index c05f771..1f02bcc 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc
@@ -105,7 +105,6 @@
}
} // namespace
-
std::string RtcEventLogEncoderLegacy::EncodeLogStart(int64_t timestamp_us) {
rtclog::Event rtclog_event;
rtclog_event.set_timestamp_us(timestamp_us);
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h
index a817313..63102c5 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h
@@ -50,8 +50,6 @@
public:
~RtcEventLogEncoderLegacy() override = default;
- std::string Encode(const RtcEvent& event) override;
-
std::string EncodeLogStart(int64_t timestamp_us) override;
std::string EncodeLogEnd(int64_t timestamp_us) override;
@@ -60,6 +58,7 @@
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override;
private:
+ std::string Encode(const RtcEvent& event);
// Encoding entry-point for the various RtcEvent subclasses.
std::string EncodeAlrState(const RtcEventAlrState& event);
std::string EncodeAudioNetworkAdaptation(
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
index 00dad29..a8e6e8d 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
@@ -9,6 +9,7 @@
*/
#include <cmath>
+#include <deque>
#include <limits>
#include <memory>
#include <string>
@@ -117,6 +118,7 @@
int RandomBitrate() { return RandomInt(); }
+ std::deque<std::unique_ptr<RtcEvent>> history_;
// TODO(eladalon): Once we have more than once possible encoder, parameterize
// encoder selection.
std::unique_ptr<RtcEventLogEncoder> encoder_;
@@ -126,12 +128,16 @@
void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
std::unique_ptr<AudioEncoderRuntimeConfig> runtime_config) {
+ // This function is called repeatedly. Clear state between calls.
+ history_.clear();
auto original_runtime_config = *runtime_config;
auto event = rtc::MakeUnique<RtcEventAudioNetworkAdaptation>(
std::move(runtime_config));
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_.GetEventType(0),
ParsedRtcEventLog::AUDIO_NETWORK_ADAPTATION_EVENT);
@@ -220,8 +226,10 @@
const uint32_t ssrc = RandomSsrc();
auto event = rtc::MakeUnique<RtcEventAudioPlayout>(ssrc);
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_.GetEventType(0),
ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT);
@@ -248,8 +256,10 @@
auto event = rtc::MakeUnique<RtcEventAudioReceiveStreamConfig>(
std::move(stream_config));
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_.GetEventType(0),
ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT);
@@ -271,8 +281,10 @@
auto event =
rtc::MakeUnique<RtcEventAudioSendStreamConfig>(std::move(stream_config));
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_.GetEventType(0),
ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT);
@@ -289,8 +301,10 @@
auto event =
rtc::MakeUnique<RtcEventBweUpdateDelayBased>(bitrate_bps, detector_state);
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_.GetEventType(0),
ParsedRtcEventLog::DELAY_BASED_BWE_UPDATE);
@@ -311,8 +325,10 @@
auto event = rtc::MakeUnique<RtcEventBweUpdateLossBased>(
bitrate_bps, fraction_loss, total_packets);
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_.GetEventType(0),
ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE);
@@ -358,8 +374,10 @@
auto event = rtc::MakeUnique<RtcEventProbeClusterCreated>(
id, bitrate_bps, min_probes, min_bytes);
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_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_CLUSTER_CREATED_EVENT);
@@ -380,8 +398,10 @@
auto event = rtc::MakeUnique<RtcEventProbeResultFailure>(id, failure_reason);
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_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
@@ -401,8 +421,10 @@
auto event = rtc::MakeUnique<RtcEventProbeResultSuccess>(id, bitrate_bps);
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_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
@@ -428,8 +450,10 @@
event = rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(rtcp_packet);
}
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_.GetEventType(0), ParsedRtcEventLog::RTCP_EVENT);
@@ -480,8 +504,10 @@
probe_cluster_id);
}
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_.GetEventType(0), ParsedRtcEventLog::RTP_EVENT);
@@ -528,8 +554,10 @@
auto event = rtc::MakeUnique<RtcEventVideoReceiveStreamConfig>(
std::move(stream_config));
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_.GetEventType(0),
ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT);
@@ -552,8 +580,10 @@
auto event =
rtc::MakeUnique<RtcEventVideoSendStreamConfig>(std::move(stream_config));
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_.GetEventType(0),
ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT);