#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h"
#include <algorithm>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "api/array_view.h"
#include "api/numerics/samples_stats_counter.h"
#include "api/test/metrics/metric.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "api/video/video_frame.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/clock.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_frame_in_flight.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_internal_shared_objects.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_stream_state.h"
#include "test/pc/e2e/metric_metadata_keys.h"
namespace webrtc {
namespace {
ImprovementDirection;
Unit;
MetricMetadataKey;
constexpr int kBitsInByte = …;
constexpr absl::string_view kSkipRenderedFrameReasonProcessed = …;
constexpr absl::string_view kSkipRenderedFrameReasonRendered = …;
constexpr absl::string_view kSkipRenderedFrameReasonDropped = …;
void LogFrameCounters(const std::string& name, const FrameCounters& counters) { … }
void LogStreamInternalStats(const std::string& name,
const StreamStats& stats,
Timestamp start_time) { … }
template <typename T>
absl::optional<T> MaybeGetValue(const std::map<size_t, T>& map, size_t key) { … }
SamplesStatsCounter::StatsSample StatsSample(double value,
Timestamp sampling_time) { … }
}
DefaultVideoQualityAnalyzer::DefaultVideoQualityAnalyzer(
webrtc::Clock* clock,
test::MetricsLogger* metrics_logger,
DefaultVideoQualityAnalyzerOptions options)
: … { … }
DefaultVideoQualityAnalyzer::~DefaultVideoQualityAnalyzer() { … }
void DefaultVideoQualityAnalyzer::Start(
std::string test_case_name,
rtc::ArrayView<const std::string> peer_names,
int max_threads_count) { … }
uint16_t DefaultVideoQualityAnalyzer::OnFrameCaptured(
absl::string_view peer_name,
const std::string& stream_label,
const webrtc::VideoFrame& frame) { … }
void DefaultVideoQualityAnalyzer::OnFramePreEncode(
absl::string_view peer_name,
const webrtc::VideoFrame& frame) { … }
void DefaultVideoQualityAnalyzer::OnFrameEncoded(
absl::string_view peer_name,
uint16_t frame_id,
const webrtc::EncodedImage& encoded_image,
const EncoderStats& stats,
bool discarded) { … }
void DefaultVideoQualityAnalyzer::OnFrameDropped(
absl::string_view peer_name,
webrtc::EncodedImageCallback::DropReason reason) { … }
void DefaultVideoQualityAnalyzer::OnFramePreDecode(
absl::string_view peer_name,
uint16_t frame_id,
const webrtc::EncodedImage& input_image) { … }
void DefaultVideoQualityAnalyzer::OnFrameDecoded(
absl::string_view peer_name,
const webrtc::VideoFrame& frame,
const DecoderStats& stats) { … }
void DefaultVideoQualityAnalyzer::OnFrameRendered(
absl::string_view peer_name,
const webrtc::VideoFrame& frame) { … }
void DefaultVideoQualityAnalyzer::OnEncoderError(
absl::string_view peer_name,
const webrtc::VideoFrame& frame,
int32_t error_code) { … }
void DefaultVideoQualityAnalyzer::OnDecoderError(absl::string_view peer_name,
uint16_t frame_id,
int32_t error_code,
const DecoderStats& stats) { … }
void DefaultVideoQualityAnalyzer::RegisterParticipantInCall(
absl::string_view peer_name) { … }
void DefaultVideoQualityAnalyzer::UnregisterParticipantInCall(
absl::string_view peer_name) { … }
void DefaultVideoQualityAnalyzer::OnPauseAllStreamsFrom(
absl::string_view sender_peer_name,
absl::string_view receiver_peer_name) { … }
void DefaultVideoQualityAnalyzer::OnResumeAllStreamsFrom(
absl::string_view sender_peer_name,
absl::string_view receiver_peer_name) { … }
void DefaultVideoQualityAnalyzer::Stop() { … }
std::string DefaultVideoQualityAnalyzer::GetStreamLabel(uint16_t frame_id) { … }
std::string DefaultVideoQualityAnalyzer::GetSenderPeerName(
uint16_t frame_id) const { … }
std::set<StatsKey> DefaultVideoQualityAnalyzer::GetKnownVideoStreams() const { … }
VideoStreamsInfo DefaultVideoQualityAnalyzer::GetKnownStreams() const { … }
FrameCounters DefaultVideoQualityAnalyzer::GetGlobalCounters() const { … }
std::map<std::string, FrameCounters>
DefaultVideoQualityAnalyzer::GetUnknownSenderFrameCounters() const { … }
std::map<StatsKey, FrameCounters>
DefaultVideoQualityAnalyzer::GetPerStreamCounters() const { … }
std::map<StatsKey, StreamStats> DefaultVideoQualityAnalyzer::GetStats() const { … }
AnalyzerStats DefaultVideoQualityAnalyzer::GetAnalyzerStats() const { … }
uint16_t DefaultVideoQualityAnalyzer::GetNextFrameId() { … }
void DefaultVideoQualityAnalyzer::
AddExistingFramesInFlightForStreamToComparator(size_t stream_index,
StreamState& stream_state,
size_t peer_index) { … }
int DefaultVideoQualityAnalyzer::ProcessNotSeenFramesBeforeRendered(
size_t peer_index,
uint16_t rendered_frame_id,
const InternalStatsKey& stats_key,
StreamState& state) { … }
void DefaultVideoQualityAnalyzer::ReportResults() { … }
void DefaultVideoQualityAnalyzer::ReportResults(
const InternalStatsKey& key,
const StreamStats& stats,
const FrameCounters& frame_counters) { … }
std::string DefaultVideoQualityAnalyzer::GetTestCaseName(
const std::string& stream_label) const { … }
Timestamp DefaultVideoQualityAnalyzer::Now() { … }
StatsKey DefaultVideoQualityAnalyzer::ToStatsKey(
const InternalStatsKey& key) const { … }
std::string DefaultVideoQualityAnalyzer::ToMetricName(
const InternalStatsKey& key) const { … }
std::string DefaultVideoQualityAnalyzer::GetStreamLabelInternal(
uint16_t frame_id) const { … }
double DefaultVideoQualityAnalyzer::GetCpuUsagePercent() const { … }
std::map<std::string, std::vector<uint16_t>>
DefaultVideoQualityAnalyzer::GetStreamFrames() const { … }
}