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 "api/video/video_bitrate_allocator.h"
12
13 namespace webrtc {
14
VideoBitrateAllocationParameters(uint32_t total_bitrate_bps,uint32_t framerate)15 VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
16 uint32_t total_bitrate_bps,
17 uint32_t framerate)
18 : total_bitrate(DataRate::BitsPerSec(total_bitrate_bps)),
19 stable_bitrate(DataRate::BitsPerSec(total_bitrate_bps)),
20 framerate(static_cast<double>(framerate)) {}
21
VideoBitrateAllocationParameters(DataRate total_bitrate,double framerate)22 VideoBitrateAllocationParameters::VideoBitrateAllocationParameters(
23 DataRate total_bitrate,
24 double framerate)
25 : total_bitrate(total_bitrate),
26 stable_bitrate(total_bitrate),
27 framerate(framerate) {}
28
VideoBitrateAllocationParameters(DataRate total_bitrate,DataRate stable_bitrate,double framerate)29 VideoBitrateAllocationParameters::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
37 VideoBitrateAllocationParameters::~VideoBitrateAllocationParameters() = default;
38
GetAllocation(uint32_t total_bitrate_bps,uint32_t framerate)39 VideoBitrateAllocation VideoBitrateAllocator::GetAllocation(
40 uint32_t total_bitrate_bps,
41 uint32_t framerate) {
42 return Allocate({DataRate::BitsPerSec(total_bitrate_bps),
43 DataRate::BitsPerSec(total_bitrate_bps),
44 static_cast<double>(framerate)});
45 }
46
Allocate(VideoBitrateAllocationParameters parameters)47 VideoBitrateAllocation VideoBitrateAllocator::Allocate(
48 VideoBitrateAllocationParameters parameters) {
49 return GetAllocation(parameters.total_bitrate.bps(), parameters.framerate);
50 }
51
52 } // namespace webrtc
53