blob: e3408258605020f833211b3542d2683171fa1e86 [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
Seth Hampsonf32795e2017-12-19 11:37:41 -080075extern const double kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -080076
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
Seth Hampson24722b32017-12-22 09:36:42 -0800364 // The relative bitrate priority of this encoding. Currently this is
365 // implemented on the sender level (using the first RtpEncodingParameters
366 // of the rtp parameters).
367 double bitrate_priority = kDefaultBitratePriority;
deadbeefe702b302017-02-04 12:09:01 -0800368
369 // If set, this represents the Transport Independent Application Specific
370 // maximum bandwidth defined in RFC3890. If unset, there is no maximum
371 // bitrate.
deadbeefe814a0d2017-02-25 18:15:09 -0800372 //
deadbeefe702b302017-02-04 12:09:01 -0800373 // Just called "maxBitrate" in ORTC spec.
deadbeefe814a0d2017-02-25 18:15:09 -0800374 //
375 // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total
376 // bandwidth for the entire bandwidth estimator (audio and video). This is
377 // just always how "b=AS" was handled, but it's not correct and should be
378 // fixed.
deadbeefe702b302017-02-04 12:09:01 -0800379 rtc::Optional<int> max_bitrate_bps;
380
381 // TODO(deadbeef): Not implemented.
382 rtc::Optional<int> max_framerate;
383
384 // For video, scale the resolution down by this factor.
385 // TODO(deadbeef): Not implemented.
386 double scale_resolution_down_by = 1.0;
387
388 // Scale the framerate down by this factor.
389 // TODO(deadbeef): Not implemented.
390 double scale_framerate_down_by = 1.0;
391
392 // For an RtpSender, set to true to cause this encoding to be sent, and false
393 // for it not to be sent. For an RtpReceiver, set to true to cause the
394 // encoding to be decoded, and false for it to be ignored.
deadbeefe814a0d2017-02-25 18:15:09 -0800395 // TODO(deadbeef): Not implemented for PeerConnection RtpReceivers.
deadbeefdbe2b872016-03-22 15:42:00 -0700396 bool active = true;
deadbeefe702b302017-02-04 12:09:01 -0800397
398 // Value to use for RID RTP header extension.
399 // Called "encodingId" in ORTC.
400 // TODO(deadbeef): Not implemented.
401 std::string rid;
402
403 // RIDs of encodings on which this layer depends.
404 // Called "dependencyEncodingIds" in ORTC spec.
405 // TODO(deadbeef): Not implemented.
406 std::vector<std::string> dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700407
408 bool operator==(const RtpEncodingParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800409 return ssrc == o.ssrc && codec_payload_type == o.codec_payload_type &&
410 fec == o.fec && rtx == o.rtx && dtx == o.dtx &&
Seth Hampson24722b32017-12-22 09:36:42 -0800411 bitrate_priority == o.bitrate_priority &&
412 max_bitrate_bps == o.max_bitrate_bps &&
deadbeefe702b302017-02-04 12:09:01 -0800413 max_framerate == o.max_framerate &&
414 scale_resolution_down_by == o.scale_resolution_down_by &&
415 scale_framerate_down_by == o.scale_framerate_down_by &&
416 active == o.active && rid == o.rid &&
417 dependency_rids == o.dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700418 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700419 bool operator!=(const RtpEncodingParameters& o) const {
420 return !(*this == o);
421 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700422};
423
424struct RtpCodecParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200425 RtpCodecParameters();
426 ~RtpCodecParameters();
427
deadbeefe702b302017-02-04 12:09:01 -0800428 // Build MIME "type/subtype" string from |name| and |kind|.
429 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
430
431 // Used to identify the codec. Equivalent to MIME subtype.
432 std::string name;
433
434 // The media type of this codec. Equivalent to MIME top-level type.
435 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
436
437 // Payload type used to identify this codec in RTP packets.
deadbeefe814a0d2017-02-25 18:15:09 -0800438 // This must always be present, and must be unique across all codecs using
deadbeefe702b302017-02-04 12:09:01 -0800439 // the same transport.
440 int payload_type = 0;
441
442 // If unset, the implementation default is used.
443 rtc::Optional<int> clock_rate;
444
445 // The number of audio channels used. Unset for video codecs. If unset for
446 // audio, the implementation default is used.
deadbeefe814a0d2017-02-25 18:15:09 -0800447 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
448 // Only defaults to 1, even though some codecs (such as opus) should really
449 // default to 2.
deadbeefe702b302017-02-04 12:09:01 -0800450 rtc::Optional<int> num_channels;
451
452 // The maximum packetization time to be used by an RtpSender.
453 // If |ptime| is also set, this will be ignored.
454 // TODO(deadbeef): Not implemented.
455 rtc::Optional<int> max_ptime;
456
457 // The packetization time to be used by an RtpSender.
458 // If unset, will use any time up to max_ptime.
459 // TODO(deadbeef): Not implemented.
460 rtc::Optional<int> ptime;
461
462 // Feedback mechanisms to be used for this codec.
deadbeefe814a0d2017-02-25 18:15:09 -0800463 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800464 std::vector<RtcpFeedback> rtcp_feedback;
465
466 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800467 //
deadbeefe702b302017-02-04 12:09:01 -0800468 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800469 //
470 // Contrary to ORTC, these parameters are named using all lowercase strings.
471 // This helps make the mapping to SDP simpler, if an application is using
472 // SDP. Boolean values are represented by the string "1".
473 //
474 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800475 std::unordered_map<std::string, std::string> parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700476
477 bool operator==(const RtpCodecParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800478 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
479 clock_rate == o.clock_rate && num_channels == o.num_channels &&
480 max_ptime == o.max_ptime && ptime == o.ptime &&
481 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700482 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700483 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700484};
485
deadbeefe702b302017-02-04 12:09:01 -0800486// RtpCapabilities is used to represent the static capabilities of an
487// endpoint. An application can use these capabilities to construct an
488// RtpParameters.
489struct RtpCapabilities {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200490 RtpCapabilities();
491 ~RtpCapabilities();
492
deadbeefe702b302017-02-04 12:09:01 -0800493 // Supported codecs.
494 std::vector<RtpCodecCapability> codecs;
495
496 // Supported RTP header extensions.
497 std::vector<RtpHeaderExtensionCapability> header_extensions;
498
deadbeefe814a0d2017-02-25 18:15:09 -0800499 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED,
500 // ulpfec and flexfec codecs used by these mechanisms will still appear in
501 // |codecs|.
deadbeefe702b302017-02-04 12:09:01 -0800502 std::vector<FecMechanism> fec;
503
504 bool operator==(const RtpCapabilities& o) const {
505 return codecs == o.codecs && header_extensions == o.header_extensions &&
506 fec == o.fec;
507 }
508 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
509};
510
deadbeefe814a0d2017-02-25 18:15:09 -0800511// Note that unlike in ORTC, an RtcpParameters structure is not included in
512// RtpParameters, because our API includes an additional "RtpTransport"
deadbeefe702b302017-02-04 12:09:01 -0800513// abstraction on which RTCP parameters are set.
skvladdc1c62c2016-03-16 19:07:43 -0700514struct RtpParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200515 RtpParameters();
516 ~RtpParameters();
517
deadbeefe702b302017-02-04 12:09:01 -0800518 // Used when calling getParameters/setParameters with a PeerConnection
519 // RtpSender, to ensure that outdated parameters are not unintentionally
520 // applied successfully.
521 // TODO(deadbeef): Not implemented.
522 std::string transaction_id;
523
524 // Value to use for MID RTP header extension.
525 // Called "muxId" in ORTC.
526 // TODO(deadbeef): Not implemented.
527 std::string mid;
528
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700529 std::vector<RtpCodecParameters> codecs;
530
deadbeefe814a0d2017-02-25 18:15:09 -0800531 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800532 std::vector<RtpHeaderExtensionParameters> header_extensions;
533
534 std::vector<RtpEncodingParameters> encodings;
535
536 // TODO(deadbeef): Not implemented.
537 DegradationPreference degradation_preference =
538 DegradationPreference::BALANCED;
539
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700540 bool operator==(const RtpParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800541 return mid == o.mid && codecs == o.codecs &&
542 header_extensions == o.header_extensions &&
543 encodings == o.encodings &&
544 degradation_preference == o.degradation_preference;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700545 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700546 bool operator!=(const RtpParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700547};
548
549} // namespace webrtc
550
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200551#endif // API_RTPPARAMETERS_H_