blob: 94ce00d91641c1b5ad2cea833f2882f4f9e776d7 [file] [log] [blame]
skvladdc1c62c2016-03-16 19:07:43 -07001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef API_RTP_PARAMETERS_H_
12#define API_RTP_PARAMETERS_H_
skvladdc1c62c2016-03-16 19:07:43 -070013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
Johannes Kron72d69152020-02-10 14:05:55 +010016#include <map>
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070017#include <string>
skvladdc1c62c2016-03-16 19:07:43 -070018#include <vector>
19
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020020#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/media_types.h"
Mirko Bonadeiac194142018-10-22 17:08:37 +020022#include "rtc_base/system/rtc_export.h"
sakal1fd95952016-06-22 00:46:15 -070023
skvladdc1c62c2016-03-16 19:07:43 -070024namespace webrtc {
25
deadbeefe702b302017-02-04 12:09:01 -080026// These structures are intended to mirror those defined by:
27// http://draft.ortc.org/#rtcrtpdictionaries*
28// Contains everything specified as of 2017 Jan 24.
29//
30// They are used when retrieving or modifying the parameters of an
31// RtpSender/RtpReceiver, or retrieving capabilities.
32//
33// Note on conventions: Where ORTC may use "octet", "short" and "unsigned"
34// types, we typically use "int", in keeping with our style guidelines. The
35// parameter's actual valid range will be enforced when the parameters are set,
36// rather than when the parameters struct is built. An exception is made for
37// SSRCs, since they use the full unsigned 32-bit range, and aren't expected to
38// be used for any numeric comparisons/operations.
39//
40// Additionally, where ORTC uses strings, we may use enums for things that have
41// a fixed number of supported values. However, for things that can be extended
42// (such as codecs, by providing an external encoder factory), a string
43// identifier is used.
44
45enum class FecMechanism {
46 RED,
47 RED_AND_ULPFEC,
48 FLEXFEC,
49};
50
51// Used in RtcpFeedback struct.
52enum class RtcpFeedbackType {
deadbeefe702b302017-02-04 12:09:01 -080053 CCM,
Elad Alonfadb1812019-05-24 13:40:02 +020054 LNTF, // "goog-lntf"
deadbeefe702b302017-02-04 12:09:01 -080055 NACK,
56 REMB, // "goog-remb"
57 TRANSPORT_CC,
58};
59
deadbeefe814a0d2017-02-25 18:15:09 -080060// Used in RtcpFeedback struct when type is NACK or CCM.
deadbeefe702b302017-02-04 12:09:01 -080061enum class RtcpFeedbackMessageType {
62 // Equivalent to {type: "nack", parameter: undefined} in ORTC.
63 GENERIC_NACK,
64 PLI, // Usable with NACK.
65 FIR, // Usable with CCM.
66};
67
68enum class DtxStatus {
69 DISABLED,
70 ENABLED,
71};
72
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070073// Based on the spec in
74// https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
75// These options are enforced on a best-effort basis. For instance, all of
76// these options may suffer some frame drops in order to avoid queuing.
77// TODO(sprang): Look into possibility of more strictly enforcing the
78// maintain-framerate option.
79// TODO(deadbeef): Default to "balanced", as the spec indicates?
deadbeefe702b302017-02-04 12:09:01 -080080enum class DegradationPreference {
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070081 // Don't take any actions based on over-utilization signals. Not part of the
82 // web API.
83 DISABLED,
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070084 // On over-use, request lower resolution, possibly causing down-scaling.
Åsa Persson90bc1e12019-05-31 13:29:35 +020085 MAINTAIN_FRAMERATE,
86 // On over-use, request lower frame rate, possibly causing frame drops.
deadbeefe702b302017-02-04 12:09:01 -080087 MAINTAIN_RESOLUTION,
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070088 // Try to strike a "pleasing" balance between frame rate or resolution.
deadbeefe702b302017-02-04 12:09:01 -080089 BALANCED,
90};
91
Mirko Bonadei66e76792019-04-02 11:33:59 +020092RTC_EXPORT extern const double kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -080093
Taylor Brandstetter567f03f2020-02-18 13:41:54 -080094// TODO(deadbeef): Switch to an enum class.
95struct RTC_EXPORT NetworkPriority {
96 static const double kVeryLow;
97 static const double kLow;
98 static const double kMedium;
99 static const double kHigh;
100};
101
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200102struct RTC_EXPORT RtcpFeedback {
deadbeefe814a0d2017-02-25 18:15:09 -0800103 RtcpFeedbackType type = RtcpFeedbackType::CCM;
deadbeefe702b302017-02-04 12:09:01 -0800104
105 // Equivalent to ORTC "parameter" field with slight differences:
106 // 1. It's an enum instead of a string.
107 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
108 // rather than an unset "parameter" value.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200109 absl::optional<RtcpFeedbackMessageType> message_type;
deadbeefe702b302017-02-04 12:09:01 -0800110
deadbeefe814a0d2017-02-25 18:15:09 -0800111 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200112 RtcpFeedback();
113 explicit RtcpFeedback(RtcpFeedbackType type);
114 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200115 RtcpFeedback(const RtcpFeedback&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200116 ~RtcpFeedback();
deadbeefe814a0d2017-02-25 18:15:09 -0800117
deadbeefe702b302017-02-04 12:09:01 -0800118 bool operator==(const RtcpFeedback& o) const {
119 return type == o.type && message_type == o.message_type;
120 }
121 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
122};
123
124// RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to
125// RtpParameters. This represents the static capabilities of an endpoint's
126// implementation of a codec.
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200127struct RTC_EXPORT RtpCodecCapability {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200128 RtpCodecCapability();
129 ~RtpCodecCapability();
130
deadbeefe702b302017-02-04 12:09:01 -0800131 // Build MIME "type/subtype" string from |name| and |kind|.
132 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
133
134 // Used to identify the codec. Equivalent to MIME subtype.
135 std::string name;
136
137 // The media type of this codec. Equivalent to MIME top-level type.
138 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
139
140 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200141 absl::optional<int> clock_rate;
deadbeefe702b302017-02-04 12:09:01 -0800142
143 // Default payload type for this codec. Mainly needed for codecs that use
144 // that have statically assigned payload types.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200145 absl::optional<int> preferred_payload_type;
deadbeefe702b302017-02-04 12:09:01 -0800146
147 // Maximum packetization time supported by an RtpReceiver for this codec.
148 // TODO(deadbeef): Not implemented.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200149 absl::optional<int> max_ptime;
deadbeefe702b302017-02-04 12:09:01 -0800150
Åsa Persson90bc1e12019-05-31 13:29:35 +0200151 // Preferred packetization time for an RtpReceiver or RtpSender of this codec.
deadbeefe702b302017-02-04 12:09:01 -0800152 // TODO(deadbeef): Not implemented.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200153 absl::optional<int> ptime;
deadbeefe702b302017-02-04 12:09:01 -0800154
155 // The number of audio channels supported. Unused for video codecs.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200156 absl::optional<int> num_channels;
deadbeefe702b302017-02-04 12:09:01 -0800157
158 // Feedback mechanisms supported for this codec.
159 std::vector<RtcpFeedback> rtcp_feedback;
160
161 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800162 //
deadbeefe702b302017-02-04 12:09:01 -0800163 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800164 //
165 // Contrary to ORTC, these parameters are named using all lowercase strings.
Åsa Persson90bc1e12019-05-31 13:29:35 +0200166 // This helps make the mapping to SDP simpler, if an application is using SDP.
167 // Boolean values are represented by the string "1".
Johannes Kron72d69152020-02-10 14:05:55 +0100168 std::map<std::string, std::string> parameters;
deadbeefe702b302017-02-04 12:09:01 -0800169
170 // Codec-specific parameters that may optionally be signaled to the remote
171 // party.
172 // TODO(deadbeef): Not implemented.
Johannes Kron72d69152020-02-10 14:05:55 +0100173 std::map<std::string, std::string> options;
deadbeefe702b302017-02-04 12:09:01 -0800174
175 // Maximum number of temporal layer extensions supported by this codec.
176 // For example, a value of 1 indicates that 2 total layers are supported.
177 // TODO(deadbeef): Not implemented.
178 int max_temporal_layer_extensions = 0;
179
180 // Maximum number of spatial layer extensions supported by this codec.
181 // For example, a value of 1 indicates that 2 total layers are supported.
182 // TODO(deadbeef): Not implemented.
183 int max_spatial_layer_extensions = 0;
184
Åsa Persson90bc1e12019-05-31 13:29:35 +0200185 // Whether the implementation can send/receive SVC layers with distinct SSRCs.
186 // Always false for audio codecs. True for video codecs that support scalable
187 // video coding with MRST.
deadbeefe702b302017-02-04 12:09:01 -0800188 // TODO(deadbeef): Not implemented.
189 bool svc_multi_stream_support = false;
190
191 bool operator==(const RtpCodecCapability& o) const {
192 return name == o.name && kind == o.kind && clock_rate == o.clock_rate &&
193 preferred_payload_type == o.preferred_payload_type &&
194 max_ptime == o.max_ptime && ptime == o.ptime &&
195 num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback &&
196 parameters == o.parameters && options == o.options &&
197 max_temporal_layer_extensions == o.max_temporal_layer_extensions &&
198 max_spatial_layer_extensions == o.max_spatial_layer_extensions &&
199 svc_multi_stream_support == o.svc_multi_stream_support;
200 }
201 bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
202};
203
204// Used in RtpCapabilities; represents the capabilities/preferences of an
205// implementation for a header extension.
206//
207// Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was
208// added here for consistency and to avoid confusion with
209// RtpHeaderExtensionParameters.
210//
211// Note that ORTC includes a "kind" field, but we omit this because it's
212// redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)",
213// you know you're getting audio capabilities.
214struct RtpHeaderExtensionCapability {
Johannes Kron07ba2b92018-09-26 13:33:35 +0200215 // URI of this extension, as defined in RFC8285.
deadbeefe702b302017-02-04 12:09:01 -0800216 std::string uri;
217
218 // Preferred value of ID that goes in the packet.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200219 absl::optional<int> preferred_id;
deadbeefe702b302017-02-04 12:09:01 -0800220
221 // If true, it's preferred that the value in the header is encrypted.
222 // TODO(deadbeef): Not implemented.
223 bool preferred_encrypt = false;
224
deadbeefe814a0d2017-02-25 18:15:09 -0800225 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200226 RtpHeaderExtensionCapability();
227 explicit RtpHeaderExtensionCapability(const std::string& uri);
228 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
229 ~RtpHeaderExtensionCapability();
deadbeefe814a0d2017-02-25 18:15:09 -0800230
deadbeefe702b302017-02-04 12:09:01 -0800231 bool operator==(const RtpHeaderExtensionCapability& o) const {
232 return uri == o.uri && preferred_id == o.preferred_id &&
233 preferred_encrypt == o.preferred_encrypt;
234 }
235 bool operator!=(const RtpHeaderExtensionCapability& o) const {
236 return !(*this == o);
237 }
238};
239
Johannes Kron07ba2b92018-09-26 13:33:35 +0200240// RTP header extension, see RFC8285.
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200241struct RTC_EXPORT RtpExtension {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200242 RtpExtension();
243 RtpExtension(const std::string& uri, int id);
244 RtpExtension(const std::string& uri, int id, bool encrypt);
245 ~RtpExtension();
246 std::string ToString() const;
247 bool operator==(const RtpExtension& rhs) const {
248 return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
249 }
250 static bool IsSupportedForAudio(const std::string& uri);
251 static bool IsSupportedForVideo(const std::string& uri);
252 // Return "true" if the given RTP header extension URI may be encrypted.
253 static bool IsEncryptionSupported(const std::string& uri);
254
255 // Returns the named header extension if found among all extensions,
256 // nullptr otherwise.
257 static const RtpExtension* FindHeaderExtensionByUri(
258 const std::vector<RtpExtension>& extensions,
259 const std::string& uri);
260
261 // Return a list of RTP header extensions with the non-encrypted extensions
262 // removed if both the encrypted and non-encrypted extension is present for
263 // the same URI.
264 static std::vector<RtpExtension> FilterDuplicateNonEncrypted(
265 const std::vector<RtpExtension>& extensions);
266
267 // Header extension for audio levels, as defined in:
268 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
269 static const char kAudioLevelUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200270
271 // Header extension for RTP timestamp offset, see RFC 5450 for details:
272 // http://tools.ietf.org/html/rfc5450
273 static const char kTimestampOffsetUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200274
275 // Header extension for absolute send time, see url for details:
276 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
277 static const char kAbsSendTimeUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200278
Chen Xingcd8a6e22019-07-01 10:56:51 +0200279 // Header extension for absolute capture time, see url for details:
280 // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time
281 static const char kAbsoluteCaptureTimeUri[];
282
Stefan Holmer1acbd682017-09-01 15:29:28 +0200283 // Header extension for coordination of video orientation, see url for
284 // details:
285 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
286 static const char kVideoRotationUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200287
288 // Header extension for video content type. E.g. default or screenshare.
289 static const char kVideoContentTypeUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200290
291 // Header extension for video timing.
292 static const char kVideoTimingUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200293
Johnny Leee0c8b232018-09-11 16:50:49 -0400294 // Header extension for video frame marking.
295 static const char kFrameMarkingUri[];
Johnny Leee0c8b232018-09-11 16:50:49 -0400296
Danil Chapovalovf3119ef2018-09-25 12:20:37 +0200297 // Experimental codec agnostic frame descriptor.
Elad Alonccb9b752019-02-19 13:01:31 +0100298 static const char kGenericFrameDescriptorUri00[];
299 static const char kGenericFrameDescriptorUri01[];
Danil Chapovalov2272f202020-02-18 12:09:43 +0100300 static const char kDependencyDescriptorUri[];
Elad Alonccb9b752019-02-19 13:01:31 +0100301 // TODO(bugs.webrtc.org/10243): Remove once dependencies have been updated.
Danil Chapovalovf3119ef2018-09-25 12:20:37 +0200302 static const char kGenericFrameDescriptorUri[];
Danil Chapovalovf3119ef2018-09-25 12:20:37 +0200303
Stefan Holmer1acbd682017-09-01 15:29:28 +0200304 // Header extension for transport sequence number, see url for details:
305 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
306 static const char kTransportSequenceNumberUri[];
Johannes Kron7ff164e2019-02-07 12:50:18 +0100307 static const char kTransportSequenceNumberV2Uri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200308
309 static const char kPlayoutDelayUri[];
Stefan Holmer1acbd682017-09-01 15:29:28 +0200310
Steve Antonbb50ce52018-03-26 10:24:32 -0700311 // Header extension for identifying media section within a transport.
312 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-49#section-15
313 static const char kMidUri[];
Steve Antonbb50ce52018-03-26 10:24:32 -0700314
Stefan Holmer1acbd682017-09-01 15:29:28 +0200315 // Encryption of Header Extensions, see RFC 6904 for details:
316 // https://tools.ietf.org/html/rfc6904
317 static const char kEncryptHeaderExtensionsUri[];
318
Johannes Krond0b69a82018-12-03 14:18:53 +0100319 // Header extension for color space information.
320 static const char kColorSpaceUri[];
Johannes Krond0b69a82018-12-03 14:18:53 +0100321
Amit Hilbuch77938e62018-12-21 09:23:38 -0800322 // Header extension for RIDs and Repaired RIDs
323 // https://tools.ietf.org/html/draft-ietf-avtext-rid-09
324 // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15
325 static const char kRidUri[];
Amit Hilbuch77938e62018-12-21 09:23:38 -0800326 static const char kRepairedRidUri[];
Amit Hilbuch77938e62018-12-21 09:23:38 -0800327
Johannes Kron07ba2b92018-09-26 13:33:35 +0200328 // Inclusive min and max IDs for two-byte header extensions and one-byte
329 // header extensions, per RFC8285 Section 4.2-4.3.
330 static constexpr int kMinId = 1;
331 static constexpr int kMaxId = 255;
Johannes Kron78cdde32018-10-05 10:00:46 +0200332 static constexpr int kMaxValueSize = 255;
Johannes Kron07ba2b92018-09-26 13:33:35 +0200333 static constexpr int kOneByteHeaderExtensionMaxId = 14;
Johannes Kron78cdde32018-10-05 10:00:46 +0200334 static constexpr int kOneByteHeaderExtensionMaxValueSize = 16;
Stefan Holmer1acbd682017-09-01 15:29:28 +0200335
336 std::string uri;
337 int id = 0;
338 bool encrypt = false;
339};
340
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200341struct RTC_EXPORT RtpFecParameters {
deadbeefe702b302017-02-04 12:09:01 -0800342 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800343 // Works just like RtpEncodingParameters::ssrc.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200344 absl::optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800345
346 FecMechanism mechanism = FecMechanism::RED;
347
deadbeefe814a0d2017-02-25 18:15:09 -0800348 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200349 RtpFecParameters();
350 explicit RtpFecParameters(FecMechanism mechanism);
351 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200352 RtpFecParameters(const RtpFecParameters&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200353 ~RtpFecParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800354
deadbeefe702b302017-02-04 12:09:01 -0800355 bool operator==(const RtpFecParameters& o) const {
356 return ssrc == o.ssrc && mechanism == o.mechanism;
357 }
358 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
359};
360
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200361struct RTC_EXPORT RtpRtxParameters {
deadbeefe702b302017-02-04 12:09:01 -0800362 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800363 // Works just like RtpEncodingParameters::ssrc.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200364 absl::optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800365
deadbeefe814a0d2017-02-25 18:15:09 -0800366 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200367 RtpRtxParameters();
368 explicit RtpRtxParameters(uint32_t ssrc);
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200369 RtpRtxParameters(const RtpRtxParameters&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200370 ~RtpRtxParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800371
deadbeefe702b302017-02-04 12:09:01 -0800372 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
373 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
374};
375
Mirko Bonadei66e76792019-04-02 11:33:59 +0200376struct RTC_EXPORT RtpEncodingParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200377 RtpEncodingParameters();
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200378 RtpEncodingParameters(const RtpEncodingParameters&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200379 ~RtpEncodingParameters();
380
deadbeefe702b302017-02-04 12:09:01 -0800381 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800382 //
383 // Note that the chosen value is NOT returned by GetParameters, because it
384 // may change due to an SSRC conflict, in which case the conflict is handled
385 // internally without any event. Another way of looking at this is that an
386 // unset SSRC acts as a "wildcard" SSRC.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200387 absl::optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800388
Seth Hampson24722b32017-12-22 09:36:42 -0800389 // The relative bitrate priority of this encoding. Currently this is
Seth Hampsona881ac02018-02-12 14:14:39 -0800390 // implemented for the entire rtp sender by using the value of the first
391 // encoding parameter.
392 // TODO(webrtc.bugs.org/8630): Implement this per encoding parameter.
393 // Currently there is logic for how bitrate is distributed per simulcast layer
394 // in the VideoBitrateAllocator. This must be updated to incorporate relative
395 // bitrate priority.
Seth Hampson24722b32017-12-22 09:36:42 -0800396 double bitrate_priority = kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -0800397
Tim Haloun648d28a2018-10-18 16:52:22 -0700398 // The relative DiffServ Code Point priority for this encoding, allowing
399 // packets to be marked relatively higher or lower without affecting
400 // bandwidth allocations. See https://w3c.github.io/webrtc-dscp-exp/ . NB
401 // we follow chromium's translation of the allowed string enum values for
402 // this field to 1.0, 0.5, et cetera, similar to bitrate_priority above.
403 // TODO(http://crbug.com/webrtc/8630): Implement this per encoding parameter.
Taylor Brandstetter567f03f2020-02-18 13:41:54 -0800404 double network_priority = NetworkPriority::kLow;
Tim Haloun648d28a2018-10-18 16:52:22 -0700405
deadbeefe702b302017-02-04 12:09:01 -0800406 // If set, this represents the Transport Independent Application Specific
407 // maximum bandwidth defined in RFC3890. If unset, there is no maximum
Seth Hampsona881ac02018-02-12 14:14:39 -0800408 // bitrate. Currently this is implemented for the entire rtp sender by using
409 // the value of the first encoding parameter.
410 //
deadbeefe702b302017-02-04 12:09:01 -0800411 // Just called "maxBitrate" in ORTC spec.
deadbeefe814a0d2017-02-25 18:15:09 -0800412 //
413 // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total
414 // bandwidth for the entire bandwidth estimator (audio and video). This is
415 // just always how "b=AS" was handled, but it's not correct and should be
416 // fixed.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200417 absl::optional<int> max_bitrate_bps;
deadbeefe702b302017-02-04 12:09:01 -0800418
Åsa Persson55659812018-06-18 17:51:32 +0200419 // Specifies the minimum bitrate in bps for video.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200420 absl::optional<int> min_bitrate_bps;
Åsa Persson613591a2018-05-29 09:21:31 +0200421
Åsa Persson8c1bf952018-09-13 10:42:19 +0200422 // Specifies the maximum framerate in fps for video.
Florent Castelli907dc802019-12-06 15:03:19 +0100423 absl::optional<double> max_framerate;
deadbeefe702b302017-02-04 12:09:01 -0800424
Åsa Persson23eba222018-10-02 14:47:06 +0200425 // Specifies the number of temporal layers for video (if the feature is
426 // supported by the codec implementation).
427 // TODO(asapersson): Different number of temporal layers are not supported
428 // per simulcast layer.
Ilya Nikolaevskiy9f6a0d52019-02-05 10:29:41 +0100429 // Screencast support is experimental.
Åsa Persson23eba222018-10-02 14:47:06 +0200430 absl::optional<int> num_temporal_layers;
431
deadbeefe702b302017-02-04 12:09:01 -0800432 // For video, scale the resolution down by this factor.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200433 absl::optional<double> scale_resolution_down_by;
deadbeefe702b302017-02-04 12:09:01 -0800434
Seth Hampsona881ac02018-02-12 14:14:39 -0800435 // For an RtpSender, set to true to cause this encoding to be encoded and
436 // sent, and false for it not to be encoded and sent. This allows control
437 // across multiple encodings of a sender for turning simulcast layers on and
438 // off.
439 // TODO(webrtc.bugs.org/8807): Updating this parameter will trigger an encoder
440 // reset, but this isn't necessarily required.
deadbeefdbe2b872016-03-22 15:42:00 -0700441 bool active = true;
deadbeefe702b302017-02-04 12:09:01 -0800442
443 // Value to use for RID RTP header extension.
444 // Called "encodingId" in ORTC.
deadbeefe702b302017-02-04 12:09:01 -0800445 std::string rid;
446
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700447 bool operator==(const RtpEncodingParameters& o) const {
Florent Castellia8c2f512019-11-28 15:48:24 +0100448 return ssrc == o.ssrc && bitrate_priority == o.bitrate_priority &&
449 network_priority == o.network_priority &&
Seth Hampson24722b32017-12-22 09:36:42 -0800450 max_bitrate_bps == o.max_bitrate_bps &&
Åsa Persson8c1bf952018-09-13 10:42:19 +0200451 min_bitrate_bps == o.min_bitrate_bps &&
deadbeefe702b302017-02-04 12:09:01 -0800452 max_framerate == o.max_framerate &&
Åsa Persson23eba222018-10-02 14:47:06 +0200453 num_temporal_layers == o.num_temporal_layers &&
deadbeefe702b302017-02-04 12:09:01 -0800454 scale_resolution_down_by == o.scale_resolution_down_by &&
Florent Castellia8c2f512019-11-28 15:48:24 +0100455 active == o.active && rid == o.rid;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700456 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700457 bool operator!=(const RtpEncodingParameters& o) const {
458 return !(*this == o);
459 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700460};
461
Mirko Bonadei35214fc2019-09-23 14:54:28 +0200462struct RTC_EXPORT RtpCodecParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200463 RtpCodecParameters();
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200464 RtpCodecParameters(const RtpCodecParameters&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200465 ~RtpCodecParameters();
466
deadbeefe702b302017-02-04 12:09:01 -0800467 // Build MIME "type/subtype" string from |name| and |kind|.
468 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
469
470 // Used to identify the codec. Equivalent to MIME subtype.
471 std::string name;
472
473 // The media type of this codec. Equivalent to MIME top-level type.
474 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
475
476 // Payload type used to identify this codec in RTP packets.
deadbeefe814a0d2017-02-25 18:15:09 -0800477 // This must always be present, and must be unique across all codecs using
deadbeefe702b302017-02-04 12:09:01 -0800478 // the same transport.
479 int payload_type = 0;
480
481 // If unset, the implementation default is used.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200482 absl::optional<int> clock_rate;
deadbeefe702b302017-02-04 12:09:01 -0800483
484 // The number of audio channels used. Unset for video codecs. If unset for
485 // audio, the implementation default is used.
deadbeefe814a0d2017-02-25 18:15:09 -0800486 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
487 // Only defaults to 1, even though some codecs (such as opus) should really
488 // default to 2.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200489 absl::optional<int> num_channels;
deadbeefe702b302017-02-04 12:09:01 -0800490
491 // The maximum packetization time to be used by an RtpSender.
492 // If |ptime| is also set, this will be ignored.
493 // TODO(deadbeef): Not implemented.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200494 absl::optional<int> max_ptime;
deadbeefe702b302017-02-04 12:09:01 -0800495
496 // The packetization time to be used by an RtpSender.
497 // If unset, will use any time up to max_ptime.
498 // TODO(deadbeef): Not implemented.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200499 absl::optional<int> ptime;
deadbeefe702b302017-02-04 12:09:01 -0800500
501 // Feedback mechanisms to be used for this codec.
deadbeefe814a0d2017-02-25 18:15:09 -0800502 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800503 std::vector<RtcpFeedback> rtcp_feedback;
504
505 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800506 //
deadbeefe702b302017-02-04 12:09:01 -0800507 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800508 //
509 // Contrary to ORTC, these parameters are named using all lowercase strings.
Åsa Persson90bc1e12019-05-31 13:29:35 +0200510 // This helps make the mapping to SDP simpler, if an application is using SDP.
511 // Boolean values are represented by the string "1".
Johannes Kron72d69152020-02-10 14:05:55 +0100512 std::map<std::string, std::string> parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700513
514 bool operator==(const RtpCodecParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800515 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
516 clock_rate == o.clock_rate && num_channels == o.num_channels &&
517 max_ptime == o.max_ptime && ptime == o.ptime &&
518 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700519 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700520 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700521};
522
Åsa Persson90bc1e12019-05-31 13:29:35 +0200523// RtpCapabilities is used to represent the static capabilities of an endpoint.
524// An application can use these capabilities to construct an RtpParameters.
Mirko Bonadei66e76792019-04-02 11:33:59 +0200525struct RTC_EXPORT RtpCapabilities {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200526 RtpCapabilities();
527 ~RtpCapabilities();
528
deadbeefe702b302017-02-04 12:09:01 -0800529 // Supported codecs.
530 std::vector<RtpCodecCapability> codecs;
531
532 // Supported RTP header extensions.
533 std::vector<RtpHeaderExtensionCapability> header_extensions;
534
deadbeefe814a0d2017-02-25 18:15:09 -0800535 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED,
536 // ulpfec and flexfec codecs used by these mechanisms will still appear in
537 // |codecs|.
deadbeefe702b302017-02-04 12:09:01 -0800538 std::vector<FecMechanism> fec;
539
540 bool operator==(const RtpCapabilities& o) const {
541 return codecs == o.codecs && header_extensions == o.header_extensions &&
542 fec == o.fec;
543 }
544 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
545};
546
Florent Castellidacec712018-05-24 16:24:21 +0200547struct RtcpParameters final {
548 RtcpParameters();
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200549 RtcpParameters(const RtcpParameters&);
Florent Castellidacec712018-05-24 16:24:21 +0200550 ~RtcpParameters();
551
552 // The SSRC to be used in the "SSRC of packet sender" field. If not set, one
553 // will be chosen by the implementation.
554 // TODO(deadbeef): Not implemented.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +0200555 absl::optional<uint32_t> ssrc;
Florent Castellidacec712018-05-24 16:24:21 +0200556
557 // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages).
558 //
559 // If empty in the construction of the RtpTransport, one will be generated by
560 // the implementation, and returned in GetRtcpParameters. Multiple
561 // RtpTransports created by the same OrtcFactory will use the same generated
562 // CNAME.
563 //
564 // If empty when passed into SetParameters, the CNAME simply won't be
565 // modified.
566 std::string cname;
567
568 // Send reduced-size RTCP?
569 bool reduced_size = false;
570
571 // Send RTCP multiplexed on the RTP transport?
572 // Not used with PeerConnection senders/receivers
573 bool mux = true;
574
575 bool operator==(const RtcpParameters& o) const {
576 return ssrc == o.ssrc && cname == o.cname &&
577 reduced_size == o.reduced_size && mux == o.mux;
578 }
579 bool operator!=(const RtcpParameters& o) const { return !(*this == o); }
580};
581
Mirko Bonadeiac194142018-10-22 17:08:37 +0200582struct RTC_EXPORT RtpParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200583 RtpParameters();
Mirko Bonadei2ffed6d2018-07-20 11:09:32 +0200584 RtpParameters(const RtpParameters&);
Stefan Holmer1acbd682017-09-01 15:29:28 +0200585 ~RtpParameters();
586
deadbeefe702b302017-02-04 12:09:01 -0800587 // Used when calling getParameters/setParameters with a PeerConnection
588 // RtpSender, to ensure that outdated parameters are not unintentionally
589 // applied successfully.
deadbeefe702b302017-02-04 12:09:01 -0800590 std::string transaction_id;
591
592 // Value to use for MID RTP header extension.
593 // Called "muxId" in ORTC.
594 // TODO(deadbeef): Not implemented.
595 std::string mid;
596
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700597 std::vector<RtpCodecParameters> codecs;
598
Danil Chapovalovb19eb392019-12-23 17:55:05 +0100599 std::vector<RtpExtension> header_extensions;
deadbeefe702b302017-02-04 12:09:01 -0800600
601 std::vector<RtpEncodingParameters> encodings;
602
Florent Castellidacec712018-05-24 16:24:21 +0200603 // Only available with a Peerconnection RtpSender.
604 // In ORTC, our API includes an additional "RtpTransport"
605 // abstraction on which RTCP parameters are set.
606 RtcpParameters rtcp;
607
Florent Castelli87b3c512018-07-18 16:00:28 +0200608 // When bandwidth is constrained and the RtpSender needs to choose between
609 // degrading resolution or degrading framerate, degradationPreference
610 // indicates which is preferred. Only for video tracks.
deadbeefe702b302017-02-04 12:09:01 -0800611 DegradationPreference degradation_preference =
612 DegradationPreference::BALANCED;
613
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700614 bool operator==(const RtpParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800615 return mid == o.mid && codecs == o.codecs &&
616 header_extensions == o.header_extensions &&
Florent Castellidacec712018-05-24 16:24:21 +0200617 encodings == o.encodings && rtcp == o.rtcp &&
deadbeefe702b302017-02-04 12:09:01 -0800618 degradation_preference == o.degradation_preference;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700619 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700620 bool operator!=(const RtpParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700621};
622
623} // namespace webrtc
624
Steve Anton10542f22019-01-11 09:11:00 -0800625#endif // API_RTP_PARAMETERS_H_