blob: 98e89c085856b08ebbcefe7c3225aa0d44ec1dbb [file] [log] [blame]
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +01001/*
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
Patrik Höglundb6b29e02018-06-21 16:58:01 +020011#ifndef API_BITRATE_CONSTRAINTS_H_
12#define API_BITRATE_CONSTRAINTS_H_
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +010013
14#include <algorithm>
15
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +010016namespace webrtc {
Niels Möller0c4f7be2018-05-07 14:01:37 +020017// TODO(srte): BitrateConstraints and BitrateSettings should be merged.
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +010018// Both represent the same kind data, but are using different default
19// initializer and representation of unset values.
20struct 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 Janssonfc8d26b2018-02-21 09:52:06 +010029// Like std::min, but considers non-positive values to be unset.
30template <typename T>
31static 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
Patrik Höglundb6b29e02018-06-21 16:58:01 +020041#endif // API_BITRATE_CONSTRAINTS_H_