blob: f15d2aec7722d22a1b8f32810fc7a7d378f78cff [file] [log] [blame]
Rasmus Brandtcde53542023-06-08 08:41:251/*
2 * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef TEST_JITTER_LOGGING_DELAY_VARIATION_CALCULATOR_H_
12#define TEST_JITTER_LOGGING_DELAY_VARIATION_CALCULATOR_H_
13
14#include <string>
15
16#include "absl/strings/string_view.h"
17#include "api/test/metrics/global_metrics_logger_and_exporter.h"
18#include "api/units/data_size.h"
19#include "test/jitter/delay_variation_calculator.h"
20
21namespace webrtc {
22namespace test {
23
24// This class logs the results from a `DelayVariationCalculator`
25// to a metrics logger. For ease of integration, logging happens at
26// object destruction.
27class LoggingDelayVariationCalculator {
28 public:
29 LoggingDelayVariationCalculator(
30 absl::string_view log_type,
31 DefaultMetricsLogger* logger = GetGlobalMetricsLogger())
32 : log_type_(log_type), logger_(logger) {}
33 ~LoggingDelayVariationCalculator() { LogMetrics(); }
34
35 void Insert(uint32_t rtp_timestamp,
36 Timestamp arrival_time,
37 DataSize size,
38 absl::optional<int> spatial_layer = absl::nullopt,
39 absl::optional<int> temporal_layer = absl::nullopt,
40 absl::optional<VideoFrameType> frame_type = absl::nullopt);
41
42 private:
43 void LogMetrics() const;
44
45 const std::string log_type_;
46 DefaultMetricsLogger* const logger_;
47 DelayVariationCalculator calc_;
48};
49
50} // namespace test
51} // namespace webrtc
52
53#endif // TEST_JITTER_LOGGING_DELAY_VARIATION_CALCULATOR_H_