summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/api
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/api')
-rw-r--r--third_party/libwebrtc/api/BUILD.gn25
-rw-r--r--third_party/libwebrtc/api/audio_codecs/BUILD.gn1
-rw-r--r--third_party/libwebrtc/api/audio_codecs/audio_encoder.h15
-rw-r--r--third_party/libwebrtc/api/candidate.cc32
-rw-r--r--third_party/libwebrtc/api/candidate.h22
-rw-r--r--third_party/libwebrtc/api/candidate_unittest.cc56
-rw-r--r--third_party/libwebrtc/api/crypto_params.h43
-rw-r--r--third_party/libwebrtc/api/frame_transformer_interface.h6
-rw-r--r--third_party/libwebrtc/api/neteq/neteq.cc3
-rw-r--r--third_party/libwebrtc/api/neteq/neteq.h31
-rw-r--r--third_party/libwebrtc/api/peer_connection_interface.h17
-rw-r--r--third_party/libwebrtc/api/rtc_event_log_output_file_unittest.cc3
-rw-r--r--third_party/libwebrtc/api/stats/attribute.h54
-rw-r--r--third_party/libwebrtc/api/stats/rtc_stats.h16
-rw-r--r--third_party/libwebrtc/api/stats/rtc_stats_member.h185
-rw-r--r--third_party/libwebrtc/api/stats/rtcstats_objects.h417
-rw-r--r--third_party/libwebrtc/api/test/mock_frame_transformer.h45
-rw-r--r--third_party/libwebrtc/api/test/mock_peerconnectioninterface.h4
-rw-r--r--third_party/libwebrtc/api/test/mock_video_decoder_factory.h13
-rw-r--r--third_party/libwebrtc/api/test/pclf/BUILD.gn2
-rw-r--r--third_party/libwebrtc/api/test/video/BUILD.gn1
-rw-r--r--third_party/libwebrtc/api/test/video/function_video_decoder_factory.h19
-rw-r--r--third_party/libwebrtc/api/transport/BUILD.gn6
-rw-r--r--third_party/libwebrtc/api/transport/bandwidth_estimation_settings.h27
-rw-r--r--third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build198
-rw-r--r--third_party/libwebrtc/api/video_codecs/BUILD.gn5
-rw-r--r--third_party/libwebrtc/api/video_codecs/av1_profile.cc6
-rw-r--r--third_party/libwebrtc/api/video_codecs/av1_profile.h3
-rw-r--r--third_party/libwebrtc/api/video_codecs/sdp_video_format.cc42
-rw-r--r--third_party/libwebrtc/api/video_codecs/test/BUILD.gn3
-rw-r--r--third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc15
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codec.cc30
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codec.h4
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build1
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc45
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory.h31
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h2
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc23
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h8
-rw-r--r--third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc18
40 files changed, 899 insertions, 578 deletions
diff --git a/third_party/libwebrtc/api/BUILD.gn b/third_party/libwebrtc/api/BUILD.gn
index 1628660c3c..4549c02b7a 100644
--- a/third_party/libwebrtc/api/BUILD.gn
+++ b/third_party/libwebrtc/api/BUILD.gn
@@ -301,7 +301,6 @@ if (!build_with_mozilla) {
visibility = [ "*" ]
cflags = []
sources = [
- "crypto_params.h",
"data_channel_interface.cc",
"data_channel_interface.h",
"jsep.cc",
@@ -361,6 +360,8 @@ if (!build_with_mozilla) {
":sequence_checker",
":turn_customizer",
"../call:rtp_interfaces",
+ "../p2p:connection",
+ "../p2p:port_allocator",
"../p2p:rtc_p2p",
"../pc:media_factory",
"../rtc_base:copy_on_write_buffer",
@@ -380,6 +381,7 @@ if (!build_with_mozilla) {
"neteq:neteq_api",
"rtc_event_log",
"task_queue",
+ "transport:bandwidth_estimation_settings",
"transport:bitrate_settings",
"transport:enums",
"transport:network_control",
@@ -806,7 +808,6 @@ rtc_source_set("rtc_stats_api") {
"stats/attribute.h",
"stats/rtc_stats.h",
"stats/rtc_stats_collector_callback.h",
- "stats/rtc_stats_member.h",
"stats/rtc_stats_report.h",
"stats/rtcstats_objects.h",
]
@@ -969,6 +970,11 @@ rtc_library("ice_transport_factory") {
":make_ref_counted",
":packet_socket_factory",
":scoped_refptr",
+ "../p2p:connection",
+ "../p2p:ice_transport_internal",
+ "../p2p:p2p_constants",
+ "../p2p:p2p_transport_channel",
+ "../p2p:port_allocator",
"../p2p:rtc_p2p",
"../rtc_base:threading",
"../rtc_base/system:rtc_export",
@@ -1181,6 +1187,16 @@ if (rtc_include_tests) {
]
}
+ rtc_library("mock_frame_transformer") {
+ visibility = [ "*" ]
+ testonly = true
+ sources = [ "test/mock_frame_transformer.h" ]
+ deps = [
+ ":frame_transformer_interface",
+ "../test:test_support",
+ ]
+ }
+
rtc_library("mock_encoder_selector") {
visibility = [ "*" ]
testonly = true
@@ -1379,6 +1395,7 @@ if (rtc_include_tests) {
deps = [
"../api/video_codecs:video_codecs_api",
"../test:test_support",
+ "environment",
]
}
@@ -1447,6 +1464,7 @@ if (rtc_include_tests) {
sources = [
"array_view_unittest.cc",
+ "candidate_unittest.cc",
"field_trials_unittest.cc",
"function_view_unittest.cc",
"rtc_error_unittest.cc",
@@ -1462,6 +1480,7 @@ if (rtc_include_tests) {
deps = [
":array_view",
+ ":candidate",
":create_time_controller",
":field_trials",
":field_trials_view",
@@ -1475,12 +1494,14 @@ if (rtc_include_tests) {
":scoped_refptr",
":sequence_checker",
":time_controller",
+ "../p2p:rtc_p2p",
"../rtc_base:buffer",
"../rtc_base:checks",
"../rtc_base:gunit_helpers",
"../rtc_base:platform_thread",
"../rtc_base:rtc_event",
"../rtc_base:rtc_task_queue",
+ "../rtc_base:ssl",
"../rtc_base:task_queue_for_test",
"../rtc_base/containers:flat_set",
"../rtc_base/task_utils:repeating_task",
diff --git a/third_party/libwebrtc/api/audio_codecs/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/BUILD.gn
index 2719942488..fc02b2d834 100644
--- a/third_party/libwebrtc/api/audio_codecs/BUILD.gn
+++ b/third_party/libwebrtc/api/audio_codecs/BUILD.gn
@@ -42,6 +42,7 @@ rtc_library("audio_codecs_api") {
"../../rtc_base:refcount",
"../../rtc_base:sanitizer",
"../../rtc_base/system:rtc_export",
+ "../units:data_rate",
"../units:time_delta",
]
absl_deps = [
diff --git a/third_party/libwebrtc/api/audio_codecs/audio_encoder.h b/third_party/libwebrtc/api/audio_codecs/audio_encoder.h
index 7f5a34214f..7b5ee7a866 100644
--- a/third_party/libwebrtc/api/audio_codecs/audio_encoder.h
+++ b/third_party/libwebrtc/api/audio_codecs/audio_encoder.h
@@ -20,6 +20,7 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/call/bitrate_allocation.h"
+#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
#include "rtc_base/buffer.h"
@@ -240,12 +241,20 @@ class AudioEncoder {
// Get statistics related to audio network adaptation.
virtual ANAStats GetANAStats() const;
- // The range of frame lengths that are supported or nullopt if there's no sch
- // information. This is used to calculated the full bitrate range, including
- // overhead.
+ // The range of frame lengths that are supported or nullopt if there's no such
+ // information. This is used together with the bitrate range to calculate the
+ // full bitrate range, including overhead.
virtual absl::optional<std::pair<TimeDelta, TimeDelta>> GetFrameLengthRange()
const = 0;
+ // The range of payload bitrates that are supported. This is used together
+ // with the frame length range to calculate the full bitrate range, including
+ // overhead.
+ virtual absl::optional<std::pair<DataRate, DataRate>> GetBitrateRange()
+ const {
+ return absl::nullopt;
+ }
+
// The maximum number of audio channels supported by WebRTC encoders.
static constexpr int kMaxNumberOfChannels = 24;
diff --git a/third_party/libwebrtc/api/candidate.cc b/third_party/libwebrtc/api/candidate.cc
index 865f8e5787..7718f94076 100644
--- a/third_party/libwebrtc/api/candidate.cc
+++ b/third_party/libwebrtc/api/candidate.cc
@@ -10,6 +10,7 @@
#include "api/candidate.h"
+#include "absl/base/attributes.h"
#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
@@ -17,15 +18,16 @@
namespace cricket {
-const char LOCAL_PORT_TYPE[] = "local";
-const char STUN_PORT_TYPE[] = "stun";
-const char PRFLX_PORT_TYPE[] = "prflx";
-const char RELAY_PORT_TYPE[] = "relay";
+ABSL_CONST_INIT const absl::string_view LOCAL_PORT_TYPE = "local";
+ABSL_CONST_INIT const absl::string_view STUN_PORT_TYPE = "stun";
+ABSL_CONST_INIT const absl::string_view PRFLX_PORT_TYPE = "prflx";
+ABSL_CONST_INIT const absl::string_view RELAY_PORT_TYPE = "relay";
Candidate::Candidate()
: id_(rtc::CreateRandomString(8)),
component_(0),
priority_(0),
+ type_(LOCAL_PORT_TYPE),
network_type_(rtc::ADAPTER_TYPE_UNKNOWN),
underlying_type_for_vpn_(rtc::ADAPTER_TYPE_UNKNOWN),
generation_(0),
@@ -62,6 +64,10 @@ Candidate::Candidate(const Candidate&) = default;
Candidate::~Candidate() = default;
+void Candidate::generate_id() {
+ id_ = rtc::CreateRandomString(8);
+}
+
bool Candidate::is_local() const {
return type_ == LOCAL_PORT_TYPE;
}
@@ -75,6 +81,17 @@ bool Candidate::is_relay() const {
return type_ == RELAY_PORT_TYPE;
}
+absl::string_view Candidate::type_name() const {
+ // The LOCAL_PORT_TYPE and STUN_PORT_TYPE constants are not the standard type
+ // names, so check for those specifically. For other types, `type_` will have
+ // the correct name.
+ if (is_local())
+ return "host";
+ if (is_stun())
+ return "srflx";
+ return type_;
+}
+
bool Candidate::IsEquivalent(const Candidate& c) const {
// We ignore the network name, since that is just debug information, and
// the priority and the network cost, since they should be the same if the
@@ -99,9 +116,10 @@ std::string Candidate::ToStringInternal(bool sensitive) const {
std::string related_address = sensitive ? related_address_.ToSensitiveString()
: related_address_.ToString();
ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_
- << ":" << protocol_ << ":" << priority_ << ":" << address << ":" << type_
- << ":" << related_address << ":" << username_ << ":" << password_ << ":"
- << network_id_ << ":" << network_cost_ << ":" << generation_ << "]";
+ << ":" << protocol_ << ":" << priority_ << ":" << address << ":"
+ << type_name() << ":" << related_address << ":" << username_ << ":"
+ << password_ << ":" << network_id_ << ":" << network_cost_ << ":"
+ << generation_ << "]";
return ost.Release();
}
diff --git a/third_party/libwebrtc/api/candidate.h b/third_party/libwebrtc/api/candidate.h
index d48f4fc559..0aa75aa192 100644
--- a/third_party/libwebrtc/api/candidate.h
+++ b/third_party/libwebrtc/api/candidate.h
@@ -24,14 +24,18 @@
#include "rtc_base/socket_address.h"
#include "rtc_base/system/rtc_export.h"
+namespace webrtc {
+enum class IceCandidateType : int { kHost, kSrflx, kPrflx, kRelay };
+} // namespace webrtc
+
namespace cricket {
// TODO(tommi): These are temporarily here, moved from `port.h` and will
// eventually be removed once we use enums instead of strings for these values.
-RTC_EXPORT extern const char LOCAL_PORT_TYPE[];
-RTC_EXPORT extern const char STUN_PORT_TYPE[];
-RTC_EXPORT extern const char PRFLX_PORT_TYPE[];
-RTC_EXPORT extern const char RELAY_PORT_TYPE[];
+RTC_EXPORT extern const absl::string_view LOCAL_PORT_TYPE;
+RTC_EXPORT extern const absl::string_view STUN_PORT_TYPE;
+RTC_EXPORT extern const absl::string_view PRFLX_PORT_TYPE;
+RTC_EXPORT extern const absl::string_view RELAY_PORT_TYPE;
// TURN servers are limited to 32 in accordance with
// https://w3c.github.io/webrtc-pc/#dom-rtcconfiguration-iceservers
@@ -59,8 +63,12 @@ class RTC_EXPORT Candidate {
Candidate(const Candidate&);
~Candidate();
+ // 8 character long randomized ID string for logging purposes.
const std::string& id() const { return id_; }
- void set_id(absl::string_view id) { Assign(id_, id); }
+ // Generates a new, 8 character long, id.
+ void generate_id();
+ // TODO(tommi): Callers should use generate_id(). Remove.
+ [[deprecated]] void set_id(absl::string_view id) { Assign(id_, id); }
int component() const { return component_; }
void set_component(int component) { component_ = component; }
@@ -89,6 +97,10 @@ class RTC_EXPORT Candidate {
const std::string& type() const { return type_; }
+ // Returns the name of the candidate type as specified in
+ // https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
+ absl::string_view type_name() const;
+
// Setting the type requires a constant string (e.g.
// cricket::LOCAL_PORT_TYPE). The type should really be an enum rather than a
// string, but until we make that change the lifetime attribute helps us lock
diff --git a/third_party/libwebrtc/api/candidate_unittest.cc b/third_party/libwebrtc/api/candidate_unittest.cc
new file mode 100644
index 0000000000..e52d448e72
--- /dev/null
+++ b/third_party/libwebrtc/api/candidate_unittest.cc
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2024 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 "api/candidate.h"
+
+#include <string>
+
+#include "p2p/base/p2p_constants.h"
+#include "rtc_base/gunit.h"
+
+namespace cricket {
+
+TEST(CandidateTest, Id) {
+ Candidate c;
+ EXPECT_EQ(c.id().size(), 8u);
+ std::string current_id = c.id();
+ // Generate a new ID.
+ c.generate_id();
+ EXPECT_EQ(c.id().size(), 8u);
+ EXPECT_NE(current_id, c.id());
+}
+
+TEST(CandidateTest, Component) {
+ Candidate c;
+ EXPECT_EQ(c.component(), 0);
+ c.set_component(ICE_CANDIDATE_COMPONENT_DEFAULT);
+ EXPECT_EQ(c.component(), ICE_CANDIDATE_COMPONENT_DEFAULT);
+}
+
+TEST(CandidateTest, TypeName) {
+ Candidate c;
+ // The `type_name()` property defaults to "host".
+ EXPECT_EQ(c.type_name(), "host");
+ EXPECT_EQ(c.type(), LOCAL_PORT_TYPE);
+
+ c.set_type(STUN_PORT_TYPE);
+ EXPECT_EQ(c.type_name(), "srflx");
+ EXPECT_EQ(c.type(), STUN_PORT_TYPE);
+
+ c.set_type(PRFLX_PORT_TYPE);
+ EXPECT_EQ(c.type_name(), "prflx");
+ EXPECT_EQ(c.type(), PRFLX_PORT_TYPE);
+
+ c.set_type(RELAY_PORT_TYPE);
+ EXPECT_EQ(c.type_name(), "relay");
+ EXPECT_EQ(c.type(), RELAY_PORT_TYPE);
+}
+
+} // namespace cricket
diff --git a/third_party/libwebrtc/api/crypto_params.h b/third_party/libwebrtc/api/crypto_params.h
deleted file mode 100644
index 34906ea0ef..0000000000
--- a/third_party/libwebrtc/api/crypto_params.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2004 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 API_CRYPTO_PARAMS_H_
-#define API_CRYPTO_PARAMS_H_
-
-#include <string>
-
-#include "absl/strings/string_view.h"
-
-namespace cricket {
-
-// Parameters for SRTP negotiation, as described in RFC 4568.
-// TODO(benwright) - Rename to SrtpCryptoParams as these only apply to SRTP and
-// not generic crypto parameters for WebRTC.
-struct CryptoParams {
- CryptoParams() : tag(0) {}
- CryptoParams(int t,
- absl::string_view cs,
- absl::string_view kp,
- absl::string_view sp)
- : tag(t), crypto_suite(cs), key_params(kp), session_params(sp) {}
-
- bool Matches(const CryptoParams& params) const {
- return (tag == params.tag && crypto_suite == params.crypto_suite);
- }
-
- int tag;
- std::string crypto_suite;
- std::string key_params;
- std::string session_params;
-};
-
-} // namespace cricket
-
-#endif // API_CRYPTO_PARAMS_H_
diff --git a/third_party/libwebrtc/api/frame_transformer_interface.h b/third_party/libwebrtc/api/frame_transformer_interface.h
index afa79b92ea..4869ad6909 100644
--- a/third_party/libwebrtc/api/frame_transformer_interface.h
+++ b/third_party/libwebrtc/api/frame_transformer_interface.h
@@ -74,11 +74,7 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface {
virtual rtc::ArrayView<const uint32_t> GetContributingSources() const = 0;
- // TODO(crbug.com/1453226): Change this to pure virtual after it
- // is implemented everywhere.
- virtual const absl::optional<uint16_t> SequenceNumber() const {
- return absl::nullopt;
- }
+ virtual const absl::optional<uint16_t> SequenceNumber() const = 0;
virtual absl::optional<uint64_t> AbsoluteCaptureTimestamp() const = 0;
diff --git a/third_party/libwebrtc/api/neteq/neteq.cc b/third_party/libwebrtc/api/neteq/neteq.cc
index 155ddf2cf3..d237def23a 100644
--- a/third_party/libwebrtc/api/neteq/neteq.cc
+++ b/third_party/libwebrtc/api/neteq/neteq.cc
@@ -24,8 +24,7 @@ NetEq::Config& NetEq::Config::operator=(Config&&) = default;
std::string NetEq::Config::ToString() const {
char buf[1024];
rtc::SimpleStringBuilder ss(buf);
- ss << "sample_rate_hz=" << sample_rate_hz << ", enable_post_decode_vad="
- << (enable_post_decode_vad ? "true" : "false")
+ ss << "sample_rate_hz=" << sample_rate_hz
<< ", max_packets_in_buffer=" << max_packets_in_buffer
<< ", min_delay_ms=" << min_delay_ms << ", enable_fast_accelerate="
<< (enable_fast_accelerate ? "true" : "false")
diff --git a/third_party/libwebrtc/api/neteq/neteq.h b/third_party/libwebrtc/api/neteq/neteq.h
index 43e0e09784..3dfe662741 100644
--- a/third_party/libwebrtc/api/neteq/neteq.h
+++ b/third_party/libwebrtc/api/neteq/neteq.h
@@ -130,7 +130,6 @@ class NetEq {
std::string ToString() const;
int sample_rate_hz = 48000; // Initial value. Will change with input data.
- bool enable_post_decode_vad = false;
size_t max_packets_in_buffer = 200;
int max_delay_ms = 0;
int min_delay_ms = 0;
@@ -197,18 +196,17 @@ class NetEq {
// Instructs NetEq to deliver 10 ms of audio data. The data is written to
// `audio_frame`. All data in `audio_frame` is wiped; `data_`, `speech_type_`,
- // `num_channels_`, `sample_rate_hz_`, `samples_per_channel_`, and
- // `vad_activity_` are updated upon success. If an error is returned, some
- // fields may not have been updated, or may contain inconsistent values.
- // If muted state is enabled (through Config::enable_muted_state), `muted`
- // may be set to true after a prolonged expand period. When this happens, the
- // `data_` in `audio_frame` is not written, but should be interpreted as being
- // all zeros. For testing purposes, an override can be supplied in the
- // `action_override` argument, which will cause NetEq to take this action
- // next, instead of the action it would normally choose. An optional output
- // argument for fetching the current sample rate can be provided, which
- // will return the same value as last_output_sample_rate_hz() but will avoid
- // additional synchronization.
+ // `num_channels_`, `sample_rate_hz_` and `samples_per_channel_` are updated
+ // upon success. If an error is returned, some fields may not have been
+ // updated, or may contain inconsistent values. If muted state is enabled
+ // (through Config::enable_muted_state), `muted` may be set to true after a
+ // prolonged expand period. When this happens, the `data_` in `audio_frame`
+ // is not written, but should be interpreted as being all zeros. For testing
+ // purposes, an override can be supplied in the `action_override` argument,
+ // which will cause NetEq to take this action next, instead of the action it
+ // would normally choose. An optional output argument for fetching the current
+ // sample rate can be provided, which will return the same value as
+ // last_output_sample_rate_hz() but will avoid additional synchronization.
// Returns kOK on success, or kFail in case of an error.
virtual int GetAudio(
AudioFrame* audio_frame,
@@ -278,13 +276,6 @@ class NetEq {
// statistics are never reset.
virtual NetEqOperationsAndState GetOperationsAndState() const = 0;
- // Enables post-decode VAD. When enabled, GetAudio() will return
- // kOutputVADPassive when the signal contains no speech.
- virtual void EnableVad() = 0;
-
- // Disables post-decode VAD.
- virtual void DisableVad() = 0;
-
// Returns the RTP timestamp for the last sample delivered by GetAudio().
// The return value will be empty if no valid timestamp is available.
virtual absl::optional<uint32_t> GetPlayoutTimestamp() const = 0;
diff --git a/third_party/libwebrtc/api/peer_connection_interface.h b/third_party/libwebrtc/api/peer_connection_interface.h
index 3c225eb28a..38699ec98a 100644
--- a/third_party/libwebrtc/api/peer_connection_interface.h
+++ b/third_party/libwebrtc/api/peer_connection_interface.h
@@ -112,6 +112,7 @@
#include "api/set_remote_description_observer_interface.h"
#include "api/stats/rtc_stats_collector_callback.h"
#include "api/task_queue/task_queue_factory.h"
+#include "api/transport/bandwidth_estimation_settings.h"
#include "api/transport/bitrate_settings.h"
#include "api/transport/enums.h"
#include "api/transport/network_control.h"
@@ -451,15 +452,6 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// when switching from a static scene to one with motion.
absl::optional<int> screencast_min_bitrate;
-#if defined(WEBRTC_FUCHSIA)
- // TODO(bugs.webrtc.org/11066): Remove entirely once Fuchsia does not use.
- // TODO(bugs.webrtc.org/9891) - Move to crypto_options
- // Can be used to disable DTLS-SRTP. This should never be done, but can be
- // useful for testing purposes, for example in setting up a loopback call
- // with a single PeerConnection.
- absl::optional<bool> enable_dtls_srtp;
-#endif
-
/////////////////////////////////////////////////
// The below fields are not part of the standard.
/////////////////////////////////////////////////
@@ -1142,6 +1134,13 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface {
// to the provided value.
virtual RTCError SetBitrate(const BitrateSettings& bitrate) = 0;
+ // Allows an application to reconfigure bandwidth estimation.
+ // The method can be called both before and after estimation has started.
+ // Estimation starts when the first RTP packet is sent.
+ // Estimation will be restarted if already started.
+ virtual void ReconfigureBandwidthEstimation(
+ const BandwidthEstimationSettings& settings) {}
+
// Enable/disable playout of received audio streams. Enabled by default. Note
// that even if playout is enabled, streams will only be played out if the
// appropriate SDP is also applied. Setting `playout` to false will stop
diff --git a/third_party/libwebrtc/api/rtc_event_log_output_file_unittest.cc b/third_party/libwebrtc/api/rtc_event_log_output_file_unittest.cc
index 0aff57fbbc..d2f1e1c6b5 100644
--- a/third_party/libwebrtc/api/rtc_event_log_output_file_unittest.cc
+++ b/third_party/libwebrtc/api/rtc_event_log_output_file_unittest.cc
@@ -34,7 +34,8 @@ class RtcEventLogOutputFileTest : public ::testing::Test {
protected:
std::string GetOutputFilePath() const {
auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
- return test::OutputPath() + test_info->test_case_name() + test_info->name();
+ return test::OutputPathWithRandomDirectory() + test_info->test_case_name() +
+ test_info->name();
}
std::string GetOutputFileContents() const {
diff --git a/third_party/libwebrtc/api/stats/attribute.h b/third_party/libwebrtc/api/stats/attribute.h
index 09211f469c..36500db999 100644
--- a/third_party/libwebrtc/api/stats/attribute.h
+++ b/third_party/libwebrtc/api/stats/attribute.h
@@ -16,37 +16,38 @@
#include <string>
#include <vector>
+#include "absl/types/optional.h"
#include "absl/types/variant.h"
-#include "api/stats/rtc_stats_member.h"
+#include "rtc_base/checks.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
-// A light-weight wrapper of an RTCStats attribute (an individual metric).
+// A light-weight wrapper of an RTCStats attribute, i.e. an individual metric of
+// type absl::optional<T>.
class RTC_EXPORT Attribute {
public:
- // TODO(https://crbug.com/webrtc/15164): Replace uses of RTCStatsMember<T>
- // with absl::optional<T> and update these pointer types.
- typedef absl::variant<const RTCStatsMember<bool>*,
- const RTCStatsMember<int32_t>*,
- const RTCStatsMember<uint32_t>*,
- const RTCStatsMember<int64_t>*,
- const RTCStatsMember<uint64_t>*,
- const RTCStatsMember<double>*,
- const RTCStatsMember<std::string>*,
- const RTCStatsMember<std::vector<bool>>*,
- const RTCStatsMember<std::vector<int32_t>>*,
- const RTCStatsMember<std::vector<uint32_t>>*,
- const RTCStatsMember<std::vector<int64_t>>*,
- const RTCStatsMember<std::vector<uint64_t>>*,
- const RTCStatsMember<std::vector<double>>*,
- const RTCStatsMember<std::vector<std::string>>*,
- const RTCStatsMember<std::map<std::string, uint64_t>>*,
- const RTCStatsMember<std::map<std::string, double>>*>
+ // All supported attribute types.
+ typedef absl::variant<const absl::optional<bool>*,
+ const absl::optional<int32_t>*,
+ const absl::optional<uint32_t>*,
+ const absl::optional<int64_t>*,
+ const absl::optional<uint64_t>*,
+ const absl::optional<double>*,
+ const absl::optional<std::string>*,
+ const absl::optional<std::vector<bool>>*,
+ const absl::optional<std::vector<int32_t>>*,
+ const absl::optional<std::vector<uint32_t>>*,
+ const absl::optional<std::vector<int64_t>>*,
+ const absl::optional<std::vector<uint64_t>>*,
+ const absl::optional<std::vector<double>>*,
+ const absl::optional<std::vector<std::string>>*,
+ const absl::optional<std::map<std::string, uint64_t>>*,
+ const absl::optional<std::map<std::string, double>>*>
StatVariant;
template <typename T>
- explicit Attribute(const char* name, const RTCStatsMember<T>* attribute)
+ Attribute(const char* name, const absl::optional<T>* attribute)
: name_(name), attribute_(attribute) {}
const char* name() const;
@@ -55,21 +56,18 @@ class RTC_EXPORT Attribute {
bool has_value() const;
template <typename T>
bool holds_alternative() const {
- return absl::holds_alternative<const RTCStatsMember<T>*>(attribute_);
+ return absl::holds_alternative<const absl::optional<T>*>(attribute_);
}
template <typename T>
- absl::optional<T> as_optional() const {
+ const absl::optional<T>& as_optional() const {
RTC_CHECK(holds_alternative<T>());
- if (!has_value()) {
- return absl::nullopt;
- }
- return absl::optional<T>(get<T>());
+ return *absl::get<const absl::optional<T>*>(attribute_);
}
template <typename T>
const T& get() const {
RTC_CHECK(holds_alternative<T>());
RTC_CHECK(has_value());
- return absl::get<const RTCStatsMember<T>*>(attribute_)->value();
+ return absl::get<const absl::optional<T>*>(attribute_)->value();
}
bool is_sequence() const;
diff --git a/third_party/libwebrtc/api/stats/rtc_stats.h b/third_party/libwebrtc/api/stats/rtc_stats.h
index edd293f5c9..74e7fc4d8e 100644
--- a/third_party/libwebrtc/api/stats/rtc_stats.h
+++ b/third_party/libwebrtc/api/stats/rtc_stats.h
@@ -20,8 +20,8 @@
#include <utility>
#include <vector>
+#include "absl/types/optional.h"
#include "api/stats/attribute.h"
-#include "api/stats/rtc_stats_member.h"
#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
#include "rtc_base/system/rtc_export.h"
@@ -39,8 +39,8 @@ namespace webrtc {
// Use the `WEBRTC_RTCSTATS_IMPL` macro when implementing subclasses, see macro
// for details.
//
-// Derived classes list their dictionary attributes (RTCStatsMember<T> to soon
-// be replaced by absl::optional<T>) as public fields, allowing the following:
+// Derived classes list their dictionary attributes, absl::optional<T>, as
+// public fields, allowing the following:
//
// RTCFooStats foo("fooId", Timestamp::Micros(GetCurrentTime()));
// foo.bar = 42;
@@ -52,7 +52,7 @@ namespace webrtc {
// iteration:
//
// for (const auto& attribute : foo.Attributes()) {
-// printf("%s = %s\n", attribute.name(), attribute.ValueToString().c_str());
+// printf("%s = %s\n", attribute.name(), attribute.ToString().c_str());
// }
class RTC_EXPORT RTCStats {
public:
@@ -73,12 +73,12 @@ class RTC_EXPORT RTCStats {
// metrics as viewed via the Attribute wrapper.
std::vector<Attribute> Attributes() const;
template <typename T>
- Attribute GetAttribute(const RTCStatsMember<T>& stat) const {
+ Attribute GetAttribute(const absl::optional<T>& stat) const {
for (const auto& attribute : Attributes()) {
if (!attribute.holds_alternative<T>()) {
continue;
}
- if (absl::get<const RTCStatsMember<T>*>(attribute.as_variant()) ==
+ if (absl::get<const absl::optional<T>*>(attribute.as_variant()) ==
&stat) {
return attribute;
}
@@ -136,8 +136,8 @@ class RTC_EXPORT RTCStats {
//
// RTCFooStats(const std::string& id, Timestamp timestamp);
//
-// RTCStatsMember<int32_t> foo;
-// RTCStatsMember<int32_t> bar;
+// absl::optional<int32_t> foo;
+// absl::optional<int32_t> bar;
// };
//
// rtcfoostats.cc:
diff --git a/third_party/libwebrtc/api/stats/rtc_stats_member.h b/third_party/libwebrtc/api/stats/rtc_stats_member.h
deleted file mode 100644
index 9039569ede..0000000000
--- a/third_party/libwebrtc/api/stats/rtc_stats_member.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef API_STATS_RTC_STATS_MEMBER_H_
-#define API_STATS_RTC_STATS_MEMBER_H_
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "absl/types/optional.h"
-#include "rtc_base/checks.h"
-#include "rtc_base/system/rtc_export.h"
-#include "rtc_base/system/rtc_export_template.h"
-
-namespace webrtc {
-
-// Interface for `RTCStats` members, which have a name and a value of a type
-// defined in a subclass. Only the types listed in `Type` are supported, these
-// are implemented by `RTCStatsMember<T>`. The value of a member may be
-// undefined, the value can only be read if `is_defined`.
-class RTCStatsMemberInterface {
- public:
- // Member value types.
- enum Type {
- kBool, // bool
- kInt32, // int32_t
- kUint32, // uint32_t
- kInt64, // int64_t
- kUint64, // uint64_t
- kDouble, // double
- kString, // std::string
-
- kSequenceBool, // std::vector<bool>
- kSequenceInt32, // std::vector<int32_t>
- kSequenceUint32, // std::vector<uint32_t>
- kSequenceInt64, // std::vector<int64_t>
- kSequenceUint64, // std::vector<uint64_t>
- kSequenceDouble, // std::vector<double>
- kSequenceString, // std::vector<std::string>
-
- kMapStringUint64, // std::map<std::string, uint64_t>
- kMapStringDouble, // std::map<std::string, double>
- };
-
- virtual ~RTCStatsMemberInterface() {}
-
- virtual Type type() const = 0;
- virtual bool is_sequence() const = 0;
- virtual bool is_string() const = 0;
- virtual bool has_value() const = 0;
- // Type and value comparator. The names are not compared. These operators are
- // exposed for testing.
- bool operator==(const RTCStatsMemberInterface& other) const {
- return IsEqual(other);
- }
- bool operator!=(const RTCStatsMemberInterface& other) const {
- return !(*this == other);
- }
-
- virtual const RTCStatsMemberInterface* member_ptr() const { return this; }
- template <typename T>
- const T& cast_to() const {
- RTC_DCHECK_EQ(type(), T::StaticType());
- return static_cast<const T&>(*member_ptr());
- }
-
- protected:
- virtual bool IsEqual(const RTCStatsMemberInterface& other) const = 0;
-};
-
-// Template implementation of `RTCStatsMemberInterface`.
-// The supported types are the ones described by
-// `RTCStatsMemberInterface::Type`.
-template <typename T>
-class RTCStatsMember : public RTCStatsMemberInterface {
- public:
- RTCStatsMember() {}
- explicit RTCStatsMember(const T& value) : value_(value) {}
-
- static Type StaticType();
- Type type() const override { return StaticType(); }
- bool is_sequence() const override;
- bool is_string() const override;
-
- template <typename U>
- inline T value_or(U default_value) const {
- return value_.value_or(default_value);
- }
- // TODO(https://crbug.com/webrtc/15164): Migrate to value_or() and delete.
- template <typename U>
- inline T ValueOrDefault(U default_value) const {
- return value_or(default_value);
- }
-
- // Assignment operators.
- T& operator=(const T& value) {
- value_ = value;
- return value_.value();
- }
- T& operator=(const T&& value) {
- value_ = std::move(value);
- return value_.value();
- }
-
- // Getter methods that look the same as absl::optional<T>. Please prefer these
- // in order to unblock replacing RTCStatsMember<T> with absl::optional<T> in
- // the future (https://crbug.com/webrtc/15164).
- bool has_value() const override { return value_.has_value(); }
- const T& value() const { return value_.value(); }
- T& value() { return value_.value(); }
- T& operator*() {
- RTC_DCHECK(value_);
- return *value_;
- }
- const T& operator*() const {
- RTC_DCHECK(value_);
- return *value_;
- }
- T* operator->() {
- RTC_DCHECK(value_);
- return &(*value_);
- }
- const T* operator->() const {
- RTC_DCHECK(value_);
- return &(*value_);
- }
-
- bool IsEqual(const RTCStatsMemberInterface& other) const override {
- if (type() != other.type())
- return false;
- const RTCStatsMember<T>& other_t =
- static_cast<const RTCStatsMember<T>&>(other);
- return value_ == other_t.value_;
- }
-
- private:
- absl::optional<T> value_;
-};
-
-namespace rtc_stats_internal {
-
-typedef std::map<std::string, uint64_t> MapStringUint64;
-typedef std::map<std::string, double> MapStringDouble;
-
-} // namespace rtc_stats_internal
-
-#define WEBRTC_DECLARE_RTCSTATSMEMBER(T) \
- template <> \
- RTC_EXPORT RTCStatsMemberInterface::Type RTCStatsMember<T>::StaticType(); \
- template <> \
- RTC_EXPORT bool RTCStatsMember<T>::is_sequence() const; \
- template <> \
- RTC_EXPORT bool RTCStatsMember<T>::is_string() const; \
- extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) \
- RTCStatsMember<T>
-
-WEBRTC_DECLARE_RTCSTATSMEMBER(bool);
-WEBRTC_DECLARE_RTCSTATSMEMBER(int32_t);
-WEBRTC_DECLARE_RTCSTATSMEMBER(uint32_t);
-WEBRTC_DECLARE_RTCSTATSMEMBER(int64_t);
-WEBRTC_DECLARE_RTCSTATSMEMBER(uint64_t);
-WEBRTC_DECLARE_RTCSTATSMEMBER(double);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::string);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<bool>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<int32_t>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<uint32_t>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<int64_t>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<uint64_t>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<double>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<std::string>);
-WEBRTC_DECLARE_RTCSTATSMEMBER(rtc_stats_internal::MapStringUint64);
-WEBRTC_DECLARE_RTCSTATSMEMBER(rtc_stats_internal::MapStringDouble);
-
-} // namespace webrtc
-
-#endif // API_STATS_RTC_STATS_MEMBER_H_
diff --git a/third_party/libwebrtc/api/stats/rtcstats_objects.h b/third_party/libwebrtc/api/stats/rtcstats_objects.h
index 351c2cbefe..9f51f56cc5 100644
--- a/third_party/libwebrtc/api/stats/rtcstats_objects.h
+++ b/third_party/libwebrtc/api/stats/rtcstats_objects.h
@@ -18,6 +18,7 @@
#include <string>
#include <vector>
+#include "absl/types/optional.h"
#include "api/stats/rtc_stats.h"
#include "rtc_base/system/rtc_export.h"
@@ -30,10 +31,10 @@ class RTC_EXPORT RTCCertificateStats final : public RTCStats {
RTCCertificateStats(std::string id, Timestamp timestamp);
~RTCCertificateStats() override;
- RTCStatsMember<std::string> fingerprint;
- RTCStatsMember<std::string> fingerprint_algorithm;
- RTCStatsMember<std::string> base64_certificate;
- RTCStatsMember<std::string> issuer_certificate_id;
+ absl::optional<std::string> fingerprint;
+ absl::optional<std::string> fingerprint_algorithm;
+ absl::optional<std::string> base64_certificate;
+ absl::optional<std::string> issuer_certificate_id;
};
// https://w3c.github.io/webrtc-stats/#codec-dict*
@@ -43,12 +44,12 @@ class RTC_EXPORT RTCCodecStats final : public RTCStats {
RTCCodecStats(std::string id, Timestamp timestamp);
~RTCCodecStats() override;
- RTCStatsMember<std::string> transport_id;
- RTCStatsMember<uint32_t> payload_type;
- RTCStatsMember<std::string> mime_type;
- RTCStatsMember<uint32_t> clock_rate;
- RTCStatsMember<uint32_t> channels;
- RTCStatsMember<std::string> sdp_fmtp_line;
+ absl::optional<std::string> transport_id;
+ absl::optional<uint32_t> payload_type;
+ absl::optional<std::string> mime_type;
+ absl::optional<uint32_t> clock_rate;
+ absl::optional<uint32_t> channels;
+ absl::optional<std::string> sdp_fmtp_line;
};
// https://w3c.github.io/webrtc-stats/#dcstats-dict*
@@ -58,14 +59,14 @@ class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
RTCDataChannelStats(std::string id, Timestamp timestamp);
~RTCDataChannelStats() override;
- RTCStatsMember<std::string> label;
- RTCStatsMember<std::string> protocol;
- RTCStatsMember<int32_t> data_channel_identifier;
- RTCStatsMember<std::string> state;
- RTCStatsMember<uint32_t> messages_sent;
- RTCStatsMember<uint64_t> bytes_sent;
- RTCStatsMember<uint32_t> messages_received;
- RTCStatsMember<uint64_t> bytes_received;
+ absl::optional<std::string> label;
+ absl::optional<std::string> protocol;
+ absl::optional<int32_t> data_channel_identifier;
+ absl::optional<std::string> state;
+ absl::optional<uint32_t> messages_sent;
+ absl::optional<uint64_t> bytes_sent;
+ absl::optional<uint32_t> messages_received;
+ absl::optional<uint64_t> bytes_received;
};
// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
@@ -75,35 +76,35 @@ class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
RTCIceCandidatePairStats(std::string id, Timestamp timestamp);
~RTCIceCandidatePairStats() override;
- RTCStatsMember<std::string> transport_id;
- RTCStatsMember<std::string> local_candidate_id;
- RTCStatsMember<std::string> remote_candidate_id;
- RTCStatsMember<std::string> state;
+ absl::optional<std::string> transport_id;
+ absl::optional<std::string> local_candidate_id;
+ absl::optional<std::string> remote_candidate_id;
+ absl::optional<std::string> state;
// Obsolete: priority
- RTCStatsMember<uint64_t> priority;
- RTCStatsMember<bool> nominated;
+ absl::optional<uint64_t> priority;
+ absl::optional<bool> nominated;
// `writable` does not exist in the spec and old comments suggest it used to
// exist but was incorrectly implemented.
// TODO(https://crbug.com/webrtc/14171): Standardize and/or modify
// implementation.
- RTCStatsMember<bool> writable;
- RTCStatsMember<uint64_t> packets_sent;
- RTCStatsMember<uint64_t> packets_received;
- RTCStatsMember<uint64_t> bytes_sent;
- RTCStatsMember<uint64_t> bytes_received;
- RTCStatsMember<double> total_round_trip_time;
- RTCStatsMember<double> current_round_trip_time;
- RTCStatsMember<double> available_outgoing_bitrate;
- RTCStatsMember<double> available_incoming_bitrate;
- RTCStatsMember<uint64_t> requests_received;
- RTCStatsMember<uint64_t> requests_sent;
- RTCStatsMember<uint64_t> responses_received;
- RTCStatsMember<uint64_t> responses_sent;
- RTCStatsMember<uint64_t> consent_requests_sent;
- RTCStatsMember<uint64_t> packets_discarded_on_send;
- RTCStatsMember<uint64_t> bytes_discarded_on_send;
- RTCStatsMember<double> last_packet_received_timestamp;
- RTCStatsMember<double> last_packet_sent_timestamp;
+ absl::optional<bool> writable;
+ absl::optional<uint64_t> packets_sent;
+ absl::optional<uint64_t> packets_received;
+ absl::optional<uint64_t> bytes_sent;
+ absl::optional<uint64_t> bytes_received;
+ absl::optional<double> total_round_trip_time;
+ absl::optional<double> current_round_trip_time;
+ absl::optional<double> available_outgoing_bitrate;
+ absl::optional<double> available_incoming_bitrate;
+ absl::optional<uint64_t> requests_received;
+ absl::optional<uint64_t> requests_sent;
+ absl::optional<uint64_t> responses_received;
+ absl::optional<uint64_t> responses_sent;
+ absl::optional<uint64_t> consent_requests_sent;
+ absl::optional<uint64_t> packets_discarded_on_send;
+ absl::optional<uint64_t> bytes_discarded_on_send;
+ absl::optional<double> last_packet_received_timestamp;
+ absl::optional<double> last_packet_sent_timestamp;
};
// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
@@ -112,28 +113,28 @@ class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
WEBRTC_RTCSTATS_DECL();
~RTCIceCandidateStats() override;
- RTCStatsMember<std::string> transport_id;
+ absl::optional<std::string> transport_id;
// Obsolete: is_remote
- RTCStatsMember<bool> is_remote;
- RTCStatsMember<std::string> network_type;
- RTCStatsMember<std::string> ip;
- RTCStatsMember<std::string> address;
- RTCStatsMember<int32_t> port;
- RTCStatsMember<std::string> protocol;
- RTCStatsMember<std::string> relay_protocol;
- RTCStatsMember<std::string> candidate_type;
- RTCStatsMember<int32_t> priority;
- RTCStatsMember<std::string> url;
- RTCStatsMember<std::string> foundation;
- RTCStatsMember<std::string> related_address;
- RTCStatsMember<int32_t> related_port;
- RTCStatsMember<std::string> username_fragment;
- RTCStatsMember<std::string> tcp_type;
+ absl::optional<bool> is_remote;
+ absl::optional<std::string> network_type;
+ absl::optional<std::string> ip;
+ absl::optional<std::string> address;
+ absl::optional<int32_t> port;
+ absl::optional<std::string> protocol;
+ absl::optional<std::string> relay_protocol;
+ absl::optional<std::string> candidate_type;
+ absl::optional<int32_t> priority;
+ absl::optional<std::string> url;
+ absl::optional<std::string> foundation;
+ absl::optional<std::string> related_address;
+ absl::optional<int32_t> related_port;
+ absl::optional<std::string> username_fragment;
+ absl::optional<std::string> tcp_type;
// The following metrics are NOT exposed to JavaScript. We should consider
// standardizing or removing them.
- RTCStatsMember<bool> vpn;
- RTCStatsMember<std::string> network_adapter_type;
+ absl::optional<bool> vpn;
+ absl::optional<std::string> network_adapter_type;
protected:
RTCIceCandidateStats(std::string id, Timestamp timestamp, bool is_remote);
@@ -168,8 +169,8 @@ class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
RTCPeerConnectionStats(std::string id, Timestamp timestamp);
~RTCPeerConnectionStats() override;
- RTCStatsMember<uint32_t> data_channels_opened;
- RTCStatsMember<uint32_t> data_channels_closed;
+ absl::optional<uint32_t> data_channels_opened;
+ absl::optional<uint32_t> data_channels_closed;
};
// https://w3c.github.io/webrtc-stats/#streamstats-dict*
@@ -178,10 +179,10 @@ class RTC_EXPORT RTCRtpStreamStats : public RTCStats {
WEBRTC_RTCSTATS_DECL();
~RTCRtpStreamStats() override;
- RTCStatsMember<uint32_t> ssrc;
- RTCStatsMember<std::string> kind;
- RTCStatsMember<std::string> transport_id;
- RTCStatsMember<std::string> codec_id;
+ absl::optional<uint32_t> ssrc;
+ absl::optional<std::string> kind;
+ absl::optional<std::string> transport_id;
+ absl::optional<std::string> codec_id;
protected:
RTCRtpStreamStats(std::string id, Timestamp timestamp);
@@ -193,8 +194,8 @@ class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRtpStreamStats {
WEBRTC_RTCSTATS_DECL();
~RTCReceivedRtpStreamStats() override;
- RTCStatsMember<double> jitter;
- RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
+ absl::optional<double> jitter;
+ absl::optional<int32_t> packets_lost; // Signed per RFC 3550
protected:
RTCReceivedRtpStreamStats(std::string id, Timestamp timestamp);
@@ -206,8 +207,8 @@ class RTC_EXPORT RTCSentRtpStreamStats : public RTCRtpStreamStats {
WEBRTC_RTCSTATS_DECL();
~RTCSentRtpStreamStats() override;
- RTCStatsMember<uint64_t> packets_sent;
- RTCStatsMember<uint64_t> bytes_sent;
+ absl::optional<uint64_t> packets_sent;
+ absl::optional<uint64_t> bytes_sent;
protected:
RTCSentRtpStreamStats(std::string id, Timestamp timestamp);
@@ -221,51 +222,51 @@ class RTC_EXPORT RTCInboundRtpStreamStats final
RTCInboundRtpStreamStats(std::string id, Timestamp timestamp);
~RTCInboundRtpStreamStats() override;
- RTCStatsMember<std::string> playout_id;
- RTCStatsMember<std::string> track_identifier;
- RTCStatsMember<std::string> mid;
- RTCStatsMember<std::string> remote_id;
- RTCStatsMember<uint32_t> packets_received;
- RTCStatsMember<uint64_t> packets_discarded;
- RTCStatsMember<uint64_t> fec_packets_received;
- RTCStatsMember<uint64_t> fec_bytes_received;
- RTCStatsMember<uint64_t> fec_packets_discarded;
+ absl::optional<std::string> playout_id;
+ absl::optional<std::string> track_identifier;
+ absl::optional<std::string> mid;
+ absl::optional<std::string> remote_id;
+ absl::optional<uint32_t> packets_received;
+ absl::optional<uint64_t> packets_discarded;
+ absl::optional<uint64_t> fec_packets_received;
+ absl::optional<uint64_t> fec_bytes_received;
+ absl::optional<uint64_t> fec_packets_discarded;
// Inbound FEC SSRC. Only present if a mechanism like FlexFEC is negotiated.
- RTCStatsMember<uint32_t> fec_ssrc;
- RTCStatsMember<uint64_t> bytes_received;
- RTCStatsMember<uint64_t> header_bytes_received;
+ absl::optional<uint32_t> fec_ssrc;
+ absl::optional<uint64_t> bytes_received;
+ absl::optional<uint64_t> header_bytes_received;
// Inbound RTX stats. Only defined when RTX is used and it is therefore
// possible to distinguish retransmissions.
- RTCStatsMember<uint64_t> retransmitted_packets_received;
- RTCStatsMember<uint64_t> retransmitted_bytes_received;
- RTCStatsMember<uint32_t> rtx_ssrc;
-
- RTCStatsMember<double> last_packet_received_timestamp;
- RTCStatsMember<double> jitter_buffer_delay;
- RTCStatsMember<double> jitter_buffer_target_delay;
- RTCStatsMember<double> jitter_buffer_minimum_delay;
- RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
- RTCStatsMember<uint64_t> total_samples_received;
- RTCStatsMember<uint64_t> concealed_samples;
- RTCStatsMember<uint64_t> silent_concealed_samples;
- RTCStatsMember<uint64_t> concealment_events;
- RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
- RTCStatsMember<uint64_t> removed_samples_for_acceleration;
- RTCStatsMember<double> audio_level;
- RTCStatsMember<double> total_audio_energy;
- RTCStatsMember<double> total_samples_duration;
+ absl::optional<uint64_t> retransmitted_packets_received;
+ absl::optional<uint64_t> retransmitted_bytes_received;
+ absl::optional<uint32_t> rtx_ssrc;
+
+ absl::optional<double> last_packet_received_timestamp;
+ absl::optional<double> jitter_buffer_delay;
+ absl::optional<double> jitter_buffer_target_delay;
+ absl::optional<double> jitter_buffer_minimum_delay;
+ absl::optional<uint64_t> jitter_buffer_emitted_count;
+ absl::optional<uint64_t> total_samples_received;
+ absl::optional<uint64_t> concealed_samples;
+ absl::optional<uint64_t> silent_concealed_samples;
+ absl::optional<uint64_t> concealment_events;
+ absl::optional<uint64_t> inserted_samples_for_deceleration;
+ absl::optional<uint64_t> removed_samples_for_acceleration;
+ absl::optional<double> audio_level;
+ absl::optional<double> total_audio_energy;
+ absl::optional<double> total_samples_duration;
// Stats below are only implemented or defined for video.
- RTCStatsMember<uint32_t> frames_received;
- RTCStatsMember<uint32_t> frame_width;
- RTCStatsMember<uint32_t> frame_height;
- RTCStatsMember<double> frames_per_second;
- RTCStatsMember<uint32_t> frames_decoded;
- RTCStatsMember<uint32_t> key_frames_decoded;
- RTCStatsMember<uint32_t> frames_dropped;
- RTCStatsMember<double> total_decode_time;
- RTCStatsMember<double> total_processing_delay;
- RTCStatsMember<double> total_assembly_time;
- RTCStatsMember<uint32_t> frames_assembled_from_multiple_packets;
+ absl::optional<uint32_t> frames_received;
+ absl::optional<uint32_t> frame_width;
+ absl::optional<uint32_t> frame_height;
+ absl::optional<double> frames_per_second;
+ absl::optional<uint32_t> frames_decoded;
+ absl::optional<uint32_t> key_frames_decoded;
+ absl::optional<uint32_t> frames_dropped;
+ absl::optional<double> total_decode_time;
+ absl::optional<double> total_processing_delay;
+ absl::optional<double> total_assembly_time;
+ absl::optional<uint32_t> frames_assembled_from_multiple_packets;
// TODO(https://crbug.com/webrtc/15600): Implement framesRendered, which is
// incremented at the same time that totalInterFrameDelay and
// totalSquaredInterFrameDelay is incremented. (Dividing inter-frame delay by
@@ -277,43 +278,43 @@ class RTC_EXPORT RTCInboundRtpStreamStats final
// at delivery to sink, not at actual render time. When we have an actual
// frame rendered callback, move the calculating of these metrics to there in
// order to make them more accurate.
- RTCStatsMember<double> total_inter_frame_delay;
- RTCStatsMember<double> total_squared_inter_frame_delay;
- RTCStatsMember<uint32_t> pause_count;
- RTCStatsMember<double> total_pauses_duration;
- RTCStatsMember<uint32_t> freeze_count;
- RTCStatsMember<double> total_freezes_duration;
+ absl::optional<double> total_inter_frame_delay;
+ absl::optional<double> total_squared_inter_frame_delay;
+ absl::optional<uint32_t> pause_count;
+ absl::optional<double> total_pauses_duration;
+ absl::optional<uint32_t> freeze_count;
+ absl::optional<double> total_freezes_duration;
// https://w3c.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
- RTCStatsMember<std::string> content_type;
+ absl::optional<std::string> content_type;
// Only populated if audio/video sync is enabled.
// TODO(https://crbug.com/webrtc/14177): Expose even if A/V sync is off?
- RTCStatsMember<double> estimated_playout_timestamp;
+ absl::optional<double> estimated_playout_timestamp;
// Only defined for video.
// In JavaScript, this is only exposed if HW exposure is allowed.
- RTCStatsMember<std::string> decoder_implementation;
+ absl::optional<std::string> decoder_implementation;
// FIR and PLI counts are only defined for |kind == "video"|.
- RTCStatsMember<uint32_t> fir_count;
- RTCStatsMember<uint32_t> pli_count;
- RTCStatsMember<uint32_t> nack_count;
- RTCStatsMember<uint64_t> qp_sum;
+ absl::optional<uint32_t> fir_count;
+ absl::optional<uint32_t> pli_count;
+ absl::optional<uint32_t> nack_count;
+ absl::optional<uint64_t> qp_sum;
// This is a remnant of the legacy getStats() API. When the "video-timing"
// header extension is used,
// https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/,
// `googTimingFrameInfo` is exposed with the value of
// TimingFrameInfo::ToString().
// TODO(https://crbug.com/webrtc/14586): Unship or standardize this metric.
- RTCStatsMember<std::string> goog_timing_frame_info;
+ absl::optional<std::string> goog_timing_frame_info;
// In JavaScript, this is only exposed if HW exposure is allowed.
- RTCStatsMember<bool> power_efficient_decoder;
+ absl::optional<bool> power_efficient_decoder;
// The following metrics are NOT exposed to JavaScript. We should consider
// standardizing or removing them.
- RTCStatsMember<uint64_t> jitter_buffer_flushes;
- RTCStatsMember<uint64_t> delayed_packet_outage_samples;
- RTCStatsMember<double> relative_packet_arrival_delay;
- RTCStatsMember<uint32_t> interruption_count;
- RTCStatsMember<double> total_interruption_duration;
- RTCStatsMember<double> min_playout_delay;
+ absl::optional<uint64_t> jitter_buffer_flushes;
+ absl::optional<uint64_t> delayed_packet_outage_samples;
+ absl::optional<double> relative_packet_arrival_delay;
+ absl::optional<uint32_t> interruption_count;
+ absl::optional<double> total_interruption_duration;
+ absl::optional<double> min_playout_delay;
};
// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
@@ -324,46 +325,46 @@ class RTC_EXPORT RTCOutboundRtpStreamStats final
RTCOutboundRtpStreamStats(std::string id, Timestamp timestamp);
~RTCOutboundRtpStreamStats() override;
- RTCStatsMember<std::string> media_source_id;
- RTCStatsMember<std::string> remote_id;
- RTCStatsMember<std::string> mid;
- RTCStatsMember<std::string> rid;
- RTCStatsMember<uint64_t> retransmitted_packets_sent;
- RTCStatsMember<uint64_t> header_bytes_sent;
- RTCStatsMember<uint64_t> retransmitted_bytes_sent;
- RTCStatsMember<double> target_bitrate;
- RTCStatsMember<uint32_t> frames_encoded;
- RTCStatsMember<uint32_t> key_frames_encoded;
- RTCStatsMember<double> total_encode_time;
- RTCStatsMember<uint64_t> total_encoded_bytes_target;
- RTCStatsMember<uint32_t> frame_width;
- RTCStatsMember<uint32_t> frame_height;
- RTCStatsMember<double> frames_per_second;
- RTCStatsMember<uint32_t> frames_sent;
- RTCStatsMember<uint32_t> huge_frames_sent;
- RTCStatsMember<double> total_packet_send_delay;
- RTCStatsMember<std::string> quality_limitation_reason;
- RTCStatsMember<std::map<std::string, double>> quality_limitation_durations;
+ absl::optional<std::string> media_source_id;
+ absl::optional<std::string> remote_id;
+ absl::optional<std::string> mid;
+ absl::optional<std::string> rid;
+ absl::optional<uint64_t> retransmitted_packets_sent;
+ absl::optional<uint64_t> header_bytes_sent;
+ absl::optional<uint64_t> retransmitted_bytes_sent;
+ absl::optional<double> target_bitrate;
+ absl::optional<uint32_t> frames_encoded;
+ absl::optional<uint32_t> key_frames_encoded;
+ absl::optional<double> total_encode_time;
+ absl::optional<uint64_t> total_encoded_bytes_target;
+ absl::optional<uint32_t> frame_width;
+ absl::optional<uint32_t> frame_height;
+ absl::optional<double> frames_per_second;
+ absl::optional<uint32_t> frames_sent;
+ absl::optional<uint32_t> huge_frames_sent;
+ absl::optional<double> total_packet_send_delay;
+ absl::optional<std::string> quality_limitation_reason;
+ absl::optional<std::map<std::string, double>> quality_limitation_durations;
// https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
- RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
+ absl::optional<uint32_t> quality_limitation_resolution_changes;
// https://w3c.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
- RTCStatsMember<std::string> content_type;
+ absl::optional<std::string> content_type;
// In JavaScript, this is only exposed if HW exposure is allowed.
// Only implemented for video.
// TODO(https://crbug.com/webrtc/14178): Implement for audio as well.
- RTCStatsMember<std::string> encoder_implementation;
+ absl::optional<std::string> encoder_implementation;
// FIR and PLI counts are only defined for |kind == "video"|.
- RTCStatsMember<uint32_t> fir_count;
- RTCStatsMember<uint32_t> pli_count;
- RTCStatsMember<uint32_t> nack_count;
- RTCStatsMember<uint64_t> qp_sum;
- RTCStatsMember<bool> active;
+ absl::optional<uint32_t> fir_count;
+ absl::optional<uint32_t> pli_count;
+ absl::optional<uint32_t> nack_count;
+ absl::optional<uint64_t> qp_sum;
+ absl::optional<bool> active;
// In JavaScript, this is only exposed if HW exposure is allowed.
- RTCStatsMember<bool> power_efficient_encoder;
- RTCStatsMember<std::string> scalability_mode;
+ absl::optional<bool> power_efficient_encoder;
+ absl::optional<std::string> scalability_mode;
// RTX ssrc. Only present if RTX is negotiated.
- RTCStatsMember<uint32_t> rtx_ssrc;
+ absl::optional<uint32_t> rtx_ssrc;
};
// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
@@ -374,11 +375,11 @@ class RTC_EXPORT RTCRemoteInboundRtpStreamStats final
RTCRemoteInboundRtpStreamStats(std::string id, Timestamp timestamp);
~RTCRemoteInboundRtpStreamStats() override;
- RTCStatsMember<std::string> local_id;
- RTCStatsMember<double> round_trip_time;
- RTCStatsMember<double> fraction_lost;
- RTCStatsMember<double> total_round_trip_time;
- RTCStatsMember<int32_t> round_trip_time_measurements;
+ absl::optional<std::string> local_id;
+ absl::optional<double> round_trip_time;
+ absl::optional<double> fraction_lost;
+ absl::optional<double> total_round_trip_time;
+ absl::optional<int32_t> round_trip_time_measurements;
};
// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
@@ -389,12 +390,12 @@ class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final
RTCRemoteOutboundRtpStreamStats(std::string id, Timestamp timestamp);
~RTCRemoteOutboundRtpStreamStats() override;
- RTCStatsMember<std::string> local_id;
- RTCStatsMember<double> remote_timestamp;
- RTCStatsMember<uint64_t> reports_sent;
- RTCStatsMember<double> round_trip_time;
- RTCStatsMember<uint64_t> round_trip_time_measurements;
- RTCStatsMember<double> total_round_trip_time;
+ absl::optional<std::string> local_id;
+ absl::optional<double> remote_timestamp;
+ absl::optional<uint64_t> reports_sent;
+ absl::optional<double> round_trip_time;
+ absl::optional<uint64_t> round_trip_time_measurements;
+ absl::optional<double> total_round_trip_time;
};
// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
@@ -403,8 +404,8 @@ class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
WEBRTC_RTCSTATS_DECL();
~RTCMediaSourceStats() override;
- RTCStatsMember<std::string> track_identifier;
- RTCStatsMember<std::string> kind;
+ absl::optional<std::string> track_identifier;
+ absl::optional<std::string> kind;
protected:
RTCMediaSourceStats(std::string id, Timestamp timestamp);
@@ -417,11 +418,11 @@ class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
RTCAudioSourceStats(std::string id, Timestamp timestamp);
~RTCAudioSourceStats() override;
- RTCStatsMember<double> audio_level;
- RTCStatsMember<double> total_audio_energy;
- RTCStatsMember<double> total_samples_duration;
- RTCStatsMember<double> echo_return_loss;
- RTCStatsMember<double> echo_return_loss_enhancement;
+ absl::optional<double> audio_level;
+ absl::optional<double> total_audio_energy;
+ absl::optional<double> total_samples_duration;
+ absl::optional<double> echo_return_loss;
+ absl::optional<double> echo_return_loss_enhancement;
};
// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
@@ -431,10 +432,10 @@ class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
RTCVideoSourceStats(std::string id, Timestamp timestamp);
~RTCVideoSourceStats() override;
- RTCStatsMember<uint32_t> width;
- RTCStatsMember<uint32_t> height;
- RTCStatsMember<uint32_t> frames;
- RTCStatsMember<double> frames_per_second;
+ absl::optional<uint32_t> width;
+ absl::optional<uint32_t> height;
+ absl::optional<uint32_t> frames;
+ absl::optional<double> frames_per_second;
};
// https://w3c.github.io/webrtc-stats/#transportstats-dict*
@@ -444,23 +445,23 @@ class RTC_EXPORT RTCTransportStats final : public RTCStats {
RTCTransportStats(std::string id, Timestamp timestamp);
~RTCTransportStats() override;
- RTCStatsMember<uint64_t> bytes_sent;
- RTCStatsMember<uint64_t> packets_sent;
- RTCStatsMember<uint64_t> bytes_received;
- RTCStatsMember<uint64_t> packets_received;
- RTCStatsMember<std::string> rtcp_transport_stats_id;
- RTCStatsMember<std::string> dtls_state;
- RTCStatsMember<std::string> selected_candidate_pair_id;
- RTCStatsMember<std::string> local_certificate_id;
- RTCStatsMember<std::string> remote_certificate_id;
- RTCStatsMember<std::string> tls_version;
- RTCStatsMember<std::string> dtls_cipher;
- RTCStatsMember<std::string> dtls_role;
- RTCStatsMember<std::string> srtp_cipher;
- RTCStatsMember<uint32_t> selected_candidate_pair_changes;
- RTCStatsMember<std::string> ice_role;
- RTCStatsMember<std::string> ice_local_username_fragment;
- RTCStatsMember<std::string> ice_state;
+ absl::optional<uint64_t> bytes_sent;
+ absl::optional<uint64_t> packets_sent;
+ absl::optional<uint64_t> bytes_received;
+ absl::optional<uint64_t> packets_received;
+ absl::optional<std::string> rtcp_transport_stats_id;
+ absl::optional<std::string> dtls_state;
+ absl::optional<std::string> selected_candidate_pair_id;
+ absl::optional<std::string> local_certificate_id;
+ absl::optional<std::string> remote_certificate_id;
+ absl::optional<std::string> tls_version;
+ absl::optional<std::string> dtls_cipher;
+ absl::optional<std::string> dtls_role;
+ absl::optional<std::string> srtp_cipher;
+ absl::optional<uint32_t> selected_candidate_pair_changes;
+ absl::optional<std::string> ice_role;
+ absl::optional<std::string> ice_local_username_fragment;
+ absl::optional<std::string> ice_state;
};
// https://w3c.github.io/webrtc-stats/#playoutstats-dict*
@@ -470,12 +471,12 @@ class RTC_EXPORT RTCAudioPlayoutStats final : public RTCStats {
RTCAudioPlayoutStats(const std::string& id, Timestamp timestamp);
~RTCAudioPlayoutStats() override;
- RTCStatsMember<std::string> kind;
- RTCStatsMember<double> synthesized_samples_duration;
- RTCStatsMember<uint64_t> synthesized_samples_events;
- RTCStatsMember<double> total_samples_duration;
- RTCStatsMember<double> total_playout_delay;
- RTCStatsMember<uint64_t> total_samples_count;
+ absl::optional<std::string> kind;
+ absl::optional<double> synthesized_samples_duration;
+ absl::optional<uint64_t> synthesized_samples_events;
+ absl::optional<double> total_samples_duration;
+ absl::optional<double> total_playout_delay;
+ absl::optional<uint64_t> total_samples_count;
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/test/mock_frame_transformer.h b/third_party/libwebrtc/api/test/mock_frame_transformer.h
new file mode 100644
index 0000000000..8f438bdf9e
--- /dev/null
+++ b/third_party/libwebrtc/api/test/mock_frame_transformer.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef API_TEST_MOCK_FRAME_TRANSFORMER_H_
+#define API_TEST_MOCK_FRAME_TRANSFORMER_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/frame_transformer_interface.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockFrameTransformer : public FrameTransformerInterface {
+ public:
+ MOCK_METHOD(void,
+ Transform,
+ (std::unique_ptr<TransformableFrameInterface>),
+ (override));
+ MOCK_METHOD(void,
+ RegisterTransformedFrameCallback,
+ (rtc::scoped_refptr<TransformedFrameCallback>),
+ (override));
+ MOCK_METHOD(void,
+ RegisterTransformedFrameSinkCallback,
+ (rtc::scoped_refptr<TransformedFrameCallback>, uint32_t),
+ (override));
+ MOCK_METHOD(void, UnregisterTransformedFrameCallback, (), (override));
+ MOCK_METHOD(void,
+ UnregisterTransformedFrameSinkCallback,
+ (uint32_t),
+ (override));
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_FRAME_TRANSFORMER_H_
diff --git a/third_party/libwebrtc/api/test/mock_peerconnectioninterface.h b/third_party/libwebrtc/api/test/mock_peerconnectioninterface.h
index ccc6ce46b1..22a77d7dfe 100644
--- a/third_party/libwebrtc/api/test/mock_peerconnectioninterface.h
+++ b/third_party/libwebrtc/api/test/mock_peerconnectioninterface.h
@@ -177,6 +177,10 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
(const std::vector<cricket::Candidate>&),
(override));
MOCK_METHOD(RTCError, SetBitrate, (const BitrateSettings&), (override));
+ MOCK_METHOD(void,
+ ReconfigureBandwidthEstimation,
+ (const BandwidthEstimationSettings&),
+ (override));
MOCK_METHOD(void, SetAudioPlayout, (bool), (override));
MOCK_METHOD(void, SetAudioRecording, (bool), (override));
MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>,
diff --git a/third_party/libwebrtc/api/test/mock_video_decoder_factory.h b/third_party/libwebrtc/api/test/mock_video_decoder_factory.h
index 6150d9f8b5..48d96ea58b 100644
--- a/third_party/libwebrtc/api/test/mock_video_decoder_factory.h
+++ b/third_party/libwebrtc/api/test/mock_video_decoder_factory.h
@@ -14,6 +14,7 @@
#include <memory>
#include <vector>
+#include "api/environment/environment.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/video_decoder_factory.h"
@@ -21,17 +22,21 @@
namespace webrtc {
-class MockVideoDecoderFactory : public webrtc::VideoDecoderFactory {
+class MockVideoDecoderFactory : public VideoDecoderFactory {
public:
~MockVideoDecoderFactory() override { Die(); }
- MOCK_METHOD(std::vector<webrtc::SdpVideoFormat>,
+ MOCK_METHOD(std::vector<SdpVideoFormat>,
GetSupportedFormats,
(),
(const, override));
- MOCK_METHOD(std::unique_ptr<webrtc::VideoDecoder>,
+ MOCK_METHOD(std::unique_ptr<VideoDecoder>,
+ Create,
+ (const Environment&, const SdpVideoFormat&),
+ (override));
+ MOCK_METHOD(std::unique_ptr<VideoDecoder>,
CreateVideoDecoder,
- (const webrtc::SdpVideoFormat&),
+ (const SdpVideoFormat&),
(override));
MOCK_METHOD(void, Die, ());
};
diff --git a/third_party/libwebrtc/api/test/pclf/BUILD.gn b/third_party/libwebrtc/api/test/pclf/BUILD.gn
index 4f62984e83..68f1688556 100644
--- a/third_party/libwebrtc/api/test/pclf/BUILD.gn
+++ b/third_party/libwebrtc/api/test/pclf/BUILD.gn
@@ -74,6 +74,8 @@ rtc_library("media_quality_test_params") {
"../../../api/transport:network_control",
"../../../api/video_codecs:video_codecs_api",
"../../../modules/audio_processing:api",
+ "../../../p2p:connection",
+ "../../../p2p:port_allocator",
"../../../p2p:rtc_p2p",
"../../../rtc_base:network",
"../../../rtc_base:rtc_certificate_generator",
diff --git a/third_party/libwebrtc/api/test/video/BUILD.gn b/third_party/libwebrtc/api/test/video/BUILD.gn
index 0eae85aef3..cf6dd599c9 100644
--- a/third_party/libwebrtc/api/test/video/BUILD.gn
+++ b/third_party/libwebrtc/api/test/video/BUILD.gn
@@ -18,6 +18,7 @@ rtc_library("function_video_factory") {
deps = [
"../../../rtc_base:checks",
+ "../../environment",
"../../video_codecs:video_codecs_api",
]
}
diff --git a/third_party/libwebrtc/api/test/video/function_video_decoder_factory.h b/third_party/libwebrtc/api/test/video/function_video_decoder_factory.h
index 2145c71bff..2f2eeb5886 100644
--- a/third_party/libwebrtc/api/test/video/function_video_decoder_factory.h
+++ b/third_party/libwebrtc/api/test/video/function_video_decoder_factory.h
@@ -16,6 +16,7 @@
#include <utility>
#include <vector>
+#include "api/environment/environment.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/video_decoder_factory.h"
@@ -29,17 +30,20 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
public:
explicit FunctionVideoDecoderFactory(
std::function<std::unique_ptr<VideoDecoder>()> create)
- : create_([create = std::move(create)](const SdpVideoFormat&) {
+ : create_([create = std::move(create)](const Environment&,
+ const SdpVideoFormat&) {
return create();
}) {}
explicit FunctionVideoDecoderFactory(
- std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
+ std::function<std::unique_ptr<VideoDecoder>(const Environment&,
+ const SdpVideoFormat&)>
create)
: create_(std::move(create)) {}
FunctionVideoDecoderFactory(
std::function<std::unique_ptr<VideoDecoder>()> create,
std::vector<SdpVideoFormat> sdp_video_formats)
- : create_([create = std::move(create)](const SdpVideoFormat&) {
+ : create_([create = std::move(create)](const Environment&,
+ const SdpVideoFormat&) {
return create();
}),
sdp_video_formats_(std::move(sdp_video_formats)) {}
@@ -48,13 +52,14 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
return sdp_video_formats_;
}
- std::unique_ptr<VideoDecoder> CreateVideoDecoder(
- const SdpVideoFormat& format) override {
- return create_(format);
+ std::unique_ptr<VideoDecoder> Create(const Environment& env,
+ const SdpVideoFormat& format) override {
+ return create_(env, format);
}
private:
- const std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
+ const std::function<std::unique_ptr<VideoDecoder>(const Environment& env,
+ const SdpVideoFormat&)>
create_;
const std::vector<SdpVideoFormat> sdp_video_formats_;
};
diff --git a/third_party/libwebrtc/api/transport/BUILD.gn b/third_party/libwebrtc/api/transport/BUILD.gn
index c0209bf0d0..21559815ca 100644
--- a/third_party/libwebrtc/api/transport/BUILD.gn
+++ b/third_party/libwebrtc/api/transport/BUILD.gn
@@ -18,6 +18,12 @@ rtc_library("bitrate_settings") {
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
+rtc_library("bandwidth_estimation_settings") {
+ visibility = [ "*" ]
+ sources = [ "bandwidth_estimation_settings.h" ]
+ deps = [ "../../rtc_base/system:rtc_export" ]
+}
+
rtc_source_set("enums") {
visibility = [ "*" ]
sources = [ "enums.h" ]
diff --git a/third_party/libwebrtc/api/transport/bandwidth_estimation_settings.h b/third_party/libwebrtc/api/transport/bandwidth_estimation_settings.h
new file mode 100644
index 0000000000..7ae8cc9ef8
--- /dev/null
+++ b/third_party/libwebrtc/api/transport/bandwidth_estimation_settings.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2024 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 API_TRANSPORT_BANDWIDTH_ESTIMATION_SETTINGS_H_
+#define API_TRANSPORT_BANDWIDTH_ESTIMATION_SETTINGS_H_
+
+#include "rtc_base/system/rtc_export.h"
+namespace webrtc {
+// Configuration settings affecting bandwidth estimation.
+// These settings can be set and changed by an application.
+struct RTC_EXPORT BandwidthEstimationSettings {
+ // A bandwith estimation probe may be sent using a RtpTransceiver with
+ // direction SendOnly or SendRecv that supports RTX. The probe can be sent
+ // without first sending media packets in which case Rtp padding packets are
+ // used.
+ bool allow_probe_without_media = false;
+};
+
+} // namespace webrtc
+#endif // API_TRANSPORT_BANDWIDTH_ESTIMATION_SETTINGS_H_
diff --git a/third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build b/third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build
new file mode 100644
index 0000000000..10e3f8f835
--- /dev/null
+++ b/third_party/libwebrtc/api/transport/bandwidth_estimation_settings_gn/moz.build
@@ -0,0 +1,198 @@
+# 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"
+]
+
+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
+
+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
+
+if CONFIG["TARGET_CPU"] == "aarch64":
+
+ DEFINES["WEBRTC_ARCH_ARM64"] = True
+ DEFINES["WEBRTC_HAS_NEON"] = True
+
+if CONFIG["TARGET_CPU"] == "arm":
+
+ 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 += [
+ "unwind"
+ ]
+
+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":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64":
+
+ DEFINES["_GNU_SOURCE"] = True
+
+Library("bandwidth_estimation_settings_gn")
diff --git a/third_party/libwebrtc/api/video_codecs/BUILD.gn b/third_party/libwebrtc/api/video_codecs/BUILD.gn
index 3865f4fee7..9f7022ca67 100644
--- a/third_party/libwebrtc/api/video_codecs/BUILD.gn
+++ b/third_party/libwebrtc/api/video_codecs/BUILD.gn
@@ -58,6 +58,7 @@ rtc_library("video_codecs_api") {
"video_codec.h",
"video_decoder.cc",
"video_decoder.h",
+ "video_decoder_factory.cc",
"video_decoder_factory.h",
"video_encoder.cc",
"video_encoder.h",
@@ -84,6 +85,7 @@ rtc_library("video_codecs_api") {
"..:scoped_refptr",
"../../api:array_view",
"../../api:rtp_parameters",
+ "../../media:media_constants",
"../../modules/video_coding:codec_globals_headers",
"../../rtc_base:checks",
"../../rtc_base:logging",
@@ -91,6 +93,7 @@ rtc_library("video_codecs_api") {
"../../rtc_base:refcount",
"../../rtc_base:stringutils",
"../../rtc_base/system:rtc_export",
+ "../environment",
"../units:data_rate",
"../video:encoded_image",
"../video:render_resolution",
@@ -302,6 +305,8 @@ rtc_library("rtc_software_fallback_wrappers") {
deps = [
":video_codecs_api",
"..:fec_controller_api",
+ "../../api:field_trials_view",
+ "../../api/environment",
"../../api/transport:field_trial_based_config",
"../../api/video:video_frame",
"../../media:rtc_media_base",
diff --git a/third_party/libwebrtc/api/video_codecs/av1_profile.cc b/third_party/libwebrtc/api/video_codecs/av1_profile.cc
index 59d7b13e51..1a953a0c53 100644
--- a/third_party/libwebrtc/api/video_codecs/av1_profile.cc
+++ b/third_party/libwebrtc/api/video_codecs/av1_profile.cc
@@ -13,13 +13,11 @@
#include <map>
#include <utility>
+#include "media/base/media_constants.h"
#include "rtc_base/string_to_number.h"
namespace webrtc {
-// Parameter name in the format parameter map for AV1 video.
-const char kAV1FmtpProfile[] = "profile";
-
absl::string_view AV1ProfileToString(AV1Profile profile) {
switch (profile) {
case AV1Profile::kProfile0:
@@ -51,7 +49,7 @@ absl::optional<AV1Profile> StringToAV1Profile(absl::string_view str) {
absl::optional<AV1Profile> ParseSdpForAV1Profile(
const CodecParameterMap& params) {
- const auto profile_it = params.find(kAV1FmtpProfile);
+ const auto profile_it = params.find(cricket::kAv1FmtpProfile);
if (profile_it == params.end())
return AV1Profile::kProfile0;
const std::string& profile_str = profile_it->second;
diff --git a/third_party/libwebrtc/api/video_codecs/av1_profile.h b/third_party/libwebrtc/api/video_codecs/av1_profile.h
index bc9767631c..4651d93ef4 100644
--- a/third_party/libwebrtc/api/video_codecs/av1_profile.h
+++ b/third_party/libwebrtc/api/video_codecs/av1_profile.h
@@ -20,9 +20,6 @@
namespace webrtc {
-// Profile information for AV1 video.
-extern RTC_EXPORT const char kAV1FmtpProfile[];
-
// Profiles can be found at:
// https://aomedia.org/av1/specification/annex-a/#profiles
// The enum values match the number specified in the SDP.
diff --git a/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc b/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
index 0f313e84a9..5abde8fbb0 100644
--- a/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
+++ b/third_party/libwebrtc/api/video_codecs/sdp_video_format.cc
@@ -20,6 +20,7 @@
#endif
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/vp9_profile.h"
+#include "media/base/media_constants.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
@@ -28,15 +29,21 @@ namespace webrtc {
namespace {
-std::string H264GetPacketizationModeOrDefault(const CodecParameterMap& params) {
- constexpr char kH264FmtpPacketizationMode[] = "packetization-mode";
- const auto it = params.find(kH264FmtpPacketizationMode);
+std::string GetFmtpParameterOrDefault(const CodecParameterMap& params,
+ const std::string& name,
+ const std::string& default_value) {
+ const auto it = params.find(name);
if (it != params.end()) {
return it->second;
}
+ return default_value;
+}
+
+std::string H264GetPacketizationModeOrDefault(const CodecParameterMap& params) {
// If packetization-mode is not present, default to "0".
// https://tools.ietf.org/html/rfc6184#section-6.2
- return "0";
+ return GetFmtpParameterOrDefault(params, cricket::kH264FmtpPacketizationMode,
+ "0");
}
bool H264IsSamePacketizationMode(const CodecParameterMap& left,
@@ -45,6 +52,28 @@ bool H264IsSamePacketizationMode(const CodecParameterMap& left,
H264GetPacketizationModeOrDefault(right);
}
+std::string AV1GetTierOrDefault(const CodecParameterMap& params) {
+ // If the parameter is not present, the tier MUST be inferred to be 0.
+ // https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
+ return GetFmtpParameterOrDefault(params, cricket::kAv1FmtpTier, "0");
+}
+
+bool AV1IsSameTier(const CodecParameterMap& left,
+ const CodecParameterMap& right) {
+ return AV1GetTierOrDefault(left) == AV1GetTierOrDefault(right);
+}
+
+std::string AV1GetLevelIdxOrDefault(const CodecParameterMap& params) {
+ // If the parameter is not present, it MUST be inferred to be 5 (level 3.1).
+ // https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
+ return GetFmtpParameterOrDefault(params, cricket::kAv1FmtpLevelIdx, "5");
+}
+
+bool AV1IsSameLevelIdx(const CodecParameterMap& left,
+ const CodecParameterMap& right) {
+ return AV1GetLevelIdxOrDefault(left) == AV1GetLevelIdxOrDefault(right);
+}
+
// Some (video) codecs are actually families of codecs and rely on parameters
// to distinguish different incompatible family members.
bool IsSameCodecSpecific(const SdpVideoFormat& format1,
@@ -62,7 +91,9 @@ bool IsSameCodecSpecific(const SdpVideoFormat& format1,
case kVideoCodecVP9:
return VP9IsSameProfile(format1.parameters, format2.parameters);
case kVideoCodecAV1:
- return AV1IsSameProfile(format1.parameters, format2.parameters);
+ return AV1IsSameProfile(format1.parameters, format2.parameters) &&
+ AV1IsSameTier(format1.parameters, format2.parameters) &&
+ AV1IsSameLevelIdx(format1.parameters, format2.parameters);
#ifdef RTC_ENABLE_H265
case kVideoCodecH265:
return H265IsSameProfileTierLevel(format1.parameters, format2.parameters);
@@ -71,6 +102,7 @@ bool IsSameCodecSpecific(const SdpVideoFormat& format1,
return true;
}
}
+
} // namespace
SdpVideoFormat::SdpVideoFormat(const std::string& name) : name(name) {}
diff --git a/third_party/libwebrtc/api/video_codecs/test/BUILD.gn b/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
index 7bfe86e9f4..be897ae124 100644
--- a/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
+++ b/third_party/libwebrtc/api/video_codecs/test/BUILD.gn
@@ -39,10 +39,13 @@ if (rtc_include_tests) {
"../../../modules/video_coding:webrtc_vp8",
"../../../rtc_base:checks",
"../../../rtc_base:rtc_base_tests_utils",
+ "../../../test:explicit_key_value_config",
"../../../test:fake_video_codecs",
"../../../test:field_trial",
"../../../test:test_support",
"../../../test:video_test_common",
+ "../../environment",
+ "../../environment:environment_factory",
"../../video:encoded_image",
"../../video:video_bitrate_allocation",
"../../video:video_frame",
diff --git a/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
index 97be6250db..bd837605b0 100644
--- a/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
+++ b/third_party/libwebrtc/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
@@ -13,6 +13,8 @@
#include <stdint.h>
#include "absl/types/optional.h"
+#include "api/environment/environment.h"
+#include "api/environment/environment_factory.h"
#include "api/video/encoded_image.h"
#include "api/video/video_frame.h"
#include "api/video_codecs/video_decoder.h"
@@ -20,7 +22,7 @@
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "rtc_base/checks.h"
-#include "test/field_trial.h"
+#include "test/explicit_key_value_config.h"
#include "test/gtest.h"
namespace webrtc {
@@ -31,10 +33,12 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
: VideoDecoderSoftwareFallbackWrapperTest("") {}
explicit VideoDecoderSoftwareFallbackWrapperTest(
const std::string& field_trials)
- : override_field_trials_(field_trials),
+ : field_trials_(field_trials),
+ env_(CreateEnvironment(&field_trials_)),
fake_decoder_(new CountingFakeDecoder()),
fallback_wrapper_(CreateVideoDecoderSoftwareFallbackWrapper(
- std::unique_ptr<VideoDecoder>(VP8Decoder::Create()),
+ env_,
+ CreateVp8Decoder(env_),
std::unique_ptr<VideoDecoder>(fake_decoder_))) {}
class CountingFakeDecoder : public VideoDecoder {
@@ -71,7 +75,8 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
int release_count_ = 0;
int reset_count_ = 0;
};
- test::ScopedFieldTrials override_field_trials_;
+ test::ExplicitKeyValueConfig field_trials_;
+ const Environment env_;
// `fake_decoder_` is owned and released by `fallback_wrapper_`.
CountingFakeDecoder* fake_decoder_;
std::unique_ptr<VideoDecoder> fallback_wrapper_;
@@ -275,7 +280,7 @@ class ForcedSoftwareDecoderFallbackTest
fake_decoder_ = new CountingFakeDecoder();
sw_fallback_decoder_ = new CountingFakeDecoder();
fallback_wrapper_ = CreateVideoDecoderSoftwareFallbackWrapper(
- std::unique_ptr<VideoDecoder>(sw_fallback_decoder_),
+ env_, std::unique_ptr<VideoDecoder>(sw_fallback_decoder_),
std::unique_ptr<VideoDecoder>(fake_decoder_));
}
diff --git a/third_party/libwebrtc/api/video_codecs/video_codec.cc b/third_party/libwebrtc/api/video_codecs/video_codec.cc
index 39a345d699..82c9bfc8ea 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codec.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_codec.cc
@@ -16,6 +16,7 @@
#include "absl/strings/match.h"
#include "rtc_base/checks.h"
+#include "rtc_base/strings/string_builder.h"
namespace webrtc {
namespace {
@@ -73,6 +74,35 @@ VideoCodec::VideoCodec()
codec_specific_(),
complexity_(VideoCodecComplexity::kComplexityNormal) {}
+std::string VideoCodec::ToString() const {
+ char string_buf[2048];
+ rtc::SimpleStringBuilder ss(string_buf);
+
+ ss << "VideoCodec {" << "type: " << CodecTypeToPayloadString(codecType)
+ << ", mode: "
+ << (mode == VideoCodecMode::kRealtimeVideo ? "RealtimeVideo"
+ : "Screensharing");
+ if (IsSinglecast()) {
+ absl::optional<ScalabilityMode> scalability_mode = GetScalabilityMode();
+ if (scalability_mode.has_value()) {
+ ss << ", Singlecast: {" << width << "x" << height << " "
+ << ScalabilityModeToString(*scalability_mode)
+ << (active ? ", active" : ", inactive") << "}";
+ }
+ } else {
+ ss << ", Simulcast: {";
+ for (size_t i = 0; i < numberOfSimulcastStreams; ++i) {
+ const SimulcastStream stream = simulcastStream[i];
+ ss << "[" << stream.width << "x" << stream.height << " "
+ << ScalabilityModeToString(stream.GetScalabilityMode())
+ << (stream.active ? ", active" : ", inactive") << "]";
+ }
+ ss << "}";
+ }
+ ss << "}";
+ return ss.str();
+}
+
VideoCodecVP8* VideoCodec::VP8() {
RTC_DCHECK_EQ(codecType, kVideoCodecVP8);
return &codec_specific_.VP8;
diff --git a/third_party/libwebrtc/api/video_codecs/video_codec.h b/third_party/libwebrtc/api/video_codecs/video_codec.h
index a596af1528..e48ffd4b5f 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codec.h
+++ b/third_party/libwebrtc/api/video_codecs/video_codec.h
@@ -141,6 +141,9 @@ class RTC_EXPORT VideoCodec {
bool GetFrameDropEnabled() const;
void SetFrameDropEnabled(bool enabled);
+ bool IsSinglecast() const { return numberOfSimulcastStreams <= 1; }
+ bool IsSimulcast() const { return !IsSinglecast(); }
+
// Public variables. TODO(hta): Make them private with accessors.
VideoCodecType codecType;
@@ -193,6 +196,7 @@ class RTC_EXPORT VideoCodec {
bool operator==(const VideoCodec& other) const = delete;
bool operator!=(const VideoCodec& other) const = delete;
+ std::string ToString() const;
// Accessors for codec specific information.
// There is a const version of each that returns a reference,
diff --git a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
index c6c127e5b6..13a1c027cf 100644
--- a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
+++ b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build
@@ -38,6 +38,7 @@ UNIFIED_SOURCES += [
"/third_party/libwebrtc/api/video_codecs/spatial_layer.cc",
"/third_party/libwebrtc/api/video_codecs/video_codec.cc",
"/third_party/libwebrtc/api/video_codecs/video_decoder.cc",
+ "/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc",
"/third_party/libwebrtc/api/video_codecs/video_encoder.cc",
"/third_party/libwebrtc/api/video_codecs/vp8_frame_config.cc",
"/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers.cc",
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc
new file mode 100644
index 0000000000..60fe92bf38
--- /dev/null
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.cc
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2024 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 "api/video_codecs/video_decoder_factory.h"
+
+#include <memory>
+
+#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_decoder.h"
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+VideoDecoderFactory::CodecSupport VideoDecoderFactory::QueryCodecSupport(
+ const SdpVideoFormat& format,
+ bool reference_scaling) const {
+ // Default implementation, query for supported formats and check if the
+ // specified format is supported. Returns false if `reference_scaling` is
+ // true.
+ return {.is_supported = !reference_scaling &&
+ format.IsCodecInList(GetSupportedFormats())};
+}
+
+std::unique_ptr<VideoDecoder> VideoDecoderFactory::Create(
+ const Environment& env,
+ const SdpVideoFormat& format) {
+ return CreateVideoDecoder(format);
+}
+
+std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
+ const SdpVideoFormat& format) {
+ // Newer code shouldn't call this function,
+ // Older code should implement it in derived classes.
+ RTC_CHECK_NOTREACHED();
+ return nullptr;
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
index 7e1d2ee883..6048cb27fb 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory.h
@@ -12,17 +12,15 @@
#define API_VIDEO_CODECS_VIDEO_DECODER_FACTORY_H_
#include <memory>
-#include <string>
#include <vector>
-#include "absl/types/optional.h"
+#include "api/environment/environment.h"
#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_decoder.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
-class VideoDecoder;
-
// A factory that creates VideoDecoders.
// NOTE: This class is still under development and may change without notice.
class RTC_EXPORT VideoDecoderFactory {
@@ -32,6 +30,8 @@ class RTC_EXPORT VideoDecoderFactory {
bool is_power_efficient = false;
};
+ virtual ~VideoDecoderFactory() = default;
+
// Returns a list of supported video formats in order of preference, to use
// for signaling etc.
virtual std::vector<SdpVideoFormat> GetSupportedFormats() const = 0;
@@ -47,21 +47,18 @@ class RTC_EXPORT VideoDecoderFactory {
// different scalabilty modes. NOTE: QueryCodecSupport is currently an
// experimental feature that is subject to change without notice.
virtual CodecSupport QueryCodecSupport(const SdpVideoFormat& format,
- bool reference_scaling) const {
- // Default implementation, query for supported formats and check if the
- // specified format is supported. Returns false if `reference_scaling` is
- // true.
- CodecSupport codec_support;
- codec_support.is_supported =
- !reference_scaling && format.IsCodecInList(GetSupportedFormats());
- return codec_support;
- }
+ bool reference_scaling) const;
- // Creates a VideoDecoder for the specified format.
- virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
- const SdpVideoFormat& format) = 0;
+ // Creates a VideoDecoder for the specified `format`.
+ // TODO: bugs.webrtc.org/15791 - Make pure virtual when implemented in all
+ // derived classes.
+ virtual std::unique_ptr<VideoDecoder> Create(const Environment& env,
+ const SdpVideoFormat& format);
- virtual ~VideoDecoderFactory() {}
+ // TODO: bugs.webrtc.org/15791 - Make private or delete when all callers are
+ // migrated to `Create`.
+ virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
+ const SdpVideoFormat& format);
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h b/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
index bffbdc43d3..f38d46994b 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_factory_template_dav1d_adapter.h
@@ -23,7 +23,7 @@ struct Dav1dDecoderTemplateAdapter {
static std::vector<SdpVideoFormat> SupportedFormats() {
return {SdpVideoFormat("AV1"),
SdpVideoFormat(
- "AV1", {{kAV1FmtpProfile,
+ "AV1", {{"profile",
AV1ProfileToString(AV1Profile::kProfile1).data()}})};
}
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
index 2af4d39b3a..623888b9e2 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.cc
@@ -16,6 +16,7 @@
#include <string>
#include <utility>
+#include "api/field_trials_view.h"
#include "api/video/encoded_image.h"
#include "api/video_codecs/video_decoder.h"
#include "modules/video_coding/include/video_error_codes.h"
@@ -35,7 +36,8 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
public:
VideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
- std::unique_ptr<VideoDecoder> hw_decoder);
+ std::unique_ptr<VideoDecoder> hw_decoder,
+ bool force_sw_decoder_fallback);
~VideoDecoderSoftwareFallbackWrapper() override;
bool Configure(const Settings& settings) override;
@@ -67,6 +69,7 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
} decoder_type_;
std::unique_ptr<VideoDecoder> hw_decoder_;
+ const bool force_sw_decoder_fallback_;
Settings decoder_settings_;
const std::unique_ptr<VideoDecoder> fallback_decoder_;
const std::string fallback_implementation_name_;
@@ -77,9 +80,11 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
VideoDecoderSoftwareFallbackWrapper::VideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
- std::unique_ptr<VideoDecoder> hw_decoder)
+ std::unique_ptr<VideoDecoder> hw_decoder,
+ bool force_sw_decoder_fallback)
: decoder_type_(DecoderType::kNone),
hw_decoder_(std::move(hw_decoder)),
+ force_sw_decoder_fallback_(force_sw_decoder_fallback),
fallback_decoder_(std::move(sw_fallback_decoder)),
fallback_implementation_name_(
fallback_decoder_->GetDecoderInfo().implementation_name +
@@ -94,7 +99,7 @@ VideoDecoderSoftwareFallbackWrapper::~VideoDecoderSoftwareFallbackWrapper() =
bool VideoDecoderSoftwareFallbackWrapper::Configure(const Settings& settings) {
decoder_settings_ = settings;
- if (webrtc::field_trial::IsEnabled("WebRTC-Video-ForcedSwDecoderFallback")) {
+ if (force_sw_decoder_fallback_) {
RTC_LOG(LS_INFO) << "Forced software decoder fallback enabled.";
RTC_DCHECK(decoder_type_ == DecoderType::kNone);
return InitFallbackDecoder();
@@ -276,10 +281,20 @@ VideoDecoder& VideoDecoderSoftwareFallbackWrapper::active_decoder() const {
} // namespace
std::unique_ptr<VideoDecoder> CreateVideoDecoderSoftwareFallbackWrapper(
+ const Environment& env,
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
std::unique_ptr<VideoDecoder> hw_decoder) {
return std::make_unique<VideoDecoderSoftwareFallbackWrapper>(
- std::move(sw_fallback_decoder), std::move(hw_decoder));
+ std::move(sw_fallback_decoder), std::move(hw_decoder),
+ env.field_trials().IsEnabled("WebRTC-Video-ForcedSwDecoderFallback"));
+}
+
+std::unique_ptr<VideoDecoder> CreateVideoDecoderSoftwareFallbackWrapper(
+ std::unique_ptr<VideoDecoder> sw_fallback_decoder,
+ std::unique_ptr<VideoDecoder> hw_decoder) {
+ return std::make_unique<VideoDecoderSoftwareFallbackWrapper>(
+ std::move(sw_fallback_decoder), std::move(hw_decoder),
+ webrtc::field_trial::IsEnabled("WebRTC-Video-ForcedSwDecoderFallback"));
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
index 3f44e02b26..4fbc9a0048 100644
--- a/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
+++ b/third_party/libwebrtc/api/video_codecs/video_decoder_software_fallback_wrapper.h
@@ -13,6 +13,7 @@
#include <memory>
+#include "api/environment/environment.h"
#include "api/video_codecs/video_decoder.h"
#include "rtc_base/system/rtc_export.h"
@@ -23,6 +24,13 @@ namespace webrtc {
// hardware restrictions, such as max resolution.
RTC_EXPORT std::unique_ptr<VideoDecoder>
CreateVideoDecoderSoftwareFallbackWrapper(
+ const Environment& env,
+ std::unique_ptr<VideoDecoder> sw_fallback_decoder,
+ std::unique_ptr<VideoDecoder> hw_decoder);
+
+// TODO: bugs.webrtc.org/15791 - Deprecated, remove when not used by chromium.
+RTC_EXPORT std::unique_ptr<VideoDecoder>
+CreateVideoDecoderSoftwareFallbackWrapper(
std::unique_ptr<VideoDecoder> sw_fallback_decoder,
std::unique_ptr<VideoDecoder> hw_decoder);
diff --git a/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
index d35c9f9950..e50b5086e8 100644
--- a/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
+++ b/third_party/libwebrtc/api/video_codecs/video_encoder_software_fallback_wrapper.cc
@@ -28,6 +28,7 @@
#include "api/video_codecs/video_encoder.h"
#include "media/base/video_common.h"
#include "modules/video_coding/include/video_error_codes.h"
+#include "modules/video_coding/include/video_error_codes_utils.h"
#include "modules/video_coding/utility/simulcast_utility.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
@@ -264,14 +265,17 @@ void VideoEncoderSoftwareFallbackWrapper::PrimeEncoder(
}
bool VideoEncoderSoftwareFallbackWrapper::InitFallbackEncoder(bool is_forced) {
- RTC_LOG(LS_WARNING) << "Encoder falling back to software encoding.";
+ RTC_LOG(LS_WARNING) << "[VESFW] " << __func__
+ << "(is_forced=" << (is_forced ? "true" : "false") << ")";
RTC_DCHECK(encoder_settings_.has_value());
const int ret = fallback_encoder_->InitEncode(&codec_settings_,
encoder_settings_.value());
if (ret != WEBRTC_VIDEO_CODEC_OK) {
- RTC_LOG(LS_ERROR) << "Failed to initialize software-encoder fallback.";
+ RTC_LOG(LS_ERROR)
+ << "[VESFW] software-encoder fallback initialization failed with"
+ << " error code: " << WebRtcVideoCodecErrorToString(ret);
fallback_encoder_->Release();
return false;
}
@@ -305,6 +309,12 @@ void VideoEncoderSoftwareFallbackWrapper::SetFecControllerOverride(
int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
const VideoCodec* codec_settings,
const VideoEncoder::Settings& settings) {
+ RTC_LOG(LS_INFO) << "[VESFW] " << __func__
+ << "(codec=" << codec_settings->ToString()
+ << ", settings={number_of_cores: "
+ << settings.number_of_cores
+ << ", max_payload_size: " << settings.max_payload_size
+ << "})";
// Store settings, in case we need to dynamically switch to the fallback
// encoder after a failed Encode call.
codec_settings_ = *codec_settings;
@@ -327,6 +337,8 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
PrimeEncoder(current_encoder());
return ret;
}
+ RTC_LOG(LS_WARNING) << "[VESFW] Hardware encoder initialization failed with"
+ << " error code: " << WebRtcVideoCodecErrorToString(ret);
// Try to instantiate software codec.
if (InitFallbackEncoder(/*is_forced=*/false)) {
@@ -335,6 +347,8 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode(
}
// Software encoder failed too, use original return code.
+ RTC_LOG(LS_WARNING)
+ << "[VESFW] Software fallback encoder initialization also failed.";
encoder_state_ = EncoderState::kUninitialized;
return ret;
}