rtp_parameters.h 25 KB

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