[DVQA] Make entities loggable

Make StreamCodecInfo and FrameDropPhase generally loggable

Bug: b/243855428
Change-Id: Id8424596f82d1489fe6f7deaf0670e6960375df0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273103
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37916}
This commit is contained in:
Artem Titov
2022-08-26 11:51:03 +02:00
committed by WebRTC LUCI CQ
parent 6d47f2e1fa
commit f02212b8b0
3 changed files with 54 additions and 15 deletions

View File

@ -52,21 +52,6 @@ void LogFrameCounters(const std::string& name, const FrameCounters& counters) {
RTC_LOG(LS_INFO) << "[" << name << "] Dropped : " << counters.dropped; RTC_LOG(LS_INFO) << "[" << name << "] Dropped : " << counters.dropped;
} }
absl::string_view ToString(FrameDropPhase phase) {
switch (phase) {
case FrameDropPhase::kBeforeEncoder:
return "kBeforeEncoder";
case FrameDropPhase::kByEncoder:
return "kByEncoder";
case FrameDropPhase::kTransport:
return "kTransport";
case FrameDropPhase::kAfterDecoder:
return "kAfterDecoder";
case FrameDropPhase::kLastValue:
RTC_CHECK(false) << "FrameDropPhase::kLastValue mustn't be used";
}
}
void LogStreamInternalStats(const std::string& name, void LogStreamInternalStats(const std::string& name,
const StreamStats& stats, const StreamStats& stats,
Timestamp start_time) { Timestamp start_time) {

View File

@ -11,6 +11,8 @@
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <ostream>
#include <string>
#include "api/units/timestamp.h" #include "api/units/timestamp.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -23,6 +25,46 @@ constexpr int kMicrosPerSecond = 1000000;
} // namespace } // namespace
std::string StreamCodecInfo::ToString() const {
rtc::StringBuilder out;
out << "{codec_name=" << codec_name << "; first_frame_id=" << first_frame_id
<< "; last_frame_id=" << last_frame_id
<< "; switched_on_at=" << webrtc::ToString(switched_on_at)
<< "; switched_from_at=" << webrtc::ToString(switched_from_at) << " }";
return out.str();
}
std::ostream& operator<<(std::ostream& os, const StreamCodecInfo& state) {
return os << state.ToString();
}
rtc::StringBuilder& operator<<(rtc::StringBuilder& sb,
const StreamCodecInfo& state) {
return sb << state.ToString();
}
std::string ToString(FrameDropPhase phase) {
switch (phase) {
case FrameDropPhase::kBeforeEncoder:
return "kBeforeEncoder";
case FrameDropPhase::kByEncoder:
return "kByEncoder";
case FrameDropPhase::kTransport:
return "kTransport";
case FrameDropPhase::kAfterDecoder:
return "kAfterDecoder";
case FrameDropPhase::kLastValue:
return "kLastValue";
}
}
std::ostream& operator<<(std::ostream& os, FrameDropPhase phase) {
return os << ToString(phase);
}
rtc::StringBuilder& operator<<(rtc::StringBuilder& sb, FrameDropPhase phase) {
return sb << ToString(phase);
}
void SamplesRateCounter::AddEvent(Timestamp event_time) { void SamplesRateCounter::AddEvent(Timestamp event_time) {
if (event_first_time_.IsMinusInfinity()) { if (event_first_time_.IsMinusInfinity()) {
event_first_time_ = event_time; event_first_time_ = event_time;

View File

@ -13,6 +13,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <ostream>
#include <set> #include <set>
#include <string> #include <string>
#include <utility> #include <utility>
@ -21,6 +22,7 @@
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/numerics/samples_stats_counter.h" #include "api/numerics/samples_stats_counter.h"
#include "api/units/timestamp.h" #include "api/units/timestamp.h"
#include "rtc_base/strings/string_builder.h"
namespace webrtc { namespace webrtc {
@ -77,8 +79,14 @@ struct StreamCodecInfo {
Timestamp switched_on_at = Timestamp::PlusInfinity(); Timestamp switched_on_at = Timestamp::PlusInfinity();
// Timestamp when this codec was used last time. // Timestamp when this codec was used last time.
Timestamp switched_from_at = Timestamp::PlusInfinity(); Timestamp switched_from_at = Timestamp::PlusInfinity();
std::string ToString() const;
}; };
std::ostream& operator<<(std::ostream& os, const StreamCodecInfo& state);
rtc::StringBuilder& operator<<(rtc::StringBuilder& sb,
const StreamCodecInfo& state);
// Represents phases where video frame can be dropped and such drop will be // Represents phases where video frame can be dropped and such drop will be
// detected by analyzer. // detected by analyzer.
enum class FrameDropPhase : int { enum class FrameDropPhase : int {
@ -90,6 +98,10 @@ enum class FrameDropPhase : int {
kLastValue kLastValue
}; };
std::string ToString(FrameDropPhase phase);
std::ostream& operator<<(std::ostream& os, FrameDropPhase phase);
rtc::StringBuilder& operator<<(rtc::StringBuilder& sb, FrameDropPhase phase);
struct StreamStats { struct StreamStats {
explicit StreamStats(Timestamp stream_started_time); explicit StreamStats(Timestamp stream_started_time);