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