OLD | NEW |
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" | |
20 #include "webrtc/rtc_base/optional.h" | 19 #include "webrtc/rtc_base/optional.h" |
21 | 20 |
22 namespace webrtc { | 21 namespace webrtc { |
23 | 22 |
24 // These structures are intended to mirror those defined by: | 23 // These structures are intended to mirror those defined by: |
25 // http://draft.ortc.org/#rtcrtpdictionaries* | 24 // http://draft.ortc.org/#rtcrtpdictionaries* |
26 // Contains everything specified as of 2017 Jan 24. | 25 // Contains everything specified as of 2017 Jan 24. |
27 // | 26 // |
28 // They are used when retrieving or modifying the parameters of an | 27 // They are used when retrieving or modifying the parameters of an |
29 // RtpSender/RtpReceiver, or retrieving capabilities. | 28 // RtpSender/RtpReceiver, or retrieving capabilities. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 struct RtcpFeedback { | 77 struct RtcpFeedback { |
79 RtcpFeedbackType type = RtcpFeedbackType::CCM; | 78 RtcpFeedbackType type = RtcpFeedbackType::CCM; |
80 | 79 |
81 // Equivalent to ORTC "parameter" field with slight differences: | 80 // Equivalent to ORTC "parameter" field with slight differences: |
82 // 1. It's an enum instead of a string. | 81 // 1. It's an enum instead of a string. |
83 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, | 82 // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, |
84 // rather than an unset "parameter" value. | 83 // rather than an unset "parameter" value. |
85 rtc::Optional<RtcpFeedbackMessageType> message_type; | 84 rtc::Optional<RtcpFeedbackMessageType> message_type; |
86 | 85 |
87 // Constructors for convenience. | 86 // Constructors for convenience. |
88 RtcpFeedback() {} | 87 RtcpFeedback(); |
89 explicit RtcpFeedback(RtcpFeedbackType type) : type(type) {} | 88 explicit RtcpFeedback(RtcpFeedbackType type); |
90 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type) | 89 RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type); |
91 : type(type), message_type(message_type) {} | 90 ~RtcpFeedback(); |
92 | 91 |
93 bool operator==(const RtcpFeedback& o) const { | 92 bool operator==(const RtcpFeedback& o) const { |
94 return type == o.type && message_type == o.message_type; | 93 return type == o.type && message_type == o.message_type; |
95 } | 94 } |
96 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); } | 95 bool operator!=(const RtcpFeedback& o) const { return !(*this == o); } |
97 }; | 96 }; |
98 | 97 |
99 // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to | 98 // RtpCodecCapability is to RtpCodecParameters as RtpCapabilities is to |
100 // RtpParameters. This represents the static capabilities of an endpoint's | 99 // RtpParameters. This represents the static capabilities of an endpoint's |
101 // implementation of a codec. | 100 // implementation of a codec. |
102 struct RtpCodecCapability { | 101 struct RtpCodecCapability { |
| 102 RtpCodecCapability(); |
| 103 ~RtpCodecCapability(); |
| 104 |
103 // Build MIME "type/subtype" string from |name| and |kind|. | 105 // Build MIME "type/subtype" string from |name| and |kind|. |
104 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } | 106 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
105 | 107 |
106 // Used to identify the codec. Equivalent to MIME subtype. | 108 // Used to identify the codec. Equivalent to MIME subtype. |
107 std::string name; | 109 std::string name; |
108 | 110 |
109 // The media type of this codec. Equivalent to MIME top-level type. | 111 // The media type of this codec. Equivalent to MIME top-level type. |
110 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; | 112 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
111 | 113 |
112 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate. | 114 // Clock rate in Hertz. If unset, the codec is applicable to any clock rate. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 std::string uri; | 191 std::string uri; |
190 | 192 |
191 // Preferred value of ID that goes in the packet. | 193 // Preferred value of ID that goes in the packet. |
192 rtc::Optional<int> preferred_id; | 194 rtc::Optional<int> preferred_id; |
193 | 195 |
194 // If true, it's preferred that the value in the header is encrypted. | 196 // If true, it's preferred that the value in the header is encrypted. |
195 // TODO(deadbeef): Not implemented. | 197 // TODO(deadbeef): Not implemented. |
196 bool preferred_encrypt = false; | 198 bool preferred_encrypt = false; |
197 | 199 |
198 // Constructors for convenience. | 200 // Constructors for convenience. |
199 RtpHeaderExtensionCapability() = default; | 201 RtpHeaderExtensionCapability(); |
200 explicit RtpHeaderExtensionCapability(const std::string& uri) : uri(uri) {} | 202 explicit RtpHeaderExtensionCapability(const std::string& uri); |
201 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id) | 203 RtpHeaderExtensionCapability(const std::string& uri, int preferred_id); |
202 : uri(uri), preferred_id(preferred_id) {} | 204 ~RtpHeaderExtensionCapability(); |
203 | 205 |
204 bool operator==(const RtpHeaderExtensionCapability& o) const { | 206 bool operator==(const RtpHeaderExtensionCapability& o) const { |
205 return uri == o.uri && preferred_id == o.preferred_id && | 207 return uri == o.uri && preferred_id == o.preferred_id && |
206 preferred_encrypt == o.preferred_encrypt; | 208 preferred_encrypt == o.preferred_encrypt; |
207 } | 209 } |
208 bool operator!=(const RtpHeaderExtensionCapability& o) const { | 210 bool operator!=(const RtpHeaderExtensionCapability& o) const { |
209 return !(*this == o); | 211 return !(*this == o); |
210 } | 212 } |
211 }; | 213 }; |
212 | 214 |
| 215 // RTP header extension, see RFC 5285. |
| 216 struct 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_126
114v120700p.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 |
213 // See webrtc/config.h. Has "uri" and "id" fields. | 292 // See webrtc/config.h. Has "uri" and "id" fields. |
214 // TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented. | 293 // TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented. |
215 typedef RtpExtension RtpHeaderExtensionParameters; | 294 typedef RtpExtension RtpHeaderExtensionParameters; |
216 | 295 |
217 struct RtpFecParameters { | 296 struct RtpFecParameters { |
218 // If unset, a value is chosen by the implementation. | 297 // If unset, a value is chosen by the implementation. |
219 // Works just like RtpEncodingParameters::ssrc. | 298 // Works just like RtpEncodingParameters::ssrc. |
220 rtc::Optional<uint32_t> ssrc; | 299 rtc::Optional<uint32_t> ssrc; |
221 | 300 |
222 FecMechanism mechanism = FecMechanism::RED; | 301 FecMechanism mechanism = FecMechanism::RED; |
223 | 302 |
224 // Constructors for convenience. | 303 // Constructors for convenience. |
225 RtpFecParameters() = default; | 304 RtpFecParameters(); |
226 explicit RtpFecParameters(FecMechanism mechanism) : mechanism(mechanism) {} | 305 explicit RtpFecParameters(FecMechanism mechanism); |
227 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc) | 306 RtpFecParameters(FecMechanism mechanism, uint32_t ssrc); |
228 : ssrc(ssrc), mechanism(mechanism) {} | 307 ~RtpFecParameters(); |
229 | 308 |
230 bool operator==(const RtpFecParameters& o) const { | 309 bool operator==(const RtpFecParameters& o) const { |
231 return ssrc == o.ssrc && mechanism == o.mechanism; | 310 return ssrc == o.ssrc && mechanism == o.mechanism; |
232 } | 311 } |
233 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); } | 312 bool operator!=(const RtpFecParameters& o) const { return !(*this == o); } |
234 }; | 313 }; |
235 | 314 |
236 struct RtpRtxParameters { | 315 struct RtpRtxParameters { |
237 // If unset, a value is chosen by the implementation. | 316 // If unset, a value is chosen by the implementation. |
238 // Works just like RtpEncodingParameters::ssrc. | 317 // Works just like RtpEncodingParameters::ssrc. |
239 rtc::Optional<uint32_t> ssrc; | 318 rtc::Optional<uint32_t> ssrc; |
240 | 319 |
241 // Constructors for convenience. | 320 // Constructors for convenience. |
242 RtpRtxParameters() = default; | 321 RtpRtxParameters(); |
243 explicit RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {} | 322 explicit RtpRtxParameters(uint32_t ssrc); |
| 323 ~RtpRtxParameters(); |
244 | 324 |
245 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } | 325 bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } |
246 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } | 326 bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } |
247 }; | 327 }; |
248 | 328 |
249 struct RtpEncodingParameters { | 329 struct RtpEncodingParameters { |
| 330 RtpEncodingParameters(); |
| 331 ~RtpEncodingParameters(); |
| 332 |
250 // If unset, a value is chosen by the implementation. | 333 // If unset, a value is chosen by the implementation. |
251 // | 334 // |
252 // Note that the chosen value is NOT returned by GetParameters, because it | 335 // Note that the chosen value is NOT returned by GetParameters, because it |
253 // may change due to an SSRC conflict, in which case the conflict is handled | 336 // may change due to an SSRC conflict, in which case the conflict is handled |
254 // internally without any event. Another way of looking at this is that an | 337 // internally without any event. Another way of looking at this is that an |
255 // unset SSRC acts as a "wildcard" SSRC. | 338 // unset SSRC acts as a "wildcard" SSRC. |
256 rtc::Optional<uint32_t> ssrc; | 339 rtc::Optional<uint32_t> ssrc; |
257 | 340 |
258 // Can be used to reference a codec in the |codecs| member of the | 341 // Can be used to reference a codec in the |codecs| member of the |
259 // RtpParameters that contains this RtpEncodingParameters. If unset, the | 342 // RtpParameters that contains this RtpEncodingParameters. If unset, the |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 scale_framerate_down_by == o.scale_framerate_down_by && | 414 scale_framerate_down_by == o.scale_framerate_down_by && |
332 active == o.active && rid == o.rid && | 415 active == o.active && rid == o.rid && |
333 dependency_rids == o.dependency_rids; | 416 dependency_rids == o.dependency_rids; |
334 } | 417 } |
335 bool operator!=(const RtpEncodingParameters& o) const { | 418 bool operator!=(const RtpEncodingParameters& o) const { |
336 return !(*this == o); | 419 return !(*this == o); |
337 } | 420 } |
338 }; | 421 }; |
339 | 422 |
340 struct RtpCodecParameters { | 423 struct RtpCodecParameters { |
| 424 RtpCodecParameters(); |
| 425 ~RtpCodecParameters(); |
| 426 |
341 // Build MIME "type/subtype" string from |name| and |kind|. | 427 // Build MIME "type/subtype" string from |name| and |kind|. |
342 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } | 428 std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } |
343 | 429 |
344 // Used to identify the codec. Equivalent to MIME subtype. | 430 // Used to identify the codec. Equivalent to MIME subtype. |
345 std::string name; | 431 std::string name; |
346 | 432 |
347 // The media type of this codec. Equivalent to MIME top-level type. | 433 // The media type of this codec. Equivalent to MIME top-level type. |
348 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; | 434 cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; |
349 | 435 |
350 // Payload type used to identify this codec in RTP packets. | 436 // Payload type used to identify this codec in RTP packets. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 max_ptime == o.max_ptime && ptime == o.ptime && | 479 max_ptime == o.max_ptime && ptime == o.ptime && |
394 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters; | 480 rtcp_feedback == o.rtcp_feedback && parameters == o.parameters; |
395 } | 481 } |
396 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); } | 482 bool operator!=(const RtpCodecParameters& o) const { return !(*this == o); } |
397 }; | 483 }; |
398 | 484 |
399 // RtpCapabilities is used to represent the static capabilities of an | 485 // RtpCapabilities is used to represent the static capabilities of an |
400 // endpoint. An application can use these capabilities to construct an | 486 // endpoint. An application can use these capabilities to construct an |
401 // RtpParameters. | 487 // RtpParameters. |
402 struct RtpCapabilities { | 488 struct RtpCapabilities { |
| 489 RtpCapabilities(); |
| 490 ~RtpCapabilities(); |
| 491 |
403 // Supported codecs. | 492 // Supported codecs. |
404 std::vector<RtpCodecCapability> codecs; | 493 std::vector<RtpCodecCapability> codecs; |
405 | 494 |
406 // Supported RTP header extensions. | 495 // Supported RTP header extensions. |
407 std::vector<RtpHeaderExtensionCapability> header_extensions; | 496 std::vector<RtpHeaderExtensionCapability> header_extensions; |
408 | 497 |
409 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED, | 498 // Supported Forward Error Correction (FEC) mechanisms. Note that the RED, |
410 // ulpfec and flexfec codecs used by these mechanisms will still appear in | 499 // ulpfec and flexfec codecs used by these mechanisms will still appear in |
411 // |codecs|. | 500 // |codecs|. |
412 std::vector<FecMechanism> fec; | 501 std::vector<FecMechanism> fec; |
413 | 502 |
414 bool operator==(const RtpCapabilities& o) const { | 503 bool operator==(const RtpCapabilities& o) const { |
415 return codecs == o.codecs && header_extensions == o.header_extensions && | 504 return codecs == o.codecs && header_extensions == o.header_extensions && |
416 fec == o.fec; | 505 fec == o.fec; |
417 } | 506 } |
418 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); } | 507 bool operator!=(const RtpCapabilities& o) const { return !(*this == o); } |
419 }; | 508 }; |
420 | 509 |
421 // Note that unlike in ORTC, an RtcpParameters structure is not included in | 510 // Note that unlike in ORTC, an RtcpParameters structure is not included in |
422 // RtpParameters, because our API includes an additional "RtpTransport" | 511 // RtpParameters, because our API includes an additional "RtpTransport" |
423 // abstraction on which RTCP parameters are set. | 512 // abstraction on which RTCP parameters are set. |
424 struct RtpParameters { | 513 struct RtpParameters { |
| 514 RtpParameters(); |
| 515 ~RtpParameters(); |
| 516 |
425 // Used when calling getParameters/setParameters with a PeerConnection | 517 // Used when calling getParameters/setParameters with a PeerConnection |
426 // RtpSender, to ensure that outdated parameters are not unintentionally | 518 // RtpSender, to ensure that outdated parameters are not unintentionally |
427 // applied successfully. | 519 // applied successfully. |
428 // TODO(deadbeef): Not implemented. | 520 // TODO(deadbeef): Not implemented. |
429 std::string transaction_id; | 521 std::string transaction_id; |
430 | 522 |
431 // Value to use for MID RTP header extension. | 523 // Value to use for MID RTP header extension. |
432 // Called "muxId" in ORTC. | 524 // Called "muxId" in ORTC. |
433 // TODO(deadbeef): Not implemented. | 525 // TODO(deadbeef): Not implemented. |
434 std::string mid; | 526 std::string mid; |
(...skipping 14 matching lines...) Expand all Loading... |
449 header_extensions == o.header_extensions && | 541 header_extensions == o.header_extensions && |
450 encodings == o.encodings && | 542 encodings == o.encodings && |
451 degradation_preference == o.degradation_preference; | 543 degradation_preference == o.degradation_preference; |
452 } | 544 } |
453 bool operator!=(const RtpParameters& o) const { return !(*this == o); } | 545 bool operator!=(const RtpParameters& o) const { return !(*this == o); } |
454 }; | 546 }; |
455 | 547 |
456 } // namespace webrtc | 548 } // namespace webrtc |
457 | 549 |
458 #endif // WEBRTC_API_RTPPARAMETERS_H_ | 550 #endif // WEBRTC_API_RTPPARAMETERS_H_ |
OLD | NEW |