blob: f7ae28837e1e9e8f893d2d49519ed177608ed742 [file] [log] [blame]
Amit Hilbucha2012042018-12-03 19:35:051/*
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
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_SIMULCAST_DESCRIPTION_H_
12#define PC_SIMULCAST_DESCRIPTION_H_
Amit Hilbucha2012042018-12-03 19:35:0513
Harald Alvestrand5761e7b2021-01-29 14:45:0814#include <stddef.h>
15
Amit Hilbucha2012042018-12-03 19:35:0516#include <string>
17#include <vector>
18
19namespace cricket {
20
21// Describes a Simulcast Layer.
22// Each simulcast layer has a rid as the identifier and a paused flag.
23// See also: https://tools.ietf.org/html/draft-ietf-mmusic-rid-15 for
24// an explanation about rids.
25struct SimulcastLayer final {
26 SimulcastLayer(const std::string& rid, bool is_paused);
27
28 SimulcastLayer(const SimulcastLayer& other) = default;
29 SimulcastLayer& operator=(const SimulcastLayer& other) = default;
Amit Hilbuchc63ddb22019-01-02 18:13:5830 bool operator==(const SimulcastLayer& other) const;
Amit Hilbucha2012042018-12-03 19:35:0531
32 std::string rid;
33 bool is_paused;
34};
35
36// Describes a list of Simulcast layers.
37// Simulcast layers are specified in order of preference.
38// Each layer can have a list of alternatives (in order of preference).
39// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
40// Example Usage:
41// To populate a list that specifies the following:
42// 1. Layer 1 or Layer 2
43// 2. Layer 3
44// 3. Layer 4 or Layer 5
45// Use the following code:
46// SimulcastLayerList list;
47// list.AddLayerWithAlternatives(
48// {SimulcastLayer("1", false), SimulcastLayer("2", false});
49// list.AddLayer("3");
50// list.AddLayerWithAlternatives(
51// {SimulcastLayer("4", false), SimulcastLayer("5", false});
52class SimulcastLayerList final {
53 public:
Amit Hilbuchc63ddb22019-01-02 18:13:5854 // Type definitions required by a container.
55 typedef size_t size_type;
56 typedef std::vector<SimulcastLayer> value_type;
57 typedef std::vector<std::vector<SimulcastLayer>>::const_iterator
58 const_iterator;
59
Amit Hilbucha2012042018-12-03 19:35:0560 // Use to add a layer when there will be no alternatives.
61 void AddLayer(const SimulcastLayer& layer);
62
63 // Use to add a list of alternatives.
64 // The alternatives should be specified in order of preference.
65 void AddLayerWithAlternatives(const std::vector<SimulcastLayer>& layers);
66
67 // Read-only access to the contents.
68 // Note: This object does not allow removal of layers.
Amit Hilbuchc63ddb22019-01-02 18:13:5869 const_iterator begin() const { return list_.begin(); }
Amit Hilbucha2012042018-12-03 19:35:0570
Amit Hilbuchc63ddb22019-01-02 18:13:5871 const_iterator end() const { return list_.end(); }
Amit Hilbucha2012042018-12-03 19:35:0572
73 const std::vector<SimulcastLayer>& operator[](size_t index) const;
74
75 size_t size() const { return list_.size(); }
76 bool empty() const { return list_.empty(); }
77
Amit Hilbuchc57d5732018-12-11 23:30:1178 // Provides access to all the layers in the simulcast without their
79 // association into groups of alternatives.
80 std::vector<SimulcastLayer> GetAllLayers() const;
81
Amit Hilbucha2012042018-12-03 19:35:0582 private:
83 // TODO(amithi, bugs.webrtc.org/10075):
84 // Validate that rids do not repeat in the list.
85 std::vector<std::vector<SimulcastLayer>> list_;
86};
87
88// Describes the simulcast options of a video media section.
89// This will list the send and receive layers (along with their alternatives).
90// Each simulcast layer has an identifier (rid) and can optionally be paused.
91// The order of the layers (as well as alternates) indicates user preference
92// from first to last (most preferred to least preferred).
93// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
94class SimulcastDescription final {
95 public:
96 const SimulcastLayerList& send_layers() const { return send_layers_; }
97 SimulcastLayerList& send_layers() { return send_layers_; }
98
99 const SimulcastLayerList& receive_layers() const { return receive_layers_; }
100 SimulcastLayerList& receive_layers() { return receive_layers_; }
101
102 bool empty() const;
103
104 private:
105 // TODO(amithi, bugs.webrtc.org/10075):
106 // Validate that rids do not repeat in send and receive layers.
107 SimulcastLayerList send_layers_;
108 SimulcastLayerList receive_layers_;
109};
110
111} // namespace cricket
112
Steve Anton10542f22019-01-11 17:11:00113#endif // PC_SIMULCAST_DESCRIPTION_H_