diff options
Diffstat (limited to 'third_party/libwebrtc/api/transport/stun.h')
-rw-r--r-- | third_party/libwebrtc/api/transport/stun.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/third_party/libwebrtc/api/transport/stun.h b/third_party/libwebrtc/api/transport/stun.h index 4a04db33cf..62d98f71e0 100644 --- a/third_party/libwebrtc/api/transport/stun.h +++ b/third_party/libwebrtc/api/transport/stun.h @@ -519,13 +519,22 @@ class StunByteStringAttribute : public StunAttribute { StunAttributeValueType value_type() const override; - const char* bytes() const { return bytes_; } + [[deprecated("Use array_view")]] const char* bytes() const { + return reinterpret_cast<const char*>(bytes_); + } + // Returns the attribute value as a string. + // Use this for attributes that are text or text-compatible. absl::string_view string_view() const { - return absl::string_view(bytes_, length()); + return absl::string_view(reinterpret_cast<const char*>(bytes_), length()); + } + // Returns the attribute value as an uint8_t view. + // Use this function for values that are not text. + rtc::ArrayView<uint8_t> array_view() const { + return rtc::MakeArrayView(bytes_, length()); } [[deprecated]] std::string GetString() const { - return std::string(bytes_, length()); + return std::string(reinterpret_cast<const char*>(bytes_), length()); } void CopyBytes(const void* bytes, size_t length); @@ -538,9 +547,9 @@ class StunByteStringAttribute : public StunAttribute { bool Write(rtc::ByteBufferWriter* buf) const override; private: - void SetBytes(char* bytes, size_t length); + void SetBytes(uint8_t* bytes, size_t length); - char* bytes_; + uint8_t* bytes_; }; // Implements STUN attributes that record an error code. |