Amit Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 1 | /* |
| 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 Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 11 | #include "pc/simulcast_description.h" |
| 12 | |
Amit Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
| 14 | |
| 15 | namespace cricket { |
| 16 | |
Niels Möller | 2d3186e | 2022-01-24 13:15:03 | [diff] [blame] | 17 | SimulcastLayer::SimulcastLayer(absl::string_view rid, bool is_paused) |
Amit Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 18 | : rid{rid}, is_paused{is_paused} { |
Amit Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 19 | RTC_DCHECK(!rid.empty()); |
| 20 | } |
| 21 | |
Amit Hilbuch | c63ddb2 | 2019-01-02 18:13:58 | [diff] [blame] | 22 | bool SimulcastLayer::operator==(const SimulcastLayer& other) const { |
| 23 | return rid == other.rid && is_paused == other.is_paused; |
| 24 | } |
| 25 | |
Amit Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 26 | void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) { |
| 27 | list_.push_back({layer}); |
| 28 | } |
| 29 | |
| 30 | void SimulcastLayerList::AddLayerWithAlternatives( |
| 31 | const std::vector<SimulcastLayer>& rids) { |
| 32 | RTC_DCHECK(!rids.empty()); |
| 33 | list_.push_back(rids); |
| 34 | } |
| 35 | |
| 36 | const std::vector<SimulcastLayer>& SimulcastLayerList::operator[]( |
| 37 | size_t index) const { |
| 38 | RTC_DCHECK_LT(index, list_.size()); |
| 39 | return list_[index]; |
| 40 | } |
| 41 | |
| 42 | bool SimulcastDescription::empty() const { |
| 43 | return send_layers_.empty() && receive_layers_.empty(); |
| 44 | } |
| 45 | |
Amit Hilbuch | c57d573 | 2018-12-11 23:30:11 | [diff] [blame] | 46 | std::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 Hilbuch | a201204 | 2018-12-03 19:35:05 | [diff] [blame] | 57 | } // namespace cricket |