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:
Arun Raghavan
2023-12-12 10:42:58 -05:00
parent 9a202fb8c2
commit c6abf6cd3f
479 changed files with 20900 additions and 11996 deletions

View File

@ -0,0 +1,111 @@
# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import("../../webrtc.gni")
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
rtc_source_set("arch") {
sources = [ "arch.h" ]
}
rtc_source_set("asm_defines") {
sources = [ "asm_defines.h" ]
}
rtc_library("file_wrapper") {
sources = [
"file_wrapper.cc",
"file_wrapper.h",
]
deps = [
"..:checks",
"..:criticalsection",
"..:safe_conversions",
]
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
}
if (rtc_include_tests) {
rtc_library("file_wrapper_unittests") {
testonly = true
sources = [ "file_wrapper_unittest.cc" ]
deps = [
":file_wrapper",
"//rtc_base:checks",
"//test:fileutils",
"//test:test_support",
]
}
}
rtc_source_set("ignore_warnings") {
sources = [ "ignore_warnings.h" ]
}
rtc_source_set("inline") {
sources = [ "inline.h" ]
}
rtc_source_set("unused") {
sources = [ "unused.h" ]
}
rtc_source_set("assume") {
sources = [ "assume.h" ]
}
rtc_source_set("rtc_export") {
sources = [
"rtc_export.h",
"rtc_export_template.h",
]
}
rtc_source_set("no_unique_address") {
sources = [ "no_unique_address.h" ]
}
rtc_source_set("no_cfi_icall") {
sources = [ "no_cfi_icall.h" ]
deps = [ "..:sanitizer" ]
}
if (is_mac || is_ios) {
rtc_library("cocoa_threading") {
sources = [
"cocoa_threading.h",
"cocoa_threading.mm",
]
deps = [ "..:checks" ]
frameworks = [ "Foundation.framework" ]
}
rtc_library("gcd_helpers") {
sources = [
"gcd_helpers.h",
"gcd_helpers.m",
]
include_dirs = [ "../.." ]
}
}
rtc_source_set("warn_current_thread_is_deadlocked") {
sources = [ "warn_current_thread_is_deadlocked.h" ]
deps = []
if (is_android && !build_with_chromium) {
sources += [ "warn_current_thread_is_deadlocked.cc" ]
deps += [
"..:logging",
"../../sdk/android:native_api_stacktrace",
]
}
}

View File

@ -73,6 +73,16 @@
#elif defined(__riscv) && __riscv_xlen == 32
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(__loongarch32)
#define WEBRTC_ARCH_LOONG_FAMILY
#define WEBRTC_ARCH_LOONG32
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(__loongarch64)
#define WEBRTC_ARCH_LOONG_FAMILY
#define WEBRTC_ARCH_LOONG64
#define WEBRTC_ARCH_64_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN
#elif defined(__pnacl__)
#define WEBRTC_ARCH_32_BITS
#define WEBRTC_ARCH_LITTLE_ENDIAN

View File

@ -9,28 +9,37 @@
*/
#include "rtc_base/system/file_wrapper.h"
#include "rtc_base/numerics/safe_conversions.h"
#include <stddef.h>
#include <cerrno>
#include <cstdint>
#include <string>
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_conversions.h"
#ifdef _WIN32
#include <windows.h>
#include <Windows.h>
#else
#include <string.h>
#endif
#include <utility>
namespace webrtc {
namespace {
FILE* FileOpen(const char* file_name_utf8, bool read_only, int* error) {
FILE* FileOpen(absl::string_view file_name_utf8, bool read_only, int* error) {
RTC_CHECK_EQ(file_name_utf8.find_first_of('\0'), absl::string_view::npos)
<< "Invalid filename, containing NUL character";
std::string file_name(file_name_utf8);
#if defined(_WIN32)
int len = MultiByteToWideChar(CP_UTF8, 0, file_name_utf8, -1, nullptr, 0);
int len = MultiByteToWideChar(CP_UTF8, 0, file_name.c_str(), -1, nullptr, 0);
std::wstring wstr(len, 0);
MultiByteToWideChar(CP_UTF8, 0, file_name_utf8, -1, &wstr[0], len);
MultiByteToWideChar(CP_UTF8, 0, file_name.c_str(), -1, &wstr[0], len);
FILE* file = _wfopen(wstr.c_str(), read_only ? L"rb" : L"wb");
#else
FILE* file = fopen(file_name_utf8, read_only ? "rb" : "wb");
FILE* file = fopen(file_name.c_str(), read_only ? "rb" : "wb");
#endif
if (!file && error) {
*error = errno;
@ -38,36 +47,19 @@ FILE* FileOpen(const char* file_name_utf8, bool read_only, int* error) {
return file;
}
const char* GetCstrCheckNoEmbeddedNul(const std::string& s) {
const char* p = s.c_str();
RTC_CHECK_EQ(strlen(p), s.size())
<< "Invalid filename, containing NUL character";
return p;
}
} // namespace
// static
FileWrapper FileWrapper::OpenReadOnly(const char* file_name_utf8) {
FileWrapper FileWrapper::OpenReadOnly(absl::string_view file_name_utf8) {
return FileWrapper(FileOpen(file_name_utf8, true, nullptr));
}
// static
FileWrapper FileWrapper::OpenReadOnly(const std::string& file_name_utf8) {
return OpenReadOnly(GetCstrCheckNoEmbeddedNul(file_name_utf8));
}
// static
FileWrapper FileWrapper::OpenWriteOnly(const char* file_name_utf8,
FileWrapper FileWrapper::OpenWriteOnly(absl::string_view file_name_utf8,
int* error /*=nullptr*/) {
return FileWrapper(FileOpen(file_name_utf8, false, error));
}
// static
FileWrapper FileWrapper::OpenWriteOnly(const std::string& file_name_utf8,
int* error /*=nullptr*/) {
return OpenWriteOnly(GetCstrCheckNoEmbeddedNul(file_name_utf8), error);
}
FileWrapper::FileWrapper(FileWrapper&& other) {
operator=(std::move(other));
}
@ -89,6 +81,22 @@ bool FileWrapper::SeekTo(int64_t position) {
return fseek(file_, rtc::checked_cast<long>(position), SEEK_SET) == 0;
}
long FileWrapper::FileSize() {
if (file_ == nullptr)
return -1;
long original_position = ftell(file_);
if (original_position < 0)
return -1;
int seek_error = fseek(file_, 0, SEEK_END);
if (seek_error)
return -1;
long file_size = ftell(file_);
seek_error = fseek(file_, original_position, SEEK_SET);
if (seek_error)
return -1;
return file_size;
}
bool FileWrapper::Flush() {
RTC_DCHECK(file_);
return fflush(file_) == 0;

View File

@ -12,11 +12,14 @@
#define RTC_BASE_SYSTEM_FILE_WRAPPER_H_
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <string>
#include "absl/strings/string_view.h"
// Implementation that can read (exclusive) or write from/to a file.
namespace webrtc {
@ -33,20 +36,16 @@ class FileWrapper final {
public:
// Opens a file, in read or write mode. Use the is_open() method on the
// returned object to check if the open operation was successful. On failure,
// and if |error| is non-null, the system errno value is stored at |*error|.
// and if `error` is non-null, the system errno value is stored at |*error|.
// The file is closed by the destructor.
static FileWrapper OpenReadOnly(const char* file_name_utf8);
static FileWrapper OpenReadOnly(const std::string& file_name_utf8);
static FileWrapper OpenWriteOnly(const char* file_name_utf8,
int* error = nullptr);
static FileWrapper OpenWriteOnly(const std::string& file_name_utf8,
static FileWrapper OpenReadOnly(absl::string_view file_name_utf8);
static FileWrapper OpenWriteOnly(absl::string_view file_name_utf8,
int* error = nullptr);
FileWrapper() = default;
// Takes over ownership of |file|, closing it on destruction. Calling with
// null |file| is allowed, and results in a FileWrapper with is_open() false.
// Takes over ownership of `file`, closing it on destruction. Calling with
// null `file` is allowed, and results in a FileWrapper with is_open() false.
explicit FileWrapper(FILE* file) : file_(file) {}
~FileWrapper() { Close(); }
@ -88,6 +87,11 @@ class FileWrapper final {
// Seek to given position.
bool SeekTo(int64_t position);
// Returns the file size or -1 if a size could not be determined.
// (A file size might not exists for non-seekable files or file-like
// objects, for example /dev/tty on unix.)
long FileSize();
// Returns number of bytes read. Short count indicates EOF or error.
size_t Read(void* buf, size_t length);

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef RTC_BASE_SYSTEM_NO_UNIQUE_ADDRESS_H_
#define RTC_BASE_SYSTEM_NO_UNIQUE_ADDRESS_H_
// RTC_NO_UNIQUE_ADDRESS is a portable annotation to tell the compiler that
// a data member need not have an address distinct from all other non-static
// data members of its class.
// It allows empty types to actually occupy zero bytes as class members,
// instead of occupying at least one byte just so that they get their own
// address. There is almost never any reason not to use it on class members
// that could possibly be empty.
// The macro expands to [[no_unique_address]] if the compiler supports the
// attribute, it expands to nothing otherwise.
// Clang should supports this attribute since C++11, while other compilers
// should add support for it starting from C++20. Among clang compilers,
// clang-cl doesn't support it yet and support is unclear also when the target
// platform is iOS.
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#endif
#if __has_cpp_attribute(no_unique_address)
// NOLINTNEXTLINE(whitespace/braces)
#define RTC_NO_UNIQUE_ADDRESS [[no_unique_address]]
#else
#define RTC_NO_UNIQUE_ADDRESS
#endif
#endif // RTC_BASE_SYSTEM_NO_UNIQUE_ADDRESS_H_

View File

@ -11,29 +11,18 @@
#ifndef RTC_BASE_SYSTEM_UNUSED_H_
#define RTC_BASE_SYSTEM_UNUSED_H_
// Annotate a function indicating the caller must examine the return value.
// Use like:
// int foo() RTC_WARN_UNUSED_RESULT;
// To explicitly ignore a result, cast to void.
// TODO(kwiberg): Remove when we can use [[nodiscard]] from C++17.
#if defined(__clang__)
#define RTC_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#elif defined(__GNUC__)
// gcc has a __warn_unused_result__ attribute, but you can't quiet it by
// casting to void, so we don't use it.
#define RTC_WARN_UNUSED_RESULT
#else
#define RTC_WARN_UNUSED_RESULT
#endif
// Prevent the compiler from warning about an unused variable. For example:
// int result = DoSomething();
// assert(result == 17);
// RTC_DCHECK(result == 17);
// RTC_UNUSED(result);
// Note: In most cases it is better to remove the unused variable rather than
// suppressing the compiler warning.
#ifndef RTC_UNUSED
#ifdef __cplusplus
#define RTC_UNUSED(x) static_cast<void>(x)
#else
#define RTC_UNUSED(x) (void)(x)
#endif
#endif // RTC_UNUSED
#endif // RTC_BASE_SYSTEM_UNUSED_H_

View File

@ -0,0 +1,28 @@
/*
* Copyright 2019 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/system/warn_current_thread_is_deadlocked.h"
#include "rtc_base/logging.h"
#if 0
# commented out to prevent pulling in extra android files
#include "sdk/android/native_api/stacktrace/stacktrace.h"
#endif
namespace webrtc {
void WarnThatTheCurrentThreadIsProbablyDeadlocked() {
RTC_LOG(LS_WARNING) << "Probable deadlock:";
#if 0
RTC_LOG(LS_WARNING) << StackTraceToString(GetStackTrace());
#endif
}
} // namespace webrtc

View File

@ -14,11 +14,7 @@
namespace webrtc {
#if defined(WEBRTC_ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
/* webrtc-audio-processing:
* We don't support the Android SDK integration for this, so stub out
void WarnThatTheCurrentThreadIsProbablyDeadlocked();
*/
inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {}
#else
inline void WarnThatTheCurrentThreadIsProbablyDeadlocked() {}
#endif