Return status instead of CHECKing in event log parser.

This CL adds ParseStatus/ParseStatusOr classes and returns those instead
of CHECKing that the log is well formed. Some refactoring was required.

We also add a allow_incomplete_logs parameter to the parser which by
default is false. Setting it to true will make the parser log a warning
but return success for errors that typically indicate that the log has
been truncated. "Deeper" errors indicating log corruption still return
an error.

Bug: webrtc:11064
Change-Id: Id5bd6e321de07e250662ae3aaa5ef15f48db6d55
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158746
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29679}
This commit is contained in:
Björn Terelius 2019-11-01 14:31:46 +01:00 committed by Commit Bot
parent cc9bf6398c
commit a06048a41e
10 changed files with 1006 additions and 709 deletions

View file

@ -102,7 +102,7 @@ void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& ana_configs = parsed_log_.audio_network_adaptation_events();
ASSERT_EQ(ana_configs.size(), events.size());
@ -182,7 +182,7 @@ void RtcEventLogEncoderTest::TestRtpPackets() {
// Encode and parse.
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
// For each SSRC, make sure the RTP packets associated with it to have been
// correctly encoded and parsed.
@ -209,7 +209,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAlrState) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& alr_state_events = parsed_log_.alr_state_events();
ASSERT_EQ(alr_state_events.size(), event_count_);
@ -230,7 +230,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRouteChange) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& route_change_events = parsed_log_.route_change_events();
ASSERT_EQ(route_change_events.size(), event_count_);
@ -252,7 +252,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRemoteEstimate) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& parsed_events = parsed_log_.remote_estimate_events();
ASSERT_EQ(parsed_events.size(), event_count_);
@ -406,7 +406,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioPlayout) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& parsed_playout_events_by_ssrc =
parsed_log_.audio_playout_events();
@ -442,7 +442,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioReceiveStreamConfig) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& audio_recv_configs = parsed_log_.audio_recv_configs();
ASSERT_EQ(audio_recv_configs.size(), 1u);
@ -458,7 +458,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioSendStreamConfig) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& audio_send_configs = parsed_log_.audio_send_configs();
ASSERT_EQ(audio_send_configs.size(), 1u);
@ -476,7 +476,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateDelayBased) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& bwe_delay_updates = parsed_log_.bwe_delay_updates();
ASSERT_EQ(bwe_delay_updates.size(), event_count_);
@ -496,7 +496,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateLossBased) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& bwe_loss_updates = parsed_log_.bwe_loss_updates();
ASSERT_EQ(bwe_loss_updates.size(), event_count_);
@ -520,7 +520,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketReceived) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& packets_received = parsed_log_.generic_packets_received();
ASSERT_EQ(packets_received.size(), event_count_);
@ -544,7 +544,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketSent) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& packets_sent = parsed_log_.generic_packets_sent();
ASSERT_EQ(packets_sent.size(), event_count_);
@ -567,7 +567,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericAcksReceived) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& decoded_events = parsed_log_.generic_acks_received();
ASSERT_EQ(decoded_events.size(), event_count_);
@ -588,7 +588,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventDtlsTransportState) {
const std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& dtls_transport_states = parsed_log_.dtls_transport_states();
if (!new_encoding_) {
@ -614,7 +614,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventDtlsWritableState) {
const std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& dtls_writable_states = parsed_log_.dtls_writable_states();
if (!new_encoding_) {
@ -637,7 +637,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventIceCandidatePairConfig) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& ice_candidate_pair_configs =
parsed_log_.ice_candidate_pair_configs();
@ -652,7 +652,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventIceCandidatePair) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& ice_candidate_pair_events =
parsed_log_.ice_candidate_pair_events();
@ -665,8 +665,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) {
const int64_t timestamp_us = rtc::TimeMicros();
const int64_t utc_time_us = rtc::TimeUTCMicros();
ASSERT_TRUE(parsed_log_.ParseString(
encoder_->EncodeLogStart(timestamp_us, utc_time_us)));
std::string encoded = encoder_->EncodeLogStart(timestamp_us, utc_time_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& start_log_events = parsed_log_.start_log_events();
ASSERT_EQ(start_log_events.size(), 1u);
@ -676,8 +676,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) {
TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStopped) {
const int64_t timestamp_us = rtc::TimeMicros();
ASSERT_TRUE(parsed_log_.ParseString(encoder_->EncodeLogEnd(timestamp_us)));
std::string encoded = encoder_->EncodeLogEnd(timestamp_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& stop_log_events = parsed_log_.stop_log_events();
ASSERT_EQ(stop_log_events.size(), 1u);
@ -691,7 +691,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeClusterCreated) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& bwe_probe_cluster_created_events =
parsed_log_.bwe_probe_cluster_created_events();
@ -707,7 +707,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultFailure) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& bwe_probe_failure_events = parsed_log_.bwe_probe_failure_events();
ASSERT_EQ(bwe_probe_failure_events.size(), 1u);
@ -722,7 +722,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& bwe_probe_success_events = parsed_log_.bwe_probe_success_events();
ASSERT_EQ(bwe_probe_success_events.size(), 1u);
@ -746,7 +746,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPacketIncoming) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& incoming_rtcp_packets = parsed_log_.incoming_rtcp_packets();
ASSERT_EQ(incoming_rtcp_packets.size(), event_count_);
@ -767,7 +767,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPacketOutgoing) {
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& outgoing_rtcp_packets = parsed_log_.outgoing_rtcp_packets();
ASSERT_EQ(outgoing_rtcp_packets.size(), event_count_);
@ -805,7 +805,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpReceiverReport) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& receiver_reports = parsed_log_.receiver_reports(direction);
ASSERT_EQ(receiver_reports.size(), event_count_);
@ -844,7 +844,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpSenderReport) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& sender_reports = parsed_log_.sender_reports(direction);
ASSERT_EQ(sender_reports.size(), event_count_);
@ -883,7 +883,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpExtendedReports) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& extended_reports = parsed_log_.extended_reports(direction);
ASSERT_EQ(extended_reports.size(), event_count_);
@ -922,7 +922,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpFir) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& firs = parsed_log_.firs(direction);
ASSERT_EQ(firs.size(), event_count_);
@ -960,7 +960,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPli) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& plis = parsed_log_.plis(direction);
ASSERT_EQ(plis.size(), event_count_);
@ -998,7 +998,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpNack) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& nacks = parsed_log_.nacks(direction);
ASSERT_EQ(nacks.size(), event_count_);
@ -1036,7 +1036,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpRemb) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& rembs = parsed_log_.rembs(direction);
ASSERT_EQ(rembs.size(), event_count_);
@ -1075,7 +1075,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpTransportFeedback) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& transport_feedbacks =
parsed_log_.transport_feedbacks(direction);
@ -1116,7 +1116,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpLossNotification) {
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& loss_notifications = parsed_log_.loss_notifications(direction);
ASSERT_EQ(loss_notifications.size(), event_count_);
@ -1145,7 +1145,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoReceiveStreamConfig) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& video_recv_configs = parsed_log_.video_recv_configs();
ASSERT_EQ(video_recv_configs.size(), 1u);
@ -1161,7 +1161,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoSendStreamConfig) {
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded));
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
const auto& video_send_configs = parsed_log_.video_send_configs();
ASSERT_EQ(video_send_configs.size(), 1u);

View file

@ -39,4 +39,17 @@ LoggedPacketInfo::LoggedPacketInfo(const LoggedRtpPacket& rtp,
LoggedPacketInfo::LoggedPacketInfo(const LoggedPacketInfo&) = default;
LoggedPacketInfo::~LoggedPacketInfo() {}
LoggedRtcpPacket::LoggedRtcpPacket(int64_t timestamp_us,
const uint8_t* packet,
size_t total_length)
: timestamp_us(timestamp_us), raw_data(packet, packet + total_length) {}
LoggedRtcpPacket::LoggedRtcpPacket(int64_t timestamp_us,
const std::string& packet)
: timestamp_us(timestamp_us), raw_data(packet.size()) {
memcpy(raw_data.data(), packet.data(), packet.size());
}
LoggedRtcpPacket::LoggedRtcpPacket(const LoggedRtcpPacket& rhs) = default;
LoggedRtcpPacket::~LoggedRtcpPacket() = default;
} // namespace webrtc

View file

@ -251,7 +251,7 @@ struct LoggedRemoteEstimateEvent {
};
struct LoggedRtpPacket {
LoggedRtpPacket(uint64_t timestamp_us,
LoggedRtpPacket(int64_t timestamp_us,
RTPHeader header,
size_t header_length,
size_t total_length)
@ -271,7 +271,7 @@ struct LoggedRtpPacket {
};
struct LoggedRtpPacketIncoming {
LoggedRtpPacketIncoming(uint64_t timestamp_us,
LoggedRtpPacketIncoming(int64_t timestamp_us,
RTPHeader header,
size_t header_length,
size_t total_length)
@ -283,7 +283,7 @@ struct LoggedRtpPacketIncoming {
};
struct LoggedRtpPacketOutgoing {
LoggedRtpPacketOutgoing(uint64_t timestamp_us,
LoggedRtpPacketOutgoing(int64_t timestamp_us,
RTPHeader header,
size_t header_length,
size_t total_length)
@ -295,10 +295,10 @@ struct LoggedRtpPacketOutgoing {
};
struct LoggedRtcpPacket {
LoggedRtcpPacket(uint64_t timestamp_us,
LoggedRtcpPacket(int64_t timestamp_us,
const uint8_t* packet,
size_t total_length);
LoggedRtcpPacket(uint64_t timestamp_us, const std::string& packet);
LoggedRtcpPacket(int64_t timestamp_us, const std::string& packet);
LoggedRtcpPacket(const LoggedRtcpPacket&);
~LoggedRtcpPacket();
@ -310,7 +310,7 @@ struct LoggedRtcpPacket {
};
struct LoggedRtcpPacketIncoming {
LoggedRtcpPacketIncoming(uint64_t timestamp_us,
LoggedRtcpPacketIncoming(int64_t timestamp_us,
const uint8_t* packet,
size_t total_length)
: rtcp(timestamp_us, packet, total_length) {}
@ -324,7 +324,7 @@ struct LoggedRtcpPacketIncoming {
};
struct LoggedRtcpPacketOutgoing {
LoggedRtcpPacketOutgoing(uint64_t timestamp_us,
LoggedRtcpPacketOutgoing(int64_t timestamp_us,
const uint8_t* packet,
size_t total_length)
: rtcp(timestamp_us, packet, total_length) {}

View file

@ -186,8 +186,10 @@ int main(int argc, char* argv[]) {
}
webrtc::ParsedRtcEventLog parsed_stream;
if (!parsed_stream.ParseFile(input_file)) {
std::cerr << "Error while parsing input file: " << input_file << std::endl;
auto status = parsed_stream.ParseFile(input_file);
if (!status.ok()) {
std::cerr << "Failed to parse event log " << input_file << ": "
<< status.message() << std::endl;
return -1;
}

File diff suppressed because it is too large Load diff

View file

@ -259,6 +259,48 @@ class ParsedRtcEventLog {
kDontParse,
kAttemptWebrtcDefaultConfig
};
class ParseStatus {
public:
static ParseStatus Success() { return ParseStatus(); }
static ParseStatus Error(std::string error, std::string file, int line) {
return ParseStatus(error, file, line);
}
bool ok() const { return error_.empty() && file_.empty() && line_ == 0; }
std::string message() const {
return error_ + " failed at " + file_ + " line " + std::to_string(line_);
}
RTC_DEPRECATED operator bool() const { return ok(); }
private:
ParseStatus() : error_(), file_(), line_(0) {}
ParseStatus(std::string error, std::string file, int line)
: error_(error), file_(file), line_(line) {}
std::string error_;
std::string file_;
int line_;
};
template <typename T>
class ParseStatusOr {
public:
ParseStatusOr(const ParseStatus& error) // NOLINT
: status_(error), value_() {}
ParseStatusOr(const T& value) // NOLINT
: status_(ParseStatus::Success()), value_(value) {}
bool ok() const { return status_.ok(); }
const T& value() const& {
RTC_DCHECK(status_.ok());
return value_;
}
std::string message() const { return status_.message(); }
const ParseStatus& status() const { return status_; }
private:
ParseStatus status_;
T value_;
};
struct LoggedRtpStreamIncoming {
LoggedRtpStreamIncoming();
@ -292,7 +334,8 @@ class ParsedRtcEventLog {
explicit ParsedRtcEventLog(
UnconfiguredHeaderExtensions parse_unconfigured_header_extensions =
UnconfiguredHeaderExtensions::kDontParse);
UnconfiguredHeaderExtensions::kDontParse,
bool allow_incomplete_log = false);
~ParsedRtcEventLog();
@ -300,14 +343,14 @@ class ParsedRtcEventLog {
// empty state.
void Clear();
// Reads an RtcEventLog file and returns true if parsing was successful.
bool ParseFile(const std::string& file_name);
// Reads an RtcEventLog file and returns success if parsing was successful.
ParseStatus ParseFile(const std::string& file_name);
// Reads an RtcEventLog from a string and returns true if successful.
bool ParseString(const std::string& s);
// Reads an RtcEventLog from a string and returns success if successful.
ParseStatus ParseString(const std::string& s);
// Reads an RtcEventLog from an istream and returns true if successful.
bool ParseStream(
// Reads an RtcEventLog from an istream and returns success if successful.
ParseStatus ParseStream(
std::istream& stream); // no-presubmit-check TODO(webrtc:8982)
MediaType GetMediaType(uint32_t ssrc, PacketDirection direction) const;
@ -567,104 +610,126 @@ class ParsedRtcEventLog {
std::vector<InferredRouteChangeEvent> GetRouteChanges() const;
private:
bool ParseStreamInternal(
ABSL_MUST_USE_RESULT ParseStatus ParseStreamInternal(
std::istream& stream); // no-presubmit-check TODO(webrtc:8982)
void StoreParsedLegacyEvent(const rtclog::Event& event);
ABSL_MUST_USE_RESULT ParseStatus
StoreParsedLegacyEvent(const rtclog::Event& event);
template <typename T>
void StoreFirstAndLastTimestamp(const std::vector<T>& v);
// Reads the arrival timestamp (in microseconds) from a rtclog::Event.
int64_t GetTimestamp(const rtclog::Event& event) const;
// Reads the header, direction, header length and packet length from the RTP
// event at |index|, and stores the values in the corresponding output
// parameters. Each output parameter can be set to nullptr if that value
// isn't needed.
// NB: The header must have space for at least IP_PACKET_SIZE bytes.
ParseStatus GetRtpHeader(const rtclog::Event& event,
PacketDirection* incoming,
uint8_t* header,
size_t* header_length,
size_t* total_length,
int* probe_cluster_id) const;
// Returns: a pointer to a header extensions map acquired from parsing
// corresponding Audio/Video Sender/Receiver config events.
// Warning: if the same SSRC is reused by both video and audio streams during
// call, extensions maps may be incorrect (the last one would be returned).
const webrtc::RtpHeaderExtensionMap* GetRtpHeader(
const rtclog::Event& event,
PacketDirection* incoming,
uint8_t* header,
size_t* header_length,
size_t* total_length,
int* probe_cluster_id) const;
const RtpHeaderExtensionMap* GetRtpHeaderExtensionMap(
PacketDirection direction,
uint32_t ssrc);
// Reads packet, direction and packet length from the RTCP event at |index|,
// and stores the values in the corresponding output parameters.
// Each output parameter can be set to nullptr if that value isn't needed.
// NB: The packet must have space for at least IP_PACKET_SIZE bytes.
void GetRtcpPacket(const rtclog::Event& event,
PacketDirection* incoming,
uint8_t* packet,
size_t* length) const;
ParseStatus GetRtcpPacket(const rtclog::Event& event,
PacketDirection* incoming,
uint8_t* packet,
size_t* length) const;
rtclog::StreamConfig GetVideoReceiveConfig(const rtclog::Event& event) const;
rtclog::StreamConfig GetVideoSendConfig(const rtclog::Event& event) const;
rtclog::StreamConfig GetAudioReceiveConfig(const rtclog::Event& event) const;
rtclog::StreamConfig GetAudioSendConfig(const rtclog::Event& event) const;
LoggedAudioPlayoutEvent GetAudioPlayout(const rtclog::Event& event) const;
LoggedBweLossBasedUpdate GetLossBasedBweUpdate(
ParseStatusOr<rtclog::StreamConfig> GetVideoReceiveConfig(
const rtclog::Event& event) const;
LoggedBweDelayBasedUpdate GetDelayBasedBweUpdate(
ParseStatusOr<rtclog::StreamConfig> GetVideoSendConfig(
const rtclog::Event& event) const;
ParseStatusOr<rtclog::StreamConfig> GetAudioReceiveConfig(
const rtclog::Event& event) const;
ParseStatusOr<rtclog::StreamConfig> GetAudioSendConfig(
const rtclog::Event& event) const;
LoggedAudioNetworkAdaptationEvent GetAudioNetworkAdaptation(
ParsedRtcEventLog::ParseStatusOr<LoggedAudioPlayoutEvent> GetAudioPlayout(
const rtclog::Event& event) const;
LoggedBweProbeClusterCreatedEvent GetBweProbeClusterCreated(
const rtclog::Event& event) const;
LoggedBweProbeFailureEvent GetBweProbeFailure(
const rtclog::Event& event) const;
LoggedBweProbeSuccessEvent GetBweProbeSuccess(
ParsedRtcEventLog::ParseStatusOr<LoggedBweLossBasedUpdate>
GetLossBasedBweUpdate(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedBweDelayBasedUpdate>
GetDelayBasedBweUpdate(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedAudioNetworkAdaptationEvent>
GetAudioNetworkAdaptation(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeClusterCreatedEvent>
GetBweProbeClusterCreated(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeFailureEvent>
GetBweProbeFailure(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeSuccessEvent>
GetBweProbeSuccess(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedAlrStateEvent> GetAlrState(
const rtclog::Event& event) const;
LoggedAlrStateEvent GetAlrState(const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedIceCandidatePairConfig>
GetIceCandidatePairConfig(const rtclog::Event& event) const;
LoggedIceCandidatePairConfig GetIceCandidatePairConfig(
const rtclog::Event& event) const;
LoggedIceCandidatePairEvent GetIceCandidatePairEvent(
const rtclog::Event& event) const;
ParsedRtcEventLog::ParseStatusOr<LoggedIceCandidatePairEvent>
GetIceCandidatePairEvent(const rtclog::Event& event) const;
// Parsing functions for new format.
void StoreAlrStateEvent(const rtclog2::AlrState& proto);
void StoreAudioNetworkAdaptationEvent(
ParseStatus StoreAlrStateEvent(const rtclog2::AlrState& proto);
ParseStatus StoreAudioNetworkAdaptationEvent(
const rtclog2::AudioNetworkAdaptations& proto);
void StoreAudioPlayoutEvent(const rtclog2::AudioPlayoutEvents& proto);
void StoreAudioRecvConfig(const rtclog2::AudioRecvStreamConfig& proto);
void StoreAudioSendConfig(const rtclog2::AudioSendStreamConfig& proto);
void StoreBweDelayBasedUpdate(const rtclog2::DelayBasedBweUpdates& proto);
void StoreBweLossBasedUpdate(const rtclog2::LossBasedBweUpdates& proto);
void StoreBweProbeClusterCreated(const rtclog2::BweProbeCluster& proto);
void StoreBweProbeFailureEvent(const rtclog2::BweProbeResultFailure& proto);
void StoreBweProbeSuccessEvent(const rtclog2::BweProbeResultSuccess& proto);
void StoreDtlsTransportState(const rtclog2::DtlsTransportStateEvent& proto);
void StoreDtlsWritableState(const rtclog2::DtlsWritableState& proto);
void StoreGenericAckReceivedEvent(const rtclog2::GenericAckReceived& proto);
void StoreGenericPacketReceivedEvent(
ParseStatus StoreAudioPlayoutEvent(const rtclog2::AudioPlayoutEvents& proto);
ParseStatus StoreAudioRecvConfig(const rtclog2::AudioRecvStreamConfig& proto);
ParseStatus StoreAudioSendConfig(const rtclog2::AudioSendStreamConfig& proto);
ParseStatus StoreBweDelayBasedUpdate(
const rtclog2::DelayBasedBweUpdates& proto);
ParseStatus StoreBweLossBasedUpdate(
const rtclog2::LossBasedBweUpdates& proto);
ParseStatus StoreBweProbeClusterCreated(
const rtclog2::BweProbeCluster& proto);
ParseStatus StoreBweProbeFailureEvent(
const rtclog2::BweProbeResultFailure& proto);
ParseStatus StoreBweProbeSuccessEvent(
const rtclog2::BweProbeResultSuccess& proto);
ParseStatus StoreDtlsTransportState(
const rtclog2::DtlsTransportStateEvent& proto);
ParseStatus StoreDtlsWritableState(const rtclog2::DtlsWritableState& proto);
ParseStatus StoreGenericAckReceivedEvent(
const rtclog2::GenericAckReceived& proto);
ParseStatus StoreGenericPacketReceivedEvent(
const rtclog2::GenericPacketReceived& proto);
void StoreGenericPacketSentEvent(const rtclog2::GenericPacketSent& proto);
void StoreIceCandidateEvent(const rtclog2::IceCandidatePairEvent& proto);
void StoreIceCandidatePairConfig(
ParseStatus StoreGenericPacketSentEvent(
const rtclog2::GenericPacketSent& proto);
ParseStatus StoreIceCandidateEvent(
const rtclog2::IceCandidatePairEvent& proto);
ParseStatus StoreIceCandidatePairConfig(
const rtclog2::IceCandidatePairConfig& proto);
void StoreIncomingRtcpPackets(const rtclog2::IncomingRtcpPackets& proto);
void StoreIncomingRtpPackets(const rtclog2::IncomingRtpPackets& proto);
void StoreOutgoingRtcpPackets(const rtclog2::OutgoingRtcpPackets& proto);
void StoreOutgoingRtpPackets(const rtclog2::OutgoingRtpPackets& proto);
void StoreParsedNewFormatEvent(const rtclog2::EventStream& event);
void StoreRouteChangeEvent(const rtclog2::RouteChange& proto);
void StoreRemoteEstimateEvent(const rtclog2::RemoteEstimates& proto);
void StoreStartEvent(const rtclog2::BeginLogEvent& proto);
void StoreStopEvent(const rtclog2::EndLogEvent& proto);
void StoreVideoRecvConfig(const rtclog2::VideoRecvStreamConfig& proto);
void StoreVideoSendConfig(const rtclog2::VideoSendStreamConfig& proto);
ParseStatus StoreIncomingRtcpPackets(
const rtclog2::IncomingRtcpPackets& proto);
ParseStatus StoreIncomingRtpPackets(const rtclog2::IncomingRtpPackets& proto);
ParseStatus StoreOutgoingRtcpPackets(
const rtclog2::OutgoingRtcpPackets& proto);
ParseStatus StoreOutgoingRtpPackets(const rtclog2::OutgoingRtpPackets& proto);
ParseStatus StoreParsedNewFormatEvent(const rtclog2::EventStream& event);
ParseStatus StoreRouteChangeEvent(const rtclog2::RouteChange& proto);
ParseStatus StoreRemoteEstimateEvent(const rtclog2::RemoteEstimates& proto);
ParseStatus StoreStartEvent(const rtclog2::BeginLogEvent& proto);
ParseStatus StoreStopEvent(const rtclog2::EndLogEvent& proto);
ParseStatus StoreVideoRecvConfig(const rtclog2::VideoRecvStreamConfig& proto);
ParseStatus StoreVideoSendConfig(const rtclog2::VideoSendStreamConfig& proto);
// End of new parsing functions.
struct Stream {
@ -683,6 +748,7 @@ class ParsedRtcEventLog {
};
const UnconfiguredHeaderExtensions parse_unconfigured_header_extensions_;
const bool allow_incomplete_logs_;
// Make a default extension map for streams without configuration information.
// TODO(ivoc): Once configuration of audio streams is stored in the event log,

View file

@ -258,7 +258,7 @@ void RtcEventLogSession::WriteVideoRecvConfigs(size_t video_recv_streams,
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
uint32_t ssrc = prng_.Rand<uint32_t>();
incoming_extensions_.emplace_back(prng_.Rand<uint32_t>(), all_extensions);
incoming_extensions_.emplace_back(ssrc, all_extensions);
auto event = gen_.NewVideoReceiveStreamConfig(ssrc, all_extensions);
event_log->Log(event->Copy());
video_recv_config_list_.push_back(std::move(event));
@ -287,7 +287,7 @@ void RtcEventLogSession::WriteVideoSendConfigs(size_t video_send_streams,
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
uint32_t ssrc = prng_.Rand<uint32_t>();
outgoing_extensions_.emplace_back(prng_.Rand<uint32_t>(), all_extensions);
outgoing_extensions_.emplace_back(ssrc, all_extensions);
auto event = gen_.NewVideoSendStreamConfig(ssrc, all_extensions);
event_log->Log(event->Copy());
video_send_config_list_.push_back(std::move(event));
@ -545,7 +545,7 @@ void RtcEventLogSession::WriteLog(EventCounts count,
void RtcEventLogSession::ReadAndVerifyLog() {
// Read the generated file from disk.
ParsedRtcEventLog parsed_log;
ASSERT_TRUE(parsed_log.ParseFile(temp_filename_));
ASSERT_TRUE(parsed_log.ParseFile(temp_filename_).ok());
// Start and stop events.
auto& parsed_start_log_events = parsed_log.start_log_events();
@ -875,7 +875,7 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
// Read the generated file from disk.
ParsedRtcEventLog parsed_log;
ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
ASSERT_TRUE(parsed_log.ParseFile(temp_filename).ok());
const auto& start_log_events = parsed_log.start_log_events();
ASSERT_EQ(start_log_events.size(), 1u);

View file

@ -319,6 +319,7 @@ rtcp::TransportFeedback EventGenerator::NewTransportFeedback() {
uint16_t base_seq_no = prng_.Rand<uint16_t>();
int64_t base_time_us = prng_.Rand<uint32_t>();
transport_feedback.SetBase(base_seq_no, base_time_us);
transport_feedback.AddReceivedPacket(base_seq_no, base_time_us);
int64_t time_us = base_time_us;
for (uint16_t i = 1u; i < 10u; i++) {
time_us += prng_.Rand(0, 100000);

View file

@ -42,9 +42,15 @@ std::unique_ptr<RtcEventLogSource> RtcEventLogSource::CreateFromFile(
absl::optional<uint32_t> ssrc_filter) {
auto source = std::unique_ptr<RtcEventLogSource>(new RtcEventLogSource());
ParsedRtcEventLog parsed_log;
if (!parsed_log.ParseFile(file_name) ||
!source->Initialize(parsed_log, ssrc_filter)) {
std::cerr << "Error while parsing event log, skipping." << std::endl;
auto status = parsed_log.ParseFile(file_name);
if (!status.ok()) {
std::cerr << "Failed to parse event log: " << status.message() << std::endl;
std::cerr << "Skipping log." << std::endl;
return nullptr;
}
if (!source->Initialize(parsed_log, ssrc_filter)) {
std::cerr << "Failed to initialize source from event log, skipping."
<< std::endl;
return nullptr;
}
return source;
@ -55,9 +61,15 @@ std::unique_ptr<RtcEventLogSource> RtcEventLogSource::CreateFromString(
absl::optional<uint32_t> ssrc_filter) {
auto source = std::unique_ptr<RtcEventLogSource>(new RtcEventLogSource());
ParsedRtcEventLog parsed_log;
if (!parsed_log.ParseString(file_contents) ||
!source->Initialize(parsed_log, ssrc_filter)) {
std::cerr << "Error while parsing event log, skipping." << std::endl;
auto status = parsed_log.ParseString(file_contents);
if (!status.ok()) {
std::cerr << "Failed to parse event log: " << status.message() << std::endl;
std::cerr << "Skipping log." << std::endl;
return nullptr;
}
if (!source->Initialize(parsed_log, ssrc_filter)) {
std::cerr << "Failed to initialize source from event log, skipping."
<< std::endl;
return nullptr;
}
return source;

View file

@ -29,6 +29,7 @@
#include "logging/rtc_event_log/rtc_event_log_parser.h"
#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_tools/rtc_event_log_visualizer/analyzer.h"
#include "rtc_tools/rtc_event_log_visualizer/plot_base.h"
#include "rtc_tools/rtc_event_log_visualizer/plot_protobuf.h"
@ -198,6 +199,12 @@ int main(int argc, char* argv[]) {
absl::SetFlagsUsageConfig(config);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
// Print RTC_LOG warnings and errors even in release builds.
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_WARNING) {
rtc::LogMessage::LogToDebug(rtc::LS_WARNING);
}
rtc::LogMessage::SetLogToStderr(true);
// Flag replacements
std::map<std::string, std::vector<std::string>> flag_aliases = {
{"default",
@ -241,13 +248,16 @@ int main(int argc, char* argv[]) {
header_extensions = webrtc::ParsedRtcEventLog::
UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig;
}
webrtc::ParsedRtcEventLog parsed_log(header_extensions);
webrtc::ParsedRtcEventLog parsed_log(header_extensions,
/*allow_incomplete_logs*/ true);
if (args.size() == 2) {
std::string filename = args[1];
if (!parsed_log.ParseFile(filename)) {
std::cerr << "Could not parse the entire log file." << std::endl;
std::cerr << "Only the parsable events will be analyzed." << std::endl;
auto status = parsed_log.ParseFile(filename);
if (!status.ok()) {
std::cerr << "Failed to parse " << filename << ": " << status.message()
<< std::endl;
return -1;
}
}