Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [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 19:08:33 +0200 | [diff] [blame] | 11 | #include "pc/simulcast_description.h" |
| 12 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 15 | #include "rtc_base/checks.h" |
| 16 | |
| 17 | namespace cricket { |
| 18 | |
| 19 | SimulcastLayer::SimulcastLayer(const std::string& rid, bool is_paused) |
| 20 | : rid{rid}, is_paused{is_paused} { |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 21 | RTC_DCHECK(!rid.empty()); |
| 22 | } |
| 23 | |
Amit Hilbuch | c63ddb2 | 2019-01-02 10:13:58 -0800 | [diff] [blame] | 24 | bool SimulcastLayer::operator==(const SimulcastLayer& other) const { |
| 25 | return rid == other.rid && is_paused == other.is_paused; |
| 26 | } |
| 27 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 28 | void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) { |
| 29 | list_.push_back({layer}); |
| 30 | } |
| 31 | |
| 32 | void SimulcastLayerList::AddLayerWithAlternatives( |
| 33 | const std::vector<SimulcastLayer>& rids) { |
| 34 | RTC_DCHECK(!rids.empty()); |
| 35 | list_.push_back(rids); |
| 36 | } |
| 37 | |
| 38 | const std::vector<SimulcastLayer>& SimulcastLayerList::operator[]( |
| 39 | size_t index) const { |
| 40 | RTC_DCHECK_LT(index, list_.size()); |
| 41 | return list_[index]; |
| 42 | } |
| 43 | |
| 44 | bool SimulcastDescription::empty() const { |
| 45 | return send_layers_.empty() && receive_layers_.empty(); |
| 46 | } |
| 47 | |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 48 | std::vector<SimulcastLayer> SimulcastLayerList::GetAllLayers() const { |
| 49 | std::vector<SimulcastLayer> result; |
| 50 | for (auto groupIt = begin(); groupIt != end(); groupIt++) { |
| 51 | for (auto it = groupIt->begin(); it != groupIt->end(); it++) { |
| 52 | result.push_back(*it); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return result; |
| 57 | } |
| 58 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 59 | } // namespace cricket |