Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 CALL_BITRATE_CONSTRAINTS_H_ |
| 12 | #define CALL_BITRATE_CONSTRAINTS_H_ |
| 13 | |
| 14 | #include <algorithm> |
| 15 | |
Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 16 | namespace webrtc { |
Niels Möller | 0c4f7be | 2018-05-07 14:01:37 +0200 | [diff] [blame] | 17 | // TODO(srte): BitrateConstraints and BitrateSettings should be merged. |
Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 18 | // Both represent the same kind data, but are using different default |
| 19 | // initializer and representation of unset values. |
| 20 | struct BitrateConstraints { |
| 21 | int min_bitrate_bps = 0; |
| 22 | int start_bitrate_bps = kDefaultStartBitrateBps; |
| 23 | int max_bitrate_bps = -1; |
| 24 | |
| 25 | private: |
| 26 | static constexpr int kDefaultStartBitrateBps = 300000; |
| 27 | }; |
| 28 | |
Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 29 | // Like std::min, but considers non-positive values to be unset. |
| 30 | template <typename T> |
| 31 | static T MinPositive(T a, T b) { |
| 32 | if (a <= 0) { |
| 33 | return b; |
| 34 | } |
| 35 | if (b <= 0) { |
| 36 | return a; |
| 37 | } |
| 38 | return std::min(a, b); |
| 39 | } |
| 40 | } // namespace webrtc |
| 41 | #endif // CALL_BITRATE_CONSTRAINTS_H_ |