Bump to WebRTC M120 release
Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone. We're continuing to carry iSAC even though it's gone upstream, but maybe we'll want to drop that soon.
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
|
||||
@ -26,16 +27,20 @@ SimpleStringBuilder::SimpleStringBuilder(rtc::ArrayView<char> buffer)
|
||||
RTC_DCHECK(IsConsistent());
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(const char* str) {
|
||||
return Append(str, strlen(str));
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(char ch) {
|
||||
return Append(&ch, 1);
|
||||
return operator<<(absl::string_view(&ch, 1));
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(const std::string& str) {
|
||||
return Append(str.c_str(), str.length());
|
||||
SimpleStringBuilder& SimpleStringBuilder::operator<<(absl::string_view str) {
|
||||
RTC_DCHECK_LT(size_ + str.length(), buffer_.size())
|
||||
<< "Buffer size was insufficient";
|
||||
const size_t chars_added =
|
||||
rtc::SafeMin(str.length(), buffer_.size() - size_ - 1);
|
||||
memcpy(&buffer_[size_], str.data(), chars_added);
|
||||
size_ += chars_added;
|
||||
buffer_[size_] = '\0';
|
||||
RTC_DCHECK(IsConsistent());
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Numeric conversion routines.
|
||||
@ -98,7 +103,7 @@ SimpleStringBuilder& SimpleStringBuilder::AppendFormat(const char* fmt, ...) {
|
||||
} else {
|
||||
// This should never happen, but we're paranoid, so re-write the
|
||||
// terminator in case vsnprintf() overwrote it.
|
||||
RTC_NOTREACHED();
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
buffer_[size_] = '\0';
|
||||
}
|
||||
va_end(args);
|
||||
@ -106,18 +111,6 @@ SimpleStringBuilder& SimpleStringBuilder::AppendFormat(const char* fmt, ...) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
SimpleStringBuilder& SimpleStringBuilder::Append(const char* str,
|
||||
size_t length) {
|
||||
RTC_DCHECK_LT(size_ + length, buffer_.size())
|
||||
<< "Buffer size was insufficient";
|
||||
const size_t chars_added = rtc::SafeMin(length, buffer_.size() - size_ - 1);
|
||||
memcpy(&buffer_[size_], str, chars_added);
|
||||
size_ += chars_added;
|
||||
buffer_[size_] = '\0';
|
||||
RTC_DCHECK(IsConsistent());
|
||||
return *this;
|
||||
}
|
||||
|
||||
StringBuilder& StringBuilder::AppendFormat(const char* fmt, ...) {
|
||||
va_list args, copy;
|
||||
va_start(args, fmt);
|
||||
|
@ -25,16 +25,15 @@ namespace rtc {
|
||||
// when you might otherwise be tempted to use a stringstream (discouraged for
|
||||
// anything except logging). It uses a fixed-size buffer provided by the caller
|
||||
// and concatenates strings and numbers into it, allowing the results to be
|
||||
// read via |str()|.
|
||||
// read via `str()`.
|
||||
class SimpleStringBuilder {
|
||||
public:
|
||||
explicit SimpleStringBuilder(rtc::ArrayView<char> buffer);
|
||||
SimpleStringBuilder(const SimpleStringBuilder&) = delete;
|
||||
SimpleStringBuilder& operator=(const SimpleStringBuilder&) = delete;
|
||||
|
||||
SimpleStringBuilder& operator<<(const char* str);
|
||||
SimpleStringBuilder& operator<<(char ch);
|
||||
SimpleStringBuilder& operator<<(const std::string& str);
|
||||
SimpleStringBuilder& operator<<(absl::string_view str);
|
||||
SimpleStringBuilder& operator<<(int i);
|
||||
SimpleStringBuilder& operator<<(unsigned i);
|
||||
SimpleStringBuilder& operator<<(long i); // NOLINT
|
||||
@ -45,12 +44,12 @@ class SimpleStringBuilder {
|
||||
SimpleStringBuilder& operator<<(double f);
|
||||
SimpleStringBuilder& operator<<(long double f);
|
||||
|
||||
// Returns a pointer to the built string. The name |str()| is borrowed for
|
||||
// Returns a pointer to the built string. The name `str()` is borrowed for
|
||||
// compatibility reasons as we replace usage of stringstream throughout the
|
||||
// code base.
|
||||
const char* str() const { return buffer_.data(); }
|
||||
|
||||
// Returns the length of the string. The name |size()| is picked for STL
|
||||
// Returns the length of the string. The name `size()` is picked for STL
|
||||
// compatibility reasons.
|
||||
size_t size() const { return size_; }
|
||||
|
||||
@ -61,10 +60,6 @@ class SimpleStringBuilder {
|
||||
SimpleStringBuilder&
|
||||
AppendFormat(const char* fmt, ...);
|
||||
|
||||
// An alternate way from operator<<() to append a string. This variant is
|
||||
// slightly more efficient when the length of the string to append, is known.
|
||||
SimpleStringBuilder& Append(const char* str, size_t length);
|
||||
|
||||
private:
|
||||
bool IsConsistent() const {
|
||||
return size_ <= buffer_.size() - 1 && buffer_[size_] == '\0';
|
||||
|
Reference in New Issue
Block a user