Rasmus Brandt | cde5354 | 2023-06-08 08:41:25 | [diff] [blame] | 1 | /* |
| 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 | #include "test/jitter/logging_delay_variation_calculator.h" |
| 12 | |
| 13 | #include "api/test/metrics/global_metrics_logger_and_exporter.h" |
| 14 | #include "rtc_base/logging.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace test { |
| 18 | |
| 19 | void LoggingDelayVariationCalculator::Insert( |
| 20 | uint32_t rtp_timestamp, |
| 21 | Timestamp arrival_time, |
| 22 | DataSize size, |
Florent Castelli | 8037fc6 | 2024-08-29 13:00:40 | [diff] [blame] | 23 | std::optional<int> spatial_layer, |
| 24 | std::optional<int> temporal_layer, |
| 25 | std::optional<VideoFrameType> frame_type) { |
Rasmus Brandt | cde5354 | 2023-06-08 08:41:25 | [diff] [blame] | 26 | calc_.Insert(rtp_timestamp, arrival_time, size, spatial_layer, temporal_layer, |
| 27 | frame_type); |
| 28 | } |
| 29 | |
| 30 | void LoggingDelayVariationCalculator::LogMetrics() const { |
| 31 | const DelayVariationCalculator::TimeSeries& time_series = calc_.time_series(); |
| 32 | |
| 33 | if (!time_series.rtp_timestamps.IsEmpty()) { |
| 34 | logger_->LogMetric("rtp_timestamp", log_type_, time_series.rtp_timestamps, |
| 35 | Unit::kUnitless, ImprovementDirection::kNeitherIsBetter); |
| 36 | } |
| 37 | if (!time_series.arrival_times_ms.IsEmpty()) { |
| 38 | logger_->LogMetric("arrival_time", log_type_, time_series.arrival_times_ms, |
| 39 | Unit::kMilliseconds, |
| 40 | ImprovementDirection::kNeitherIsBetter); |
| 41 | } |
| 42 | if (!time_series.sizes_bytes.IsEmpty()) { |
| 43 | logger_->LogMetric("size_bytes", log_type_, time_series.sizes_bytes, |
| 44 | Unit::kBytes, ImprovementDirection::kNeitherIsBetter); |
| 45 | } |
| 46 | if (!time_series.inter_departure_times_ms.IsEmpty()) { |
| 47 | logger_->LogMetric( |
| 48 | "inter_departure_time", log_type_, time_series.inter_departure_times_ms, |
| 49 | Unit::kMilliseconds, ImprovementDirection::kNeitherIsBetter); |
| 50 | } |
| 51 | if (!time_series.inter_arrival_times_ms.IsEmpty()) { |
| 52 | logger_->LogMetric("inter_arrival_time", log_type_, |
| 53 | time_series.inter_arrival_times_ms, Unit::kMilliseconds, |
| 54 | ImprovementDirection::kNeitherIsBetter); |
| 55 | } |
| 56 | if (!time_series.inter_delay_variations_ms.IsEmpty()) { |
| 57 | logger_->LogMetric("inter_delay_variation", log_type_, |
| 58 | time_series.inter_delay_variations_ms, |
| 59 | Unit::kMilliseconds, |
| 60 | ImprovementDirection::kNeitherIsBetter); |
| 61 | } |
| 62 | if (!time_series.inter_size_variations_bytes.IsEmpty()) { |
| 63 | logger_->LogMetric("inter_size_variation", log_type_, |
| 64 | time_series.inter_size_variations_bytes, Unit::kBytes, |
| 65 | ImprovementDirection::kNeitherIsBetter); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } // namespace test |
| 70 | } // namespace webrtc |