Rasmus Brandt | 3dde450 | 2019-03-21 11:46:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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 "rtc_base/experiments/keyframe_interval_settings.h" |
| 12 | |
| 13 | #include "api/transport/field_trial_based_config.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | namespace { |
| 18 | |
| 19 | constexpr char kFieldTrialName[] = "WebRTC-KeyframeInterval"; |
| 20 | |
| 21 | } // namespace |
| 22 | |
| 23 | KeyframeIntervalSettings::KeyframeIntervalSettings( |
| 24 | const WebRtcKeyValueConfig* const key_value_config) |
| 25 | : min_keyframe_send_interval_ms_("min_keyframe_send_interval_ms"), |
| 26 | max_wait_for_keyframe_ms_("max_wait_for_keyframe_ms"), |
| 27 | max_wait_for_frame_ms_("max_wait_for_frame_ms") { |
| 28 | ParseFieldTrial({&min_keyframe_send_interval_ms_, &max_wait_for_keyframe_ms_, |
| 29 | &max_wait_for_frame_ms_}, |
| 30 | key_value_config->Lookup(kFieldTrialName)); |
| 31 | } |
| 32 | |
| 33 | KeyframeIntervalSettings KeyframeIntervalSettings::ParseFromFieldTrials() { |
| 34 | FieldTrialBasedConfig field_trial_config; |
| 35 | return KeyframeIntervalSettings(&field_trial_config); |
| 36 | } |
| 37 | |
| 38 | absl::optional<int> KeyframeIntervalSettings::MinKeyframeSendIntervalMs() |
| 39 | const { |
| 40 | return min_keyframe_send_interval_ms_.GetOptional(); |
| 41 | } |
| 42 | |
| 43 | absl::optional<int> KeyframeIntervalSettings::MaxWaitForKeyframeMs() const { |
| 44 | return max_wait_for_keyframe_ms_.GetOptional(); |
| 45 | } |
| 46 | |
| 47 | absl::optional<int> KeyframeIntervalSettings::MaxWaitForFrameMs() const { |
| 48 | return max_wait_for_frame_ms_.GetOptional(); |
| 49 | } |
| 50 | |
| 51 | } // namespace webrtc |