blob: c12b0c9588eb820a72b715e319b8e771fca7b2dc [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_RTPPARAMETERS_H_
12#define API_RTPPARAMETERS_H_
skvladdc1c62c2016-03-16 19:07:43 -070013
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070014#include <string>
deadbeefe702b302017-02-04 12:09:01 -080015#include <unordered_map>
skvladdc1c62c2016-03-16 19:07:43 -070016#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/mediatypes.h"
19#include "api/optional.h"
sakal1fd95952016-06-22 00:46:15 -070020
skvladdc1c62c2016-03-16 19:07:43 -070021namespace webrtc {
22
deadbeefe702b302017-02-04 12:09:01 -080023// 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
42enum class FecMechanism {
43 RED,
44 RED_AND_ULPFEC,
45 FLEXFEC,
46};
47
48// Used in RtcpFeedback struct.
49enum class RtcpFeedbackType {
deadbeefe702b302017-02-04 12:09:01 -080050 CCM,
51 NACK,
52 REMB, // "goog-remb"
53 TRANSPORT_CC,
54};
55
deadbeefe814a0d2017-02-25 18:15:09 -080056// Used in RtcpFeedback struct when type is NACK or CCM.
deadbeefe702b302017-02-04 12:09:01 -080057enum class RtcpFeedbackMessageType {
58 // Equivalent to {type: "nack", parameter: undefined} in ORTC.
59 GENERIC_NACK,
60 PLI, // Usable with NACK.
61 FIR, // Usable with CCM.
62};
63
64enum class DtxStatus {
65 DISABLED,
66 ENABLED,
67};
68
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070069// Based on the spec in
70// https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
71// These options are enforced on a best-effort basis. For instance, all of
72// these options may suffer some frame drops in order to avoid queuing.
73// TODO(sprang): Look into possibility of more strictly enforcing the
74// maintain-framerate option.
75// TODO(deadbeef): Default to "balanced", as the spec indicates?
deadbeefe702b302017-02-04 12:09:01 -080076enum class DegradationPreference {
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070077 // Don't take any actions based on over-utilization signals. Not part of the
78 // web API.
79 DISABLED,
80 // On over-use, request lower frame rate, possibly causing frame drops.
deadbeefe702b302017-02-04 12:09:01 -080081 MAINTAIN_FRAMERATE,
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070082 // On over-use, request lower resolution, possibly causing down-scaling.
deadbeefe702b302017-02-04 12:09:01 -080083 MAINTAIN_RESOLUTION,
Taylor Brandstetter49fcc102018-05-16 14:20:41 -070084 // Try to strike a "pleasing" balance between frame rate or resolution.
deadbeefe702b302017-02-04 12:09:01 -080085 BALANCED,
86};
87
Seth Hampsonf32795e2017-12-19 11:37:41 -080088extern const double kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -080089
90struct RtcpFeedback {
deadbeefe814a0d2017-02-25 18:15:09 -080091 RtcpFeedbackType type = RtcpFeedbackType::CCM;
deadbeefe702b302017-02-04 12:09:01 -080092
93 // Equivalent to ORTC "parameter" field with slight differences:
94 // 1. It's an enum instead of a string.
95 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
96 // rather than an unset "parameter" value.
97 rtc::Optional<RtcpFeedbackMessageType> message_type;
98
deadbeefe814a0d2017-02-25 18:15:09 -080099 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200100 RtcpFeedback();
101 explicit RtcpFeedback(RtcpFeedbackType type);
102 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
103 ~RtcpFeedback();
deadbeefe814a0d2017-02-25 18:15:09 -0800104
deadbeefe702b302017-02-04 12:09:01 -0800105 bool operator==(const RtcpFeedback& o) const {
106 return type == o.type && message_type == o.message_type;
107 }
108 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
109};
110
111// RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to
112// RtpParameters. This represents the static capabilities of an endpoint's
113// implementation of a codec.
114struct RtpCodecCapability {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200115 RtpCodecCapability();
116 ~RtpCodecCapability();
117
deadbeefe702b302017-02-04 12:09:01 -0800118 // Build MIME "type/subtype" string from |name| and |kind|.
119 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
120
121 // Used to identify the codec. Equivalent to MIME subtype.
122 std::string name;
123
124 // The media type of this codec. Equivalent to MIME top-level type.
125 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
126
127 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate.
128 rtc::Optional<int> clock_rate;
129
130 // Default payload type for this codec. Mainly needed for codecs that use
131 // that have statically assigned payload types.
132 rtc::Optional<int> preferred_payload_type;
133
134 // Maximum packetization time supported by an RtpReceiver for this codec.
135 // TODO(deadbeef): Not implemented.
136 rtc::Optional<int> max_ptime;
137
138 // Preferred packetization time for an RtpReceiver or RtpSender of this
139 // codec.
140 // TODO(deadbeef): Not implemented.
141 rtc::Optional<int> ptime;
142
143 // The number of audio channels supported. Unused for video codecs.
144 rtc::Optional<int> num_channels;
145
146 // Feedback mechanisms supported for this codec.
147 std::vector<RtcpFeedback> rtcp_feedback;
148
149 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800150 //
deadbeefe702b302017-02-04 12:09:01 -0800151 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800152 //
153 // Contrary to ORTC, these parameters are named using all lowercase strings.
154 // This helps make the mapping to SDP simpler, if an application is using
155 // SDP. Boolean values are represented by the string "1".
deadbeefe702b302017-02-04 12:09:01 -0800156 std::unordered_map<std::string, std::string> parameters;
157
158 // Codec-specific parameters that may optionally be signaled to the remote
159 // party.
160 // TODO(deadbeef): Not implemented.
161 std::unordered_map<std::string, std::string> options;
162
163 // Maximum number of temporal layer extensions supported by this codec.
164 // For example, a value of 1 indicates that 2 total layers are supported.
165 // TODO(deadbeef): Not implemented.
166 int max_temporal_layer_extensions = 0;
167
168 // Maximum number of spatial layer extensions supported by this codec.
169 // For example, a value of 1 indicates that 2 total layers are supported.
170 // TODO(deadbeef): Not implemented.
171 int max_spatial_layer_extensions = 0;
172
173 // Whether the implementation can send/receive SVC layers with distinct
174 // SSRCs. Always false for audio codecs. True for video codecs that support
175 // scalable video coding with MRST.
176 // TODO(deadbeef): Not implemented.
177 bool svc_multi_stream_support = false;
178
179 bool operator==(const RtpCodecCapability& o) const {
180 return name == o.name && kind == o.kind && clock_rate == o.clock_rate &&
181 preferred_payload_type == o.preferred_payload_type &&
182 max_ptime == o.max_ptime && ptime == o.ptime &&
183 num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback &&
184 parameters == o.parameters && options == o.options &&
185 max_temporal_layer_extensions == o.max_temporal_layer_extensions &&
186 max_spatial_layer_extensions == o.max_spatial_layer_extensions &&
187 svc_multi_stream_support == o.svc_multi_stream_support;
188 }
189 bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
190};
191
192// Used in RtpCapabilities; represents the capabilities/preferences of an
193// implementation for a header extension.
194//
195// Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was
196// added here for consistency and to avoid confusion with
197// RtpHeaderExtensionParameters.
198//
199// Note that ORTC includes a "kind" field, but we omit this because it's
200// redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)",
201// you know you're getting audio capabilities.
202struct RtpHeaderExtensionCapability {
203 // URI of this extension, as defined in RFC5285.
204 std::string uri;
205
206 // Preferred value of ID that goes in the packet.
207 rtc::Optional<int> preferred_id;
208
209 // If true, it's preferred that the value in the header is encrypted.
210 // TODO(deadbeef): Not implemented.
211 bool preferred_encrypt = false;
212
deadbeefe814a0d2017-02-25 18:15:09 -0800213 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200214 RtpHeaderExtensionCapability();
215 explicit RtpHeaderExtensionCapability(const std::string& uri);
216 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
217 ~RtpHeaderExtensionCapability();
deadbeefe814a0d2017-02-25 18:15:09 -0800218
deadbeefe702b302017-02-04 12:09:01 -0800219 bool operator==(const RtpHeaderExtensionCapability& o) const {
220 return uri == o.uri && preferred_id == o.preferred_id &&
221 preferred_encrypt == o.preferred_encrypt;
222 }
223 bool operator!=(const RtpHeaderExtensionCapability& o) const {
224 return !(*this == o);
225 }
226};
227
Stefan Holmer1acbd682017-09-01 15:29:28 +0200228// RTP header extension, see RFC 5285.
229struct RtpExtension {
230 RtpExtension();
231 RtpExtension(const std::string& uri, int id);
232 RtpExtension(const std::string& uri, int id, bool encrypt);
233 ~RtpExtension();
234 std::string ToString() const;
235 bool operator==(const RtpExtension& rhs) const {
236 return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
237 }
238 static bool IsSupportedForAudio(const std::string& uri);
239 static bool IsSupportedForVideo(const std::string& uri);
240 // Return "true" if the given RTP header extension URI may be encrypted.
241 static bool IsEncryptionSupported(const std::string& uri);
242
243 // Returns the named header extension if found among all extensions,
244 // nullptr otherwise.
245 static const RtpExtension* FindHeaderExtensionByUri(
246 const std::vector<RtpExtension>& extensions,
247 const std::string& uri);
248
249 // Return a list of RTP header extensions with the non-encrypted extensions
250 // removed if both the encrypted and non-encrypted extension is present for
251 // the same URI.
252 static std::vector<RtpExtension> FilterDuplicateNonEncrypted(
253 const std::vector<RtpExtension>& extensions);
254
255 // Header extension for audio levels, as defined in:
256 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
257 static const char kAudioLevelUri[];
258 static const int kAudioLevelDefaultId;
259
260 // Header extension for RTP timestamp offset, see RFC 5450 for details:
261 // http://tools.ietf.org/html/rfc5450
262 static const char kTimestampOffsetUri[];
263 static const int kTimestampOffsetDefaultId;
264
265 // Header extension for absolute send time, see url for details:
266 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
267 static const char kAbsSendTimeUri[];
268 static const int kAbsSendTimeDefaultId;
269
270 // Header extension for coordination of video orientation, see url for
271 // details:
272 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
273 static const char kVideoRotationUri[];
274 static const int kVideoRotationDefaultId;
275
276 // Header extension for video content type. E.g. default or screenshare.
277 static const char kVideoContentTypeUri[];
278 static const int kVideoContentTypeDefaultId;
279
280 // Header extension for video timing.
281 static const char kVideoTimingUri[];
282 static const int kVideoTimingDefaultId;
283
284 // Header extension for transport sequence number, see url for details:
285 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
286 static const char kTransportSequenceNumberUri[];
287 static const int kTransportSequenceNumberDefaultId;
288
289 static const char kPlayoutDelayUri[];
290 static const int kPlayoutDelayDefaultId;
291
Steve Antonbb50ce52018-03-26 10:24:32 -0700292 // Header extension for identifying media section within a transport.
293 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-49#section-15
294 static const char kMidUri[];
295 static const int kMidDefaultId;
296
Stefan Holmer1acbd682017-09-01 15:29:28 +0200297 // Encryption of Header Extensions, see RFC 6904 for details:
298 // https://tools.ietf.org/html/rfc6904
299 static const char kEncryptHeaderExtensionsUri[];
300
301 // Inclusive min and max IDs for one-byte header extensions, per RFC5285.
302 static const int kMinId;
303 static const int kMaxId;
304
305 std::string uri;
306 int id = 0;
307 bool encrypt = false;
308};
309
deadbeefe814a0d2017-02-25 18:15:09 -0800310// TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented.
311typedef RtpExtension RtpHeaderExtensionParameters;
deadbeefe702b302017-02-04 12:09:01 -0800312
313struct RtpFecParameters {
314 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800315 // Works just like RtpEncodingParameters::ssrc.
sakal1fd95952016-06-22 00:46:15 -0700316 rtc::Optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800317
318 FecMechanism mechanism = FecMechanism::RED;
319
deadbeefe814a0d2017-02-25 18:15:09 -0800320 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200321 RtpFecParameters();
322 explicit RtpFecParameters(FecMechanism mechanism);
323 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
324 ~RtpFecParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800325
deadbeefe702b302017-02-04 12:09:01 -0800326 bool operator==(const RtpFecParameters& o) const {
327 return ssrc == o.ssrc && mechanism == o.mechanism;
328 }
329 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
330};
331
332struct RtpRtxParameters {
333 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800334 // Works just like RtpEncodingParameters::ssrc.
deadbeefe702b302017-02-04 12:09:01 -0800335 rtc::Optional<uint32_t> ssrc;
336
deadbeefe814a0d2017-02-25 18:15:09 -0800337 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200338 RtpRtxParameters();
339 explicit RtpRtxParameters(uint32_t ssrc);
340 ~RtpRtxParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800341
deadbeefe702b302017-02-04 12:09:01 -0800342 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
343 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
344};
345
346struct RtpEncodingParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200347 RtpEncodingParameters();
348 ~RtpEncodingParameters();
349
deadbeefe702b302017-02-04 12:09:01 -0800350 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800351 //
352 // Note that the chosen value is NOT returned by GetParameters, because it
353 // may change due to an SSRC conflict, in which case the conflict is handled
354 // internally without any event. Another way of looking at this is that an
355 // unset SSRC acts as a "wildcard" SSRC.
deadbeefe702b302017-02-04 12:09:01 -0800356 rtc::Optional<uint32_t> ssrc;
357
358 // Can be used to reference a codec in the |codecs| member of the
359 // RtpParameters that contains this RtpEncodingParameters. If unset, the
deadbeefe814a0d2017-02-25 18:15:09 -0800360 // implementation will choose the first possible codec (if a sender), or
361 // prepare to receive any codec (for a receiver).
362 // TODO(deadbeef): Not implemented. Implementation of RtpSender will always
363 // choose the first codec from the list.
deadbeefe702b302017-02-04 12:09:01 -0800364 rtc::Optional<int> codec_payload_type;
365
366 // Specifies the FEC mechanism, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800367 // TODO(deadbeef): Not implemented. Current implementation will use whatever
368 // FEC codecs are available, including red+ulpfec.
deadbeefe702b302017-02-04 12:09:01 -0800369 rtc::Optional<RtpFecParameters> fec;
370
371 // Specifies the RTX parameters, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800372 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800373 rtc::Optional<RtpRtxParameters> rtx;
374
375 // Only used for audio. If set, determines whether or not discontinuous
376 // transmission will be used, if an available codec supports it. If not
377 // set, the implementation default setting will be used.
deadbeefe814a0d2017-02-25 18:15:09 -0800378 // TODO(deadbeef): Not implemented. Current implementation will use a CN
379 // codec as long as it's present.
deadbeefe702b302017-02-04 12:09:01 -0800380 rtc::Optional<DtxStatus> dtx;
381
Seth Hampson24722b32017-12-22 09:36:42 -0800382 // The relative bitrate priority of this encoding. Currently this is
Seth Hampsona881ac02018-02-12 14:14:39 -0800383 // implemented for the entire rtp sender by using the value of the first
384 // encoding parameter.
385 // TODO(webrtc.bugs.org/8630): Implement this per encoding parameter.
386 // Currently there is logic for how bitrate is distributed per simulcast layer
387 // in the VideoBitrateAllocator. This must be updated to incorporate relative
388 // bitrate priority.
Seth Hampson24722b32017-12-22 09:36:42 -0800389 double bitrate_priority = kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -0800390
Seth Hampsonf209cb52018-02-06 14:28:16 -0800391 // Indicates the preferred duration of media represented by a packet in
392 // milliseconds for this encoding. If set, this will take precedence over the
393 // ptime set in the RtpCodecParameters. This could happen if SDP negotiation
394 // creates a ptime for a specific codec, which is later changed in the
395 // RtpEncodingParameters by the application.
396 // TODO(bugs.webrtc.org/8819): Not implemented.
397 rtc::Optional<int> ptime;
398
deadbeefe702b302017-02-04 12:09:01 -0800399 // If set, this represents the Transport Independent Application Specific
400 // maximum bandwidth defined in RFC3890. If unset, there is no maximum
Seth Hampsona881ac02018-02-12 14:14:39 -0800401 // bitrate. Currently this is implemented for the entire rtp sender by using
402 // the value of the first encoding parameter.
403 //
404 // TODO(webrtc.bugs.org/8655): Implement this per encoding parameter.
405 // Current implementation for a sender:
406 // The max bitrate is decided by taking the minimum of the first encoding
407 // parameter's max_bitrate_bps and the max bitrate specified by the sdp with
408 // the b=AS attribute. In the case of simulcast video, default values are used
409 // for each simulcast layer, and if there is some bitrate left over from the
410 // sender's max bitrate then it will roll over into the highest quality layer.
deadbeefe814a0d2017-02-25 18:15:09 -0800411 //
deadbeefe702b302017-02-04 12:09:01 -0800412 // Just called "maxBitrate" in ORTC spec.
deadbeefe814a0d2017-02-25 18:15:09 -0800413 //
414 // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total
415 // bandwidth for the entire bandwidth estimator (audio and video). This is
416 // just always how "b=AS" was handled, but it's not correct and should be
417 // fixed.
deadbeefe702b302017-02-04 12:09:01 -0800418 rtc::Optional<int> max_bitrate_bps;
419
420 // TODO(deadbeef): Not implemented.
421 rtc::Optional<int> max_framerate;
422
423 // For video, scale the resolution down by this factor.
424 // TODO(deadbeef): Not implemented.
Seth Hampson2d2c8882018-05-16 16:02:32 -0700425 rtc::Optional<double> scale_resolution_down_by;
deadbeefe702b302017-02-04 12:09:01 -0800426
427 // Scale the framerate down by this factor.
428 // TODO(deadbeef): Not implemented.
Seth Hampson2d2c8882018-05-16 16:02:32 -0700429 rtc::Optional<double> scale_framerate_down_by;
deadbeefe702b302017-02-04 12:09:01 -0800430
Seth Hampsona881ac02018-02-12 14:14:39 -0800431 // For an RtpSender, set to true to cause this encoding to be encoded and
432 // sent, and false for it not to be encoded and sent. This allows control
433 // across multiple encodings of a sender for turning simulcast layers on and
434 // off.
435 // TODO(webrtc.bugs.org/8807): Updating this parameter will trigger an encoder
436 // reset, but this isn't necessarily required.
deadbeefdbe2b872016-03-22 15:42:00 -0700437 bool active = true;
deadbeefe702b302017-02-04 12:09:01 -0800438
439 // Value to use for RID RTP header extension.
440 // Called "encodingId" in ORTC.
441 // TODO(deadbeef): Not implemented.
442 std::string rid;
443
444 // RIDs of encodings on which this layer depends.
445 // Called "dependencyEncodingIds" in ORTC spec.
446 // TODO(deadbeef): Not implemented.
447 std::vector<std::string> dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700448
449 bool operator==(const RtpEncodingParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800450 return ssrc == o.ssrc && codec_payload_type == o.codec_payload_type &&
451 fec == o.fec && rtx == o.rtx && dtx == o.dtx &&
Seth Hampsonf209cb52018-02-06 14:28:16 -0800452 bitrate_priority == o.bitrate_priority && ptime == o.ptime &&
Seth Hampson24722b32017-12-22 09:36:42 -0800453 max_bitrate_bps == o.max_bitrate_bps &&
deadbeefe702b302017-02-04 12:09:01 -0800454 max_framerate == o.max_framerate &&
455 scale_resolution_down_by == o.scale_resolution_down_by &&
456 scale_framerate_down_by == o.scale_framerate_down_by &&
457 active == o.active && rid == o.rid &&
458 dependency_rids == o.dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700459 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700460 bool operator!=(const RtpEncodingParameters& o) const {
461 return !(*this == o);
462 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700463};
464
465struct RtpCodecParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200466 RtpCodecParameters();
467 ~RtpCodecParameters();
468
deadbeefe702b302017-02-04 12:09:01 -0800469 // Build MIME "type/subtype" string from |name| and |kind|.
470 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
471
472 // Used to identify the codec. Equivalent to MIME subtype.
473 std::string name;
474
475 // The media type of this codec. Equivalent to MIME top-level type.
476 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
477
478 // Payload type used to identify this codec in RTP packets.
deadbeefe814a0d2017-02-25 18:15:09 -0800479 // This must always be present, and must be unique across all codecs using
deadbeefe702b302017-02-04 12:09:01 -0800480 // the same transport.
481 int payload_type = 0;
482
483 // If unset, the implementation default is used.
484 rtc::Optional<int> clock_rate;
485
486 // The number of audio channels used. Unset for video codecs. If unset for
487 // audio, the implementation default is used.
deadbeefe814a0d2017-02-25 18:15:09 -0800488 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
489 // Only defaults to 1, even though some codecs (such as opus) should really
490 // default to 2.
deadbeefe702b302017-02-04 12:09:01 -0800491 rtc::Optional<int> num_channels;
492
493 // The maximum packetization time to be used by an RtpSender.
494 // If |ptime| is also set, this will be ignored.
495 // TODO(deadbeef): Not implemented.
496 rtc::Optional<int> max_ptime;
497
498 // The packetization time to be used by an RtpSender.
499 // If unset, will use any time up to max_ptime.
500 // TODO(deadbeef): Not implemented.
501 rtc::Optional<int> ptime;
502
503 // Feedback mechanisms to be used for this codec.
deadbeefe814a0d2017-02-25 18:15:09 -0800504 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800505 std::vector<RtcpFeedback> rtcp_feedback;
506
507 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800508 //
deadbeefe702b302017-02-04 12:09:01 -0800509 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800510 //
511 // Contrary to ORTC, these parameters are named using all lowercase strings.
512 // This helps make the mapping to SDP simpler, if an application is using
513 // SDP. Boolean values are represented by the string "1".
deadbeefe702b302017-02-04 12:09:01 -0800514 std::unordered_map<std::string, std::string> parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700515
516 bool operator==(const RtpCodecParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800517 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
518 clock_rate == o.clock_rate && num_channels == o.num_channels &&
519 max_ptime == o.max_ptime && ptime == o.ptime &&
520 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700521 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700522 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700523};
524
deadbeefe702b302017-02-04 12:09:01 -0800525// RtpCapabilities is used to represent the static capabilities of an
526// endpoint. An application can use these capabilities to construct an
527// RtpParameters.
528struct RtpCapabilities {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200529 RtpCapabilities();
530 ~RtpCapabilities();
531
deadbeefe702b302017-02-04 12:09:01 -0800532 // Supported codecs.
533 std::vector<RtpCodecCapability> codecs;
534
535 // Supported RTP header extensions.
536 std::vector<RtpHeaderExtensionCapability> header_extensions;
537
deadbeefe814a0d2017-02-25 18:15:09 -0800538 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED,
539 // ulpfec and flexfec codecs used by these mechanisms will still appear in
540 // |codecs|.
deadbeefe702b302017-02-04 12:09:01 -0800541 std::vector<FecMechanism> fec;
542
543 bool operator==(const RtpCapabilities& o) const {
544 return codecs == o.codecs && header_extensions == o.header_extensions &&
545 fec == o.fec;
546 }
547 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
548};
549
Florent Castellidacec712018-05-24 16:24:21 +0200550struct RtcpParameters final {
551 RtcpParameters();
552 ~RtcpParameters();
553
554 // The SSRC to be used in the "SSRC of packet sender" field. If not set, one
555 // will be chosen by the implementation.
556 // TODO(deadbeef): Not implemented.
557 rtc::Optional<uint32_t> ssrc;
558
559 // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages).
560 //
561 // If empty in the construction of the RtpTransport, one will be generated by
562 // the implementation, and returned in GetRtcpParameters. Multiple
563 // RtpTransports created by the same OrtcFactory will use the same generated
564 // CNAME.
565 //
566 // If empty when passed into SetParameters, the CNAME simply won't be
567 // modified.
568 std::string cname;
569
570 // Send reduced-size RTCP?
571 bool reduced_size = false;
572
573 // Send RTCP multiplexed on the RTP transport?
574 // Not used with PeerConnection senders/receivers
575 bool mux = true;
576
577 bool operator==(const RtcpParameters& o) const {
578 return ssrc == o.ssrc && cname == o.cname &&
579 reduced_size == o.reduced_size && mux == o.mux;
580 }
581 bool operator!=(const RtcpParameters& o) const { return !(*this == o); }
582};
583
skvladdc1c62c2016-03-16 19:07:43 -0700584struct RtpParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200585 RtpParameters();
586 ~RtpParameters();
587
deadbeefe702b302017-02-04 12:09:01 -0800588 // Used when calling getParameters/setParameters with a PeerConnection
589 // RtpSender, to ensure that outdated parameters are not unintentionally
590 // applied successfully.
deadbeefe702b302017-02-04 12:09:01 -0800591 std::string transaction_id;
592
593 // Value to use for MID RTP header extension.
594 // Called "muxId" in ORTC.
595 // TODO(deadbeef): Not implemented.
596 std::string mid;
597
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700598 std::vector<RtpCodecParameters> codecs;
599
deadbeefe814a0d2017-02-25 18:15:09 -0800600 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800601 std::vector<RtpHeaderExtensionParameters> header_extensions;
602
603 std::vector<RtpEncodingParameters> encodings;
604
Florent Castellidacec712018-05-24 16:24:21 +0200605 // Only available with a Peerconnection RtpSender.
606 // In ORTC, our API includes an additional "RtpTransport"
607 // abstraction on which RTCP parameters are set.
608 RtcpParameters rtcp;
609
deadbeefe702b302017-02-04 12:09:01 -0800610 // TODO(deadbeef): Not implemented.
611 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200625#endif // API_RTPPARAMETERS_H_