blob: e6bd25e3aec35b2c609b58c2de6e21644964ad90 [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
69enum class DegradationPreference {
70 MAINTAIN_FRAMERATE,
71 MAINTAIN_RESOLUTION,
72 BALANCED,
73};
74
75enum class PriorityType { VERY_LOW, LOW, MEDIUM, HIGH };
76
77struct RtcpFeedback {
deadbeefe814a0d2017-02-25 18:15:09 -080078 RtcpFeedbackType type = RtcpFeedbackType::CCM;
deadbeefe702b302017-02-04 12:09:01 -080079
80 // Equivalent to ORTC "parameter" field with slight differences:
81 // 1. It's an enum instead of a string.
82 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
83 // rather than an unset "parameter" value.
84 rtc::Optional<RtcpFeedbackMessageType> message_type;
85
deadbeefe814a0d2017-02-25 18:15:09 -080086 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +020087 RtcpFeedback();
88 explicit RtcpFeedback(RtcpFeedbackType type);
89 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
90 ~RtcpFeedback();
deadbeefe814a0d2017-02-25 18:15:09 -080091
deadbeefe702b302017-02-04 12:09:01 -080092 bool operator==(const RtcpFeedback& o) const {
93 return type == o.type && message_type == o.message_type;
94 }
95 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
96};
97
98// RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to
99// RtpParameters. This represents the static capabilities of an endpoint's
100// implementation of a codec.
101struct RtpCodecCapability {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200102 RtpCodecCapability();
103 ~RtpCodecCapability();
104
deadbeefe702b302017-02-04 12:09:01 -0800105 // Build MIME "type/subtype" string from |name| and |kind|.
106 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
107
108 // Used to identify the codec. Equivalent to MIME subtype.
109 std::string name;
110
111 // The media type of this codec. Equivalent to MIME top-level type.
112 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
113
114 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate.
115 rtc::Optional<int> clock_rate;
116
117 // Default payload type for this codec. Mainly needed for codecs that use
118 // that have statically assigned payload types.
119 rtc::Optional<int> preferred_payload_type;
120
121 // Maximum packetization time supported by an RtpReceiver for this codec.
122 // TODO(deadbeef): Not implemented.
123 rtc::Optional<int> max_ptime;
124
125 // Preferred packetization time for an RtpReceiver or RtpSender of this
126 // codec.
127 // TODO(deadbeef): Not implemented.
128 rtc::Optional<int> ptime;
129
130 // The number of audio channels supported. Unused for video codecs.
131 rtc::Optional<int> num_channels;
132
133 // Feedback mechanisms supported for this codec.
134 std::vector<RtcpFeedback> rtcp_feedback;
135
136 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800137 //
deadbeefe702b302017-02-04 12:09:01 -0800138 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800139 //
140 // Contrary to ORTC, these parameters are named using all lowercase strings.
141 // This helps make the mapping to SDP simpler, if an application is using
142 // SDP. Boolean values are represented by the string "1".
deadbeefe702b302017-02-04 12:09:01 -0800143 std::unordered_map<std::string, std::string> parameters;
144
145 // Codec-specific parameters that may optionally be signaled to the remote
146 // party.
147 // TODO(deadbeef): Not implemented.
148 std::unordered_map<std::string, std::string> options;
149
150 // Maximum number of temporal layer extensions supported by this codec.
151 // For example, a value of 1 indicates that 2 total layers are supported.
152 // TODO(deadbeef): Not implemented.
153 int max_temporal_layer_extensions = 0;
154
155 // Maximum number of spatial layer extensions supported by this codec.
156 // For example, a value of 1 indicates that 2 total layers are supported.
157 // TODO(deadbeef): Not implemented.
158 int max_spatial_layer_extensions = 0;
159
160 // Whether the implementation can send/receive SVC layers with distinct
161 // SSRCs. Always false for audio codecs. True for video codecs that support
162 // scalable video coding with MRST.
163 // TODO(deadbeef): Not implemented.
164 bool svc_multi_stream_support = false;
165
166 bool operator==(const RtpCodecCapability& o) const {
167 return name == o.name && kind == o.kind && clock_rate == o.clock_rate &&
168 preferred_payload_type == o.preferred_payload_type &&
169 max_ptime == o.max_ptime && ptime == o.ptime &&
170 num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback &&
171 parameters == o.parameters && options == o.options &&
172 max_temporal_layer_extensions == o.max_temporal_layer_extensions &&
173 max_spatial_layer_extensions == o.max_spatial_layer_extensions &&
174 svc_multi_stream_support == o.svc_multi_stream_support;
175 }
176 bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
177};
178
179// Used in RtpCapabilities; represents the capabilities/preferences of an
180// implementation for a header extension.
181//
182// Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was
183// added here for consistency and to avoid confusion with
184// RtpHeaderExtensionParameters.
185//
186// Note that ORTC includes a "kind" field, but we omit this because it's
187// redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)",
188// you know you're getting audio capabilities.
189struct RtpHeaderExtensionCapability {
190 // URI of this extension, as defined in RFC5285.
191 std::string uri;
192
193 // Preferred value of ID that goes in the packet.
194 rtc::Optional<int> preferred_id;
195
196 // If true, it's preferred that the value in the header is encrypted.
197 // TODO(deadbeef): Not implemented.
198 bool preferred_encrypt = false;
199
deadbeefe814a0d2017-02-25 18:15:09 -0800200 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200201 RtpHeaderExtensionCapability();
202 explicit RtpHeaderExtensionCapability(const std::string& uri);
203 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
204 ~RtpHeaderExtensionCapability();
deadbeefe814a0d2017-02-25 18:15:09 -0800205
deadbeefe702b302017-02-04 12:09:01 -0800206 bool operator==(const RtpHeaderExtensionCapability& o) const {
207 return uri == o.uri && preferred_id == o.preferred_id &&
208 preferred_encrypt == o.preferred_encrypt;
209 }
210 bool operator!=(const RtpHeaderExtensionCapability& o) const {
211 return !(*this == o);
212 }
213};
214
Stefan Holmer1acbd682017-09-01 15:29:28 +0200215// RTP header extension, see RFC 5285.
216struct RtpExtension {
217 RtpExtension();
218 RtpExtension(const std::string& uri, int id);
219 RtpExtension(const std::string& uri, int id, bool encrypt);
220 ~RtpExtension();
221 std::string ToString() const;
222 bool operator==(const RtpExtension& rhs) const {
223 return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
224 }
225 static bool IsSupportedForAudio(const std::string& uri);
226 static bool IsSupportedForVideo(const std::string& uri);
227 // Return "true" if the given RTP header extension URI may be encrypted.
228 static bool IsEncryptionSupported(const std::string& uri);
229
230 // Returns the named header extension if found among all extensions,
231 // nullptr otherwise.
232 static const RtpExtension* FindHeaderExtensionByUri(
233 const std::vector<RtpExtension>& extensions,
234 const std::string& uri);
235
236 // Return a list of RTP header extensions with the non-encrypted extensions
237 // removed if both the encrypted and non-encrypted extension is present for
238 // the same URI.
239 static std::vector<RtpExtension> FilterDuplicateNonEncrypted(
240 const std::vector<RtpExtension>& extensions);
241
242 // Header extension for audio levels, as defined in:
243 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
244 static const char kAudioLevelUri[];
245 static const int kAudioLevelDefaultId;
246
247 // Header extension for RTP timestamp offset, see RFC 5450 for details:
248 // http://tools.ietf.org/html/rfc5450
249 static const char kTimestampOffsetUri[];
250 static const int kTimestampOffsetDefaultId;
251
252 // Header extension for absolute send time, see url for details:
253 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
254 static const char kAbsSendTimeUri[];
255 static const int kAbsSendTimeDefaultId;
256
257 // Header extension for coordination of video orientation, see url for
258 // details:
259 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
260 static const char kVideoRotationUri[];
261 static const int kVideoRotationDefaultId;
262
263 // Header extension for video content type. E.g. default or screenshare.
264 static const char kVideoContentTypeUri[];
265 static const int kVideoContentTypeDefaultId;
266
267 // Header extension for video timing.
268 static const char kVideoTimingUri[];
269 static const int kVideoTimingDefaultId;
270
271 // Header extension for transport sequence number, see url for details:
272 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
273 static const char kTransportSequenceNumberUri[];
274 static const int kTransportSequenceNumberDefaultId;
275
276 static const char kPlayoutDelayUri[];
277 static const int kPlayoutDelayDefaultId;
278
279 // Encryption of Header Extensions, see RFC 6904 for details:
280 // https://tools.ietf.org/html/rfc6904
281 static const char kEncryptHeaderExtensionsUri[];
282
283 // Inclusive min and max IDs for one-byte header extensions, per RFC5285.
284 static const int kMinId;
285 static const int kMaxId;
286
287 std::string uri;
288 int id = 0;
289 bool encrypt = false;
290};
291
deadbeefe814a0d2017-02-25 18:15:09 -0800292// TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented.
293typedef RtpExtension RtpHeaderExtensionParameters;
deadbeefe702b302017-02-04 12:09:01 -0800294
295struct RtpFecParameters {
296 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800297 // Works just like RtpEncodingParameters::ssrc.
sakal1fd95952016-06-22 00:46:15 -0700298 rtc::Optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800299
300 FecMechanism mechanism = FecMechanism::RED;
301
deadbeefe814a0d2017-02-25 18:15:09 -0800302 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200303 RtpFecParameters();
304 explicit RtpFecParameters(FecMechanism mechanism);
305 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
306 ~RtpFecParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800307
deadbeefe702b302017-02-04 12:09:01 -0800308 bool operator==(const RtpFecParameters& o) const {
309 return ssrc == o.ssrc && mechanism == o.mechanism;
310 }
311 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
312};
313
314struct RtpRtxParameters {
315 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800316 // Works just like RtpEncodingParameters::ssrc.
deadbeefe702b302017-02-04 12:09:01 -0800317 rtc::Optional<uint32_t> ssrc;
318
deadbeefe814a0d2017-02-25 18:15:09 -0800319 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200320 RtpRtxParameters();
321 explicit RtpRtxParameters(uint32_t ssrc);
322 ~RtpRtxParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800323
deadbeefe702b302017-02-04 12:09:01 -0800324 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
325 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
326};
327
328struct RtpEncodingParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200329 RtpEncodingParameters();
330 ~RtpEncodingParameters();
331
deadbeefe702b302017-02-04 12:09:01 -0800332 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800333 //
334 // Note that the chosen value is NOT returned by GetParameters, because it
335 // may change due to an SSRC conflict, in which case the conflict is handled
336 // internally without any event. Another way of looking at this is that an
337 // unset SSRC acts as a "wildcard" SSRC.
deadbeefe702b302017-02-04 12:09:01 -0800338 rtc::Optional<uint32_t> ssrc;
339
340 // Can be used to reference a codec in the |codecs| member of the
341 // RtpParameters that contains this RtpEncodingParameters. If unset, the
deadbeefe814a0d2017-02-25 18:15:09 -0800342 // implementation will choose the first possible codec (if a sender), or
343 // prepare to receive any codec (for a receiver).
344 // TODO(deadbeef): Not implemented. Implementation of RtpSender will always
345 // choose the first codec from the list.
deadbeefe702b302017-02-04 12:09:01 -0800346 rtc::Optional<int> codec_payload_type;
347
348 // Specifies the FEC mechanism, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800349 // TODO(deadbeef): Not implemented. Current implementation will use whatever
350 // FEC codecs are available, including red+ulpfec.
deadbeefe702b302017-02-04 12:09:01 -0800351 rtc::Optional<RtpFecParameters> fec;
352
353 // Specifies the RTX parameters, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800354 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800355 rtc::Optional<RtpRtxParameters> rtx;
356
357 // Only used for audio. If set, determines whether or not discontinuous
358 // transmission will be used, if an available codec supports it. If not
359 // set, the implementation default setting will be used.
deadbeefe814a0d2017-02-25 18:15:09 -0800360 // TODO(deadbeef): Not implemented. Current implementation will use a CN
361 // codec as long as it's present.
deadbeefe702b302017-02-04 12:09:01 -0800362 rtc::Optional<DtxStatus> dtx;
363
364 // The relative priority of this encoding.
365 // TODO(deadbeef): Not implemented.
366 rtc::Optional<PriorityType> priority;
367
368 // If set, this represents the Transport Independent Application Specific
369 // maximum bandwidth defined in RFC3890. If unset, there is no maximum
370 // bitrate.
deadbeefe814a0d2017-02-25 18:15:09 -0800371 //
deadbeefe702b302017-02-04 12:09:01 -0800372 // Just called "maxBitrate" in ORTC spec.
deadbeefe814a0d2017-02-25 18:15:09 -0800373 //
374 // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total
375 // bandwidth for the entire bandwidth estimator (audio and video). This is
376 // just always how "b=AS" was handled, but it's not correct and should be
377 // fixed.
deadbeefe702b302017-02-04 12:09:01 -0800378 rtc::Optional<int> max_bitrate_bps;
379
380 // TODO(deadbeef): Not implemented.
381 rtc::Optional<int> max_framerate;
382
383 // For video, scale the resolution down by this factor.
384 // TODO(deadbeef): Not implemented.
385 double scale_resolution_down_by = 1.0;
386
387 // Scale the framerate down by this factor.
388 // TODO(deadbeef): Not implemented.
389 double scale_framerate_down_by = 1.0;
390
391 // For an RtpSender, set to true to cause this encoding to be sent, and false
392 // for it not to be sent. For an RtpReceiver, set to true to cause the
393 // encoding to be decoded, and false for it to be ignored.
deadbeefe814a0d2017-02-25 18:15:09 -0800394 // TODO(deadbeef): Not implemented for PeerConnection RtpReceivers.
deadbeefdbe2b872016-03-22 15:42:00 -0700395 bool active = true;
deadbeefe702b302017-02-04 12:09:01 -0800396
397 // Value to use for RID RTP header extension.
398 // Called "encodingId" in ORTC.
399 // TODO(deadbeef): Not implemented.
400 std::string rid;
401
402 // RIDs of encodings on which this layer depends.
403 // Called "dependencyEncodingIds" in ORTC spec.
404 // TODO(deadbeef): Not implemented.
405 std::vector<std::string> dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700406
407 bool operator==(const RtpEncodingParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800408 return ssrc == o.ssrc && codec_payload_type == o.codec_payload_type &&
409 fec == o.fec && rtx == o.rtx && dtx == o.dtx &&
410 priority == o.priority && max_bitrate_bps == o.max_bitrate_bps &&
411 max_framerate == o.max_framerate &&
412 scale_resolution_down_by == o.scale_resolution_down_by &&
413 scale_framerate_down_by == o.scale_framerate_down_by &&
414 active == o.active && rid == o.rid &&
415 dependency_rids == o.dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700416 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700417 bool operator!=(const RtpEncodingParameters& o) const {
418 return !(*this == o);
419 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700420};
421
422struct RtpCodecParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200423 RtpCodecParameters();
424 ~RtpCodecParameters();
425
deadbeefe702b302017-02-04 12:09:01 -0800426 // Build MIME "type/subtype" string from |name| and |kind|.
427 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
428
429 // Used to identify the codec. Equivalent to MIME subtype.
430 std::string name;
431
432 // The media type of this codec. Equivalent to MIME top-level type.
433 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
434
435 // Payload type used to identify this codec in RTP packets.
deadbeefe814a0d2017-02-25 18:15:09 -0800436 // This must always be present, and must be unique across all codecs using
deadbeefe702b302017-02-04 12:09:01 -0800437 // the same transport.
438 int payload_type = 0;
439
440 // If unset, the implementation default is used.
441 rtc::Optional<int> clock_rate;
442
443 // The number of audio channels used. Unset for video codecs. If unset for
444 // audio, the implementation default is used.
deadbeefe814a0d2017-02-25 18:15:09 -0800445 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
446 // Only defaults to 1, even though some codecs (such as opus) should really
447 // default to 2.
deadbeefe702b302017-02-04 12:09:01 -0800448 rtc::Optional<int> num_channels;
449
450 // The maximum packetization time to be used by an RtpSender.
451 // If |ptime| is also set, this will be ignored.
452 // TODO(deadbeef): Not implemented.
453 rtc::Optional<int> max_ptime;
454
455 // The packetization time to be used by an RtpSender.
456 // If unset, will use any time up to max_ptime.
457 // TODO(deadbeef): Not implemented.
458 rtc::Optional<int> ptime;
459
460 // Feedback mechanisms to be used for this codec.
deadbeefe814a0d2017-02-25 18:15:09 -0800461 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800462 std::vector<RtcpFeedback> rtcp_feedback;
463
464 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800465 //
deadbeefe702b302017-02-04 12:09:01 -0800466 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800467 //
468 // Contrary to ORTC, these parameters are named using all lowercase strings.
469 // This helps make the mapping to SDP simpler, if an application is using
470 // SDP. Boolean values are represented by the string "1".
471 //
472 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800473 std::unordered_map<std::string, std::string> parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700474
475 bool operator==(const RtpCodecParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800476 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
477 clock_rate == o.clock_rate && num_channels == o.num_channels &&
478 max_ptime == o.max_ptime && ptime == o.ptime &&
479 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700480 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700481 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700482};
483
deadbeefe702b302017-02-04 12:09:01 -0800484// RtpCapabilities is used to represent the static capabilities of an
485// endpoint. An application can use these capabilities to construct an
486// RtpParameters.
487struct RtpCapabilities {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200488 RtpCapabilities();
489 ~RtpCapabilities();
490
deadbeefe702b302017-02-04 12:09:01 -0800491 // Supported codecs.
492 std::vector<RtpCodecCapability> codecs;
493
494 // Supported RTP header extensions.
495 std::vector<RtpHeaderExtensionCapability> header_extensions;
496
deadbeefe814a0d2017-02-25 18:15:09 -0800497 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED,
498 // ulpfec and flexfec codecs used by these mechanisms will still appear in
499 // |codecs|.
deadbeefe702b302017-02-04 12:09:01 -0800500 std::vector<FecMechanism> fec;
501
502 bool operator==(const RtpCapabilities& o) const {
503 return codecs == o.codecs && header_extensions == o.header_extensions &&
504 fec == o.fec;
505 }
506 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
507};
508
deadbeefe814a0d2017-02-25 18:15:09 -0800509// Note that unlike in ORTC, an RtcpParameters structure is not included in
510// RtpParameters, because our API includes an additional "RtpTransport"
deadbeefe702b302017-02-04 12:09:01 -0800511// abstraction on which RTCP parameters are set.
skvladdc1c62c2016-03-16 19:07:43 -0700512struct RtpParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200513 RtpParameters();
514 ~RtpParameters();
515
deadbeefe702b302017-02-04 12:09:01 -0800516 // Used when calling getParameters/setParameters with a PeerConnection
517 // RtpSender, to ensure that outdated parameters are not unintentionally
518 // applied successfully.
519 // TODO(deadbeef): Not implemented.
520 std::string transaction_id;
521
522 // Value to use for MID RTP header extension.
523 // Called "muxId" in ORTC.
524 // TODO(deadbeef): Not implemented.
525 std::string mid;
526
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700527 std::vector<RtpCodecParameters> codecs;
528
deadbeefe814a0d2017-02-25 18:15:09 -0800529 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800530 std::vector<RtpHeaderExtensionParameters> header_extensions;
531
532 std::vector<RtpEncodingParameters> encodings;
533
534 // TODO(deadbeef): Not implemented.
535 DegradationPreference degradation_preference =
536 DegradationPreference::BALANCED;
537
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700538 bool operator==(const RtpParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800539 return mid == o.mid && codecs == o.codecs &&
540 header_extensions == o.header_extensions &&
541 encodings == o.encodings &&
542 degradation_preference == o.degradation_preference;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700543 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700544 bool operator!=(const RtpParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700545};
546
547} // namespace webrtc
548
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200549#endif // API_RTPPARAMETERS_H_