blob: b300a0e16b49832c7a78e93269762283800d8388 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "base/component_export.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
namespace media {
// Reports UMA stats for audio delays. The class may be created, deleted and
// called on different threads, though all calls must be on the same thread. The
// user must ensure that no calls are made after destruction.
class COMPONENT_EXPORT(MEDIA_WEBRTC) AudioDelayStatsReporter {
// |variance_window_size| is the window size, that is the number of delay
// values, on which to calculate the variance.
AudioDelayStatsReporter(int variance_window_size);
virtual ~AudioDelayStatsReporter();
// Reports delay stats and stores delays. When the number of stored delays
// reaches the variance window size, variance stats are reported.
void ReportDelay(base::TimeDelta capture_delay, base::TimeDelta render_delay);
const int variance_window_size_;
// Min and max values in the delay histograms.
const base::TimeDelta delay_histogram_min_;
const base::TimeDelta delay_histogram_max_;
// Stores delay values.
std::vector<int> capture_delays_ms_;
std::vector<int> render_delays_ms_;
std::vector<int> total_delays_ms_;
// Ensures that all function calls are done on the same thread.
} // namespace media