Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1367)

Side by Side Diff: webrtc/api/rtpparameters.h

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Adding OrtcFactory unit tests. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_API_RTPPARAMETERS_H_ 11 #ifndef WEBRTC_API_RTPPARAMETERS_H_
12 #define WEBRTC_API_RTPPARAMETERS_H_ 12 #define WEBRTC_API_RTPPARAMETERS_H_
13 13
14 #include <string> 14 #include <string>
15 #include <unordered_map> 15 #include <unordered_map>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/api/mediatypes.h" 18 #include "webrtc/api/mediatypes.h"
19 #include "webrtc/config.h"
19 #include "webrtc/base/optional.h" 20 #include "webrtc/base/optional.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 // These structures are intended to mirror those defined by: 24 // These structures are intended to mirror those defined by:
24 // http://draft.ortc.org/#rtcrtpdictionaries* 25 // http://draft.ortc.org/#rtcrtpdictionaries*
25 // Contains everything specified as of 2017 Jan 24. 26 // Contains everything specified as of 2017 Jan 24.
26 // 27 //
27 // They are used when retrieving or modifying the parameters of an 28 // They are used when retrieving or modifying the parameters of an
28 // RtpSender/RtpReceiver, or retrieving capabilities. 29 // RtpSender/RtpReceiver, or retrieving capabilities.
(...skipping 11 matching lines...) Expand all
40 // identifier is used. 41 // identifier is used.
41 42
42 enum class FecMechanism { 43 enum class FecMechanism {
43 RED, 44 RED,
44 RED_AND_ULPFEC, 45 RED_AND_ULPFEC,
45 FLEXFEC, 46 FLEXFEC,
46 }; 47 };
47 48
48 // Used in RtcpFeedback struct. 49 // Used in RtcpFeedback struct.
49 enum class RtcpFeedbackType { 50 enum class RtcpFeedbackType {
50 ACK,
51 CCM, 51 CCM,
52 NACK, 52 NACK,
53 REMB, // "goog-remb" 53 REMB, // "goog-remb"
54 TRANSPORT_CC, 54 TRANSPORT_CC,
55 }; 55 };
56 56
57 // Used in RtcpFeedback struct when type is ACK, NACK or CCM. 57 // Used in RtcpFeedback struct when type is NACK or CCM.
58 enum class RtcpFeedbackMessageType { 58 enum class RtcpFeedbackMessageType {
59 // Equivalent to {type: "nack", parameter: undefined} in ORTC. 59 // Equivalent to {type: "nack", parameter: undefined} in ORTC.
60 GENERIC_NACK, 60 GENERIC_NACK,
61 PLI, // Usable with NACK. 61 PLI, // Usable with NACK.
62 FIR, // Usable with CCM. 62 FIR, // Usable with CCM.
63 }; 63 };
64 64
65 enum class DtxStatus { 65 enum class DtxStatus {
66 DISABLED, 66 DISABLED,
67 ENABLED, 67 ENABLED,
68 }; 68 };
69 69
70 enum class DegradationPreference { 70 enum class DegradationPreference {
71 MAINTAIN_FRAMERATE, 71 MAINTAIN_FRAMERATE,
72 MAINTAIN_RESOLUTION, 72 MAINTAIN_RESOLUTION,
73 BALANCED, 73 BALANCED,
74 }; 74 };
75 75
76 enum class PriorityType { VERY_LOW, LOW, MEDIUM, HIGH }; 76 enum class PriorityType { VERY_LOW, LOW, MEDIUM, HIGH };
77 77
78 struct RtcpFeedback { 78 struct RtcpFeedback {
79 RtcpFeedbackType type = RtcpFeedbackType::ACK; 79 RtcpFeedbackType type = RtcpFeedbackType::CCM;
80 80
81 // Equivalent to ORTC "parameter" field with slight differences: 81 // Equivalent to ORTC "parameter" field with slight differences:
82 // 1. It's an enum instead of a string. 82 // 1. It's an enum instead of a string.
83 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, 83 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type,
84 // rather than an unset "parameter" value. 84 // rather than an unset "parameter" value.
85 rtc::Optional<RtcpFeedbackMessageType> message_type; 85 rtc::Optional<RtcpFeedbackMessageType> message_type;
86 86
87 // Constructors for convenience.
88 RtcpFeedback() {}
89 explicit RtcpFeedback(RtcpFeedbackType type) : type(type) {}
90 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type)
91 : type(type), message_type(message_type) {}
92
87 bool operator==(const RtcpFeedback& o) const { 93 bool operator==(const RtcpFeedback& o) const {
88 return type == o.type && message_type == o.message_type; 94 return type == o.type && message_type == o.message_type;
89 } 95 }
90 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); } 96 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); }
91 }; 97 };
92 98
93 // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to 99 // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to
94 // RtpParameters. This represents the static capabilities of an endpoint's 100 // RtpParameters. This represents the static capabilities of an endpoint's
95 // implementation of a codec. 101 // implementation of a codec.
96 struct RtpCodecCapability { 102 struct RtpCodecCapability {
(...skipping 22 matching lines...) Expand all
119 // TODO(deadbeef): Not implemented. 125 // TODO(deadbeef): Not implemented.
120 rtc::Optional<int> ptime; 126 rtc::Optional<int> ptime;
121 127
122 // The number of audio channels supported. Unused for video codecs. 128 // The number of audio channels supported. Unused for video codecs.
123 rtc::Optional<int> num_channels; 129 rtc::Optional<int> num_channels;
124 130
125 // Feedback mechanisms supported for this codec. 131 // Feedback mechanisms supported for this codec.
126 std::vector<RtcpFeedback> rtcp_feedback; 132 std::vector<RtcpFeedback> rtcp_feedback;
127 133
128 // Codec-specific parameters that must be signaled to the remote party. 134 // Codec-specific parameters that must be signaled to the remote party.
135 //
129 // Corresponds to "a=fmtp" parameters in SDP. 136 // Corresponds to "a=fmtp" parameters in SDP.
137 //
138 // Contrary to ORTC, these parameters are named using all lowercase strings.
139 // This helps make the mapping to SDP simpler, if an application is using
140 // SDP. Boolean values are represented by the string "1".
130 std::unordered_map<std::string, std::string> parameters; 141 std::unordered_map<std::string, std::string> parameters;
131 142
132 // Codec-specific parameters that may optionally be signaled to the remote 143 // Codec-specific parameters that may optionally be signaled to the remote
133 // party. 144 // party.
134 // TODO(deadbeef): Not implemented. 145 // TODO(deadbeef): Not implemented.
135 std::unordered_map<std::string, std::string> options; 146 std::unordered_map<std::string, std::string> options;
136 147
137 // Maximum number of temporal layer extensions supported by this codec. 148 // Maximum number of temporal layer extensions supported by this codec.
138 // For example, a value of 1 indicates that 2 total layers are supported. 149 // For example, a value of 1 indicates that 2 total layers are supported.
139 // TODO(deadbeef): Not implemented. 150 // TODO(deadbeef): Not implemented.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // URI of this extension, as defined in RFC5285. 188 // URI of this extension, as defined in RFC5285.
178 std::string uri; 189 std::string uri;
179 190
180 // Preferred value of ID that goes in the packet. 191 // Preferred value of ID that goes in the packet.
181 rtc::Optional<int> preferred_id; 192 rtc::Optional<int> preferred_id;
182 193
183 // If true, it's preferred that the value in the header is encrypted. 194 // If true, it's preferred that the value in the header is encrypted.
184 // TODO(deadbeef): Not implemented. 195 // TODO(deadbeef): Not implemented.
185 bool preferred_encrypt = false; 196 bool preferred_encrypt = false;
186 197
198 // Constructors for convenience.
199 RtpHeaderExtensionCapability() = default;
200 explicit RtpHeaderExtensionCapability(const std::string& uri) : uri(uri) {}
201 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id)
202 : uri(uri), preferred_id(preferred_id) {}
203
187 bool operator==(const RtpHeaderExtensionCapability& o) const { 204 bool operator==(const RtpHeaderExtensionCapability& o) const {
188 return uri == o.uri && preferred_id == o.preferred_id && 205 return uri == o.uri && preferred_id == o.preferred_id &&
189 preferred_encrypt == o.preferred_encrypt; 206 preferred_encrypt == o.preferred_encrypt;
190 } 207 }
191 bool operator!=(const RtpHeaderExtensionCapability& o) const { 208 bool operator!=(const RtpHeaderExtensionCapability& o) const {
192 return !(*this == o); 209 return !(*this == o);
193 } 210 }
194 }; 211 };
195 212
196 // Used in RtpParameters; represents a specific configuration of a header 213 // See webrtc/config.h. Has "uri" and "id" fields.
197 // extension. 214 // TODO(deadbeef): This is missing "encrypt" flag, which is unimplemented.
198 struct RtpHeaderExtensionParameters { 215 typedef RtpExtension RtpHeaderExtensionParameters;
199 // URI of this extension, as defined in RFC5285.
200 std::string uri;
201
202 // ID value that goes in the packet.
203 int id = 0;
204
205 // If true, the value in the header is encrypted.
206 // TODO(deadbeef): Not implemented.
207 bool encrypt = false;
208
209 bool operator==(const RtpHeaderExtensionParameters& o) const {
210 return uri == o.uri && id == o.id && encrypt == o.encrypt;
211 }
212 bool operator!=(const RtpHeaderExtensionParameters& o) const {
213 return !(*this == o);
214 }
215 };
216 216
217 struct RtpFecParameters { 217 struct RtpFecParameters {
218 // If unset, a value is chosen by the implementation. 218 // If unset, a value is chosen by the implementation.
219 // Works just like RtpEncodingParameters.ssrc.
219 rtc::Optional<uint32_t> ssrc; 220 rtc::Optional<uint32_t> ssrc;
220 221
221 FecMechanism mechanism = FecMechanism::RED; 222 FecMechanism mechanism = FecMechanism::RED;
222 223
224 // Constructors for convenience.
225 RtpFecParameters() = default;
226 explicit RtpFecParameters(FecMechanism mechanism) : mechanism(mechanism) {}
227 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc)
228 : ssrc(ssrc), mechanism(mechanism) {}
229
223 bool operator==(const RtpFecParameters& o) const { 230 bool operator==(const RtpFecParameters& o) const {
224 return ssrc == o.ssrc && mechanism == o.mechanism; 231 return ssrc == o.ssrc && mechanism == o.mechanism;
225 } 232 }
226 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); } 233 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); }
227 }; 234 };
228 235
229 struct RtpRtxParameters { 236 struct RtpRtxParameters {
230 // If unset, a value is chosen by the implementation. 237 // If unset, a value is chosen by the implementation.
238 // Works just like RtpEncodingParameters.ssrc.
231 rtc::Optional<uint32_t> ssrc; 239 rtc::Optional<uint32_t> ssrc;
232 240
241 // Constructors for convenience.
242 RtpRtxParameters() = default;
243 explicit RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {}
244
233 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } 245 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; }
234 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } 246 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); }
235 }; 247 };
236 248
237 struct RtpEncodingParameters { 249 struct RtpEncodingParameters {
238 // If unset, a value is chosen by the implementation. 250 // If unset, a value is chosen by the implementation.
251 // Note that the chosen value is NOT returned by GetParameters, because it
252 // may change due to an SSRC conflict, in which case the conflict is handled
253 // internally without any event.
239 rtc::Optional<uint32_t> ssrc; 254 rtc::Optional<uint32_t> ssrc;
240 255
241 // Can be used to reference a codec in the |codecs| member of the 256 // Can be used to reference a codec in the |codecs| member of the
242 // RtpParameters that contains this RtpEncodingParameters. If unset, the 257 // RtpParameters that contains this RtpEncodingParameters. If unset, the
243 // implementation will choose the first possible codec. 258 // implementation will choose the first possible codec (if a sender), or
244 // TODO(deadbeef): Not implemented. 259 // prepare to receive any codec (for a receiver).
260 // TODO(deadbeef): Not implemented. Implementation will always choose the
261 // first codec from the list.
245 rtc::Optional<int> codec_payload_type; 262 rtc::Optional<int> codec_payload_type;
246 263
247 // Specifies the FEC mechanism, if set. 264 // Specifies the FEC mechanism, if set.
248 // TODO(deadbeef): Not implemented. 265 // TODO(deadbeef): Not implemented. Current implementation will use whatever
266 // FEC codecs are available, including red+ulpfec.
249 rtc::Optional<RtpFecParameters> fec; 267 rtc::Optional<RtpFecParameters> fec;
250 268
251 // Specifies the RTX parameters, if set. 269 // Specifies the RTX parameters, if set.
252 // TODO(deadbeef): Not implemented. 270 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
253 rtc::Optional<RtpRtxParameters> rtx; 271 rtc::Optional<RtpRtxParameters> rtx;
254 272
255 // Only used for audio. If set, determines whether or not discontinuous 273 // Only used for audio. If set, determines whether or not discontinuous
256 // transmission will be used, if an available codec supports it. If not 274 // transmission will be used, if an available codec supports it. If not
257 // set, the implementation default setting will be used. 275 // set, the implementation default setting will be used.
276 // TODO(deadbeef): Not implemented. Current implementation will use a CN
277 // codec as long as it's present.
258 rtc::Optional<DtxStatus> dtx; 278 rtc::Optional<DtxStatus> dtx;
259 279
260 // The relative priority of this encoding. 280 // The relative priority of this encoding.
261 // TODO(deadbeef): Not implemented. 281 // TODO(deadbeef): Not implemented.
262 rtc::Optional<PriorityType> priority; 282 rtc::Optional<PriorityType> priority;
263 283
264 // If set, this represents the Transport Independent Application Specific 284 // If set, this represents the Transport Independent Application Specific
265 // maximum bandwidth defined in RFC3890. If unset, there is no maximum 285 // maximum bandwidth defined in RFC3890. If unset, there is no maximum
266 // bitrate. 286 // bitrate.
287 //
267 // Just called "maxBitrate" in ORTC spec. 288 // Just called "maxBitrate" in ORTC spec.
289 //
290 // TODO(deadbeef): With ORTC RtpSenders, this currently sets the total
291 // bandwidth for the entire bandwidth estimator (audio and video). This is
292 // just always how "b=AS" was handled, but it's not correct and should be
293 // fixed.
268 rtc::Optional<int> max_bitrate_bps; 294 rtc::Optional<int> max_bitrate_bps;
269 295
270 // TODO(deadbeef): Not implemented. 296 // TODO(deadbeef): Not implemented.
271 rtc::Optional<int> max_framerate; 297 rtc::Optional<int> max_framerate;
272 298
273 // For video, scale the resolution down by this factor. 299 // For video, scale the resolution down by this factor.
274 // TODO(deadbeef): Not implemented. 300 // TODO(deadbeef): Not implemented.
275 double scale_resolution_down_by = 1.0; 301 double scale_resolution_down_by = 1.0;
276 302
277 // Scale the framerate down by this factor. 303 // Scale the framerate down by this factor.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // Payload type used to identify this codec in RTP packets. 348 // Payload type used to identify this codec in RTP packets.
323 // This MUST always be present, and must be unique across all codecs using 349 // This MUST always be present, and must be unique across all codecs using
324 // the same transport. 350 // the same transport.
325 int payload_type = 0; 351 int payload_type = 0;
326 352
327 // If unset, the implementation default is used. 353 // If unset, the implementation default is used.
328 rtc::Optional<int> clock_rate; 354 rtc::Optional<int> clock_rate;
329 355
330 // The number of audio channels used. Unset for video codecs. If unset for 356 // The number of audio channels used. Unset for video codecs. If unset for
331 // audio, the implementation default is used. 357 // audio, the implementation default is used.
332 // TODO(deadbeef): The "implementation default" part is unimplemented. 358 // TODO(deadbeef): The "implementation default" part isn't fully implemented.
359 // Only defaults to 1.
333 rtc::Optional<int> num_channels; 360 rtc::Optional<int> num_channels;
334 361
335 // The maximum packetization time to be used by an RtpSender. 362 // The maximum packetization time to be used by an RtpSender.
336 // If |ptime| is also set, this will be ignored. 363 // If |ptime| is also set, this will be ignored.
337 // TODO(deadbeef): Not implemented. 364 // TODO(deadbeef): Not implemented.
338 rtc::Optional<int> max_ptime; 365 rtc::Optional<int> max_ptime;
339 366
340 // The packetization time to be used by an RtpSender. 367 // The packetization time to be used by an RtpSender.
341 // If unset, will use any time up to max_ptime. 368 // If unset, will use any time up to max_ptime.
342 // TODO(deadbeef): Not implemented. 369 // TODO(deadbeef): Not implemented.
343 rtc::Optional<int> ptime; 370 rtc::Optional<int> ptime;
344 371
345 // Feedback mechanisms to be used for this codec. 372 // Feedback mechanisms to be used for this codec.
346 // TODO(deadbeef): Not implemented. 373 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
347 std::vector<RtcpFeedback> rtcp_feedback; 374 std::vector<RtcpFeedback> rtcp_feedback;
348 375
349 // Codec-specific parameters that must be signaled to the remote party. 376 // Codec-specific parameters that must be signaled to the remote party.
377 //
350 // Corresponds to "a=fmtp" parameters in SDP. 378 // Corresponds to "a=fmtp" parameters in SDP.
351 // TODO(deadbeef): Not implemented. 379 //
380 // Contrary to ORTC, these parameters are named using all lowercase strings.
381 // This helps make the mapping to SDP simpler, if an application is using
382 // SDP. Boolean values are represented by the string "1".
383 //
384 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
352 std::unordered_map<std::string, std::string> parameters; 385 std::unordered_map<std::string, std::string> parameters;
353 386
354 bool operator==(const RtpCodecParameters& o) const { 387 bool operator==(const RtpCodecParameters& o) const {
355 return name == o.name && kind == o.kind && payload_type == o.payload_type && 388 return name == o.name && kind == o.kind && payload_type == o.payload_type &&
356 clock_rate == o.clock_rate && num_channels == o.num_channels && 389 clock_rate == o.clock_rate && num_channels == o.num_channels &&
357 max_ptime == o.max_ptime && ptime == o.ptime && 390 max_ptime == o.max_ptime && ptime == o.ptime &&
358 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters; 391 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters;
359 } 392 }
360 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); } 393 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); }
361 }; 394 };
(...skipping 28 matching lines...) Expand all
390 // TODO(deadbeef): Not implemented. 423 // TODO(deadbeef): Not implemented.
391 std::string transaction_id; 424 std::string transaction_id;
392 425
393 // Value to use for MID RTP header extension. 426 // Value to use for MID RTP header extension.
394 // Called "muxId" in ORTC. 427 // Called "muxId" in ORTC.
395 // TODO(deadbeef): Not implemented. 428 // TODO(deadbeef): Not implemented.
396 std::string mid; 429 std::string mid;
397 430
398 std::vector<RtpCodecParameters> codecs; 431 std::vector<RtpCodecParameters> codecs;
399 432
400 // TODO(deadbeef): Not implemented. 433 // TODO(deadbeef): Not implemented with PeerConnection senders/receivers.
401 std::vector<RtpHeaderExtensionParameters> header_extensions; 434 std::vector<RtpHeaderExtensionParameters> header_extensions;
402 435
403 std::vector<RtpEncodingParameters> encodings; 436 std::vector<RtpEncodingParameters> encodings;
404 437
405 // TODO(deadbeef): Not implemented. 438 // TODO(deadbeef): Not implemented.
406 DegradationPreference degradation_preference = 439 DegradationPreference degradation_preference =
407 DegradationPreference::BALANCED; 440 DegradationPreference::BALANCED;
408 441
409 bool operator==(const RtpParameters& o) const { 442 bool operator==(const RtpParameters& o) const {
410 return mid == o.mid && codecs == o.codecs && 443 return mid == o.mid && codecs == o.codecs &&
411 header_extensions == o.header_extensions && 444 header_extensions == o.header_extensions &&
412 encodings == o.encodings && 445 encodings == o.encodings &&
413 degradation_preference == o.degradation_preference; 446 degradation_preference == o.degradation_preference;
414 } 447 }
415 bool operator!=(const RtpParameters& o) const { return !(*this == o); } 448 bool operator!=(const RtpParameters& o) const { return !(*this == o); }
416 }; 449 };
417 450
418 } // namespace webrtc 451 } // namespace webrtc
419 452
420 #endif // WEBRTC_API_RTPPARAMETERS_H_ 453 #endif // WEBRTC_API_RTPPARAMETERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698