rid_description.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 MEDIA_BASE_RID_DESCRIPTION_H_
  11. #define MEDIA_BASE_RID_DESCRIPTION_H_
  12. #include <map>
  13. #include <string>
  14. #include <vector>
  15. namespace cricket {
  16. enum class RidDirection { kSend, kReceive };
  17. // Description of a Restriction Id (RID) according to:
  18. // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15
  19. // A Restriction Identifier serves two purposes:
  20. // 1. Uniquely identifies an RTP stream inside an RTP session.
  21. // When combined with MIDs (https://tools.ietf.org/html/rfc5888),
  22. // RIDs uniquely identify an RTP stream within an RTP session.
  23. // The MID will identify the media section and the RID will identify
  24. // the stream within the section.
  25. // RID identifiers must be unique within the media section.
  26. // 2. Allows indicating further restrictions to the stream.
  27. // These restrictions are added according to the direction specified.
  28. // The direction field identifies the direction of the RTP stream packets
  29. // to which the restrictions apply. The direction is independent of the
  30. // transceiver direction and can be one of {send, recv}.
  31. // The following are some examples of these restrictions:
  32. // a. max-width, max-height, max-fps, max-br, ...
  33. // b. further restricting the codec set (from what m= section specified)
  34. //
  35. // Note: Indicating dependencies between streams (using depend) will not be
  36. // supported, since the WG is adopting a different approach to achieve this.
  37. // As of 2018-12-04, the new SVC (Scalable Video Coder) approach is still not
  38. // mature enough to be implemented as part of this work.
  39. // See: https://w3c.github.io/webrtc-svc/ for more details.
  40. struct RidDescription final {
  41. RidDescription();
  42. RidDescription(const std::string& rid, RidDirection direction);
  43. RidDescription(const RidDescription& other);
  44. ~RidDescription();
  45. RidDescription& operator=(const RidDescription& other);
  46. // This is currently required for unit tests of StreamParams which contains
  47. // RidDescription objects and checks for equality using operator==.
  48. bool operator==(const RidDescription& other) const;
  49. bool operator!=(const RidDescription& other) const {
  50. return !(*this == other);
  51. }
  52. // The RID identifier that uniquely identifies the stream within the session.
  53. std::string rid;
  54. // Specifies the direction for which the specified restrictions hold.
  55. // This direction is either send or receive and is independent of the
  56. // direction of the transceiver.
  57. // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-4 :
  58. // The "direction" field identifies the direction of the RTP Stream
  59. // packets to which the indicated restrictions are applied. It may be
  60. // either "send" or "recv". Note that these restriction directions are
  61. // expressed independently of any "inactive", "sendonly", "recvonly", or
  62. // "sendrecv" attributes associated with the media section. It is, for
  63. // example, valid to indicate "recv" restrictions on a "sendonly"
  64. // stream; those restrictions would apply if, at a future point in time,
  65. // the stream were changed to "sendrecv" or "recvonly".
  66. RidDirection direction;
  67. // The list of codec payload types for this stream.
  68. // It should be a subset of the payloads supported for the media section.
  69. std::vector<int> payload_types;
  70. // Contains key-value pairs for restrictions.
  71. // The keys are not validated against a known set.
  72. // The meaning to infer for the values depends on each key.
  73. // Examples:
  74. // 1. An entry for max-width will have a value that is interpreted as an int.
  75. // 2. An entry for max-bpp (bits per pixel) will have a float value.
  76. // Interpretation (and validation of value) is left for the implementation.
  77. // I.E. the media engines should validate values for parameters they support.
  78. std::map<std::string, std::string> restrictions;
  79. };
  80. } // namespace cricket
  81. #endif // MEDIA_BASE_RID_DESCRIPTION_H_