#include "media/mojo/services/webrtc_video_perf_history.h"
#include <math.h>
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/base/media_switches.h"
#include "media/base/video_codecs.h"
#include "media/capabilities/bucket_utility.h"
#include "media/mojo/mojom/media_types.mojom.h"
namespace media {
namespace {
constexpr float kSmoothnessThresholdDecodeDefault = …;
constexpr float kSmoothnessThresholdEncodeDefault = …;
constexpr float kSmoothDecisionRatioThresholdDefault = …;
constexpr char kSmoothnessThresholdDecodeParamName[] = …;
constexpr char kSmoothnessThresholdEncodeParamName[] = …;
constexpr char kSmoothDecisionRatioThresholdParamName[] = …;
enum class SmoothVolatility { … };
enum class SmoothPrediction { … };
enum class LimitedCodecProfile { … };
LimitedCodecProfile LimitedCodecProfileFromCodecProfile(
VideoCodecProfile codec_profile) { … }
constexpr SmoothVolatility SmoothVolatilityFromBool(bool smooth_before,
bool smooth_after) { … }
int UmaSmoothPredictionData(const WebrtcVideoStatsDB::VideoDescKey& key,
SmoothPrediction prediction) { … }
void ReportUmaSmoothPredictionData(const WebrtcVideoStatsDB::VideoDescKey& key,
SmoothPrediction prediction) { … }
bool PredictSmoothFromStats(const WebrtcVideoStatsDB::VideoStats& stats,
int frames_per_second,
float threshold) { … }
constexpr int MakeBucketedFramerate(int framerate) { … }
bool AreFeaturesInvalid(
const media::mojom::WebrtcPredictionFeatures& features) { … }
bool IsFramesPerSecondInvalid(int frames_per_second) { … }
bool AreVideoStatsInvalid(const media::mojom::WebrtcVideoStats& video_stats) { … }
}
WebrtcVideoPerfHistory::WebrtcVideoPerfHistory(
std::unique_ptr<WebrtcVideoStatsDB> db)
: … { … }
WebrtcVideoPerfHistory::~WebrtcVideoPerfHistory() { … }
void WebrtcVideoPerfHistory::BindReceiver(
mojo::PendingReceiver<media::mojom::WebrtcVideoPerfHistory> receiver) { … }
void WebrtcVideoPerfHistory::InitDatabase() { … }
void WebrtcVideoPerfHistory::OnDatabaseInit(bool success) { … }
void WebrtcVideoPerfHistory::GetPerfInfo(
media::mojom::WebrtcPredictionFeaturesPtr features,
int frames_per_second,
GetPerfInfoCallback got_info_cb) { … }
void WebrtcVideoPerfHistory::OnGotStatsCollectionForRequest(
const WebrtcVideoStatsDB::VideoDescKey& video_key,
int frames_per_second,
GetPerfInfoCallback got_info_cb,
bool database_success,
std::optional<WebrtcVideoStatsDB::VideoStatsCollection> stats_collection) { … }
WebrtcVideoPerfHistory::SaveCallback WebrtcVideoPerfHistory::GetSaveCallback() { … }
void WebrtcVideoPerfHistory::SavePerfRecord(
media::mojom::WebrtcPredictionFeatures features,
media::mojom::WebrtcVideoStats video_stats,
base::OnceClosure save_done_cb) { … }
void WebrtcVideoPerfHistory::OnGotStatsForSave(
const WebrtcVideoStatsDB::VideoDescKey& video_key,
const WebrtcVideoStatsDB::VideoStats& new_stats,
base::OnceClosure save_done_cb,
bool success,
std::optional<WebrtcVideoStatsDB::VideoStatsEntry> past_stats) { … }
void WebrtcVideoPerfHistory::OnSaveDone(base::OnceClosure save_done_cb,
bool success) { … }
void WebrtcVideoPerfHistory::ClearHistory(base::OnceClosure clear_done_cb) { … }
void WebrtcVideoPerfHistory::OnClearedHistory(base::OnceClosure clear_done_cb) { … }
void WebrtcVideoPerfHistory::GetWebrtcVideoStatsDB(GetCB get_db_cb) { … }
bool WebrtcVideoPerfHistory::PredictSmooth(
bool is_decode,
const WebrtcVideoStatsDB::VideoStatsEntry& stats_entry,
int frames_per_second) { … }
bool WebrtcVideoPerfHistory::PredictSmoothAfterUpdate(
bool is_decode,
const WebrtcVideoStatsDB::VideoStats& new_stats,
const WebrtcVideoStatsDB::VideoStatsEntry& past_stats_entry,
int frames_per_second) { … }
void WebrtcVideoPerfHistory::ReportUmaMetricsOnSave(
bool is_decode_stats,
const WebrtcVideoStatsDB::VideoStats& new_stats,
const WebrtcVideoStatsDB::VideoStatsEntry& past_stats_entry) { … }
float WebrtcVideoPerfHistory::GetSmoothnessThreshold(bool is_decode) { … }
float WebrtcVideoPerfHistory::GetSmoothDecisionRatioThreshold() { … }
}