xref: /aosp_15_r20/external/webrtc/video/config/simulcast.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2014 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 VIDEO_CONFIG_SIMULCAST_H_
12 #define VIDEO_CONFIG_SIMULCAST_H_
13 
14 #include <stddef.h>
15 
16 #include <vector>
17 
18 #include "api/field_trials_view.h"
19 #include "api/units/data_rate.h"
20 #include "video/config/video_encoder_config.h"
21 
22 namespace cricket {
23 
24 // Gets the total maximum bitrate for the `streams`.
25 webrtc::DataRate GetTotalMaxBitrate(
26     const std::vector<webrtc::VideoStream>& streams);
27 
28 // Adds any bitrate of `max_bitrate` that is above the total maximum bitrate for
29 // the `layers` to the highest quality layer.
30 void BoostMaxSimulcastLayer(webrtc::DataRate max_bitrate,
31                             std::vector<webrtc::VideoStream>* layers);
32 
33 // Round size to nearest simulcast-friendly size
34 int NormalizeSimulcastSize(int size, size_t simulcast_layers);
35 
36 // Gets simulcast settings.
37 std::vector<webrtc::VideoStream> GetSimulcastConfig(
38     size_t min_layers,
39     size_t max_layers,
40     int width,
41     int height,
42     double bitrate_priority,
43     int max_qp,
44     bool is_screenshare_with_conference_mode,
45     bool temporal_layers_supported,
46     const webrtc::FieldTrialsView& trials);
47 
48 // Gets the simulcast config layers for a non-screensharing case.
49 std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
50     size_t max_layers,
51     int width,
52     int height,
53     double bitrate_priority,
54     int max_qp,
55     bool temporal_layers_supported,
56     bool base_heavy_tl3_rate_alloc,
57     const webrtc::FieldTrialsView& trials);
58 
59 // Gets simulcast config layers for screenshare settings.
60 std::vector<webrtc::VideoStream> GetScreenshareLayers(
61     size_t max_layers,
62     int width,
63     int height,
64     double bitrate_priority,
65     int max_qp,
66     bool temporal_layers_supported,
67     bool base_heavy_tl3_rate_alloc,
68     const webrtc::FieldTrialsView& trials);
69 
70 }  // namespace cricket
71 
72 #endif  // VIDEO_CONFIG_SIMULCAST_H_
73