blob: 1337a9ce4d3077bb5df04d5640c4f407eb598bbe [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
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;
Amit Hilbuchc63ddb22019-01-02 18:13:5828 bool operator==(const SimulcastLayer& other) const;
Amit Hilbucha2012042018-12-03 19:35:0529
30 std::string rid;
31 bool is_paused;
32};
33
34// Describes a list of Simulcast layers.
35// Simulcast layers are specified in order of preference.
36// Each layer can have a list of alternatives (in order of preference).
37// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
38// Example Usage:
39// To populate a list that specifies the following:
40// 1. Layer 1 or Layer 2
41// 2. Layer 3
42// 3. Layer 4 or Layer 5
43// Use the following code:
44// SimulcastLayerList list;
45// list.AddLayerWithAlternatives(
46// {SimulcastLayer("1", false), SimulcastLayer("2", false});
47// list.AddLayer("3");
48// list.AddLayerWithAlternatives(
49// {SimulcastLayer("4", false), SimulcastLayer("5", false});
50class SimulcastLayerList final {
51 public:
Amit Hilbuchc63ddb22019-01-02 18:13:5852 // Type definitions required by a container.
53 typedef size_t size_type;
54 typedef std::vector<SimulcastLayer> value_type;
55 typedef std::vector<std::vector<SimulcastLayer>>::const_iterator
56 const_iterator;
57
Amit Hilbucha2012042018-12-03 19:35:0558 // Use to add a layer when there will be no alternatives.
59 void AddLayer(const SimulcastLayer& layer);
60
61 // Use to add a list of alternatives.
62 // The alternatives should be specified in order of preference.
63 void AddLayerWithAlternatives(const std::vector<SimulcastLayer>& layers);
64
65 // Read-only access to the contents.
66 // Note: This object does not allow removal of layers.
Amit Hilbuchc63ddb22019-01-02 18:13:5867 const_iterator begin() const { return list_.begin(); }
Amit Hilbucha2012042018-12-03 19:35:0568
Amit Hilbuchc63ddb22019-01-02 18:13:5869 const_iterator end() const { return list_.end(); }
Amit Hilbucha2012042018-12-03 19:35:0570
71 const std::vector<SimulcastLayer>& operator[](size_t index) const;
72
73 size_t size() const { return list_.size(); }
74 bool empty() const { return list_.empty(); }
75
Amit Hilbuchc57d5732018-12-11 23:30:1176 // Provides access to all the layers in the simulcast without their
77 // association into groups of alternatives.
78 std::vector<SimulcastLayer> GetAllLayers() const;
79
Amit Hilbucha2012042018-12-03 19:35:0580 private:
81 // TODO(amithi, bugs.webrtc.org/10075):
82 // Validate that rids do not repeat in the list.
83 std::vector<std::vector<SimulcastLayer>> list_;
84};
85
86// Describes the simulcast options of a video media section.
87// This will list the send and receive layers (along with their alternatives).
88// Each simulcast layer has an identifier (rid) and can optionally be paused.
89// The order of the layers (as well as alternates) indicates user preference
90// from first to last (most preferred to least preferred).
91// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
92class SimulcastDescription final {
93 public:
94 const SimulcastLayerList& send_layers() const { return send_layers_; }
95 SimulcastLayerList& send_layers() { return send_layers_; }
96
97 const SimulcastLayerList& receive_layers() const { return receive_layers_; }
98 SimulcastLayerList& receive_layers() { return receive_layers_; }
99
100 bool empty() const;
101
102 private:
103 // TODO(amithi, bugs.webrtc.org/10075):
104 // Validate that rids do not repeat in send and receive layers.
105 SimulcastLayerList send_layers_;
106 SimulcastLayerList receive_layers_;
107};
108
109} // namespace cricket
110
Steve Anton10542f22019-01-11 17:11:00111#endif // PC_SIMULCAST_DESCRIPTION_H_