diff options
Diffstat (limited to 'third_party/libwebrtc/rtc_base')
137 files changed, 637 insertions, 1699 deletions
diff --git a/third_party/libwebrtc/rtc_base/BUILD.gn b/third_party/libwebrtc/rtc_base/BUILD.gn index 3d57e3bfb4..5392e5f472 100644 --- a/third_party/libwebrtc/rtc_base/BUILD.gn +++ b/third_party/libwebrtc/rtc_base/BUILD.gn @@ -156,8 +156,12 @@ rtc_library("byte_buffer") { deps = [ ":buffer", ":byte_order", + "../api:array_view", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/base:core_headers", + "//third_party/abseil-cpp/absl/strings", ] - absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("buffer_queue") { @@ -371,6 +375,7 @@ rtc_source_set("refcount") { ] deps = [ ":macromagic", + "../api:ref_count", "../api:scoped_refptr", ] } @@ -613,6 +618,7 @@ rtc_library("stringutils") { "string_to_number.h", "string_utils.cc", "string_utils.h", + "strings/str_join.h", "strings/string_builder.cc", "strings/string_builder.h", "strings/string_format.cc", @@ -925,20 +931,6 @@ rtc_library("net_test_helpers") { } } -rtc_library("async_resolver_interface") { - visibility = [ "*" ] - sources = [ - "async_resolver_interface.cc", - "async_resolver_interface.h", - ] - deps = [ - ":checks", - ":socket_address", - "system:rtc_export", - "third_party/sigslot", - ] -} - rtc_library("async_dns_resolver") { sources = [ "async_dns_resolver.cc", @@ -1037,8 +1029,6 @@ rtc_library("threading") { visibility = [ "*" ] sources = [ - "async_resolver.cc", - "async_resolver.h", "internal/default_socket_server.cc", "internal/default_socket_server.h", "network_monitor.cc", @@ -1060,7 +1050,6 @@ rtc_library("threading") { ] deps = [ ":async_dns_resolver", - ":async_resolver_interface", ":byte_order", ":checks", ":criticalsection", @@ -1395,10 +1384,12 @@ if (!build_with_mozilla) { ] deps = [ ":callback_list", + ":checks", ":dscp", ":socket", ":timeutils", "../api:sequence_checker", + "network:received_packet", "network:sent_packet", "system:no_unique_address", "system:rtc_export", @@ -1407,6 +1398,21 @@ if (!build_with_mozilla) { } } +if (rtc_include_tests) { + rtc_library("async_packet_socket_unittest") { + testonly = true + visibility = [ "*" ] + sources = [ "async_packet_socket_unittest.cc" ] + deps = [ + ":async_packet_socket", + ":gunit_helpers", + "../test:test_support", + "network:received_packet", + "third_party/sigslot", + ] + } +} + rtc_library("mdns_responder_interface") { sources = [ "mdns_responder_interface.h" ] deps = [ ":ip_address" ] @@ -1680,10 +1686,13 @@ rtc_library("testclient") { ] deps = [ ":async_udp_socket", + ":buffer", ":gunit_helpers", ":rtc_base_tests_utils", ":threading", ":timeutils", + "../api/units:timestamp", + "network:received_packet", "synchronization:mutex", ] } @@ -1766,12 +1775,14 @@ rtc_library("rtc_base_tests_utils") { "../api:make_ref_counted", "../api:refcountedbase", "../api:scoped_refptr", + "../api:sequence_checker", "../api/task_queue", "../api/units:time_delta", "../api/units:timestamp", "../test:scoped_key_value_config", "memory:always_valid_pointer", "memory:fifo_buffer", + "network:received_packet", "synchronization:mutex", "third_party/sigslot", ] @@ -1929,6 +1940,7 @@ if (rtc_include_tests) { "string_encode_unittest.cc", "string_to_number_unittest.cc", "string_utils_unittest.cc", + "strings/str_join_unittest.cc", "strings/string_builder_unittest.cc", "strings/string_format_unittest.cc", "strong_alias_unittest.cc", @@ -1993,6 +2005,7 @@ if (rtc_include_tests) { ":zero_memory", "../api:array_view", "../api:make_ref_counted", + "../api:ref_count", "../api:scoped_refptr", "../api/numerics", "../api/units:data_rate", diff --git a/third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build b/third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build index 866c7aec5a..c278a28f8f 100644 --- a/third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/async_dns_resolver_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/async_packet_socket.cc b/third_party/libwebrtc/rtc_base/async_packet_socket.cc index f50138cb62..3721366099 100644 --- a/third_party/libwebrtc/rtc_base/async_packet_socket.cc +++ b/third_party/libwebrtc/rtc_base/async_packet_socket.cc @@ -10,6 +10,8 @@ #include "rtc_base/async_packet_socket.h" +#include "rtc_base/checks.h" + namespace rtc { PacketTimeUpdateParams::PacketTimeUpdateParams() = default; @@ -38,6 +40,41 @@ void AsyncPacketSocket::UnsubscribeCloseEvent(const void* removal_tag) { on_close_.RemoveReceivers(removal_tag); } +void AsyncPacketSocket::RegisterReceivedPacketCallback( + absl::AnyInvocable<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)> + received_packet_callback) { + RTC_DCHECK_RUN_ON(&network_checker_); + RTC_CHECK(!received_packet_callback_); + SignalReadPacket.connect(this, &AsyncPacketSocket::NotifyPacketReceived); + received_packet_callback_ = std::move(received_packet_callback); +} + +void AsyncPacketSocket::DeregisterReceivedPacketCallback() { + RTC_DCHECK_RUN_ON(&network_checker_); + SignalReadPacket.disconnect(this); + received_packet_callback_ = nullptr; +} + +void AsyncPacketSocket::NotifyPacketReceived( + const rtc::ReceivedPacket& packet) { + RTC_DCHECK_RUN_ON(&network_checker_); + if (received_packet_callback_) { + received_packet_callback_(this, packet); + return; + } + if (SignalReadPacket.is_empty()) { + RTC_DCHECK_NOTREACHED() << " No listener registered"; + return; + } + // TODO(bugs.webrtc.org:15368): Remove. This code path is only used if + // SignalReadyPacket is used by clients to get notification of received + // packets but actual socket implementation use NotifyPacketReceived to + // trigger the notification. + SignalReadPacket(this, reinterpret_cast<const char*>(packet.payload().data()), + packet.payload().size(), packet.source_address(), + packet.arrival_time() ? packet.arrival_time()->us() : -1); +} + void CopySocketInformationToPacketInfo(size_t packet_size_bytes, const AsyncPacketSocket& socket_from, bool is_connectionless, diff --git a/third_party/libwebrtc/rtc_base/async_packet_socket.h b/third_party/libwebrtc/rtc_base/async_packet_socket.h index 0d3ceb94e7..768fcd446b 100644 --- a/third_party/libwebrtc/rtc_base/async_packet_socket.h +++ b/third_party/libwebrtc/rtc_base/async_packet_socket.h @@ -11,11 +11,13 @@ #ifndef RTC_BASE_ASYNC_PACKET_SOCKET_H_ #define RTC_BASE_ASYNC_PACKET_SOCKET_H_ +#include <cstdint> #include <vector> #include "api/sequence_checker.h" #include "rtc_base/callback_list.h" #include "rtc_base/dscp.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/socket.h" #include "rtc_base/system/no_unique_address.h" @@ -115,8 +117,14 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> { std::function<void(AsyncPacketSocket*, int)> callback); void UnsubscribeCloseEvent(const void* removal_tag); + void RegisterReceivedPacketCallback( + absl::AnyInvocable<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)> + received_packet_callback); + void DeregisterReceivedPacketCallback(); + // Emitted each time a packet is read. Used only for UDP and // connected TCP sockets. + // TODO(bugs.webrtc.org:15368): Deprecate and remove. sigslot::signal5<AsyncPacketSocket*, const char*, size_t, @@ -155,12 +163,26 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> { on_close_.Send(this, err); } + // TODO(bugs.webrtc.org:15368): Deprecate and remove. + void NotifyPacketReceived(AsyncPacketSocket*, + const char* data, + size_t size, + const SocketAddress& address, + const int64_t& packet_time_us) { + NotifyPacketReceived( + ReceivedPacket::CreateFromLegacy(data, size, packet_time_us, address)); + } + + void NotifyPacketReceived(const rtc::ReceivedPacket& packet); + RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker network_checker_{ webrtc::SequenceChecker::kDetached}; private: webrtc::CallbackList<AsyncPacketSocket*, int> on_close_ RTC_GUARDED_BY(&network_checker_); + absl::AnyInvocable<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)> + received_packet_callback_ RTC_GUARDED_BY(&network_checker_); }; // Listen socket, producing an AsyncPacketSocket when a peer connects. diff --git a/third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build b/third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build index 0038aa7ef8..40c8366f97 100644 --- a/third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/async_packet_socket_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/async_packet_socket_unittest.cc b/third_party/libwebrtc/rtc_base/async_packet_socket_unittest.cc new file mode 100644 index 0000000000..6cd4f09459 --- /dev/null +++ b/third_party/libwebrtc/rtc_base/async_packet_socket_unittest.cc @@ -0,0 +1,110 @@ +/* + * Copyright 2023 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/async_packet_socket.h" + +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace rtc { +namespace { + +using ::testing::MockFunction; + +class MockAsyncPacketSocket : public rtc::AsyncPacketSocket { + public: + ~MockAsyncPacketSocket() = default; + + MOCK_METHOD(SocketAddress, GetLocalAddress, (), (const, override)); + MOCK_METHOD(SocketAddress, GetRemoteAddress, (), (const, override)); + MOCK_METHOD(int, + Send, + (const void* pv, size_t cb, const rtc::PacketOptions& options), + (override)); + + MOCK_METHOD(int, + SendTo, + (const void* pv, + size_t cb, + const SocketAddress& addr, + const rtc::PacketOptions& options), + (override)); + MOCK_METHOD(int, Close, (), (override)); + MOCK_METHOD(State, GetState, (), (const, override)); + MOCK_METHOD(int, + GetOption, + (rtc::Socket::Option opt, int* value), + (override)); + MOCK_METHOD(int, SetOption, (rtc::Socket::Option opt, int value), (override)); + MOCK_METHOD(int, GetError, (), (const, override)); + MOCK_METHOD(void, SetError, (int error), (override)); + + void NotifyPacketReceived() { + char data[1] = {'a'}; + AsyncPacketSocket::NotifyPacketReceived(this, data, 1, SocketAddress(), -1); + } +}; + +TEST(AsyncPacketSocket, RegisteredCallbackReceivePacketsFromNotify) { + MockAsyncPacketSocket mock_socket; + MockFunction<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)> + received_packet; + + EXPECT_CALL(received_packet, Call); + mock_socket.RegisterReceivedPacketCallback(received_packet.AsStdFunction()); + mock_socket.NotifyPacketReceived(); +} + +TEST(AsyncPacketSocket, RegisteredCallbackReceivePacketsFromSignalReadPacket) { + MockAsyncPacketSocket mock_socket; + MockFunction<void(AsyncPacketSocket*, const rtc::ReceivedPacket&)> + received_packet; + + EXPECT_CALL(received_packet, Call); + mock_socket.RegisterReceivedPacketCallback(received_packet.AsStdFunction()); + char data[1] = {'a'}; + mock_socket.SignalReadPacket(&mock_socket, data, 1, SocketAddress(), -1); +} + +TEST(AsyncPacketSocket, SignalReadPacketTriggeredByNotifyPacketReceived) { + class SigslotPacketReceiver : public sigslot::has_slots<> { + public: + explicit SigslotPacketReceiver(rtc::AsyncPacketSocket& socket) { + socket.SignalReadPacket.connect(this, + &SigslotPacketReceiver::OnPacketReceived); + } + + bool packet_received() const { return packet_received_; } + + private: + void OnPacketReceived(AsyncPacketSocket*, + const char*, + size_t, + const SocketAddress&, + // TODO(bugs.webrtc.org/9584): Change to passing the + // int64_t timestamp by value. + const int64_t&) { + packet_received_ = true; + } + + bool packet_received_ = false; + }; + + MockAsyncPacketSocket mock_socket; + SigslotPacketReceiver receiver(mock_socket); + ASSERT_FALSE(receiver.packet_received()); + + mock_socket.NotifyPacketReceived(); + EXPECT_TRUE(receiver.packet_received()); +} + +} // namespace +} // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/async_resolver.cc b/third_party/libwebrtc/rtc_base/async_resolver.cc deleted file mode 100644 index f79200bc05..0000000000 --- a/third_party/libwebrtc/rtc_base/async_resolver.cc +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2008 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/async_resolver.h" - -#include <memory> -#include <string> -#include <utility> - -#include "absl/strings/string_view.h" -#include "api/ref_counted_base.h" -#include "rtc_base/synchronization/mutex.h" -#include "rtc_base/thread_annotations.h" - -#if defined(WEBRTC_WIN) -#include <ws2spi.h> -#include <ws2tcpip.h> - -#include "rtc_base/win32.h" -#endif -#if defined(WEBRTC_POSIX) && !defined(__native_client__) -#if defined(WEBRTC_ANDROID) -#include "rtc_base/ifaddrs_android.h" -#else -#include <ifaddrs.h> -#endif -#endif // defined(WEBRTC_POSIX) && !defined(__native_client__) - -#include "api/task_queue/task_queue_base.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/logging.h" -#include "rtc_base/platform_thread.h" -#include "rtc_base/task_queue.h" -#include "rtc_base/third_party/sigslot/sigslot.h" // for signal_with_thread... - -#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) -#include <dispatch/dispatch.h> -#endif - -namespace rtc { - -#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) -namespace { - -void GlobalGcdRunTask(void* context) { - std::unique_ptr<absl::AnyInvocable<void() &&>> task( - static_cast<absl::AnyInvocable<void() &&>*>(context)); - std::move (*task)(); -} - -// Post a task into the system-defined global concurrent queue. -void PostTaskToGlobalQueue( - std::unique_ptr<absl::AnyInvocable<void() &&>> task) { - dispatch_async_f( - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - task.release(), &GlobalGcdRunTask); -} - -} // namespace -#endif - -int ResolveHostname(absl::string_view hostname, - int family, - std::vector<IPAddress>* addresses) { -#ifdef __native_client__ - RTC_DCHECK_NOTREACHED(); - RTC_LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl"; - return -1; -#else // __native_client__ - if (!addresses) { - return -1; - } - addresses->clear(); - struct addrinfo* result = nullptr; - struct addrinfo hints = {0}; - hints.ai_family = family; - // `family` here will almost always be AF_UNSPEC, because `family` comes from - // AsyncResolver::addr_.family(), which comes from a SocketAddress constructed - // with a hostname. When a SocketAddress is constructed with a hostname, its - // family is AF_UNSPEC. However, if someday in the future we construct - // a SocketAddress with both a hostname and a family other than AF_UNSPEC, - // then it would be possible to get a specific family value here. - - // The behavior of AF_UNSPEC is roughly "get both ipv4 and ipv6", as - // documented by the various operating systems: - // Linux: http://man7.org/linux/man-pages/man3/getaddrinfo.3.html - // Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/ - // ms738520(v=vs.85).aspx - // Mac: https://developer.apple.com/legacy/library/documentation/Darwin/ - // Reference/ManPages/man3/getaddrinfo.3.html - // Android (source code, not documentation): - // https://android.googlesource.com/platform/bionic/+/ - // 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657 - hints.ai_flags = AI_ADDRCONFIG; - int ret = - getaddrinfo(std::string(hostname).c_str(), nullptr, &hints, &result); - if (ret != 0) { - return ret; - } - struct addrinfo* cursor = result; - for (; cursor; cursor = cursor->ai_next) { - if (family == AF_UNSPEC || cursor->ai_family == family) { - IPAddress ip; - if (IPFromAddrInfo(cursor, &ip)) { - addresses->push_back(ip); - } - } - } - freeaddrinfo(result); - return 0; -#endif // !__native_client__ -} - -struct AsyncResolver::State : public RefCountedBase { - webrtc::Mutex mutex; - enum class Status { - kLive, - kDead - } status RTC_GUARDED_BY(mutex) = Status::kLive; -}; - -AsyncResolver::AsyncResolver() : error_(-1), state_(new State) {} - -AsyncResolver::~AsyncResolver() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - - // Ensure the thread isn't using a stale reference to the current task queue, - // or calling into ResolveDone post destruction. - webrtc::MutexLock lock(&state_->mutex); - state_->status = State::Status::kDead; -} - -void RunResolution(void* obj) { - std::function<void()>* function_ptr = - static_cast<std::function<void()>*>(obj); - (*function_ptr)(); - delete function_ptr; -} - -void AsyncResolver::Start(const SocketAddress& addr) { - Start(addr, addr.family()); -} - -void AsyncResolver::Start(const SocketAddress& addr, int family) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(!destroy_called_); - addr_ = addr; - auto thread_function = [this, addr, family, - caller_task_queue = webrtc::TaskQueueBase::Current(), - state = state_] { - std::vector<IPAddress> addresses; - int error = ResolveHostname(addr.hostname(), family, &addresses); - webrtc::MutexLock lock(&state->mutex); - if (state->status == State::Status::kLive) { - caller_task_queue->PostTask( - [this, error, addresses = std::move(addresses), state] { - bool live; - { - // ResolveDone can lead to instance destruction, so make sure - // we don't deadlock. - webrtc::MutexLock lock(&state->mutex); - live = state->status == State::Status::kLive; - } - if (live) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - ResolveDone(std::move(addresses), error); - } - }); - } - }; -#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS) - PostTaskToGlobalQueue( - std::make_unique<absl::AnyInvocable<void() &&>>(thread_function)); -#else - PlatformThread::SpawnDetached(std::move(thread_function), "AsyncResolver"); -#endif -} - -bool AsyncResolver::GetResolvedAddress(int family, SocketAddress* addr) const { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(!destroy_called_); - if (error_ != 0 || addresses_.empty()) - return false; - - *addr = addr_; - for (size_t i = 0; i < addresses_.size(); ++i) { - if (family == addresses_[i].family()) { - addr->SetResolvedIP(addresses_[i]); - return true; - } - } - return false; -} - -int AsyncResolver::GetError() const { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(!destroy_called_); - return error_; -} - -void AsyncResolver::Destroy(bool wait) { - // Some callers have trouble guaranteeing that Destroy is called on the - // sequence guarded by `sequence_checker_`. - // RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(!destroy_called_); - destroy_called_ = true; - MaybeSelfDestruct(); -} - -const std::vector<IPAddress>& AsyncResolver::addresses() const { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(!destroy_called_); - return addresses_; -} - -void AsyncResolver::ResolveDone(std::vector<IPAddress> addresses, int error) { - addresses_ = addresses; - error_ = error; - recursion_check_ = true; - SignalDone(this); - MaybeSelfDestruct(); -} - -void AsyncResolver::MaybeSelfDestruct() { - if (!recursion_check_) { - delete this; - } else { - recursion_check_ = false; - } -} - -} // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/async_resolver.h b/third_party/libwebrtc/rtc_base/async_resolver.h deleted file mode 100644 index 9de4d12fed..0000000000 --- a/third_party/libwebrtc/rtc_base/async_resolver.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2008 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_ASYNC_RESOLVER_H_ -#define RTC_BASE_ASYNC_RESOLVER_H_ - -#if defined(WEBRTC_POSIX) -#include <sys/socket.h> -#elif WEBRTC_WIN -#include <winsock2.h> // NOLINT -#endif - -#include <vector> - -#include "api/sequence_checker.h" -#include "api/task_queue/pending_task_safety_flag.h" -#include "rtc_base/async_resolver_interface.h" -#include "rtc_base/event.h" -#include "rtc_base/ip_address.h" -#include "rtc_base/socket_address.h" -#include "rtc_base/system/no_unique_address.h" -#include "rtc_base/system/rtc_export.h" -#include "rtc_base/thread.h" -#include "rtc_base/thread_annotations.h" - -namespace rtc { - -// AsyncResolver will perform async DNS resolution, signaling the result on -// the SignalDone from AsyncResolverInterface when the operation completes. -// -// This class is thread-compatible, and all methods and destruction needs to -// happen from the same rtc::Thread, except for Destroy which is allowed to -// happen on another context provided it's not happening concurrently to another -// public API call, and is the last access to the object. -// TODO(bugs.webrtc.org/12598): Deprecate and remove -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wstrict-aliasing" -class [[deprecated("Use AsyncDnsResolver")]] RTC_EXPORT AsyncResolver - : public AsyncResolverInterface { -#pragma clang diagnostic pop - public: - AsyncResolver(); - ~AsyncResolver() override; - - void Start(const SocketAddress& addr) override; - void Start(const SocketAddress& addr, int family) override; - bool GetResolvedAddress(int family, SocketAddress* addr) const override; - int GetError() const override; - void Destroy(bool wait) override; - - const std::vector<IPAddress>& addresses() const; - - private: - // Fwd decl. - struct State; - - void ResolveDone(std::vector<IPAddress> addresses, int error) - RTC_EXCLUSIVE_LOCKS_REQUIRED(sequence_checker_); - void MaybeSelfDestruct(); - - SocketAddress addr_ RTC_GUARDED_BY(sequence_checker_); - std::vector<IPAddress> addresses_ RTC_GUARDED_BY(sequence_checker_); - int error_ RTC_GUARDED_BY(sequence_checker_); - bool recursion_check_ = - false; // Protects against SignalDone calling into Destroy. - bool destroy_called_ = false; - scoped_refptr<State> state_; - RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker sequence_checker_; -}; - -} // namespace rtc - -#endif // RTC_BASE_ASYNC_RESOLVER_H_ diff --git a/third_party/libwebrtc/rtc_base/async_resolver_interface.cc b/third_party/libwebrtc/rtc_base/async_resolver_interface.cc deleted file mode 100644 index ff8c87e346..0000000000 --- a/third_party/libwebrtc/rtc_base/async_resolver_interface.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2015 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/async_resolver_interface.h" - -namespace rtc { - -AsyncResolverInterface::AsyncResolverInterface() {} - -AsyncResolverInterface::~AsyncResolverInterface() = default; - -} // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/async_resolver_interface.h b/third_party/libwebrtc/rtc_base/async_resolver_interface.h deleted file mode 100644 index a0bda2774a..0000000000 --- a/third_party/libwebrtc/rtc_base/async_resolver_interface.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013 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_ASYNC_RESOLVER_INTERFACE_H_ -#define RTC_BASE_ASYNC_RESOLVER_INTERFACE_H_ - -#include "rtc_base/checks.h" -#include "rtc_base/socket_address.h" -#include "rtc_base/system/rtc_export.h" -#include "rtc_base/third_party/sigslot/sigslot.h" - -namespace rtc { - -// This interface defines the methods to resolve the address asynchronously. -// TODO(bugs.webrtc.org/12598): Deprecate and remove. -class [[deprecated("Use AsyncDnsResolver")]] RTC_EXPORT AsyncResolverInterface { - public: - AsyncResolverInterface(); - virtual ~AsyncResolverInterface(); - - // Start address resolution of the hostname in `addr`. - virtual void Start(const SocketAddress& addr) = 0; - // Start address resolution of the hostname in `addr` matching `family`. - virtual void Start(const SocketAddress& addr, int family) = 0; - // Returns true iff the address from `Start` was successfully resolved. - // If the address was successfully resolved, sets `addr` to a copy of the - // address from `Start` with the IP address set to the top most resolved - // address of `family` (`addr` will have both hostname and the resolved ip). - virtual bool GetResolvedAddress(int family, SocketAddress* addr) const = 0; - // Returns error from resolver. - virtual int GetError() const = 0; - // Delete the resolver. - virtual void Destroy(bool wait) = 0; - // Returns top most resolved IPv4 address if address is resolved successfully. - // Otherwise returns address set in SetAddress. - SocketAddress address() const { - SocketAddress addr; - GetResolvedAddress(AF_INET, &addr); - return addr; - } - - // This signal is fired when address resolve process is completed. - sigslot::signal1<AsyncResolverInterface*> SignalDone; -}; - -} // namespace rtc - -#endif diff --git a/third_party/libwebrtc/rtc_base/async_resolver_interface_gn/moz.build b/third_party/libwebrtc/rtc_base/async_resolver_interface_gn/moz.build deleted file mode 100644 index 485ef7ae1c..0000000000 --- a/third_party/libwebrtc/rtc_base/async_resolver_interface_gn/moz.build +++ /dev/null @@ -1,233 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - - ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ### - ### DO NOT edit it by hand. ### - -COMPILE_FLAGS["OS_INCLUDES"] = [] -AllowCompilerWarnings() - -DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1" -DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True -DEFINES["RTC_ENABLE_VP9"] = True -DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0" -DEFINES["WEBRTC_LIBRARY_IMPL"] = True -DEFINES["WEBRTC_MOZILLA_BUILD"] = True -DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0" -DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0" - -FINAL_LIBRARY = "webrtc" - - -LOCAL_INCLUDES += [ - "!/ipc/ipdl/_ipdlheaders", - "!/third_party/libwebrtc/gen", - "/ipc/chromium/src", - "/third_party/libwebrtc/", - "/third_party/libwebrtc/third_party/abseil-cpp/", - "/tools/profiler/public" -] - -UNIFIED_SOURCES += [ - "/third_party/libwebrtc/rtc_base/async_resolver_interface.cc" -] - -if not CONFIG["MOZ_DEBUG"]: - - DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0" - DEFINES["NDEBUG"] = True - DEFINES["NVALGRIND"] = True - -if CONFIG["MOZ_DEBUG"] == "1": - - DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1" - -if CONFIG["OS_TARGET"] == "Android": - - DEFINES["ANDROID"] = True - DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1" - DEFINES["HAVE_SYS_UIO_H"] = True - DEFINES["WEBRTC_ANDROID"] = True - DEFINES["WEBRTC_ANDROID_OPENSLES"] = True - DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True - DEFINES["WEBRTC_LINUX"] = True - DEFINES["WEBRTC_POSIX"] = True - DEFINES["_GNU_SOURCE"] = True - DEFINES["__STDC_CONSTANT_MACROS"] = True - DEFINES["__STDC_FORMAT_MACROS"] = True - - OS_LIBS += [ - "GLESv2", - "log" - ] - -if CONFIG["OS_TARGET"] == "Darwin": - - DEFINES["WEBRTC_MAC"] = True - DEFINES["WEBRTC_POSIX"] = True - DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True - DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0" - DEFINES["__STDC_CONSTANT_MACROS"] = True - DEFINES["__STDC_FORMAT_MACROS"] = True - -if CONFIG["OS_TARGET"] == "Linux": - - DEFINES["USE_AURA"] = "1" - DEFINES["USE_GLIB"] = "1" - DEFINES["USE_NSS_CERTS"] = "1" - DEFINES["USE_OZONE"] = "1" - DEFINES["USE_UDEV"] = True - DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True - DEFINES["WEBRTC_LINUX"] = True - DEFINES["WEBRTC_POSIX"] = True - DEFINES["_FILE_OFFSET_BITS"] = "64" - DEFINES["_LARGEFILE64_SOURCE"] = True - DEFINES["_LARGEFILE_SOURCE"] = True - DEFINES["__STDC_CONSTANT_MACROS"] = True - DEFINES["__STDC_FORMAT_MACROS"] = True - -if CONFIG["OS_TARGET"] == "OpenBSD": - - DEFINES["USE_GLIB"] = "1" - DEFINES["USE_OZONE"] = "1" - DEFINES["USE_X11"] = "1" - DEFINES["WEBRTC_BSD"] = True - DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True - DEFINES["WEBRTC_POSIX"] = True - DEFINES["_FILE_OFFSET_BITS"] = "64" - DEFINES["_LARGEFILE64_SOURCE"] = True - DEFINES["_LARGEFILE_SOURCE"] = True - DEFINES["__STDC_CONSTANT_MACROS"] = True - DEFINES["__STDC_FORMAT_MACROS"] = True - -if CONFIG["OS_TARGET"] == "WINNT": - - DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True - DEFINES["NOMINMAX"] = True - DEFINES["NTDDI_VERSION"] = "0x0A000000" - DEFINES["PSAPI_VERSION"] = "2" - DEFINES["RTC_ENABLE_WIN_WGC"] = True - DEFINES["UNICODE"] = True - DEFINES["USE_AURA"] = "1" - DEFINES["WEBRTC_WIN"] = True - DEFINES["WIN32"] = True - DEFINES["WIN32_LEAN_AND_MEAN"] = True - DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP" - DEFINES["WINVER"] = "0x0A00" - DEFINES["_ATL_NO_OPENGL"] = True - DEFINES["_CRT_RAND_S"] = True - DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True - DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True - DEFINES["_HAS_EXCEPTIONS"] = "0" - DEFINES["_HAS_NODISCARD"] = True - DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True - DEFINES["_SECURE_ATL"] = True - DEFINES["_UNICODE"] = True - DEFINES["_WIN32_WINNT"] = "0x0A00" - DEFINES["_WINDOWS"] = True - DEFINES["__STD_C"] = True - - OS_LIBS += [ - "crypt32", - "iphlpapi", - "secur32", - "winmm" - ] - -if CONFIG["TARGET_CPU"] == "aarch64": - - DEFINES["WEBRTC_ARCH_ARM64"] = True - DEFINES["WEBRTC_HAS_NEON"] = True - -if CONFIG["TARGET_CPU"] == "arm": - - CXXFLAGS += [ - "-mfpu=neon" - ] - - DEFINES["WEBRTC_ARCH_ARM"] = True - DEFINES["WEBRTC_ARCH_ARM_V7"] = True - DEFINES["WEBRTC_HAS_NEON"] = True - -if CONFIG["TARGET_CPU"] == "mips32": - - DEFINES["MIPS32_LE"] = True - DEFINES["MIPS_FPU_LE"] = True - DEFINES["_GNU_SOURCE"] = True - -if CONFIG["TARGET_CPU"] == "mips64": - - DEFINES["_GNU_SOURCE"] = True - -if CONFIG["TARGET_CPU"] == "x86": - - DEFINES["WEBRTC_ENABLE_AVX2"] = True - -if CONFIG["TARGET_CPU"] == "x86_64": - - DEFINES["WEBRTC_ENABLE_AVX2"] = True - -if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android": - - DEFINES["_DEBUG"] = True - -if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin": - - DEFINES["_DEBUG"] = True - -if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux": - - DEFINES["_DEBUG"] = True - -if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD": - - DEFINES["_DEBUG"] = True - -if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT": - - DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0" - -if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": - - DEFINES["USE_X11"] = "1" - -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": - - OS_LIBS += [ - "android_support", - "unwind" - ] - -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - CXXFLAGS += [ - "-msse2" - ] - - OS_LIBS += [ - "android_support" - ] - -if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": - - DEFINES["_GNU_SOURCE"] = True - -if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm": - - DEFINES["_GNU_SOURCE"] = True - -if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": - - CXXFLAGS += [ - "-msse2" - ] - - DEFINES["_GNU_SOURCE"] = True - -if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64": - - DEFINES["_GNU_SOURCE"] = True - -Library("async_resolver_interface_gn") diff --git a/third_party/libwebrtc/rtc_base/async_tcp_socket.cc b/third_party/libwebrtc/rtc_base/async_tcp_socket.cc index 367c5b04e7..2924340c16 100644 --- a/third_party/libwebrtc/rtc_base/async_tcp_socket.cc +++ b/third_party/libwebrtc/rtc_base/async_tcp_socket.cc @@ -14,6 +14,8 @@ #include <string.h> #include <algorithm> +#include <cstddef> +#include <cstdint> #include <memory> #include "api/array_view.h" @@ -209,15 +211,17 @@ void AsyncTCPSocketBase::OnReadEvent(Socket* socket) { return; } - size_t size = inbuf_.size(); - ProcessInput(inbuf_.data<char>(), &size); - - if (size > inbuf_.size()) { + size_t processed = ProcessInput(inbuf_); + size_t bytes_remaining = inbuf_.size() - processed; + if (processed > inbuf_.size()) { RTC_LOG(LS_ERROR) << "input buffer overflow"; RTC_DCHECK_NOTREACHED(); inbuf_.Clear(); } else { - inbuf_.SetSize(size); + if (bytes_remaining > 0) { + memmove(inbuf_.data(), inbuf_.data() + processed, bytes_remaining); + } + inbuf_.SetSize(bytes_remaining); } } @@ -283,24 +287,24 @@ int AsyncTCPSocket::Send(const void* pv, return static_cast<int>(cb); } -void AsyncTCPSocket::ProcessInput(char* data, size_t* len) { +size_t AsyncTCPSocket::ProcessInput(rtc::ArrayView<const uint8_t> data) { SocketAddress remote_addr(GetRemoteAddress()); + size_t processed_bytes = 0; while (true) { - if (*len < kPacketLenSize) - return; - - PacketLength pkt_len = rtc::GetBE16(data); - if (*len < kPacketLenSize + pkt_len) - return; - - SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr, - TimeMicros()); - - *len -= kPacketLenSize + pkt_len; - if (*len > 0) { - memmove(data, data + kPacketLenSize + pkt_len, *len); - } + size_t bytes_left = data.size() - processed_bytes; + if (bytes_left < kPacketLenSize) + return processed_bytes; + + PacketLength pkt_len = rtc::GetBE16(data.data() + processed_bytes); + if (bytes_left < kPacketLenSize + pkt_len) + return processed_bytes; + + rtc::ReceivedPacket received_packet( + data.subview(processed_bytes + kPacketLenSize, pkt_len), remote_addr, + webrtc::Timestamp::Micros(rtc::TimeMicros())); + NotifyPacketReceived(received_packet); + processed_bytes += kPacketLenSize + pkt_len; } } diff --git a/third_party/libwebrtc/rtc_base/async_tcp_socket.h b/third_party/libwebrtc/rtc_base/async_tcp_socket.h index 541080fba7..d3aff60520 100644 --- a/third_party/libwebrtc/rtc_base/async_tcp_socket.h +++ b/third_party/libwebrtc/rtc_base/async_tcp_socket.h @@ -13,8 +13,10 @@ #include <stddef.h> +#include <cstdint> #include <memory> +#include "api/array_view.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" #include "rtc_base/socket.h" @@ -37,7 +39,8 @@ class AsyncTCPSocketBase : public AsyncPacketSocket { int Send(const void* pv, size_t cb, const rtc::PacketOptions& options) override = 0; - virtual void ProcessInput(char* data, size_t* len) = 0; + // Must return the number of bytes processed. + virtual size_t ProcessInput(rtc::ArrayView<const uint8_t> data) = 0; SocketAddress GetLocalAddress() const override; SocketAddress GetRemoteAddress() const override; @@ -99,7 +102,7 @@ class AsyncTCPSocket : public AsyncTCPSocketBase { int Send(const void* pv, size_t cb, const rtc::PacketOptions& options) override; - void ProcessInput(char* data, size_t* len) override; + size_t ProcessInput(rtc::ArrayView<const uint8_t>) override; }; class AsyncTcpListenSocket : public AsyncListenSocket { diff --git a/third_party/libwebrtc/rtc_base/async_udp_socket.cc b/third_party/libwebrtc/rtc_base/async_udp_socket.cc index af7ae56fb6..358420a5de 100644 --- a/third_party/libwebrtc/rtc_base/async_udp_socket.cc +++ b/third_party/libwebrtc/rtc_base/async_udp_socket.cc @@ -136,8 +136,8 @@ void AsyncUDPSocket::OnReadEvent(Socket* socket) { // TODO: Make sure that we got all of the packet. // If we did not, then we should resize our buffer to be large enough. - SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr, - timestamp); + NotifyPacketReceived( + rtc::ReceivedPacket::CreateFromLegacy(buf_, len, timestamp, remote_addr)); } void AsyncUDPSocket::OnWriteEvent(Socket* socket) { diff --git a/third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build b/third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build index 62b75c06ce..c756a0eb11 100644 --- a/third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/audio_format_to_string_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build b/third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build index a4a4e8c6e4..ca5959866c 100644 --- a/third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/bit_buffer_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build b/third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build index 8836b1e089..8c00ef1ac5 100644 --- a/third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/bitrate_tracker_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build b/third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build index b6a5de1971..2047e015e4 100644 --- a/third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/bitstream_reader_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/buffer_gn/moz.build b/third_party/libwebrtc/rtc_base/buffer_gn/moz.build index cb5a45ce58..acbe827a94 100644 --- a/third_party/libwebrtc/rtc_base/buffer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/buffer_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/byte_buffer.cc b/third_party/libwebrtc/rtc_base/byte_buffer.cc index e1278337a4..a076f46ecb 100644 --- a/third_party/libwebrtc/rtc_base/byte_buffer.cc +++ b/third_party/libwebrtc/rtc_base/byte_buffer.cc @@ -19,23 +19,23 @@ ByteBufferWriter::ByteBufferWriter() : ByteBufferWriterT() {} ByteBufferWriter::ByteBufferWriter(const char* bytes, size_t len) : ByteBufferWriterT(bytes, len) {} -ByteBufferReader::ByteBufferReader(const char* bytes, size_t len) { - Construct(bytes, len); +ByteBufferReader::ByteBufferReader(rtc::ArrayView<const uint8_t> bytes) { + Construct(bytes.data(), bytes.size()); } -ByteBufferReader::ByteBufferReader(const char* bytes) { - Construct(bytes, strlen(bytes)); +ByteBufferReader::ByteBufferReader(const char* bytes, size_t len) { + Construct(reinterpret_cast<const uint8_t*>(bytes), len); } -ByteBufferReader::ByteBufferReader(const Buffer& buf) { - Construct(buf.data<char>(), buf.size()); +ByteBufferReader::ByteBufferReader(const char* bytes) { + Construct(reinterpret_cast<const uint8_t*>(bytes), strlen(bytes)); } ByteBufferReader::ByteBufferReader(const ByteBufferWriter& buf) { - Construct(buf.Data(), buf.Length()); + Construct(reinterpret_cast<const uint8_t*>(buf.Data()), buf.Length()); } -void ByteBufferReader::Construct(const char* bytes, size_t len) { +void ByteBufferReader::Construct(const uint8_t* bytes, size_t len) { bytes_ = bytes; size_ = len; start_ = 0; @@ -46,7 +46,7 @@ bool ByteBufferReader::ReadUInt8(uint8_t* val) { if (!val) return false; - return ReadBytes(reinterpret_cast<char*>(val), 1); + return ReadBytes(val, 1); } bool ByteBufferReader::ReadUInt16(uint16_t* val) { @@ -54,7 +54,7 @@ bool ByteBufferReader::ReadUInt16(uint16_t* val) { return false; uint16_t v; - if (!ReadBytes(reinterpret_cast<char*>(&v), 2)) { + if (!ReadBytes(reinterpret_cast<uint8_t*>(&v), 2)) { return false; } else { *val = NetworkToHost16(v); @@ -67,7 +67,7 @@ bool ByteBufferReader::ReadUInt24(uint32_t* val) { return false; uint32_t v = 0; - char* read_into = reinterpret_cast<char*>(&v); + uint8_t* read_into = reinterpret_cast<uint8_t*>(&v); ++read_into; if (!ReadBytes(read_into, 3)) { @@ -83,7 +83,7 @@ bool ByteBufferReader::ReadUInt32(uint32_t* val) { return false; uint32_t v; - if (!ReadBytes(reinterpret_cast<char*>(&v), 4)) { + if (!ReadBytes(reinterpret_cast<uint8_t*>(&v), 4)) { return false; } else { *val = NetworkToHost32(v); @@ -96,7 +96,7 @@ bool ByteBufferReader::ReadUInt64(uint64_t* val) { return false; uint64_t v; - if (!ReadBytes(reinterpret_cast<char*>(&v), 8)) { + if (!ReadBytes(reinterpret_cast<uint8_t*>(&v), 8)) { return false; } else { *val = NetworkToHost64(v); @@ -112,14 +112,14 @@ bool ByteBufferReader::ReadUVarint(uint64_t* val) { // continuation byte (msb=1) if there are more bytes to be read. uint64_t v = 0; for (int i = 0; i < 64; i += 7) { - char byte; + uint8_t byte; if (!ReadBytes(&byte, 1)) { return false; } // Read the first 7 bits of the byte, then offset by bits read so far. v |= (static_cast<uint64_t>(byte) & 0x7F) << i; - // True if the msb is not a continuation byte. - if (static_cast<uint64_t>(byte) < 0x80) { + // Return if the msb is not a continuation byte. + if (byte < 0x80) { *val = v; return true; } @@ -134,20 +134,34 @@ bool ByteBufferReader::ReadString(std::string* val, size_t len) { if (len > Length()) { return false; } else { - val->append(bytes_ + start_, len); + val->append(reinterpret_cast<const char*>(bytes_ + start_), len); start_ += len; return true; } } +bool ByteBufferReader::ReadBytes(rtc::ArrayView<uint8_t> val) { + if (val.size() == 0) { + return true; + } + return ReadBytes(val.data(), val.size()); +} + bool ByteBufferReader::ReadBytes(char* val, size_t len) { + return ReadBytes(reinterpret_cast<uint8_t*>(val), len); +} + +// Private function supporting the other Read* functions. +bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) { if (len > Length()) { return false; - } else { - memcpy(val, bytes_ + start_, len); - start_ += len; + } + if (len == 0) { return true; } + memcpy(val, bytes_ + start_, len); + start_ += len; + return true; } bool ByteBufferReader::Consume(size_t size) { diff --git a/third_party/libwebrtc/rtc_base/byte_buffer.h b/third_party/libwebrtc/rtc_base/byte_buffer.h index 9bcbb838aa..c15773779e 100644 --- a/third_party/libwebrtc/rtc_base/byte_buffer.h +++ b/third_party/libwebrtc/rtc_base/byte_buffer.h @@ -16,7 +16,9 @@ #include <string> +#include "absl/base/attributes.h" #include "absl/strings/string_view.h" +#include "api/array_view.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" @@ -25,39 +27,54 @@ namespace rtc { template <class BufferClassT> class ByteBufferWriterT { + using value_type = typename BufferClassT::value_type; + public: ByteBufferWriterT() { Construct(nullptr, kDefaultCapacity); } - ByteBufferWriterT(const char* bytes, size_t len) { Construct(bytes, len); } + ByteBufferWriterT(const value_type* bytes, size_t len) { + Construct(bytes, len); + } ByteBufferWriterT(const ByteBufferWriterT&) = delete; ByteBufferWriterT& operator=(const ByteBufferWriterT&) = delete; - const char* Data() const { return buffer_.data(); } + const value_type* Data() const { return buffer_.data(); } size_t Length() const { return buffer_.size(); } size_t Capacity() const { return buffer_.capacity(); } + rtc::ArrayView<const value_type> DataView() const { + return rtc::MakeArrayView(Data(), Length()); + } + // Accessor that returns a string_view, independent of underlying type. + // Intended to provide access for existing users that expect char* + // when the underlying type changes to uint8_t. + // TODO(bugs.webrtc.org/15665): Delete when users are converted. + absl::string_view DataAsStringView() const { + return absl::string_view(reinterpret_cast<const char*>(Data()), Length()); + } + char* DataAsCharPointer() const { return reinterpret_cast<char*>(Data()); } // Write value to the buffer. Resizes the buffer when it is // neccessary. void WriteUInt8(uint8_t val) { - WriteBytes(reinterpret_cast<const char*>(&val), 1); + WriteBytes(reinterpret_cast<const value_type*>(&val), 1); } void WriteUInt16(uint16_t val) { uint16_t v = HostToNetwork16(val); - WriteBytes(reinterpret_cast<const char*>(&v), 2); + WriteBytes(reinterpret_cast<const value_type*>(&v), 2); } void WriteUInt24(uint32_t val) { uint32_t v = HostToNetwork32(val); - char* start = reinterpret_cast<char*>(&v); + value_type* start = reinterpret_cast<value_type*>(&v); ++start; WriteBytes(start, 3); } void WriteUInt32(uint32_t val) { uint32_t v = HostToNetwork32(val); - WriteBytes(reinterpret_cast<const char*>(&v), 4); + WriteBytes(reinterpret_cast<const value_type*>(&v), 4); } void WriteUInt64(uint64_t val) { uint64_t v = HostToNetwork64(val); - WriteBytes(reinterpret_cast<const char*>(&v), 8); + WriteBytes(reinterpret_cast<const value_type*>(&v), 8); } // Serializes an unsigned varint in the format described by // https://developers.google.com/protocol-buffers/docs/encoding#varints @@ -66,22 +83,24 @@ class ByteBufferWriterT { while (val >= 0x80) { // Write 7 bits at a time, then set the msb to a continuation byte // (msb=1). - char byte = static_cast<char>(val) | 0x80; + value_type byte = static_cast<value_type>(val) | 0x80; WriteBytes(&byte, 1); val >>= 7; } - char last_byte = static_cast<char>(val); + value_type last_byte = static_cast<value_type>(val); WriteBytes(&last_byte, 1); } void WriteString(absl::string_view val) { WriteBytes(val.data(), val.size()); } - void WriteBytes(const char* val, size_t len) { buffer_.AppendData(val, len); } + void WriteBytes(const value_type* val, size_t len) { + buffer_.AppendData(val, len); + } - // Reserves the given number of bytes and returns a char* that can be written - // into. Useful for functions that require a char* buffer and not a - // ByteBufferWriter. - char* ReserveWriteBuffer(size_t len) { + // Reserves the given number of bytes and returns a value_type* that can be + // written into. Useful for functions that require a value_type* buffer and + // not a ByteBufferWriter. + value_type* ReserveWriteBuffer(size_t len) { buffer_.SetSize(buffer_.size() + len); return buffer_.data(); } @@ -95,7 +114,7 @@ class ByteBufferWriterT { private: static constexpr size_t kDefaultCapacity = 4096; - void Construct(const char* bytes, size_t size) { + void Construct(const value_type* bytes, size_t size) { if (bytes) { buffer_.AppendData(bytes, size); } else { @@ -122,22 +141,31 @@ class ByteBufferWriter : public ByteBufferWriterT<BufferT<char>> { // valid during the lifetime of the reader. class ByteBufferReader { public: - ByteBufferReader(const char* bytes, size_t len); + [[deprecated("Use ArrayView<uint8_t>")]] ByteBufferReader(const char* bytes, + size_t len); + + explicit ByteBufferReader( + rtc::ArrayView<const uint8_t> bytes ABSL_ATTRIBUTE_LIFETIME_BOUND); // Initializes buffer from a zero-terminated string. explicit ByteBufferReader(const char* bytes); - explicit ByteBufferReader(const Buffer& buf); - explicit ByteBufferReader(const ByteBufferWriter& buf); ByteBufferReader(const ByteBufferReader&) = delete; ByteBufferReader& operator=(const ByteBufferReader&) = delete; // Returns start of unprocessed data. - const char* Data() const { return bytes_ + start_; } + // TODO(bugs.webrtc.org/15661): Deprecate and remove. + const char* Data() const { + return reinterpret_cast<const char*>(bytes_ + start_); + } // Returns number of unprocessed bytes. size_t Length() const { return end_ - start_; } + // Returns a view of the unprocessed data. + rtc::ArrayView<const uint8_t> DataView() const { + return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_); + } // Read a next value from the buffer. Return false if there isn't // enough data left for the specified type. @@ -147,7 +175,10 @@ class ByteBufferReader { bool ReadUInt32(uint32_t* val); bool ReadUInt64(uint64_t* val); bool ReadUVarint(uint64_t* val); - bool ReadBytes(char* val, size_t len); + bool ReadBytes(rtc::ArrayView<uint8_t> val); + // For backwards compatibility. + // TODO(bugs.webrtc.org/15661): Deprecate and remove. + [[deprecated("Read using ArrayView")]] bool ReadBytes(char* val, size_t len); // Appends next `len` bytes from the buffer to `val`. Returns false // if there is less than `len` bytes left. @@ -159,10 +190,11 @@ class ByteBufferReader { // after this call. bool Consume(size_t size); - protected: - void Construct(const char* bytes, size_t size); + private: + void Construct(const uint8_t* bytes, size_t size); + bool ReadBytes(uint8_t* val, size_t len); - const char* bytes_; + const uint8_t* bytes_; size_t size_; size_t start_; size_t end_; diff --git a/third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build b/third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build index b093b72f1f..4d9cc19bfb 100644 --- a/third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/byte_buffer_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/byte_buffer_unittest.cc b/third_party/libwebrtc/rtc_base/byte_buffer_unittest.cc index 4f8043c98f..f65299e639 100644 --- a/third_party/libwebrtc/rtc_base/byte_buffer_unittest.cc +++ b/third_party/libwebrtc/rtc_base/byte_buffer_unittest.cc @@ -12,6 +12,8 @@ #include <string.h> +#include <cstdint> + #include "rtc_base/arraysize.h" #include "rtc_base/byte_order.h" #include "test/gtest.h" @@ -83,14 +85,14 @@ TEST(ByteBufferTest, TestBufferLength) { TEST(ByteBufferTest, TestReadWriteBuffer) { ByteBufferWriter buffer; - ByteBufferReader read_buf(nullptr, 0); + ByteBufferReader read_buf(rtc::ArrayView<const uint8_t>(nullptr, 0)); uint8_t ru8; EXPECT_FALSE(read_buf.ReadUInt8(&ru8)); // Write and read uint8_t. uint8_t wu8 = 1; buffer.WriteUInt8(wu8); - ByteBufferReader read_buf1(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf1(buffer); EXPECT_TRUE(read_buf1.ReadUInt8(&ru8)); EXPECT_EQ(wu8, ru8); EXPECT_EQ(0U, read_buf1.Length()); @@ -99,7 +101,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read uint16_t. uint16_t wu16 = (1 << 8) + 1; buffer.WriteUInt16(wu16); - ByteBufferReader read_buf2(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf2(buffer); uint16_t ru16; EXPECT_TRUE(read_buf2.ReadUInt16(&ru16)); EXPECT_EQ(wu16, ru16); @@ -109,7 +111,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read uint24. uint32_t wu24 = (3 << 16) + (2 << 8) + 1; buffer.WriteUInt24(wu24); - ByteBufferReader read_buf3(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf3(buffer); uint32_t ru24; EXPECT_TRUE(read_buf3.ReadUInt24(&ru24)); EXPECT_EQ(wu24, ru24); @@ -119,7 +121,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read uint32_t. uint32_t wu32 = (4 << 24) + (3 << 16) + (2 << 8) + 1; buffer.WriteUInt32(wu32); - ByteBufferReader read_buf4(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf4(buffer); uint32_t ru32; EXPECT_TRUE(read_buf4.ReadUInt32(&ru32)); EXPECT_EQ(wu32, ru32); @@ -130,7 +132,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { uint32_t another32 = (8 << 24) + (7 << 16) + (6 << 8) + 5; uint64_t wu64 = (static_cast<uint64_t>(another32) << 32) + wu32; buffer.WriteUInt64(wu64); - ByteBufferReader read_buf5(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf5(buffer); uint64_t ru64; EXPECT_TRUE(read_buf5.ReadUInt64(&ru64)); EXPECT_EQ(wu64, ru64); @@ -140,7 +142,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read string. std::string write_string("hello"); buffer.WriteString(write_string); - ByteBufferReader read_buf6(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf6(buffer); std::string read_string; EXPECT_TRUE(read_buf6.ReadString(&read_string, write_string.size())); EXPECT_EQ(write_string, read_string); @@ -150,9 +152,9 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read bytes char write_bytes[] = "foo"; buffer.WriteBytes(write_bytes, 3); - ByteBufferReader read_buf7(buffer.Data(), buffer.Length()); - char read_bytes[3]; - EXPECT_TRUE(read_buf7.ReadBytes(read_bytes, 3)); + ByteBufferReader read_buf7(buffer); + uint8_t read_bytes[3]; + EXPECT_TRUE(read_buf7.ReadBytes(read_bytes)); for (int i = 0; i < 3; ++i) { EXPECT_EQ(write_bytes[i], read_bytes[i]); } @@ -162,9 +164,9 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { // Write and read reserved buffer space char* write_dst = buffer.ReserveWriteBuffer(3); memcpy(write_dst, write_bytes, 3); - ByteBufferReader read_buf8(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf8(buffer); memset(read_bytes, 0, 3); - EXPECT_TRUE(read_buf8.ReadBytes(read_bytes, 3)); + EXPECT_TRUE(read_buf8.ReadBytes(read_bytes)); for (int i = 0; i < 3; ++i) { EXPECT_EQ(write_bytes[i], read_bytes[i]); } @@ -177,7 +179,7 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { buffer.WriteUInt24(wu24); buffer.WriteUInt32(wu32); buffer.WriteUInt64(wu64); - ByteBufferReader read_buf9(buffer.Data(), buffer.Length()); + ByteBufferReader read_buf9(buffer); EXPECT_TRUE(read_buf9.ReadUInt8(&ru8)); EXPECT_EQ(wu8, ru8); EXPECT_TRUE(read_buf9.ReadUInt16(&ru16)); @@ -217,7 +219,7 @@ TEST(ByteBufferTest, TestReadWriteUVarint) { size += 6; EXPECT_EQ(size, write_buffer.Length()); - ByteBufferReader read_buffer(write_buffer.Data(), write_buffer.Length()); + ByteBufferReader read_buffer(write_buffer); EXPECT_EQ(size, read_buffer.Length()); uint64_t val1, val2, val3, val4, val5; @@ -247,4 +249,33 @@ TEST(ByteBufferTest, TestReadWriteUVarint) { EXPECT_EQ(size, read_buffer.Length()); } +TEST(ByteBufferTest, ReadFromArrayView) { + const uint8_t buf[] = {'a', 'b', 'c'}; + ArrayView<const uint8_t> view(buf, 3); + + ByteBufferReader read_buffer(view); + uint8_t val; + EXPECT_TRUE(read_buffer.ReadUInt8(&val)); + EXPECT_EQ(val, 'a'); + EXPECT_TRUE(read_buffer.ReadUInt8(&val)); + EXPECT_EQ(val, 'b'); + EXPECT_TRUE(read_buffer.ReadUInt8(&val)); + EXPECT_EQ(val, 'c'); + EXPECT_FALSE(read_buffer.ReadUInt8(&val)); +} + +TEST(ByteBufferTest, ReadToArrayView) { + const uint8_t buf[] = {'a', 'b', 'c'}; + ArrayView<const uint8_t> stored_view(buf, 3); + ByteBufferReader read_buffer(stored_view); + uint8_t result[] = {'1', '2', '3'}; + EXPECT_TRUE(read_buffer.ReadBytes(rtc::MakeArrayView(result, 2))); + EXPECT_EQ(result[0], 'a'); + EXPECT_EQ(result[1], 'b'); + EXPECT_EQ(result[2], '3'); + EXPECT_TRUE(read_buffer.ReadBytes(rtc::MakeArrayView(&result[2], 1))); + EXPECT_EQ(result[2], 'c'); + EXPECT_FALSE(read_buffer.ReadBytes(rtc::MakeArrayView(result, 1))); +} + } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/byte_order_gn/moz.build b/third_party/libwebrtc/rtc_base/byte_order_gn/moz.build index 21ea639dd4..621abaa96d 100644 --- a/third_party/libwebrtc/rtc_base/byte_order_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/byte_order_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/checks_gn/moz.build b/third_party/libwebrtc/rtc_base/checks_gn/moz.build index f2ef2e2a78..ee982603d3 100644 --- a/third_party/libwebrtc/rtc_base/checks_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/checks_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build b/third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build index 9f6999032d..62b89c7deb 100644 --- a/third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/compile_assert_c_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build b/third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build index 8fd59a6ce2..ff33c5381a 100644 --- a/third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/containers/flat_containers_internal_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build b/third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build index 164aae2969..9b6add6b86 100644 --- a/third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/containers/flat_map_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build b/third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build index 5283c7e3d3..4b398de383 100644 --- a/third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/containers/flat_set_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/copy_on_write_buffer.h b/third_party/libwebrtc/rtc_base/copy_on_write_buffer.h index 8332ee6f62..bc5e82f89f 100644 --- a/third_party/libwebrtc/rtc_base/copy_on_write_buffer.h +++ b/third_party/libwebrtc/rtc_base/copy_on_write_buffer.h @@ -132,6 +132,8 @@ class RTC_EXPORT CopyOnWriteBuffer { return buffer_->data<T>() + offset_; } + bool empty() const { return size_ == 0; } + size_t size() const { RTC_DCHECK(IsConsistent()); return size_; diff --git a/third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build b/third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build index f026e25abd..cb8e9c4a5f 100644 --- a/third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/copy_on_write_buffer_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/copy_on_write_buffer_unittest.cc b/third_party/libwebrtc/rtc_base/copy_on_write_buffer_unittest.cc index 8a9fc4e2f4..8bf53c4d4c 100644 --- a/third_party/libwebrtc/rtc_base/copy_on_write_buffer_unittest.cc +++ b/third_party/libwebrtc/rtc_base/copy_on_write_buffer_unittest.cc @@ -46,11 +46,20 @@ void EnsureBuffersDontShareData(const CopyOnWriteBuffer& buf1, TEST(CopyOnWriteBufferTest, TestCreateEmptyData) { CopyOnWriteBuffer buf(static_cast<const uint8_t*>(nullptr), 0); + EXPECT_TRUE(buf.empty()); EXPECT_EQ(buf.size(), 0u); EXPECT_EQ(buf.capacity(), 0u); EXPECT_EQ(buf.data(), nullptr); } +TEST(CopyOnWriteBufferTest, CreateEmptyDataWithCapacity) { + CopyOnWriteBuffer buf(0, 16); + EXPECT_TRUE(buf.empty()); + EXPECT_EQ(buf.size(), 0u); + EXPECT_EQ(buf.capacity(), 16u); + EXPECT_NE(buf.MutableData(), nullptr); +} + TEST(CopyOnWriteBufferTest, TestMoveConstruct) { EXPECT_TRUE(std::is_nothrow_move_constructible_v<CopyOnWriteBuffer>); @@ -60,9 +69,11 @@ TEST(CopyOnWriteBufferTest, TestMoveConstruct) { const uint8_t* buf1_data = buf1.cdata(); CopyOnWriteBuffer buf2(std::move(buf1)); + EXPECT_TRUE(buf1.empty()); EXPECT_EQ(buf1.size(), 0u); EXPECT_EQ(buf1.capacity(), 0u); EXPECT_EQ(buf1.data(), nullptr); + EXPECT_FALSE(buf2.empty()); EXPECT_EQ(buf2.size(), buf1_size); EXPECT_EQ(buf2.capacity(), buf1_capacity); EXPECT_EQ(buf2.data(), buf1_data); @@ -127,6 +138,7 @@ TEST(CopyOnWriteBufferTest, SetEmptyData) { buf.SetData<uint8_t>(nullptr, 0); EXPECT_EQ(0u, buf.size()); + EXPECT_TRUE(buf.empty()); } TEST(CopyOnWriteBufferTest, SetDataNoMoreThanCapacityDoesntCauseReallocation) { diff --git a/third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build b/third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build index 4aa1aa4353..a681a12746 100644 --- a/third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/criticalsection_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/divide_round_gn/moz.build b/third_party/libwebrtc/rtc_base/divide_round_gn/moz.build index 79146161c2..f30da236c4 100644 --- a/third_party/libwebrtc/rtc_base/divide_round_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/divide_round_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/dscp_gn/moz.build b/third_party/libwebrtc/rtc_base/dscp_gn/moz.build index 7bfe2d0c75..5f1d97d2e8 100644 --- a/third_party/libwebrtc/rtc_base/dscp_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/dscp_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build b/third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build index 06daf6b03a..9ff988a251 100644 --- a/third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/event_tracer_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build index 4435f010b6..1857d67850 100644 --- a/third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/alr_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build index cbbb32ab70..3a258e4696 100644 --- a/third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/balanced_degradation_settings_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/bandwidth_quality_scaler_settings_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/bandwidth_quality_scaler_settings_gn/moz.build index 95a92d20e1..b8a6ccdd29 100644 --- a/third_party/libwebrtc/rtc_base/experiments/bandwidth_quality_scaler_settings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/bandwidth_quality_scaler_settings_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/cpu_speed_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/cpu_speed_experiment_gn/moz.build index 5151c986c4..b436f5962d 100644 --- a/third_party/libwebrtc/rtc_base/experiments/cpu_speed_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/cpu_speed_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build index b7a699fe03..ad4be851e0 100644 --- a/third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/encoder_info_settings_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build index ea63aafc99..31a945e00f 100644 --- a/third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/field_trial_parser_gn/moz.build @@ -198,7 +198,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -208,10 +207,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build index 3857bc9451..3b5cbf462f 100644 --- a/third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/keyframe_interval_settings_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build index 5f811a6c6d..e2c4f2537e 100644 --- a/third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/min_video_bitrate_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build index 68ad8a0f14..2cdcea5897 100644 --- a/third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/normalize_simulcast_size_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/quality_rampup_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/quality_rampup_experiment_gn/moz.build index c4b1f5bc22..234db8e906 100644 --- a/third_party/libwebrtc/rtc_base/experiments/quality_rampup_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/quality_rampup_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build index 298ca9297c..8ea1b50754 100644 --- a/third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/quality_scaler_settings_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build index d606a38148..36a79a7347 100644 --- a/third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/quality_scaling_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build index be85251358..416e7a35c7 100644 --- a/third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/rate_control_settings_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/rtt_mult_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/rtt_mult_experiment_gn/moz.build index 7229d639e8..32fd27e4ef 100644 --- a/third_party/libwebrtc/rtc_base/experiments/rtt_mult_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/rtt_mult_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build b/third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build index d031f8ace4..bdf9e49985 100644 --- a/third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/experiments/stable_target_rate_experiment_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build b/third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build index 30c52de724..e7a94c5776 100644 --- a/third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/frequency_tracker_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build b/third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build index eb85347810..54596d501f 100644 --- a/third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/gtest_prod_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build b/third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build index ee30758d89..48d98b418b 100644 --- a/third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/histogram_percentile_counter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build b/third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build index 7985a5f7fe..6697a8f93c 100644 --- a/third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/ifaddrs_android_gn/moz.build @@ -77,7 +77,6 @@ if CONFIG["TARGET_CPU"] == "arm": DEFINES["WEBRTC_HAS_NEON"] = True OS_LIBS += [ - "android_support", "unwind" ] @@ -89,10 +88,6 @@ if CONFIG["TARGET_CPU"] == "x86": DEFINES["WEBRTC_ENABLE_AVX2"] = True - OS_LIBS += [ - "android_support" - ] - if CONFIG["TARGET_CPU"] == "x86_64": DEFINES["WEBRTC_ENABLE_AVX2"] = True diff --git a/third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build b/third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build index 15c6052f7b..502a867a4b 100644 --- a/third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/ignore_wundef_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/ip_address_gn/moz.build b/third_party/libwebrtc/rtc_base/ip_address_gn/moz.build index a893dab3c2..108fd06e54 100644 --- a/third_party/libwebrtc/rtc_base/ip_address_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/ip_address_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/logging_gn/moz.build b/third_party/libwebrtc/rtc_base/logging_gn/moz.build index 02f74cddfa..85c9773f24 100644 --- a/third_party/libwebrtc/rtc_base/logging_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/logging_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/macromagic_gn/moz.build b/third_party/libwebrtc/rtc_base/macromagic_gn/moz.build index b44dfa38f5..949d31b870 100644 --- a/third_party/libwebrtc/rtc_base/macromagic_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/macromagic_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build b/third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build index f5720480dd..8709bdd95b 100644 --- a/third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/memory/aligned_malloc_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build b/third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build index 84e775fe74..43f0844548 100644 --- a/third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/mod_ops_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build b/third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build index 5cd827786e..15ef767b07 100644 --- a/third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/moving_max_counter_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/nat_unittest.cc b/third_party/libwebrtc/rtc_base/nat_unittest.cc index 19e53543ba..432985d283 100644 --- a/third_party/libwebrtc/rtc_base/nat_unittest.cc +++ b/third_party/libwebrtc/rtc_base/nat_unittest.cc @@ -11,14 +11,17 @@ #include <string.h> #include <algorithm> +#include <cstddef> #include <memory> #include <string> #include <vector> #include "absl/memory/memory.h" +#include "api/units/time_delta.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_tcp_socket.h" #include "rtc_base/async_udp_socket.h" +#include "rtc_base/event.h" #include "rtc_base/gunit.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" @@ -80,29 +83,36 @@ void TestSend(SocketServer* internal, NATSocketFactory* natsf = new NATSocketFactory( internal, nat->internal_udp_address(), nat->internal_tcp_address()); - TestClient* in = CreateTestClient(natsf, internal_addr); - TestClient* out[4]; - for (int i = 0; i < 4; i++) - out[i] = CreateTestClient(external, external_addrs[i]); - th_int.Start(); th_ext.Start(); + TestClient* in; + th_int.BlockingCall([&] { in = CreateTestClient(natsf, internal_addr); }); + + TestClient* out[4]; + th_ext.BlockingCall([&] { + for (int i = 0; i < 4; i++) + out[i] = CreateTestClient(external, external_addrs[i]); + }); + const char* buf = "filter_test"; size_t len = strlen(buf); - in->SendTo(buf, len, out[0]->address()); + th_int.BlockingCall([&] { in->SendTo(buf, len, out[0]->address()); }); SocketAddress trans_addr; - EXPECT_TRUE(out[0]->CheckNextPacket(buf, len, &trans_addr)); + th_ext.BlockingCall( + [&] { EXPECT_TRUE(out[0]->CheckNextPacket(buf, len, &trans_addr)); }); for (int i = 1; i < 4; i++) { - in->SendTo(buf, len, out[i]->address()); + th_int.BlockingCall([&] { in->SendTo(buf, len, out[i]->address()); }); SocketAddress trans_addr2; - EXPECT_TRUE(out[i]->CheckNextPacket(buf, len, &trans_addr2)); - bool are_same = (trans_addr == trans_addr2); - ASSERT_EQ(are_same, exp_same) << "same translated address"; - ASSERT_NE(AF_UNSPEC, trans_addr.family()); - ASSERT_NE(AF_UNSPEC, trans_addr2.family()); + th_ext.BlockingCall([&] { + EXPECT_TRUE(out[i]->CheckNextPacket(buf, len, &trans_addr2)); + bool are_same = (trans_addr == trans_addr2); + ASSERT_EQ(are_same, exp_same) << "same translated address"; + ASSERT_NE(AF_UNSPEC, trans_addr.family()); + ASSERT_NE(AF_UNSPEC, trans_addr2.family()); + }); } th_int.Stop(); @@ -134,29 +144,39 @@ void TestRecv(SocketServer* internal, NATSocketFactory* natsf = new NATSocketFactory( internal, nat->internal_udp_address(), nat->internal_tcp_address()); - TestClient* in = CreateTestClient(natsf, internal_addr); - TestClient* out[4]; - for (int i = 0; i < 4; i++) - out[i] = CreateTestClient(external, external_addrs[i]); - th_int.Start(); th_ext.Start(); + TestClient* in = nullptr; + th_int.BlockingCall([&] { in = CreateTestClient(natsf, internal_addr); }); + + TestClient* out[4]; + th_ext.BlockingCall([&] { + for (int i = 0; i < 4; i++) + out[i] = CreateTestClient(external, external_addrs[i]); + }); + const char* buf = "filter_test"; size_t len = strlen(buf); - in->SendTo(buf, len, out[0]->address()); + th_int.BlockingCall([&] { in->SendTo(buf, len, out[0]->address()); }); SocketAddress trans_addr; - EXPECT_TRUE(out[0]->CheckNextPacket(buf, len, &trans_addr)); + th_ext.BlockingCall( + [&] { EXPECT_TRUE(out[0]->CheckNextPacket(buf, len, &trans_addr)); }); + + th_ext.BlockingCall([&] { out[1]->SendTo(buf, len, trans_addr); }); + th_int.BlockingCall( + [&] { EXPECT_TRUE(CheckReceive(in, !filter_ip, buf, len)); }); + th_ext.BlockingCall([&] { out[2]->SendTo(buf, len, trans_addr); }); - out[1]->SendTo(buf, len, trans_addr); - EXPECT_TRUE(CheckReceive(in, !filter_ip, buf, len)); + th_int.BlockingCall( + [&] { EXPECT_TRUE(CheckReceive(in, !filter_port, buf, len)); }); - out[2]->SendTo(buf, len, trans_addr); - EXPECT_TRUE(CheckReceive(in, !filter_port, buf, len)); + th_ext.BlockingCall([&] { out[3]->SendTo(buf, len, trans_addr); }); - out[3]->SendTo(buf, len, trans_addr); - EXPECT_TRUE(CheckReceive(in, !filter_ip && !filter_port, buf, len)); + th_int.BlockingCall([&] { + EXPECT_TRUE(CheckReceive(in, !filter_ip && !filter_port, buf, len)); + }); th_int.Stop(); th_ext.Stop(); diff --git a/third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build b/third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build index c036110d1a..ceb2150c06 100644 --- a/third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/net_helpers_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/network/BUILD.gn b/third_party/libwebrtc/rtc_base/network/BUILD.gn index a42745a4c0..7e9cf7ab68 100644 --- a/third_party/libwebrtc/rtc_base/network/BUILD.gn +++ b/third_party/libwebrtc/rtc_base/network/BUILD.gn @@ -23,8 +23,10 @@ rtc_library("received_packet") { "received_packet.h", ] deps = [ + "..:socket_address", "../../api:array_view", "../../api/units:timestamp", + "../system:rtc_export", ] absl_deps = [ "//third_party/abseil-cpp/absl/functional:any_invocable", diff --git a/third_party/libwebrtc/rtc_base/network/received_packet.cc b/third_party/libwebrtc/rtc_base/network/received_packet.cc index 9612c3dab4..40d6e1142c 100644 --- a/third_party/libwebrtc/rtc_base/network/received_packet.cc +++ b/third_party/libwebrtc/rtc_base/network/received_packet.cc @@ -17,7 +17,26 @@ namespace rtc { ReceivedPacket::ReceivedPacket(rtc::ArrayView<const uint8_t> payload, + const SocketAddress& source_address, absl::optional<webrtc::Timestamp> arrival_time) - : payload_(payload), arrival_time_(std::move(arrival_time)) {} + : payload_(payload), + arrival_time_(std::move(arrival_time)), + source_address_(source_address) {} + +// static +ReceivedPacket ReceivedPacket::CreateFromLegacy( + const char* data, + size_t size, + int64_t packet_time_us, + const rtc::SocketAddress& source_address) { + RTC_DCHECK(packet_time_us == -1 || packet_time_us >= 0); + return ReceivedPacket(rtc::reinterpret_array_view<const uint8_t>( + rtc::MakeArrayView(data, size)), + source_address, + (packet_time_us >= 0) + ? absl::optional<webrtc::Timestamp>( + webrtc::Timestamp::Micros(packet_time_us)) + : absl::nullopt); +} } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/network/received_packet.h b/third_party/libwebrtc/rtc_base/network/received_packet.h index 7f8b2f934c..e33361ca29 100644 --- a/third_party/libwebrtc/rtc_base/network/received_packet.h +++ b/third_party/libwebrtc/rtc_base/network/received_packet.h @@ -15,6 +15,8 @@ #include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/system/rtc_export.h" namespace rtc { @@ -22,14 +24,17 @@ namespace rtc { // It contains a payload and metadata. // ReceivedPacket itself does not put constraints on what payload contains. For // example it may contains STUN, SCTP, SRTP, RTP, RTCP.... etc. -class ReceivedPacket { +class RTC_EXPORT ReceivedPacket { public: - // Caller must keep memory pointed to by payload valid for the lifetime of - // this ReceivedPacket. + // Caller must keep memory pointed to by payload and address valid for the + // lifetime of this ReceivedPacket. ReceivedPacket( rtc::ArrayView<const uint8_t> payload, + const SocketAddress& source_address, absl::optional<webrtc::Timestamp> arrival_time = absl::nullopt); + // Address/port of the packet sender. + const SocketAddress& source_address() const { return source_address_; } rtc::ArrayView<const uint8_t> payload() const { return payload_; } // Timestamp when this packet was received. Not available on all socket @@ -38,9 +43,16 @@ class ReceivedPacket { return arrival_time_; } + static ReceivedPacket CreateFromLegacy( + const char* data, + size_t size, + int64_t packet_time_us, + const rtc::SocketAddress& = rtc::SocketAddress()); + private: rtc::ArrayView<const uint8_t> payload_; absl::optional<webrtc::Timestamp> arrival_time_; + const SocketAddress& source_address_; }; } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build b/third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build index a1276d9a7a..fb580667ce 100644 --- a/third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/network/sent_packet_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/network_constants_gn/moz.build b/third_party/libwebrtc/rtc_base/network_constants_gn/moz.build index 083e18ac8e..40a117b476 100644 --- a/third_party/libwebrtc/rtc_base/network_constants_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/network_constants_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/network_route_gn/moz.build b/third_party/libwebrtc/rtc_base/network_route_gn/moz.build index c35c498d44..b14b2b5633 100644 --- a/third_party/libwebrtc/rtc_base/network_route_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/network_route_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build b/third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build index 7385764373..e6b3d3c59a 100644 --- a/third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/null_socket_server_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build b/third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build index d5afd56fb6..10ad1f454a 100644 --- a/third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/one_time_event_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/openssl_adapter.cc b/third_party/libwebrtc/rtc_base/openssl_adapter.cc index c68eb22f5c..e48cdf43bd 100644 --- a/third_party/libwebrtc/rtc_base/openssl_adapter.cc +++ b/third_party/libwebrtc/rtc_base/openssl_adapter.cc @@ -44,6 +44,7 @@ #include "rtc_base/openssl_identity.h" #endif #include "rtc_base/openssl_utility.h" +#include "rtc_base/strings/str_join.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/thread.h" @@ -168,23 +169,6 @@ namespace rtc { using ::webrtc::TimeDelta; -namespace webrtc_openssl_adapter_internal { - -// Simple O(n^2) implementation is sufficient for current use case. -std::string StrJoin(const std::vector<std::string>& list, char delimiter) { - RTC_CHECK(!list.empty()); - StringBuilder sb; - sb << list[0]; - for (size_t i = 1; i < list.size(); i++) { - sb.AppendFormat("%c", delimiter); - sb << list[i]; - } - return sb.Release(); -} -} // namespace webrtc_openssl_adapter_internal - -using webrtc_openssl_adapter_internal::StrJoin; - bool OpenSSLAdapter::InitializeSSL() { if (!SSL_library_init()) return false; @@ -373,7 +357,7 @@ int OpenSSLAdapter::BeginSSL() { } if (!elliptic_curves_.empty()) { - SSL_set1_curves_list(ssl_, StrJoin(elliptic_curves_, ':').c_str()); + SSL_set1_curves_list(ssl_, webrtc::StrJoin(elliptic_curves_, ":").c_str()); } // Now that the initial config is done, transfer ownership of `bio` to the diff --git a/third_party/libwebrtc/rtc_base/openssl_adapter.h b/third_party/libwebrtc/rtc_base/openssl_adapter.h index 558a04077a..4c05471b2b 100644 --- a/third_party/libwebrtc/rtc_base/openssl_adapter.h +++ b/third_party/libwebrtc/rtc_base/openssl_adapter.h @@ -37,14 +37,6 @@ namespace rtc { -namespace webrtc_openssl_adapter_internal { - -// Local definition, since absl::StrJoin is not allow-listed. Declared in header -// file only for unittests. -std::string StrJoin(const std::vector<std::string>& list, char delimiter); - -} // namespace webrtc_openssl_adapter_internal - class OpenSSLAdapter final : public SSLAdapter { public: static bool InitializeSSL(); diff --git a/third_party/libwebrtc/rtc_base/openssl_adapter_unittest.cc b/third_party/libwebrtc/rtc_base/openssl_adapter_unittest.cc index ce351dc98e..5b59a8019e 100644 --- a/third_party/libwebrtc/rtc_base/openssl_adapter_unittest.cc +++ b/third_party/libwebrtc/rtc_base/openssl_adapter_unittest.cc @@ -116,19 +116,4 @@ TEST(OpenSSLAdapterFactoryTest, CreateWorksWithCustomVerifier) { EXPECT_NE(simple_adapter, nullptr); } -TEST(StrJoinTest, SingleElement) { - EXPECT_EQ(webrtc_openssl_adapter_internal::StrJoin({"a"}, ','), "a"); -} - -TEST(StrJoinTest, TwoElements) { - EXPECT_EQ(webrtc_openssl_adapter_internal::StrJoin({"first", "second"}, ':'), - "first:second"); -} - -TEST(StrJoinTest, WithEmptyElement) { - EXPECT_EQ( - webrtc_openssl_adapter_internal::StrJoin({"first", "", "second"}, ':'), - "first::second"); -} - } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/openssl_stream_adapter.cc b/third_party/libwebrtc/rtc_base/openssl_stream_adapter.cc index 353cbbe681..9642674d45 100644 --- a/third_party/libwebrtc/rtc_base/openssl_stream_adapter.cc +++ b/third_party/libwebrtc/rtc_base/openssl_stream_adapter.cc @@ -278,21 +278,6 @@ static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) { // OpenSSLStreamAdapter ///////////////////////////////////////////////////////////////////////////// -static std::atomic<bool> g_use_legacy_tls_protocols_override(false); -static std::atomic<bool> g_allow_legacy_tls_protocols(false); - -void SetAllowLegacyTLSProtocols(const absl::optional<bool>& allow) { - g_use_legacy_tls_protocols_override.store(allow.has_value()); - if (allow.has_value()) - g_allow_legacy_tls_protocols.store(allow.value()); -} - -bool ShouldAllowLegacyTLSProtocols() { - return g_use_legacy_tls_protocols_override.load() - ? g_allow_legacy_tls_protocols.load() - : webrtc::field_trial::IsEnabled("WebRTC-LegacyTlsProtocols"); -} - OpenSSLStreamAdapter::OpenSSLStreamAdapter( std::unique_ptr<StreamInterface> stream, absl::AnyInvocable<void(SSLHandshakeError)> handshake_error) @@ -306,10 +291,7 @@ OpenSSLStreamAdapter::OpenSSLStreamAdapter( ssl_(nullptr), ssl_ctx_(nullptr), ssl_mode_(SSL_MODE_TLS), - ssl_max_version_(SSL_PROTOCOL_TLS_12), - // Default is to support legacy TLS protocols. - // This will be changed to default non-support in M82 or M83. - support_legacy_tls_protocols_flag_(ShouldAllowLegacyTLSProtocols()) { + ssl_max_version_(SSL_PROTOCOL_TLS_12) { stream_->SignalEvent.connect(this, &OpenSSLStreamAdapter::OnEvent); } @@ -1031,33 +1013,10 @@ SSL_CTX* OpenSSLStreamAdapter::SetupSSLContext() { return nullptr; } - if (support_legacy_tls_protocols_flag_) { - // TODO(https://bugs.webrtc.org/10261): Completely remove this branch in - // M84. - SSL_CTX_set_min_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_VERSION); - switch (ssl_max_version_) { - case SSL_PROTOCOL_TLS_10: - SSL_CTX_set_max_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_VERSION); - break; - case SSL_PROTOCOL_TLS_11: - SSL_CTX_set_max_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_VERSION : TLS1_1_VERSION); - break; - case SSL_PROTOCOL_TLS_12: - default: - SSL_CTX_set_max_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); - break; - } - } else { - // TODO(https://bugs.webrtc.org/10261): Make this the default in M84. - SSL_CTX_set_min_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); - SSL_CTX_set_max_proto_version( - ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); - } + SSL_CTX_set_min_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); + SSL_CTX_set_max_proto_version( + ctx, ssl_mode_ == SSL_MODE_DTLS ? DTLS1_2_VERSION : TLS1_2_VERSION); #ifdef OPENSSL_IS_BORINGSSL // SSL_CTX_set_current_time_cb is only supported in BoringSSL. diff --git a/third_party/libwebrtc/rtc_base/openssl_stream_adapter.h b/third_party/libwebrtc/rtc_base/openssl_stream_adapter.h index 42fdb08aae..34cadeb06c 100644 --- a/third_party/libwebrtc/rtc_base/openssl_stream_adapter.h +++ b/third_party/libwebrtc/rtc_base/openssl_stream_adapter.h @@ -66,12 +66,6 @@ class SSLCertChain; /////////////////////////////////////////////////////////////////////////////// -// If `allow` has a value, its value determines if legacy TLS protocols are -// allowed, overriding the default configuration. -// If `allow` has no value, any previous override is removed and the default -// configuration is restored. -RTC_EXPORT void SetAllowLegacyTLSProtocols(const absl::optional<bool>& allow); - class OpenSSLStreamAdapter final : public SSLStreamAdapter, public sigslot::has_slots<> { public: @@ -252,9 +246,6 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter, // A 50-ms initial timeout ensures rapid setup on fast connections, but may // be too aggressive for low bandwidth links. int dtls_handshake_timeout_ms_ = 50; - - // TODO(https://bugs.webrtc.org/10261): Completely remove this option in M84. - const bool support_legacy_tls_protocols_flag_; }; ///////////////////////////////////////////////////////////////////////////// diff --git a/third_party/libwebrtc/rtc_base/physical_socket_server.h b/third_party/libwebrtc/rtc_base/physical_socket_server.h index ea449ff121..584f42a188 100644 --- a/third_party/libwebrtc/rtc_base/physical_socket_server.h +++ b/third_party/libwebrtc/rtc_base/physical_socket_server.h @@ -41,8 +41,6 @@ #include <unordered_map> #include <vector> -#include "rtc_base/async_resolver.h" -#include "rtc_base/async_resolver_interface.h" #include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/socket_server.h" #include "rtc_base/synchronization/mutex.h" diff --git a/third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build b/third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build index 6e962e3280..8045b2de62 100644 --- a/third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/platform_thread_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build b/third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build index 0e817e6eb9..3738ea61fc 100644 --- a/third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/platform_thread_types_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build b/third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build index 7f1e533b39..4ec9f79060 100644 --- a/third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/protobuf_utils_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/race_checker_gn/moz.build b/third_party/libwebrtc/rtc_base/race_checker_gn/moz.build index 2fab623156..ed66936a90 100644 --- a/third_party/libwebrtc/rtc_base/race_checker_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/race_checker_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/random_gn/moz.build b/third_party/libwebrtc/rtc_base/random_gn/moz.build index 394eefde59..93b07582aa 100644 --- a/third_party/libwebrtc/rtc_base/random_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/random_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build b/third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build index cf10767d72..60acfb0176 100644 --- a/third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rate_limiter_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build b/third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build index 657f0a6597..84b47cf914 100644 --- a/third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rate_statistics_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build b/third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build index f8ebf228f1..880d7d6236 100644 --- a/third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rate_tracker_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/ref_count.h b/third_party/libwebrtc/rtc_base/ref_count.h index d8d652abd8..60a11fa5c7 100644 --- a/third_party/libwebrtc/rtc_base/ref_count.h +++ b/third_party/libwebrtc/rtc_base/ref_count.h @@ -10,57 +10,16 @@ #ifndef RTC_BASE_REF_COUNT_H_ #define RTC_BASE_REF_COUNT_H_ -namespace rtc { - -// Refcounted objects should implement the following informal interface: -// -// void AddRef() const ; -// RefCountReleaseStatus Release() const; -// -// You may access members of a reference-counted object, including the AddRef() -// and Release() methods, only if you already own a reference to it, or if -// you're borrowing someone else's reference. (A newly created object is a -// special case: the reference count is zero on construction, and the code that -// creates the object should immediately call AddRef(), bringing the reference -// count from zero to one, e.g., by constructing an rtc::scoped_refptr). -// -// AddRef() creates a new reference to the object. -// -// Release() releases a reference to the object; the caller now has one less -// reference than before the call. Returns kDroppedLastRef if the number of -// references dropped to zero because of this (in which case the object destroys -// itself). Otherwise, returns kOtherRefsRemained, to signal that at the precise -// time the caller's reference was dropped, other references still remained (but -// if other threads own references, this may of course have changed by the time -// Release() returns). -// -// The caller of Release() must treat it in the same way as a delete operation: -// Regardless of the return value from Release(), the caller mustn't access the -// object. The object might still be alive, due to references held by other -// users of the object, but the object can go away at any time, e.g., as the -// result of another thread calling Release(). -// -// Calling AddRef() and Release() manually is discouraged. It's recommended to -// use rtc::scoped_refptr to manage all pointers to reference counted objects. -// Note that rtc::scoped_refptr depends on compile-time duck-typing; formally -// implementing the below RefCountInterface is not required. +// Transition file for backwards compatibility with source code +// that includes the non-API file. -enum class RefCountReleaseStatus { kDroppedLastRef, kOtherRefsRemained }; +#include "api/ref_count.h" -// Interfaces where refcounting is part of the public api should -// inherit this abstract interface. The implementation of these -// methods is usually provided by the RefCountedObject template class, -// applied as a leaf in the inheritance tree. -class RefCountInterface { - public: - virtual void AddRef() const = 0; - virtual RefCountReleaseStatus Release() const = 0; +namespace rtc { - // Non-public destructor, because Release() has exclusive responsibility for - // destroying the object. - protected: - virtual ~RefCountInterface() {} -}; +// TODO(bugs.webrtc.org/15622): Deprecate and remove these aliases. +using webrtc::RefCountInterface; +using webrtc::RefCountReleaseStatus; } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/refcount_gn/moz.build b/third_party/libwebrtc/rtc_base/refcount_gn/moz.build index a1b2bcfecc..383d69e458 100644 --- a/third_party/libwebrtc/rtc_base/refcount_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/refcount_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build b/third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build index c5cbc0cb54..97fafd6dfb 100644 --- a/third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rolling_accumulator_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build b/third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build index a3bb657070..d120effc69 100644 --- a/third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rtc_event_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build b/third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build index 1c0d84013b..ac5a402772 100644 --- a/third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rtc_numerics_gn/moz.build @@ -190,7 +190,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -200,10 +199,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/rtc_task_queue_gn/moz.build b/third_party/libwebrtc/rtc_base/rtc_task_queue_gn/moz.build index 21635e570b..a8de45e8df 100644 --- a/third_party/libwebrtc/rtc_base/rtc_task_queue_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/rtc_task_queue_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build b/third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build index fdcf248573..77dbd737c8 100644 --- a/third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/safe_compare_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build b/third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build index 5901f174a6..f0d60f3922 100644 --- a/third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/safe_conversions_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build b/third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build index c01e7c799b..a975f0911f 100644 --- a/third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/safe_minmax_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build b/third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build index 99c6eb8f53..6cfed54db6 100644 --- a/third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/sample_counter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build b/third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build index 43e96ee810..8bf1b02b4f 100644 --- a/third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/sanitizer_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/server_socket_adapters.cc b/third_party/libwebrtc/rtc_base/server_socket_adapters.cc index 673083c7cd..47c19cbed9 100644 --- a/third_party/libwebrtc/rtc_base/server_socket_adapters.cc +++ b/third_party/libwebrtc/rtc_base/server_socket_adapters.cc @@ -63,7 +63,8 @@ AsyncSocksProxyServerSocket::AsyncSocksProxyServerSocket(Socket* socket) void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) { RTC_DCHECK(state_ < SS_CONNECT_PENDING); - ByteBufferReader response(data, *len); + ByteBufferReader response( + rtc::MakeArrayView(reinterpret_cast<const uint8_t*>(data), *len)); if (state_ == SS_HELLO) { HandleHello(&response); } else if (state_ == SS_AUTH) { diff --git a/third_party/libwebrtc/rtc_base/socket_adapters.cc b/third_party/libwebrtc/rtc_base/socket_adapters.cc index 4ec93ae3e9..f628929a46 100644 --- a/third_party/libwebrtc/rtc_base/socket_adapters.cc +++ b/third_party/libwebrtc/rtc_base/socket_adapters.cc @@ -520,7 +520,8 @@ void AsyncSocksProxySocket::OnConnectEvent(Socket* socket) { void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { RTC_DCHECK(state_ < SS_TUNNEL); - ByteBufferReader response(data, *len); + ByteBufferReader response( + rtc::MakeArrayView(reinterpret_cast<uint8_t*>(data), *len)); if (state_ == SS_HELLO) { uint8_t ver, method; diff --git a/third_party/libwebrtc/rtc_base/socket_address_gn/moz.build b/third_party/libwebrtc/rtc_base/socket_address_gn/moz.build index 86ef2dc1a7..7d4c5ea206 100644 --- a/third_party/libwebrtc/rtc_base/socket_address_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/socket_address_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build b/third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build index 3a2f72d1e6..c0df17e881 100644 --- a/third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/socket_factory_gn/moz.build @@ -188,16 +188,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/socket_gn/moz.build b/third_party/libwebrtc/rtc_base/socket_gn/moz.build index 0d1760a15c..0001376066 100644 --- a/third_party/libwebrtc/rtc_base/socket_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/socket_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/socket_server_gn/moz.build b/third_party/libwebrtc/rtc_base/socket_server_gn/moz.build index 48972cbb4c..e671f719bc 100644 --- a/third_party/libwebrtc/rtc_base/socket_server_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/socket_server_gn/moz.build @@ -188,16 +188,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/socket_unittest.cc b/third_party/libwebrtc/rtc_base/socket_unittest.cc index 0a41a776ac..f5ef2a33fc 100644 --- a/third_party/libwebrtc/rtc_base/socket_unittest.cc +++ b/third_party/libwebrtc/rtc_base/socket_unittest.cc @@ -1132,13 +1132,13 @@ void SocketTest::UdpSocketRecvTimestampUseRtcEpoch(const IPAddress& loopback) { client2->SendTo("foo", 3, address); std::unique_ptr<TestClient::Packet> packet_1 = client1->NextPacket(10000); ASSERT_TRUE(packet_1 != nullptr); - EXPECT_NEAR(packet_1->packet_time_us, rtc::TimeMicros(), 1000'000); + EXPECT_NEAR(packet_1->packet_time->us(), rtc::TimeMicros(), 1000'000); Thread::SleepMs(100); client2->SendTo("bar", 3, address); std::unique_ptr<TestClient::Packet> packet_2 = client1->NextPacket(10000); ASSERT_TRUE(packet_2 != nullptr); - EXPECT_GT(packet_2->packet_time_us, packet_1->packet_time_us); - EXPECT_NEAR(packet_2->packet_time_us, rtc::TimeMicros(), 1000'000); + EXPECT_GT(packet_2->packet_time->us(), packet_1->packet_time->us()); + EXPECT_NEAR(packet_2->packet_time->us(), rtc::TimeMicros(), 1000'000); } } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/ssl_gn/moz.build b/third_party/libwebrtc/rtc_base/ssl_gn/moz.build index 4be1ae9766..66200fa70c 100644 --- a/third_party/libwebrtc/rtc_base/ssl_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/ssl_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/ssl_stream_adapter_unittest.cc b/third_party/libwebrtc/rtc_base/ssl_stream_adapter_unittest.cc index 0a99d9b1f0..def4c47c0d 100644 --- a/third_party/libwebrtc/rtc_base/ssl_stream_adapter_unittest.cc +++ b/third_party/libwebrtc/rtc_base/ssl_stream_adapter_unittest.cc @@ -31,8 +31,11 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/stream.h" #include "test/field_trial.h" +#include "test/gmock.h" +#include "test/gtest.h" using ::testing::Combine; +using ::testing::NotNull; using ::testing::tuple; using ::testing::Values; using ::testing::WithParamInterface; @@ -593,9 +596,12 @@ class SSLStreamAdapterTestBase : public ::testing::Test, size_t client_digest_len; bool rv; + ASSERT_THAT(server_identity(), NotNull()); rv = server_identity()->certificate().ComputeDigest( rtc::DIGEST_SHA_1, server_digest, 20, &server_digest_len); ASSERT_TRUE(rv); + + ASSERT_THAT(client_identity(), NotNull()); rv = client_identity()->certificate().ComputeDigest( rtc::DIGEST_SHA_1, client_digest, 20, &client_digest_len); ASSERT_TRUE(rv); @@ -1607,11 +1613,14 @@ INSTANTIATE_TEST_SUITE_P( rtc::KeyParams::RSA(1152, 65537), rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); -// Tests for enabling / disabling legacy TLS protocols in DTLS. -class SSLStreamAdapterTestDTLSLegacyProtocols +// Tests for enabling the (D)TLS extension permutation which randomizes the +// order of extensions in the client hello. +// These tests are a no-op under OpenSSL. +#ifdef OPENSSL_IS_BORINGSSL +class SSLStreamAdapterTestDTLSExtensionPermutation : public SSLStreamAdapterTestDTLSBase { public: - SSLStreamAdapterTestDTLSLegacyProtocols() + SSLStreamAdapterTestDTLSExtensionPermutation() : SSLStreamAdapterTestDTLSBase(rtc::KeyParams::ECDSA(rtc::EC_NIST_P256), rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)) { } @@ -1650,179 +1659,6 @@ class SSLStreamAdapterTestDTLSLegacyProtocols } }; -// Test getting the used DTLS ciphers. -// DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, TestGetSslCipherSuite) { - ConfigureClient("WebRTC-LegacyTlsProtocols/Enabled/"); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(); - - int client_cipher; - ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); - int server_cipher; - ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); - - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(true)); - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(false)); - - ASSERT_EQ(client_cipher, server_cipher); -} - -// Test getting the used DTLS 1.2 ciphers. -// DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslCipherSuiteDtls12Both) { - ConfigureClient(""); - ConfigureServer(""); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); - TestHandshake(); - - int client_cipher; - ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); - int server_cipher; - ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); - - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_12, GetSslVersion(true)); - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_12, GetSslVersion(false)); - - ASSERT_EQ(client_cipher, server_cipher); -} - -// DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslCipherSuiteDtls12Client) { - ConfigureClient("WebRTC-LegacyTlsProtocols/Enabled/"); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); - TestHandshake(); - - int client_cipher; - ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); - int server_cipher; - ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); - - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(true)); - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(false)); - - ASSERT_EQ(client_cipher, server_cipher); -} - -// DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslCipherSuiteDtls12Server) { - ConfigureClient("WebRTC-LegacyTlsProtocols/Enabled/"); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(); - - int client_cipher; - ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); - int server_cipher; - ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); - - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(true)); - ASSERT_EQ(rtc::SSL_PROTOCOL_DTLS_10, GetSslVersion(false)); - - ASSERT_EQ(client_cipher, server_cipher); -} - -// Client has legacy TLS versions disabled, server has DTLS 1.0 only. -// This is meant to cause a failure. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyDisabledServer10) { - ConfigureClient(""); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); - // Handshake should fail. - TestHandshake(false); -} - -// Both client and server have legacy TLS versions disabled and support -// DTLS 1.2. This should work. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyDisabledServer12) { - ConfigureClient(""); - ConfigureServer(""); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); - TestHandshake(); -} - -// Both client and server have legacy TLS versions enabled and support DTLS 1.0. -// This should work. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyEnabledClient10Server10) { - ConfigureClient("WebRTC-LegacyTlsProtocols/Enabled/"); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(); -} - -// Legacy protocols are disabled in the client, max TLS version is 1.0 -// This should be a configuration error, and handshake should fail. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyDisabledClient10Server10) { - ConfigureClient(""); - ConfigureServer("WebRTC-LegacyTlsProtocols/Enabled/"); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(false); -} - -// Both client and server have legacy TLS versions enabled and support DTLS 1.0. -// This should work. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyOverrideEnabledClient10Server10) { - rtc::SetAllowLegacyTLSProtocols(true); - ConfigureClient(""); - ConfigureServer(""); - // Remove override. - rtc::SetAllowLegacyTLSProtocols(absl::nullopt); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(); -} - -// Client has legacy TLS disabled and server has legacy TLS enabled via -// override. Handshake for DTLS 1.0 should fail. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyOverrideDisabledClient10EnabledServer10) { - rtc::SetAllowLegacyTLSProtocols(false); - ConfigureClient(""); - rtc::SetAllowLegacyTLSProtocols(true); - ConfigureServer(""); - // Remove override. - rtc::SetAllowLegacyTLSProtocols(absl::nullopt); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(false); -} - -// Client has legacy TLS enabled and server has legacy TLS disabled via -// override. Handshake for DTLS 1.0 should fail. -TEST_F(SSLStreamAdapterTestDTLSLegacyProtocols, - TestGetSslVersionLegacyOverrideEnabledClient10DisabledServer10) { - rtc::SetAllowLegacyTLSProtocols(true); - ConfigureClient(""); - rtc::SetAllowLegacyTLSProtocols(false); - ConfigureServer(""); - // Remove override. - rtc::SetAllowLegacyTLSProtocols(absl::nullopt); - SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); - TestHandshake(false); -} - -// These tests are a no-op under OpenSSL. -#ifdef OPENSSL_IS_BORINGSSL -// TODO(https://bugs.webrtc.org/10261): when removing -// SSLStreamAdapterTestDTLSLegacyProtocols that this class -// inherits from move the code to this class. -class SSLStreamAdapterTestDTLSExtensionPermutation - : public SSLStreamAdapterTestDTLSLegacyProtocols { - public: - SSLStreamAdapterTestDTLSExtensionPermutation() - : SSLStreamAdapterTestDTLSLegacyProtocols() {} -}; - -// Tests for enabling the (D)TLS extension permutation which randomizes the -// order of extensions in the client hello. TEST_F(SSLStreamAdapterTestDTLSExtensionPermutation, ClientDefaultServerDefault) { ConfigureClient(""); diff --git a/third_party/libwebrtc/rtc_base/strings/str_join.h b/third_party/libwebrtc/rtc_base/strings/str_join.h new file mode 100644 index 0000000000..762e63ae2a --- /dev/null +++ b/third_party/libwebrtc/rtc_base/strings/str_join.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 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_STRINGS_STR_JOIN_H_ +#define RTC_BASE_STRINGS_STR_JOIN_H_ + +#include <string> + +#include "absl/strings/string_view.h" +#include "rtc_base/strings/string_builder.h" + +namespace webrtc { + +template <typename Range> +std::string StrJoin(const Range& seq, absl::string_view delimiter) { + rtc::StringBuilder sb; + int idx = 0; + + for (const typename Range::value_type& elem : seq) { + if (idx > 0) { + sb << delimiter; + } + sb << elem; + + ++idx; + } + return sb.Release(); +} + +template <typename Range, typename Functor> +std::string StrJoin(const Range& seq, + absl::string_view delimiter, + const Functor& fn) { + rtc::StringBuilder sb; + int idx = 0; + + for (const typename Range::value_type& elem : seq) { + if (idx > 0) { + sb << delimiter; + } + fn(sb, elem); + + ++idx; + } + return sb.Release(); +} + +} // namespace webrtc + +#endif // RTC_BASE_STRINGS_STR_JOIN_H_ diff --git a/third_party/libwebrtc/rtc_base/strings/str_join_unittest.cc b/third_party/libwebrtc/rtc_base/strings/str_join_unittest.cc new file mode 100644 index 0000000000..a4ac02125f --- /dev/null +++ b/third_party/libwebrtc/rtc_base/strings/str_join_unittest.cc @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 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/strings/str_join.h" + +#include <string> +#include <utility> +#include <vector> + +#include "test/gtest.h" + +namespace webrtc { +namespace { + +TEST(StrJoinTest, CanJoinStringsFromVector) { + std::vector<std::string> strings = {"Hello", "World"}; + std::string s = StrJoin(strings, " "); + EXPECT_EQ(s, "Hello World"); +} + +TEST(StrJoinTest, CanJoinNumbersFromArray) { + std::array<int, 3> numbers = {1, 2, 3}; + std::string s = StrJoin(numbers, ","); + EXPECT_EQ(s, "1,2,3"); +} + +TEST(StrJoinTest, CanFormatElementsWhileJoining) { + std::vector<std::pair<std::string, std::string>> pairs = { + {"hello", "world"}, {"foo", "bar"}, {"fum", "gazonk"}}; + std::string s = StrJoin(pairs, ",", + [&](rtc::StringBuilder& sb, + const std::pair<std::string, std::string>& p) { + sb << p.first << "=" << p.second; + }); + EXPECT_EQ(s, "hello=world,foo=bar,fum=gazonk"); +} + +} // namespace +} // namespace webrtc diff --git a/third_party/libwebrtc/rtc_base/stringutils_gn/moz.build b/third_party/libwebrtc/rtc_base/stringutils_gn/moz.build index 58008d114a..3b7954e86e 100644 --- a/third_party/libwebrtc/rtc_base/stringutils_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/stringutils_gn/moz.build @@ -192,7 +192,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -202,10 +201,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build b/third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build index 3bffe145d6..b03cf37955 100644 --- a/third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/swap_queue_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build b/third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build index 9799330606..197f9213a8 100644 --- a/third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/synchronization/mutex_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build b/third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build index a43e97a8c2..28788b4b65 100644 --- a/third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/synchronization/sequence_checker_internal_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build b/third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build index ac962ac0a2..6e5fe912f1 100644 --- a/third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/synchronization/yield_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build b/third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build index 7adceec9b4..df7b6a62b9 100644 --- a/third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/synchronization/yield_policy_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/arch_gn/moz.build b/third_party/libwebrtc/rtc_base/system/arch_gn/moz.build index 136948d0f2..c72b2b9951 100644 --- a/third_party/libwebrtc/rtc_base/system/arch_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/arch_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build b/third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build index b99d782d88..4a2dbbea32 100644 --- a/third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/asm_defines_gn/moz.build @@ -59,7 +59,6 @@ if CONFIG["OS_TARGET"] == "Android": DEFINES["WEBRTC_ANDROID_OPENSLES"] = True OS_LIBS += [ - "android_support", "unwind" ] diff --git a/third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build b/third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build index 6d0a523103..4fdec8d732 100644 --- a/third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/file_wrapper_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build b/third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build index 61bbeefabc..3406348246 100644 --- a/third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/ignore_warnings_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/inline_gn/moz.build b/third_party/libwebrtc/rtc_base/system/inline_gn/moz.build index 574d7958f1..4236cd7c5d 100644 --- a/third_party/libwebrtc/rtc_base/system/inline_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/inline_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build b/third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build index 4d51581c1b..bcb6b00848 100644 --- a/third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/no_unique_address_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build b/third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build index e4d340d3c6..4eb3c21325 100644 --- a/third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/rtc_export_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/unused_gn/moz.build b/third_party/libwebrtc/rtc_base/system/unused_gn/moz.build index c6dd8a6bab..25a3e4e088 100644 --- a/third_party/libwebrtc/rtc_base/system/unused_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/unused_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build b/third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build index 3aa57ac48e..cc34279237 100644 --- a/third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/system/warn_current_thread_is_deadlocked_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build b/third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build index 224f776828..ffe3228fdc 100644 --- a/third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/task_utils/repeating_task_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/test_client.cc b/third_party/libwebrtc/rtc_base/test_client.cc index f23ac2aec0..87c946529e 100644 --- a/third_party/libwebrtc/rtc_base/test_client.cc +++ b/third_party/libwebrtc/rtc_base/test_client.cc @@ -15,7 +15,9 @@ #include <memory> #include <utility> +#include "api/units/timestamp.h" #include "rtc_base/gunit.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" @@ -30,10 +32,11 @@ TestClient::TestClient(std::unique_ptr<AsyncPacketSocket> socket) TestClient::TestClient(std::unique_ptr<AsyncPacketSocket> socket, ThreadProcessingFakeClock* fake_clock) - : fake_clock_(fake_clock), - socket_(std::move(socket)), - prev_packet_timestamp_(-1) { - socket_->SignalReadPacket.connect(this, &TestClient::OnPacket); + : fake_clock_(fake_clock), socket_(std::move(socket)) { + socket_->RegisterReceivedPacketCallback( + [&](rtc::AsyncPacketSocket* socket, const rtc::ReceivedPacket& packet) { + OnPacket(socket, packet); + }); socket_->SignalReadyToSend.connect(this, &TestClient::OnReadyToSend); } @@ -100,20 +103,22 @@ bool TestClient::CheckNextPacket(const char* buf, bool res = false; std::unique_ptr<Packet> packet = NextPacket(kTimeoutMs); if (packet) { - res = (packet->size == size && memcmp(packet->buf, buf, size) == 0 && - CheckTimestamp(packet->packet_time_us)); + res = (packet->buf.size() == size && + memcmp(packet->buf.data(), buf, size) == 0 && + CheckTimestamp(packet->packet_time)); if (addr) *addr = packet->addr; } return res; } -bool TestClient::CheckTimestamp(int64_t packet_timestamp) { +bool TestClient::CheckTimestamp( + absl::optional<webrtc::Timestamp> packet_timestamp) { bool res = true; - if (packet_timestamp == -1) { + if (!packet_timestamp) { res = false; } - if (prev_packet_timestamp_ != -1) { + if (prev_packet_timestamp_) { if (packet_timestamp < prev_packet_timestamp_) { res = false; } @@ -145,36 +150,24 @@ int TestClient::SetOption(Socket::Option opt, int value) { } void TestClient::OnPacket(AsyncPacketSocket* socket, - const char* buf, - size_t size, - const SocketAddress& remote_addr, - const int64_t& packet_time_us) { + const rtc::ReceivedPacket& received_packet) { webrtc::MutexLock lock(&mutex_); - packets_.push_back( - std::make_unique<Packet>(remote_addr, buf, size, packet_time_us)); + packets_.push_back(std::make_unique<Packet>(received_packet)); } void TestClient::OnReadyToSend(AsyncPacketSocket* socket) { ++ready_to_send_count_; } -TestClient::Packet::Packet(const SocketAddress& a, - const char* b, - size_t s, - int64_t packet_time_us) - : addr(a), buf(0), size(s), packet_time_us(packet_time_us) { - buf = new char[size]; - memcpy(buf, b, size); -} +TestClient::Packet::Packet(const rtc::ReceivedPacket& received_packet) + : addr(received_packet.source_address()), + // Copy received_packet payload to a buffer owned by Packet. + buf(received_packet.payload().data(), received_packet.payload().size()), + packet_time(received_packet.arrival_time()) {} TestClient::Packet::Packet(const Packet& p) - : addr(p.addr), buf(0), size(p.size), packet_time_us(p.packet_time_us) { - buf = new char[size]; - memcpy(buf, p.buf, size); -} - -TestClient::Packet::~Packet() { - delete[] buf; -} + : addr(p.addr), + buf(p.buf.data(), p.buf.size()), + packet_time(p.packet_time) {} } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/test_client.h b/third_party/libwebrtc/rtc_base/test_client.h index dd91d37ab9..6fe6fd5b83 100644 --- a/third_party/libwebrtc/rtc_base/test_client.h +++ b/third_party/libwebrtc/rtc_base/test_client.h @@ -14,8 +14,11 @@ #include <memory> #include <vector> +#include "api/units/timestamp.h" #include "rtc_base/async_udp_socket.h" +#include "rtc_base/buffer.h" #include "rtc_base/fake_clock.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/synchronization/mutex.h" namespace rtc { @@ -26,17 +29,12 @@ class TestClient : public sigslot::has_slots<> { public: // Records the contents of a packet that was received. struct Packet { - Packet(const SocketAddress& a, - const char* b, - size_t s, - int64_t packet_time_us); + Packet(const rtc::ReceivedPacket& received_packet); Packet(const Packet& p); - virtual ~Packet(); SocketAddress addr; - char* buf; - size_t size; - int64_t packet_time_us; + Buffer buf; + absl::optional<webrtc::Timestamp> packet_time; }; // Default timeout for NextPacket reads. @@ -96,14 +94,11 @@ class TestClient : public sigslot::has_slots<> { static const int kNoPacketTimeoutMs = 1000; // Workaround for the fact that AsyncPacketSocket::GetConnState doesn't exist. Socket::ConnState GetState(); - // Slot for packets read on the socket. + void OnPacket(AsyncPacketSocket* socket, - const char* buf, - size_t len, - const SocketAddress& remote_addr, - const int64_t& packet_time_us); + const rtc::ReceivedPacket& received_packet); void OnReadyToSend(AsyncPacketSocket* socket); - bool CheckTimestamp(int64_t packet_timestamp); + bool CheckTimestamp(absl::optional<webrtc::Timestamp> packet_timestamp); void AdvanceTime(int ms); ThreadProcessingFakeClock* fake_clock_ = nullptr; @@ -111,7 +106,7 @@ class TestClient : public sigslot::has_slots<> { std::unique_ptr<AsyncPacketSocket> socket_; std::vector<std::unique_ptr<Packet>> packets_; int ready_to_send_count_ = 0; - int64_t prev_packet_timestamp_; + absl::optional<webrtc::Timestamp> prev_packet_timestamp_; }; } // namespace rtc diff --git a/third_party/libwebrtc/rtc_base/test_echo_server.h b/third_party/libwebrtc/rtc_base/test_echo_server.h index 82817624a5..d99ed72f00 100644 --- a/third_party/libwebrtc/rtc_base/test_echo_server.h +++ b/third_party/libwebrtc/rtc_base/test_echo_server.h @@ -21,6 +21,7 @@ #include "absl/memory/memory.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_tcp_socket.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -45,19 +46,17 @@ class TestEchoServer : public sigslot::has_slots<> { Socket* raw_socket = socket->Accept(nullptr); if (raw_socket) { AsyncTCPSocket* packet_socket = new AsyncTCPSocket(raw_socket); - packet_socket->SignalReadPacket.connect(this, &TestEchoServer::OnPacket); + packet_socket->RegisterReceivedPacketCallback( + [&](rtc::AsyncPacketSocket* socket, + const rtc::ReceivedPacket& packet) { OnPacket(socket, packet); }); packet_socket->SubscribeCloseEvent( this, [this](AsyncPacketSocket* s, int err) { OnClose(s, err); }); client_sockets_.push_back(packet_socket); } } - void OnPacket(AsyncPacketSocket* socket, - const char* buf, - size_t size, - const SocketAddress& remote_addr, - const int64_t& /* packet_time_us */) { + void OnPacket(AsyncPacketSocket* socket, const rtc::ReceivedPacket& packet) { rtc::PacketOptions options; - socket->Send(buf, size, options); + socket->Send(packet.payload().data(), packet.payload().size(), options); } void OnClose(AsyncPacketSocket* socket, int err) { ClientList::iterator it = absl::c_find(client_sockets_, socket); diff --git a/third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build b/third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build index 0d35da2f19..18384b6a38 100644 --- a/third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/third_party/base64/base64_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build b/third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build index 906a4a9e81..b5b20ed538 100644 --- a/third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/third_party/sigslot/sigslot_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/threading_gn/moz.build b/third_party/libwebrtc/rtc_base/threading_gn/moz.build index 199af4b1d3..1ed74bfaad 100644 --- a/third_party/libwebrtc/rtc_base/threading_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/threading_gn/moz.build @@ -31,7 +31,6 @@ LOCAL_INCLUDES += [ ] UNIFIED_SOURCES += [ - "/third_party/libwebrtc/rtc_base/async_resolver.cc", "/third_party/libwebrtc/rtc_base/internal/default_socket_server.cc", "/third_party/libwebrtc/rtc_base/network_monitor.cc", "/third_party/libwebrtc/rtc_base/network_monitor_factory.cc", @@ -201,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/timeutils_gn/moz.build b/third_party/libwebrtc/rtc_base/timeutils_gn/moz.build index c4eb7ac8de..c74be73063 100644 --- a/third_party/libwebrtc/rtc_base/timeutils_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/timeutils_gn/moz.build @@ -197,7 +197,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -207,10 +206,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/type_traits_gn/moz.build b/third_party/libwebrtc/rtc_base/type_traits_gn/moz.build index 1f72327af3..9b5c10f949 100644 --- a/third_party/libwebrtc/rtc_base/type_traits_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/type_traits_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build b/third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build index 975562a208..8b55572cb5 100644 --- a/third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/unique_id_generator_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build b/third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build index bb68c4ea3c..259ef161a2 100644 --- a/third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/units/unit_base_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/virtual_socket_server.cc b/third_party/libwebrtc/rtc_base/virtual_socket_server.cc index efc206b219..bec7d9733f 100644 --- a/third_party/libwebrtc/rtc_base/virtual_socket_server.cc +++ b/third_party/libwebrtc/rtc_base/virtual_socket_server.cc @@ -18,6 +18,7 @@ #include <vector> #include "absl/algorithm/container.h" +#include "api/sequence_checker.h" #include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" diff --git a/third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build b/third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build index a7cf9dd19e..42342eee8b 100644 --- a/third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/weak_ptr_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build b/third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build index 1029a25252..0b8ed4f70c 100644 --- a/third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build +++ b/third_party/libwebrtc/rtc_base/zero_memory_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True |