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