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