Parse and plot RTCP BYE in RTC event log.

Bug: webrtc:12432
Change-Id: I9a98876044e0e75ee4f3ef975ae75237606d108d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/204380
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Lahiru Ginnaliya Gamathige <glahiru@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33161}
This commit is contained in:
Björn Terelius 2021-02-03 14:12:24 +01:00 committed by Commit Bot
parent 14b036d436
commit 4ef5638871
7 changed files with 116 additions and 5 deletions

View File

@ -1035,6 +1035,44 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPli) {
}
}
TEST_P(RtcEventLogEncoderTest, RtcEventRtcpBye) {
if (force_repeated_fields_) {
return;
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTime(Timestamp::Millis(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::Bye> events(event_count_);
std::vector<int64_t> timestamps_us(event_count_);
for (size_t i = 0; i < event_count_; ++i) {
timestamps_us[i] = rtc::TimeMicros();
events[i] = gen_.NewBye();
rtc::Buffer buffer = events[i].Build();
if (direction == kIncomingPacket) {
history_.push_back(
std::make_unique<RtcEventRtcpPacketIncoming>(buffer));
} else {
history_.push_back(
std::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& byes = parsed_log_.byes(direction);
ASSERT_EQ(byes.size(), event_count_);
for (size_t i = 0; i < event_count_; ++i) {
verifier_.VerifyLoggedBye(timestamps_us[i], events[i], byes[i]);
}
}
}
TEST_P(RtcEventLogEncoderTest, RtcEventRtcpNack) {
if (force_repeated_fields_) {
return;

View File

@ -17,6 +17,7 @@
#include "api/rtp_headers.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
#include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
#include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h"
@ -228,6 +229,16 @@ struct LoggedRtcpPacketLossNotification {
rtcp::LossNotification loss_notification;
};
struct LoggedRtcpPacketBye {
LoggedRtcpPacketBye() = default;
int64_t log_time_us() const { return timestamp_us; }
int64_t log_time_ms() const { return timestamp_us / 1000; }
int64_t timestamp_us;
rtcp::Bye bye;
};
struct LoggedStartEvent {
explicit LoggedStartEvent(int64_t timestamp_us)
: LoggedStartEvent(timestamp_us, timestamp_us / 1000) {}

View File

@ -694,6 +694,7 @@ ParsedRtcEventLog::ParseStatus StoreRtcpBlocks(
std::vector<LoggedRtcpPacketNack>* nack_list,
std::vector<LoggedRtcpPacketFir>* fir_list,
std::vector<LoggedRtcpPacketPli>* pli_list,
std::vector<LoggedRtcpPacketBye>* bye_list,
std::vector<LoggedRtcpPacketTransportFeedback>* transport_feedback_list,
std::vector<LoggedRtcpPacketLossNotification>* loss_notification_list) {
rtcp::CommonHeader header;
@ -738,7 +739,13 @@ ParsedRtcEventLog::ParseStatus StoreRtcpBlocks(
if (parsed_block.pli.Parse(header)) {
pli_list->push_back(std::move(parsed_block));
}
} else if (header.type() == rtcp::Remb::kPacketType &&
} else if (header.type() == rtcp::Bye::kPacketType) {
LoggedRtcpPacketBye parsed_block;
parsed_block.timestamp_us = timestamp_us;
if (parsed_block.bye.Parse(header)) {
bye_list->push_back(std::move(parsed_block));
}
} else if (header.type() == rtcp::Psfb::kPacketType &&
header.fmt() == rtcp::Psfb::kAfbMessageType) {
bool type_found = false;
if (!type_found) {
@ -1182,7 +1189,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream(
auto status = StoreRtcpBlocks(
timestamp_us, packet_begin, packet_end, &incoming_sr_, &incoming_rr_,
&incoming_xr_, &incoming_remb_, &incoming_nack_, &incoming_fir_,
&incoming_pli_, &incoming_transport_feedback_,
&incoming_pli_, &incoming_bye_, &incoming_transport_feedback_,
&incoming_loss_notification_);
RTC_RETURN_IF_ERROR(status);
}
@ -1194,7 +1201,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream(
auto status = StoreRtcpBlocks(
timestamp_us, packet_begin, packet_end, &outgoing_sr_, &outgoing_rr_,
&outgoing_xr_, &outgoing_remb_, &outgoing_nack_, &outgoing_fir_,
&outgoing_pli_, &outgoing_transport_feedback_,
&outgoing_pli_, &outgoing_bye_, &outgoing_transport_feedback_,
&outgoing_loss_notification_);
RTC_RETURN_IF_ERROR(status);
}

View File

@ -603,6 +603,15 @@ class ParsedRtcEventLog {
}
}
const std::vector<LoggedRtcpPacketBye>& byes(
PacketDirection direction) const {
if (direction == kIncomingPacket) {
return incoming_bye_;
} else {
return outgoing_bye_;
}
}
const std::vector<LoggedRtcpPacketTransportFeedback>& transport_feedbacks(
PacketDirection direction) const {
if (direction == kIncomingPacket) {
@ -849,6 +858,8 @@ class ParsedRtcEventLog {
std::vector<LoggedRtcpPacketFir> outgoing_fir_;
std::vector<LoggedRtcpPacketPli> incoming_pli_;
std::vector<LoggedRtcpPacketPli> outgoing_pli_;
std::vector<LoggedRtcpPacketBye> incoming_bye_;
std::vector<LoggedRtcpPacketBye> outgoing_bye_;
std::vector<LoggedRtcpPacketTransportFeedback> incoming_transport_feedback_;
std::vector<LoggedRtcpPacketTransportFeedback> outgoing_transport_feedback_;
std::vector<LoggedRtcpPacketLossNotification> incoming_loss_notification_;

View File

@ -338,6 +338,19 @@ rtcp::Pli EventGenerator::NewPli() {
return pli;
}
rtcp::Bye EventGenerator::NewBye() {
rtcp::Bye bye;
bye.SetSenderSsrc(prng_.Rand<uint32_t>());
std::vector<uint32_t> csrcs{prng_.Rand<uint32_t>(), prng_.Rand<uint32_t>()};
bye.SetCsrcs(csrcs);
if (prng_.Rand(0, 2)) {
bye.SetReason("foo");
} else {
bye.SetReason("bar");
}
return bye;
}
rtcp::TransportFeedback EventGenerator::NewTransportFeedback() {
rtcp::TransportFeedback transport_feedback;
uint16_t base_seq_no = prng_.Rand<uint16_t>();
@ -396,6 +409,7 @@ EventGenerator::NewRtcpPacketIncoming() {
kPli,
kNack,
kRemb,
kBye,
kTransportFeedback,
kNumValues
};
@ -437,6 +451,11 @@ EventGenerator::NewRtcpPacketIncoming() {
rtc::Buffer buffer = remb.Build();
return std::make_unique<RtcEventRtcpPacketIncoming>(buffer);
}
case SupportedRtcpTypes::kBye: {
rtcp::Bye bye = NewBye();
rtc::Buffer buffer = bye.Build();
return std::make_unique<RtcEventRtcpPacketIncoming>(buffer);
}
case SupportedRtcpTypes::kTransportFeedback: {
rtcp::TransportFeedback transport_feedback = NewTransportFeedback();
rtc::Buffer buffer = transport_feedback.Build();
@ -459,6 +478,7 @@ EventGenerator::NewRtcpPacketOutgoing() {
kPli,
kNack,
kRemb,
kBye,
kTransportFeedback,
kNumValues
};
@ -500,6 +520,11 @@ EventGenerator::NewRtcpPacketOutgoing() {
rtc::Buffer buffer = remb.Build();
return std::make_unique<RtcEventRtcpPacketOutgoing>(buffer);
}
case SupportedRtcpTypes::kBye: {
rtcp::Bye bye = NewBye();
rtc::Buffer buffer = bye.Build();
return std::make_unique<RtcEventRtcpPacketOutgoing>(buffer);
}
case SupportedRtcpTypes::kTransportFeedback: {
rtcp::TransportFeedback transport_feedback = NewTransportFeedback();
rtc::Buffer buffer = transport_feedback.Build();
@ -1133,6 +1158,7 @@ void EventVerifier::VerifyLoggedExtendedReports(
int64_t log_time_us,
const rtcp::ExtendedReports& original_xr,
const LoggedRtcpPacketExtendedReports& logged_xr) {
EXPECT_EQ(log_time_us, logged_xr.log_time_us());
EXPECT_EQ(original_xr.sender_ssrc(), logged_xr.xr.sender_ssrc());
EXPECT_EQ(original_xr.rrtr().has_value(), logged_xr.xr.rrtr().has_value());
@ -1173,8 +1199,8 @@ void EventVerifier::VerifyLoggedExtendedReports(
void EventVerifier::VerifyLoggedFir(int64_t log_time_us,
const rtcp::Fir& original_fir,
const LoggedRtcpPacketFir& logged_fir) {
EXPECT_EQ(log_time_us, logged_fir.log_time_us());
EXPECT_EQ(original_fir.sender_ssrc(), logged_fir.fir.sender_ssrc());
const auto& original_requests = original_fir.requests();
const auto& logged_requests = logged_fir.fir.requests();
ASSERT_EQ(original_requests.size(), logged_requests.size());
@ -1187,10 +1213,20 @@ void EventVerifier::VerifyLoggedFir(int64_t log_time_us,
void EventVerifier::VerifyLoggedPli(int64_t log_time_us,
const rtcp::Pli& original_pli,
const LoggedRtcpPacketPli& logged_pli) {
EXPECT_EQ(log_time_us, logged_pli.log_time_us());
EXPECT_EQ(original_pli.sender_ssrc(), logged_pli.pli.sender_ssrc());
EXPECT_EQ(original_pli.media_ssrc(), logged_pli.pli.media_ssrc());
}
void EventVerifier::VerifyLoggedBye(int64_t log_time_us,
const rtcp::Bye& original_bye,
const LoggedRtcpPacketBye& logged_bye) {
EXPECT_EQ(log_time_us, logged_bye.log_time_us());
EXPECT_EQ(original_bye.sender_ssrc(), logged_bye.bye.sender_ssrc());
EXPECT_EQ(original_bye.csrcs(), logged_bye.bye.csrcs());
EXPECT_EQ(original_bye.reason(), logged_bye.bye.reason());
}
void EventVerifier::VerifyLoggedNack(int64_t log_time_us,
const rtcp::Nack& original_nack,
const LoggedRtcpPacketNack& logged_nack) {

View File

@ -45,6 +45,7 @@
#include "logging/rtc_event_log/rtc_event_log_parser.h"
#include "logging/rtc_event_log/rtc_stream_config.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
#include "modules/rtp_rtcp/source/rtcp_packet/fir.h"
#include "modules/rtp_rtcp/source/rtcp_packet/loss_notification.h"
@ -93,6 +94,7 @@ class EventGenerator {
rtcp::Remb NewRemb();
rtcp::Fir NewFir();
rtcp::Pli NewPli();
rtcp::Bye NewBye();
rtcp::TransportFeedback NewTransportFeedback();
rtcp::LossNotification NewLossNotification();
@ -275,6 +277,9 @@ class EventVerifier {
void VerifyLoggedPli(int64_t log_time_us,
const rtcp::Pli& original_pli,
const LoggedRtcpPacketPli& logged_pli);
void VerifyLoggedBye(int64_t log_time_us,
const rtcp::Bye& original_bye,
const LoggedRtcpPacketBye& logged_bye);
void VerifyLoggedNack(int64_t log_time_us,
const rtcp::Nack& original_nack,
const LoggedRtcpPacketNack& logged_nack);

View File

@ -445,6 +445,8 @@ void EventLogAnalyzer::CreateRtcpTypeGraph(PacketDirection direction,
CreateRtcpTypeTimeSeries(parsed_log_.firs(direction), config_, "FIR", 7));
plot->AppendTimeSeries(
CreateRtcpTypeTimeSeries(parsed_log_.plis(direction), config_, "PLI", 8));
plot->AppendTimeSeries(
CreateRtcpTypeTimeSeries(parsed_log_.byes(direction), config_, "BYE", 9));
plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
"Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "RTCP type", kBottomMargin, kTopMargin);
@ -456,7 +458,8 @@ void EventLogAnalyzer::CreateRtcpTypeGraph(PacketDirection direction,
{5, "NACK"},
{6, "REMB"},
{7, "FIR"},
{8, "PLI"}});
{8, "PLI"},
{9, "BYE"}});
}
template <typename IterableType>