blob: 6ad16c93f2f305b48a187181b8e9cf8a58d4848e [file] [log] [blame]
Florent Castelli8bbdb5b2019-08-02 15:16:28 +02001/*
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 "api/video/video_bitrate_allocator.h"
12
13namespace webrtc {
14
15VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
16 uint32_t total_bitrate_bps,
17 uint32_t framerate)
18 : total_bitrate(DataRate::bps(total_bitrate_bps)),
19 stable_bitrate(DataRate::bps(total_bitrate_bps)),
20 framerate(static_cast<double>(framerate)) {}
21
22VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
23 DataRate total_bitrate,
24 double framerate)
25 : total_bitrate(total_bitrate),
26 stable_bitrate(total_bitrate),
27 framerate(framerate) {}
28
29VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
30 DataRate total_bitrate,
31 DataRate stable_bitrate,
32 double framerate)
33 : total_bitrate(total_bitrate),
34 stable_bitrate(stable_bitrate),
35 framerate(framerate) {}
36
37VideoBitrateAllocationParameters::~VideoBitrateAllocationParameters() = default;
38
39VideoBitrateAllocation VideoBitrateAllocator::GetAllocation(
40 uint32_t total_bitrate_bps,
41 uint32_t framerate) {
42 return Allocate({DataRate::bps(total_bitrate_bps),
43 DataRate::bps(total_bitrate_bps),
44 static_cast<double>(framerate)});
45}
46
47VideoBitrateAllocation VideoBitrateAllocator::Allocate(
48 VideoBitrateAllocationParameters parameters) {
49 return GetAllocation(parameters.total_bitrate.bps(), parameters.framerate);
50}
51
52} // namespace webrtc