Deprecate implicit conversion from RtpHeaderExtensionId to int Bug: webrtc:514817938 Change-Id: Id8e8a1d7e57d68ab385689b2ead0d1baf0d5fc0d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/476241 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Auto-Submit: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47879}
diff --git a/api/BUILD.gn b/api/BUILD.gn index 17c40ab..3895469 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn
@@ -834,6 +834,7 @@ deps = [ "../rtc_base:checks", "../rtc_base:strong_alias", + "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings:str_format", ] }
diff --git a/api/rtp_header_extension_id.h b/api/rtp_header_extension_id.h index af45231..740adb3 100644 --- a/api/rtp_header_extension_id.h +++ b/api/rtp_header_extension_id.h
@@ -11,6 +11,7 @@ #ifndef API_RTP_HEADER_EXTENSION_ID_H_ #define API_RTP_HEADER_EXTENSION_ID_H_ +#include "absl/base/macros.h" #include "absl/strings/str_format.h" #include "rtc_base/strong_alias.h" @@ -48,7 +49,11 @@ // RTC_DCHECK_LE(id, kMaxId.value()); } // TODO: bugs.webrtc.org/514817938 - RTC_DCHECK(id is valid). - constexpr operator int() const& { return value(); } // NOLINT: explicit + [[deprecated]] ABSL_REFACTOR_INLINE // + constexpr + operator int() const& { // NOLINT: explicit + return value(); + } // Returns true for an extension id that is set and is in the legal range. constexpr bool Valid() const {
diff --git a/api/rtp_parameters.cc b/api/rtp_parameters.cc index df4673b..35f15db 100644 --- a/api/rtp_parameters.cc +++ b/api/rtp_parameters.cc
@@ -358,10 +358,12 @@ // Sort the returned vector to make comparisons of header extensions reliable. // In order of priority, we sort by uri first, then encrypt and id last. + // .value() has to be used because tie compares using the <=> operator, + // which is defined for int, but not for RtpHeaderExtensionId. std::sort(filtered.begin(), filtered.end(), [](const RtpExtension& a, const RtpExtension& b) { - return std::tie(a.uri, a.encrypt, a.id) < - std::tie(b.uri, b.encrypt, b.id); + return std::tie(a.uri, a.encrypt, a.id.value()) < + std::tie(b.uri, b.encrypt, b.id.value()); }); return filtered;
diff --git a/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_unittest.cc index 981f816..0e713dc 100644 --- a/modules/rtp_rtcp/source/rtp_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_unittest.cc
@@ -95,7 +95,7 @@ 0x10, 0x00, 0x00, 0x04, 0x01, 0x03, 0x00, 0x56, 0xce, 0x09, 0x01, 0x80|kAudioLevel, - kTwoByteExtensionId, 0x03, 0x00, 0x30, // => 0x00 0x30 0x22 + kTwoByteExtensionId.value(), 0x03, 0x00, 0x30, // => 0x00 0x30 0x22 0x22, 0x00, 0x00, 0x00}; // => Playout delay.min_ms = 3*10 // => Playout delay.max_ms = 34*10 @@ -104,7 +104,7 @@ 0x65, 0x43, 0x12, 0x78, 0x12, 0x34, 0x56, 0x78, 0x10, 0x00, 0x00, 0x04, - kTwoByteExtensionId, 0x03, 0x00, 0x30, // => 0x00 0x30 0x22 + kTwoByteExtensionId.value(), 0x03, 0x00, 0x30, // => 0x00 0x30 0x22 0x22, 0x01, 0x03, 0x00, // => Playout delay.min_ms = 3*10 0x56, 0xce, 0x09, 0x01, // => Playout delay.max_ms = 34*10 0x80|kAudioLevel, 0x00, 0x00, 0x00}; @@ -162,7 +162,7 @@ 0x65, 0x43, 0x12, 0x78, 0x12, 0x34, 0x56, 0x78, 0x10, 0x00, 0x00, 0x02, // Two-byte header extension profile id + length. - kTwoByteExtensionId, 0x03, 0x00, 0x56, + kTwoByteExtensionId.value(), 0x03, 0x00, 0x56, 0xce, 0x00, 0x00, 0x00}; constexpr uint8_t kPacketWithLongTwoByteHeaderExtension[] = { @@ -170,7 +170,7 @@ 0x65, 0x43, 0x12, 0x78, 0x12, 0x34, 0x56, 0x78, 0x10, 0x00, 0x00, 0x0B, // Two-byte header extension profile id + length. - kTwoByteExtensionId, 0x29, 'e', 'x', + kTwoByteExtensionId.value(), 0x29, 'e', 'x', 't', 'r', 'a', '-', 'l', 'o', 'n', 'g', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 't', 'o', ' ', 't', 'e', 's', 't', ' ', @@ -182,18 +182,19 @@ 0x65, 0x43, 0x12, 0x78, 0x12, 0x34, 0x56, 0x78, 0x10, 0x00, 0x00, 0x03, // Two-byte header extension profile id + length. - kTwoByteExtensionId, 0x03, 0x00, 0x56, + kTwoByteExtensionId.value(), 0x03, 0x00, 0x56, 0xce, 0x00, 0x00, 0x00, // Three padding bytes. - kAudioLevelExtensionId, 0x01, 0x80|kAudioLevel, 0x00}; + kAudioLevelExtensionId.value(), 0x01, 0x80|kAudioLevel, 0x00}; constexpr uint8_t kPacketWithInvalidExtension[] = { 0x90, kPayloadType, kSeqNumFirstByte, kSeqNumSecondByte, 0x65, 0x43, 0x12, 0x78, // kTimestamp. 0x12, 0x34, 0x56, 0x78, // kSSrc. 0xbe, 0xde, 0x00, 0x02, // Extension block of size 2 x 32bit words. - (kTransmissionOffsetExtensionId << 4) | 6, // (6+1)-byte extension, but - 'e', 'x', 't', // Transmission Offset - 'd', 'a', 't', 'a', // expected to be 3-bytes. + (kTransmissionOffsetExtensionId.value() << 4) | 6, + // (6+1)-byte extension, but TransmissionOffset expected to be 3-bytes. + 'e', 'x', 't', + 'd', 'a', 't', 'a', 'p', 'a', 'y', 'l', 'o', 'a', 'd'}; constexpr uint8_t kPacketWithLegacyTimingExtension[] = { @@ -201,7 +202,7 @@ 0x65, 0x43, 0x12, 0x78, // kTimestamp. 0x12, 0x34, 0x56, 0x78, // kSSrc. 0xbe, 0xde, 0x00, 0x04, // Extension block of size 4 x 32bit words. - (kVideoTimingExtensionId << 4) + (kVideoTimingExtensionId.value() << 4) | VideoTimingExtension::kValueSizeBytes - 2, // Old format without flags. 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00,
diff --git a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm index 547d42c..88f2650 100644 --- a/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm +++ b/sdk/objc/api/peerconnection/RTCRtpHeaderExtension.mm
@@ -28,7 +28,7 @@ self = [super init]; if (self) { _uri = [NSString stringForStdString:nativeParameters.uri]; - _id = nativeParameters.id; + _id = nativeParameters.id.value(); _encrypted = nativeParameters.encrypt; } return self;