simulcast_description.h 4.0 KB

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