blob: 221f5b6da165377eec0704cb394ea31efddb00a8 [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;
Lu Liu8b77aea2017-12-20 23:48:03 +000076enum class PriorityType { VERY_LOW, LOW, MEDIUM, HIGH };
deadbeefe702b302017-02-04 12:09:01 -080077
78struct RtcpFeedback {
deadbeefe814a0d2017-02-25 18:15:09 -080079 RtcpFeedbackType type = RtcpFeedbackType::CCM;
deadbeefe702b302017-02-04 12:09:01 -080080
81 // Equivalent to ORTC "parameter" field with slight differences:
82 // 1. It's an enum instead of a string.
83 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
84 // rather than an unset "parameter" value.
85 rtc::Optional<RtcpFeedbackMessageType> message_type;
86
deadbeefe814a0d2017-02-25 18:15:09 -080087 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +020088 RtcpFeedback();
89 explicit RtcpFeedback(RtcpFeedbackType type);
90 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type);
91 ~RtcpFeedback();
deadbeefe814a0d2017-02-25 18:15:09 -080092
deadbeefe702b302017-02-04 12:09:01 -080093 bool operator==(const RtcpFeedback& o) const {
94 return type == o.type && message_type == o.message_type;
95 }
96 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
97};
98
99// RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to
100// RtpParameters. This represents the static capabilities of an endpoint's
101// implementation of a codec.
102struct RtpCodecCapability {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200103 RtpCodecCapability();
104 ~RtpCodecCapability();
105
deadbeefe702b302017-02-04 12:09:01 -0800106 // Build MIME "type/subtype" string from |name| and |kind|.
107 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
108
109 // Used to identify the codec. Equivalent to MIME subtype.
110 std::string name;
111
112 // The media type of this codec. Equivalent to MIME top-level type.
113 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
114
115 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate.
116 rtc::Optional<int> clock_rate;
117
118 // Default payload type for this codec. Mainly needed for codecs that use
119 // that have statically assigned payload types.
120 rtc::Optional<int> preferred_payload_type;
121
122 // Maximum packetization time supported by an RtpReceiver for this codec.
123 // TODO(deadbeef): Not implemented.
124 rtc::Optional<int> max_ptime;
125
126 // Preferred packetization time for an RtpReceiver or RtpSender of this
127 // codec.
128 // TODO(deadbeef): Not implemented.
129 rtc::Optional<int> ptime;
130
131 // The number of audio channels supported. Unused for video codecs.
132 rtc::Optional<int> num_channels;
133
134 // Feedback mechanisms supported for this codec.
135 std::vector<RtcpFeedback> rtcp_feedback;
136
137 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800138 //
deadbeefe702b302017-02-04 12:09:01 -0800139 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800140 //
141 // Contrary to ORTC, these parameters are named using all lowercase strings.
142 // This helps make the mapping to SDP simpler, if an application is using
143 // SDP. Boolean values are represented by the string "1".
deadbeefe702b302017-02-04 12:09:01 -0800144 std::unordered_map<std::string, std::string> parameters;
145
146 // Codec-specific parameters that may optionally be signaled to the remote
147 // party.
148 // TODO(deadbeef): Not implemented.
149 std::unordered_map<std::string, std::string> options;
150
151 // Maximum number of temporal layer extensions supported by this codec.
152 // For example, a value of 1 indicates that 2 total layers are supported.
153 // TODO(deadbeef): Not implemented.
154 int max_temporal_layer_extensions = 0;
155
156 // Maximum number of spatial layer extensions supported by this codec.
157 // For example, a value of 1 indicates that 2 total layers are supported.
158 // TODO(deadbeef): Not implemented.
159 int max_spatial_layer_extensions = 0;
160
161 // Whether the implementation can send/receive SVC layers with distinct
162 // SSRCs. Always false for audio codecs. True for video codecs that support
163 // scalable video coding with MRST.
164 // TODO(deadbeef): Not implemented.
165 bool svc_multi_stream_support = false;
166
167 bool operator==(const RtpCodecCapability& o) const {
168 return name == o.name && kind == o.kind && clock_rate == o.clock_rate &&
169 preferred_payload_type == o.preferred_payload_type &&
170 max_ptime == o.max_ptime && ptime == o.ptime &&
171 num_channels == o.num_channels && rtcp_feedback == o.rtcp_feedback &&
172 parameters == o.parameters && options == o.options &&
173 max_temporal_layer_extensions == o.max_temporal_layer_extensions &&
174 max_spatial_layer_extensions == o.max_spatial_layer_extensions &&
175 svc_multi_stream_support == o.svc_multi_stream_support;
176 }
177 bool operator!=(const RtpCodecCapability& o) const { return !(*this == o); }
178};
179
180// Used in RtpCapabilities; represents the capabilities/preferences of an
181// implementation for a header extension.
182//
183// Just called "RtpHeaderExtension" in ORTC, but the "Capability" suffix was
184// added here for consistency and to avoid confusion with
185// RtpHeaderExtensionParameters.
186//
187// Note that ORTC includes a "kind" field, but we omit this because it's
188// redundant; if you call "RtpReceiver::GetCapabilities(MEDIA_TYPE_AUDIO)",
189// you know you're getting audio capabilities.
190struct RtpHeaderExtensionCapability {
191 // URI of this extension, as defined in RFC5285.
192 std::string uri;
193
194 // Preferred value of ID that goes in the packet.
195 rtc::Optional<int> preferred_id;
196
197 // If true, it's preferred that the value in the header is encrypted.
198 // TODO(deadbeef): Not implemented.
199 bool preferred_encrypt = false;
200
deadbeefe814a0d2017-02-25 18:15:09 -0800201 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200202 RtpHeaderExtensionCapability();
203 explicit RtpHeaderExtensionCapability(const std::string& uri);
204 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id);
205 ~RtpHeaderExtensionCapability();
deadbeefe814a0d2017-02-25 18:15:09 -0800206
deadbeefe702b302017-02-04 12:09:01 -0800207 bool operator==(const RtpHeaderExtensionCapability& o) const {
208 return uri == o.uri && preferred_id == o.preferred_id &&
209 preferred_encrypt == o.preferred_encrypt;
210 }
211 bool operator!=(const RtpHeaderExtensionCapability& o) const {
212 return !(*this == o);
213 }
214};
215
Stefan Holmer1acbd682017-09-01 15:29:28 +0200216// RTP header extension, see RFC 5285.
217struct RtpExtension {
218 RtpExtension();
219 RtpExtension(const std::string& uri, int id);
220 RtpExtension(const std::string& uri, int id, bool encrypt);
221 ~RtpExtension();
222 std::string ToString() const;
223 bool operator==(const RtpExtension& rhs) const {
224 return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt;
225 }
226 static bool IsSupportedForAudio(const std::string& uri);
227 static bool IsSupportedForVideo(const std::string& uri);
228 // Return "true" if the given RTP header extension URI may be encrypted.
229 static bool IsEncryptionSupported(const std::string& uri);
230
231 // Returns the named header extension if found among all extensions,
232 // nullptr otherwise.
233 static const RtpExtension* FindHeaderExtensionByUri(
234 const std::vector<RtpExtension>& extensions,
235 const std::string& uri);
236
237 // Return a list of RTP header extensions with the non-encrypted extensions
238 // removed if both the encrypted and non-encrypted extension is present for
239 // the same URI.
240 static std::vector<RtpExtension> FilterDuplicateNonEncrypted(
241 const std::vector<RtpExtension>& extensions);
242
243 // Header extension for audio levels, as defined in:
244 // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03
245 static const char kAudioLevelUri[];
246 static const int kAudioLevelDefaultId;
247
248 // Header extension for RTP timestamp offset, see RFC 5450 for details:
249 // http://tools.ietf.org/html/rfc5450
250 static const char kTimestampOffsetUri[];
251 static const int kTimestampOffsetDefaultId;
252
253 // Header extension for absolute send time, see url for details:
254 // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
255 static const char kAbsSendTimeUri[];
256 static const int kAbsSendTimeDefaultId;
257
258 // Header extension for coordination of video orientation, see url for
259 // details:
260 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
261 static const char kVideoRotationUri[];
262 static const int kVideoRotationDefaultId;
263
264 // Header extension for video content type. E.g. default or screenshare.
265 static const char kVideoContentTypeUri[];
266 static const int kVideoContentTypeDefaultId;
267
268 // Header extension for video timing.
269 static const char kVideoTimingUri[];
270 static const int kVideoTimingDefaultId;
271
272 // Header extension for transport sequence number, see url for details:
273 // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
274 static const char kTransportSequenceNumberUri[];
275 static const int kTransportSequenceNumberDefaultId;
276
277 static const char kPlayoutDelayUri[];
278 static const int kPlayoutDelayDefaultId;
279
280 // Encryption of Header Extensions, see RFC 6904 for details:
281 // https://tools.ietf.org/html/rfc6904
282 static const char kEncryptHeaderExtensionsUri[];
283
284 // Inclusive min and max IDs for one-byte header extensions, per RFC5285.
285 static const int kMinId;
286 static const int kMaxId;
287
288 std::string uri;
289 int id = 0;
290 bool encrypt = false;
291};
292
deadbeefe814a0d2017-02-25 18:15:09 -0800293// TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented.
294typedef RtpExtension RtpHeaderExtensionParameters;
deadbeefe702b302017-02-04 12:09:01 -0800295
296struct RtpFecParameters {
297 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800298 // Works just like RtpEncodingParameters::ssrc.
sakal1fd95952016-06-22 00:46:15 -0700299 rtc::Optional<uint32_t> ssrc;
deadbeefe702b302017-02-04 12:09:01 -0800300
301 FecMechanism mechanism = FecMechanism::RED;
302
deadbeefe814a0d2017-02-25 18:15:09 -0800303 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200304 RtpFecParameters();
305 explicit RtpFecParameters(FecMechanism mechanism);
306 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc);
307 ~RtpFecParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800308
deadbeefe702b302017-02-04 12:09:01 -0800309 bool operator==(const RtpFecParameters& o) const {
310 return ssrc == o.ssrc && mechanism == o.mechanism;
311 }
312 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
313};
314
315struct RtpRtxParameters {
316 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800317 // Works just like RtpEncodingParameters::ssrc.
deadbeefe702b302017-02-04 12:09:01 -0800318 rtc::Optional<uint32_t> ssrc;
319
deadbeefe814a0d2017-02-25 18:15:09 -0800320 // Constructors for convenience.
Stefan Holmer1acbd682017-09-01 15:29:28 +0200321 RtpRtxParameters();
322 explicit RtpRtxParameters(uint32_t ssrc);
323 ~RtpRtxParameters();
deadbeefe814a0d2017-02-25 18:15:09 -0800324
deadbeefe702b302017-02-04 12:09:01 -0800325 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
326 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
327};
328
329struct RtpEncodingParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200330 RtpEncodingParameters();
331 ~RtpEncodingParameters();
332
deadbeefe702b302017-02-04 12:09:01 -0800333 // If unset, a value is chosen by the implementation.
deadbeefe814a0d2017-02-25 18:15:09 -0800334 //
335 // Note that the chosen value is NOT returned by GetParameters, because it
336 // may change due to an SSRC conflict, in which case the conflict is handled
337 // internally without any event. Another way of looking at this is that an
338 // unset SSRC acts as a "wildcard" SSRC.
deadbeefe702b302017-02-04 12:09:01 -0800339 rtc::Optional<uint32_t> ssrc;
340
341 // Can be used to reference a codec in the |codecs| member of the
342 // RtpParameters that contains this RtpEncodingParameters. If unset, the
deadbeefe814a0d2017-02-25 18:15:09 -0800343 // implementation will choose the first possible codec (if a sender), or
344 // prepare to receive any codec (for a receiver).
345 // TODO(deadbeef): Not implemented. Implementation of RtpSender will always
346 // choose the first codec from the list.
deadbeefe702b302017-02-04 12:09:01 -0800347 rtc::Optional<int> codec_payload_type;
348
349 // Specifies the FEC mechanism, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800350 // TODO(deadbeef): Not implemented. Current implementation will use whatever
351 // FEC codecs are available, including red+ulpfec.
deadbeefe702b302017-02-04 12:09:01 -0800352 rtc::Optional<RtpFecParameters> fec;
353
354 // Specifies the RTX parameters, if set.
deadbeefe814a0d2017-02-25 18:15:09 -0800355 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800356 rtc::Optional<RtpRtxParameters> rtx;
357
358 // Only used for audio. If set, determines whether or not discontinuous
359 // transmission will be used, if an available codec supports it. If not
360 // set, the implementation default setting will be used.
deadbeefe814a0d2017-02-25 18:15:09 -0800361 // TODO(deadbeef): Not implemented. Current implementation will use a CN
362 // codec as long as it's present.
deadbeefe702b302017-02-04 12:09:01 -0800363 rtc::Optional<DtxStatus> dtx;
364
Lu Liu8b77aea2017-12-20 23:48:03 +0000365 // The relative priority of this encoding.
366 // TODO(deadbeef): Not implemented.
367 rtc::Optional<PriorityType> priority;
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 &&
Lu Liu8b77aea2017-12-20 23:48:03 +0000411 priority == o.priority && max_bitrate_bps == o.max_bitrate_bps &&
deadbeefe702b302017-02-04 12:09:01 -0800412 max_framerate == o.max_framerate &&
413 scale_resolution_down_by == o.scale_resolution_down_by &&
414 scale_framerate_down_by == o.scale_framerate_down_by &&
415 active == o.active && rid == o.rid &&
416 dependency_rids == o.dependency_rids;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700417 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700418 bool operator!=(const RtpEncodingParameters& o) const {
419 return !(*this == o);
420 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700421};
422
423struct RtpCodecParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200424 RtpCodecParameters();
425 ~RtpCodecParameters();
426
deadbeefe702b302017-02-04 12:09:01 -0800427 // Build MIME "type/subtype" string from |name| and |kind|.
428 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; }
429
430 // Used to identify the codec. Equivalent to MIME subtype.
431 std::string name;
432
433 // The media type of this codec. Equivalent to MIME top-level type.
434 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO;
435
436 // Payload type used to identify this codec in RTP packets.
deadbeefe814a0d2017-02-25 18:15:09 -0800437 // This must always be present, and must be unique across all codecs using
deadbeefe702b302017-02-04 12:09:01 -0800438 // the same transport.
439 int payload_type = 0;
440
441 // If unset, the implementation default is used.
442 rtc::Optional<int> clock_rate;
443
444 // The number of audio channels used. Unset for video codecs. If unset for
445 // audio, the implementation default is used.
deadbeefe814a0d2017-02-25 18:15:09 -0800446 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
447 // Only defaults to 1, even though some codecs (such as opus) should really
448 // default to 2.
deadbeefe702b302017-02-04 12:09:01 -0800449 rtc::Optional<int> num_channels;
450
451 // The maximum packetization time to be used by an RtpSender.
452 // If |ptime| is also set, this will be ignored.
453 // TODO(deadbeef): Not implemented.
454 rtc::Optional<int> max_ptime;
455
456 // The packetization time to be used by an RtpSender.
457 // If unset, will use any time up to max_ptime.
458 // TODO(deadbeef): Not implemented.
459 rtc::Optional<int> ptime;
460
461 // Feedback mechanisms to be used for this codec.
deadbeefe814a0d2017-02-25 18:15:09 -0800462 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800463 std::vector<RtcpFeedback> rtcp_feedback;
464
465 // Codec-specific parameters that must be signaled to the remote party.
deadbeefe814a0d2017-02-25 18:15:09 -0800466 //
deadbeefe702b302017-02-04 12:09:01 -0800467 // Corresponds to "a=fmtp" parameters in SDP.
deadbeefe814a0d2017-02-25 18:15:09 -0800468 //
469 // Contrary to ORTC, these parameters are named using all lowercase strings.
470 // This helps make the mapping to SDP simpler, if an application is using
471 // SDP. Boolean values are represented by the string "1".
472 //
473 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800474 std::unordered_map<std::string, std::string> parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700475
476 bool operator==(const RtpCodecParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800477 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
478 clock_rate == o.clock_rate && num_channels == o.num_channels &&
479 max_ptime == o.max_ptime && ptime == o.ptime &&
480 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700481 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700482 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700483};
484
deadbeefe702b302017-02-04 12:09:01 -0800485// RtpCapabilities is used to represent the static capabilities of an
486// endpoint. An application can use these capabilities to construct an
487// RtpParameters.
488struct RtpCapabilities {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200489 RtpCapabilities();
490 ~RtpCapabilities();
491
deadbeefe702b302017-02-04 12:09:01 -0800492 // Supported codecs.
493 std::vector<RtpCodecCapability> codecs;
494
495 // Supported RTP header extensions.
496 std::vector<RtpHeaderExtensionCapability> header_extensions;
497
deadbeefe814a0d2017-02-25 18:15:09 -0800498 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED,
499 // ulpfec and flexfec codecs used by these mechanisms will still appear in
500 // |codecs|.
deadbeefe702b302017-02-04 12:09:01 -0800501 std::vector<FecMechanism> fec;
502
503 bool operator==(const RtpCapabilities& o) const {
504 return codecs == o.codecs && header_extensions == o.header_extensions &&
505 fec == o.fec;
506 }
507 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); }
508};
509
deadbeefe814a0d2017-02-25 18:15:09 -0800510// Note that unlike in ORTC, an RtcpParameters structure is not included in
511// RtpParameters, because our API includes an additional "RtpTransport"
deadbeefe702b302017-02-04 12:09:01 -0800512// abstraction on which RTCP parameters are set.
skvladdc1c62c2016-03-16 19:07:43 -0700513struct RtpParameters {
Stefan Holmer1acbd682017-09-01 15:29:28 +0200514 RtpParameters();
515 ~RtpParameters();
516
deadbeefe702b302017-02-04 12:09:01 -0800517 // Used when calling getParameters/setParameters with a PeerConnection
518 // RtpSender, to ensure that outdated parameters are not unintentionally
519 // applied successfully.
520 // TODO(deadbeef): Not implemented.
521 std::string transaction_id;
522
523 // Value to use for MID RTP header extension.
524 // Called "muxId" in ORTC.
525 // TODO(deadbeef): Not implemented.
526 std::string mid;
527
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700528 std::vector<RtpCodecParameters> codecs;
529
deadbeefe814a0d2017-02-25 18:15:09 -0800530 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
deadbeefe702b302017-02-04 12:09:01 -0800531 std::vector<RtpHeaderExtensionParameters> header_extensions;
532
533 std::vector<RtpEncodingParameters> encodings;
534
535 // TODO(deadbeef): Not implemented.
536 DegradationPreference degradation_preference =
537 DegradationPreference::BALANCED;
538
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700539 bool operator==(const RtpParameters& o) const {
deadbeefe702b302017-02-04 12:09:01 -0800540 return mid == o.mid && codecs == o.codecs &&
541 header_extensions == o.header_extensions &&
542 encodings == o.encodings &&
543 degradation_preference == o.degradation_preference;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700544 }
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700545 bool operator!=(const RtpParameters& o) const { return !(*this == o); }
skvladdc1c62c2016-03-16 19:07:43 -0700546};
547
548} // namespace webrtc
549
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200550#endif // API_RTPPARAMETERS_H_