Bug 1766646 - Vendor libwebrtc from e5f4c6b8d2

Upstream commit: https://webrtc.googlesource.com/src/+/e5f4c6b8d2b2fce452e1e6228be7c4f52a08db6f
    Reland "Refactor rtc_base build targets."

    This is a reland of 69241a93fb14f6527a26d5c94dde879013012d2a

    Fix: The problem was related to NO_MAIN_THREAD_WRAPPING, which
    affects https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/rtc_base/thread.cc;l=257-263;drc=7acc2d9fe3a6e3c4d8881d2bdfc9b8968a724cd5.
    The original CL didn't attach the definition of the macro
    NO_MAIN_THREAD_WRAPPING when building for Chromium (which doesn't have
    to be related to //rtc_base anymore but to //rtc_base:threading).

    Original change's description:
    > Refactor rtc_base build targets.
    >
    > The "//rtc_base:rtc_base" build target has historically been one of the
    > biggest targets in the WebRTC build. Big targets are the main source of
    > circular dependencies and non-API types leakage.
    >
    > This CL is a step forward into splitting "//rtc_base:rtc_base" into
    > smaller targets (as originally started in 2018).
    >
    > The only non-automated changes are (like re-wiring the build system):
    > * The creation of //rtc_base/async_resolver.{h,cc} which allows to
    >   break a circular dependency (is has been extracted from
    >   //rtc_base/net_helpers.{h,cc}).
    > * The creation of //rtc_base/internal/default_socket_server.{h,cc} to
    >   break another circular dependency.
    >
    > Bug: webrtc:9987
    > Change-Id: I0c8f5e7efe2c8fd8e6bffa0d6dd2dd494cf3df02
    > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196903
    > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
    > Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    > Cr-Commit-Position: refs/heads/master@{#32941}

    Bug: webrtc:9987
    Change-Id: I7cdf49d2aac8357f1f50f90010bf2c2f62fa19f6
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202021
    Reviewed-by: Niels Moller <nisse@webrtc.org>
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
    Cr-Commit-Position: refs/heads/master@{#33001}
This commit is contained in:
Michael Froman 2022-04-28 14:54:22 -05:00 коммит произвёл Connor Sheehan
Родитель 064ed12c76
Коммит fb0516e296
46 изменённых файлов: 681 добавлений и 344 удалений

3
third_party/libwebrtc/README.moz-ff-commit поставляемый
Просмотреть файл

@ -2541,3 +2541,6 @@ a86cef7e2c
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
79d9c373c5
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
e5f4c6b8d2

2
third_party/libwebrtc/README.mozilla поставляемый
Просмотреть файл

@ -1696,3 +1696,5 @@ libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwe
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-04-28T19:43:50.051303.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-04-28T19:44:39.367120.
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-04-28T19:54:16.395880.

11
third_party/libwebrtc/api/BUILD.gn поставляемый
Просмотреть файл

@ -52,6 +52,7 @@ if (!build_with_chromium && !build_with_mozilla) {
"../pc:peerconnection",
"../rtc_base",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
"audio:audio_mixer_api",
"audio_codecs:audio_codecs_api",
"task_queue:default_task_queue_factory",
@ -175,6 +176,7 @@ rtc_library("libjingle_peerconnection_api") {
":rtp_parameters",
":rtp_transceiver_direction",
":scoped_refptr",
"../rtc_base:network_constants",
"adaptation:resource_adaptation_api",
"audio:audio_mixer_api",
"audio_codecs:audio_codecs_api",
@ -205,7 +207,10 @@ rtc_library("libjingle_peerconnection_api") {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:deprecation",
"../rtc_base:ip_address",
"../rtc_base:rtc_base_approved",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../rtc_base/system:rtc_export",
]
absl_deps = [
@ -250,6 +255,7 @@ rtc_source_set("packet_socket_factory") {
"packet_socket_factory.h",
]
deps = [
"../rtc_base:async_resolver_interface",
"../rtc_base:rtc_base",
"../rtc_base/system:rtc_export",
]
@ -388,6 +394,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") {
":video_quality_analyzer_api",
"../media:rtc_media_base",
"../rtc_base:rtc_base",
"../rtc_base:threading",
"rtc_event_log",
"task_queue",
"transport:network_control",
@ -608,6 +615,8 @@ rtc_source_set("network_emulation_manager_api") {
":time_controller",
"../call:simulated_network",
"../rtc_base",
"../rtc_base:network_constants",
"../rtc_base:threading",
"test/network_emulation",
"units:data_rate",
"units:data_size",
@ -625,6 +634,7 @@ rtc_source_set("time_controller") {
deps = [
"../modules/utility",
"../rtc_base",
"../rtc_base:threading",
"../rtc_base/synchronization:yield_policy",
"../system_wrappers",
"task_queue",
@ -679,6 +689,7 @@ rtc_library("ice_transport_factory") {
":scoped_refptr",
"../p2p:rtc_p2p",
"../rtc_base",
"../rtc_base:threading",
"../rtc_base/system:rtc_export",
"rtc_event_log:rtc_event_log",
]

Просмотреть файл

@ -21,7 +21,9 @@ rtc_library("network_emulation") {
"../..:array_view",
"../../../rtc_base",
"../../../rtc_base:checks",
"../../../rtc_base:ip_address",
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:socket_address",
"../../numerics",
"../../task_queue",
"../../units:data_rate",

Просмотреть файл

@ -109,8 +109,10 @@ rtc_source_set("stun_types") {
deps = [
"../../api:array_view",
"../../rtc_base:checks",
"../../rtc_base:ip_address",
"../../rtc_base:rtc_base",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:socket_address",
]
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
}
@ -149,6 +151,7 @@ if (rtc_include_tests) {
":stun_types",
"../../rtc_base",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:socket_address",
"../../test:test_support",
"//testing/gtest",
]

1
third_party/libwebrtc/audio/BUILD.gn поставляемый
Просмотреть файл

@ -90,6 +90,7 @@ rtc_library("audio") {
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
"../rtc_base:safe_minmax",
"../rtc_base:threading",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",

1
third_party/libwebrtc/call/BUILD.gn поставляемый
Просмотреть файл

@ -504,6 +504,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_base_approved",
"../rtc_base:task_queue_for_test",
"../rtc_base:task_queue_for_test",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/task_utils:repeating_task",
"../system_wrappers",

11
third_party/libwebrtc/examples/BUILD.gn поставляемый
Просмотреть файл

@ -686,6 +686,8 @@ if (is_linux || is_chromeos || is_win) {
"../p2p:rtc_p2p",
"../pc:video_track_source",
"../rtc_base:checks",
"../rtc_base:net_helpers",
"../rtc_base:threading",
"../rtc_base/third_party/sigslot",
"../system_wrappers:field_trial",
"../test:field_trial",
@ -777,7 +779,11 @@ if (is_linux || is_chromeos || is_win) {
"../p2p:rtc_p2p",
"../pc:rtc_pc",
"../rtc_base",
"../rtc_base:ip_address",
"../rtc_base:rtc_base_approved",
"../rtc_base:socket_address",
"../rtc_base:socket_server",
"../rtc_base:threading",
]
}
rtc_executable("stunserver") {
@ -789,6 +795,9 @@ if (is_linux || is_chromeos || is_win) {
"../pc:rtc_pc",
"../rtc_base",
"../rtc_base:rtc_base_approved",
"../rtc_base:socket_address",
"../rtc_base:socket_server",
"../rtc_base:threading",
]
}
}
@ -912,6 +921,8 @@ if (!build_with_chromium) {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
"../rtc_base:socket_address",
"../rtc_base:threading",
"//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse",
]

Просмотреть файл

@ -56,6 +56,9 @@ if (is_android) {
deps = [
":generated_jni",
"../../rtc_base:socket_address",
"../../rtc_base:socket_server",
"../../rtc_base:threading",
"//api:transport_api",
"//api/audio_codecs:audio_codecs_api",
"//api/audio_codecs:builtin_audio_decoder_factory",

1
third_party/libwebrtc/logging/BUILD.gn поставляемый
Просмотреть файл

@ -289,6 +289,7 @@ rtc_library("fake_rtc_event_log") {
"../api/rtc_event_log",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:threading",
]
}
}

5
third_party/libwebrtc/media/BUILD.gn поставляемый
Просмотреть файл

@ -113,6 +113,7 @@ rtc_library("rtc_media_base") {
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
"../rtc_base:sanitizer",
"../rtc_base:socket",
"../rtc_base:stringutils",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
@ -323,6 +324,7 @@ rtc_library("rtc_audio_video") {
"../rtc_base:ignore_wundef",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/experiments:min_video_bitrate_experiment",
"../rtc_base/experiments:normalize_simulcast_size_experiment",
@ -411,6 +413,7 @@ rtc_library("rtc_data") {
"../p2p:rtc_p2p",
"../rtc_base",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/task_utils:pending_task_safety_flag",
"../rtc_base/task_utils:to_queued_task",
@ -488,6 +491,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/third_party/sigslot",
"../test:test_support",
@ -597,6 +601,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/experiments:min_video_bitrate_experiment",
"../rtc_base/synchronization:mutex",
"../rtc_base/third_party/sigslot",

Просмотреть файл

@ -367,6 +367,7 @@ if (rtc_include_tests) {
"../../rtc_base:rtc_base_tests_utils",
"../../rtc_base:safe_minmax",
"../../rtc_base:task_queue_for_test",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/system:arch",
"../../rtc_base/system:file_wrapper",

Просмотреть файл

@ -191,6 +191,7 @@ rtc_library("video_coding") {
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_numerics",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:threading",
"../../rtc_base/experiments:alr_experiment",
"../../rtc_base/experiments:field_trial_parser",
"../../rtc_base/experiments:jitter_upper_bound_experiment",

30
third_party/libwebrtc/p2p/BUILD.gn поставляемый
Просмотреть файл

@ -96,8 +96,17 @@ rtc_library("rtc_p2p") {
"../api/transport:stun_types",
"../logging:ice_log",
"../rtc_base",
"../rtc_base:async_resolver_interface",
"../rtc_base:async_socket",
"../rtc_base:checks",
"../rtc_base:ip_address",
"../rtc_base:net_helpers",
"../rtc_base:network_constants",
"../rtc_base:rtc_numerics",
"../rtc_base:socket",
"../rtc_base:socket_address",
"../rtc_base:socket_server",
"../rtc_base:threading",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/synchronization:sequence_checker",
"../rtc_base/system:no_unique_address",
@ -148,6 +157,8 @@ if (rtc_include_tests) {
deps = [
":rtc_p2p",
"../rtc_base",
"../rtc_base:net_helpers",
"../rtc_base:threading",
]
}
@ -173,9 +184,14 @@ if (rtc_include_tests) {
"../api/crypto:options",
"../api/transport:stun_types",
"../rtc_base",
"../rtc_base:async_resolver_interface",
"../rtc_base:async_socket",
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:socket_address",
"../rtc_base:socket_server",
"../rtc_base:threading",
"../rtc_base/third_party/sigslot",
"../test:test_support",
]
@ -221,11 +237,18 @@ if (rtc_include_tests) {
"../api/transport:stun_types",
"../api/units:time_delta",
"../rtc_base",
"../rtc_base:async_socket",
"../rtc_base:checks",
"../rtc_base:gunit_helpers",
"../rtc_base:ip_address",
"../rtc_base:net_helpers",
"../rtc_base:network_constants",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:socket",
"../rtc_base:socket_address",
"../rtc_base:testclient",
"../rtc_base:threading",
"../rtc_base/network:sent_packet",
"../rtc_base/third_party/sigslot",
"../system_wrappers:metrics",
@ -256,6 +279,8 @@ rtc_library("p2p_server_utils") {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../rtc_base/third_party/sigslot",
]
absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
@ -273,7 +298,11 @@ rtc_library("libstunprober") {
"../api:packet_socket_factory",
"../api/transport:stun_types",
"../rtc_base",
"../rtc_base:async_resolver_interface",
"../rtc_base:checks",
"../rtc_base:ip_address",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../rtc_base/system:rtc_export",
]
}
@ -290,6 +319,7 @@ if (rtc_include_tests) {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:gunit_helpers",
"../rtc_base:ip_address",
"../rtc_base:rtc_base_tests_utils",
"../test:test_support",
"//testing/gtest",

Просмотреть файл

@ -10,7 +10,7 @@
#include "p2p/base/basic_async_resolver_factory.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/async_resolver.h"
namespace webrtc {

Просмотреть файл

@ -15,6 +15,7 @@
#include <string>
#include "p2p/base/async_stun_tcp_socket.h"
#include "rtc_base/async_resolver.h"
#include "rtc_base/async_tcp_socket.h"
#include "rtc_base/async_udp_socket.h"
#include "rtc_base/checks.h"

2
third_party/libwebrtc/p2p/base/stun_port.cc поставляемый
Просмотреть файл

@ -17,11 +17,11 @@
#include "p2p/base/connection.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port_allocator.h"
#include "rtc_base/async_resolver_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/strings/string_builder.h"
namespace cricket {

1
third_party/libwebrtc/p2p/base/turn_port.h поставляемый
Просмотреть файл

@ -25,6 +25,7 @@
#include "p2p/client/basic_port_allocator.h"
#include "rtc_base/async_invoker.h"
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/async_resolver_interface.h"
#include "rtc_base/ssl_certificate.h"
namespace webrtc {

23
third_party/libwebrtc/pc/BUILD.gn поставляемый
Просмотреть файл

@ -114,7 +114,9 @@ rtc_library("rtc_pc_base") {
"../rtc_base:checks",
"../rtc_base:deprecation",
"../rtc_base:rtc_task_queue",
"../rtc_base:socket_address",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
"../rtc_base/system:file_wrapper",
@ -277,9 +279,13 @@ rtc_library("peerconnection") {
"../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:deprecation",
"../rtc_base:ip_address",
"../rtc_base:network_constants",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_operations_chain",
"../rtc_base:safe_minmax",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../rtc_base:weak_ptr",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/network:sent_packet",
@ -324,6 +330,7 @@ rtc_library("connection_context") {
"../p2p:rtc_p2p",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:threading",
]
}
@ -338,6 +345,7 @@ rtc_library("peer_connection_message_handler") {
"../api:media_stream_interface",
"../api:rtc_error",
"../rtc_base",
"../rtc_base:threading",
"../rtc_base/synchronization:sequence_checker",
]
}
@ -400,6 +408,7 @@ rtc_library("rtp_transmission_manager") {
"../media:rtc_media_base",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:threading",
"../rtc_base/third_party/sigslot",
]
absl_deps = [
@ -436,6 +445,7 @@ rtc_library("rtp_receiver") {
"../rtc_base:logging",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -466,6 +476,7 @@ rtc_library("audio_rtp_receiver") {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:refcount",
"../rtc_base:threading",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -498,6 +509,7 @@ rtc_library("video_rtp_receiver") {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -548,6 +560,7 @@ rtc_library("video_track") {
"../rtc_base:checks",
"../rtc_base:refcount",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
]
}
@ -593,6 +606,7 @@ rtc_library("jitter_buffer_delay") {
"../rtc_base:checks",
"../rtc_base:refcount",
"../rtc_base:safe_minmax",
"../rtc_base:threading",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -617,6 +631,7 @@ rtc_library("remote_audio_source") {
"../rtc_base:rtc_base_approved",
"../rtc_base:safe_conversions",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
]
absl_deps = [
@ -680,6 +695,7 @@ rtc_library("dtmf_sender") {
"../api:libjingle_peerconnection_api",
"../rtc_base:checks",
"../rtc_base:rtc_base",
"../rtc_base:threading",
]
absl_deps = [
"//third_party/abseil-cpp/absl/algorithm:container",
@ -803,6 +819,7 @@ if (rtc_include_tests) {
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:threading",
"../rtc_base/third_party/sigslot",
"../system_wrappers:metrics",
"../test:field_trial",
@ -851,6 +868,8 @@ if (rtc_include_tests) {
"../rtc_base:checks",
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../system_wrappers",
"../test:perf_test",
"../test:test_support",
@ -951,6 +970,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
"../rtc_base:task_queue_for_test",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
"../rtc_base/task_utils:repeating_task",
@ -1066,8 +1086,11 @@ if (rtc_include_tests) {
"../p2p:fake_port_allocator",
"../rtc_base:checks",
"../rtc_base:gunit_helpers",
"../rtc_base:ip_address",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:rtc_json",
"../rtc_base:socket_address",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/third_party/base64",
"../rtc_base/third_party/sigslot",

361
third_party/libwebrtc/rtc_base/BUILD.gn поставляемый
Просмотреть файл

@ -15,7 +15,7 @@ if (is_android) {
import("//build/config/android/rules.gni")
}
config("rtc_base_chromium_config") {
config("threading_chromium_config") {
defines = [ "NO_MAIN_THREAD_WRAPPING" ]
}
@ -674,139 +674,220 @@ rtc_library("rtc_json") {
}
rtc_source_set("async_resolver") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# async_resolver source files (see
# https://webrtc-review.googlesource.com/c/src/+/196903).
sources = [ "async_resolver.h" ]
# TODO(bugs.webrtc.org/9987): Remove when downstream clients have
# been redirected on //rtc_base:threading.
sources = []
}
rtc_source_set("net_helpers") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "net_helpers.cc",
# "net_helpers.h",
# ]
rtc_library("net_helpers") {
sources = [
"net_helpers.cc",
"net_helpers.h",
]
deps = []
if (is_android) {
deps += [ ":ifaddrs_android" ]
}
if (is_win) {
deps += [ ":win32" ]
}
}
rtc_source_set("async_resolver_interface") {
rtc_library("async_resolver_interface") {
visibility = [ "*" ]
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "async_resolver_interface.cc",
# "async_resolver_interface.h",
# ]
sources = [
"async_resolver_interface.cc",
"async_resolver_interface.h",
]
deps = [
":socket_address",
"system:rtc_export",
"third_party/sigslot",
]
}
rtc_source_set("ip_address") {
rtc_library("ip_address") {
visibility = [ "*" ]
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "ip_address.cc",
# "ip_address.h",
# ]
sources = [
"ip_address.cc",
"ip_address.h",
]
deps = [
":net_helpers",
":rtc_base_approved",
":stringutils",
"system:rtc_export",
]
if (is_win) {
deps += [ ":win32" ]
}
}
rtc_source_set("socket_address") {
rtc_library("socket_address") {
visibility = [ "*" ]
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "socket_address.cc",
# "socket_address.h",
# ]
sources = [
"socket_address.cc",
"socket_address.h",
]
deps = [
":checks",
":ip_address",
":logging",
":net_helpers",
":rtc_base_approved",
":safe_conversions",
":stringutils",
"system:rtc_export",
]
if (is_win) {
deps += [ ":win32" ]
}
}
rtc_source_set("null_socket_server") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "null_socket_server.cc",
# "null_socket_server.h",
# ]
rtc_library("null_socket_server") {
sources = [
"null_socket_server.cc",
"null_socket_server.h",
]
deps = [
":async_socket",
":checks",
":rtc_event",
":socket",
":socket_server",
"system:rtc_export",
]
}
rtc_source_set("socket_server") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "socket_server.h",
# ]
sources = [ "socket_server.h" ]
deps = [ ":socket_factory" ]
}
rtc_source_set("threading") {
rtc_library("threading") {
visibility = [ "*" ]
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "asyncresolver.cc",
# "asyncresolver.h",
# "defaultsocketserver.cc",
# "defaultsocketserver.h",
# "message_handler.cc",
# "message_handler.h",
# "network_monitor.cc",
# "network_monitor.h",
# "network_monitor_factory.cc",
# "network_monitor_factory.h",
# "physical_socket_server.cc",
# "physical_socket_server.h",
# "signal_thread.cc",
# "signal_thread.h",
# "thread.cc",
# "thread.h",
# ]
if (build_with_chromium) {
public_configs = [ ":threading_chromium_config" ]
}
sources = [
"async_resolver.cc",
"async_resolver.h",
"internal/default_socket_server.cc",
"internal/default_socket_server.h",
"message_handler.cc",
"message_handler.h",
"network_monitor.cc",
"network_monitor.h",
"network_monitor_factory.cc",
"network_monitor_factory.h",
"physical_socket_server.cc",
"physical_socket_server.h",
# "signal_thread.cc",
# "signal_thread.h",
"thread.cc",
"thread.h",
"thread_message.h",
]
absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
deps = [
":async_resolver_interface",
":atomicops",
":checks",
":criticalsection",
":ip_address",
":logging",
":macromagic",
":network_constants",
":null_socket_server",
":platform_thread_types",
":rtc_base_approved",
":rtc_event",
":rtc_task_queue",
":socket_address",
":socket_server",
":timeutils",
"../api:function_view",
"../api:scoped_refptr",
"../api/task_queue",
"synchronization:sequence_checker",
"system:no_unique_address",
"system:rtc_export",
"task_utils:pending_task_safety_flag",
"task_utils:to_queued_task",
"third_party/sigslot",
]
if (is_android) {
deps += [ ":ifaddrs_android" ]
}
if (is_win) {
deps += [ ":win32" ]
}
if (is_mac || is_ios) {
deps += [ "system:cocoa_threading" ]
}
}
rtc_source_set("socket_factory") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "socket_factory.h",
# ]
sources = [ "socket_factory.h" ]
deps = [
":async_socket",
":socket",
]
}
rtc_source_set("async_socket") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "async_socket.cc",
# "async_socket.h",
# ]
rtc_library("async_socket") {
sources = [
"async_socket.cc",
"async_socket.h",
]
deps = [
":checks",
":socket",
":socket_address",
"third_party/sigslot",
]
}
rtc_source_set("socket") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "socket.cc",
# "socket.h",
# ]
rtc_library("socket") {
sources = [
"socket.cc",
"socket.h",
]
deps = [
":macromagic",
":socket_address",
]
if (is_win) {
deps += [ ":win32" ]
}
}
rtc_source_set("network_constants") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "network_constants.h",
# ]
sources = [
"network_constants.cc",
"network_constants.h",
]
deps = [ ":checks" ]
}
if (is_android) {
rtc_source_set("ifaddrs_android") {
# TODO(bugs.webrtc.org/9987): This build target will soon contain
# the following files:
# sources = [
# "ifaddrs_android.cc",
# "ifaddrs_android.h",
# ]
rtc_library("ifaddrs_android") {
sources = [
"ifaddrs_android.cc",
"ifaddrs_android.h",
]
libs = [
"log",
"GLESv2",
]
}
}
if (is_win) {
rtc_source_set("win32") {
rtc_library("win32") {
sources = [
"win32.cc",
"win32.h",
@ -837,10 +918,20 @@ rtc_library("rtc_base") {
libs = []
defines = []
deps = [
":async_resolver_interface",
":async_socket",
":checks",
":deprecation",
":ip_address",
":network_constants",
":null_socket_server",
":rtc_task_queue",
":socket",
":socket_address",
":socket_factory",
":socket_server",
":stringutils",
":threading",
"../api:array_view",
"../api:function_view",
"../api:scoped_refptr",
@ -876,10 +967,6 @@ rtc_library("rtc_base") {
#"async_invoker_inl.h",
#"async_packet_socket.cc",
#"async_packet_socket.h",
"async_resolver_interface.cc",
"async_resolver_interface.h",
"async_socket.cc",
"async_socket.h",
#"async_tcp_socket.cc",
#"async_tcp_socket.h",
#"async_udp_socket.cc",
@ -899,30 +986,16 @@ rtc_library("rtc_base") {
#"helpers.h",
#"http_common.cc",
#"http_common.h",
"ip_address.cc",
"ip_address.h",
"keep_ref_until_done.h",
#"mdns_responder_interface.h",
#"message_digest.cc",
#"message_digest.h",
"message_handler.cc",
"message_handler.h",
#"net_helper.cc",
#"net_helper.h",
"net_helpers.cc",
"net_helpers.h",
#"network.cc",
#"network.h",
"network_constants.cc",
"network_constants.h",
#"network_monitor.cc",
#"network_monitor.h",
#"network_monitor_factory.cc",
#"network_monitor_factory.h",
"network_route.cc",
"network_route.h",
"null_socket_server.cc",
"null_socket_server.h",
#"openssl.h",
#"openssl_adapter.cc",
#"openssl_adapter.h",
@ -936,8 +1009,6 @@ rtc_library("rtc_base") {
#"openssl_stream_adapter.h",
#"openssl_utility.cc",
#"openssl_utility.h",
"physical_socket_server.cc",
"physical_socket_server.h",
#"proxy_info.cc",
#"proxy_info.h",
#"rtc_certificate.cc",
@ -946,16 +1017,10 @@ rtc_library("rtc_base") {
#"rtc_certificate_generator.h",
#"signal_thread.h",
"sigslot_repeater.h",
#"socket.cc",
#"socket.h",
#"socket_adapters.cc",
#"socket_adapters.h",
"socket_address.cc",
"socket_address.h",
#"socket_address_pair.cc",
#"socket_address_pair.h",
#"socket_factory.h",
"socket_server.h",
#"ssl_adapter.cc",
#"ssl_adapter.h",
#"ssl_certificate.cc",
@ -968,9 +1033,6 @@ rtc_library("rtc_base") {
#"ssl_stream_adapter.h",
"stream.cc",
"stream.h",
"thread.cc",
"thread.h",
#"thread_message.h",
#"unique_id_generator.cc",
#"unique_id_generator.h",
]
@ -994,7 +1056,6 @@ rtc_library("rtc_base") {
if (build_with_chromium) {
include_dirs = [ "../../boringssl/src/include" ]
public_configs += [ ":rtc_base_chromium_config" ]
} else {
sources += [
"callback.h",
@ -1024,20 +1085,11 @@ rtc_library("rtc_base") {
}
if (is_android) {
sources += [
"ifaddrs_android.cc",
"ifaddrs_android.h",
]
libs += [
"log",
"GLESv2",
]
deps += [ ":ifaddrs_android" ]
}
if (is_ios || is_mac) {
sources += [ "mac_ifaddrs_converter.cc" ]
deps += [ "system:cocoa_threading" ]
}
if (is_linux || is_chromeos) {
@ -1093,6 +1145,7 @@ rtc_library("gunit_helpers") {
":rtc_base",
":rtc_base_tests_utils",
":stringutils",
":threading",
"../test:test_support",
]
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
@ -1109,6 +1162,7 @@ rtc_library("testclient") {
":gunit_helpers",
":rtc_base",
":rtc_base_tests_utils",
":threading",
":timeutils",
"synchronization:mutex",
]
@ -1167,8 +1221,15 @@ rtc_library("rtc_base_tests_utils") {
"virtual_socket_server.h",
]
deps = [
":async_socket",
":checks",
":ip_address",
":rtc_base",
":socket",
":socket_address",
":socket_factory",
":socket_server",
":threading",
"../api/units:time_delta",
"../api/units:timestamp",
"memory:fifo_buffer",
@ -1237,11 +1298,19 @@ if (rtc_include_tests) {
"socket_unittest.h",
]
deps = [
":async_socket",
":checks",
":gunit_helpers",
":ip_address",
":net_helpers",
":null_socket_server",
":rtc_base",
":rtc_base_tests_utils",
":socket",
":socket_address",
":socket_server",
":testclient",
":threading",
"../system_wrappers",
"../test:fileutils",
"../test:test_main",
@ -1305,10 +1374,13 @@ if (rtc_include_tests) {
sources += [ "win/windows_version_unittest.cc" ]
}
deps = [
":async_socket",
":bounded_inline_vector",
":checks",
":divide_round",
":gunit_helpers",
":ip_address",
":null_socket_server",
":rate_limiter",
":rtc_base",
":rtc_base_approved",
@ -1318,8 +1390,12 @@ if (rtc_include_tests) {
":safe_compare",
":safe_minmax",
":sanitizer",
":socket",
":socket_address",
":socket_server",
":stringutils",
":testclient",
":threading",
"../api:array_view",
"../api:scoped_refptr",
"../api/numerics",
@ -1366,6 +1442,7 @@ if (rtc_include_tests) {
":rtc_base_approved",
":rtc_event",
":rtc_operations_chain",
":threading",
"../test:test_support",
]
}
@ -1447,11 +1524,19 @@ if (rtc_include_tests) {
"unique_id_generator_unittest.cc",
]
deps = [
":async_socket",
":checks",
":gunit_helpers",
":ip_address",
":net_helpers",
":null_socket_server",
":rtc_base_tests_utils",
":socket_address",
":socket_factory",
":socket_server",
":stringutils",
":testclient",
":threading",
"../api:array_view",
"../api/task_queue",
"../api/task_queue:task_queue_test",

169
third_party/libwebrtc/rtc_base/async_resolver.cc поставляемый Normal file
Просмотреть файл

@ -0,0 +1,169 @@
/*
* 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 <string>
#include <utility>
#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/task_queue.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "rtc_base/third_party/sigslot/sigslot.h" // for signal_with_thread...
namespace rtc {
int ResolveHostname(const std::string& hostname,
int family,
std::vector<IPAddress>* addresses) {
#ifdef __native_client__
RTC_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(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__
}
AsyncResolver::AsyncResolver() : error_(-1) {}
AsyncResolver::~AsyncResolver() {
RTC_DCHECK_RUN_ON(&sequence_checker_);
}
void AsyncResolver::Start(const SocketAddress& addr) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
RTC_DCHECK(!destroy_called_);
addr_ = addr;
webrtc::TaskQueueBase* current_task_queue = webrtc::TaskQueueBase::Current();
popup_thread_ = Thread::Create();
popup_thread_->Start();
popup_thread_->PostTask(webrtc::ToQueuedTask(
[this, flag = safety_.flag(), addr, current_task_queue] {
std::vector<IPAddress> addresses;
int error =
ResolveHostname(addr.hostname().c_str(), addr.family(), &addresses);
current_task_queue->PostTask(webrtc::ToQueuedTask(
std::move(flag), [this, error, addresses = std::move(addresses)] {
RTC_DCHECK_RUN_ON(&sequence_checker_);
ResolveDone(std::move(addresses), error);
}));
}));
}
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

Просмотреть файл

@ -11,7 +11,62 @@
#ifndef RTC_BASE_ASYNC_RESOLVER_H_
#define RTC_BASE_ASYNC_RESOLVER_H_
// Placeholder header for the refactoring in:
// https://webrtc-review.googlesource.com/c/src/+/196903
#if defined(WEBRTC_POSIX)
#include <sys/socket.h>
#elif WEBRTC_WIN
#include <winsock2.h> // NOLINT
#endif
#include <memory>
#include <vector>
#include "rtc_base/async_resolver_interface.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/task_utils/pending_task_safety_flag.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.
class RTC_EXPORT AsyncResolver : public AsyncResolverInterface {
public:
AsyncResolver();
~AsyncResolver() override;
void Start(const SocketAddress& addr) 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:
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_);
webrtc::ScopedTaskSafety safety_ RTC_GUARDED_BY(sequence_checker_);
std::unique_ptr<Thread> popup_thread_ RTC_GUARDED_BY(sequence_checker_);
bool recursion_check_ =
false; // Protects against SignalDone calling into Destroy.
bool destroy_called_ = false;
RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker sequence_checker_;
};
} // namespace rtc
#endif // RTC_BASE_ASYNC_RESOLVER_H_

Просмотреть файл

@ -0,0 +1,33 @@
/*
* Copyright 2020 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/internal/default_socket_server.h"
#include <memory>
#include "rtc_base/socket_server.h"
#if defined(__native_client__)
#include "rtc_base/null_socket_server.h"
#else
#include "rtc_base/physical_socket_server.h"
#endif
namespace rtc {
std::unique_ptr<SocketServer> CreateDefaultSocketServer() {
#if defined(__native_client__)
return std::unique_ptr<SocketServer>(new rtc::NullSocketServer);
#else
return std::unique_ptr<SocketServer>(new rtc::PhysicalSocketServer);
#endif
}
} // namespace rtc

24
third_party/libwebrtc/rtc_base/internal/default_socket_server.h поставляемый Normal file
Просмотреть файл

@ -0,0 +1,24 @@
/*
* Copyright 2020 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef RTC_BASE_INTERNAL_DEFAULT_SOCKET_SERVER_H_
#define RTC_BASE_INTERNAL_DEFAULT_SOCKET_SERVER_H_
#include <memory>
#include "rtc_base/socket_server.h"
namespace rtc {
std::unique_ptr<SocketServer> CreateDefaultSocketServer();
} // namespace rtc
#endif // RTC_BASE_INTERNAL_DEFAULT_SOCKET_SERVER_H_

Просмотреть файл

@ -20,8 +20,9 @@
#include <netdb.h>
#endif
#include "rtc_base/byte_order.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/byte_order.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/string_utils.h"

Просмотреть файл

@ -36,6 +36,7 @@ rtc_library("fifo_buffer") {
]
deps = [
"..:rtc_base",
"..:threading",
"../synchronization:mutex",
"../task_utils:pending_task_safety_flag",
"../task_utils:to_queued_task",

140
third_party/libwebrtc/rtc_base/net_helpers.cc поставляемый
Просмотреть файл

@ -10,6 +10,8 @@
#include "rtc_base/net_helpers.h"
#include <memory>
#if defined(WEBRTC_WIN)
#include <ws2spi.h>
#include <ws2tcpip.h>
@ -17,6 +19,7 @@
#include "rtc_base/win32.h"
#endif
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
#include <arpa/inet.h>
#if defined(WEBRTC_ANDROID)
#include "rtc_base/ifaddrs_android.h"
#else
@ -24,145 +27,8 @@
#endif
#endif // defined(WEBRTC_POSIX) && !defined(__native_client__)
#include "api/task_queue/task_queue_base.h"
#include "rtc_base/logging.h"
#include "rtc_base/signal_thread.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "rtc_base/third_party/sigslot/sigslot.h" // for signal_with_thread...
namespace rtc {
int ResolveHostname(const std::string& hostname,
int family,
std::vector<IPAddress>* addresses) {
#ifdef __native_client__
RTC_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(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__
}
AsyncResolver::AsyncResolver() : error_(-1) {}
AsyncResolver::~AsyncResolver() {
RTC_DCHECK_RUN_ON(&sequence_checker_);
}
void AsyncResolver::Start(const SocketAddress& addr) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
RTC_DCHECK(!destroy_called_);
addr_ = addr;
webrtc::TaskQueueBase* current_task_queue = webrtc::TaskQueueBase::Current();
popup_thread_ = Thread::Create();
popup_thread_->Start();
popup_thread_->PostTask(webrtc::ToQueuedTask(
[this, flag = safety_.flag(), addr, current_task_queue] {
std::vector<IPAddress> addresses;
int error =
ResolveHostname(addr.hostname().c_str(), addr.family(), &addresses);
current_task_queue->PostTask(webrtc::ToQueuedTask(
std::move(flag), [this, error, addresses = std::move(addresses)] {
RTC_DCHECK_RUN_ON(&sequence_checker_);
ResolveDone(std::move(addresses), error);
}));
}));
}
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;
}
}
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size) {
#if defined(WEBRTC_WIN)
return win32_inet_ntop(af, src, dst, size);

50
third_party/libwebrtc/rtc_base/net_helpers.h поставляемый
Просмотреть файл

@ -15,57 +15,12 @@
#include <sys/socket.h>
#elif WEBRTC_WIN
#include <winsock2.h> // NOLINT
#include "rtc_base/win32.h"
#endif
#include <vector>
#include "rtc_base/async_resolver_interface.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/task_utils/pending_task_safety_flag.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.
class RTC_EXPORT AsyncResolver : public AsyncResolverInterface {
public:
AsyncResolver();
~AsyncResolver() override;
void Start(const SocketAddress& addr) 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:
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_);
webrtc::ScopedTaskSafety safety_ RTC_GUARDED_BY(sequence_checker_);
std::unique_ptr<Thread> popup_thread_ RTC_GUARDED_BY(sequence_checker_);
bool recursion_check_ =
false; // Protects against SignalDone calling into Destroy.
bool destroy_called_ = false;
RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker sequence_checker_;
};
// rtc namespaced wrappers for inet_ntop and inet_pton so we can avoid
// the windows-native versions of these.
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
@ -73,6 +28,7 @@ int inet_pton(int af, const char* src, void* dst);
bool HasIPv4Enabled();
bool HasIPv6Enabled();
} // namespace rtc
#endif // RTC_BASE_NET_HELPERS_H_

Просмотреть файл

@ -122,14 +122,6 @@ class ScopedSetTrue {
namespace rtc {
std::unique_ptr<SocketServer> SocketServer::CreateDefault() {
#if defined(__native_client__)
return std::unique_ptr<SocketServer>(new rtc::NullSocketServer);
#else
return std::unique_ptr<SocketServer>(new rtc::PhysicalSocketServer);
#endif
}
PhysicalSocket::PhysicalSocket(PhysicalSocketServer* ss, SOCKET s)
: ss_(ss),
s_(s),

Просмотреть файл

@ -21,8 +21,9 @@
#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/net_helpers.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/thread_annotations.h"

Просмотреть файл

@ -18,6 +18,7 @@
#include "rtc_base/gunit.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/network_monitor.h"
#include "rtc_base/socket_unittest.h"
#include "rtc_base/test_utils.h"

Просмотреть файл

@ -88,6 +88,7 @@ if (rtc_include_tests) {
"..:macromagic",
"..:rtc_base",
"..:rtc_event",
"..:threading",
"../../test:test_support",
"//third_party/google_benchmark",
]

9
third_party/libwebrtc/rtc_base/thread.cc поставляемый
Просмотреть файл

@ -33,6 +33,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/deprecated/recursive_critical_section.h"
#include "rtc_base/event.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/logging.h"
#include "rtc_base/null_socket_server.h"
#include "rtc_base/synchronization/sequence_checker.h"
@ -257,7 +258,7 @@ Thread* Thread::Current() {
#ifndef NO_MAIN_THREAD_WRAPPING
// Only autowrap the thread which instantiated the ThreadManager.
if (!thread && manager->IsMainThread()) {
thread = new Thread(SocketServer::CreateDefault());
thread = new Thread(CreateDefaultSocketServer());
thread->WrapCurrentWithThreadManager(manager, true);
}
#endif
@ -326,7 +327,7 @@ void rtc::ThreadManager::ChangeCurrentThreadForTest(rtc::Thread* thread) {
Thread* ThreadManager::WrapCurrentThread() {
Thread* result = CurrentThread();
if (nullptr == result) {
result = new Thread(SocketServer::CreateDefault());
result = new Thread(CreateDefaultSocketServer());
result->WrapCurrentWithThreadManager(this, true);
}
return result;
@ -696,7 +697,7 @@ bool Thread::IsCurrent() const {
}
std::unique_ptr<Thread> Thread::CreateWithSocketServer() {
return std::unique_ptr<Thread>(new Thread(SocketServer::CreateDefault()));
return std::unique_ptr<Thread>(new Thread(CreateDefaultSocketServer()));
}
std::unique_ptr<Thread> Thread::Create() {
@ -1137,7 +1138,7 @@ MessageHandler* Thread::GetPostTaskMessageHandler() {
}
AutoThread::AutoThread()
: Thread(SocketServer::CreateDefault(), /*do_init=*/false) {
: Thread(CreateDefaultSocketServer(), /*do_init=*/false) {
if (!ThreadManager::Instance()->CurrentThread()) {
// DoInit registers with ThreadManager. Do that only if we intend to
// be rtc::Thread::Current(), otherwise ProcessAllMessageQueuesInternal will

Просмотреть файл

@ -19,6 +19,7 @@
#include "rtc_base/atomic_ops.h"
#include "rtc_base/event.h"
#include "rtc_base/gunit.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/null_socket_server.h"
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/socket_address.h"
@ -505,7 +506,7 @@ TEST(ThreadTest, SetNameOnSignalQueueDestroyed) {
class ThreadQueueTest : public ::testing::Test, public Thread {
public:
ThreadQueueTest() : Thread(SocketServer::CreateDefault(), true) {}
ThreadQueueTest() : Thread(CreateDefaultSocketServer(), true) {}
bool IsLocked_Worker() {
if (!CritForTest()->TryEnter()) {
return true;
@ -555,7 +556,7 @@ static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(Thread* q) {
}
TEST_F(ThreadQueueTest, DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder) {
Thread q(SocketServer::CreateDefault(), true);
Thread q(CreateDefaultSocketServer(), true);
DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(&q);
NullSocketServer nullss;

3
third_party/libwebrtc/rtc_tools/BUILD.gn поставляемый
Просмотреть файл

@ -181,6 +181,7 @@ if (!is_component_build) {
"../rtc_base",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_json",
"../rtc_base:threading",
"../rtc_base/system:file_wrapper",
"../test:fileutils",
"../test:rtp_test_utils",
@ -489,6 +490,8 @@ if (rtc_include_tests) {
"../common_video",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:null_socket_server",
"../rtc_base:threading",
"../test:fileutils",
"../test:test_main",
"../test:test_support",

Просмотреть файл

@ -45,9 +45,12 @@ if (rtc_enable_protobuf) {
"../../rtc_base",
"../../rtc_base:checks",
"../../rtc_base:ignore_wundef",
"../../rtc_base:ip_address",
"../../rtc_base:protobuf_utils",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:socket_address",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/system:no_unique_address",

18
third_party/libwebrtc/sdk/BUILD.gn поставляемый
Просмотреть файл

@ -238,7 +238,10 @@ if (is_ios || is_mac) {
sources = [ "objc/native/src/audio/audio_session_observer.h" ]
deps = [ "../rtc_base" ]
deps = [
"../rtc_base",
"../rtc_base:threading",
]
}
rtc_library("audio_device") {
@ -267,6 +270,7 @@ if (is_ios || is_mac) {
"../modules/audio_device:audio_device_generic",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:threading",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
]
@ -340,7 +344,11 @@ if (is_ios || is_mac) {
sources = [ "objc/native/src/network_monitor_observer.h" ]
deps = [ "../rtc_base" ]
deps = [
"../rtc_base",
"../rtc_base:network_constants",
"../rtc_base:threading",
]
}
rtc_library("network_monitor_objc") {
@ -385,6 +393,7 @@ if (is_ios || is_mac) {
"../media:rtc_media_base",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:threading",
"//third_party/libyuv",
]
@ -975,6 +984,7 @@ if (is_ios || is_mac) {
"../pc:peerconnection",
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:network_constants",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
]
@ -1079,6 +1089,7 @@ if (is_ios || is_mac) {
":sdk_unittests_bundle_data",
":sdk_unittests_sources",
"../rtc_base",
"../rtc_base:threading",
"//test:test_support",
]
ldflags = [ "-all_load" ]
@ -1098,6 +1109,7 @@ if (is_ios || is_mac) {
":framework_objc+link",
":ios_framework_bundle",
"../rtc_base",
"../rtc_base:threading",
"//test:test_support",
]
}
@ -1502,6 +1514,7 @@ if (is_ios || is_mac) {
"../api/video_codecs:video_codecs_api",
"../common_video",
"../rtc_base",
"../rtc_base:threading",
]
if (is_ios) {
deps += [ ":native_network_monitor" ]
@ -1522,6 +1535,7 @@ if (is_ios || is_mac) {
":network_monitor_objc",
":network_monitor_observer",
"../rtc_base",
"../rtc_base:threading",
"../rtc_base/synchronization:sequence_checker",
]
}

8
third_party/libwebrtc/sdk/android/BUILD.gn поставляемый
Просмотреть файл

@ -559,7 +559,9 @@ if (current_os == "linux" || is_android) {
"../../api:scoped_refptr",
"../../rtc_base",
"../../rtc_base:checks",
"../../rtc_base:ip_address",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:threading",
"../../rtc_base/synchronization:sequence_checker",
"../../system_wrappers:field_trial",
"../../system_wrappers:metrics",
@ -656,6 +658,7 @@ if (current_os == "linux" || is_android) {
"../../rtc_base",
"../../rtc_base:checks",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/task_utils:to_queued_task",
"//third_party/libyuv",
@ -746,6 +749,7 @@ if (current_os == "linux" || is_android) {
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:threading",
"../../rtc_base/system:thread_registry",
"../../system_wrappers:field_trial",
]
@ -916,6 +920,7 @@ if (current_os == "linux" || is_android) {
deps = [
":base_jni",
"../../rtc_base:threading",
"//rtc_base",
]
}
@ -930,6 +935,7 @@ if (current_os == "linux" || is_android) {
deps = [
":base_jni",
":peerconnection_jni",
"../../rtc_base:threading",
"//api:libjingle_peerconnection_api",
"//api/video_codecs:video_codecs_api",
"//rtc_base",
@ -968,6 +974,7 @@ if (current_os == "linux" || is_android) {
":native_api_jni",
":video_jni",
":videoframe_jni",
"../../rtc_base:threading",
"//api:libjingle_peerconnection_api",
"//api:media_stream_interface",
"//api/video:video_frame",
@ -1471,6 +1478,7 @@ if (is_android) {
"../../modules/utility",
"../../pc:libjingle_peerconnection",
"../../rtc_base:checks",
"../../rtc_base:ip_address",
"../../rtc_base:rtc_base",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/system:inline",

3
third_party/libwebrtc/test/BUILD.gn поставляемый
Просмотреть файл

@ -146,6 +146,7 @@ if (!build_with_chromium) {
"../api:scoped_refptr",
"../modules/video_capture:video_capture_module",
"../rtc_base",
"../rtc_base:threading",
"../sdk:base_objc",
"../sdk:native_api",
"../sdk:native_video",
@ -418,6 +419,7 @@ if (rtc_include_tests) {
"../rtc_base:checks",
"../rtc_base:logging",
"../rtc_base:rtc_base_approved",
"../rtc_base:threading",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
]
@ -868,6 +870,7 @@ rtc_library("test_common") {
"../rtc_base:rtc_base",
"../rtc_base:rtc_event",
"../rtc_base:task_queue_for_test",
"../rtc_base:threading",
"../rtc_base/task_utils:to_queued_task",
"../system_wrappers",
"../system_wrappers:field_trial",

1
third_party/libwebrtc/test/fuzzers/BUILD.gn поставляемый
Просмотреть файл

@ -439,6 +439,7 @@ webrtc_fuzzer_test("pseudotcp_parser_fuzzer") {
deps = [
"../../p2p:rtc_p2p",
"../../rtc_base",
"../../rtc_base:threading",
]
}

7
third_party/libwebrtc/test/network/BUILD.gn поставляемый
Просмотреть файл

@ -52,10 +52,16 @@ rtc_library("emulated_network") {
"../../call:simulated_network",
"../../p2p:p2p_server_utils",
"../../rtc_base",
"../../rtc_base:async_socket",
"../../rtc_base:ip_address",
"../../rtc_base:network_constants",
"../../rtc_base:rtc_base_tests_utils",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:safe_minmax",
"../../rtc_base:socket_address",
"../../rtc_base:socket_server",
"../../rtc_base:task_queue_for_test",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/task_utils:repeating_task",
@ -127,6 +133,7 @@ rtc_library("cross_traffic_unittest") {
"../../call:simulated_network",
"../../rtc_base",
"../../rtc_base:logging",
"../../rtc_base:network_constants",
"../../rtc_base:rtc_event",
"../time_controller",
]

4
third_party/libwebrtc/test/pc/e2e/BUILD.gn поставляемый
Просмотреть файл

@ -61,6 +61,7 @@ if (!build_with_chromium) {
"../../../api/transport:webrtc_key_value_config",
"../../../api/video_codecs:video_codecs_api",
"../../../rtc_base",
"../../../rtc_base:threading",
]
}
@ -328,6 +329,7 @@ if (!build_with_chromium) {
"../../../api/transport:network_control",
"../../../api/video_codecs:video_codecs_api",
"../../../rtc_base",
"../../../rtc_base:threading",
]
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
}
@ -404,6 +406,7 @@ if (!build_with_chromium) {
"../../../rtc_base:rtc_base_approved",
"../../../rtc_base:safe_conversions",
"../../../rtc_base:task_queue_for_test",
"../../../rtc_base:threading",
"../../../rtc_base/synchronization:mutex",
"../../../system_wrappers",
"../../../system_wrappers:field_trial",
@ -697,6 +700,7 @@ if (!build_with_chromium) {
"../../../api/units:data_size",
"../../../api/units:timestamp",
"../../../rtc_base",
"../../../rtc_base:ip_address",
"../../../rtc_base:rtc_event",
"../../../rtc_base:stringutils",
"../../../rtc_base/synchronization:mutex",

Просмотреть файл

@ -48,6 +48,7 @@ if (rtc_include_tests) {
"../../pc:pc_test_utils",
"../../pc:rtc_pc_base",
"../../rtc_base",
"../../rtc_base:null_socket_server",
"../../rtc_base:stringutils",
"../logging:log_writer",
"../network:emulated_network",

Просмотреть файл

@ -132,7 +132,9 @@ if (rtc_include_tests) {
"../../rtc_base:rtc_stats_counters",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:safe_minmax",
"../../rtc_base:socket_address",
"../../rtc_base:task_queue_for_test",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/task_utils:repeating_task",

Просмотреть файл

@ -35,6 +35,7 @@ rtc_library("time_controller") {
"../../modules/utility:utility",
"../../rtc_base",
"../../rtc_base:checks",
"../../rtc_base:null_socket_server",
"../../rtc_base:rtc_base_tests_utils",
"../../rtc_base:rtc_event",
"../../rtc_base/synchronization:mutex",
@ -62,6 +63,7 @@ if (rtc_include_tests) {
"../../rtc_base",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:threading",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/task_utils:repeating_task",
"../../rtc_base/task_utils:to_queued_task",

2
third_party/libwebrtc/video/BUILD.gn поставляемый
Просмотреть файл

@ -120,6 +120,7 @@ rtc_library("video") {
"../rtc_base:rtc_numerics",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base:weak_ptr",
"../rtc_base/experiments:alr_experiment",
"../rtc_base/experiments:field_trial_parser",
@ -668,6 +669,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_numerics",
"../rtc_base:rtc_task_queue",
"../rtc_base:task_queue_for_test",
"../rtc_base:threading",
"../rtc_base/experiments:alr_experiment",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",