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