xref: /aosp_15_r20/external/webrtc/pc/simulcast_description.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2018 The WebRTC Project Authors. All rights reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #include "pc/simulcast_description.h"
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h"
14*d9f75844SAndroid Build Coastguard Worker 
15*d9f75844SAndroid Build Coastguard Worker namespace cricket {
16*d9f75844SAndroid Build Coastguard Worker 
SimulcastLayer(absl::string_view rid,bool is_paused)17*d9f75844SAndroid Build Coastguard Worker SimulcastLayer::SimulcastLayer(absl::string_view rid, bool is_paused)
18*d9f75844SAndroid Build Coastguard Worker     : rid{rid}, is_paused{is_paused} {
19*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(!rid.empty());
20*d9f75844SAndroid Build Coastguard Worker }
21*d9f75844SAndroid Build Coastguard Worker 
operator ==(const SimulcastLayer & other) const22*d9f75844SAndroid Build Coastguard Worker bool SimulcastLayer::operator==(const SimulcastLayer& other) const {
23*d9f75844SAndroid Build Coastguard Worker   return rid == other.rid && is_paused == other.is_paused;
24*d9f75844SAndroid Build Coastguard Worker }
25*d9f75844SAndroid Build Coastguard Worker 
AddLayer(const SimulcastLayer & layer)26*d9f75844SAndroid Build Coastguard Worker void SimulcastLayerList::AddLayer(const SimulcastLayer& layer) {
27*d9f75844SAndroid Build Coastguard Worker   list_.push_back({layer});
28*d9f75844SAndroid Build Coastguard Worker }
29*d9f75844SAndroid Build Coastguard Worker 
AddLayerWithAlternatives(const std::vector<SimulcastLayer> & rids)30*d9f75844SAndroid Build Coastguard Worker void SimulcastLayerList::AddLayerWithAlternatives(
31*d9f75844SAndroid Build Coastguard Worker     const std::vector<SimulcastLayer>& rids) {
32*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(!rids.empty());
33*d9f75844SAndroid Build Coastguard Worker   list_.push_back(rids);
34*d9f75844SAndroid Build Coastguard Worker }
35*d9f75844SAndroid Build Coastguard Worker 
operator [](size_t index) const36*d9f75844SAndroid Build Coastguard Worker const std::vector<SimulcastLayer>& SimulcastLayerList::operator[](
37*d9f75844SAndroid Build Coastguard Worker     size_t index) const {
38*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK_LT(index, list_.size());
39*d9f75844SAndroid Build Coastguard Worker   return list_[index];
40*d9f75844SAndroid Build Coastguard Worker }
41*d9f75844SAndroid Build Coastguard Worker 
empty() const42*d9f75844SAndroid Build Coastguard Worker bool SimulcastDescription::empty() const {
43*d9f75844SAndroid Build Coastguard Worker   return send_layers_.empty() && receive_layers_.empty();
44*d9f75844SAndroid Build Coastguard Worker }
45*d9f75844SAndroid Build Coastguard Worker 
GetAllLayers() const46*d9f75844SAndroid Build Coastguard Worker std::vector<SimulcastLayer> SimulcastLayerList::GetAllLayers() const {
47*d9f75844SAndroid Build Coastguard Worker   std::vector<SimulcastLayer> result;
48*d9f75844SAndroid Build Coastguard Worker   for (auto groupIt = begin(); groupIt != end(); groupIt++) {
49*d9f75844SAndroid Build Coastguard Worker     for (auto it = groupIt->begin(); it != groupIt->end(); it++) {
50*d9f75844SAndroid Build Coastguard Worker       result.push_back(*it);
51*d9f75844SAndroid Build Coastguard Worker     }
52*d9f75844SAndroid Build Coastguard Worker   }
53*d9f75844SAndroid Build Coastguard Worker 
54*d9f75844SAndroid Build Coastguard Worker   return result;
55*d9f75844SAndroid Build Coastguard Worker }
56*d9f75844SAndroid Build Coastguard Worker 
57*d9f75844SAndroid Build Coastguard Worker }  // namespace cricket
58