#include "cast/streaming/impl/statistics_analyzer.h"
#include <algorithm>
#include "platform/base/trivial_clock_traits.h"
#include "util/chrono_helpers.h"
namespace openscreen::cast {
namespace {
constexpr Clock::duration kAnalysisInterval = …;
constexpr size_t kMaxRecentPacketInfoMapSize = …;
constexpr size_t kMaxRecentFrameInfoMapSize = …;
constexpr int kDefaultMaxLatencyBucketMs = …;
constexpr int kDefaultBucketWidthMs = …;
double InMilliseconds(Clock::duration duration) { … }
bool IsReceiverEvent(StatisticsEventType event) { … }
}
StatisticsAnalyzer::StatisticsAnalyzer(
SenderStatsClient* stats_client,
ClockNowFunctionPtr now,
TaskRunner& task_runner,
std::unique_ptr<ClockOffsetEstimator> offset_estimator)
: … { … }
StatisticsAnalyzer::~StatisticsAnalyzer() = default;
void StatisticsAnalyzer::ScheduleAnalysis() { … }
void StatisticsAnalyzer::InitHistograms() { … }
void StatisticsAnalyzer::AnalyzeStatistics() { … }
void StatisticsAnalyzer::SendStatistics() { … }
void StatisticsAnalyzer::ProcessFrameEvents(
const std::vector<FrameEvent>& frame_events) { … }
void StatisticsAnalyzer::ProcessPacketEvents(
const std::vector<PacketEvent>& packet_events) { … }
void StatisticsAnalyzer::RecordFrameLatencies(const FrameEvent& frame_event) { … }
void StatisticsAnalyzer::RecordPacketLatencies(
const PacketEvent& packet_event) { … }
void StatisticsAnalyzer::RecordEventTimes(const StatisticsEvent& event) { … }
void StatisticsAnalyzer::ErasePacketInfo(const PacketEvent& packet_event) { … }
void StatisticsAnalyzer::AddToLatencyAggregrate(
StatisticType latency_stat,
Clock::duration latency_delta,
StatisticsEventMediaType media_type) { … }
void StatisticsAnalyzer::AddToHistogram(HistogramType histogram,
StatisticsEventMediaType media_type,
int64_t sample) { … }
SenderStats::StatisticsList StatisticsAnalyzer::ConstructStatisticsList(
Clock::time_point end_time,
StatisticsEventMediaType media_type) { … }
void StatisticsAnalyzer::PopulatePacketCountStat(
StatisticsEventType event,
StatisticType stat,
StatisticsEventMediaType media_type,
SenderStats::StatisticsList& stats_list) { … }
void StatisticsAnalyzer::PopulateFrameCountStat(
StatisticsEventType event,
StatisticType stat,
StatisticsEventMediaType media_type,
SenderStats::StatisticsList& stats_list) { … }
void StatisticsAnalyzer::PopulateFpsStat(
StatisticsEventType event,
StatisticType stat,
StatisticsEventMediaType media_type,
Clock::time_point end_time,
SenderStats::StatisticsList& stats_list) { … }
void StatisticsAnalyzer::PopulateAvgLatencyStat(
StatisticType stat,
StatisticsEventMediaType media_type,
SenderStats::StatisticsList& stats_list
) { … }
void StatisticsAnalyzer::PopulateFrameBitrateStat(
StatisticsEventType event,
StatisticType stat,
StatisticsEventMediaType media_type,
Clock::time_point end_time,
SenderStats::StatisticsList& stats_list) { … }
void StatisticsAnalyzer::PopulatePacketBitrateStat(
StatisticsEventType event,
StatisticType stat,
StatisticsEventMediaType media_type,
Clock::time_point end_time,
SenderStats::StatisticsList& stats_list) { … }
void StatisticsAnalyzer::PopulateSessionStats(
StatisticsEventMediaType media_type,
Clock::time_point end_time,
SenderStats::StatisticsList& stats_list) { … }
std::optional<Clock::time_point> StatisticsAnalyzer::ToSenderTimestamp(
Clock::time_point receiver_timestamp,
StatisticsEventMediaType media_type) const { … }
void StatisticsAnalyzer::RecordEstimatedNetworkLatency(
Clock::duration latency) { … }
}