blob: a2802a49984ec1ec719f21972b646b33408bc78a [file] [log] [blame]
buildbot@webrtc.orga8530772014-12-10 09:01:18 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
buildbot@webrtc.orga8530772014-12-10 09:01:18 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.
buildbot@webrtc.orga8530772014-12-10 09:01:18 +00009 */
10
sprang@webrtc.org46d4d292014-12-23 15:19:35 +000011#include <stdio.h>
Steve Antone78bcb92017-10-31 09:53:08 -070012#include <algorithm>
13#include <string>
sprang@webrtc.org46d4d292014-12-23 15:19:35 +000014
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "media/base/streamparams.h"
16#include "media/engine/constants.h"
17#include "media/engine/simulcast.h"
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +020018#include "modules/video_coding/utility/simulcast_rate_allocator.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/arraysize.h"
20#include "rtc_base/logging.h"
21#include "system_wrappers/include/field_trial.h"
tfarina5237aaf2015-11-10 23:44:30 -080022
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000023namespace cricket {
24
Rasmus Brandt195d1d72018-05-09 11:28:01 +020025namespace {
26
Erik Språngb6b1cac2018-08-09 16:12:54 +020027// Limits for legacy conference screensharing mode. Currently used for the
28// lower of the two simulcast streams.
Rasmus Brandt195d1d72018-05-09 11:28:01 +020029constexpr int kScreenshareDefaultTl0BitrateKbps = 200;
30constexpr int kScreenshareDefaultTl1BitrateKbps = 1000;
31
Erik Språngb6b1cac2018-08-09 16:12:54 +020032// Max bitrate for the higher one of the two simulcast stream used for screen
33// content.
Erik Språng58b22842018-08-21 13:15:28 +020034constexpr int kScreenshareHighStreamMaxBitrateBps = 1250000;
Erik Språngb6b1cac2018-08-09 16:12:54 +020035
Rasmus Brandt195d1d72018-05-09 11:28:01 +020036} // namespace
37
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000038struct SimulcastFormat {
39 int width;
40 int height;
41 // The maximum number of simulcast layers can be used for
42 // resolutions at |widthxheigh|.
43 size_t max_layers;
44 // The maximum bitrate for encoding stream at |widthxheight|, when we are
45 // not sending the next higher spatial stream.
pbosbe16f792015-10-16 12:49:39 -070046 int max_bitrate_kbps;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000047 // The target bitrate for encoding stream at |widthxheight|, when this layer
48 // is not the highest layer (i.e., when we are sending another higher spatial
49 // stream).
pbosbe16f792015-10-16 12:49:39 -070050 int target_bitrate_kbps;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000051 // The minimum bitrate needed for encoding stream at |widthxheight|.
pbosbe16f792015-10-16 12:49:39 -070052 int min_bitrate_kbps;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000053};
54
55// These tables describe from which resolution we can use how many
56// simulcast layers at what bitrates (maximum, target, and minimum).
57// Important!! Keep this table from high resolution to low resolution.
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +020058// clang-format off
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000059const SimulcastFormat kSimulcastFormats[] = {
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +020060 {1920, 1080, 3, 5000, 4000, 800},
61 {1280, 720, 3, 2500, 2500, 600},
62 {960, 540, 3, 900, 900, 450},
63 {640, 360, 2, 700, 500, 150},
64 {480, 270, 2, 450, 350, 150},
65 {320, 180, 1, 200, 150, 30},
66 {0, 0, 1, 200, 150, 30}
67};
68// clang-format on
buildbot@webrtc.orga8530772014-12-10 09:01:18 +000069
Seth Hampson1370e302018-02-07 08:50:36 -080070const int kMaxScreenshareSimulcastLayers = 2;
sprang429600d2017-01-26 06:12:26 -080071
Erik Språngbfe3d852018-05-15 09:54:14 +020072// Multiway: Number of temporal layers for each simulcast stream.
Erik Språng58b22842018-08-21 13:15:28 +020073int DefaultNumberOfTemporalLayers(int simulcast_id, bool screenshare) {
Erik Språngbfe3d852018-05-15 09:54:14 +020074 RTC_CHECK_GE(simulcast_id, 0);
75 RTC_CHECK_LT(simulcast_id, webrtc::kMaxSimulcastStreams);
76
77 const int kDefaultNumTemporalLayers = 3;
78
79 const std::string group_name =
Erik Språng58b22842018-08-21 13:15:28 +020080 screenshare ? webrtc::field_trial::FindFullName(
81 "WebRTC-VP8ScreenshareTemporalLayers")
82 : webrtc::field_trial::FindFullName(
83 "WebRTC-VP8ConferenceTemporalLayers");
Erik Språngbfe3d852018-05-15 09:54:14 +020084 if (group_name.empty())
85 return kDefaultNumTemporalLayers;
86
87 int num_temporal_layers = kDefaultNumTemporalLayers;
88 if (sscanf(group_name.c_str(), "%d", &num_temporal_layers) == 1 &&
89 num_temporal_layers > 0 &&
90 num_temporal_layers <= webrtc::kMaxTemporalStreams) {
91 return num_temporal_layers;
92 }
93
94 RTC_LOG(LS_WARNING) << "Attempt to set number of temporal layers to "
95 "incorrect value: "
96 << group_name;
97
98 return kDefaultNumTemporalLayers;
99}
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000100
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000101int FindSimulcastFormatIndex(int width, int height) {
Seth Hampson438663e2018-01-09 11:14:14 -0800102 RTC_DCHECK_GE(width, 0);
103 RTC_DCHECK_GE(height, 0);
kjellandera96e2d72016-02-04 23:52:28 -0800104 for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
sprang429600d2017-01-26 06:12:26 -0800105 if (width * height >=
106 kSimulcastFormats[i].width * kSimulcastFormats[i].height) {
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000107 return i;
108 }
109 }
Seth Hampson438663e2018-01-09 11:14:14 -0800110 RTC_NOTREACHED();
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000111 return -1;
112}
113
114int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
Seth Hampson438663e2018-01-09 11:14:14 -0800115 RTC_DCHECK_GE(width, 0);
116 RTC_DCHECK_GE(height, 0);
117 RTC_DCHECK_GT(max_layers, 0);
kjellandera96e2d72016-02-04 23:52:28 -0800118 for (uint32_t i = 0; i < arraysize(kSimulcastFormats); ++i) {
sprang429600d2017-01-26 06:12:26 -0800119 if (width * height >=
120 kSimulcastFormats[i].width * kSimulcastFormats[i].height &&
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000121 max_layers == kSimulcastFormats[i].max_layers) {
122 return i;
123 }
124 }
Seth Hampson438663e2018-01-09 11:14:14 -0800125 RTC_NOTREACHED();
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000126 return -1;
127}
128
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000129// Simulcast stream width and height must both be dividable by
Rasmus Brandtefbdcb02018-04-26 17:47:42 +0200130// |2 ^ (simulcast_layers - 1)|.
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000131int NormalizeSimulcastSize(int size, size_t simulcast_layers) {
132 const int base2_exponent = static_cast<int>(simulcast_layers) - 1;
133 return ((size >> base2_exponent) << base2_exponent);
134}
135
136size_t FindSimulcastMaxLayers(int width, int height) {
137 int index = FindSimulcastFormatIndex(width, height);
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000138 return kSimulcastFormats[index].max_layers;
139}
140
sprang429600d2017-01-26 06:12:26 -0800141int FindSimulcastMaxBitrateBps(int width, int height) {
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000142 const int format_index = FindSimulcastFormatIndex(width, height);
pbosbe16f792015-10-16 12:49:39 -0700143 return kSimulcastFormats[format_index].max_bitrate_kbps * 1000;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000144}
145
sprang429600d2017-01-26 06:12:26 -0800146int FindSimulcastTargetBitrateBps(int width, int height) {
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000147 const int format_index = FindSimulcastFormatIndex(width, height);
pbosbe16f792015-10-16 12:49:39 -0700148 return kSimulcastFormats[format_index].target_bitrate_kbps * 1000;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000149}
150
sprang429600d2017-01-26 06:12:26 -0800151int FindSimulcastMinBitrateBps(int width, int height) {
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000152 const int format_index = FindSimulcastFormatIndex(width, height);
pbosbe16f792015-10-16 12:49:39 -0700153 return kSimulcastFormats[format_index].min_bitrate_kbps * 1000;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000154}
155
Seth Hampson438663e2018-01-09 11:14:14 -0800156void SlotSimulcastMaxResolution(size_t max_layers, int* width, int* height) {
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000157 int index = FindSimulcastFormatIndex(*width, *height, max_layers);
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000158 *width = kSimulcastFormats[index].width;
159 *height = kSimulcastFormats[index].height;
Mirko Bonadei675513b2017-11-09 11:09:25 +0100160 RTC_LOG(LS_INFO) << "SlotSimulcastMaxResolution to width:" << *width
161 << " height:" << *height;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000162}
163
Seth Hampson1370e302018-02-07 08:50:36 -0800164void BoostMaxSimulcastLayer(int max_bitrate_bps,
165 std::vector<webrtc::VideoStream>* layers) {
Åsa Persson55659812018-06-18 17:51:32 +0200166 if (layers->empty())
167 return;
168
Seth Hampson1370e302018-02-07 08:50:36 -0800169 // Spend additional bits to boost the max layer.
170 int bitrate_left_bps = max_bitrate_bps - GetTotalMaxBitrateBps(*layers);
171 if (bitrate_left_bps > 0) {
172 layers->back().max_bitrate_bps += bitrate_left_bps;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000173 }
Seth Hampson1370e302018-02-07 08:50:36 -0800174}
175
176int GetTotalMaxBitrateBps(const std::vector<webrtc::VideoStream>& layers) {
Åsa Persson55659812018-06-18 17:51:32 +0200177 if (layers.empty())
178 return 0;
179
Seth Hampson1370e302018-02-07 08:50:36 -0800180 int total_max_bitrate_bps = 0;
181 for (size_t s = 0; s < layers.size() - 1; ++s) {
182 total_max_bitrate_bps += layers[s].target_bitrate_bps;
183 }
184 total_max_bitrate_bps += layers.back().max_bitrate_bps;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000185 return total_max_bitrate_bps;
186}
187
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200188std::vector<webrtc::VideoStream> GetSimulcastConfig(
189 size_t max_layers,
190 int width,
191 int height,
192 int /*max_bitrate_bps*/,
193 double bitrate_priority,
194 int max_qp,
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000195 int max_framerate,
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200196 bool is_screenshare,
197 bool temporal_layers_supported) {
Seth Hampson1370e302018-02-07 08:50:36 -0800198 if (is_screenshare) {
Åsa Persson55659812018-06-18 17:51:32 +0200199 return GetScreenshareLayers(max_layers, width, height, bitrate_priority,
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000200 max_qp, max_framerate,
201 temporal_layers_supported);
sprang429600d2017-01-26 06:12:26 -0800202 } else {
Åsa Persson55659812018-06-18 17:51:32 +0200203 return GetNormalSimulcastLayers(max_layers, width, height, bitrate_priority,
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000204 max_qp, max_framerate,
205 temporal_layers_supported);
sprang429600d2017-01-26 06:12:26 -0800206 }
Seth Hampson1370e302018-02-07 08:50:36 -0800207}
sprang429600d2017-01-26 06:12:26 -0800208
Seth Hampson1370e302018-02-07 08:50:36 -0800209std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
210 size_t max_layers,
211 int width,
212 int height,
Seth Hampson1370e302018-02-07 08:50:36 -0800213 double bitrate_priority,
214 int max_qp,
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000215 int max_framerate,
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200216 bool temporal_layers_supported) {
Seth Hampson1370e302018-02-07 08:50:36 -0800217 // TODO(bugs.webrtc.org/8785): Currently if the resolution isn't large enough
218 // (defined in kSimulcastFormats) we scale down the number of simulcast
219 // layers. Consider changing this so that the application can have more
220 // control over exactly how many simulcast layers are used.
221 size_t num_simulcast_layers = FindSimulcastMaxLayers(width, height);
222 if (num_simulcast_layers > max_layers) {
223 // TODO(bugs.webrtc.org/8486): This scales down the resolution if the
224 // number of simulcast layers created by the application isn't sufficient
225 // (defined in kSimulcastFormats). For example if the input frame's
226 // resolution is HD, but there are only 2 simulcast layers, the
227 // resolution gets scaled down to VGA. Consider taking this logic out to
228 // allow the application more control over the resolutions.
229 SlotSimulcastMaxResolution(max_layers, &width, &height);
230 num_simulcast_layers = max_layers;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000231 }
Seth Hampson1370e302018-02-07 08:50:36 -0800232 std::vector<webrtc::VideoStream> layers(num_simulcast_layers);
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000233
Seth Hampson1370e302018-02-07 08:50:36 -0800234 // Format width and height has to be divisible by |2 ^ num_simulcast_layers -
235 // 1|.
236 width = NormalizeSimulcastSize(width, num_simulcast_layers);
237 height = NormalizeSimulcastSize(height, num_simulcast_layers);
238 // Add simulcast streams, from highest resolution (|s| = num_simulcast_layers
239 // -1) to lowest resolution at |s| = 0.
240 for (size_t s = num_simulcast_layers - 1;; --s) {
241 layers[s].width = width;
242 layers[s].height = height;
243 // TODO(pbos): Fill actual temporal-layer bitrate thresholds.
244 layers[s].max_qp = max_qp;
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200245 layers[s].num_temporal_layers =
Erik Språng58b22842018-08-21 13:15:28 +0200246 temporal_layers_supported ? DefaultNumberOfTemporalLayers(s, false) : 0;
Seth Hampson1370e302018-02-07 08:50:36 -0800247 layers[s].max_bitrate_bps = FindSimulcastMaxBitrateBps(width, height);
248 layers[s].target_bitrate_bps = FindSimulcastTargetBitrateBps(width, height);
Erik Språng58b22842018-08-21 13:15:28 +0200249 int num_temporal_layers = DefaultNumberOfTemporalLayers(s, false);
Erik Språngd497e6b2018-07-06 17:17:10 +0200250 if (s == 0) {
Erik Språng79478ad2018-05-18 09:39:55 +0200251 // If alternative number temporal layers is selected, adjust the
Erik Språngd92288f2018-07-04 10:07:40 +0200252 // bitrate of the lowest simulcast stream so that absolute bitrate for
253 // the base temporal layer matches the bitrate for the base temporal
254 // layer with the default 3 simulcast streams. Otherwise we risk a
255 // higher threshold for receiving a feed at all.
Erik Språngd497e6b2018-07-06 17:17:10 +0200256 float rate_factor = 1.0;
257 if (num_temporal_layers == 3) {
258 if (webrtc::field_trial::IsEnabled("WebRTC-UseShortVP8TL3Pattern")) {
259 // Shortened pattern increases TL0 bitrate from 40% to 60%.
260 rate_factor = 0.4 / 0.6;
261 }
262 } else {
263 rate_factor =
264 webrtc::SimulcastRateAllocator::GetTemporalRateAllocation(3, 0) /
265 webrtc::SimulcastRateAllocator::GetTemporalRateAllocation(
266 num_temporal_layers, 0);
267 }
268
Erik Språng79478ad2018-05-18 09:39:55 +0200269 layers[s].max_bitrate_bps =
270 static_cast<int>(layers[s].max_bitrate_bps * rate_factor);
271 layers[s].target_bitrate_bps =
272 static_cast<int>(layers[s].target_bitrate_bps * rate_factor);
273 }
Seth Hampson1370e302018-02-07 08:50:36 -0800274 layers[s].min_bitrate_bps = FindSimulcastMinBitrateBps(width, height);
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000275 layers[s].max_framerate = max_framerate;
sprang02569ad2017-07-06 05:05:50 -0700276
Seth Hampson1370e302018-02-07 08:50:36 -0800277 width /= 2;
278 height /= 2;
sprang02569ad2017-07-06 05:05:50 -0700279
Seth Hampson1370e302018-02-07 08:50:36 -0800280 if (s == 0) {
281 break;
sprang02569ad2017-07-06 05:05:50 -0700282 }
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000283 }
Seth Hampson1370e302018-02-07 08:50:36 -0800284 // Currently the relative bitrate priority of the sender is controlled by
285 // the value of the lowest VideoStream.
286 // TODO(bugs.webrtc.org/8630): The web specification describes being able to
287 // control relative bitrate for each individual simulcast layer, but this
288 // is currently just implemented per rtp sender.
289 layers[0].bitrate_priority = bitrate_priority;
290 return layers;
291}
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000292
Seth Hampson1370e302018-02-07 08:50:36 -0800293std::vector<webrtc::VideoStream> GetScreenshareLayers(
294 size_t max_layers,
295 int width,
296 int height,
Seth Hampson1370e302018-02-07 08:50:36 -0800297 double bitrate_priority,
298 int max_qp,
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000299 int max_framerate,
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200300 bool temporal_layers_supported) {
Seth Hampson1370e302018-02-07 08:50:36 -0800301 size_t num_simulcast_layers =
Ilya Nikolaevskiya3df0f22018-07-24 17:02:07 +0200302 std::min<int>(max_layers, kMaxScreenshareSimulcastLayers);
Seth Hampson1370e302018-02-07 08:50:36 -0800303
304 std::vector<webrtc::VideoStream> layers(num_simulcast_layers);
Seth Hampson1370e302018-02-07 08:50:36 -0800305 // For legacy screenshare in conference mode, tl0 and tl1 bitrates are
306 // piggybacked on the VideoCodec struct as target and max bitrates,
Erik Språngcc681cc2018-03-14 17:52:55 +0100307 // respectively. See eg. webrtc::LibvpxVp8Encoder::SetRates().
Seth Hampson1370e302018-02-07 08:50:36 -0800308 layers[0].width = width;
309 layers[0].height = height;
310 layers[0].max_qp = max_qp;
311 layers[0].max_framerate = 5;
312 layers[0].min_bitrate_bps = kMinVideoBitrateBps;
Rasmus Brandt195d1d72018-05-09 11:28:01 +0200313 layers[0].target_bitrate_bps = kScreenshareDefaultTl0BitrateKbps * 1000;
314 layers[0].max_bitrate_bps = kScreenshareDefaultTl1BitrateKbps * 1000;
Sergio Garcia Murillo43800f92018-06-21 16:16:38 +0200315 layers[0].num_temporal_layers = temporal_layers_supported ? 2 : 0;
Seth Hampson1370e302018-02-07 08:50:36 -0800316
317 // With simulcast enabled, add another spatial layer. This one will have a
318 // more normal layout, with the regular 3 temporal layer pattern and no fps
319 // restrictions. The base simulcast layer will still use legacy setup.
320 if (num_simulcast_layers == kMaxScreenshareSimulcastLayers) {
321 // Add optional upper simulcast layer.
Erik Språng58b22842018-08-21 13:15:28 +0200322 const int num_temporal_layers = DefaultNumberOfTemporalLayers(1, true);
Erik Språngb6b1cac2018-08-09 16:12:54 +0200323 int max_bitrate_bps;
324 if (!temporal_layers_supported) {
325 // Set the max bitrate to where the base layer would have been if temporal
Erik Språng58b22842018-08-21 13:15:28 +0200326 // layers were enabled.
Erik Språngb6b1cac2018-08-09 16:12:54 +0200327 max_bitrate_bps = static_cast<int>(
328 kScreenshareHighStreamMaxBitrateBps *
329 webrtc::SimulcastRateAllocator::GetTemporalRateAllocation(
330 num_temporal_layers, 0));
Erik Språng58b22842018-08-21 13:15:28 +0200331 } else if (DefaultNumberOfTemporalLayers(1, true) != 3 ||
Erik Språngb6b1cac2018-08-09 16:12:54 +0200332 webrtc::field_trial::IsEnabled("WebRTC-UseShortVP8TL3Pattern")) {
333 // Experimental temporal layer mode used, use increased max bitrate.
334 max_bitrate_bps = kScreenshareHighStreamMaxBitrateBps;
335 } else {
336 // Keep current bitrates with default 3tl/8 frame settings.
337 // Lowest temporal layers of a 3 layer setup will have 40% of the total
338 // bitrate allocation for that simulcast layer. Make sure the gap between
339 // the target of the lower simulcast layer and first temporal layer of the
340 // higher one is at most 2x the bitrate, so that upswitching is not
341 // hampered by stalled bitrate estimates.
342 max_bitrate_bps = 2 * ((layers[0].target_bitrate_bps * 10) / 4);
343 }
344
Seth Hampson1370e302018-02-07 08:50:36 -0800345 // Cap max bitrate so it isn't overly high for the given resolution.
346 max_bitrate_bps = std::min<int>(max_bitrate_bps,
347 FindSimulcastMaxBitrateBps(width, height));
Seth Hampson1370e302018-02-07 08:50:36 -0800348 layers[1].width = width;
349 layers[1].height = height;
350 layers[1].max_qp = max_qp;
Mirko Bonadei948b7e32018-08-14 07:23:21 +0000351 layers[1].max_framerate = max_framerate;
Erik Språngb6b1cac2018-08-09 16:12:54 +0200352 layers[1].num_temporal_layers =
Erik Språng58b22842018-08-21 13:15:28 +0200353 temporal_layers_supported ? DefaultNumberOfTemporalLayers(1, true) : 0;
Seth Hampson1370e302018-02-07 08:50:36 -0800354 layers[1].min_bitrate_bps = layers[0].target_bitrate_bps * 2;
355 layers[1].target_bitrate_bps = max_bitrate_bps;
356 layers[1].max_bitrate_bps = max_bitrate_bps;
357 }
358
Seth Hampson24722b32017-12-22 09:36:42 -0800359 // The bitrate priority currently implemented on a per-sender level, so we
Seth Hampson1370e302018-02-07 08:50:36 -0800360 // just set it for the first simulcast layer.
361 layers[0].bitrate_priority = bitrate_priority;
362 return layers;
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000363}
364
buildbot@webrtc.orga8530772014-12-10 09:01:18 +0000365} // namespace cricket