blob: 61849ce5dc7b233779cc94ea4244a01115bb8d7b [file] [log] [blame]
Amit Hilbucha2012042018-12-03 11:35:05 -08001/*
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
11#include <utility>
12
13#include "pc/simulcastdescription.h"
14#include "rtc_base/checks.h"
15
16namespace cricket {
17
18SimulcastLayer::SimulcastLayer(const std::string& rid, bool is_paused)
19 : rid{rid}, is_paused{is_paused} {
Amit Hilbucha2012042018-12-03 11:35:05 -080020 RTC_DCHECK(!rid.empty());
21}
22
Amit Hilbuchc63ddb22019-01-02 10:13:58 -080023bool SimulcastLayer::operator==(const SimulcastLayer& other) const {
24 return rid == other.rid && is_paused == other.is_paused;
25}
26
Amit Hilbucha2012042018-12-03 11:35:05 -080027void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) {
28 list_.push_back({layer});
29}
30
31void SimulcastLayerList::AddLayerWithAlternatives(
32 const std::vector<SimulcastLayer>& rids) {
33 RTC_DCHECK(!rids.empty());
34 list_.push_back(rids);
35}
36
37const std::vector<SimulcastLayer>& SimulcastLayerList::operator[](
38 size_t index) const {
39 RTC_DCHECK_LT(index, list_.size());
40 return list_[index];
41}
42
43bool SimulcastDescription::empty() const {
44 return send_layers_.empty() && receive_layers_.empty();
45}
46
Amit Hilbuchc57d5732018-12-11 15:30:11 -080047std::vector<SimulcastLayer> SimulcastLayerList::GetAllLayers() const {
48 std::vector<SimulcastLayer> result;
49 for (auto groupIt = begin(); groupIt != end(); groupIt++) {
50 for (auto it = groupIt->begin(); it != groupIt->end(); it++) {
51 result.push_back(*it);
52 }
53 }
54
55 return result;
56}
57
Amit Hilbucha2012042018-12-03 11:35:05 -080058} // namespace cricket