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