#include "media/mojo/services/watch_time_recorder.h"
#include <cmath>
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/hash/hash.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "media/base/limits.h"
#include "media/base/video_codecs.h"
#include "media/base/video_decoder.h"
#include "media/base/watch_time_keys.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
namespace media {
constexpr base::TimeDelta kMinimumElapsedWatchTime = …;
static void RecordWatchTimeInternal(
std::string_view key,
base::TimeDelta value,
base::TimeDelta minimum = kMinimumElapsedWatchTime) { … }
static void RecordMeanTimeBetweenRebuffers(std::string_view key,
base::TimeDelta value) { … }
static void RecordDiscardedWatchTime(std::string_view key,
base::TimeDelta value) { … }
static void RecordRebuffersCount(std::string_view key, int underflow_count) { … }
WatchTimeRecorder::WatchTimeUkmRecord::WatchTimeUkmRecord(
mojom::SecondaryPlaybackPropertiesPtr properties)
: … { … }
WatchTimeRecorder::WatchTimeUkmRecord::WatchTimeUkmRecord(
WatchTimeUkmRecord&& record) = default;
WatchTimeRecorder::WatchTimeUkmRecord::~WatchTimeUkmRecord() = default;
WatchTimeRecorder::WatchTimeRecorder(mojom::PlaybackPropertiesPtr properties,
ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id)
: … { … }
WatchTimeRecorder::~WatchTimeRecorder() { … }
void WatchTimeRecorder::RecordWatchTime(WatchTimeKey key,
base::TimeDelta watch_time) { … }
void WatchTimeRecorder::FinalizeWatchTime(
const std::vector<WatchTimeKey>& keys_to_finalize) { … }
void WatchTimeRecorder::OnError(const PipelineStatus& status) { … }
void WatchTimeRecorder::UpdateSecondaryProperties(
mojom::SecondaryPlaybackPropertiesPtr secondary_properties) { … }
void WatchTimeRecorder::SetAutoplayInitiated(bool value) { … }
void WatchTimeRecorder::OnDurationChanged(base::TimeDelta duration) { … }
void WatchTimeRecorder::UpdateVideoDecodeStats(uint32_t video_frames_decoded,
uint32_t video_frames_dropped) { … }
void WatchTimeRecorder::UpdateUnderflowCount(int32_t total_count) { … }
void WatchTimeRecorder::UpdateUnderflowDuration(
int32_t total_completed_count,
base::TimeDelta total_duration) { … }
void WatchTimeRecorder::RecordUkmPlaybackData() { … }
bool WatchTimeRecorder::ShouldRecordUma() const { … }
WatchTimeRecorder::ExtendedMetricsKeyMap::ExtendedMetricsKeyMap(
const ExtendedMetricsKeyMap& copy)
: … { … }
WatchTimeRecorder::ExtendedMetricsKeyMap::ExtendedMetricsKeyMap(
WatchTimeKey watch_time_key,
std::string_view mtbr_key,
std::string_view smooth_rate_key,
std::string_view discard_key)
: … { … }
}