blob: ec8741567789ee30aeb10f282e99591f5b18cfaa [file] [log] [blame]
Amit Hilbucha2012042018-12-03 19:35:051/*
2 * Copyright 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
Jonas Olssona4d87372019-07-05 17:08:3311#include "pc/simulcast_description.h"
12
Amit Hilbucha2012042018-12-03 19:35:0513#include "rtc_base/checks.h"
14
15namespace cricket {
16
Niels Möller2d3186e2022-01-24 13:15:0317SimulcastLayer::SimulcastLayer(absl::string_view rid, bool is_paused)
Amit Hilbucha2012042018-12-03 19:35:0518 : rid{rid}, is_paused{is_paused} {
Amit Hilbucha2012042018-12-03 19:35:0519 RTC_DCHECK(!rid.empty());
20}
21
Amit Hilbuchc63ddb22019-01-02 18:13:5822bool SimulcastLayer::operator==(const SimulcastLayer& other) const {
23 return rid == other.rid && is_paused == other.is_paused;
24}
25
Amit Hilbucha2012042018-12-03 19:35:0526void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) {
27 list_.push_back({layer});
28}
29
30void SimulcastLayerList::AddLayerWithAlternatives(
31 const std::vector<SimulcastLayer>& rids) {
32 RTC_DCHECK(!rids.empty());
33 list_.push_back(rids);
34}
35
36const std::vector<SimulcastLayer>& SimulcastLayerList::operator[](
37 size_t index) const {
38 RTC_DCHECK_LT(index, list_.size());
39 return list_[index];
40}
41
42bool SimulcastDescription::empty() const {
43 return send_layers_.empty() && receive_layers_.empty();
44}
45
Amit Hilbuchc57d5732018-12-11 23:30:1146std::vector<SimulcastLayer> SimulcastLayerList::GetAllLayers() const {
47 std::vector<SimulcastLayer> result;
48 for (auto groupIt = begin(); groupIt != end(); groupIt++) {
49 for (auto it = groupIt->begin(); it != groupIt->end(); it++) {
50 result.push_back(*it);
51 }
52 }
53
54 return result;
55}
56
Amit Hilbucha2012042018-12-03 19:35:0557} // namespace cricket