#include "video/adaptation/overuse_frame_detector.h"
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "api/environment/environment.h"
#include "api/field_trials_view.h"
#include "api/video/video_frame.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/exp_filter.h"
#include "rtc_base/time_utils.h"
#include "rtc_base/trace_event.h"
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
#include <mach/mach.h>
#endif
namespace webrtc {
namespace {
const int64_t kCheckForOveruseIntervalMs = …;
const int64_t kTimeToFirstCheckForOveruseMs = …;
const int kQuickRampUpDelayMs = …;
const int kStandardRampUpDelayMs = …;
const int kMaxRampUpDelayMs = …;
const double kRampUpBackoffFactor = …;
const int kMaxOverusesBeforeApplyRampupDelay = …;
const float kMaxExp = …;
const int kDefaultFrameRate = …;
const float kDefaultSampleDiffMs = …;
const float kMaxSampleDiffMarginFactor = …;
const int kMinFramerate = …;
const int kMaxFramerate = …;
class SendProcessingUsage1 : public OveruseFrameDetector::ProcessingUsage { … };
class SendProcessingUsage2 : public OveruseFrameDetector::ProcessingUsage { … };
class OverdoseInjector : public OveruseFrameDetector::ProcessingUsage { … };
}
std::unique_ptr<OveruseFrameDetector::ProcessingUsage>
OveruseFrameDetector::CreateProcessingUsage(const FieldTrialsView& field_trials,
const CpuOveruseOptions& options) { … }
OveruseFrameDetector::OveruseFrameDetector(
const Environment& env,
CpuOveruseMetricsObserver* metrics_observer)
: … { … }
OveruseFrameDetector::~OveruseFrameDetector() { … }
void OveruseFrameDetector::StartCheckForOveruse(
TaskQueueBase* task_queue_base,
const CpuOveruseOptions& options,
OveruseFrameDetectorObserverInterface* overuse_observer) { … }
void OveruseFrameDetector::StopCheckForOveruse() { … }
void OveruseFrameDetector::EncodedFrameTimeMeasured(int encode_duration_ms) { … }
bool OveruseFrameDetector::FrameSizeChanged(int num_pixels) const { … }
bool OveruseFrameDetector::FrameTimeoutDetected(int64_t now_us) const { … }
void OveruseFrameDetector::ResetAll(int num_pixels) { … }
void OveruseFrameDetector::OnTargetFramerateUpdated(int framerate_fps) { … }
void OveruseFrameDetector::FrameCaptured(const VideoFrame& frame,
int64_t time_when_first_seen_us) { … }
void OveruseFrameDetector::FrameSent(uint32_t timestamp,
int64_t time_sent_in_us,
int64_t capture_time_us,
absl::optional<int> encode_duration_us) { … }
void OveruseFrameDetector::CheckForOveruse(
OveruseFrameDetectorObserverInterface* observer) { … }
void OveruseFrameDetector::SetOptions(const CpuOveruseOptions& options) { … }
bool OveruseFrameDetector::IsOverusing(int usage_percent) { … }
bool OveruseFrameDetector::IsUnderusing(int usage_percent, int64_t time_now) { … }
}