Adding SDP parsing for Simulcast.
Parsing simulcast according to:
https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
Created SdpSerializer for making serialized components more testable.
Simulcast functionality is still not accessible to users.
Bug: webrtc:10055
Change-Id: Ia6e4cef756cb954521dd19e22911f8eb6498880e
Reviewed-on: https://webrtc-review.googlesource.com/c/112160
Commit-Queue: Amit Hilbuch <amithi@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25883}
diff --git a/pc/simulcastdescription.h b/pc/simulcastdescription.h
new file mode 100644
index 0000000..f4708ff
--- /dev/null
+++ b/pc/simulcastdescription.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2018 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef PC_SIMULCASTDESCRIPTION_H_
+#define PC_SIMULCASTDESCRIPTION_H_
+
+#include <string>
+#include <vector>
+
+namespace cricket {
+
+// Describes a Simulcast Layer.
+// Each simulcast layer has a rid as the identifier and a paused flag.
+// See also: https://tools.ietf.org/html/draft-ietf-mmusic-rid-15 for
+// an explanation about rids.
+struct SimulcastLayer final {
+ SimulcastLayer(const std::string& rid, bool is_paused);
+
+ SimulcastLayer(const SimulcastLayer& other) = default;
+ SimulcastLayer& operator=(const SimulcastLayer& other) = default;
+
+ std::string rid;
+ bool is_paused;
+};
+
+// Describes a list of Simulcast layers.
+// Simulcast layers are specified in order of preference.
+// Each layer can have a list of alternatives (in order of preference).
+// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
+// Example Usage:
+// To populate a list that specifies the following:
+// 1. Layer 1 or Layer 2
+// 2. Layer 3
+// 3. Layer 4 or Layer 5
+// Use the following code:
+// SimulcastLayerList list;
+// list.AddLayerWithAlternatives(
+// {SimulcastLayer("1", false), SimulcastLayer("2", false});
+// list.AddLayer("3");
+// list.AddLayerWithAlternatives(
+// {SimulcastLayer("4", false), SimulcastLayer("5", false});
+class SimulcastLayerList final {
+ public:
+ // Use to add a layer when there will be no alternatives.
+ void AddLayer(const SimulcastLayer& layer);
+
+ // Use to add a list of alternatives.
+ // The alternatives should be specified in order of preference.
+ void AddLayerWithAlternatives(const std::vector<SimulcastLayer>& layers);
+
+ // Read-only access to the contents.
+ // Note: This object does not allow removal of layers.
+ std::vector<std::vector<SimulcastLayer>>::const_iterator begin() const {
+ return list_.begin();
+ }
+
+ std::vector<std::vector<SimulcastLayer>>::const_iterator end() const {
+ return list_.end();
+ }
+
+ const std::vector<SimulcastLayer>& operator[](size_t index) const;
+
+ size_t size() const { return list_.size(); }
+ bool empty() const { return list_.empty(); }
+
+ private:
+ // TODO(amithi, bugs.webrtc.org/10075):
+ // Validate that rids do not repeat in the list.
+ std::vector<std::vector<SimulcastLayer>> list_;
+};
+
+// Describes the simulcast options of a video media section.
+// This will list the send and receive layers (along with their alternatives).
+// Each simulcast layer has an identifier (rid) and can optionally be paused.
+// The order of the layers (as well as alternates) indicates user preference
+// from first to last (most preferred to least preferred).
+// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
+class SimulcastDescription final {
+ public:
+ const SimulcastLayerList& send_layers() const { return send_layers_; }
+ SimulcastLayerList& send_layers() { return send_layers_; }
+
+ const SimulcastLayerList& receive_layers() const { return receive_layers_; }
+ SimulcastLayerList& receive_layers() { return receive_layers_; }
+
+ bool empty() const;
+
+ private:
+ // TODO(amithi, bugs.webrtc.org/10075):
+ // Validate that rids do not repeat in send and receive layers.
+ SimulcastLayerList send_layers_;
+ SimulcastLayerList receive_layers_;
+};
+
+} // namespace cricket
+
+#endif // PC_SIMULCASTDESCRIPTION_H_