blob: 8b510febaacb384794b3850eaa1b60d6d24402a5 [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
Jonas Olssona4d87372019-07-05 19:08:33 +020011#include "pc/simulcast_description.h"
12
Amit Hilbucha2012042018-12-03 11:35:05 -080013#include <utility>
14
Amit Hilbucha2012042018-12-03 11:35:05 -080015#include "rtc_base/checks.h"
16
17namespace cricket {
18
19SimulcastLayer::SimulcastLayer(const std::string& rid, bool is_paused)
20 : rid{rid}, is_paused{is_paused} {
Amit Hilbucha2012042018-12-03 11:35:05 -080021 RTC_DCHECK(!rid.empty());
22}
23
Amit Hilbuchc63ddb22019-01-02 10:13:58 -080024bool SimulcastLayer::operator==(const SimulcastLayer& other) const {
25 return rid == other.rid && is_paused == other.is_paused;
26}
27
Amit Hilbucha2012042018-12-03 11:35:05 -080028void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) {
29 list_.push_back({layer});
30}
31
32void SimulcastLayerList::AddLayerWithAlternatives(
33 const std::vector<SimulcastLayer>& rids) {
34 RTC_DCHECK(!rids.empty());
35 list_.push_back(rids);
36}
37
38const std::vector<SimulcastLayer>& SimulcastLayerList::operator[](
39 size_t index) const {
40 RTC_DCHECK_LT(index, list_.size());
41 return list_[index];
42}
43
44bool SimulcastDescription::empty() const {
45 return send_layers_.empty() && receive_layers_.empty();
46}
47
Amit Hilbuchc57d5732018-12-11 15:30:11 -080048std::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 Hilbucha2012042018-12-03 11:35:05 -080059} // namespace cricket