Skip to content

Commit

Permalink
Reland "Create new API for RtcEventLogParser."
Browse files Browse the repository at this point in the history
The new API stores events gathered by event type. For example, it is
possible to ask for a list of all incoming RTCP messages or all audio
playout events.

The new API is experimental and may change over next few weeks. Once
it has stabilized and all unit tests and existing tools have been
ported to the new API, the old one will be removed.

This CL also updates the event_log_visualizer tool to use the new
parser API. This is not a funcional change except for:
- Incoming and outgoing audio level are now drawn in two separate plots.
- Incoming and outgoing timstamps are now drawn in two separate plots.
- RTCP count is no longer split into Video and Audio. It also counts
  all RTCP packets rather than only specific message types.
- Slight timing difference in sendside BWE simulation due to only
  iterating over transport feedbacks and not over all RTCP packets.
  This timing changes are not visible in the plots.


Media type for RTCP messages might not be identified correctly by
rtc_event_log2text anymore. On the other hand, assigning a specific
media type to an RTCP packet was a bit hacky to begin with.

Bug: webrtc:8111
Change-Id: Ib244338c86a2c1a010c668a7aba440482023b512
Reviewed-on: https://webrtc-review.googlesource.com/73140
Reviewed-by: Sebastian Jansson <[email protected]>
Reviewed-by: Minyue Li <[email protected]>
Commit-Queue: Björn Terelius <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23056}
  • Loading branch information
Bjorn Terelius authored and Commit Bot committed Apr 27, 2018
1 parent ebd9abc commit c4ca1d3
Show file tree
Hide file tree
Showing 23 changed files with 3,390 additions and 1,527 deletions.
8 changes: 4 additions & 4 deletions logging/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ group("logging") {
":rtc_event_rtp_rtcp",
":rtc_event_video",
]

if (rtc_enable_protobuf) {
deps += [ ":rtc_event_log_parser" ]
}
}

rtc_source_set("rtc_event_log_api") {
Expand Down Expand Up @@ -256,6 +252,8 @@ if (rtc_enable_protobuf) {
sources = [
"rtc_event_log/rtc_event_log_parser.cc",
"rtc_event_log/rtc_event_log_parser.h",
"rtc_event_log/rtc_event_log_parser_new.cc",
"rtc_event_log/rtc_event_log_parser_new.h",
]

deps = [
Expand All @@ -266,6 +264,7 @@ if (rtc_enable_protobuf) {
":rtc_event_log_proto",
":rtc_stream_config",
"..:webrtc_common",
"../api:libjingle_peerconnection_api",
"../call:video_stream_api",
"../modules/audio_coding:audio_network_adaptor",
"../modules/remote_bitrate_estimator:remote_bitrate_estimator",
Expand Down Expand Up @@ -366,6 +365,7 @@ if (rtc_enable_protobuf) {
"../rtc_base:checks",
"../rtc_base:protobuf_utils",
"../rtc_base:rtc_base_approved",
"../rtc_base:stringutils",

# TODO(kwiberg): Remove this dependency.
"../api/audio_codecs:audio_codecs_api",
Expand Down
63 changes: 29 additions & 34 deletions logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
#include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h"
#include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h"
#include "logging/rtc_event_log/rtc_event_log_parser.h"
#include "logging/rtc_event_log/rtc_event_log_parser_new.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "modules/remote_bitrate_estimator/include/bwe_defines.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h" // Arbitrary RTCP message.
Expand Down Expand Up @@ -122,7 +122,7 @@ class RtcEventLogEncoderTest : public testing::TestWithParam<int> {
// TODO(eladalon): Once we have more than once possible encoder, parameterize
// encoder selection.
std::unique_ptr<RtcEventLogEncoder> encoder_;
ParsedRtcEventLog parsed_log_;
ParsedRtcEventLogNew parsed_log_;
Random prng_;
};

Expand All @@ -140,13 +140,13 @@ void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::AUDIO_NETWORK_ADAPTATION_EVENT);
ParsedRtcEventLogNew::AUDIO_NETWORK_ADAPTATION_EVENT);

AudioEncoderRuntimeConfig parsed_runtime_config;
parsed_log_.GetAudioNetworkAdaptation(0, &parsed_runtime_config);
LoggedAudioNetworkAdaptationEvent parsed_event =
parsed_log_.GetAudioNetworkAdaptation(0);

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
EXPECT_EQ(parsed_runtime_config, original_runtime_config);
EXPECT_EQ(parsed_event.timestamp_us, timestamp_us);
EXPECT_EQ(parsed_event.config, original_runtime_config);
}

TEST_P(RtcEventLogEncoderTest, RtcEventAudioNetworkAdaptationBitrate) {
Expand Down Expand Up @@ -232,13 +232,12 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioPlayout) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT);
ParsedRtcEventLogNew::AUDIO_PLAYOUT_EVENT);

uint32_t parsed_ssrc;
parsed_log_.GetAudioPlayout(0, &parsed_ssrc);
LoggedAudioPlayoutEvent playout_event = parsed_log_.GetAudioPlayout(0);

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
EXPECT_EQ(parsed_ssrc, ssrc);
EXPECT_EQ(playout_event.timestamp_us, timestamp_us);
EXPECT_EQ(playout_event.ssrc, ssrc);
}

TEST_P(RtcEventLogEncoderTest, RtcEventAudioReceiveStreamConfig) {
Expand All @@ -262,7 +261,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioReceiveStreamConfig) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT);
ParsedRtcEventLogNew::AUDIO_RECEIVER_CONFIG_EVENT);

auto parsed_event = parsed_log_.GetAudioReceiveConfig(0);
EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
Expand All @@ -287,7 +286,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioSendStreamConfig) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT);
ParsedRtcEventLogNew::AUDIO_SENDER_CONFIG_EVENT);

auto parsed_event = parsed_log_.GetAudioSendConfig(0);
EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
Expand All @@ -307,7 +306,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateDelayBased) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::DELAY_BASED_BWE_UPDATE);
ParsedRtcEventLogNew::DELAY_BASED_BWE_UPDATE);

auto parsed_event = parsed_log_.GetDelayBasedBweUpdate(0);

Expand All @@ -331,26 +330,22 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateLossBased) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::LOSS_BASED_BWE_UPDATE);
ParsedRtcEventLogNew::LOSS_BASED_BWE_UPDATE);

int32_t parsed_bitrate_bps;
uint8_t parsed_fraction_loss;
int32_t parsed_total_packets;
parsed_log_.GetLossBasedBweUpdate(
0, &parsed_bitrate_bps, &parsed_fraction_loss, &parsed_total_packets);
LoggedBweLossBasedUpdate bwe_update = parsed_log_.GetLossBasedBweUpdate(0);

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
EXPECT_EQ(parsed_bitrate_bps, bitrate_bps);
EXPECT_EQ(parsed_fraction_loss, fraction_loss);
EXPECT_EQ(parsed_total_packets, total_packets);
EXPECT_EQ(bwe_update.timestamp_us, timestamp_us);
EXPECT_EQ(bwe_update.bitrate_bps, bitrate_bps);
EXPECT_EQ(bwe_update.fraction_lost, fraction_loss);
EXPECT_EQ(bwe_update.expected_packets, total_packets);
}

TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) {
const int64_t timestamp_us = rtc::TimeMicros();

ASSERT_TRUE(parsed_log_.ParseString(encoder_->EncodeLogStart(timestamp_us)));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::LOG_START);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLogNew::LOG_START);

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
}
Expand All @@ -360,7 +355,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStopped) {

ASSERT_TRUE(parsed_log_.ParseString(encoder_->EncodeLogEnd(timestamp_us)));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLog::LOG_END);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLogNew::LOG_END);

EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
}
Expand All @@ -380,7 +375,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeClusterCreated) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_CLUSTER_CREATED_EVENT);
ParsedRtcEventLogNew::BWE_PROBE_CLUSTER_CREATED_EVENT);

auto parsed_event = parsed_log_.GetBweProbeClusterCreated(0);

Expand All @@ -404,7 +399,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultFailure) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
ParsedRtcEventLogNew::BWE_PROBE_RESULT_EVENT);

auto parsed_event = parsed_log_.GetBweProbeResult(0);

Expand All @@ -427,7 +422,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::BWE_PROBE_RESULT_EVENT);
ParsedRtcEventLogNew::BWE_PROBE_RESULT_EVENT);

auto parsed_event = parsed_log_.GetBweProbeResult(0);

Expand All @@ -454,7 +449,7 @@ void RtcEventLogEncoderTest::TestRtcEventRtcpPacket(PacketDirection direction) {
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);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLogNew::RTCP_EVENT);

PacketDirection parsed_direction;
uint8_t parsed_packet[IP_PACKET_SIZE]; // "Parsed" = after event-encoding.
Expand Down Expand Up @@ -508,7 +503,7 @@ void RtcEventLogEncoderTest::TestRtcEventRtpPacket(PacketDirection direction) {
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);
ASSERT_EQ(parsed_log_.GetEventType(0), ParsedRtcEventLogNew::RTP_EVENT);

PacketDirection parsed_direction;
uint8_t parsed_rtp_header[IP_PACKET_SIZE];
Expand Down Expand Up @@ -559,7 +554,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoReceiveStreamConfig) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT);
ParsedRtcEventLogNew::VIDEO_RECEIVER_CONFIG_EVENT);

auto parsed_event = parsed_log_.GetVideoReceiveConfig(0);
EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
Expand All @@ -585,7 +580,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoSendStreamConfig) {
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_EQ(parsed_log_.GetNumberOfEvents(), 1u);
ASSERT_EQ(parsed_log_.GetEventType(0),
ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT);
ParsedRtcEventLogNew::VIDEO_SENDER_CONFIG_EVENT);

auto parsed_event = parsed_log_.GetVideoSendConfig(0)[0];
EXPECT_EQ(parsed_log_.GetTimestamp(0), timestamp_us);
Expand Down
1 change: 1 addition & 0 deletions logging/rtc_event_log/rtc_event_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace webrtc {

// TODO(terelius): Move this to the parser.
enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };

class RtcEventLog {
Expand Down
12 changes: 6 additions & 6 deletions logging/rtc_event_log/rtc_event_log2rtp_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string>

#include "logging/rtc_event_log/rtc_event_log.h"
#include "logging/rtc_event_log/rtc_event_log_parser.h"
#include "logging/rtc_event_log/rtc_event_log_parser_new.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/checks.h"
Expand All @@ -25,7 +25,7 @@

namespace {

using MediaType = webrtc::ParsedRtcEventLog::MediaType;
using MediaType = webrtc::ParsedRtcEventLogNew::MediaType;

DEFINE_bool(
audio,
Expand Down Expand Up @@ -102,7 +102,7 @@ int main(int argc, char* argv[]) {
RTC_CHECK(ParseSsrc(FLAG_ssrc, &ssrc_filter))
<< "Flag verification has failed.";

webrtc::ParsedRtcEventLog parsed_stream;
webrtc::ParsedRtcEventLogNew parsed_stream;
if (!parsed_stream.ParseFile(input_file)) {
std::cerr << "Error while parsing input file: " << input_file << std::endl;
return -1;
Expand All @@ -127,8 +127,8 @@ int main(int argc, char* argv[]) {
// some required fields and we attempt to access them. We could consider
// a softer failure option, but it does not seem useful to generate
// RTP dumps based on broken event logs.
if (FLAG_rtp &&
parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) {
if (FLAG_rtp && parsed_stream.GetEventType(i) ==
webrtc::ParsedRtcEventLogNew::RTP_EVENT) {
webrtc::test::RtpPacket packet;
webrtc::PacketDirection direction;
parsed_stream.GetRtpHeader(i, &direction, packet.data, &packet.length,
Expand Down Expand Up @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) {
rtp_counter++;
}
if (FLAG_rtcp && parsed_stream.GetEventType(i) ==
webrtc::ParsedRtcEventLog::RTCP_EVENT) {
webrtc::ParsedRtcEventLogNew::RTCP_EVENT) {
webrtc::test::RtpPacket packet;
webrtc::PacketDirection direction;
parsed_stream.GetRtcpPacket(i, &direction, packet.data, &packet.length);
Expand Down
Loading

0 comments on commit c4ca1d3

Please sign in to comment.