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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef API_RTPPARAMETERS_H_ |
| 12 | #define API_RTPPARAMETERS_H_ |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 13 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 14 | #include <string> |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 15 | #include <unordered_map> |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "api/mediatypes.h" |
| 19 | #include "api/optional.h" |
sakal | 1fd9595 | 2016-06-22 00:46:15 -0700 | [diff] [blame] | 20 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 21 | namespace webrtc { |
| 22 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 23 | // These structures are intended to mirror those defined by: |
| 24 | // http://draft.ortc.org/#rtcrtpdictionaries* |
| 25 | // Contains everything specified as of 2017 Jan 24. |
| 26 | // |
| 27 | // They are used when retrieving or modifying the parameters of an |
| 28 | // RtpSender/RtpReceiver, or retrieving capabilities. |
| 29 | // |
| 30 | // Note on conventions: Where ORTC may use "octet", "short" and "unsigned" |
| 31 | // types, we typically use "int", in keeping with our style guidelines. The |
| 32 | // parameter's actual valid range will be enforced when the parameters are set, |
| 33 | // rather than when the parameters struct is built. An exception is made for |
| 34 | // SSRCs, since they use the full unsigned 32-bit range, and aren't expected to |
| 35 | // be used for any numeric comparisons/operations. |
| 36 | // |
| 37 | // Additionally, where ORTC uses strings, we may use enums for things that have |
| 38 | // a fixed number of supported values. However, for things that can be extended |
| 39 | // (such as codecs, by providing an external encoder factory), a string |
| 40 | // identifier is used. |
| 41 | |
| 42 | enum class FecMechanism { |
| 43 | RED, |
| 44 | RED_AND_ULPFEC, |
| 45 | FLEXFEC, |
| 46 | }; |
| 47 | |
| 48 | // Used in RtcpFeedback struct. |
| 49 | enum class RtcpFeedbackType { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 50 | CCM, |
| 51 | NACK, |
| 52 | REMB, // "goog-remb" |
| 53 | TRANSPORT_CC, |
| 54 | }; |
| 55 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 56 | // Used in RtcpFeedback struct when type is NACK or CCM. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 57 | enum class RtcpFeedbackMessageType { |
| 58 | // Equivalent to {type: "nack", parameter: undefined} in ORTC. |
| 59 | GENERIC_NACK, |
| 60 | PLI, // Usable with NACK. |
| 61 | FIR, // Usable with CCM. |
| 62 | }; |
| 63 | |
| 64 | enum class DtxStatus { |
| 65 | DISABLED, |
| 66 | ENABLED, |
| 67 | }; |
| 68 | |
| 69 | enum class DegradationPreference { |
| 70 | MAINTAIN_FRAMERATE, |
| 71 | MAINTAIN_RESOLUTION, |
| 72 | BALANCED, |
| 73 | }; |
| 74 | |
Seth Hampson | f32795e | 2017-12-19 11:37:41 -0800 | [diff] [blame] | 75 | extern const double kDefaultBitratePriority; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 76 | |
| 77 | struct RtcpFeedback { |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 78 | RtcpFeedbackType type = RtcpFeedbackType::CCM; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 79 | |
| 80 | // Equivalent to ORTC "parameter" field with slight differences: |
| 81 | // 1. It's an enum instead of a string. |
| 82 | // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, |
| 83 | // rather than an unset "parameter" value. |
| 84 | rtc::Optional<RtcpFeedbackMessageType> message_type; |
| 85 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 86 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 87 | RtcpFeedback(); |
| 88 | explicit RtcpFeedback(RtcpFeedbackType type); |
| 89 | RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type); |
| 90 | ~RtcpFeedback(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 91 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 92 | bool operator==(const RtcpFeedback& o) const { |
| 93 | return type == o.type && message_type == o.message_type; |
| 94 | } |
| 95 | bool operator!=(const RtcpFeedback& o) const { return !(*this == o); } |
| 96 | }; |
| 97 | |
| 98 | // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to |
| 99 | // RtpParameters. This represents the static capabilities of an endpoint's |
| 100 | // implementation of a codec. |
| 101 | struct RtpCodecCapability { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 102 | RtpCodecCapability(); |
| 103 | ~RtpCodecCapability(); |
| 104 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 105 | // Build MIME "type/subtype" string from |name| and |kind|. |
| 106 | std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
| 107 | |
| 108 | // Used to identify the codec. Equivalent to MIME subtype. |
| 109 | std::string name; |
| 110 | |
| 111 | // The media type of this codec. Equivalent to MIME top-level type. |
| 112 | cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
| 113 | |
| 114 | // Clock rate in Hertz. If unset, the codec is applicable to any clock rate. |
| 115 | rtc::Optional<int> clock_rate; |
| 116 | |
| 117 | // Default payload type for this codec. Mainly needed for codecs that use |
| 118 | // that have statically assigned payload types. |
| 119 | rtc::Optional<int> preferred_payload_type; |
| 120 | |
| 121 | // Maximum packetization time supported by an RtpReceiver for this codec. |
| 122 | // TODO(deadbeef): Not implemented. |
| 123 | rtc::Optional<int> max_ptime; |
| 124 | |
| 125 | // Preferred packetization time for an RtpReceiver or RtpSender of this |
| 126 | // codec. |
| 127 | // TODO(deadbeef): Not implemented. |
| 128 | rtc::Optional<int> ptime; |
| 129 | |
| 130 | // The number of audio channels supported. Unused for video codecs. |
| 131 | rtc::Optional<int> num_channels; |
| 132 | |
| 133 | // Feedback mechanisms supported for this codec. |
| 134 | std::vector<RtcpFeedback> rtcp_feedback; |
| 135 | |
| 136 | // Codec-specific parameters that must be signaled to the remote party. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 137 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 138 | // Corresponds to "a=fmtp" parameters in SDP. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 139 | // |
| 140 | // Contrary to ORTC, these parameters are named using all lowercase strings. |
| 141 | // This helps make the mapping to SDP simpler, if an application is using |
| 142 | // SDP. Boolean values are represented by the string "1". |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 143 | std::unordered_map<std::string, std::string> parameters; |
| 144 | |
| 145 | // Codec-specific parameters that may optionally be signaled to the remote |
| 146 | // party. |
| 147 | // TODO(deadbeef): Not implemented. |
| 148 | std::unordered_map<std::string, std::string> options; |
| 149 | |
| 150 | // Maximum number of temporal layer extensions supported by this codec. |
| 151 | // For example, a value of 1 indicates that 2 total layers are supported. |
| 152 | // TODO(deadbeef): Not implemented. |
| 153 | int max_temporal_layer_extensions = 0; |
| 154 | |
| 155 | // Maximum number of spatial layer extensions supported by this codec. |
| 156 | // For example, a value of 1 indicates that 2 total layers are supported. |
| 157 | // TODO(deadbeef): Not implemented. |
| 158 | int max_spatial_layer_extensions = 0; |
| 159 | |
| 160 | // Whether the implementation can send/receive SVC layers with distinct |
| 161 | // SSRCs. Always false for audio codecs. True for video codecs that support |
| 162 | // scalable video coding with MRST. |
| 163 | // TODO(deadbeef): Not implemented. |
| 164 | bool svc_multi_stream_support = false; |
| 165 | |
| 166 | bool operator==(const RtpCodecCapability& o) const { |
| 167 | return name == o.name && kind == o.kind && clock_rate == o.clock_rate && |
| 168 | preferred_payload_type == o.preferred_payload_type && |
| 169 | max_ptime == o.max_ptime && ptime == o.ptime && |
| 170 | num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback && |
| 171 | parameters == o.parameters && options == o.options && |
| 172 | max_temporal_layer_extensions == o.max_temporal_layer_extensions && |
| 173 | max_spatial_layer_extensions == o.max_spatial_layer_extensions && |
| 174 | svc_multi_stream_support == o.svc_multi_stream_support; |
| 175 | } |
| 176 | bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); } |
| 177 | }; |
| 178 | |
| 179 | // Used in RtpCapabilities; represents the capabilities/preferences of an |
| 180 | // implementation for a header extension. |
| 181 | // |
| 182 | // Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was |
| 183 | // added here for consistency and to avoid confusion with |
| 184 | // RtpHeaderExtensionParameters. |
| 185 | // |
| 186 | // Note that ORTC includes a "kind" field, but we omit this because it's |
| 187 | // redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)", |
| 188 | // you know you're getting audio capabilities. |
| 189 | struct RtpHeaderExtensionCapability { |
| 190 | // URI of this extension, as defined in RFC5285. |
| 191 | std::string uri; |
| 192 | |
| 193 | // Preferred value of ID that goes in the packet. |
| 194 | rtc::Optional<int> preferred_id; |
| 195 | |
| 196 | // If true, it's preferred that the value in the header is encrypted. |
| 197 | // TODO(deadbeef): Not implemented. |
| 198 | bool preferred_encrypt = false; |
| 199 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 200 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 201 | RtpHeaderExtensionCapability(); |
| 202 | explicit RtpHeaderExtensionCapability(const std::string& uri); |
| 203 | RtpHeaderExtensionCapability(const std::string& uri, int preferred_id); |
| 204 | ~RtpHeaderExtensionCapability(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 205 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 206 | bool operator==(const RtpHeaderExtensionCapability& o) const { |
| 207 | return uri == o.uri && preferred_id == o.preferred_id && |
| 208 | preferred_encrypt == o.preferred_encrypt; |
| 209 | } |
| 210 | bool operator!=(const RtpHeaderExtensionCapability& o) const { |
| 211 | return !(*this == o); |
| 212 | } |
| 213 | }; |
| 214 | |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 215 | // RTP header extension, see RFC 5285. |
| 216 | struct RtpExtension { |
| 217 | RtpExtension(); |
| 218 | RtpExtension(const std::string& uri, int id); |
| 219 | RtpExtension(const std::string& uri, int id, bool encrypt); |
| 220 | ~RtpExtension(); |
| 221 | std::string ToString() const; |
| 222 | bool operator==(const RtpExtension& rhs) const { |
| 223 | return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt; |
| 224 | } |
| 225 | static bool IsSupportedForAudio(const std::string& uri); |
| 226 | static bool IsSupportedForVideo(const std::string& uri); |
| 227 | // Return "true" if the given RTP header extension URI may be encrypted. |
| 228 | static bool IsEncryptionSupported(const std::string& uri); |
| 229 | |
| 230 | // Returns the named header extension if found among all extensions, |
| 231 | // nullptr otherwise. |
| 232 | static const RtpExtension* FindHeaderExtensionByUri( |
| 233 | const std::vector<RtpExtension>& extensions, |
| 234 | const std::string& uri); |
| 235 | |
| 236 | // Return a list of RTP header extensions with the non-encrypted extensions |
| 237 | // removed if both the encrypted and non-encrypted extension is present for |
| 238 | // the same URI. |
| 239 | static std::vector<RtpExtension> FilterDuplicateNonEncrypted( |
| 240 | const std::vector<RtpExtension>& extensions); |
| 241 | |
| 242 | // Header extension for audio levels, as defined in: |
| 243 | // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03 |
| 244 | static const char kAudioLevelUri[]; |
| 245 | static const int kAudioLevelDefaultId; |
| 246 | |
| 247 | // Header extension for RTP timestamp offset, see RFC 5450 for details: |
| 248 | // http://tools.ietf.org/html/rfc5450 |
| 249 | static const char kTimestampOffsetUri[]; |
| 250 | static const int kTimestampOffsetDefaultId; |
| 251 | |
| 252 | // Header extension for absolute send time, see url for details: |
| 253 | // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time |
| 254 | static const char kAbsSendTimeUri[]; |
| 255 | static const int kAbsSendTimeDefaultId; |
| 256 | |
| 257 | // Header extension for coordination of video orientation, see url for |
| 258 | // details: |
| 259 | // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf |
| 260 | static const char kVideoRotationUri[]; |
| 261 | static const int kVideoRotationDefaultId; |
| 262 | |
| 263 | // Header extension for video content type. E.g. default or screenshare. |
| 264 | static const char kVideoContentTypeUri[]; |
| 265 | static const int kVideoContentTypeDefaultId; |
| 266 | |
| 267 | // Header extension for video timing. |
| 268 | static const char kVideoTimingUri[]; |
| 269 | static const int kVideoTimingDefaultId; |
| 270 | |
| 271 | // Header extension for transport sequence number, see url for details: |
| 272 | // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions |
| 273 | static const char kTransportSequenceNumberUri[]; |
| 274 | static const int kTransportSequenceNumberDefaultId; |
| 275 | |
| 276 | static const char kPlayoutDelayUri[]; |
| 277 | static const int kPlayoutDelayDefaultId; |
| 278 | |
| 279 | // Encryption of Header Extensions, see RFC 6904 for details: |
| 280 | // https://tools.ietf.org/html/rfc6904 |
| 281 | static const char kEncryptHeaderExtensionsUri[]; |
| 282 | |
| 283 | // Inclusive min and max IDs for one-byte header extensions, per RFC5285. |
| 284 | static const int kMinId; |
| 285 | static const int kMaxId; |
| 286 | |
| 287 | std::string uri; |
| 288 | int id = 0; |
| 289 | bool encrypt = false; |
| 290 | }; |
| 291 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 292 | // TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented. |
| 293 | typedef RtpExtension RtpHeaderExtensionParameters; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 294 | |
| 295 | struct RtpFecParameters { |
| 296 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 297 | // Works just like RtpEncodingParameters::ssrc. |
sakal | 1fd9595 | 2016-06-22 00:46:15 -0700 | [diff] [blame] | 298 | rtc::Optional<uint32_t> ssrc; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 299 | |
| 300 | FecMechanism mechanism = FecMechanism::RED; |
| 301 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 302 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 303 | RtpFecParameters(); |
| 304 | explicit RtpFecParameters(FecMechanism mechanism); |
| 305 | RtpFecParameters(FecMechanism mechanism, uint32_t ssrc); |
| 306 | ~RtpFecParameters(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 307 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 308 | bool operator==(const RtpFecParameters& o) const { |
| 309 | return ssrc == o.ssrc && mechanism == o.mechanism; |
| 310 | } |
| 311 | bool operator!=(const RtpFecParameters& o) const { return !(*this == o); } |
| 312 | }; |
| 313 | |
| 314 | struct RtpRtxParameters { |
| 315 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 316 | // Works just like RtpEncodingParameters::ssrc. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 317 | rtc::Optional<uint32_t> ssrc; |
| 318 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 319 | // Constructors for convenience. |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 320 | RtpRtxParameters(); |
| 321 | explicit RtpRtxParameters(uint32_t ssrc); |
| 322 | ~RtpRtxParameters(); |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 323 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 324 | bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } |
| 325 | bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } |
| 326 | }; |
| 327 | |
| 328 | struct RtpEncodingParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 329 | RtpEncodingParameters(); |
| 330 | ~RtpEncodingParameters(); |
| 331 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 332 | // If unset, a value is chosen by the implementation. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 333 | // |
| 334 | // Note that the chosen value is NOT returned by GetParameters, because it |
| 335 | // may change due to an SSRC conflict, in which case the conflict is handled |
| 336 | // internally without any event. Another way of looking at this is that an |
| 337 | // unset SSRC acts as a "wildcard" SSRC. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 338 | rtc::Optional<uint32_t> ssrc; |
| 339 | |
| 340 | // Can be used to reference a codec in the |codecs| member of the |
| 341 | // RtpParameters that contains this RtpEncodingParameters. If unset, the |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 342 | // implementation will choose the first possible codec (if a sender), or |
| 343 | // prepare to receive any codec (for a receiver). |
| 344 | // TODO(deadbeef): Not implemented. Implementation of RtpSender will always |
| 345 | // choose the first codec from the list. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 346 | rtc::Optional<int> codec_payload_type; |
| 347 | |
| 348 | // Specifies the FEC mechanism, if set. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 349 | // TODO(deadbeef): Not implemented. Current implementation will use whatever |
| 350 | // FEC codecs are available, including red+ulpfec. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 351 | rtc::Optional<RtpFecParameters> fec; |
| 352 | |
| 353 | // Specifies the RTX parameters, if set. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 354 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 355 | rtc::Optional<RtpRtxParameters> rtx; |
| 356 | |
| 357 | // Only used for audio. If set, determines whether or not discontinuous |
| 358 | // transmission will be used, if an available codec supports it. If not |
| 359 | // set, the implementation default setting will be used. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 360 | // TODO(deadbeef): Not implemented. Current implementation will use a CN |
| 361 | // codec as long as it's present. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 362 | rtc::Optional<DtxStatus> dtx; |
| 363 | |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 364 | // The relative bitrate priority of this encoding. Currently this is |
| 365 | // implemented on the sender level (using the first RtpEncodingParameters |
| 366 | // of the rtp parameters). |
| 367 | double bitrate_priority = kDefaultBitratePriority; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 368 | |
| 369 | // If set, this represents the Transport Independent Application Specific |
| 370 | // maximum bandwidth defined in RFC3890. If unset, there is no maximum |
| 371 | // bitrate. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 372 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 373 | // Just called "maxBitrate" in ORTC spec. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 374 | // |
| 375 | // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total |
| 376 | // bandwidth for the entire bandwidth estimator (audio and video). This is |
| 377 | // just always how "b=AS" was handled, but it's not correct and should be |
| 378 | // fixed. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 379 | rtc::Optional<int> max_bitrate_bps; |
| 380 | |
| 381 | // TODO(deadbeef): Not implemented. |
| 382 | rtc::Optional<int> max_framerate; |
| 383 | |
| 384 | // For video, scale the resolution down by this factor. |
| 385 | // TODO(deadbeef): Not implemented. |
| 386 | double scale_resolution_down_by = 1.0; |
| 387 | |
| 388 | // Scale the framerate down by this factor. |
| 389 | // TODO(deadbeef): Not implemented. |
| 390 | double scale_framerate_down_by = 1.0; |
| 391 | |
| 392 | // For an RtpSender, set to true to cause this encoding to be sent, and false |
| 393 | // for it not to be sent. For an RtpReceiver, set to true to cause the |
| 394 | // encoding to be decoded, and false for it to be ignored. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 395 | // TODO(deadbeef): Not implemented for PeerConnection RtpReceivers. |
deadbeef | dbe2b87 | 2016-03-22 15:42:00 -0700 | [diff] [blame] | 396 | bool active = true; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 397 | |
| 398 | // Value to use for RID RTP header extension. |
| 399 | // Called "encodingId" in ORTC. |
| 400 | // TODO(deadbeef): Not implemented. |
| 401 | std::string rid; |
| 402 | |
| 403 | // RIDs of encodings on which this layer depends. |
| 404 | // Called "dependencyEncodingIds" in ORTC spec. |
| 405 | // TODO(deadbeef): Not implemented. |
| 406 | std::vector<std::string> dependency_rids; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 407 | |
| 408 | bool operator==(const RtpEncodingParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 409 | return ssrc == o.ssrc && codec_payload_type == o.codec_payload_type && |
| 410 | fec == o.fec && rtx == o.rtx && dtx == o.dtx && |
Seth Hampson | 24722b3 | 2017-12-22 09:36:42 -0800 | [diff] [blame] | 411 | bitrate_priority == o.bitrate_priority && |
| 412 | max_bitrate_bps == o.max_bitrate_bps && |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 413 | max_framerate == o.max_framerate && |
| 414 | scale_resolution_down_by == o.scale_resolution_down_by && |
| 415 | scale_framerate_down_by == o.scale_framerate_down_by && |
| 416 | active == o.active && rid == o.rid && |
| 417 | dependency_rids == o.dependency_rids; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 418 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 419 | bool operator!=(const RtpEncodingParameters& o) const { |
| 420 | return !(*this == o); |
| 421 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 422 | }; |
| 423 | |
| 424 | struct RtpCodecParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 425 | RtpCodecParameters(); |
| 426 | ~RtpCodecParameters(); |
| 427 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 428 | // Build MIME "type/subtype" string from |name| and |kind|. |
| 429 | std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
| 430 | |
| 431 | // Used to identify the codec. Equivalent to MIME subtype. |
| 432 | std::string name; |
| 433 | |
| 434 | // The media type of this codec. Equivalent to MIME top-level type. |
| 435 | cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
| 436 | |
| 437 | // Payload type used to identify this codec in RTP packets. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 438 | // This must always be present, and must be unique across all codecs using |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 439 | // the same transport. |
| 440 | int payload_type = 0; |
| 441 | |
| 442 | // If unset, the implementation default is used. |
| 443 | rtc::Optional<int> clock_rate; |
| 444 | |
| 445 | // The number of audio channels used. Unset for video codecs. If unset for |
| 446 | // audio, the implementation default is used. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 447 | // TODO(deadbeef): The "implementation default" part isn't fully implemented. |
| 448 | // Only defaults to 1, even though some codecs (such as opus) should really |
| 449 | // default to 2. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 450 | rtc::Optional<int> num_channels; |
| 451 | |
| 452 | // The maximum packetization time to be used by an RtpSender. |
| 453 | // If |ptime| is also set, this will be ignored. |
| 454 | // TODO(deadbeef): Not implemented. |
| 455 | rtc::Optional<int> max_ptime; |
| 456 | |
| 457 | // The packetization time to be used by an RtpSender. |
| 458 | // If unset, will use any time up to max_ptime. |
| 459 | // TODO(deadbeef): Not implemented. |
| 460 | rtc::Optional<int> ptime; |
| 461 | |
| 462 | // Feedback mechanisms to be used for this codec. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 463 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 464 | std::vector<RtcpFeedback> rtcp_feedback; |
| 465 | |
| 466 | // Codec-specific parameters that must be signaled to the remote party. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 467 | // |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 468 | // Corresponds to "a=fmtp" parameters in SDP. |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 469 | // |
| 470 | // Contrary to ORTC, these parameters are named using all lowercase strings. |
| 471 | // This helps make the mapping to SDP simpler, if an application is using |
| 472 | // SDP. Boolean values are represented by the string "1". |
| 473 | // |
| 474 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 475 | std::unordered_map<std::string, std::string> parameters; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 476 | |
| 477 | bool operator==(const RtpCodecParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 478 | return name == o.name && kind == o.kind && payload_type == o.payload_type && |
| 479 | clock_rate == o.clock_rate && num_channels == o.num_channels && |
| 480 | max_ptime == o.max_ptime && ptime == o.ptime && |
| 481 | rtcp_feedback == o.rtcp_feedback && parameters == o.parameters; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 482 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 483 | bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); } |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 484 | }; |
| 485 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 486 | // RtpCapabilities is used to represent the static capabilities of an |
| 487 | // endpoint. An application can use these capabilities to construct an |
| 488 | // RtpParameters. |
| 489 | struct RtpCapabilities { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 490 | RtpCapabilities(); |
| 491 | ~RtpCapabilities(); |
| 492 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 493 | // Supported codecs. |
| 494 | std::vector<RtpCodecCapability> codecs; |
| 495 | |
| 496 | // Supported RTP header extensions. |
| 497 | std::vector<RtpHeaderExtensionCapability> header_extensions; |
| 498 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 499 | // Supported Forward Error Correction (FEC) mechanisms. Note that the RED, |
| 500 | // ulpfec and flexfec codecs used by these mechanisms will still appear in |
| 501 | // |codecs|. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 502 | std::vector<FecMechanism> fec; |
| 503 | |
| 504 | bool operator==(const RtpCapabilities& o) const { |
| 505 | return codecs == o.codecs && header_extensions == o.header_extensions && |
| 506 | fec == o.fec; |
| 507 | } |
| 508 | bool operator!=(const RtpCapabilities& o) const { return !(*this == o); } |
| 509 | }; |
| 510 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 511 | // Note that unlike in ORTC, an RtcpParameters structure is not included in |
| 512 | // RtpParameters, because our API includes an additional "RtpTransport" |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 513 | // abstraction on which RTCP parameters are set. |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 514 | struct RtpParameters { |
Stefan Holmer | 1acbd68 | 2017-09-01 15:29:28 +0200 | [diff] [blame] | 515 | RtpParameters(); |
| 516 | ~RtpParameters(); |
| 517 | |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 518 | // Used when calling getParameters/setParameters with a PeerConnection |
| 519 | // RtpSender, to ensure that outdated parameters are not unintentionally |
| 520 | // applied successfully. |
| 521 | // TODO(deadbeef): Not implemented. |
| 522 | std::string transaction_id; |
| 523 | |
| 524 | // Value to use for MID RTP header extension. |
| 525 | // Called "muxId" in ORTC. |
| 526 | // TODO(deadbeef): Not implemented. |
| 527 | std::string mid; |
| 528 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 529 | std::vector<RtpCodecParameters> codecs; |
| 530 | |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 531 | // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 532 | std::vector<RtpHeaderExtensionParameters> header_extensions; |
| 533 | |
| 534 | std::vector<RtpEncodingParameters> encodings; |
| 535 | |
| 536 | // TODO(deadbeef): Not implemented. |
| 537 | DegradationPreference degradation_preference = |
| 538 | DegradationPreference::BALANCED; |
| 539 | |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 540 | bool operator==(const RtpParameters& o) const { |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 541 | return mid == o.mid && codecs == o.codecs && |
| 542 | header_extensions == o.header_extensions && |
| 543 | encodings == o.encodings && |
| 544 | degradation_preference == o.degradation_preference; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 545 | } |
Taylor Brandstetter | db0cd9e | 2016-05-16 11:40:30 -0700 | [diff] [blame] | 546 | bool operator!=(const RtpParameters& o) const { return !(*this == o); } |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 547 | }; |
| 548 | |
| 549 | } // namespace webrtc |
| 550 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 551 | #endif // API_RTPPARAMETERS_H_ |