blob: f4708ff0256d6216131436584d142e049a346fab [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
73 private:
74 // TODO(amithi, bugs.webrtc.org/10075):
75 // Validate that rids do not repeat in the list.
76 std::vector<std::vector<SimulcastLayer>> list_;
77};
78
79// Describes the simulcast options of a video media section.
80// This will list the send and receive layers (along with their alternatives).
81// Each simulcast layer has an identifier (rid) and can optionally be paused.
82// The order of the layers (as well as alternates) indicates user preference
83// from first to last (most preferred to least preferred).
84// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
85class SimulcastDescription final {
86 public:
87 const SimulcastLayerList& send_layers() const { return send_layers_; }
88 SimulcastLayerList& send_layers() { return send_layers_; }
89
90 const SimulcastLayerList& receive_layers() const { return receive_layers_; }
91 SimulcastLayerList& receive_layers() { return receive_layers_; }
92
93 bool empty() const;
94
95 private:
96 // TODO(amithi, bugs.webrtc.org/10075):
97 // Validate that rids do not repeat in send and receive layers.
98 SimulcastLayerList send_layers_;
99 SimulcastLayerList receive_layers_;
100};
101
102} // namespace cricket
103
104#endif // PC_SIMULCASTDESCRIPTION_H_