skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef API_RTP_PARAMETERS_H_ |
| 12 | #define API_RTP_PARAMETERS_H_ |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame^] | 15 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 16 | #include <string> |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 17 | #include <unordered_map> |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 18 | #include <vector> |
| 19 | |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "api/media_types.h" |
Mirko Bonadei | ac19414 | 2018-10-22 17:08:37 +0200 | [diff] [blame] | 22 | #include "rtc_base/system/rtc_export.h" |
sakal | 1fd9595 | 2016-06-22 00:46:15 -0700 | [diff] [blame] | 23 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 24 | namespace webrtc { |
| 25 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 26 | // These structures are intended to mirror those defined by: |
| 27 | // http://draft.ortc.org/#rtcrtpdictionaries* |
| 28 | // Contains everything specified as of 2017 Jan 24. |
| 29 | // |
| 30 | // They are used when retrieving or modifying the parameters of an |
| 31 | // RtpSender/RtpReceiver, or retrieving capabilities. |
| 32 | // |
| 33 | // Note on conventions: Where ORTC may use "octet", "short" and "unsigned" |
| 34 | // types, we typically use "int", in keeping with our style guidelines. The |
| 35 | // parameter's actual valid range will be enforced when the parameters are set, |
| 36 | // rather than when the parameters struct is built. An exception is made for |
| 37 | // SSRCs, since they use the full unsigned 32-bit range, and aren't expected to |
| 38 | // be used for any numeric comparisons/operations. |
| 39 | // |
| 40 | // Additionally, where ORTC uses strings, we may use enums for things that have |
| 41 | // a fixed number of supported values. However, for things that can be extended |
| 42 | // (such as codecs, by providing an external encoder factory), a string |
| 43 | // identifier is used. |
| 44 | |
| 45 | enum class FecMechanism { |
| 46 | RED, |
| 47 | RED_AND_ULPFEC, |
| 48 | FLEXFEC, |
| 49 | }; |
| 50 | |
| 51 | // Used in RtcpFeedback struct. |
| 52 | enum class RtcpFeedbackType { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 53 | CCM, |
Elad Alon | fadb181 | 2019-05-24 13:40:02 +0200 | [diff] [blame] | 54 | LNTF, // "goog-lntf" |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 55 | NACK, |
| 56 | REMB, // "goog-remb" |
| 57 | TRANSPORT_CC, |
| 58 | }; |
| 59 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 60 | // Used in RtcpFeedback struct when type is NACK or CCM. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 61 | enum class RtcpFeedbackMessageType { |
| 62 | // Equivalent to {type: "nack", parameter: undefined} in ORTC. |
| 63 | GENERIC_NACK, |
| 64 | PLI, // Usable with NACK. |
| 65 | FIR, // Usable with CCM. |
| 66 | }; |
| 67 | |
| 68 | enum class DtxStatus { |
| 69 | DISABLED, |
| 70 | ENABLED, |
| 71 | }; |
| 72 | |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 73 | // Based on the spec in |
| 74 | // https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference. |
| 75 | // These options are enforced on a best-effort basis. For instance, all of |
| 76 | // these options may suffer some frame drops in order to avoid queuing. |
| 77 | // TODO(sprang): Look into possibility of more strictly enforcing the |
| 78 | // maintain-framerate option. |
| 79 | // TODO(deadbeef): Default to "balanced", as the spec indicates? |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 80 | enum class DegradationPreference { |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 81 | // Don't take any actions based on over-utilization signals. Not part of the |
| 82 | // web API. |
| 83 | DISABLED, |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 84 | // On over-use, request lower resolution, possibly causing down-scaling. |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 85 | MAINTAIN_FRAMERATE, |
| 86 | // On over-use, request lower frame rate, possibly causing frame drops. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 87 | MAINTAIN_RESOLUTION, |
Taylor Brandstetter | 49fcc10 | 2018-05-16 14:20:41 -0700 | [diff] [blame] | 88 | // Try to strike a "pleasing" balance between frame rate or resolution. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 89 | BALANCED, |
| 90 | }; |
| 91 | |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 92 | RTC_EXPORT extern const double kDefaultBitratePriority; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 93 | |
| 94 | struct RtcpFeedback { |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 95 | RtcpFeedbackType type = RtcpFeedbackType::CCM; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 96 | |
| 97 | // Equivalent to ORTC "parameter" field with slight differences: |
| 98 | // 1. It's an enum instead of a string. |
| 99 | // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, |
| 100 | // rather than an unset "parameter" value. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 101 | absl::optional<RtcpFeedbackMessageType> message_type; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 102 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 103 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 104 | RtcpFeedback(); |
| 105 | explicit RtcpFeedback(RtcpFeedbackType type); |
| 106 | RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 107 | RtcpFeedback(const RtcpFeedback&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 108 | ~RtcpFeedback(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 109 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 110 | bool operator==(const RtcpFeedback& o) const { |
| 111 | return type == o.type && message_type == o.message_type; |
| 112 | } |
| 113 | bool operator!=(const RtcpFeedback& o) const { return !(*this == o); } |
| 114 | }; |
| 115 | |
| 116 | // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to |
| 117 | // RtpParameters. This represents the static capabilities of an endpoint's |
| 118 | // implementation of a codec. |
| 119 | struct RtpCodecCapability { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 120 | RtpCodecCapability(); |
| 121 | ~RtpCodecCapability(); |
| 122 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 123 | // Build MIME "type/subtype" string from |name| and |kind|. |
| 124 | std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
| 125 | |
| 126 | // Used to identify the codec. Equivalent to MIME subtype. |
| 127 | std::string name; |
| 128 | |
| 129 | // The media type of this codec. Equivalent to MIME top-level type. |
| 130 | cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
| 131 | |
| 132 | // Clock rate in Hertz. If unset, the codec is applicable to any clock rate. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 133 | absl::optional<int> clock_rate; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 134 | |
| 135 | // Default payload type for this codec. Mainly needed for codecs that use |
| 136 | // that have statically assigned payload types. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 137 | absl::optional<int> preferred_payload_type; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 138 | |
| 139 | // Maximum packetization time supported by an RtpReceiver for this codec. |
| 140 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 141 | absl::optional<int> max_ptime; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 142 | |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 143 | // Preferred packetization time for an RtpReceiver or RtpSender of this codec. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 144 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 145 | absl::optional<int> ptime; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 146 | |
| 147 | // The number of audio channels supported. Unused for video codecs. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 148 | absl::optional<int> num_channels; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 149 | |
| 150 | // Feedback mechanisms supported for this codec. |
| 151 | std::vector<RtcpFeedback> rtcp_feedback; |
| 152 | |
| 153 | // Codec-specific parameters that must be signaled to the remote party. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 154 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 155 | // Corresponds to "a=fmtp" parameters in SDP. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 156 | // |
| 157 | // Contrary to ORTC, these parameters are named using all lowercase strings. |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 158 | // This helps make the mapping to SDP simpler, if an application is using SDP. |
| 159 | // Boolean values are represented by the string "1". |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 160 | std::unordered_map<std::string, std::string> parameters; |
| 161 | |
| 162 | // Codec-specific parameters that may optionally be signaled to the remote |
| 163 | // party. |
| 164 | // TODO(deadbeef): Not implemented. |
| 165 | std::unordered_map<std::string, std::string> options; |
| 166 | |
| 167 | // Maximum number of temporal layer extensions supported by this codec. |
| 168 | // For example, a value of 1 indicates that 2 total layers are supported. |
| 169 | // TODO(deadbeef): Not implemented. |
| 170 | int max_temporal_layer_extensions = 0; |
| 171 | |
| 172 | // Maximum number of spatial layer extensions supported by this codec. |
| 173 | // For example, a value of 1 indicates that 2 total layers are supported. |
| 174 | // TODO(deadbeef): Not implemented. |
| 175 | int max_spatial_layer_extensions = 0; |
| 176 | |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 177 | // Whether the implementation can send/receive SVC layers with distinct SSRCs. |
| 178 | // Always false for audio codecs. True for video codecs that support scalable |
| 179 | // video coding with MRST. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 180 | // TODO(deadbeef): Not implemented. |
| 181 | bool svc_multi_stream_support = false; |
| 182 | |
| 183 | bool operator==(const RtpCodecCapability& o) const { |
| 184 | return name == o.name && kind == o.kind && clock_rate == o.clock_rate && |
| 185 | preferred_payload_type == o.preferred_payload_type && |
| 186 | max_ptime == o.max_ptime && ptime == o.ptime && |
| 187 | num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback && |
| 188 | parameters == o.parameters && options == o.options && |
| 189 | max_temporal_layer_extensions == o.max_temporal_layer_extensions && |
| 190 | max_spatial_layer_extensions == o.max_spatial_layer_extensions && |
| 191 | svc_multi_stream_support == o.svc_multi_stream_support; |
| 192 | } |
| 193 | bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); } |
| 194 | }; |
| 195 | |
| 196 | // Used in RtpCapabilities; represents the capabilities/preferences of an |
| 197 | // implementation for a header extension. |
| 198 | // |
| 199 | // Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was |
| 200 | // added here for consistency and to avoid confusion with |
| 201 | // RtpHeaderExtensionParameters. |
| 202 | // |
| 203 | // Note that ORTC includes a "kind" field, but we omit this because it's |
| 204 | // redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)", |
| 205 | // you know you're getting audio capabilities. |
| 206 | struct RtpHeaderExtensionCapability { |
Johannes Kron | 07ba2b9 | 2018-09-26 13:33:35 +0200 | [diff] [blame] | 207 | // URI of this extension, as defined in RFC8285. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 208 | std::string uri; |
| 209 | |
| 210 | // Preferred value of ID that goes in the packet. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 211 | absl::optional<int> preferred_id; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 212 | |
| 213 | // If true, it's preferred that the value in the header is encrypted. |
| 214 | // TODO(deadbeef): Not implemented. |
| 215 | bool preferred_encrypt = false; |
| 216 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 217 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 218 | RtpHeaderExtensionCapability(); |
| 219 | explicit RtpHeaderExtensionCapability(const std::string& uri); |
| 220 | RtpHeaderExtensionCapability(const std::string& uri, int preferred_id); |
| 221 | ~RtpHeaderExtensionCapability(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 222 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 223 | bool operator==(const RtpHeaderExtensionCapability& o) const { |
| 224 | return uri == o.uri && preferred_id == o.preferred_id && |
| 225 | preferred_encrypt == o.preferred_encrypt; |
| 226 | } |
| 227 | bool operator!=(const RtpHeaderExtensionCapability& o) const { |
| 228 | return !(*this == o); |
| 229 | } |
| 230 | }; |
| 231 | |
Johannes Kron | 07ba2b9 | 2018-09-26 13:33:35 +0200 | [diff] [blame] | 232 | // RTP header extension, see RFC8285. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 233 | struct RtpExtension { |
| 234 | RtpExtension(); |
| 235 | RtpExtension(const std::string& uri, int id); |
| 236 | RtpExtension(const std::string& uri, int id, bool encrypt); |
| 237 | ~RtpExtension(); |
| 238 | std::string ToString() const; |
| 239 | bool operator==(const RtpExtension& rhs) const { |
| 240 | return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt; |
| 241 | } |
| 242 | static bool IsSupportedForAudio(const std::string& uri); |
| 243 | static bool IsSupportedForVideo(const std::string& uri); |
| 244 | // Return "true" if the given RTP header extension URI may be encrypted. |
| 245 | static bool IsEncryptionSupported(const std::string& uri); |
| 246 | |
| 247 | // Returns the named header extension if found among all extensions, |
| 248 | // nullptr otherwise. |
| 249 | static const RtpExtension* FindHeaderExtensionByUri( |
| 250 | const std::vector<RtpExtension>& extensions, |
| 251 | const std::string& uri); |
| 252 | |
| 253 | // Return a list of RTP header extensions with the non-encrypted extensions |
| 254 | // removed if both the encrypted and non-encrypted extension is present for |
| 255 | // the same URI. |
| 256 | static std::vector<RtpExtension> FilterDuplicateNonEncrypted( |
| 257 | const std::vector<RtpExtension>& extensions); |
| 258 | |
| 259 | // Header extension for audio levels, as defined in: |
| 260 | // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03 |
| 261 | static const char kAudioLevelUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 262 | |
| 263 | // Header extension for RTP timestamp offset, see RFC 5450 for details: |
| 264 | // http://tools.ietf.org/html/rfc5450 |
| 265 | static const char kTimestampOffsetUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 266 | |
| 267 | // Header extension for absolute send time, see url for details: |
| 268 | // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time |
| 269 | static const char kAbsSendTimeUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 270 | |
Chen Xing | cd8a6e2 | 2019-07-01 10:56:51 +0200 | [diff] [blame] | 271 | // Header extension for absolute capture time, see url for details: |
| 272 | // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time |
| 273 | static const char kAbsoluteCaptureTimeUri[]; |
| 274 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 275 | // Header extension for coordination of video orientation, see url for |
| 276 | // details: |
| 277 | // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf |
| 278 | static const char kVideoRotationUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 279 | |
| 280 | // Header extension for video content type. E.g. default or screenshare. |
| 281 | static const char kVideoContentTypeUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 282 | |
| 283 | // Header extension for video timing. |
| 284 | static const char kVideoTimingUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 285 | |
Johnny Lee | e0c8b23 | 2018-09-11 16:50:49 -0400 | [diff] [blame] | 286 | // Header extension for video frame marking. |
| 287 | static const char kFrameMarkingUri[]; |
Johnny Lee | e0c8b23 | 2018-09-11 16:50:49 -0400 | [diff] [blame] | 288 | |
Danil Chapovalov | f3119ef | 2018-09-25 12:20:37 +0200 | [diff] [blame] | 289 | // Experimental codec agnostic frame descriptor. |
Elad Alon | ccb9b75 | 2019-02-19 13:01:31 +0100 | [diff] [blame] | 290 | static const char kGenericFrameDescriptorUri00[]; |
| 291 | static const char kGenericFrameDescriptorUri01[]; |
| 292 | // TODO(bugs.webrtc.org/10243): Remove once dependencies have been updated. |
Danil Chapovalov | f3119ef | 2018-09-25 12:20:37 +0200 | [diff] [blame] | 293 | static const char kGenericFrameDescriptorUri[]; |
Danil Chapovalov | f3119ef | 2018-09-25 12:20:37 +0200 | [diff] [blame] | 294 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 295 | // Header extension for transport sequence number, see url for details: |
| 296 | // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions |
| 297 | static const char kTransportSequenceNumberUri[]; |
Johannes Kron | 7ff164e | 2019-02-07 12:50:18 +0100 | [diff] [blame] | 298 | static const char kTransportSequenceNumberV2Uri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 299 | |
| 300 | static const char kPlayoutDelayUri[]; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 301 | |
Steve Anton | bb50ce5 | 2018-03-26 10:24:32 -0700 | [diff] [blame] | 302 | // Header extension for identifying media section within a transport. |
| 303 | // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-49#section-15 |
| 304 | static const char kMidUri[]; |
Steve Anton | bb50ce5 | 2018-03-26 10:24:32 -0700 | [diff] [blame] | 305 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 306 | // Encryption of Header Extensions, see RFC 6904 for details: |
| 307 | // https://tools.ietf.org/html/rfc6904 |
| 308 | static const char kEncryptHeaderExtensionsUri[]; |
| 309 | |
Johannes Kron | d0b69a8 | 2018-12-03 14:18:53 +0100 | [diff] [blame] | 310 | // Header extension for color space information. |
| 311 | static const char kColorSpaceUri[]; |
Johannes Kron | d0b69a8 | 2018-12-03 14:18:53 +0100 | [diff] [blame] | 312 | |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 313 | // Header extension for RIDs and Repaired RIDs |
| 314 | // https://tools.ietf.org/html/draft-ietf-avtext-rid-09 |
| 315 | // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15 |
| 316 | static const char kRidUri[]; |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 317 | static const char kRepairedRidUri[]; |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 318 | |
Johannes Kron | 07ba2b9 | 2018-09-26 13:33:35 +0200 | [diff] [blame] | 319 | // Inclusive min and max IDs for two-byte header extensions and one-byte |
| 320 | // header extensions, per RFC8285 Section 4.2-4.3. |
| 321 | static constexpr int kMinId = 1; |
| 322 | static constexpr int kMaxId = 255; |
Johannes Kron | 78cdde3 | 2018-10-05 10:00:46 +0200 | [diff] [blame] | 323 | static constexpr int kMaxValueSize = 255; |
Johannes Kron | 07ba2b9 | 2018-09-26 13:33:35 +0200 | [diff] [blame] | 324 | static constexpr int kOneByteHeaderExtensionMaxId = 14; |
Johannes Kron | 78cdde3 | 2018-10-05 10:00:46 +0200 | [diff] [blame] | 325 | static constexpr int kOneByteHeaderExtensionMaxValueSize = 16; |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 326 | |
| 327 | std::string uri; |
| 328 | int id = 0; |
| 329 | bool encrypt = false; |
| 330 | }; |
| 331 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 332 | // TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented. |
| 333 | typedef RtpExtension RtpHeaderExtensionParameters; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 334 | |
| 335 | struct RtpFecParameters { |
| 336 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 337 | // Works just like RtpEncodingParameters::ssrc. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 338 | absl::optional<uint32_t> ssrc; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 339 | |
| 340 | FecMechanism mechanism = FecMechanism::RED; |
| 341 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 342 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 343 | RtpFecParameters(); |
| 344 | explicit RtpFecParameters(FecMechanism mechanism); |
| 345 | RtpFecParameters(FecMechanism mechanism, uint32_t ssrc); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 346 | RtpFecParameters(const RtpFecParameters&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 347 | ~RtpFecParameters(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 348 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 349 | bool operator==(const RtpFecParameters& o) const { |
| 350 | return ssrc == o.ssrc && mechanism == o.mechanism; |
| 351 | } |
| 352 | bool operator!=(const RtpFecParameters& o) const { return !(*this == o); } |
| 353 | }; |
| 354 | |
| 355 | struct RtpRtxParameters { |
| 356 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 357 | // Works just like RtpEncodingParameters::ssrc. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 358 | absl::optional<uint32_t> ssrc; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 359 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 360 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 361 | RtpRtxParameters(); |
| 362 | explicit RtpRtxParameters(uint32_t ssrc); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 363 | RtpRtxParameters(const RtpRtxParameters&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 364 | ~RtpRtxParameters(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 365 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 366 | bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } |
| 367 | bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } |
| 368 | }; |
| 369 | |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 370 | struct RTC_EXPORT RtpEncodingParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 371 | RtpEncodingParameters(); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 372 | RtpEncodingParameters(const RtpEncodingParameters&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 373 | ~RtpEncodingParameters(); |
| 374 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 375 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 376 | // |
| 377 | // Note that the chosen value is NOT returned by GetParameters, because it |
| 378 | // may change due to an SSRC conflict, in which case the conflict is handled |
| 379 | // internally without any event. Another way of looking at this is that an |
| 380 | // unset SSRC acts as a "wildcard" SSRC. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 381 | absl::optional<uint32_t> ssrc; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 382 | |
Henrik Grunell | e1301a8 | 2018-12-13 12:13:22 +0000 | [diff] [blame] | 383 | // Can be used to reference a codec in the |codecs| member of the |
| 384 | // RtpParameters that contains this RtpEncodingParameters. If unset, the |
| 385 | // implementation will choose the first possible codec (if a sender), or |
| 386 | // prepare to receive any codec (for a receiver). |
| 387 | // TODO(deadbeef): Not implemented. Implementation of RtpSender will always |
| 388 | // choose the first codec from the list. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 389 | absl::optional<int> codec_payload_type; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 390 | |
| 391 | // Specifies the FEC mechanism, if set. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 392 | // TODO(deadbeef): Not implemented. Current implementation will use whatever |
| 393 | // FEC codecs are available, including red+ulpfec. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 394 | absl::optional<RtpFecParameters> fec; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 395 | |
| 396 | // Specifies the RTX parameters, if set. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 397 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 398 | absl::optional<RtpRtxParameters> rtx; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 399 | |
| 400 | // Only used for audio. If set, determines whether or not discontinuous |
| 401 | // transmission will be used, if an available codec supports it. If not |
| 402 | // set, the implementation default setting will be used. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 403 | // TODO(deadbeef): Not implemented. Current implementation will use a CN |
| 404 | // codec as long as it's present. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 405 | absl::optional<DtxStatus> dtx; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 406 | |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 407 | // The relative bitrate priority of this encoding. Currently this is |
Seth Hampson | a881ac0 | 2018-02-12 14:14:39 -0800 | [diff] [blame] | 408 | // implemented for the entire rtp sender by using the value of the first |
| 409 | // encoding parameter. |
| 410 | // TODO(webrtc.bugs.org/8630): Implement this per encoding parameter. |
| 411 | // Currently there is logic for how bitrate is distributed per simulcast layer |
| 412 | // in the VideoBitrateAllocator. This must be updated to incorporate relative |
| 413 | // bitrate priority. |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 414 | double bitrate_priority = kDefaultBitratePriority; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 415 | |
Tim Haloun | 648d28a | 2018-10-18 16:52:22 -0700 | [diff] [blame] | 416 | // The relative DiffServ Code Point priority for this encoding, allowing |
| 417 | // packets to be marked relatively higher or lower without affecting |
| 418 | // bandwidth allocations. See https://w3c.github.io/webrtc-dscp-exp/ . NB |
| 419 | // we follow chromium's translation of the allowed string enum values for |
| 420 | // this field to 1.0, 0.5, et cetera, similar to bitrate_priority above. |
| 421 | // TODO(http://crbug.com/webrtc/8630): Implement this per encoding parameter. |
| 422 | double network_priority = kDefaultBitratePriority; |
| 423 | |
Seth Hampson | f209cb5 | 2018-02-06 14:28:16 -0800 | [diff] [blame] | 424 | // Indicates the preferred duration of media represented by a packet in |
| 425 | // milliseconds for this encoding. If set, this will take precedence over the |
| 426 | // ptime set in the RtpCodecParameters. This could happen if SDP negotiation |
| 427 | // creates a ptime for a specific codec, which is later changed in the |
| 428 | // RtpEncodingParameters by the application. |
| 429 | // TODO(bugs.webrtc.org/8819): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 430 | absl::optional<int> ptime; |
Seth Hampson | f209cb5 | 2018-02-06 14:28:16 -0800 | [diff] [blame] | 431 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 432 | // If set, this represents the Transport Independent Application Specific |
| 433 | // maximum bandwidth defined in RFC3890. If unset, there is no maximum |
Seth Hampson | a881ac0 | 2018-02-12 14:14:39 -0800 | [diff] [blame] | 434 | // bitrate. Currently this is implemented for the entire rtp sender by using |
| 435 | // the value of the first encoding parameter. |
| 436 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 437 | // Just called "maxBitrate" in ORTC spec. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 438 | // |
| 439 | // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total |
| 440 | // bandwidth for the entire bandwidth estimator (audio and video). This is |
| 441 | // just always how "b=AS" was handled, but it's not correct and should be |
| 442 | // fixed. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 443 | absl::optional<int> max_bitrate_bps; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 444 | |
Åsa Persson | 5565981 | 2018-06-18 17:51:32 +0200 | [diff] [blame] | 445 | // Specifies the minimum bitrate in bps for video. |
| 446 | // TODO(asapersson): Not implemented for ORTC API. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 447 | absl::optional<int> min_bitrate_bps; |
Åsa Persson | 613591a | 2018-05-29 09:21:31 +0200 | [diff] [blame] | 448 | |
Åsa Persson | 8c1bf95 | 2018-09-13 10:42:19 +0200 | [diff] [blame] | 449 | // Specifies the maximum framerate in fps for video. |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 450 | // TODO(asapersson): Different framerates are not supported per simulcast |
| 451 | // layer. If set, the maximum |max_framerate| is currently used. |
Åsa Persson | 8c1bf95 | 2018-09-13 10:42:19 +0200 | [diff] [blame] | 452 | // Not supported for screencast. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 453 | absl::optional<int> max_framerate; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 454 | |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 455 | // Specifies the number of temporal layers for video (if the feature is |
| 456 | // supported by the codec implementation). |
| 457 | // TODO(asapersson): Different number of temporal layers are not supported |
| 458 | // per simulcast layer. |
Ilya Nikolaevskiy | 9f6a0d5 | 2019-02-05 10:29:41 +0100 | [diff] [blame] | 459 | // Screencast support is experimental. |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 460 | absl::optional<int> num_temporal_layers; |
| 461 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 462 | // For video, scale the resolution down by this factor. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 463 | absl::optional<double> scale_resolution_down_by; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 464 | |
| 465 | // Scale the framerate down by this factor. |
| 466 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 467 | absl::optional<double> scale_framerate_down_by; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 468 | |
Seth Hampson | a881ac0 | 2018-02-12 14:14:39 -0800 | [diff] [blame] | 469 | // For an RtpSender, set to true to cause this encoding to be encoded and |
| 470 | // sent, and false for it not to be encoded and sent. This allows control |
| 471 | // across multiple encodings of a sender for turning simulcast layers on and |
| 472 | // off. |
| 473 | // TODO(webrtc.bugs.org/8807): Updating this parameter will trigger an encoder |
| 474 | // reset, but this isn't necessarily required. |
deadbeef | dbe2b87 | 2016-03-22 15:42:00 -0700 | [diff] [blame] | 475 | bool active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 476 | |
| 477 | // Value to use for RID RTP header extension. |
| 478 | // Called "encodingId" in ORTC. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 479 | std::string rid; |
| 480 | |
| 481 | // RIDs of encodings on which this layer depends. |
| 482 | // Called "dependencyEncodingIds" in ORTC spec. |
| 483 | // TODO(deadbeef): Not implemented. |
| 484 | std::vector<std::string> dependency_rids; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 485 | |
| 486 | bool operator==(const RtpEncodingParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 487 | return ssrc == o.ssrc && codec_payload_type == o.codec_payload_type && |
| 488 | fec == o.fec && rtx == o.rtx && dtx == o.dtx && |
Tim Haloun | 648d28a | 2018-10-18 16:52:22 -0700 | [diff] [blame] | 489 | bitrate_priority == o.bitrate_priority && |
| 490 | network_priority == o.network_priority && ptime == o.ptime && |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 491 | max_bitrate_bps == o.max_bitrate_bps && |
Åsa Persson | 8c1bf95 | 2018-09-13 10:42:19 +0200 | [diff] [blame] | 492 | min_bitrate_bps == o.min_bitrate_bps && |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 493 | max_framerate == o.max_framerate && |
Åsa Persson | 23eba22 | 2018-10-02 14:47:06 +0200 | [diff] [blame] | 494 | num_temporal_layers == o.num_temporal_layers && |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 495 | scale_resolution_down_by == o.scale_resolution_down_by && |
| 496 | scale_framerate_down_by == o.scale_framerate_down_by && |
| 497 | active == o.active && rid == o.rid && |
| 498 | dependency_rids == o.dependency_rids; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 499 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 500 | bool operator!=(const RtpEncodingParameters& o) const { |
| 501 | return !(*this == o); |
| 502 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 503 | }; |
| 504 | |
| 505 | struct RtpCodecParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 506 | RtpCodecParameters(); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 507 | RtpCodecParameters(const RtpCodecParameters&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 508 | ~RtpCodecParameters(); |
| 509 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 510 | // Build MIME "type/subtype" string from |name| and |kind|. |
| 511 | std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
| 512 | |
| 513 | // Used to identify the codec. Equivalent to MIME subtype. |
| 514 | std::string name; |
| 515 | |
| 516 | // The media type of this codec. Equivalent to MIME top-level type. |
| 517 | cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
| 518 | |
| 519 | // Payload type used to identify this codec in RTP packets. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 520 | // This must always be present, and must be unique across all codecs using |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 521 | // the same transport. |
| 522 | int payload_type = 0; |
| 523 | |
| 524 | // If unset, the implementation default is used. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 525 | absl::optional<int> clock_rate; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 526 | |
| 527 | // The number of audio channels used. Unset for video codecs. If unset for |
| 528 | // audio, the implementation default is used. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 529 | // TODO(deadbeef): The "implementation default" part isn't fully implemented. |
| 530 | // Only defaults to 1, even though some codecs (such as opus) should really |
| 531 | // default to 2. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 532 | absl::optional<int> num_channels; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 533 | |
| 534 | // The maximum packetization time to be used by an RtpSender. |
| 535 | // If |ptime| is also set, this will be ignored. |
| 536 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 537 | absl::optional<int> max_ptime; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 538 | |
| 539 | // The packetization time to be used by an RtpSender. |
| 540 | // If unset, will use any time up to max_ptime. |
| 541 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 542 | absl::optional<int> ptime; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 543 | |
| 544 | // Feedback mechanisms to be used for this codec. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 545 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 546 | std::vector<RtcpFeedback> rtcp_feedback; |
| 547 | |
| 548 | // Codec-specific parameters that must be signaled to the remote party. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 549 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 550 | // Corresponds to "a=fmtp" parameters in SDP. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 551 | // |
| 552 | // Contrary to ORTC, these parameters are named using all lowercase strings. |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 553 | // This helps make the mapping to SDP simpler, if an application is using SDP. |
| 554 | // Boolean values are represented by the string "1". |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 555 | std::unordered_map<std::string, std::string> parameters; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 556 | |
| 557 | bool operator==(const RtpCodecParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 558 | return name == o.name && kind == o.kind && payload_type == o.payload_type && |
| 559 | clock_rate == o.clock_rate && num_channels == o.num_channels && |
| 560 | max_ptime == o.max_ptime && ptime == o.ptime && |
| 561 | rtcp_feedback == o.rtcp_feedback && parameters == o.parameters; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 562 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 563 | bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); } |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 564 | }; |
| 565 | |
Åsa Persson | 90bc1e1 | 2019-05-31 13:29:35 +0200 | [diff] [blame] | 566 | // RtpCapabilities is used to represent the static capabilities of an endpoint. |
| 567 | // An application can use these capabilities to construct an RtpParameters. |
Mirko Bonadei | 66e7679 | 2019-04-02 11:33:59 +0200 | [diff] [blame] | 568 | struct RTC_EXPORT RtpCapabilities { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 569 | RtpCapabilities(); |
| 570 | ~RtpCapabilities(); |
| 571 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 572 | // Supported codecs. |
| 573 | std::vector<RtpCodecCapability> codecs; |
| 574 | |
| 575 | // Supported RTP header extensions. |
| 576 | std::vector<RtpHeaderExtensionCapability> header_extensions; |
| 577 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 578 | // Supported Forward Error Correction (FEC) mechanisms. Note that the RED, |
| 579 | // ulpfec and flexfec codecs used by these mechanisms will still appear in |
| 580 | // |codecs|. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 581 | std::vector<FecMechanism> fec; |
| 582 | |
| 583 | bool operator==(const RtpCapabilities& o) const { |
| 584 | return codecs == o.codecs && header_extensions == o.header_extensions && |
| 585 | fec == o.fec; |
| 586 | } |
| 587 | bool operator!=(const RtpCapabilities& o) const { return !(*this == o); } |
| 588 | }; |
| 589 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 590 | struct RtcpParameters final { |
| 591 | RtcpParameters(); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 592 | RtcpParameters(const RtcpParameters&); |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 593 | ~RtcpParameters(); |
| 594 | |
| 595 | // The SSRC to be used in the "SSRC of packet sender" field. If not set, one |
| 596 | // will be chosen by the implementation. |
| 597 | // TODO(deadbeef): Not implemented. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 598 | absl::optional<uint32_t> ssrc; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 599 | |
| 600 | // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). |
| 601 | // |
| 602 | // If empty in the construction of the RtpTransport, one will be generated by |
| 603 | // the implementation, and returned in GetRtcpParameters. Multiple |
| 604 | // RtpTransports created by the same OrtcFactory will use the same generated |
| 605 | // CNAME. |
| 606 | // |
| 607 | // If empty when passed into SetParameters, the CNAME simply won't be |
| 608 | // modified. |
| 609 | std::string cname; |
| 610 | |
| 611 | // Send reduced-size RTCP? |
| 612 | bool reduced_size = false; |
| 613 | |
| 614 | // Send RTCP multiplexed on the RTP transport? |
| 615 | // Not used with PeerConnection senders/receivers |
| 616 | bool mux = true; |
| 617 | |
| 618 | bool operator==(const RtcpParameters& o) const { |
| 619 | return ssrc == o.ssrc && cname == o.cname && |
| 620 | reduced_size == o.reduced_size && mux == o.mux; |
| 621 | } |
| 622 | bool operator!=(const RtcpParameters& o) const { return !(*this == o); } |
| 623 | }; |
| 624 | |
Mirko Bonadei | ac19414 | 2018-10-22 17:08:37 +0200 | [diff] [blame] | 625 | struct RTC_EXPORT RtpParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 626 | RtpParameters(); |
Mirko Bonadei | 2ffed6d | 2018-07-20 11:09:32 +0200 | [diff] [blame] | 627 | RtpParameters(const RtpParameters&); |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 628 | ~RtpParameters(); |
| 629 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 630 | // Used when calling getParameters/setParameters with a PeerConnection |
| 631 | // RtpSender, to ensure that outdated parameters are not unintentionally |
| 632 | // applied successfully. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 633 | std::string transaction_id; |
| 634 | |
| 635 | // Value to use for MID RTP header extension. |
| 636 | // Called "muxId" in ORTC. |
| 637 | // TODO(deadbeef): Not implemented. |
| 638 | std::string mid; |
| 639 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 640 | std::vector<RtpCodecParameters> codecs; |
| 641 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 642 | std::vector<RtpHeaderExtensionParameters> header_extensions; |
| 643 | |
| 644 | std::vector<RtpEncodingParameters> encodings; |
| 645 | |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 646 | // Only available with a Peerconnection RtpSender. |
| 647 | // In ORTC, our API includes an additional "RtpTransport" |
| 648 | // abstraction on which RTCP parameters are set. |
| 649 | RtcpParameters rtcp; |
| 650 | |
Florent Castelli | 87b3c51 | 2018-07-18 16:00:28 +0200 | [diff] [blame] | 651 | // When bandwidth is constrained and the RtpSender needs to choose between |
| 652 | // degrading resolution or degrading framerate, degradationPreference |
| 653 | // indicates which is preferred. Only for video tracks. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 654 | DegradationPreference degradation_preference = |
| 655 | DegradationPreference::BALANCED; |
| 656 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 657 | bool operator==(const RtpParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 658 | return mid == o.mid && codecs == o.codecs && |
| 659 | header_extensions == o.header_extensions && |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 660 | encodings == o.encodings && rtcp == o.rtcp && |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 661 | degradation_preference == o.degradation_preference; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 662 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 663 | bool operator!=(const RtpParameters& o) const { return !(*this == o); } |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 664 | }; |
| 665 | |
| 666 | } // namespace webrtc |
| 667 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 668 | #endif // API_RTP_PARAMETERS_H_ |