Bug 1927224 - remove WrongConstant suppression from WebRTC code. r=ng

Differential Revision: https://phabricator.services.mozilla.com/D226966
This commit is contained in:
Michael Froman 2024-10-28 16:21:53 +00:00
parent ec171f7887
commit f3436e4ba7
101 changed files with 43646 additions and 43685 deletions

View File

@ -1,34 +1,35 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 15 Jun 2021 12:18:00 -0500
Subject: Bug 1654112 - suppress android lint warnings for WrongConstant in 2
libwebrtc java files. r=ng
Date: Fri, 25 Jun 2021 15:12:00 -0500
Subject: Bug 1654112 - Mirror Bug 1714577 - Part 3 - Register WebRTC threads
with the Gecko Profiler. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D118050
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e60e2f295fb722f69a3a9fe9af34219880afe772
Differential Revision: https://phabricator.services.mozilla.com/D119412
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d881b16dd8a6813feb5ce1516c2a7ebe0270e72d
---
sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java | 5 +++++
1 file changed, 5 insertions(+)
rtc_base/platform_thread.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java
index 2d9e30902c..9546496f2d 100644
--- a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java
+++ b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java
@@ -15,6 +15,7 @@ import static android.media.AudioManager.MODE_IN_COMMUNICATION;
import static android.media.AudioManager.MODE_NORMAL;
import static android.media.AudioManager.MODE_RINGTONE;
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index f75ce8c3dc..81e115b568 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -19,6 +19,8 @@
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -248,6 +249,10 @@ public final class WebRtcAudioUtils {
}
}
#include "rtc_base/checks.h"
+ // Moz linting complains even though AudioManager.GET_DEVICES_ALL is
+ // listed in the docs here:
+ // https://developer.android.com/reference/android/media/AudioManager#GET_DEVICES_ALL
+ @SuppressLint("WrongConstant")
private static void logAudioDeviceInfo(String tag, AudioManager audioManager) {
if (Build.VERSION.SDK_INT < VERSION_CODES.M) {
return;
+#include "MicroGeckoProfiler.h"
+
namespace rtc {
namespace {
@@ -183,6 +185,10 @@ PlatformThread PlatformThread::SpawnThread(
new std::function<void()>([thread_function = std::move(thread_function),
name = std::string(name), attributes] {
rtc::SetCurrentThreadName(name.c_str());
+
+ char stacktop;
+ AutoRegisterProfiler profiler(name.c_str(), &stacktop);
+
SetPriority(attributes.priority);
thread_function();
});

View File

@ -1,35 +1,297 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 25 Jun 2021 15:12:00 -0500
Subject: Bug 1654112 - Mirror Bug 1714577 - Part 3 - Register WebRTC threads
with the Gecko Profiler. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 14 Jul 2021 22:26:00 +0000
Subject: Bug 1654112 - deconflate the target and host architectures in
libwebrtc build files; r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D119412
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d881b16dd8a6813feb5ce1516c2a7ebe0270e72d
Differential Revision: https://phabricator.services.mozilla.com/D119707
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e21dff7362743b6f4cdd1696b
---
rtc_base/platform_thread.cc | 6 ++++++
1 file changed, 6 insertions(+)
BUILD.gn | 6 +++---
common_audio/BUILD.gn | 16 ++++++++--------
common_audio/third_party/ooura/BUILD.gn | 6 +++---
common_audio/third_party/spl_sqrt_floor/BUILD.gn | 4 ++--
modules/audio_processing/aec3/BUILD.gn | 6 +++---
modules/audio_processing/aecm/BUILD.gn | 4 ++--
modules/audio_processing/agc/BUILD.gn | 2 +-
modules/audio_processing/agc2/rnn_vad/BUILD.gn | 2 +-
modules/audio_processing/ns/BUILD.gn | 2 +-
modules/desktop_capture/BUILD.gn | 2 +-
webrtc.gni | 4 ++--
11 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index f75ce8c3dc..81e115b568 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -19,6 +19,8 @@
diff --git a/BUILD.gn b/BUILD.gn
index 9957e3ba12..8e8ed055c9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -451,12 +451,12 @@ config("common_config") {
}
}
#include "rtc_base/checks.h"
- if (current_cpu == "arm64") {
+ if (target_cpu == "arm64") {
defines += [ "WEBRTC_ARCH_ARM64" ]
defines += [ "WEBRTC_HAS_NEON" ]
}
+#include "MicroGeckoProfiler.h"
+
namespace rtc {
namespace {
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
defines += [ "WEBRTC_ARCH_ARM" ]
if (arm_version >= 7) {
defines += [ "WEBRTC_ARCH_ARM_V7" ]
@@ -466,7 +466,7 @@ config("common_config") {
}
}
@@ -183,6 +185,10 @@ PlatformThread PlatformThread::SpawnThread(
new std::function<void()>([thread_function = std::move(thread_function),
name = std::string(name), attributes] {
rtc::SetCurrentThreadName(name.c_str());
+
+ char stacktop;
+ AutoRegisterProfiler profiler(name.c_str(), &stacktop);
+
SetPriority(attributes.priority);
thread_function();
});
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
defines += [ "MIPS32_LE" ]
if (mips_float_abi == "hard") {
defines += [ "MIPS_FPU_LE" ]
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 66895ccd0e..f6d06f6ad9 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -66,7 +66,7 @@ rtc_library("common_audio") {
deps += [ ":common_audio_neon" ]
}
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -88,7 +88,7 @@ rtc_source_set("mock_common_audio") {
rtc_source_set("common_audio_c_arm_asm") {
sources = []
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "signal_processing/complex_bit_reverse_arm.S" ]
if (arm_version >= 7) {
@@ -152,7 +152,7 @@ rtc_library("common_audio_c") {
"vad/webrtc_vad.c",
]
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [
"signal_processing/complex_bit_reverse_mips.c",
"signal_processing/complex_fft_mips.c",
@@ -170,7 +170,7 @@ rtc_library("common_audio_c") {
sources += [ "signal_processing/complex_fft.c" ]
}
- if (current_cpu != "arm" && current_cpu != "mipsel") {
+ if (target_cpu != "arm" && target_cpu != "mipsel") {
sources += [
"signal_processing/complex_bit_reverse.c",
"signal_processing/filter_ar_fast_q12.c",
@@ -231,7 +231,7 @@ rtc_library("fir_filter_factory") {
"../rtc_base/system:arch",
"../system_wrappers",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -240,7 +240,7 @@ rtc_library("fir_filter_factory") {
}
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("common_audio_sse2") {
sources = [
"fir_filter_sse.cc",
@@ -289,7 +289,7 @@ if (rtc_build_with_neon) {
"resampler/sinc_resampler_neon.cc",
]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
@@ -312,7 +312,7 @@ if (rtc_build_with_neon) {
"signal_processing/min_max_operations_neon.c",
]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/common_audio/third_party/ooura/BUILD.gn b/common_audio/third_party/ooura/BUILD.gn
index 0cdf98e591..a0ddf777db 100644
--- a/common_audio/third_party/ooura/BUILD.gn
+++ b/common_audio/third_party/ooura/BUILD.gn
@@ -20,7 +20,7 @@ rtc_library("fft_size_128") {
]
cflags = []
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
sources += [
"fft_size_128/ooura_fft_sse2.cc",
"fft_size_128/ooura_fft_tables_neon_sse2.h",
@@ -38,14 +38,14 @@ rtc_library("fft_size_128") {
deps += [ "../../../common_audio" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel" && mips_float_abi == "hard") {
+ if (target_cpu == "mipsel" && mips_float_abi == "hard") {
sources += [ "fft_size_128/ooura_fft_mips.cc" ]
}
}
diff --git a/common_audio/third_party/spl_sqrt_floor/BUILD.gn b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
index ac862c65a8..e66ed2796e 100644
--- a/common_audio/third_party/spl_sqrt_floor/BUILD.gn
+++ b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
@@ -12,11 +12,11 @@ rtc_library("spl_sqrt_floor") {
visibility = [ "../..:common_audio_c" ]
sources = [ "spl_sqrt_floor.h" ]
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "spl_sqrt_floor_arm.S" ]
deps += [ "../../../rtc_base/system:asm_defines" ]
- } else if (current_cpu == "mipsel") {
+ } else if (target_cpu == "mipsel") {
sources += [ "spl_sqrt_floor_mips.c" ]
} else {
sources += [ "spl_sqrt_floor.c" ]
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index 39e24c9324..411c0d27ca 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -123,7 +123,7 @@ rtc_library("aec3") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
@@ -159,7 +159,7 @@ rtc_library("aec3") {
"//third_party/abseil-cpp/absl/strings:string_view",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":aec3_avx2" ]
}
}
@@ -249,7 +249,7 @@ rtc_source_set("fft_data") {
]
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("aec3_avx2") {
configs += [ "..:apm_debug_dump" ]
sources = [
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index 80f2901049..a77f04aba5 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -29,14 +29,14 @@ rtc_library("aecm_core") {
if (rtc_build_with_neon) {
sources += [ "aecm_core_neon.cc" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [ "aecm_core_mips.cc" ]
} else {
sources += [ "aecm_core_c.cc" ]
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index f5bb27217a..b8363ad79e 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -82,7 +82,7 @@ rtc_library("legacy_agc") {
]
if (rtc_build_with_neon) {
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 47b9466a44..f99fe509d1 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -18,7 +18,7 @@ rtc_library("rnn_vad") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn
index 31ad61156d..6587fd14f3 100644
--- a/modules/audio_processing/ns/BUILD.gn
+++ b/modules/audio_processing/ns/BUILD.gn
@@ -43,7 +43,7 @@ rtc_static_library("ns") {
]
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index e39700419d..1047f30ee4 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -10,7 +10,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni")
import("../../webrtc.gni")
-use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
+use_desktop_capture_differ_sse2 = target_cpu == "x86" || target_cpu == "x64"
config("x11_config") {
if (rtc_use_x11_extensions) {
diff --git a/webrtc.gni b/webrtc.gni
index 98c1dd279f..156c3d3985 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -172,13 +172,13 @@ declare_args() {
# Selects fixed-point code where possible.
rtc_prefer_fixed_point = false
- if (current_cpu == "arm" || current_cpu == "arm64") {
+ if (target_cpu == "arm" || target_cpu == "arm64") {
rtc_prefer_fixed_point = true
}
# Determines whether NEON code will be built.
rtc_build_with_neon =
- (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
+ (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
# Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
# all platforms except Android and iOS. Because FFmpeg can be built

View File

@ -1,297 +1,300 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 14 Jul 2021 22:26:00 +0000
Subject: Bug 1654112 - deconflate the target and host architectures in
libwebrtc build files; r=mjf
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 19 Feb 2021 15:56:00 -0600
Subject: Bug 1654112 - Get RTCP BYE and RTP timeout handling working again
(from Bug 1595479) r=mjf,dminor
Differential Revision: https://phabricator.services.mozilla.com/D119707
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e21dff7362743b6f4cdd1696b
Differential Revision: https://phabricator.services.mozilla.com/D106145
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0b311007c033e83824f5f6996a70ab9e870f31f
---
BUILD.gn | 6 +++---
common_audio/BUILD.gn | 16 ++++++++--------
common_audio/third_party/ooura/BUILD.gn | 6 +++---
common_audio/third_party/spl_sqrt_floor/BUILD.gn | 4 ++--
modules/audio_processing/aec3/BUILD.gn | 6 +++---
modules/audio_processing/aecm/BUILD.gn | 4 ++--
modules/audio_processing/agc/BUILD.gn | 2 +-
modules/audio_processing/agc2/rnn_vad/BUILD.gn | 2 +-
modules/audio_processing/ns/BUILD.gn | 2 +-
modules/desktop_capture/BUILD.gn | 2 +-
webrtc.gni | 4 ++--
11 files changed, 27 insertions(+), 27 deletions(-)
audio/audio_receive_stream.cc | 4 +++-
audio/channel_receive.cc | 12 ++++++++----
audio/channel_receive.h | 4 +++-
call/audio_receive_stream.h | 3 +++
call/video_receive_stream.cc | 2 ++
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/include/rtp_rtcp_defines.h | 8 ++++++++
modules/rtp_rtcp/source/rtcp_receiver.cc | 18 ++++++++++++++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 3 +++
video/rtp_video_stream_receiver2.cc | 7 +++++--
11 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/BUILD.gn b/BUILD.gn
index 9957e3ba12..8e8ed055c9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -451,12 +451,12 @@ config("common_config") {
}
}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 269c85103b..319b56a08d 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -43,6 +43,8 @@ std::string AudioReceiveStreamInterface::Config::Rtp::ToString() const {
<< (rtcp_mode == RtcpMode::kCompound
? "compound"
: (rtcp_mode == RtcpMode::kReducedSize ? "reducedSize" : "off"));
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
@@ -76,7 +78,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
config.jitter_buffer_min_delay_ms, config.enable_non_sender_rtt,
config.decoder_factory, config.codec_pair_id,
std::move(config.frame_decryptor), config.crypto_options,
- std::move(config.frame_transformer));
+ std::move(config.frame_transformer), config.rtp.rtcp_event_observer);
}
} // namespace
- if (current_cpu == "arm64") {
+ if (target_cpu == "arm64") {
defines += [ "WEBRTC_ARCH_ARM64" ]
defines += [ "WEBRTC_HAS_NEON" ]
}
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index c40244010d..36fdd98753 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -109,7 +109,8 @@ class ChannelReceive : public ChannelReceiveInterface,
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
~ChannelReceive() override;
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
defines += [ "WEBRTC_ARCH_ARM" ]
if (arm_version >= 7) {
defines += [ "WEBRTC_ARCH_ARM_V7" ]
@@ -466,7 +466,7 @@ config("common_config") {
}
}
void SetSink(AudioSinkInterface* sink) override;
@@ -553,7 +554,8 @@ ChannelReceive::ChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer)
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer)
: env_(env),
worker_thread_(TaskQueueBase::Current()),
rtp_receive_statistics_(ReceiveStatistics::Create(&env_.clock())),
@@ -591,6 +593,7 @@ ChannelReceive::ChannelReceive(
configuration.local_media_ssrc = local_ssrc;
configuration.rtcp_packet_type_counter_observer = this;
configuration.non_sender_rtt_measurement = enable_non_sender_rtt;
+ configuration.rtcp_event_observer = rtcp_event_observer;
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
defines += [ "MIPS32_LE" ]
if (mips_float_abi == "hard") {
defines += [ "MIPS_FPU_LE" ]
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index 66895ccd0e..f6d06f6ad9 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -66,7 +66,7 @@ rtc_library("common_audio") {
deps += [ ":common_audio_neon" ]
}
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -88,7 +88,7 @@ rtc_source_set("mock_common_audio") {
rtc_source_set("common_audio_c_arm_asm") {
sources = []
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "signal_processing/complex_bit_reverse_arm.S" ]
if (arm_version >= 7) {
@@ -152,7 +152,7 @@ rtc_library("common_audio_c") {
"vad/webrtc_vad.c",
]
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [
"signal_processing/complex_bit_reverse_mips.c",
"signal_processing/complex_fft_mips.c",
@@ -170,7 +170,7 @@ rtc_library("common_audio_c") {
sources += [ "signal_processing/complex_fft.c" ]
}
- if (current_cpu != "arm" && current_cpu != "mipsel") {
+ if (target_cpu != "arm" && target_cpu != "mipsel") {
sources += [
"signal_processing/complex_bit_reverse.c",
"signal_processing/filter_ar_fast_q12.c",
@@ -231,7 +231,7 @@ rtc_library("fir_filter_factory") {
"../rtc_base/system:arch",
"../system_wrappers",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":common_audio_sse2" ]
deps += [ ":common_audio_avx2" ]
}
@@ -240,7 +240,7 @@ rtc_library("fir_filter_factory") {
}
if (frame_transformer)
InitFrameTransformerDelegate(std::move(frame_transformer));
@@ -1213,13 +1216,14 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer) {
return std::make_unique<ChannelReceive>(
env, neteq_factory, audio_device_module, rtcp_send_transport, local_ssrc,
remote_ssrc, jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, enable_non_sender_rtt, decoder_factory,
codec_pair_id, std::move(frame_decryptor), crypto_options,
- std::move(frame_transformer));
+ std::move(frame_transformer), rtcp_event_observer);
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("common_audio_sse2") {
sources = [
"fir_filter_sse.cc",
@@ -289,7 +289,7 @@ if (rtc_build_with_neon) {
"resampler/sinc_resampler_neon.cc",
]
} // namespace voe
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 4e2048daac..bebafc12a7 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -29,6 +29,7 @@
#include "call/rtp_packet_sink_interface.h"
#include "call/syncable.h"
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/source_tracker.h"
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
@@ -312,7 +312,7 @@ if (rtc_build_with_neon) {
"signal_processing/min_max_operations_neon.c",
]
// TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence
@@ -183,7 +184,8 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/common_audio/third_party/ooura/BUILD.gn b/common_audio/third_party/ooura/BUILD.gn
index 0cdf98e591..a0ddf777db 100644
--- a/common_audio/third_party/ooura/BUILD.gn
+++ b/common_audio/third_party/ooura/BUILD.gn
@@ -20,7 +20,7 @@ rtc_library("fft_size_128") {
]
cflags = []
} // namespace voe
} // namespace webrtc
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index d91e68caa9..3200c68817 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -21,6 +21,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_format.h"
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -126,6 +127,8 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
// See NackConfig for description.
NackConfig nack;
RtcpMode rtcp_mode = RtcpMode::kCompound;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
sources += [
"fft_size_128/ooura_fft_sse2.cc",
"fft_size_128/ooura_fft_tables_neon_sse2.h",
@@ -38,14 +38,14 @@ rtc_library("fft_size_128") {
deps += [ "../../../common_audio" ]
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
- if (current_cpu == "mipsel" && mips_float_abi == "hard") {
+ if (target_cpu == "mipsel" && mips_float_abi == "hard") {
sources += [ "fft_size_128/ooura_fft_mips.cc" ]
// Receive-side RTT.
diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc
index c03b053113..04e34ff579 100644
--- a/call/video_receive_stream.cc
+++ b/call/video_receive_stream.cc
@@ -169,6 +169,8 @@ std::string VideoReceiveStreamInterface::Config::Rtp::ToString() const {
ss << pt << ", ";
}
ss << '}';
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
diff --git a/common_audio/third_party/spl_sqrt_floor/BUILD.gn b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
index ac862c65a8..e66ed2796e 100644
--- a/common_audio/third_party/spl_sqrt_floor/BUILD.gn
+++ b/common_audio/third_party/spl_sqrt_floor/BUILD.gn
@@ -12,11 +12,11 @@ rtc_library("spl_sqrt_floor") {
visibility = [ "../..:common_audio_c" ]
sources = [ "spl_sqrt_floor.h" ]
deps = []
- if (current_cpu == "arm") {
+ if (target_cpu == "arm") {
sources += [ "spl_sqrt_floor_arm.S" ]
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f68368567c..4b1bcc5227 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -22,6 +22,7 @@
#include <vector>
deps += [ "../../../rtc_base/system:asm_defines" ]
- } else if (current_cpu == "mipsel") {
+ } else if (target_cpu == "mipsel") {
sources += [ "spl_sqrt_floor_mips.c" ]
} else {
sources += [ "spl_sqrt_floor.c" ]
diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn
index 39e24c9324..411c0d27ca 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -123,7 +123,7 @@ rtc_library("aec3") {
]
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -267,6 +268,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// meta data is expected to be present in generic frame descriptor
// RTP header extension).
std::set<int> raw_payload_types;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
// Transport for outgoing packets (RTCP).
diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
index eb4d1d019c..2bdfe53ab9 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -184,6 +184,14 @@ class NetworkLinkRtcpObserver {
virtual void OnRttUpdate(Timestamp receive_time, TimeDelta rtt) {}
};
+class RtcpEventObserver {
+ public:
+ virtual void OnRtcpBye() = 0;
+ virtual void OnRtcpTimeout() = 0;
+
+ virtual ~RtcpEventObserver() {}
+};
+
// NOTE! `kNumMediaTypes` must be kept in sync with RtpPacketMediaType!
static constexpr size_t kNumMediaTypes = 5;
enum class RtpPacketMediaType : size_t {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 85c892767d..349a9a673e 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -168,6 +168,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(false, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -198,6 +199,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(true, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -811,6 +813,10 @@ bool RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) {
return false;
}
@@ -159,7 +159,7 @@ rtc_library("aec3") {
"//third_party/abseil-cpp/absl/strings:string_view",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (target_cpu == "x86" || target_cpu == "x64") {
deps += [ ":aec3_avx2" ]
}
}
@@ -249,7 +249,7 @@ rtc_source_set("fft_data") {
]
+ if (rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpBye();
+ }
+
// Clear our lists.
rtts_.erase(bye.sender_ssrc());
EraseIf(received_report_blocks_, [&](const auto& elem) {
@@ -1248,12 +1254,20 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
}
-if (current_cpu == "x86" || current_cpu == "x64") {
+if (target_cpu == "x86" || target_cpu == "x64") {
rtc_library("aec3_avx2") {
configs += [ "..:apm_debug_dump" ]
sources = [
diff --git a/modules/audio_processing/aecm/BUILD.gn b/modules/audio_processing/aecm/BUILD.gn
index 80f2901049..a77f04aba5 100644
--- a/modules/audio_processing/aecm/BUILD.gn
+++ b/modules/audio_processing/aecm/BUILD.gn
@@ -29,14 +29,14 @@ rtc_library("aecm_core") {
if (rtc_build_with_neon) {
sources += [ "aecm_core_neon.cc" ]
bool RTCPReceiver::RtcpRrTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ bool result = ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags += [ "-mfpu=neon" ]
}
}
bool RTCPReceiver::RtcpRrSequenceNumberTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_increased_sequence_number_,
+ bool result = ResetTimestampIfExpired(now, last_increased_sequence_number_,
report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
- if (current_cpu == "mipsel") {
+ if (target_cpu == "mipsel") {
sources += [ "aecm_core_mips.cc" ]
} else {
sources += [ "aecm_core_c.cc" ]
diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn
index f5bb27217a..b8363ad79e 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -82,7 +82,7 @@ rtc_library("legacy_agc") {
]
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 029fc3a5e2..33aa986e8b 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -371,6 +371,7 @@ class RTCPReceiver final {
RegisteredSsrcs registered_ssrcs_;
if (rtc_build_with_neon) {
- if (current_cpu != "arm64") {
+ if (target_cpu != "arm64") {
# Enable compilation for the NEON instruction set.
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index 47b9466a44..f99fe509d1 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -18,7 +18,7 @@ rtc_library("rnn_vad") {
]
NetworkLinkRtcpObserver* const network_link_rtcp_observer_;
+ RtcpEventObserver* const rtcp_event_observer_;
RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
NetworkStateEstimateObserver* const network_state_estimate_observer_;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index cba11f2b26..236179a906 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -75,6 +75,9 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// bandwidth estimation related message.
NetworkLinkRtcpObserver* network_link_rtcp_observer = nullptr;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/audio_processing/ns/BUILD.gn b/modules/audio_processing/ns/BUILD.gn
index 31ad61156d..6587fd14f3 100644
--- a/modules/audio_processing/ns/BUILD.gn
+++ b/modules/audio_processing/ns/BUILD.gn
@@ -43,7 +43,7 @@ rtc_static_library("ns") {
]
+ // Called when we receive a RTCP bye or timeout
+ RtcpEventObserver* rtcp_event_observer = nullptr;
+
NetworkStateEstimateObserver* network_state_estimate_observer = nullptr;
defines = []
- if (rtc_build_with_neon && current_cpu != "arm64") {
+ if (rtc_build_with_neon && target_cpu != "arm64") {
suppressed_configs += [ "//build/config/compiler:compiler_arm_fpu" ]
cflags = [ "-mfpu=neon" ]
}
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index e39700419d..1047f30ee4 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -10,7 +10,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ui.gni")
import("../../webrtc.gni")
// DEPRECATED, transport_feedback_callback is no longer invoked by the RTP
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 23c3d3f6eb..931c29d8c8 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -82,7 +82,8 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
bool non_sender_rtt_measurement,
- uint32_t local_ssrc) {
+ uint32_t local_ssrc,
+ RtcpEventObserver* rtcp_event_observer) {
RtpRtcpInterface::Configuration configuration;
configuration.audio = false;
configuration.receiver_only = true;
@@ -93,6 +94,7 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
rtcp_packet_type_counter_observer;
configuration.rtcp_cname_callback = rtcp_cname_callback;
configuration.local_media_ssrc = local_ssrc;
+ configuration.rtcp_event_observer = rtcp_event_observer;
configuration.non_sender_rtt_measurement = non_sender_rtt_measurement;
-use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
+use_desktop_capture_differ_sse2 = target_cpu == "x86" || target_cpu == "x64"
config("x11_config") {
if (rtc_use_x11_extensions) {
diff --git a/webrtc.gni b/webrtc.gni
index 98c1dd279f..156c3d3985 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -172,13 +172,13 @@ declare_args() {
# Selects fixed-point code where possible.
rtc_prefer_fixed_point = false
- if (current_cpu == "arm" || current_cpu == "arm64") {
+ if (target_cpu == "arm" || target_cpu == "arm64") {
rtc_prefer_fixed_point = true
}
# Determines whether NEON code will be built.
rtc_build_with_neon =
- (current_cpu == "arm" && arm_use_neon) || current_cpu == "arm64"
+ (target_cpu == "arm" && arm_use_neon) || target_cpu == "arm64"
# Enable this to build OpenH264 encoder/FFmpeg decoder. This is supported on
# all platforms except Android and iOS. Because FFmpeg can be built
auto rtp_rtcp = std::make_unique<ModuleRtpRtcpImpl2>(env, configuration);
@@ -266,7 +268,8 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
rtcp_packet_type_counter_observer,
rtcp_cname_callback,
config_.rtp.rtcp_xr.receiver_reference_time_report,
- config_.rtp.local_ssrc)),
+ config_.rtp.local_ssrc,
+ config_.rtp.rtcp_event_observer)),
nack_periodic_processor_(nack_periodic_processor),
complete_frame_callback_(complete_frame_callback),
keyframe_request_method_(config_.rtp.keyframe_method),

View File

@ -1,300 +1,29 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 19 Feb 2021 15:56:00 -0600
Subject: Bug 1654112 - Get RTCP BYE and RTP timeout handling working again
(from Bug 1595479) r=mjf,dminor
Date: Fri, 12 Mar 2021 08:53:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Init some stats that were being
passed to us uninitialized. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D106145
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0b311007c033e83824f5f6996a70ab9e870f31f
Differential Revision: https://phabricator.services.mozilla.com/D108673
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c385bb870413b925af48df97aa1f2b80a26e78d2
---
audio/audio_receive_stream.cc | 4 +++-
audio/channel_receive.cc | 12 ++++++++----
audio/channel_receive.h | 4 +++-
call/audio_receive_stream.h | 3 +++
call/video_receive_stream.cc | 2 ++
call/video_receive_stream.h | 3 +++
modules/rtp_rtcp/include/rtp_rtcp_defines.h | 8 ++++++++
modules/rtp_rtcp/source/rtcp_receiver.cc | 18 ++++++++++++++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 3 +++
video/rtp_video_stream_receiver2.cc | 7 +++++--
11 files changed, 55 insertions(+), 10 deletions(-)
call/video_receive_stream.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 269c85103b..319b56a08d 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -43,6 +43,8 @@ std::string AudioReceiveStreamInterface::Config::Rtp::ToString() const {
<< (rtcp_mode == RtcpMode::kCompound
? "compound"
: (rtcp_mode == RtcpMode::kReducedSize ? "reducedSize" : "off"));
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
@@ -76,7 +78,7 @@ std::unique_ptr<voe::ChannelReceiveInterface> CreateChannelReceive(
config.jitter_buffer_min_delay_ms, config.enable_non_sender_rtt,
config.decoder_factory, config.codec_pair_id,
std::move(config.frame_decryptor), config.crypto_options,
- std::move(config.frame_transformer));
+ std::move(config.frame_transformer), config.rtp.rtcp_event_observer);
}
} // namespace
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index c40244010d..36fdd98753 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -109,7 +109,8 @@ class ChannelReceive : public ChannelReceiveInterface,
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
~ChannelReceive() override;
void SetSink(AudioSinkInterface* sink) override;
@@ -553,7 +554,8 @@ ChannelReceive::ChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer)
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer)
: env_(env),
worker_thread_(TaskQueueBase::Current()),
rtp_receive_statistics_(ReceiveStatistics::Create(&env_.clock())),
@@ -591,6 +593,7 @@ ChannelReceive::ChannelReceive(
configuration.local_media_ssrc = local_ssrc;
configuration.rtcp_packet_type_counter_observer = this;
configuration.non_sender_rtt_measurement = enable_non_sender_rtt;
+ configuration.rtcp_event_observer = rtcp_event_observer;
if (frame_transformer)
InitFrameTransformerDelegate(std::move(frame_transformer));
@@ -1213,13 +1216,14 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer) {
return std::make_unique<ChannelReceive>(
env, neteq_factory, audio_device_module, rtcp_send_transport, local_ssrc,
remote_ssrc, jitter_buffer_max_packets, jitter_buffer_fast_playout,
jitter_buffer_min_delay_ms, enable_non_sender_rtt, decoder_factory,
codec_pair_id, std::move(frame_decryptor), crypto_options,
- std::move(frame_transformer));
+ std::move(frame_transformer), rtcp_event_observer);
}
} // namespace voe
diff --git a/audio/channel_receive.h b/audio/channel_receive.h
index 4e2048daac..bebafc12a7 100644
--- a/audio/channel_receive.h
+++ b/audio/channel_receive.h
@@ -29,6 +29,7 @@
#include "call/rtp_packet_sink_interface.h"
#include "call/syncable.h"
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/source_tracker.h"
// TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence
@@ -183,7 +184,8 @@ std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
std::optional<AudioCodecPairId> codec_pair_id,
rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor,
const webrtc::CryptoOptions& crypto_options,
- rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
+ RtcpEventObserver* rtcp_event_observer);
} // namespace voe
} // namespace webrtc
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index d91e68caa9..3200c68817 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -21,6 +21,7 @@
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/audio_format.h"
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -126,6 +127,8 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
// See NackConfig for description.
NackConfig nack;
RtcpMode rtcp_mode = RtcpMode::kCompound;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
// Receive-side RTT.
diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc
index c03b053113..04e34ff579 100644
--- a/call/video_receive_stream.cc
+++ b/call/video_receive_stream.cc
@@ -169,6 +169,8 @@ std::string VideoReceiveStreamInterface::Config::Rtp::ToString() const {
ss << pt << ", ";
}
ss << '}';
+ ss << ", rtcp_event_observer: "
+ << (rtcp_event_observer ? "(rtcp_event_observer)" : "nullptr");
ss << '}';
return ss.str();
}
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index f68368567c..4b1bcc5227 100644
index 4b1bcc5227..ef23484414 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -22,6 +22,7 @@
#include <vector>
@@ -170,9 +170,10 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
#include "api/call/transport.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
#include "api/frame_transformer_interface.h"
@@ -267,6 +268,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// meta data is expected to be present in generic frame descriptor
// RTP header extension).
std::set<int> raw_payload_types;
+
+ RtcpEventObserver* rtcp_event_observer = nullptr;
} rtp;
- uint32_t rtcp_sender_packets_sent;
- uint32_t rtcp_sender_octets_sent;
- int64_t rtcp_sender_ntp_timestamp_ms;
+ // Mozilla modification: Init these three.
+ uint32_t rtcp_sender_packets_sent = 0;
+ uint32_t rtcp_sender_octets_sent = 0;
+ int64_t rtcp_sender_ntp_timestamp_ms = 0;
// Transport for outgoing packets (RTCP).
diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
index eb4d1d019c..2bdfe53ab9 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -184,6 +184,14 @@ class NetworkLinkRtcpObserver {
virtual void OnRttUpdate(Timestamp receive_time, TimeDelta rtt) {}
};
+class RtcpEventObserver {
+ public:
+ virtual void OnRtcpBye() = 0;
+ virtual void OnRtcpTimeout() = 0;
+
+ virtual ~RtcpEventObserver() {}
+};
+
// NOTE! `kNumMediaTypes` must be kept in sync with RtpPacketMediaType!
static constexpr size_t kNumMediaTypes = 5;
enum class RtpPacketMediaType : size_t {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 85c892767d..349a9a673e 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -168,6 +168,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(false, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -198,6 +199,7 @@ RTCPReceiver::RTCPReceiver(const Environment& env,
rtp_rtcp_(owner),
registered_ssrcs_(true, config),
network_link_rtcp_observer_(config.network_link_rtcp_observer),
+ rtcp_event_observer_(config.rtcp_event_observer),
rtcp_intra_frame_observer_(config.intra_frame_callback),
rtcp_loss_notification_observer_(config.rtcp_loss_notification_observer),
network_state_estimate_observer_(config.network_state_estimate_observer),
@@ -811,6 +813,10 @@ bool RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) {
return false;
}
+ if (rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpBye();
+ }
+
// Clear our lists.
rtts_.erase(bye.sender_ssrc());
EraseIf(received_report_blocks_, [&](const auto& elem) {
@@ -1248,12 +1254,20 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
}
bool RTCPReceiver::RtcpRrTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ bool result = ResetTimestampIfExpired(now, last_received_rb_, report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
bool RTCPReceiver::RtcpRrSequenceNumberTimeoutLocked(Timestamp now) {
- return ResetTimestampIfExpired(now, last_increased_sequence_number_,
+ bool result = ResetTimestampIfExpired(now, last_increased_sequence_number_,
report_interval_);
+ if (result && rtcp_event_observer_) {
+ rtcp_event_observer_->OnRtcpTimeout();
+ }
+ return result;
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 029fc3a5e2..33aa986e8b 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -371,6 +371,7 @@ class RTCPReceiver final {
RegisteredSsrcs registered_ssrcs_;
NetworkLinkRtcpObserver* const network_link_rtcp_observer_;
+ RtcpEventObserver* const rtcp_event_observer_;
RtcpIntraFrameObserver* const rtcp_intra_frame_observer_;
RtcpLossNotificationObserver* const rtcp_loss_notification_observer_;
NetworkStateEstimateObserver* const network_state_estimate_observer_;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index cba11f2b26..236179a906 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -75,6 +75,9 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// bandwidth estimation related message.
NetworkLinkRtcpObserver* network_link_rtcp_observer = nullptr;
+ // Called when we receive a RTCP bye or timeout
+ RtcpEventObserver* rtcp_event_observer = nullptr;
+
NetworkStateEstimateObserver* network_state_estimate_observer = nullptr;
// DEPRECATED, transport_feedback_callback is no longer invoked by the RTP
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 23c3d3f6eb..931c29d8c8 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -82,7 +82,8 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
bool non_sender_rtt_measurement,
- uint32_t local_ssrc) {
+ uint32_t local_ssrc,
+ RtcpEventObserver* rtcp_event_observer) {
RtpRtcpInterface::Configuration configuration;
configuration.audio = false;
configuration.receiver_only = true;
@@ -93,6 +94,7 @@ std::unique_ptr<ModuleRtpRtcpImpl2> CreateRtpRtcpModule(
rtcp_packet_type_counter_observer;
configuration.rtcp_cname_callback = rtcp_cname_callback;
configuration.local_media_ssrc = local_ssrc;
+ configuration.rtcp_event_observer = rtcp_event_observer;
configuration.non_sender_rtt_measurement = non_sender_rtt_measurement;
auto rtp_rtcp = std::make_unique<ModuleRtpRtcpImpl2>(env, configuration);
@@ -266,7 +268,8 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
rtcp_packet_type_counter_observer,
rtcp_cname_callback,
config_.rtp.rtcp_xr.receiver_reference_time_report,
- config_.rtp.local_ssrc)),
+ config_.rtp.local_ssrc,
+ config_.rtp.rtcp_event_observer)),
nack_periodic_processor_(nack_periodic_processor),
complete_frame_callback_(complete_frame_callback),
keyframe_request_method_(config_.rtp.keyframe_method),
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.

View File

@ -1,29 +1,73 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Mar 2021 08:53:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Init some stats that were being
passed to us uninitialized. r=ng
Date: Fri, 12 Mar 2021 08:55:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Surface video RTCP SR stats
again. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D108673
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c385bb870413b925af48df97aa1f2b80a26e78d2
libwebrtc has stopped surfacing these, and Chromium does not support
these stats at all.
Differential Revision: https://phabricator.services.mozilla.com/D108674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/edac9d01a9ac7594f4b22708a4690753638ca32c
---
call/video_receive_stream.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
video/rtp_video_stream_receiver2.cc | 10 ++++++++++
video/rtp_video_stream_receiver2.h | 6 ++++++
video/video_receive_stream2.cc | 8 ++++++++
3 files changed, 24 insertions(+)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 4b1bcc5227..ef23484414 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,9 +170,10 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 931c29d8c8..a3e3239225 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1040,6 +1040,16 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
return std::nullopt;
}
- uint32_t rtcp_sender_packets_sent;
- uint32_t rtcp_sender_octets_sent;
- int64_t rtcp_sender_ntp_timestamp_ms;
+ // Mozilla modification: Init these three.
+ uint32_t rtcp_sender_packets_sent = 0;
+ uint32_t rtcp_sender_octets_sent = 0;
+ int64_t rtcp_sender_ntp_timestamp_ms = 0;
+// Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+// stats at all, and even on the most recent libwebrtc code there does not
+// seem to be any support for these stats right now. So, we hack this in.
+void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+}
+
std::optional<RtpRtcpInterface::SenderReportStats>
RtpVideoStreamReceiver2::GetSenderReportStats() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 141f15c3df..0fb3cd1b7c 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -211,6 +211,12 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::optional<RtpRtcpInterface::SenderReportStats> GetSenderReportStats()
const;
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
+
private:
// Implements RtpVideoFrameReceiver.
void ManageFrame(std::unique_ptr<RtpFrameObject> frame) override;
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index 4372fdabdd..a655a072c4 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -578,6 +578,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
}
+
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
+ &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
+ &stats.rtcp_sender_ntp_timestamp_ms);
+
return stats;
}
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.

View File

@ -1,73 +1,35 @@
From: "Byron Campen [:bwc]" <docfaraday@gmail.com>
Date: Fri, 12 Mar 2021 08:55:00 -0600
Subject: Bug 1654112 - libwebrtc modification: Surface video RTCP SR stats
again. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Mon, 26 Jul 2021 22:51:00 -0700
Subject: Bug 1654112 - fix timestamp issues with RTP sources; r=mjf
libwebrtc has stopped surfacing these, and Chromium does not support
these stats at all.
Differential Revision: https://phabricator.services.mozilla.com/D108674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/edac9d01a9ac7594f4b22708a4690753638ca32c
Differential Revision: https://phabricator.services.mozilla.com/D120930
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/de8c14e4972f717bf937b6f2fffcd08c35e21ced
---
video/rtp_video_stream_receiver2.cc | 10 ++++++++++
video/rtp_video_stream_receiver2.h | 6 ++++++
video/video_receive_stream2.cc | 8 ++++++++
3 files changed, 24 insertions(+)
modules/rtp_rtcp/source/source_tracker.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 931c29d8c8..a3e3239225 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1040,6 +1040,16 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
return std::nullopt;
}
diff --git a/modules/rtp_rtcp/source/source_tracker.cc b/modules/rtp_rtcp/source/source_tracker.cc
index 17862148eb..4d0e8b6ad4 100644
--- a/modules/rtp_rtcp/source/source_tracker.cc
+++ b/modules/rtp_rtcp/source/source_tracker.cc
@@ -36,7 +36,8 @@ void SourceTracker::OnFrameDelivered(const RtpPacketInfos& packet_infos,
SourceKey key(RtpSourceType::CSRC, csrc);
SourceEntry& entry = UpdateEntry(key);
+// Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+// stats at all, and even on the most recent libwebrtc code there does not
+// seem to be any support for these stats right now. So, we hack this in.
+void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const {
+ RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+}
+
std::optional<RtpRtcpInterface::SenderReportStats>
RtpVideoStreamReceiver2::GetSenderReportStats() const {
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 141f15c3df..0fb3cd1b7c 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -211,6 +211,12 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::optional<RtpRtcpInterface::SenderReportStats> GetSenderReportStats()
const;
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
+ int64_t* ntp_timestamp_ms) const;
+
private:
// Implements RtpVideoFrameReceiver.
void ManageFrame(std::unique_ptr<RtpFrameObject> frame) override;
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index 4372fdabdd..a655a072c4 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -578,6 +578,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
- entry.timestamp = delivery_time;
+ const auto packet_time = packet_info.receive_time();
+ entry.timestamp = packet_time.ms() ? packet_time : delivery_time;
entry.audio_level = packet_info.audio_level();
entry.absolute_capture_time = packet_info.absolute_capture_time();
entry.local_capture_clock_offset =
@@ -73,6 +74,10 @@ std::vector<RtpSource> SourceTracker::GetSources() const {
.local_capture_clock_offset = entry.local_capture_clock_offset});
}
+ std::sort(sources.begin(), sources.end(), [](const auto &a, const auto &b){
+ return a.timestamp().ms() > b.timestamp().ms();
+ });
+
+ // Mozilla modification: VideoReceiveStream2 and friends do not surface RTCP
+ // stats at all, and even on the most recent libwebrtc code there does not
+ // seem to be any support for these stats right now. So, we hack this in.
+ rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
+ &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
+ &stats.rtcp_sender_ntp_timestamp_ms);
+
return stats;
return sources;
}

View File

@ -1,35 +1,29 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Mon, 26 Jul 2021 22:51:00 -0700
Subject: Bug 1654112 - fix timestamp issues with RTP sources; r=mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 20 Aug 2021 13:52:00 +0200
Subject: Bug 1654112 - Don't check the calling thread in
webrtc::AudioReceiveStream::GetSources. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D120930
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/de8c14e4972f717bf937b6f2fffcd08c35e21ced
source_tracker_ is thread safe with its own internal mutex, so this call is safe
as long as the caller has a guarantee for the lifetime of the
AudioReceiveStream. This is similar to webrtc::VideoReceiveStream.
Upliftable.
Differential Revision: https://phabricator.services.mozilla.com/D123226
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c186df8a088e46285a15e40149182daa34cc6805
---
modules/rtp_rtcp/source/source_tracker.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
audio/audio_receive_stream.cc | 1 -
1 file changed, 1 deletion(-)
diff --git a/modules/rtp_rtcp/source/source_tracker.cc b/modules/rtp_rtcp/source/source_tracker.cc
index 17862148eb..4d0e8b6ad4 100644
--- a/modules/rtp_rtcp/source/source_tracker.cc
+++ b/modules/rtp_rtcp/source/source_tracker.cc
@@ -36,7 +36,8 @@ void SourceTracker::OnFrameDelivered(const RtpPacketInfos& packet_infos,
SourceKey key(RtpSourceType::CSRC, csrc);
SourceEntry& entry = UpdateEntry(key);
- entry.timestamp = delivery_time;
+ const auto packet_time = packet_info.receive_time();
+ entry.timestamp = packet_time.ms() ? packet_time : delivery_time;
entry.audio_level = packet_info.audio_level();
entry.absolute_capture_time = packet_info.absolute_capture_time();
entry.local_capture_clock_offset =
@@ -73,6 +74,10 @@ std::vector<RtpSource> SourceTracker::GetSources() const {
.local_capture_clock_offset = entry.local_capture_clock_offset});
}
+ std::sort(sources.begin(), sources.end(), [](const auto &a, const auto &b){
+ return a.timestamp().ms() > b.timestamp().ms();
+ });
+
return sources;
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 319b56a08d..db64445699 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -369,7 +369,6 @@ int AudioReceiveStreamImpl::GetBaseMinimumPlayoutDelayMs() const {
}
std::vector<RtpSource> AudioReceiveStreamImpl::GetSources() const {
- RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetSources();
}

View File

@ -1,29 +1,828 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 20 Aug 2021 13:52:00 +0200
Subject: Bug 1654112 - Don't check the calling thread in
webrtc::AudioReceiveStream::GetSources. r=ng
From: Paul Adenot <paul@paul.cx>
Date: Fri, 18 Aug 2023 13:13:36 -0500
Subject: Bug 1714577 - Part 6 - Copy WebRTC's trace_event.h to Gecko,
verbatim, and redirect the original trace_event.h to it. r=gerald
source_tracker_ is thread safe with its own internal mutex, so this call is safe
as long as the caller has a guarantee for the lifetime of the
AudioReceiveStream. This is similar to webrtc::VideoReceiveStream.
Upliftable.
Differential Revision: https://phabricator.services.mozilla.com/D123226
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c186df8a088e46285a15e40149182daa34cc6805
Differential Revision: https://phabricator.services.mozilla.com/D116843
---
audio/audio_receive_stream.cc | 1 -
1 file changed, 1 deletion(-)
rtc_base/trace_event.h | 813 +----------------------------------------
1 file changed, 3 insertions(+), 810 deletions(-)
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 319b56a08d..db64445699 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -369,7 +369,6 @@ int AudioReceiveStreamImpl::GetBaseMinimumPlayoutDelayMs() const {
}
std::vector<RtpSource> AudioReceiveStreamImpl::GetSources() const {
- RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return channel_receive_->GetSources();
}
diff --git a/rtc_base/trace_event.h b/rtc_base/trace_event.h
index 3329abd66c..b34df0c93f 100644
--- a/rtc_base/trace_event.h
+++ b/rtc_base/trace_event.h
@@ -1,810 +1,3 @@
-/*
- * 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 RTC_BASE_TRACE_EVENT_H_
-#define RTC_BASE_TRACE_EVENT_H_
-
-#if defined(RTC_DISABLE_TRACE_EVENTS)
-#define RTC_TRACE_EVENTS_ENABLED 0
-#else
-#define RTC_TRACE_EVENTS_ENABLED 1
-#endif
-
-// IWYU pragma: begin_exports
-#if defined(RTC_USE_PERFETTO)
-#include "rtc_base/trace_categories.h"
-#endif
-#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
-#include "third_party/perfetto/include/perfetto/tracing/track.h"
-#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
-// IWYU pragma: end_exports
-
-#if !defined(RTC_USE_PERFETTO)
-#include <string>
-
-#include "rtc_base/event_tracer.h"
-
-#define RTC_NOOP() \
- do { \
- } while (0)
-
-// TODO(b/42226290): Add implementation for these events with Perfetto.
-#define TRACE_EVENT_BEGIN(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_END(category, ...) RTC_NOOP();
-#define TRACE_EVENT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_INSTANT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_CATEGORY_ENABLED(category) RTC_NOOP();
-#define TRACE_COUNTER(category, track, ...) RTC_NOOP();
-
-// Type values for identifying types in the TraceValue union.
-#define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
-#define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
-#define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
-#define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
-#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
-#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
-#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
-
-#if defined(TRACE_EVENT0)
-#error "Another copy of trace_event.h has already been included."
-#endif
-
-#if RTC_TRACE_EVENTS_ENABLED
-
-// Extracted from Chromium's src/base/debug/trace_event.h.
-
-// This header is designed to give you trace_event macros without specifying
-// how the events actually get collected and stored. If you need to expose trace
-// event to some other universe, you can copy-and-paste this file,
-// implement the TRACE_EVENT_API macros, and do any other necessary fixup for
-// the target platform. The end result is that multiple libraries can funnel
-// events through to a shared trace event collector.
-
-// Trace events are for tracking application performance and resource usage.
-// Macros are provided to track:
-// Begin and end of function calls
-// Counters
-//
-// Events are issued against categories. Whereas RTC_LOG's
-// categories are statically defined, TRACE categories are created
-// implicitly with a string. For example:
-// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
-//
-// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
-// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
-// doSomethingCostly()
-// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
-// Note: our tools can't always determine the correct BEGIN/END pairs unless
-// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
-// need them to be in separate scopes.
-//
-// A common use case is to trace entire function scopes. This
-// issues a trace BEGIN and END automatically:
-// void doSomethingCostly() {
-// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
-// ...
-// }
-//
-// Additional parameters can be associated with an event:
-// void doSomethingCostly2(int howMuch) {
-// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
-// "howMuch", howMuch);
-// ...
-// }
-//
-// The trace system will automatically add to this information the
-// current process id, thread id, and a timestamp in microseconds.
-//
-// To trace an asynchronous procedure such as an IPC send/receive, use
-// ASYNC_BEGIN and ASYNC_END:
-// [single threaded sender code]
-// static int send_count = 0;
-// ++send_count;
-// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
-// Send(new MyMessage(send_count));
-// [receive code]
-// void OnMyMessage(send_count) {
-// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
-// }
-// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
-// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
-// Pointers can be used for the ID parameter, and they will be mangled
-// internally so that the same pointer on two different processes will not
-// match. For example:
-// class MyTracedClass {
-// public:
-// MyTracedClass() {
-// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
-// }
-// ~MyTracedClass() {
-// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
-// }
-// }
-//
-// Trace event also supports counters, which is a way to track a quantity
-// as it varies over time. Counters are created with the following macro:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
-//
-// Counters are process-specific. The macro itself can be issued from any
-// thread, however.
-//
-// Sometimes, you want to track two counters at once. You can do this with two
-// counter macros:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
-// Or you can do it with a combined macro:
-// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
-// "bytesPinned", g_myCounterValue[0],
-// "bytesAllocated", g_myCounterValue[1]);
-// This indicates to the tracing UI that these counters should be displayed
-// in a single graph, as a summed area chart.
-//
-// Since counters are in a global namespace, you may want to disembiguate with a
-// unique ID, by using the TRACE_COUNTER_ID* variations.
-//
-// By default, trace collection is compiled in, but turned off at runtime.
-// Collecting trace data is the responsibility of the embedding
-// application. In Chrome's case, navigating to about:tracing will turn on
-// tracing and display data collected across all active processes.
-//
-// When are string argument values copied:
-// const char* arg_values are only referenced by default:
-// TRACE_EVENT1("category", "name",
-// "arg1", "literal string is only referenced");
-// Use TRACE_STR_COPY to force copying of a const char*:
-// TRACE_EVENT1("category", "name",
-// "arg1", TRACE_STR_COPY("string will be copied"));
-// std::string arg_values are always copied:
-// TRACE_EVENT1("category", "name",
-// "arg1", std::string("string will be copied"));
-//
-//
-// Thread Safety:
-// Thread safety is provided by methods defined in event_tracer.h. See the file
-// for details.
-
-// By default, const char* argument values are assumed to have long-lived scope
-// and will not be copied. Use this macro to force a const char* to be copied.
-#define TRACE_STR_COPY(str) \
- webrtc::trace_event_internal::TraceStringWithCopy(str)
-
-// This will mark the trace event as disabled by default. The user will need
-// to explicitly enable the event.
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-// By default, uint64 ID argument values are not mangled with the Process ID in
-// TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
-#define TRACE_ID_MANGLE(id) \
- webrtc::trace_event_internal::TraceID::ForceMangle(id)
-
-// Records a pair of begin and end events called "name" for the current
-// scope, with 0, 1 or 2 associated arguments. If the category is not
-// enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT0(category, name) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name)
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val)
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Enum reflecting the scope of an INSTANT event. Must fit within
-// TRACE_EVENT_FLAG_SCOPE_MASK.
-static constexpr uint8_t TRACE_EVENT_SCOPE_GLOBAL = 0u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_PROCESS = 1u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_THREAD = 2u << 2;
-
-// Records a single event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_INSTANT0(category, name, scope) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_BEGIN0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_END0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER1(category, name, value) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID1(category, name, id, value) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
-// events are considered to match if their category, name and id values all
-// match. `id` must either be a pointer or an integer value up to 64 bits. If
-// it's a pointer, the bits will be xored with a hash of the process ID so
-// that the same pointer on two different processes will not collide.
-// An asynchronous operation can consist of multiple phases. The first phase is
-// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
-// ASYNC_STEP macros. When the operation completes, call ASYNC_END.
-// An ASYNC trace typically occur on a single thread (if not, they will only be
-// drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
-// operation must use the same `name` and `id`. Each event can have its own
-// args.
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-// Records a single ASYNC_STEP event for `step` immediately. If the category
-// is not enabled, then this does nothing. The `name` and `id` must match the
-// ASYNC_BEGIN event above. The `step` param identifies this step within the
-// async event. This should be called at the beginning of the next phase of an
-// asynchronous operation.
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step)
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step, arg1_name, arg1_val)
-
-// Records a single ASYNC_END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-#define TRACE_EVENT_ASYNC_END0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-////////////////////////////////////////////////////////////////////////////////
-// Implementation specific tracing API definitions.
-
-// Get a pointer to the enabled state of the given trace category. Only
-// long-lived literal strings should be given as the category name. The returned
-// pointer can be held permanently in a local static for example. If the
-// unsigned char is non-zero, tracing is enabled. If tracing is enabled,
-// TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
-// between the load of the tracing state and the call to
-// TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
-// for best performance when tracing is disabled.
-// const unsigned char*
-// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
- webrtc::EventTracer::GetCategoryEnabled
-
-// Add a trace event to the platform tracing system.
-// void TRACE_EVENT_API_ADD_TRACE_EVENT(
-// char phase,
-// const unsigned char* category_enabled,
-// const char* name,
-// unsigned long long id,
-// int num_args,
-// const char** arg_names,
-// const unsigned char* arg_types,
-// const unsigned long long* arg_values,
-// unsigned char flags)
-#define TRACE_EVENT_API_ADD_TRACE_EVENT webrtc::EventTracer::AddTraceEvent
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Implementation detail: trace event macros create temporary variables
-// to keep instrumentation overhead low. These macros give each temporary
-// variable a unique name based on the line number to prevent name collissions.
-#define INTERNAL_TRACE_EVENT_UID3(a, b) trace_event_unique_##a##b
-#define INTERNAL_TRACE_EVENT_UID2(a, b) INTERNAL_TRACE_EVENT_UID3(a, b)
-#define INTERNAL_TRACE_EVENT_UID(name_prefix) \
- INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
-
-#if WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-#define INTERNAL_TRACE_EVENT_INFO_TYPE const unsigned char*
-#else
-#define INTERNAL_TRACE_EVENT_INFO_TYPE static const unsigned char*
-#endif // WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-
-// Implementation detail: internal macro to create static category.
-#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- INTERNAL_TRACE_EVENT_INFO_TYPE INTERNAL_TRACE_EVENT_UID(catstatic) = \
- TRACE_EVENT_API_GET_CATEGORY_ENABLED(category);
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Implementation detail: internal macro to create static category and add begin
-// event if the category is enabled. Also adds the end event when the scope
-// ends.
-#define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- webrtc::trace_event_internal::TraceEndOnScopeClose INTERNAL_TRACE_EVENT_UID( \
- profileScope); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- TRACE_EVENT_PHASE_BEGIN, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \
- ##__VA_ARGS__); \
- INTERNAL_TRACE_EVENT_UID(profileScope) \
- .Initialize(INTERNAL_TRACE_EVENT_UID(catstatic), name); \
- }
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \
- ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
- webrtc::trace_event_internal::TraceID trace_event_trace_id( \
- id, &trace_event_flags); \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- trace_event_trace_id.data(), trace_event_flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Notes regarding the following definitions:
-// New values can be added and propagated to third party libraries, but existing
-// definitions must never be changed, because third party libraries may use old
-// definitions.
-
-// Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
-#define TRACE_EVENT_PHASE_BEGIN ('B')
-#define TRACE_EVENT_PHASE_END ('E')
-#define TRACE_EVENT_PHASE_INSTANT ('I')
-#define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
-#define TRACE_EVENT_PHASE_ASYNC_STEP ('T')
-#define TRACE_EVENT_PHASE_ASYNC_END ('F')
-#define TRACE_EVENT_PHASE_METADATA ('M')
-#define TRACE_EVENT_PHASE_COUNTER ('C')
-
-// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
-#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
-#define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
-#define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
-
-namespace webrtc {
-namespace trace_event_internal {
-
-// Specify these values when the corresponding argument of AddTraceEvent is not
-// used.
-const int kZeroNumArgs = 0;
-const unsigned long long kNoEventId = 0;
-
-// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
-// are mangled with the Process ID so that they are unlikely to collide when the
-// same pointer is used on different processes.
-class TraceID {
- public:
- class ForceMangle {
- public:
- explicit ForceMangle(unsigned long long id) : data_(id) {}
- explicit ForceMangle(unsigned long id) : data_(id) {}
- explicit ForceMangle(unsigned int id) : data_(id) {}
- explicit ForceMangle(unsigned short id) : data_(id) {}
- explicit ForceMangle(unsigned char id) : data_(id) {}
- explicit ForceMangle(long long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(int id) : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(short id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(signed char id)
- : data_(static_cast<unsigned long long>(id)) {}
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
- };
-
- explicit TraceID(const void* id, unsigned char* flags)
- : data_(
- static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(id))) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(unsigned long long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned int id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned short id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned char id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(long long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(int id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(short id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(signed char id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
-};
-
-// Simple union to store various types as unsigned long long.
-union TraceValueUnion {
- bool as_bool;
- unsigned long long as_uint;
- long long as_int;
- double as_double;
- const void* as_pointer;
- const char* as_string;
-};
-
-// Simple container for const char* that should be copied instead of retained.
-class TraceStringWithCopy {
- public:
- explicit TraceStringWithCopy(const char* str) : str_(str) {}
- operator const char*() const { return str_; }
-
- private:
- const char* str_;
-};
-
-// Define SetTraceValue for each allowed type. It stores the type and
-// value in the return arguments. This allows this API to avoid declaring any
-// structures so that it is portable to third_party libraries.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, \
- value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- TraceValueUnion type_value; \
- type_value.union_member = arg; \
- *type = value_type_id; \
- *value = type_value.as_uint; \
- }
-// Simpler form for int types that can be safely casted.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- *type = value_type_id; \
- *value = static_cast<unsigned long long>(arg); \
- }
-
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL)
-INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const void*,
- as_pointer,
- TRACE_VALUE_TYPE_POINTER)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const char*,
- as_string,
- TRACE_VALUE_TYPE_STRING)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
- as_string,
- TRACE_VALUE_TYPE_COPY_STRING)
-
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
-
-// std::string version of SetTraceValue so that trace arguments can be strings.
-static inline void SetTraceValue(const std::string& arg,
- unsigned char* type,
- unsigned long long* value) {
- TraceValueUnion type_value;
- type_value.as_string = arg.c_str();
- *type = TRACE_VALUE_TYPE_COPY_STRING;
- *value = type_value.as_uint;
-}
-
-// These AddTraceEvent template functions are defined here instead of in the
-// macro, because the arg_values could be temporary objects, such as
-// std::string. In order to store pointers to the internal c_str and pass
-// through to the tracing API, the arg_values must live throughout
-// these procedures.
-
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id,
- kZeroNumArgs, nullptr, nullptr, nullptr,
- flags);
-}
-
-template <class ARG1_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val) {
- const int num_args = 1;
- unsigned char arg_types[1];
- unsigned long long arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- &arg1_name, arg_types, arg_values, flags);
-}
-
-template <class ARG1_TYPE, class ARG2_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val,
- const char* arg2_name,
- const ARG2_TYPE& arg2_val) {
- const int num_args = 2;
- const char* arg_names[2] = {arg1_name, arg2_name};
- unsigned char arg_types[2];
- unsigned long long arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- arg_names, arg_types, arg_values, flags);
-}
-
-// Used by TRACE_EVENTx macro. Do not use directly.
-class TraceEndOnScopeClose {
- public:
- // Note: members of data_ intentionally left uninitialized. See Initialize.
- TraceEndOnScopeClose() : p_data_(nullptr) {}
- ~TraceEndOnScopeClose() {
- if (p_data_)
- AddEventIfEnabled();
- }
-
- void Initialize(const unsigned char* category_enabled, const char* name) {
- data_.category_enabled = category_enabled;
- data_.name = name;
- p_data_ = &data_;
- }
-
- private:
- // Add the end event if the category is still enabled.
- void AddEventIfEnabled() {
- // Only called when p_data_ is non-null.
- if (*p_data_->category_enabled) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_END,
- p_data_->category_enabled, p_data_->name,
- kNoEventId, kZeroNumArgs, nullptr,
- nullptr, nullptr, TRACE_EVENT_FLAG_NONE);
- }
- }
-
- // This Data struct workaround is to avoid initializing all the members
- // in Data during construction of this object, since this object is always
- // constructed, even when tracing is disabled. If the members of Data were
- // members of this class instead, compiler warnings occur about potential
- // uninitialized accesses.
- struct Data {
- const unsigned char* category_enabled;
- const char* name;
- };
- Data* p_data_;
- Data data_;
-};
-
-} // namespace trace_event_internal
-} // namespace webrtc
-
-#else
-
-////////////////////////////////////////////////////////////////////////////////
-// This section defines no-op alternatives to the tracing macros when
-// RTC_DISABLE_TRACE_EVENTS is defined.
-
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-#define TRACE_ID_MANGLE(id) 0
-
-#define TRACE_EVENT0(category, name) RTC_NOOP()
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT0(category, name, scope) RTC_NOOP()
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_BEGIN0(category, name) RTC_NOOP()
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_END0(category, name) RTC_NOOP()
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER1(category, name, value) RTC_NOOP()
-
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER_ID1(category, name, id, value) RTC_NOOP()
-
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_END0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED ""
-
-#define TRACE_EVENT_API_ADD_TRACE_EVENT RTC_NOOP()
-
-#endif // RTC_TRACE_EVENTS_ENABLED
-#endif // RTC_USE_PERFETTO
-
-#endif // RTC_BASE_TRACE_EVENT_H_
+// This header is diverted to a similar header in Gecko, that is defining the
+// same macros, modified to talk to the Gecko Profiler.
+#include "GeckoTraceEvent.h"

View File

@ -1,828 +1,27 @@
From: Paul Adenot <paul@paul.cx>
Date: Fri, 18 Aug 2023 13:13:36 -0500
Subject: Bug 1714577 - Part 6 - Copy WebRTC's trace_event.h to Gecko,
verbatim, and redirect the original trace_event.h to it. r=gerald
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P6 - Restore PID recording post cherry-pick;r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D116843
This restores the code from P0, which was removed to make cherry-picking 439ffe462a66ad9fa9a251b265e4ab28c2647d25 and 449a78b1e20ea85b11f967cf3a184ee610ce21c3 easier.
Differential Revision: https://phabricator.services.mozilla.com/D129714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/72a83cb2e571023cd4150bbdef5be5455ce851f4
---
rtc_base/trace_event.h | 813 +----------------------------------------
1 file changed, 3 insertions(+), 810 deletions(-)
modules/desktop_capture/win/window_capture_utils.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/rtc_base/trace_event.h b/rtc_base/trace_event.h
index 3329abd66c..b34df0c93f 100644
--- a/rtc_base/trace_event.h
+++ b/rtc_base/trace_event.h
@@ -1,810 +1,3 @@
-/*
- * 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 RTC_BASE_TRACE_EVENT_H_
-#define RTC_BASE_TRACE_EVENT_H_
-
-#if defined(RTC_DISABLE_TRACE_EVENTS)
-#define RTC_TRACE_EVENTS_ENABLED 0
-#else
-#define RTC_TRACE_EVENTS_ENABLED 1
-#endif
-
-// IWYU pragma: begin_exports
-#if defined(RTC_USE_PERFETTO)
-#include "rtc_base/trace_categories.h"
-#endif
-#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
-#include "third_party/perfetto/include/perfetto/tracing/track.h"
-#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
-// IWYU pragma: end_exports
-
-#if !defined(RTC_USE_PERFETTO)
-#include <string>
-
-#include "rtc_base/event_tracer.h"
-
-#define RTC_NOOP() \
- do { \
- } while (0)
-
-// TODO(b/42226290): Add implementation for these events with Perfetto.
-#define TRACE_EVENT_BEGIN(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_END(category, ...) RTC_NOOP();
-#define TRACE_EVENT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_INSTANT(category, name, ...) RTC_NOOP();
-#define TRACE_EVENT_CATEGORY_ENABLED(category) RTC_NOOP();
-#define TRACE_COUNTER(category, track, ...) RTC_NOOP();
-
-// Type values for identifying types in the TraceValue union.
-#define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
-#define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
-#define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
-#define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
-#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
-#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
-#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
-
-#if defined(TRACE_EVENT0)
-#error "Another copy of trace_event.h has already been included."
-#endif
-
-#if RTC_TRACE_EVENTS_ENABLED
-
-// Extracted from Chromium's src/base/debug/trace_event.h.
-
-// This header is designed to give you trace_event macros without specifying
-// how the events actually get collected and stored. If you need to expose trace
-// event to some other universe, you can copy-and-paste this file,
-// implement the TRACE_EVENT_API macros, and do any other necessary fixup for
-// the target platform. The end result is that multiple libraries can funnel
-// events through to a shared trace event collector.
-
-// Trace events are for tracking application performance and resource usage.
-// Macros are provided to track:
-// Begin and end of function calls
-// Counters
-//
-// Events are issued against categories. Whereas RTC_LOG's
-// categories are statically defined, TRACE categories are created
-// implicitly with a string. For example:
-// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
-//
-// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
-// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
-// doSomethingCostly()
-// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
-// Note: our tools can't always determine the correct BEGIN/END pairs unless
-// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
-// need them to be in separate scopes.
-//
-// A common use case is to trace entire function scopes. This
-// issues a trace BEGIN and END automatically:
-// void doSomethingCostly() {
-// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
-// ...
-// }
-//
-// Additional parameters can be associated with an event:
-// void doSomethingCostly2(int howMuch) {
-// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
-// "howMuch", howMuch);
-// ...
-// }
-//
-// The trace system will automatically add to this information the
-// current process id, thread id, and a timestamp in microseconds.
-//
-// To trace an asynchronous procedure such as an IPC send/receive, use
-// ASYNC_BEGIN and ASYNC_END:
-// [single threaded sender code]
-// static int send_count = 0;
-// ++send_count;
-// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
-// Send(new MyMessage(send_count));
-// [receive code]
-// void OnMyMessage(send_count) {
-// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
-// }
-// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
-// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
-// Pointers can be used for the ID parameter, and they will be mangled
-// internally so that the same pointer on two different processes will not
-// match. For example:
-// class MyTracedClass {
-// public:
-// MyTracedClass() {
-// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
-// }
-// ~MyTracedClass() {
-// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
-// }
-// }
-//
-// Trace event also supports counters, which is a way to track a quantity
-// as it varies over time. Counters are created with the following macro:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
-//
-// Counters are process-specific. The macro itself can be issued from any
-// thread, however.
-//
-// Sometimes, you want to track two counters at once. You can do this with two
-// counter macros:
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
-// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
-// Or you can do it with a combined macro:
-// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
-// "bytesPinned", g_myCounterValue[0],
-// "bytesAllocated", g_myCounterValue[1]);
-// This indicates to the tracing UI that these counters should be displayed
-// in a single graph, as a summed area chart.
-//
-// Since counters are in a global namespace, you may want to disembiguate with a
-// unique ID, by using the TRACE_COUNTER_ID* variations.
-//
-// By default, trace collection is compiled in, but turned off at runtime.
-// Collecting trace data is the responsibility of the embedding
-// application. In Chrome's case, navigating to about:tracing will turn on
-// tracing and display data collected across all active processes.
-//
-// When are string argument values copied:
-// const char* arg_values are only referenced by default:
-// TRACE_EVENT1("category", "name",
-// "arg1", "literal string is only referenced");
-// Use TRACE_STR_COPY to force copying of a const char*:
-// TRACE_EVENT1("category", "name",
-// "arg1", TRACE_STR_COPY("string will be copied"));
-// std::string arg_values are always copied:
-// TRACE_EVENT1("category", "name",
-// "arg1", std::string("string will be copied"));
-//
-//
-// Thread Safety:
-// Thread safety is provided by methods defined in event_tracer.h. See the file
-// for details.
-
-// By default, const char* argument values are assumed to have long-lived scope
-// and will not be copied. Use this macro to force a const char* to be copied.
-#define TRACE_STR_COPY(str) \
- webrtc::trace_event_internal::TraceStringWithCopy(str)
-
-// This will mark the trace event as disabled by default. The user will need
-// to explicitly enable the event.
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-// By default, uint64 ID argument values are not mangled with the Process ID in
-// TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
-#define TRACE_ID_MANGLE(id) \
- webrtc::trace_event_internal::TraceID::ForceMangle(id)
-
-// Records a pair of begin and end events called "name" for the current
-// scope, with 0, 1 or 2 associated arguments. If the category is not
-// enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT0(category, name) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name)
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val)
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Enum reflecting the scope of an INSTANT event. Must fit within
-// TRACE_EVENT_FLAG_SCOPE_MASK.
-static constexpr uint8_t TRACE_EVENT_SCOPE_GLOBAL = 0u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_PROCESS = 1u << 2;
-static constexpr uint8_t TRACE_EVENT_SCOPE_THREAD = 2u << 2;
-
-// Records a single event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_INSTANT0(category, name, scope) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_BEGIN0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records a single END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_EVENT_END0(category, name) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category, name, \
- TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
- arg2_name, arg2_val)
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER1(category, name, value) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category, name, \
- TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records the value of a counter called "name" immediately. Value
-// must be representable as a 32 bit integer.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID1(category, name, id, value) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, "value", \
- static_cast<int>(value))
-
-// Records the values of a multi-parted counter called "name" immediately.
-// The UI will treat value1 and value2 as parts of a whole, displaying their
-// values as a stacked-bar chart.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to disambiguate counters with the same name. It must either
-// be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
-// will be xored with a hash of the process ID so that the same pointer on
-// two different processes will not collide.
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category, name, \
- id, TRACE_EVENT_FLAG_NONE, value1_name, \
- static_cast<int>(value1_val), value2_name, \
- static_cast<int>(value2_val))
-
-// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
-// associated arguments. If the category is not enabled, then this
-// does nothing.
-// - category and name strings must have application lifetime (statics or
-// literals). They may not include " chars.
-// - `id` is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
-// events are considered to match if their category, name and id values all
-// match. `id` must either be a pointer or an integer value up to 64 bits. If
-// it's a pointer, the bits will be xored with a hash of the process ID so
-// that the same pointer on two different processes will not collide.
-// An asynchronous operation can consist of multiple phases. The first phase is
-// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
-// ASYNC_STEP macros. When the operation completes, call ASYNC_END.
-// An ASYNC trace typically occur on a single thread (if not, they will only be
-// drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
-// operation must use the same `name` and `id`. Each event can have its own
-// args.
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-// Records a single ASYNC_STEP event for `step` immediately. If the category
-// is not enabled, then this does nothing. The `name` and `id` must match the
-// ASYNC_BEGIN event above. The `step` param identifies this step within the
-// async event. This should be called at the beginning of the next phase of an
-// asynchronous operation.
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step)
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \
- name, id, TRACE_EVENT_FLAG_NONE, "step", \
- step, arg1_name, arg1_val)
-
-// Records a single ASYNC_END event for "name" immediately. If the category
-// is not enabled, then this does nothing.
-#define TRACE_EVENT_ASYNC_END0(category, name, id) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE)
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val)
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, category, \
- name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
- arg1_val, arg2_name, arg2_val)
-
-////////////////////////////////////////////////////////////////////////////////
-// Implementation specific tracing API definitions.
-
-// Get a pointer to the enabled state of the given trace category. Only
-// long-lived literal strings should be given as the category name. The returned
-// pointer can be held permanently in a local static for example. If the
-// unsigned char is non-zero, tracing is enabled. If tracing is enabled,
-// TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
-// between the load of the tracing state and the call to
-// TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
-// for best performance when tracing is disabled.
-// const unsigned char*
-// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
- webrtc::EventTracer::GetCategoryEnabled
-
-// Add a trace event to the platform tracing system.
-// void TRACE_EVENT_API_ADD_TRACE_EVENT(
-// char phase,
-// const unsigned char* category_enabled,
-// const char* name,
-// unsigned long long id,
-// int num_args,
-// const char** arg_names,
-// const unsigned char* arg_types,
-// const unsigned long long* arg_values,
-// unsigned char flags)
-#define TRACE_EVENT_API_ADD_TRACE_EVENT webrtc::EventTracer::AddTraceEvent
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Implementation detail: trace event macros create temporary variables
-// to keep instrumentation overhead low. These macros give each temporary
-// variable a unique name based on the line number to prevent name collissions.
-#define INTERNAL_TRACE_EVENT_UID3(a, b) trace_event_unique_##a##b
-#define INTERNAL_TRACE_EVENT_UID2(a, b) INTERNAL_TRACE_EVENT_UID3(a, b)
-#define INTERNAL_TRACE_EVENT_UID(name_prefix) \
- INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
-
-#if WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-#define INTERNAL_TRACE_EVENT_INFO_TYPE const unsigned char*
-#else
-#define INTERNAL_TRACE_EVENT_INFO_TYPE static const unsigned char*
-#endif // WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS
-
-// Implementation detail: internal macro to create static category.
-#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
- INTERNAL_TRACE_EVENT_INFO_TYPE INTERNAL_TRACE_EVENT_UID(catstatic) = \
- TRACE_EVENT_API_GET_CATEGORY_ENABLED(category);
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Implementation detail: internal macro to create static category and add begin
-// event if the category is enabled. Also adds the end event when the scope
-// ends.
-#define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- webrtc::trace_event_internal::TraceEndOnScopeClose INTERNAL_TRACE_EVENT_UID( \
- profileScope); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- webrtc::trace_event_internal::AddTraceEvent( \
- TRACE_EVENT_PHASE_BEGIN, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- webrtc::trace_event_internal::kNoEventId, TRACE_EVENT_FLAG_NONE, \
- ##__VA_ARGS__); \
- INTERNAL_TRACE_EVENT_UID(profileScope) \
- .Initialize(INTERNAL_TRACE_EVENT_UID(catstatic), name); \
- }
-
-// Implementation detail: internal macro to create static category and add
-// event if the category is enabled.
-#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \
- ...) \
- do { \
- INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
- if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
- unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
- webrtc::trace_event_internal::TraceID trace_event_trace_id( \
- id, &trace_event_flags); \
- webrtc::trace_event_internal::AddTraceEvent( \
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \
- trace_event_trace_id.data(), trace_event_flags, ##__VA_ARGS__); \
- } \
- } while (0)
-
-// Notes regarding the following definitions:
-// New values can be added and propagated to third party libraries, but existing
-// definitions must never be changed, because third party libraries may use old
-// definitions.
-
-// Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
-#define TRACE_EVENT_PHASE_BEGIN ('B')
-#define TRACE_EVENT_PHASE_END ('E')
-#define TRACE_EVENT_PHASE_INSTANT ('I')
-#define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
-#define TRACE_EVENT_PHASE_ASYNC_STEP ('T')
-#define TRACE_EVENT_PHASE_ASYNC_END ('F')
-#define TRACE_EVENT_PHASE_METADATA ('M')
-#define TRACE_EVENT_PHASE_COUNTER ('C')
-
-// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
-#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
-#define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
-#define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
-
-namespace webrtc {
-namespace trace_event_internal {
-
-// Specify these values when the corresponding argument of AddTraceEvent is not
-// used.
-const int kZeroNumArgs = 0;
-const unsigned long long kNoEventId = 0;
-
-// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
-// are mangled with the Process ID so that they are unlikely to collide when the
-// same pointer is used on different processes.
-class TraceID {
- public:
- class ForceMangle {
- public:
- explicit ForceMangle(unsigned long long id) : data_(id) {}
- explicit ForceMangle(unsigned long id) : data_(id) {}
- explicit ForceMangle(unsigned int id) : data_(id) {}
- explicit ForceMangle(unsigned short id) : data_(id) {}
- explicit ForceMangle(unsigned char id) : data_(id) {}
- explicit ForceMangle(long long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(long id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(int id) : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(short id)
- : data_(static_cast<unsigned long long>(id)) {}
- explicit ForceMangle(signed char id)
- : data_(static_cast<unsigned long long>(id)) {}
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
- };
-
- explicit TraceID(const void* id, unsigned char* flags)
- : data_(
- static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(id))) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
- *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
- }
- explicit TraceID(unsigned long long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned long id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned int id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned short id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(unsigned char id, unsigned char* flags) : data_(id) {
- (void)flags;
- }
- explicit TraceID(long long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(long id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(int id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(short id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
- explicit TraceID(signed char id, unsigned char* flags)
- : data_(static_cast<unsigned long long>(id)) {
- (void)flags;
- }
-
- unsigned long long data() const { return data_; }
-
- private:
- unsigned long long data_;
-};
-
-// Simple union to store various types as unsigned long long.
-union TraceValueUnion {
- bool as_bool;
- unsigned long long as_uint;
- long long as_int;
- double as_double;
- const void* as_pointer;
- const char* as_string;
-};
-
-// Simple container for const char* that should be copied instead of retained.
-class TraceStringWithCopy {
- public:
- explicit TraceStringWithCopy(const char* str) : str_(str) {}
- operator const char*() const { return str_; }
-
- private:
- const char* str_;
-};
-
-// Define SetTraceValue for each allowed type. It stores the type and
-// value in the return arguments. This allows this API to avoid declaring any
-// structures so that it is portable to third_party libraries.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, \
- value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- TraceValueUnion type_value; \
- type_value.union_member = arg; \
- *type = value_type_id; \
- *value = type_value.as_uint; \
- }
-// Simpler form for int types that can be safely casted.
-#define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \
- static inline void SetTraceValue(actual_type arg, unsigned char* type, \
- unsigned long long* value) { \
- *type = value_type_id; \
- *value = static_cast<unsigned long long>(arg); \
- }
-
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT)
-INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL)
-INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const void*,
- as_pointer,
- TRACE_VALUE_TYPE_POINTER)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const char*,
- as_string,
- TRACE_VALUE_TYPE_STRING)
-INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&,
- as_string,
- TRACE_VALUE_TYPE_COPY_STRING)
-
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE
-#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
-
-// std::string version of SetTraceValue so that trace arguments can be strings.
-static inline void SetTraceValue(const std::string& arg,
- unsigned char* type,
- unsigned long long* value) {
- TraceValueUnion type_value;
- type_value.as_string = arg.c_str();
- *type = TRACE_VALUE_TYPE_COPY_STRING;
- *value = type_value.as_uint;
-}
-
-// These AddTraceEvent template functions are defined here instead of in the
-// macro, because the arg_values could be temporary objects, such as
-// std::string. In order to store pointers to the internal c_str and pass
-// through to the tracing API, the arg_values must live throughout
-// these procedures.
-
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id,
- kZeroNumArgs, nullptr, nullptr, nullptr,
- flags);
-}
-
-template <class ARG1_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val) {
- const int num_args = 1;
- unsigned char arg_types[1];
- unsigned long long arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- &arg1_name, arg_types, arg_values, flags);
-}
-
-template <class ARG1_TYPE, class ARG2_TYPE>
-static inline void AddTraceEvent(char phase,
- const unsigned char* category_enabled,
- const char* name,
- unsigned long long id,
- unsigned char flags,
- const char* arg1_name,
- const ARG1_TYPE& arg1_val,
- const char* arg2_name,
- const ARG2_TYPE& arg2_val) {
- const int num_args = 2;
- const char* arg_names[2] = {arg1_name, arg2_name};
- unsigned char arg_types[2];
- unsigned long long arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
- TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_enabled, name, id, num_args,
- arg_names, arg_types, arg_values, flags);
-}
-
-// Used by TRACE_EVENTx macro. Do not use directly.
-class TraceEndOnScopeClose {
- public:
- // Note: members of data_ intentionally left uninitialized. See Initialize.
- TraceEndOnScopeClose() : p_data_(nullptr) {}
- ~TraceEndOnScopeClose() {
- if (p_data_)
- AddEventIfEnabled();
- }
-
- void Initialize(const unsigned char* category_enabled, const char* name) {
- data_.category_enabled = category_enabled;
- data_.name = name;
- p_data_ = &data_;
- }
-
- private:
- // Add the end event if the category is still enabled.
- void AddEventIfEnabled() {
- // Only called when p_data_ is non-null.
- if (*p_data_->category_enabled) {
- TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_END,
- p_data_->category_enabled, p_data_->name,
- kNoEventId, kZeroNumArgs, nullptr,
- nullptr, nullptr, TRACE_EVENT_FLAG_NONE);
- }
- }
-
- // This Data struct workaround is to avoid initializing all the members
- // in Data during construction of this object, since this object is always
- // constructed, even when tracing is disabled. If the members of Data were
- // members of this class instead, compiler warnings occur about potential
- // uninitialized accesses.
- struct Data {
- const unsigned char* category_enabled;
- const char* name;
- };
- Data* p_data_;
- Data data_;
-};
-
-} // namespace trace_event_internal
-} // namespace webrtc
-
-#else
-
-////////////////////////////////////////////////////////////////////////////////
-// This section defines no-op alternatives to the tracing macros when
-// RTC_DISABLE_TRACE_EVENTS is defined.
-
-#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
-
-#define TRACE_ID_MANGLE(id) 0
-
-#define TRACE_EVENT0(category, name) RTC_NOOP()
-#define TRACE_EVENT1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT0(category, name, scope) RTC_NOOP()
-#define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_BEGIN0(category, name) RTC_NOOP()
-#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_END0(category, name) RTC_NOOP()
-#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) RTC_NOOP()
-#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
- arg2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER1(category, name, value) RTC_NOOP()
-
-#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
- value2_val) \
- RTC_NOOP()
-
-#define TRACE_COUNTER_ID1(category, name, id, value) RTC_NOOP()
-
-#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
- value2_name, value2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
- arg1_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_ASYNC_END0(category, name, id) RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
- RTC_NOOP()
-#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
- arg2_name, arg2_val) \
- RTC_NOOP()
-
-#define TRACE_EVENT_API_GET_CATEGORY_ENABLED ""
-
-#define TRACE_EVENT_API_ADD_TRACE_EVENT RTC_NOOP()
-
-#endif // RTC_TRACE_EVENTS_ENABLED
-#endif // RTC_USE_PERFETTO
-
-#endif // RTC_BASE_TRACE_EVENT_H_
+// This header is diverted to a similar header in Gecko, that is defining the
+// same macros, modified to talk to the Gecko Profiler.
+#include "GeckoTraceEvent.h"
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index 261c4002ae..040ee7da1c 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -79,6 +79,10 @@ BOOL CALLBACK GetWindowListHandler(HWND hwnd, LPARAM param) {
DesktopCapturer::Source window;
window.id = reinterpret_cast<WindowId>(hwnd);
+ DWORD pid;
+ GetWindowThreadProcessId(hwnd, &pid);
+ window.pid = static_cast<pid_t>(pid);
+
// GetWindowText* are potentially blocking operations if `hwnd` is
// owned by the current process. The APIs will send messages to the window's
// message loop, and if the message loop is waiting on this operation we will

View File

@ -1,27 +1,26 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P6 - Restore PID recording post cherry-pick;r=mjf
Subject: Bug 1729367 - P7 - restore mac PID tracking using new API;r=mjf
a=webrtc-update
This restores the code from P0, which was removed to make cherry-picking 439ffe462a66ad9fa9a251b265e4ab28c2647d25 and 449a78b1e20ea85b11f967cf3a184ee610ce21c3 easier.
Differential Revision: https://phabricator.services.mozilla.com/D129714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/72a83cb2e571023cd4150bbdef5be5455ce851f4
Differential Revision: https://phabricator.services.mozilla.com/D129721
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1495ca5ef535f8ad692a3a579ca42eddc14f39a8
---
modules/desktop_capture/win/window_capture_utils.cc | 4 ++++
1 file changed, 4 insertions(+)
modules/desktop_capture/window_capturer_mac.mm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index 261c4002ae..040ee7da1c 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -79,6 +79,10 @@ BOOL CALLBACK GetWindowListHandler(HWND hwnd, LPARAM param) {
DesktopCapturer::Source window;
window.id = reinterpret_cast<WindowId>(hwnd);
+ DWORD pid;
+ GetWindowThreadProcessId(hwnd, &pid);
+ window.pid = static_cast<pid_t>(pid);
+
// GetWindowText* are potentially blocking operations if `hwnd` is
// owned by the current process. The APIs will send messages to the window's
// message loop, and if the message loop is waiting on this operation we will
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index 56c94baada..8f5dc25516 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -169,8 +169,9 @@ void WindowCapturerMac::CaptureFrame() {
return webrtc::GetWindowList(
[sources](CFDictionaryRef window) {
WindowId window_id = GetWindowId(window);
+ int pid = GetWindowOwnerPid(window);
if (window_id != kNullWindowId) {
- sources->push_back(DesktopCapturer::Source{window_id, GetWindowTitle(window)});
+ sources->push_back(DesktopCapturer::Source{window_id, pid, GetWindowTitle(window)});
}
return true;
},

View File

@ -1,26 +1,205 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 28 Oct 2021 18:13:00 +0000
Subject: Bug 1729367 - P7 - restore mac PID tracking using new API;r=mjf
a=webrtc-update
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Add to stats the local receive time for receiving video
Sender Reports. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D129721
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1495ca5ef535f8ad692a3a579ca42eddc14f39a8
Differential Revision: https://phabricator.services.mozilla.com/D125712
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99267b6d193fbcb3e4c845c5e80770424d6d06e2
---
modules/desktop_capture/window_capturer_mac.mm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
call/video_receive_stream.h | 3 ++-
modules/rtp_rtcp/source/rtcp_receiver.cc | 6 ++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
video/rtp_video_stream_receiver2.cc | 5 +++--
video/rtp_video_stream_receiver2.h | 3 ++-
video/video_receive_stream2.cc | 3 ++-
11 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index 56c94baada..8f5dc25516 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -169,8 +169,9 @@ void WindowCapturerMac::CaptureFrame() {
return webrtc::GetWindowList(
[sources](CFDictionaryRef window) {
WindowId window_id = GetWindowId(window);
+ int pid = GetWindowOwnerPid(window);
if (window_id != kNullWindowId) {
- sources->push_back(DesktopCapturer::Source{window_id, GetWindowTitle(window)});
+ sources->push_back(DesktopCapturer::Source{window_id, pid, GetWindowTitle(window)});
}
return true;
},
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index ef23484414..472199ef57 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,10 +170,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
- // Mozilla modification: Init these three.
+ // Mozilla modification: Init these.
uint32_t rtcp_sender_packets_sent = 0;
uint32_t rtcp_sender_octets_sent = 0;
int64_t rtcp_sender_ntp_timestamp_ms = 0;
+ int64_t rtcp_sender_remote_ntp_timestamp_ms = 0;
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 349a9a673e..3298961fd3 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -391,11 +391,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 33aa986e8b..f6d1e027f4 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -126,7 +126,8 @@ class RTCPReceiver final {
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index badb8a81a0..83d507357d 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -524,11 +524,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 2ad73523db..f990a0e452 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -205,7 +205,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index 624c69e368..c0ccef149a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -547,11 +547,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 8c2487142a..eace18f958 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -201,7 +201,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 236179a906..f14b7ca244 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -412,10 +412,11 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
- // Returns packet count, octet count, and timestamp from RTCP sender report.
+ // Returns packet count, octet count, and timestamps from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const = 0;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a3e3239225..6fe5b247bd 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1045,9 +1045,10 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
// seem to be any support for these stats right now. So, we hack this in.
void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms, int64_t* remote_ntp_timestamp_ms) const {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
- rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms,
+ remote_ntp_timestamp_ms);
}
std::optional<RtpRtcpInterface::SenderReportStats>
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 0fb3cd1b7c..11b9548b76 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -215,7 +215,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
// stats at all, and even on the most recent libwebrtc code there does not
// seem to be any support for these stats right now. So, we hack this in.
void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
private:
// Implements RtpVideoFrameReceiver.
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index a655a072c4..ed9edcdd08 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -584,7 +584,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
// seem to be any support for these stats right now. So, we hack this in.
rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
&stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
- &stats.rtcp_sender_ntp_timestamp_ms);
+ &stats.rtcp_sender_ntp_timestamp_ms,
+ &stats.rtcp_sender_remote_ntp_timestamp_ms);
return stats;
}

View File

@ -1,205 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Add to stats the local receive time for receiving video
Sender Reports. r=ng
Subject: Bug 1729455 - Ensure the libwebrtc system clock is not used. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D125712
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99267b6d193fbcb3e4c845c5e80770424d6d06e2
Differential Revision: https://phabricator.services.mozilla.com/D128244
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3e8ac168ee3db089dd892bf140df53e15d6f0918
---
call/video_receive_stream.h | 3 ++-
modules/rtp_rtcp/source/rtcp_receiver.cc | 6 ++++--
modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 10 +++++-----
modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++-
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++--
video/rtp_video_stream_receiver2.cc | 5 +++--
video/rtp_video_stream_receiver2.h | 3 ++-
video/video_receive_stream2.cc | 3 ++-
11 files changed, 32 insertions(+), 22 deletions(-)
rtc_base/system_time.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index ef23484414..472199ef57 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -170,10 +170,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
RtcpPacketTypeCounter rtcp_packet_type_counts;
std::optional<RtpReceiveStats> rtx_rtp_stats;
diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc
index 058e6c2990..1a5e447916 100644
--- a/rtc_base/system_time.cc
+++ b/rtc_base/system_time.cc
@@ -12,6 +12,8 @@
// rtc::SystemTimeNanos() must be provided externally.
#ifndef WEBRTC_EXCLUDE_SYSTEM_TIME
- // Mozilla modification: Init these three.
+ // Mozilla modification: Init these.
uint32_t rtcp_sender_packets_sent = 0;
uint32_t rtcp_sender_octets_sent = 0;
int64_t rtcp_sender_ntp_timestamp_ms = 0;
+ int64_t rtcp_sender_remote_ntp_timestamp_ms = 0;
+#error Mozilla: Must not use the built-in libwebrtc clock
+
#include <stdint.h>
// Timing frame info: all important timestamps for a full lifetime of a
// single 'timing frame'.
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 349a9a673e..3298961fd3 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -391,11 +391,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
*packet_count = remote_sender_packet_count_;
*octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
}
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 33aa986e8b..f6d1e027f4 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -126,7 +126,8 @@ class RTCPReceiver final {
// Get received sender packet and octet counts
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
std::optional<TimeDelta> AverageRtt() const;
std::optional<TimeDelta> LastRtt() const;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index badb8a81a0..83d507357d 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -524,11 +524,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 2ad73523db..f990a0e452 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -205,7 +205,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index 624c69e368..c0ccef149a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -547,11 +547,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters(
}
// Received RTCP report.
-void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count,
- uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
- return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count,
- ntp_timestamp_ms);
+void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(
+ uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const {
+ return rtcp_receiver_.RemoteRTCPSenderInfo(
+ packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms);
}
std::vector<ReportBlockData> ModuleRtpRtcpImpl2::GetLatestReportBlockData()
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 8c2487142a..eace18f958 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -201,7 +201,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface,
void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const override;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const override;
// A snapshot of the most recent Report Block with additional data of
// interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats.
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 236179a906..f14b7ca244 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -412,10 +412,11 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
StreamDataCounters* rtx_counters) const = 0;
- // Returns packet count, octet count, and timestamp from RTCP sender report.
+ // Returns packet count, octet count, and timestamps from RTCP sender report.
virtual void RemoteRTCPSenderInfo(uint32_t* packet_count,
uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const = 0;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const = 0;
// A snapshot of Report Blocks with additional data of interest to statistics.
// Within this list, the sender-source SSRC pair is unique and per-pair the
// ReportBlockData represents the latest Report Block that was received for
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a3e3239225..6fe5b247bd 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1045,9 +1045,10 @@ std::optional<int64_t> RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs()
// seem to be any support for these stats right now. So, we hack this in.
void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo(
uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const {
+ int64_t* ntp_timestamp_ms, int64_t* remote_ntp_timestamp_ms) const {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
- rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms);
+ rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms,
+ remote_ntp_timestamp_ms);
}
std::optional<RtpRtcpInterface::SenderReportStats>
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 0fb3cd1b7c..11b9548b76 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -215,7 +215,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
// stats at all, and even on the most recent libwebrtc code there does not
// seem to be any support for these stats right now. So, we hack this in.
void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count,
- int64_t* ntp_timestamp_ms) const;
+ int64_t* ntp_timestamp_ms,
+ int64_t* remote_ntp_timestamp_ms) const;
private:
// Implements RtpVideoFrameReceiver.
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index a655a072c4..ed9edcdd08 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -584,7 +584,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
// seem to be any support for these stats right now. So, we hack this in.
rtp_video_stream_receiver_.RemoteRTCPSenderInfo(
&stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent,
- &stats.rtcp_sender_ntp_timestamp_ms);
+ &stats.rtcp_sender_ntp_timestamp_ms,
+ &stats.rtcp_sender_remote_ntp_timestamp_ms);
return stats;
}
#include <limits>

View File

@ -1,23 +1,104 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Ensure the libwebrtc system clock is not used. r=bwc
Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call
instances. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D128244
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3e8ac168ee3db089dd892bf140df53e15d6f0918
This patch makes libwebrtc use our clock for timestamps.
It also makes sure there's no use of the libwebrtc realtime clock, other than
for relative time tracking (like timeouts), and that future libwebrtc updates
don't introduce unaudited use of it.
Differential Revision: https://phabricator.services.mozilla.com/D127714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8
---
rtc_base/system_time.cc | 2 ++
1 file changed, 2 insertions(+)
modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++
modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++
rtc_base/task_utils/repeating_task.h | 4 ++--
system_wrappers/include/clock.h | 2 +-
system_wrappers/source/clock.cc | 2 +-
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/rtc_base/system_time.cc b/rtc_base/system_time.cc
index 058e6c2990..1a5e447916 100644
--- a/rtc_base/system_time.cc
+++ b/rtc_base/system_time.cc
@@ -12,6 +12,8 @@
// rtc::SystemTimeNanos() must be provided externally.
#ifndef WEBRTC_EXCLUDE_SYSTEM_TIME
diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h
index a869c8ad41..b6a33882d1 100644
--- a/modules/rtp_rtcp/include/flexfec_receiver.h
+++ b/modules/rtp_rtcp/include/flexfec_receiver.h
@@ -30,9 +30,11 @@ class Clock;
+#error Mozilla: Must not use the built-in libwebrtc clock
+
#include <stdint.h>
class FlexfecReceiver {
public:
+ /* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver(uint32_t ssrc,
uint32_t protected_media_ssrc,
RecoveredPacketReceiver* recovered_packet_receiver);
+ */
FlexfecReceiver(Clock* clock,
uint32_t ssrc,
uint32_t protected_media_ssrc,
diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
index 7f2cc0cb3c..2ba85a2157 100644
--- a/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
#include <limits>
} // namespace
+/* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver::FlexfecReceiver(
uint32_t ssrc,
uint32_t protected_media_ssrc,
@@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver(
ssrc,
protected_media_ssrc,
recovered_packet_receiver) {}
+ */
FlexfecReceiver::FlexfecReceiver(
Clock* clock,
diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
index c45de95ecc..28c691c3de 100644
--- a/rtc_base/task_utils/repeating_task.h
+++ b/rtc_base/task_utils/repeating_task.h
@@ -57,7 +57,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// DelayedStart is equivalent to Start except that the first invocation of the
@@ -68,7 +68,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// Stops future invocations of the repeating task closure. Can only be called
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
index 60296070cc..214b34c970 100644
--- a/system_wrappers/include/clock.h
+++ b/system_wrappers/include/clock.h
@@ -49,7 +49,7 @@ class RTC_EXPORT Clock {
}
// Returns an instance of the real-time system clock implementation.
- static Clock* GetRealTimeClock();
+ static Clock* GetRealTimeClockRaw();
};
class SimulatedClock : public Clock {
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 88c99d6a68..f7460b831c 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -57,7 +57,7 @@ class RealTimeClock : public Clock {
}
};
-Clock* Clock::GetRealTimeClock() {
+Clock* Clock::GetRealTimeClockRaw() {
static Clock* const clock = new RealTimeClock();
return clock;
}

View File

@ -1,104 +1,88 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 2 Nov 2021 14:35:00 +0000
Subject: Bug 1729455 - Inject RTCStatsTimestampMakerRealtimeClock into Call
instances. r=bwc
From: Landry Breuil <landry@openbsd.org>
Date: Wed, 22 Dec 2021 00:09:00 +0000
Subject: Bug 1654448 - P2 - readd partial support for BSD to webrtc
build;r=mjf
This patch makes libwebrtc use our clock for timestamps.
It also makes sure there's no use of the libwebrtc realtime clock, other than
for relative time tracking (like timeouts), and that future libwebrtc updates
don't introduce unaudited use of it.
only OpenBSD/amd64 is supported for now
Differential Revision: https://phabricator.services.mozilla.com/D127714
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e69945de4ac5c4ca71332e78ad8
Depends on D134432
Differential Revision: https://phabricator.services.mozilla.com/D134433
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb8976dc82d7d3bb3adb9685857
---
modules/rtp_rtcp/include/flexfec_receiver.h | 2 ++
modules/rtp_rtcp/source/flexfec_receiver.cc | 2 ++
rtc_base/task_utils/repeating_task.h | 4 ++--
system_wrappers/include/clock.h | 2 +-
system_wrappers/source/clock.cc | 2 +-
5 files changed, 8 insertions(+), 4 deletions(-)
BUILD.gn | 3 +++
modules/video_capture/BUILD.gn | 2 +-
modules/video_capture/linux/device_info_v4l2.h | 2 ++
rtc_base/platform_thread_types.cc | 4 +++-
webrtc.gni | 2 +-
5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/modules/rtp_rtcp/include/flexfec_receiver.h b/modules/rtp_rtcp/include/flexfec_receiver.h
index a869c8ad41..b6a33882d1 100644
--- a/modules/rtp_rtcp/include/flexfec_receiver.h
+++ b/modules/rtp_rtcp/include/flexfec_receiver.h
@@ -30,9 +30,11 @@ class Clock;
class FlexfecReceiver {
public:
+ /* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver(uint32_t ssrc,
uint32_t protected_media_ssrc,
RecoveredPacketReceiver* recovered_packet_receiver);
+ */
FlexfecReceiver(Clock* clock,
uint32_t ssrc,
uint32_t protected_media_ssrc,
diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
index 7f2cc0cb3c..2ba85a2157 100644
--- a/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -31,6 +31,7 @@ constexpr TimeDelta kPacketLogInterval = TimeDelta::Seconds(10);
} // namespace
+/* Mozilla: Avoid this since it could use GetRealTimeClock().
FlexfecReceiver::FlexfecReceiver(
uint32_t ssrc,
uint32_t protected_media_ssrc,
@@ -39,6 +40,7 @@ FlexfecReceiver::FlexfecReceiver(
ssrc,
protected_media_ssrc,
recovered_packet_receiver) {}
+ */
FlexfecReceiver::FlexfecReceiver(
Clock* clock,
diff --git a/rtc_base/task_utils/repeating_task.h b/rtc_base/task_utils/repeating_task.h
index c45de95ecc..28c691c3de 100644
--- a/rtc_base/task_utils/repeating_task.h
+++ b/rtc_base/task_utils/repeating_task.h
@@ -57,7 +57,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// DelayedStart is equivalent to Start except that the first invocation of the
@@ -68,7 +68,7 @@ class RepeatingTaskHandle {
absl::AnyInvocable<TimeDelta()> closure,
TaskQueueBase::DelayPrecision precision =
TaskQueueBase::DelayPrecision::kLow,
- Clock* clock = Clock::GetRealTimeClock(),
+ Clock* clock = Clock::GetRealTimeClockRaw(),
const Location& location = Location::Current());
// Stops future invocations of the repeating task closure. Can only be called
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h
index 60296070cc..214b34c970 100644
--- a/system_wrappers/include/clock.h
+++ b/system_wrappers/include/clock.h
@@ -49,7 +49,7 @@ class RTC_EXPORT Clock {
diff --git a/BUILD.gn b/BUILD.gn
index 8e8ed055c9..e1711d7e7c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -222,6 +222,9 @@ config("common_inherited_config") {
if (is_linux || is_chromeos) {
defines += [ "WEBRTC_LINUX" ]
}
// Returns an instance of the real-time system clock implementation.
- static Clock* GetRealTimeClock();
+ static Clock* GetRealTimeClockRaw();
};
class SimulatedClock : public Clock {
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 88c99d6a68..f7460b831c 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -57,7 +57,7 @@ class RealTimeClock : public Clock {
+ if (is_bsd) {
+ defines += [ "WEBRTC_BSD" ]
+ }
if (is_mac) {
defines += [ "WEBRTC_MAC" ]
}
};
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a8994aaa68..a2bf27f645 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -72,7 +72,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"video_capture_options.h",
]
-Clock* Clock::GetRealTimeClock() {
+Clock* Clock::GetRealTimeClockRaw() {
static Clock* const clock = new RealTimeClock();
return clock;
- if (is_linux || is_chromeos) {
+ if (is_linux || is_bsd || is_chromeos) {
sources += [
"linux/device_info_linux.cc",
"linux/device_info_v4l2.cc",
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index e3c2395f49..119cb07ab8 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -16,7 +16,9 @@
#include "modules/video_capture/device_info_impl.h"
#include "rtc_base/platform_thread.h"
+#ifdef WEBRTC_LINUX
#include <sys/inotify.h>
+#endif
struct v4l2_capability;
diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc
index d64ea689bb..c3c6955a7b 100644
--- a/rtc_base/platform_thread_types.cc
+++ b/rtc_base/platform_thread_types.cc
@@ -50,7 +50,9 @@ PlatformThreadId CurrentThreadId() {
return static_cast<PlatformThreadId>(pthread_self());
#else
// Default implementation for nacl and solaris.
- return reinterpret_cast<PlatformThreadId>(pthread_self());
+ // WEBRTC_BSD: pthread_t is a pointer, so cannot be casted to pid_t
+ // (aka int32_t) on 64-bit archs. Required on OpenBSD.
+ return reinterpret_cast<long>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
}
diff --git a/webrtc.gni b/webrtc.gni
index 156c3d3985..f55b88a061 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -363,7 +363,7 @@ rtc_opus_dir = "//third_party/opus"
# Desktop capturer is supported only on Windows, OSX and Linux.
rtc_desktop_capture_supported =
- (is_win && current_os != "winuwp") || is_mac ||
+ (is_win && current_os != "winuwp") || is_mac || is_bsd ||
((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
###############################################################################

View File

@ -1,88 +1,138 @@
From: Landry Breuil <landry@openbsd.org>
Date: Wed, 22 Dec 2021 00:09:00 +0000
Subject: Bug 1654448 - P2 - readd partial support for BSD to webrtc
build;r=mjf
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 4 Apr 2022 12:25:26 -0500
Subject: Bug 1766646 - (fix) breakout Call::Stats and SharedModuleThread into
seperate files
only OpenBSD/amd64 is supported for now
Depends on D134432
Differential Revision: https://phabricator.services.mozilla.com/D134433
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb8976dc82d7d3bb3adb9685857
---
BUILD.gn | 3 +++
modules/video_capture/BUILD.gn | 2 +-
modules/video_capture/linux/device_info_v4l2.h | 2 ++
rtc_base/platform_thread_types.cc | 4 +++-
webrtc.gni | 2 +-
5 files changed, 10 insertions(+), 3 deletions(-)
call/BUILD.gn | 6 ++++++
call/call.cc | 13 -------------
call/call.h | 11 ++---------
call/call_basic_stats.cc | 20 ++++++++++++++++++++
call/call_basic_stats.h | 21 +++++++++++++++++++++
5 files changed, 49 insertions(+), 22 deletions(-)
create mode 100644 call/call_basic_stats.cc
create mode 100644 call/call_basic_stats.h
diff --git a/BUILD.gn b/BUILD.gn
index 8e8ed055c9..e1711d7e7c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -222,6 +222,9 @@ config("common_inherited_config") {
if (is_linux || is_chromeos) {
defines += [ "WEBRTC_LINUX" ]
}
+ if (is_bsd) {
+ defines += [ "WEBRTC_BSD" ]
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 1b13baad0b..d1287c56f1 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,12 @@ rtc_library("call_interfaces") {
"syncable.cc",
"syncable.h",
]
+ if (build_with_mozilla) {
+ sources += [
+ "call_basic_stats.cc",
+ "call_basic_stats.h",
+ ]
+ }
if (is_mac) {
defines += [ "WEBRTC_MAC" ]
}
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a8994aaa68..a2bf27f645 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -72,7 +72,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"video_capture_options.h",
]
- if (is_linux || is_chromeos) {
+ if (is_linux || is_bsd || is_chromeos) {
sources += [
"linux/device_info_linux.cc",
"linux/device_info_v4l2.cc",
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index e3c2395f49..119cb07ab8 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -16,7 +16,9 @@
#include "modules/video_capture/device_info_impl.h"
deps = [
":audio_sender_interface",
diff --git a/call/call.cc b/call/call.cc
index 2b7751742f..11dbef3212 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -510,19 +510,6 @@ class Call final : public webrtc::Call,
};
} // namespace internal
#include "rtc_base/platform_thread.h"
+#ifdef WEBRTC_LINUX
#include <sys/inotify.h>
+#endif
-std::string Call::Stats::ToString(int64_t time_ms) const {
- char buf[1024];
- rtc::SimpleStringBuilder ss(buf);
- ss << "Call stats: " << time_ms << ", {";
- ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
- ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
- ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
- ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
- ss << "rtt_ms: " << rtt_ms;
- ss << '}';
- return ss.str();
-}
-
std::unique_ptr<Call> Call::Create(CallConfig config) {
std::unique_ptr<RtpTransportControllerSendInterface> transport_send;
if (config.rtp_transport_controller_send_factory != nullptr) {
diff --git a/call/call.h b/call/call.h
index 313e8a85d1..ef782c2bb8 100644
--- a/call/call.h
+++ b/call/call.h
@@ -25,6 +25,7 @@
#include "api/transport/bitrate_settings.h"
#include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h"
+#include "call/call_basic_stats.h"
#include "call/call_config.h"
#include "call/flexfec_receive_stream.h"
#include "call/packet_receiver.h"
@@ -50,15 +51,7 @@ namespace webrtc {
struct v4l2_capability;
class Call {
public:
- struct Stats {
- std::string ToString(int64_t time_ms) const;
-
- int send_bandwidth_bps = 0; // Estimated available send bandwidth.
- int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
- int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
- int64_t pacer_delay_ms = 0;
- int64_t rtt_ms = -1;
- };
+ using Stats = CallBasicStats;
diff --git a/rtc_base/platform_thread_types.cc b/rtc_base/platform_thread_types.cc
index d64ea689bb..c3c6955a7b 100644
--- a/rtc_base/platform_thread_types.cc
+++ b/rtc_base/platform_thread_types.cc
@@ -50,7 +50,9 @@ PlatformThreadId CurrentThreadId() {
return static_cast<PlatformThreadId>(pthread_self());
#else
// Default implementation for nacl and solaris.
- return reinterpret_cast<PlatformThreadId>(pthread_self());
+ // WEBRTC_BSD: pthread_t is a pointer, so cannot be casted to pid_t
+ // (aka int32_t) on 64-bit archs. Required on OpenBSD.
+ return reinterpret_cast<long>(pthread_self());
#endif
#endif // defined(WEBRTC_POSIX)
}
diff --git a/webrtc.gni b/webrtc.gni
index 156c3d3985..f55b88a061 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -363,7 +363,7 @@ rtc_opus_dir = "//third_party/opus"
static std::unique_ptr<Call> Create(CallConfig config);
# Desktop capturer is supported only on Windows, OSX and Linux.
rtc_desktop_capture_supported =
- (is_win && current_os != "winuwp") || is_mac ||
+ (is_win && current_os != "winuwp") || is_mac || is_bsd ||
((is_linux || is_chromeos) && (rtc_use_x11_extensions || rtc_use_pipewire))
###############################################################################
diff --git a/call/call_basic_stats.cc b/call/call_basic_stats.cc
new file mode 100644
index 0000000000..74333a663b
--- /dev/null
+++ b/call/call_basic_stats.cc
@@ -0,0 +1,20 @@
+#include "call/call_basic_stats.h"
+
+#include "rtc_base/strings/string_builder.h"
+
+namespace webrtc {
+
+std::string CallBasicStats::ToString(int64_t time_ms) const {
+ char buf[1024];
+ rtc::SimpleStringBuilder ss(buf);
+ ss << "Call stats: " << time_ms << ", {";
+ ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
+ ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
+ ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
+ ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
+ ss << "rtt_ms: " << rtt_ms;
+ ss << '}';
+ return ss.str();
+}
+
+} // namespace webrtc
diff --git a/call/call_basic_stats.h b/call/call_basic_stats.h
new file mode 100644
index 0000000000..98febe9405
--- /dev/null
+++ b/call/call_basic_stats.h
@@ -0,0 +1,21 @@
+#ifndef CALL_CALL_BASIC_STATS_H_
+#define CALL_CALL_BASIC_STATS_H_
+
+#include <string>
+
+namespace webrtc {
+
+// named to avoid conflicts with video/call_stats.h
+struct CallBasicStats {
+ std::string ToString(int64_t time_ms) const;
+
+ int send_bandwidth_bps = 0; // Estimated available send bandwidth.
+ int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
+ int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
+ int64_t pacer_delay_ms = 0;
+ int64_t rtt_ms = -1;
+};
+
+} // namespace webrtc
+
+#endif // CALL_CALL_BASIC_STATS_H_

View File

@ -1,138 +1,29 @@
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 4 Apr 2022 12:25:26 -0500
Subject: Bug 1766646 - (fix) breakout Call::Stats and SharedModuleThread into
seperate files
Date: Fri, 8 Apr 2022 11:36:36 -0500
Subject: Bug 1766646 - (fix-b556b08668) avoid InlinedVector method that can
throw exception
---
call/BUILD.gn | 6 ++++++
call/call.cc | 13 -------------
call/call.h | 11 ++---------
call/call_basic_stats.cc | 20 ++++++++++++++++++++
call/call_basic_stats.h | 21 +++++++++++++++++++++
5 files changed, 49 insertions(+), 22 deletions(-)
create mode 100644 call/call_basic_stats.cc
create mode 100644 call/call_basic_stats.h
api/video_codecs/video_encoder.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 1b13baad0b..d1287c56f1 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,12 @@ rtc_library("call_interfaces") {
"syncable.cc",
"syncable.h",
]
+ if (build_with_mozilla) {
+ sources += [
+ "call_basic_stats.cc",
+ "call_basic_stats.h",
+ ]
+ }
deps = [
":audio_sender_interface",
diff --git a/call/call.cc b/call/call.cc
index 2b7751742f..11dbef3212 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -510,19 +510,6 @@ class Call final : public webrtc::Call,
};
} // namespace internal
-std::string Call::Stats::ToString(int64_t time_ms) const {
- char buf[1024];
- rtc::SimpleStringBuilder ss(buf);
- ss << "Call stats: " << time_ms << ", {";
- ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
- ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
- ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
- ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
- ss << "rtt_ms: " << rtt_ms;
- ss << '}';
- return ss.str();
-}
-
std::unique_ptr<Call> Call::Create(CallConfig config) {
std::unique_ptr<RtpTransportControllerSendInterface> transport_send;
if (config.rtp_transport_controller_send_factory != nullptr) {
diff --git a/call/call.h b/call/call.h
index 313e8a85d1..ef782c2bb8 100644
--- a/call/call.h
+++ b/call/call.h
@@ -25,6 +25,7 @@
#include "api/transport/bitrate_settings.h"
#include "call/audio_receive_stream.h"
#include "call/audio_send_stream.h"
+#include "call/call_basic_stats.h"
#include "call/call_config.h"
#include "call/flexfec_receive_stream.h"
#include "call/packet_receiver.h"
@@ -50,15 +51,7 @@ namespace webrtc {
class Call {
public:
- struct Stats {
- std::string ToString(int64_t time_ms) const;
-
- int send_bandwidth_bps = 0; // Estimated available send bandwidth.
- int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
- int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
- int64_t pacer_delay_ms = 0;
- int64_t rtt_ms = -1;
- };
+ using Stats = CallBasicStats;
static std::unique_ptr<Call> Create(CallConfig config);
diff --git a/call/call_basic_stats.cc b/call/call_basic_stats.cc
new file mode 100644
index 0000000000..74333a663b
--- /dev/null
+++ b/call/call_basic_stats.cc
@@ -0,0 +1,20 @@
+#include "call/call_basic_stats.h"
+
+#include "rtc_base/strings/string_builder.h"
+
+namespace webrtc {
+
+std::string CallBasicStats::ToString(int64_t time_ms) const {
+ char buf[1024];
+ rtc::SimpleStringBuilder ss(buf);
+ ss << "Call stats: " << time_ms << ", {";
+ ss << "send_bw_bps: " << send_bandwidth_bps << ", ";
+ ss << "recv_bw_bps: " << recv_bandwidth_bps << ", ";
+ ss << "max_pad_bps: " << max_padding_bitrate_bps << ", ";
+ ss << "pacer_delay_ms: " << pacer_delay_ms << ", ";
+ ss << "rtt_ms: " << rtt_ms;
+ ss << '}';
+ return ss.str();
+}
+
+} // namespace webrtc
diff --git a/call/call_basic_stats.h b/call/call_basic_stats.h
new file mode 100644
index 0000000000..98febe9405
--- /dev/null
+++ b/call/call_basic_stats.h
@@ -0,0 +1,21 @@
+#ifndef CALL_CALL_BASIC_STATS_H_
+#define CALL_CALL_BASIC_STATS_H_
+
+#include <string>
+
+namespace webrtc {
+
+// named to avoid conflicts with video/call_stats.h
+struct CallBasicStats {
+ std::string ToString(int64_t time_ms) const;
+
+ int send_bandwidth_bps = 0; // Estimated available send bandwidth.
+ int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
+ int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
+ int64_t pacer_delay_ms = 0;
+ int64_t rtt_ms = -1;
+};
+
+} // namespace webrtc
+
+#endif // CALL_CALL_BASIC_STATS_H_
diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc
index c3b5f3a4e9..22a532d328 100644
--- a/api/video_codecs/video_encoder.cc
+++ b/api/video_codecs/video_encoder.cc
@@ -192,7 +192,15 @@ std::string VideoEncoder::EncoderInfo::ToString() const {
for (size_t i = 0; i < preferred_pixel_formats.size(); ++i) {
if (i > 0)
oss << ", ";
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // This could assert, as opposed to throw using the form in the
+ // else, but since we're in a for loop that uses .size() we can
+ // be fairly sure that this is safe without doing a further
+ // check to make sure 'i' is in-range.
+ oss << VideoFrameBufferTypeToString(preferred_pixel_formats[i]);
+#else
oss << VideoFrameBufferTypeToString(preferred_pixel_formats.at(i));
+#endif
}
oss << "]";
if (is_qp_trusted.has_value()) {

View File

@ -1,29 +1,67 @@
From: Michael Froman <mjfroman@mac.com>
Date: Fri, 8 Apr 2022 11:36:36 -0500
Subject: Bug 1766646 - (fix-b556b08668) avoid InlinedVector method that can
throw exception
Date: Thu, 28 Apr 2022 10:53:43 -0500
Subject: Bug 1766646 - (fix-a0bb2ef2dc) add back VideoType enum values
---
api/video_codecs/video_encoder.cc | 8 ++++++++
1 file changed, 8 insertions(+)
common_video/libyuv/include/webrtc_libyuv.h | 3 +++
common_video/libyuv/webrtc_libyuv.cc | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc
index c3b5f3a4e9..22a532d328 100644
--- a/api/video_codecs/video_encoder.cc
+++ b/api/video_codecs/video_encoder.cc
@@ -192,7 +192,15 @@ std::string VideoEncoder::EncoderInfo::ToString() const {
for (size_t i = 0; i < preferred_pixel_formats.size(); ++i) {
if (i > 0)
oss << ", ";
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // This could assert, as opposed to throw using the form in the
+ // else, but since we're in a for loop that uses .size() we can
+ // be fairly sure that this is safe without doing a further
+ // check to make sure 'i' is in-range.
+ oss << VideoFrameBufferTypeToString(preferred_pixel_formats[i]);
+#else
oss << VideoFrameBufferTypeToString(preferred_pixel_formats.at(i));
+#endif
diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h
index 68831c70ab..253a33294d 100644
--- a/common_video/libyuv/include/webrtc_libyuv.h
+++ b/common_video/libyuv/include/webrtc_libyuv.h
@@ -35,11 +35,14 @@ enum class VideoType {
kBGR24,
kARGB,
kABGR,
+ kARGB4444,
kRGB565,
+ kARGB1555,
kYUY2,
kYV12,
kUYVY,
kMJPEG,
+ kNV21,
kBGRA,
kNV12,
};
diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc
index 31ba1feca3..05a4b184c2 100644
--- a/common_video/libyuv/webrtc_libyuv.cc
+++ b/common_video/libyuv/webrtc_libyuv.cc
@@ -24,6 +24,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
RTC_DCHECK_GE(height, 0);
switch (type) {
case VideoType::kI420:
+ case VideoType::kNV21:
case VideoType::kIYUV:
case VideoType::kYV12:
case VideoType::kNV12: {
@@ -31,7 +32,9 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
int half_height = (height + 1) >> 1;
return width * height + half_width * half_height * 2;
}
+ case VideoType::kARGB4444:
case VideoType::kRGB565:
+ case VideoType::kARGB1555:
case VideoType::kYUY2:
case VideoType::kUYVY:
return width * height * 2;
@@ -104,10 +107,16 @@ int ConvertVideoType(VideoType video_type) {
return libyuv::FOURCC_UYVY;
case VideoType::kMJPEG:
return libyuv::FOURCC_MJPG;
+ case VideoType::kNV21:
+ return libyuv::FOURCC_NV21;
case VideoType::kARGB:
return libyuv::FOURCC_ARGB;
case VideoType::kBGRA:
return libyuv::FOURCC_BGRA;
+ case VideoType::kARGB4444:
+ return libyuv::FOURCC_R444;
+ case VideoType::kARGB1555:
+ return libyuv::FOURCC_RGBO;
case VideoType::kNV12:
return libyuv::FOURCC_NV12;
}
oss << "]";
if (is_qp_trusted.has_value()) {

View File

@ -1,67 +1,73 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 28 Apr 2022 10:53:43 -0500
Subject: Bug 1766646 - (fix-a0bb2ef2dc) add back VideoType enum values
Date: Thu, 19 May 2022 15:32:32 -0500
Subject: Bug 1772380 - Build 1766646 - (fix-c89fdd716c) fixes for the
refactored PlatformThread API;r?mjf
---
common_video/libyuv/include/webrtc_libyuv.h | 3 +++
common_video/libyuv/webrtc_libyuv.cc | 9 +++++++++
2 files changed, 12 insertions(+)
.../video_capture/linux/device_info_v4l2.cc | 20 ++++++-------------
.../video_capture/linux/device_info_v4l2.h | 3 +--
2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h
index 68831c70ab..253a33294d 100644
--- a/common_video/libyuv/include/webrtc_libyuv.h
+++ b/common_video/libyuv/include/webrtc_libyuv.h
@@ -35,11 +35,14 @@ enum class VideoType {
kBGR24,
kARGB,
kABGR,
+ kARGB4444,
kRGB565,
+ kARGB1555,
kYUY2,
kYV12,
kUYVY,
kMJPEG,
+ kNV21,
kBGRA,
kNV12,
};
diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc
index 31ba1feca3..05a4b184c2 100644
--- a/common_video/libyuv/webrtc_libyuv.cc
+++ b/common_video/libyuv/webrtc_libyuv.cc
@@ -24,6 +24,7 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
RTC_DCHECK_GE(height, 0);
switch (type) {
case VideoType::kI420:
+ case VideoType::kNV21:
case VideoType::kIYUV:
case VideoType::kYV12:
case VideoType::kNV12: {
@@ -31,7 +32,9 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
int half_height = (height + 1) >> 1;
return width * height + half_width * half_height * 2;
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index c5d33ff9a4..04caaea592 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -151,11 +151,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
return 0;
}
-void DeviceInfoV4l2::InotifyEventThread(void* obj)
-{
- static_cast<DeviceInfoLinux*> (obj)->InotifyProcess();
-}
-
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
@@ -181,16 +176,14 @@ void DeviceInfoV4l2::InotifyProcess()
DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
#ifdef WEBRTC_LINUX
- , _inotifyEventThread(new rtc::PlatformThread(
- InotifyEventThread, this, "InotifyEventThread"))
, _isShutdown(false)
#endif
{
#ifdef WEBRTC_LINUX
- if (_inotifyEventThread)
- {
- _inotifyEventThread->Start();
- }
+ _inotifyEventThread = rtc::PlatformThread::SpawnJoinable(
+ [this] {
+ InotifyProcess();
+ }, "InotifyEventThread");
#endif
}
@@ -202,9 +195,8 @@ DeviceInfoV4l2::~DeviceInfoV4l2() {
#ifdef WEBRTC_LINUX
_isShutdown = true;
- if (_inotifyEventThread) {
- _inotifyEventThread->Stop();
- _inotifyEventThread = nullptr;
+ if (!_inotifyEventThread.empty()) {
+ _inotifyEventThread.Finalize();
}
+ case VideoType::kARGB4444:
case VideoType::kRGB565:
+ case VideoType::kARGB1555:
case VideoType::kYUY2:
case VideoType::kUYVY:
return width * height * 2;
@@ -104,10 +107,16 @@ int ConvertVideoType(VideoType video_type) {
return libyuv::FOURCC_UYVY;
case VideoType::kMJPEG:
return libyuv::FOURCC_MJPG;
+ case VideoType::kNV21:
+ return libyuv::FOURCC_NV21;
case VideoType::kARGB:
return libyuv::FOURCC_ARGB;
case VideoType::kBGRA:
return libyuv::FOURCC_BGRA;
+ case VideoType::kARGB4444:
+ return libyuv::FOURCC_R444;
+ case VideoType::kARGB1555:
+ return libyuv::FOURCC_RGBO;
case VideoType::kNV12:
return libyuv::FOURCC_NV12;
}
#endif
}
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 119cb07ab8..0bec3eb765 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -60,8 +60,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
int EventCheck(int fd);
int HandleEvents(int fd);
int ProcessInotifyEvents();
- std::unique_ptr<rtc::PlatformThread> _inotifyEventThread;
- static void InotifyEventThread(void*);
+ rtc::PlatformThread _inotifyEventThread;
void InotifyProcess();
int _fd_v4l, _fd_dev, _wd_v4l, _wd_dev; /* accessed on InotifyEventThread thread */
std::atomic<bool> _isShutdown;

View File

@ -1,73 +1,171 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 19 May 2022 15:32:32 -0500
Subject: Bug 1772380 - Build 1766646 - (fix-c89fdd716c) fixes for the
refactored PlatformThread API;r?mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:07:00 +0100
Subject: Bug 1766646 - (fix-ae0d117d51) ifdef our Csrc impl vs upstream's
impl, see Bug 1771332.
---
.../video_capture/linux/device_info_v4l2.cc | 20 ++++++-------------
.../video_capture/linux/device_info_v4l2.h | 3 +--
2 files changed, 7 insertions(+), 16 deletions(-)
modules/rtp_rtcp/source/rtp_header_extensions.cc | 4 ++++
modules/rtp_rtcp/source/rtp_header_extensions.h | 4 ++++
modules/rtp_rtcp/source/rtp_packet.cc | 4 ++++
modules/rtp_rtcp/source/rtp_sender.cc | 4 ++++
test/fuzzers/rtp_packet_fuzzer.cc | 4 ++++
5 files changed, 20 insertions(+)
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index c5d33ff9a4..04caaea592 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -151,11 +151,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents()
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc
index bb035729f8..53211fa2b4 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.cc
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc
@@ -181,6 +181,7 @@ bool AudioLevelExtension::Write(rtc::ArrayView<uint8_t> data,
return true;
}
-void DeviceInfoV4l2::InotifyEventThread(void* obj)
-{
- static_cast<DeviceInfoLinux*> (obj)->InotifyProcess();
-}
-
void DeviceInfoV4l2::InotifyProcess()
{
_fd_v4l = inotify_init();
@@ -181,16 +176,14 @@ void DeviceInfoV4l2::InotifyProcess()
+#if !defined(WEBRTC_MOZILLA_BUILD)
// An RTP Header Extension for Mixer-to-Client Audio Level Indication
//
// https://tools.ietf.org/html/rfc6465
@@ -230,6 +231,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
}
return true;
}
+#endif
DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
#ifdef WEBRTC_LINUX
- , _inotifyEventThread(new rtc::PlatformThread(
- InotifyEventThread, this, "InotifyEventThread"))
, _isShutdown(false)
#endif
{
#ifdef WEBRTC_LINUX
- if (_inotifyEventThread)
- {
- _inotifyEventThread->Start();
- }
+ _inotifyEventThread = rtc::PlatformThread::SpawnJoinable(
+ [this] {
+ InotifyProcess();
+ }, "InotifyEventThread");
#endif
// From RFC 5450: Transmission Time Offsets in RTP Streams.
//
@@ -423,6 +425,7 @@ bool PlayoutDelayLimits::Write(rtc::ArrayView<uint8_t> data,
return true;
}
@@ -202,9 +195,8 @@ DeviceInfoV4l2::~DeviceInfoV4l2() {
#ifdef WEBRTC_LINUX
_isShutdown = true;
+#if defined(WEBRTC_MOZILLA_BUILD)
// CSRCAudioLevel
// Sample Audio Level Encoding Using the One-Byte Header Format
// Note that the range of len is 1 to 15 which is encoded as 0 to 14
@@ -461,6 +464,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
// This extension if used must have at least one audio level
return csrcAudioLevels.numAudioLevels;
}
+#endif
- if (_inotifyEventThread) {
- _inotifyEventThread->Stop();
- _inotifyEventThread = nullptr;
+ if (!_inotifyEventThread.empty()) {
+ _inotifyEventThread.Finalize();
// Video Content Type.
//
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h
index ed816caa10..2ad2d18036 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.h
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.h
@@ -104,6 +104,7 @@ class AudioLevelExtension {
static bool Write(rtc::ArrayView<uint8_t> data, const AudioLevel& extension);
};
+#if !defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -118,6 +119,7 @@ class CsrcAudioLevel {
static bool Write(rtc::ArrayView<uint8_t> data,
rtc::ArrayView<const uint8_t> csrc_audio_levels);
};
+#endif
class TransmissionOffset {
public:
@@ -308,6 +310,7 @@ class ColorSpaceExtension {
static size_t WriteLuminance(uint8_t* data, float f, int denominator);
};
+#if defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -322,6 +325,7 @@ class CsrcAudioLevel {
static size_t ValueSize(const CsrcAudioLevelList& csrcAudioLevels);
static bool Write(rtc::ArrayView<uint8_t> data, const CsrcAudioLevelList& csrcAudioLevels);
};
+#endif
// Base extension class for RTP header extensions which are strings.
// Subclasses must defined kId and kUri static constexpr members.
diff --git a/modules/rtp_rtcp/source/rtp_packet.cc b/modules/rtp_rtcp/source/rtp_packet.cc
index 3192c27a49..306c17e2c2 100644
--- a/modules/rtp_rtcp/source/rtp_packet.cc
+++ b/modules/rtp_rtcp/source/rtp_packet.cc
@@ -193,7 +193,9 @@ void RtpPacket::ZeroMutableExtensions() {
break;
}
case RTPExtensionType::kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel:
+#endif
case RTPExtensionType::kRtpExtensionAbsoluteCaptureTime:
case RTPExtensionType::kRtpExtensionColorSpace:
case RTPExtensionType::kRtpExtensionCorruptionDetection:
@@ -212,10 +214,12 @@ void RtpPacket::ZeroMutableExtensions() {
// Non-mutable extension. Don't change it.
break;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel: {
// TODO: This is a Mozilla addition, we need to add a handler for this.
RTC_CHECK(false);
}
+#endif
}
#endif
}
}
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 119cb07ab8..0bec3eb765 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -60,8 +60,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
int EventCheck(int fd);
int HandleEvents(int fd);
int ProcessInotifyEvents();
- std::unique_ptr<rtc::PlatformThread> _inotifyEventThread;
- static void InotifyEventThread(void*);
+ rtc::PlatformThread _inotifyEventThread;
void InotifyProcess();
int _fd_v4l, _fd_dev, _wd_v4l, _wd_dev; /* accessed on InotifyEventThread thread */
std::atomic<bool> _isShutdown;
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 258bfa1885..5b1c588197 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -115,7 +115,9 @@ bool IsNonVolatile(RTPExtensionType type) {
switch (type) {
case kRtpExtensionTransmissionTimeOffset:
case kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
+#endif
case kRtpExtensionAbsoluteSendTime:
case kRtpExtensionTransportSequenceNumber:
case kRtpExtensionTransportSequenceNumber02:
@@ -140,10 +142,12 @@ bool IsNonVolatile(RTPExtensionType type) {
case kRtpExtensionNumberOfExtensions:
RTC_DCHECK_NOTREACHED();
return false;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
// TODO: Mozilla implement for CsrcAudioLevel
RTC_CHECK(false);
return false;
+#endif
}
RTC_CHECK_NOTREACHED();
}
diff --git a/test/fuzzers/rtp_packet_fuzzer.cc b/test/fuzzers/rtp_packet_fuzzer.cc
index 6a7b233e29..705ceee309 100644
--- a/test/fuzzers/rtp_packet_fuzzer.cc
+++ b/test/fuzzers/rtp_packet_fuzzer.cc
@@ -79,11 +79,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
packet.GetExtension<AudioLevelExtension>(&audio_level);
break;
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
std::vector<uint8_t> audio_levels;
packet.GetExtension<CsrcAudioLevel>(&audio_levels);
break;
}
+#endif
case kRtpExtensionAbsoluteSendTime:
uint32_t sendtime;
packet.GetExtension<AbsoluteSendTime>(&sendtime);
@@ -170,11 +172,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
CorruptionDetectionMessage message;
packet.GetExtension<CorruptionDetectionExtension>(&message);
break;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
CsrcAudioLevelList levels;
packet.GetExtension<CsrcAudioLevel>(&levels);
break;
}
+#endif
}
}

View File

@ -1,171 +1,24 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 18 Jan 2021 11:07:00 +0100
Subject: Bug 1766646 - (fix-ae0d117d51) ifdef our Csrc impl vs upstream's
impl, see Bug 1771332.
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:11:09 -0500
Subject: Bug 1773223 - Generate webrtc moz.builds for all platforms at once.
r=mjf,firefox-build-system-reviewers,ahochheiden
---
modules/rtp_rtcp/source/rtp_header_extensions.cc | 4 ++++
modules/rtp_rtcp/source/rtp_header_extensions.h | 4 ++++
modules/rtp_rtcp/source/rtp_packet.cc | 4 ++++
modules/rtp_rtcp/source/rtp_sender.cc | 4 ++++
test/fuzzers/rtp_packet_fuzzer.cc | 4 ++++
5 files changed, 20 insertions(+)
build_overrides/build.gni | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc
index bb035729f8..53211fa2b4 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.cc
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc
@@ -181,6 +181,7 @@ bool AudioLevelExtension::Write(rtc::ArrayView<uint8_t> data,
return true;
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index 88b7ac3d38..57e8900e3e 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -50,6 +50,10 @@ if (host_os == "mac" || host_os == "linux") {
use_system_xcode = _result == 0
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
// An RTP Header Extension for Mixer-to-Client Audio Level Indication
//
// https://tools.ietf.org/html/rfc6465
@@ -230,6 +231,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
}
return true;
}
+#endif
// From RFC 5450: Transmission Time Offsets in RTP Streams.
//
@@ -423,6 +425,7 @@ bool PlayoutDelayLimits::Write(rtc::ArrayView<uint8_t> data,
return true;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
// CSRCAudioLevel
// Sample Audio Level Encoding Using the One-Byte Header Format
// Note that the range of len is 1 to 15 which is encoded as 0 to 14
@@ -461,6 +464,7 @@ bool CsrcAudioLevel::Write(rtc::ArrayView<uint8_t> data,
// This extension if used must have at least one audio level
return csrcAudioLevels.numAudioLevels;
}
+#endif
// Video Content Type.
//
diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h
index ed816caa10..2ad2d18036 100644
--- a/modules/rtp_rtcp/source/rtp_header_extensions.h
+++ b/modules/rtp_rtcp/source/rtp_header_extensions.h
@@ -104,6 +104,7 @@ class AudioLevelExtension {
static bool Write(rtc::ArrayView<uint8_t> data, const AudioLevel& extension);
};
+#if !defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -118,6 +119,7 @@ class CsrcAudioLevel {
static bool Write(rtc::ArrayView<uint8_t> data,
rtc::ArrayView<const uint8_t> csrc_audio_levels);
};
+#endif
class TransmissionOffset {
public:
@@ -308,6 +310,7 @@ class ColorSpaceExtension {
static size_t WriteLuminance(uint8_t* data, float f, int denominator);
};
+#if defined(WEBRTC_MOZILLA_BUILD)
class CsrcAudioLevel {
public:
static constexpr RTPExtensionType kId = kRtpExtensionCsrcAudioLevel;
@@ -322,6 +325,7 @@ class CsrcAudioLevel {
static size_t ValueSize(const CsrcAudioLevelList& csrcAudioLevels);
static bool Write(rtc::ArrayView<uint8_t> data, const CsrcAudioLevelList& csrcAudioLevels);
};
+#endif
// Base extension class for RTP header extensions which are strings.
// Subclasses must defined kId and kUri static constexpr members.
diff --git a/modules/rtp_rtcp/source/rtp_packet.cc b/modules/rtp_rtcp/source/rtp_packet.cc
index 3192c27a49..306c17e2c2 100644
--- a/modules/rtp_rtcp/source/rtp_packet.cc
+++ b/modules/rtp_rtcp/source/rtp_packet.cc
@@ -193,7 +193,9 @@ void RtpPacket::ZeroMutableExtensions() {
break;
}
case RTPExtensionType::kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel:
+#endif
case RTPExtensionType::kRtpExtensionAbsoluteCaptureTime:
case RTPExtensionType::kRtpExtensionColorSpace:
case RTPExtensionType::kRtpExtensionCorruptionDetection:
@@ -212,10 +214,12 @@ void RtpPacket::ZeroMutableExtensions() {
// Non-mutable extension. Don't change it.
break;
}
+#if defined(WEBRTC_MOZILLA_BUILD)
case RTPExtensionType::kRtpExtensionCsrcAudioLevel: {
// TODO: This is a Mozilla addition, we need to add a handler for this.
RTC_CHECK(false);
}
+#endif
}
}
}
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 258bfa1885..5b1c588197 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -115,7 +115,9 @@ bool IsNonVolatile(RTPExtensionType type) {
switch (type) {
case kRtpExtensionTransmissionTimeOffset:
case kRtpExtensionAudioLevel:
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
+#endif
case kRtpExtensionAbsoluteSendTime:
case kRtpExtensionTransportSequenceNumber:
case kRtpExtensionTransportSequenceNumber02:
@@ -140,10 +142,12 @@ bool IsNonVolatile(RTPExtensionType type) {
case kRtpExtensionNumberOfExtensions:
RTC_DCHECK_NOTREACHED();
return false;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel:
// TODO: Mozilla implement for CsrcAudioLevel
RTC_CHECK(false);
return false;
+#endif
}
RTC_CHECK_NOTREACHED();
}
diff --git a/test/fuzzers/rtp_packet_fuzzer.cc b/test/fuzzers/rtp_packet_fuzzer.cc
index 6a7b233e29..705ceee309 100644
--- a/test/fuzzers/rtp_packet_fuzzer.cc
+++ b/test/fuzzers/rtp_packet_fuzzer.cc
@@ -79,11 +79,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
packet.GetExtension<AudioLevelExtension>(&audio_level);
break;
}
+#if !defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
std::vector<uint8_t> audio_levels;
packet.GetExtension<CsrcAudioLevel>(&audio_levels);
break;
}
+#endif
case kRtpExtensionAbsoluteSendTime:
uint32_t sendtime;
packet.GetExtension<AbsoluteSendTime>(&sendtime);
@@ -170,11 +172,13 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
CorruptionDetectionMessage message;
packet.GetExtension<CorruptionDetectionExtension>(&message);
break;
+#if defined(WEBRTC_MOZILLA_BUILD)
case kRtpExtensionCsrcAudioLevel: {
CsrcAudioLevelList levels;
packet.GetExtension<CsrcAudioLevel>(&levels);
break;
}
+#endif
}
}
+use_system_xcode = false
+xcode_version = "10.15"
+mac_xcode_version = "default"
+
declare_args() {
# WebRTC doesn't depend on //base from production code but only for testing
# purposes. In any case, it doesn't depend on //third_party/perfetto which

View File

@ -1,24 +1,26 @@
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:11:09 -0500
Subject: Bug 1773223 - Generate webrtc moz.builds for all platforms at once.
r=mjf,firefox-build-system-reviewers,ahochheiden
Date: Tue, 21 Jun 2022 11:17:46 -0500
Subject: Bug 1772380 - to upstream - ref count this in lambda capture
Bug 1876843 - (fix-23cecc1d43) drop rtc:: prefix on scoped_ptr
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2e4867d8cc9813869bd80f5201d3f7d84afcd412
---
build_overrides/build.gni | 4 ++++
1 file changed, 4 insertions(+)
modules/video_capture/linux/video_capture_v4l2.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index 88b7ac3d38..57e8900e3e 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -50,6 +50,10 @@ if (host_os == "mac" || host_os == "linux") {
use_system_xcode = _result == 0
}
+use_system_xcode = false
+xcode_version = "10.15"
+mac_xcode_version = "default"
+
declare_args() {
# WebRTC doesn't depend on //base from production code but only for testing
# purposes. In any case, it doesn't depend on //third_party/perfetto which
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index a2e362bb94..6d8a5e463f 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,8 +303,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
if (_captureThread.empty()) {
quit_ = false;
_captureThread = rtc::PlatformThread::SpawnJoinable(
- [this] {
- while (CaptureProcess()) {
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
}
},
"CaptureThread",

View File

@ -1,26 +1,48 @@
From: Michael Froman <mjfroman@mac.com>
Date: Tue, 21 Jun 2022 11:17:46 -0500
Subject: Bug 1772380 - to upstream - ref count this in lambda capture
Date: Wed, 3 Aug 2022 20:21:25 -0500
Subject: Bug 1780582 - work around generating VideoFrameBufferType;r=mjf
Bug 1876843 - (fix-23cecc1d43) drop rtc:: prefix on scoped_ptr
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2e4867d8cc9813869bd80f5201d3f7d84afcd412
---
modules/video_capture/linux/video_capture_v4l2.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
.../api/org/webrtc/VideoFrameBufferType.java | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 sdk/android/api/org/webrtc/VideoFrameBufferType.java
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index a2e362bb94..6d8a5e463f 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,8 +303,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
if (_captureThread.empty()) {
quit_ = false;
_captureThread = rtc::PlatformThread::SpawnJoinable(
- [this] {
- while (CaptureProcess()) {
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
}
},
"CaptureThread",
diff --git a/sdk/android/api/org/webrtc/VideoFrameBufferType.java b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
new file mode 100644
index 0000000000..7b05b88cba
--- /dev/null
+++ b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
@@ -0,0 +1,33 @@
+
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is autogenerated by
+// java_cpp_enum.py
+// From
+// ../../api/video/video_frame_buffer.h
+
+package org.webrtc;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@IntDef({
+ VideoFrameBufferType.NATIVE, VideoFrameBufferType.I420, VideoFrameBufferType.I420A,
+ VideoFrameBufferType.I422, VideoFrameBufferType.I444, VideoFrameBufferType.I010,
+ VideoFrameBufferType.I210, VideoFrameBufferType.NV12
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface VideoFrameBufferType {
+ int NATIVE = 0;
+ int I420 = 1;
+ int I420A = 2;
+ int I422 = 3;
+ int I444 = 4;
+ int I010 = 5;
+ int I210 = 6;
+ int NV12 = 7;
+}

View File

@ -1,48 +1,53 @@
From: Michael Froman <mjfroman@mac.com>
Date: Wed, 3 Aug 2022 20:21:25 -0500
Subject: Bug 1780582 - work around generating VideoFrameBufferType;r=mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 5 Sep 2022 13:56:00 +0000
Subject: Bug 1786502 - Lock access to DeviceInfo devicechange callbacks.
r=webrtc-reviewers,jib
Differential Revision: https://phabricator.services.mozilla.com/D155365
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e826dfadfe1264c59d9b13e3c17d6f75a40f5c33
---
.../api/org/webrtc/VideoFrameBufferType.java | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 sdk/android/api/org/webrtc/VideoFrameBufferType.java
modules/video_capture/video_capture.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sdk/android/api/org/webrtc/VideoFrameBufferType.java b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
new file mode 100644
index 0000000000..7b05b88cba
--- /dev/null
+++ b/sdk/android/api/org/webrtc/VideoFrameBufferType.java
@@ -0,0 +1,33 @@
+
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file is autogenerated by
+// java_cpp_enum.py
+// From
+// ../../api/video/video_frame_buffer.h
+
+package org.webrtc;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@IntDef({
+ VideoFrameBufferType.NATIVE, VideoFrameBufferType.I420, VideoFrameBufferType.I420A,
+ VideoFrameBufferType.I422, VideoFrameBufferType.I444, VideoFrameBufferType.I010,
+ VideoFrameBufferType.I210, VideoFrameBufferType.NV12
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface VideoFrameBufferType {
+ int NATIVE = 0;
+ int I420 = 1;
+ int I420A = 2;
+ int I422 = 3;
+ int I444 = 4;
+ int I010 = 5;
+ int I210 = 6;
+ int NV12 = 7;
+}
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 7279bed476..db07580921 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -16,6 +16,8 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/video_capture/raw_video_sink_interface.h"
#include "modules/video_capture/video_capture_defines.h"
+#include "rtc_base/synchronization/mutex.h"
+#include "rtc_base/thread_annotations.h"
#include <set>
#if defined(ANDROID)
@@ -40,15 +42,18 @@ class VideoCaptureModule : public RefCountInterface {
virtual uint32_t NumberOfDevices() = 0;
virtual int32_t Refresh() = 0;
virtual void DeviceChange() {
+ MutexLock lock(&_inputCallbacksMutex);
for (auto inputCallBack : _inputCallBacks) {
inputCallBack->OnDeviceChange();
}
}
virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
_inputCallBacks.insert(callBack);
}
virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
auto it = _inputCallBacks.find(callBack);
if (it != _inputCallBacks.end()) {
_inputCallBacks.erase(it);
@@ -102,7 +107,8 @@ class VideoCaptureModule : public RefCountInterface {
virtual ~DeviceInfo() {}
private:
- std::set<VideoInputFeedBack*> _inputCallBacks;
+ Mutex _inputCallbacksMutex;
+ std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex);
};
// Register capture data callback

View File

@ -1,53 +1,49 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 5 Sep 2022 13:56:00 +0000
Subject: Bug 1786502 - Lock access to DeviceInfo devicechange callbacks.
r=webrtc-reviewers,jib
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 13:00:00 -0500
Subject: Bug 1797161 - pt1 - tweak BUILD.gn around task_queue_win usage. r?ng!
Differential Revision: https://phabricator.services.mozilla.com/D155365
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e826dfadfe1264c59d9b13e3c17d6f75a40f5c33
Add assurance that we will not build task_queue_win.cc to avoid
possible win32k API usage.
Differential Revision: https://phabricator.services.mozilla.com/D160115
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f097eb8cbd8b7686ce306a46a4db691194fd39c1
---
modules/video_capture/video_capture.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
api/task_queue/BUILD.gn | 5 +++++
rtc_base/BUILD.gn | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 7279bed476..db07580921 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -16,6 +16,8 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/video_capture/raw_video_sink_interface.h"
#include "modules/video_capture/video_capture_defines.h"
+#include "rtc_base/synchronization/mutex.h"
+#include "rtc_base/thread_annotations.h"
#include <set>
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index 7e6be706f8..bacc3ca87a 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -29,6 +29,11 @@ rtc_library("task_queue") {
]
}
#if defined(ANDROID)
@@ -40,15 +42,18 @@ class VideoCaptureModule : public RefCountInterface {
virtual uint32_t NumberOfDevices() = 0;
virtual int32_t Refresh() = 0;
virtual void DeviceChange() {
+ MutexLock lock(&_inputCallbacksMutex);
for (auto inputCallBack : _inputCallBacks) {
inputCallBack->OnDeviceChange();
}
}
virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
_inputCallBacks.insert(callBack);
}
virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
+ MutexLock lock(&_inputCallbacksMutex);
auto it = _inputCallBacks.find(callBack);
if (it != _inputCallBacks.end()) {
_inputCallBacks.erase(it);
@@ -102,7 +107,8 @@ class VideoCaptureModule : public RefCountInterface {
virtual ~DeviceInfo() {}
private:
- std::set<VideoInputFeedBack*> _inputCallBacks;
+ Mutex _inputCallbacksMutex;
+ std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex);
};
// Register capture data callback
+# Mozilla - we want to ensure that rtc_include_tests is set to false
+# to guarantee that default_task_queue_factory is not used so we
+# know that remaining win32k code in task_queue_win.cc is not built.
+# See Bug 1797161 for more info.
+assert(!rtc_include_tests, "Mozilla - verify rtc_include_tests is off")
if (rtc_include_tests) {
rtc_library("task_queue_test") {
visibility = [ "*" ]
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index ec03bc2680..db74b5a811 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -696,10 +696,14 @@ if (is_mac || is_ios) {
if (is_win) {
rtc_library("rtc_task_queue_win") {
visibility = [ "../api/task_queue:default_task_queue_factory" ]
+# See Bug 1797161 for more info. Remove from build until win32k
+# usage is removed.
+if (!build_with_mozilla) {
sources = [
"task_queue_win.cc",
"task_queue_win.h",
]
+}
deps = [
":checks",
":logging",

View File

@ -1,49 +1,31 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 13:00:00 -0500
Subject: Bug 1797161 - pt1 - tweak BUILD.gn around task_queue_win usage. r?ng!
Date: Mon, 24 Oct 2022 14:03:00 -0500
Subject: Bug 1797161 - pt3 - add static_assert to ensure we don't include
task_queue_win.cc in Mozilla builds. r?ng!
Add assurance that we will not build task_queue_win.cc to avoid
possible win32k API usage.
Differential Revision: https://phabricator.services.mozilla.com/D160115
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f097eb8cbd8b7686ce306a46a4db691194fd39c1
Differential Revision: https://phabricator.services.mozilla.com/D160117
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/50b15e036924203147e34ec20e2689fe4a847645
---
api/task_queue/BUILD.gn | 5 +++++
rtc_base/BUILD.gn | 4 ++++
2 files changed, 9 insertions(+)
rtc_base/task_queue_win.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index 7e6be706f8..bacc3ca87a 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -29,6 +29,11 @@ rtc_library("task_queue") {
]
}
diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc
index 513ccd72cc..c9605c6bb2 100644
--- a/rtc_base/task_queue_win.cc
+++ b/rtc_base/task_queue_win.cc
@@ -8,6 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+# Mozilla - we want to ensure that rtc_include_tests is set to false
+# to guarantee that default_task_queue_factory is not used so we
+# know that remaining win32k code in task_queue_win.cc is not built.
+# See Bug 1797161 for more info.
+assert(!rtc_include_tests, "Mozilla - verify rtc_include_tests is off")
if (rtc_include_tests) {
rtc_library("task_queue_test") {
visibility = [ "*" ]
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index ec03bc2680..db74b5a811 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -696,10 +696,14 @@ if (is_mac || is_ios) {
if (is_win) {
rtc_library("rtc_task_queue_win") {
visibility = [ "../api/task_queue:default_task_queue_factory" ]
+# See Bug 1797161 for more info. Remove from build until win32k
+# usage is removed.
+if (!build_with_mozilla) {
sources = [
"task_queue_win.cc",
"task_queue_win.h",
]
+}
deps = [
":checks",
":logging",
+// Mozilla - this file should not be included in Mozilla builds until
+// win32k API usage is removed. This was once done in Bug 1395259, but
+// the upstreaming attempt stalled. Until win32k usage is officially
+// removed upstream, we have reverted to upstream's version of the file
+// (to reduce or elminate merge conflicts), and a static assert is
+// placed here to ensure this file isn't accidentally included in the
+// Mozilla build.
+static_assert(false, "This file should not be built, see Bug 1797161.");
+
#include "rtc_base/task_queue_win.h"
// clang-format off

View File

@ -1,31 +1,78 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Oct 2022 14:03:00 -0500
Subject: Bug 1797161 - pt3 - add static_assert to ensure we don't include
task_queue_win.cc in Mozilla builds. r?ng!
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Expose mac camera capture backend in .gn and switch it
to gecko libyuv. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D160117
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/50b15e036924203147e34ec20e2689fe4a847645
Differential Revision: https://phabricator.services.mozilla.com/D163682
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca938597783c8a377b9bea209
---
rtc_base/task_queue_win.cc | 9 +++++++++
1 file changed, 9 insertions(+)
BUILD.gn | 4 ++++
sdk/BUILD.gn | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc
index 513ccd72cc..c9605c6bb2 100644
--- a/rtc_base/task_queue_win.cc
+++ b/rtc_base/task_queue_win.cc
@@ -8,6 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
diff --git a/BUILD.gn b/BUILD.gn
index e1711d7e7c..592696f317 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -644,6 +644,10 @@ if (!build_with_chromium) {
]
}
+// Mozilla - this file should not be included in Mozilla builds until
+// win32k API usage is removed. This was once done in Bug 1395259, but
+// the upstreaming attempt stalled. Until win32k usage is officially
+// removed upstream, we have reverted to upstream's version of the file
+// (to reduce or elminate merge conflicts), and a static assert is
+// placed here to ensure this file isn't accidentally included in the
+// Mozilla build.
+static_assert(false, "This file should not be built, see Bug 1797161.");
+ if (build_with_mozilla && is_mac) {
+ deps += [ "sdk:videocapture_objc" ]
+ }
+
#include "rtc_base/task_queue_win.h"
if (rtc_enable_protobuf) {
deps += [ "logging:rtc_event_log_proto" ]
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 27fb4adada..fce3ca62ff 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -527,6 +527,7 @@ if (is_ios || is_mac) {
}
}
// clang-format off
+ if (!build_with_mozilla) {
rtc_library("videosource_objc") {
sources = [
"objc/api/peerconnection/RTCVideoSource+Private.h",
@@ -556,6 +557,7 @@ if (is_ios || is_mac) {
":used_from_extension",
]
}
+ }
rtc_library("videoframebuffer_objc") {
visibility = [ "*" ]
@@ -588,6 +590,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("metal_objc") {
visibility = [ "*" ]
allow_poison = [
@@ -649,6 +652,7 @@ if (is_ios || is_mac) {
":videoframebuffer_objc",
]
}
+ }
rtc_library("videocapture_objc") {
visibility = [ "*" ]
@@ -677,6 +681,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("videocodec_objc") {
visibility = [ "*" ]
configs += [ "..:no_global_constructors" ]
@@ -1765,5 +1770,6 @@ if (is_ios || is_mac) {
"VideoToolbox.framework",
]
}
+ }
}
}

View File

@ -1,78 +1,28 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Expose mac camera capture backend in .gn and switch it
to gecko libyuv. r=webrtc-reviewers,mjf
Subject: Bug 1451394 - Record video frame captures with PerformanceRecorder in
the new mac camera backend. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D163682
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca938597783c8a377b9bea209
Also includes:
Bug 1806605 - Pass TrackingId instead of nsCString to CaptureStage.
Differential Revision: https://phabricator.services.mozilla.com/D163687
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7362238c9e6fbe0d28200f6b41fc40a0c9a2158
---
BUILD.gn | 4 ++++
sdk/BUILD.gn | 6 ++++++
2 files changed, 10 insertions(+)
modules/video_capture/video_capture.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/BUILD.gn b/BUILD.gn
index e1711d7e7c..592696f317 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -644,6 +644,10 @@ if (!build_with_chromium) {
]
}
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index db07580921..43a6a7f832 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -154,6 +154,9 @@ class VideoCaptureModule : public RefCountInterface {
// Return whether the rotation is applied or left pending.
virtual bool GetApplyRotation() = 0;
+ if (build_with_mozilla && is_mac) {
+ deps += [ "sdk:videocapture_objc" ]
+ }
+ // Mozilla: TrackingId setter for use in profiler markers.
+ virtual void SetTrackingId(uint32_t aTrackingIdProcId) {}
+
if (rtc_enable_protobuf) {
deps += [ "logging:rtc_event_log_proto" ]
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 27fb4adada..fce3ca62ff 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -527,6 +527,7 @@ if (is_ios || is_mac) {
}
}
+ if (!build_with_mozilla) {
rtc_library("videosource_objc") {
sources = [
"objc/api/peerconnection/RTCVideoSource+Private.h",
@@ -556,6 +557,7 @@ if (is_ios || is_mac) {
":used_from_extension",
]
}
+ }
rtc_library("videoframebuffer_objc") {
visibility = [ "*" ]
@@ -588,6 +590,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("metal_objc") {
visibility = [ "*" ]
allow_poison = [
@@ -649,6 +652,7 @@ if (is_ios || is_mac) {
":videoframebuffer_objc",
]
}
+ }
rtc_library("videocapture_objc") {
visibility = [ "*" ]
@@ -677,6 +681,7 @@ if (is_ios || is_mac) {
]
}
+ if (!build_with_mozilla) {
rtc_library("videocodec_objc") {
visibility = [ "*" ]
configs += [ "..:no_global_constructors" ]
@@ -1765,5 +1770,6 @@ if (is_ios || is_mac) {
"VideoToolbox.framework",
]
}
+ }
}
}
protected:
~VideoCaptureModule() override {}
};

View File

@ -1,28 +1,346 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 12 Dec 2022 15:47:00 +0000
Subject: Bug 1451394 - Record video frame captures with PerformanceRecorder in
the new mac camera backend. r=padenot
Date: Tue, 23 Nov 2021 14:11:00 +0000
Subject: Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for
received video. r=ng
Depends on D131707
Differential Revision: https://phabricator.services.mozilla.com/D131708
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0196a45a1f449874fc2a759e85e403c45c25575
Also includes:
Bug 1806605 - Pass TrackingId instead of nsCString to CaptureStage.
Differential Revision: https://phabricator.services.mozilla.com/D163687
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7362238c9e6fbe0d28200f6b41fc40a0c9a2158
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163959
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee566d1bfb654d36e5d58dce637fb0580b989ac1
---
modules/video_capture/video_capture.h | 3 +++
1 file changed, 3 insertions(+)
api/video/frame_buffer.cc | 25 ++++++++++++++++++++++---
api/video/frame_buffer.h | 4 ++++
call/video_receive_stream.h | 2 ++
modules/video_coding/packet_buffer.cc | 10 +++++++---
modules/video_coding/packet_buffer.h | 5 ++++-
video/receive_statistics_proxy.cc | 5 +++++
video/receive_statistics_proxy.h | 1 +
video/rtp_video_stream_receiver2.cc | 5 ++++-
video/rtp_video_stream_receiver2.h | 3 +++
video/video_receive_stream2.cc | 1 +
video/video_stream_buffer_controller.cc | 12 ++++++++++++
video/video_stream_buffer_controller.h | 5 +++++
12 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index db07580921..43a6a7f832 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -154,6 +154,9 @@ class VideoCaptureModule : public RefCountInterface {
// Return whether the rotation is applied or left pending.
virtual bool GetApplyRotation() = 0;
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index fe9d4c3d23..4981acf0ca 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -149,14 +149,29 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
}
+ // Mozilla: TrackingId setter for use in profiler markers.
+ virtual void SetTrackingId(uint32_t aTrackingIdProcId) {}
auto end_it = std::next(next_decodable_temporal_unit_->last_frame);
- num_dropped_frames_ += std::count_if(
- frames_.begin(), end_it,
- [](const auto& f) { return f.second.encoded_frame != nullptr; });
+
protected:
~VideoCaptureModule() override {}
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), end_it);
frames_.erase(frames_.begin(), end_it);
FindNextAndLastDecodableTemporalUnit();
}
+void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it) {
+ unsigned int num_discarded_packets = 0;
+ unsigned int num_dropped_frames =
+ std::count_if(begin_it, end_it, [&](const auto& f) {
+ if (f.second.encoded_frame) {
+ const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ num_discarded_packets += packetInfos.size();
+ }
+ return f.second.encoded_frame != nullptr;
+ });
+
+ num_dropped_frames_ += num_dropped_frames;
+ num_discarded_packets_ += num_discarded_packets;
+}
+
std::optional<int64_t> FrameBuffer::LastContinuousFrameId() const {
return last_continuous_frame_id_;
}
@@ -176,6 +191,9 @@ int FrameBuffer::GetTotalNumberOfContinuousTemporalUnits() const {
int FrameBuffer::GetTotalNumberOfDroppedFrames() const {
return num_dropped_frames_;
}
+int FrameBuffer::GetTotalNumberOfDiscardedPackets() const {
+ return num_discarded_packets_;
+}
size_t FrameBuffer::CurrentSize() const {
return frames_.size();
@@ -278,6 +296,7 @@ void FrameBuffer::FindNextAndLastDecodableTemporalUnit() {
}
void FrameBuffer::Clear() {
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), frames_.end());
frames_.clear();
next_decodable_temporal_unit_.reset();
decodable_temporal_units_info_.reset();
diff --git a/api/video/frame_buffer.h b/api/video/frame_buffer.h
index e607a182c2..5f2c5d0f2a 100644
--- a/api/video/frame_buffer.h
+++ b/api/video/frame_buffer.h
@@ -67,6 +67,7 @@ class FrameBuffer {
int GetTotalNumberOfContinuousTemporalUnits() const;
int GetTotalNumberOfDroppedFrames() const;
+ int GetTotalNumberOfDiscardedPackets() const;
size_t CurrentSize() const;
private:
@@ -88,6 +89,8 @@ class FrameBuffer {
void PropagateContinuity(const FrameIterator& frame_it);
void FindNextAndLastDecodableTemporalUnit();
void Clear();
+ void UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it);
const bool legacy_frame_id_jump_behavior_;
const size_t max_size_;
@@ -100,6 +103,7 @@ class FrameBuffer {
int num_continuous_temporal_units_ = 0;
int num_dropped_frames_ = 0;
+ int num_discarded_packets_ = 0;
};
} // namespace webrtc
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 472199ef57..cda4dac800 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -116,6 +116,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// https://www.w3.org/TR/webrtc-stats/#dom-rtcvideoreceiverstats-framesdropped
uint32_t frames_dropped = 0;
uint32_t frames_decoded = 0;
+ // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsdiscarded
+ uint64_t packets_discarded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
TimeDelta total_decode_time = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index 9d7b6e550c..c1f367cb3e 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -127,25 +127,27 @@ PacketBuffer::InsertResult PacketBuffer::InsertPacket(
return result;
}
-void PacketBuffer::ClearTo(uint16_t seq_num) {
+uint32_t PacketBuffer::ClearTo(uint16_t seq_num) {
// We have already cleared past this sequence number, no need to do anything.
if (is_cleared_to_first_seq_num_ &&
AheadOf<uint16_t>(first_seq_num_, seq_num)) {
- return;
+ return 0;
}
// If the packet buffer was cleared between a frame was created and returned.
if (!first_packet_received_)
- return;
+ return 0;
// Avoid iterating over the buffer more than once by capping the number of
// iterations to the `size_` of the buffer.
++seq_num;
+ uint32_t num_cleared_packets = 0;
size_t diff = ForwardDiff<uint16_t>(first_seq_num_, seq_num);
size_t iterations = std::min(diff, buffer_.size());
for (size_t i = 0; i < iterations; ++i) {
auto& stored = buffer_[first_seq_num_ % buffer_.size()];
if (stored != nullptr && AheadOf<uint16_t>(seq_num, stored->seq_num())) {
+ ++num_cleared_packets;
stored = nullptr;
}
++first_seq_num_;
@@ -161,6 +163,8 @@ void PacketBuffer::ClearTo(uint16_t seq_num) {
received_padding_.erase(received_padding_.begin(),
received_padding_.lower_bound(seq_num));
+
+ return num_cleared_packets;
}
void PacketBuffer::Clear() {
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index 495f64bdb3..10a9caacdd 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -80,7 +80,10 @@ class PacketBuffer {
ABSL_MUST_USE_RESULT InsertResult
InsertPacket(std::unique_ptr<Packet> packet);
ABSL_MUST_USE_RESULT InsertResult InsertPadding(uint16_t seq_num);
- void ClearTo(uint16_t seq_num);
+
+ // Clear all packets older than |seq_num|. Returns the number of packets
+ // cleared.
+ uint32_t ClearTo(uint16_t seq_num);
void Clear();
void ForceSpsPpsIdrIsH264Keyframe();
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index e74968bdfd..729f7b7efb 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -799,6 +799,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}));
}
+void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+}
+
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
RTC_DCHECK_RUN_ON(&main_thread_);
last_codec_type_ = codec_type;
diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h
index 7af28fd982..8d5e208d63 100644
--- a/video/receive_statistics_proxy.h
+++ b/video/receive_statistics_proxy.h
@@ -95,6 +95,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver,
void OnDecodableFrame(TimeDelta jitter_buffer_delay,
TimeDelta target_delay,
TimeDelta minimum_delay) override;
+ void OnDiscardedPackets(uint32_t packets_discarded) override;
void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
int target_delay_ms,
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 6fe5b247bd..a1d863b3ec 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -239,6 +239,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
OnCompleteFrameCallback* complete_frame_callback,
scoped_refptr<FrameDecryptorInterface> frame_decryptor,
scoped_refptr<FrameTransformerInterface> frame_transformer)
@@ -282,6 +283,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
config_.rtp.nack,
&rtcp_feedback_buffer_,
&rtcp_feedback_buffer_)),
+ vcm_receive_statistics_(vcm_receive_statistics),
packet_buffer_(kPacketBufferStartSize,
PacketBufferMaxSize(env_.field_trials())),
reference_finder_(std::make_unique<RtpFrameReferenceFinder>()),
@@ -1234,7 +1236,8 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
int64_t unwrapped_rtp_seq_num = rtp_seq_num_unwrapper_.Unwrap(seq_num);
packet_infos_.erase(packet_infos_.begin(),
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
- packet_buffer_.ClearTo(seq_num);
+ uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 11b9548b76..d993fa104f 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -51,6 +51,7 @@
#include "rtc_base/thread_annotations.h"
#include "video/buffered_frame_decryptor.h"
#include "video/unique_timestamp_counter.h"
+#include "video/video_stream_buffer_controller.h"
namespace webrtc {
@@ -93,6 +94,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
// The KeyFrameRequestSender is optional; if not provided, key frame
// requests are sent via the internal RtpRtcp module.
OnCompleteFrameCallback* complete_frame_callback,
@@ -367,6 +369,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::unique_ptr<LossNotificationController> loss_notification_controller_
RTC_GUARDED_BY(packet_sequence_checker_);
+ VideoStreamBufferControllerStatsObserver* const vcm_receive_statistics_;
video_coding::PacketBuffer packet_buffer_
RTC_GUARDED_BY(packet_sequence_checker_);
// h26x_packet_buffer_ is nullptr if codec list doens't contain H.264 or
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index ed9edcdd08..7ff917e05c 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -209,6 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2(
&stats_proxy_,
&stats_proxy_,
nack_periodic_processor,
+ &stats_proxy_,
this, // OnCompleteFrameCallback
std::move(config_.frame_decryptor),
std::move(config_.frame_transformer)),
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 83de75ac3f..01063b12f7 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -259,6 +259,7 @@ void VideoStreamBufferController::OnFrameReady(
// Update stats.
UpdateDroppedFrames();
+ UpdateDiscardedPackets();
UpdateFrameBufferTimings(min_receive_time, now);
UpdateTimingFrameInfo();
@@ -324,6 +325,17 @@ void VideoStreamBufferController::UpdateDroppedFrames()
buffer_->GetTotalNumberOfDroppedFrames();
}
+void VideoStreamBufferController::UpdateDiscardedPackets()
+ RTC_RUN_ON(&worker_sequence_checker_) {
+ const int discarded_packets = buffer_->GetTotalNumberOfDiscardedPackets() -
+ packets_discarded_before_last_new_frame_;
+ if (discarded_packets > 0) {
+ stats_proxy_->OnDiscardedPackets(discarded_packets);
+ }
+ packets_discarded_before_last_new_frame_ =
+ buffer_->GetTotalNumberOfDiscardedPackets();
+}
+
void VideoStreamBufferController::UpdateFrameBufferTimings(
Timestamp min_receive_time,
Timestamp now) {
diff --git a/video/video_stream_buffer_controller.h b/video/video_stream_buffer_controller.h
index 43d4544f71..3f3d6e465c 100644
--- a/video/video_stream_buffer_controller.h
+++ b/video/video_stream_buffer_controller.h
@@ -52,6 +52,8 @@ class VideoStreamBufferControllerStatsObserver {
TimeDelta target_delay,
TimeDelta minimum_delay) = 0;
+ virtual void OnDiscardedPackets(uint32_t packets_discarded) = 0;
+
// Various jitter buffer delays determined by VCMTiming.
virtual void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
@@ -94,6 +96,7 @@ class VideoStreamBufferController {
void OnTimeout(TimeDelta delay);
void FrameReadyForDecode(uint32_t rtp_timestamp, Timestamp render_time);
void UpdateDroppedFrames() RTC_RUN_ON(&worker_sequence_checker_);
+ void UpdateDiscardedPackets() RTC_RUN_ON(&worker_sequence_checker_);
void UpdateFrameBufferTimings(Timestamp min_receive_time, Timestamp now);
void UpdateTimingFrameInfo();
bool IsTooManyFramesQueued() const RTC_RUN_ON(&worker_sequence_checker_);
@@ -120,6 +123,8 @@ class VideoStreamBufferController {
RTC_GUARDED_BY(&worker_sequence_checker_);
int frames_dropped_before_last_new_frame_
RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
+ int packets_discarded_before_last_new_frame_
+ RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
VCMVideoProtection protection_mode_
RTC_GUARDED_BY(&worker_sequence_checker_) = kProtectionNack;

View File

@ -1,346 +1,46 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 23 Nov 2021 14:11:00 +0000
Subject: Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for
received video. r=ng
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748478 - Propagate calculated discarded packets to stats. r=bwc
Depends on D131707
Differential Revision: https://phabricator.services.mozilla.com/D131708
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d0196a45a1f449874fc2a759e85e403c45c25575
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1742181 - libwebrtc: Implement packetsDiscarded bookkeeping for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163959
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee566d1bfb654d36e5d58dce637fb0580b989ac1
Differential Revision: https://phabricator.services.mozilla.com/D135061
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56fbf0469e25fa0d589c51ca112ce534a7c0ab91
---
api/video/frame_buffer.cc | 25 ++++++++++++++++++++++---
api/video/frame_buffer.h | 4 ++++
call/video_receive_stream.h | 2 ++
modules/video_coding/packet_buffer.cc | 10 +++++++---
modules/video_coding/packet_buffer.h | 5 ++++-
video/receive_statistics_proxy.cc | 5 +++++
video/receive_statistics_proxy.h | 1 +
video/rtp_video_stream_receiver2.cc | 5 ++++-
video/rtp_video_stream_receiver2.h | 3 +++
video/video_receive_stream2.cc | 1 +
video/video_stream_buffer_controller.cc | 12 ++++++++++++
video/video_stream_buffer_controller.h | 5 +++++
12 files changed, 70 insertions(+), 8 deletions(-)
video/receive_statistics_proxy.cc | 9 +++++++--
video/rtp_video_stream_receiver2.cc | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index fe9d4c3d23..4981acf0ca 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -149,14 +149,29 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
}
auto end_it = std::next(next_decodable_temporal_unit_->last_frame);
- num_dropped_frames_ += std::count_if(
- frames_.begin(), end_it,
- [](const auto& f) { return f.second.encoded_frame != nullptr; });
+
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), end_it);
frames_.erase(frames_.begin(), end_it);
FindNextAndLastDecodableTemporalUnit();
}
+void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it) {
+ unsigned int num_discarded_packets = 0;
+ unsigned int num_dropped_frames =
+ std::count_if(begin_it, end_it, [&](const auto& f) {
+ if (f.second.encoded_frame) {
+ const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ num_discarded_packets += packetInfos.size();
+ }
+ return f.second.encoded_frame != nullptr;
+ });
+
+ num_dropped_frames_ += num_dropped_frames;
+ num_discarded_packets_ += num_discarded_packets;
+}
+
std::optional<int64_t> FrameBuffer::LastContinuousFrameId() const {
return last_continuous_frame_id_;
}
@@ -176,6 +191,9 @@ int FrameBuffer::GetTotalNumberOfContinuousTemporalUnits() const {
int FrameBuffer::GetTotalNumberOfDroppedFrames() const {
return num_dropped_frames_;
}
+int FrameBuffer::GetTotalNumberOfDiscardedPackets() const {
+ return num_discarded_packets_;
+}
size_t FrameBuffer::CurrentSize() const {
return frames_.size();
@@ -278,6 +296,7 @@ void FrameBuffer::FindNextAndLastDecodableTemporalUnit() {
}
void FrameBuffer::Clear() {
+ UpdateDroppedFramesAndDiscardedPackets(frames_.begin(), frames_.end());
frames_.clear();
next_decodable_temporal_unit_.reset();
decodable_temporal_units_info_.reset();
diff --git a/api/video/frame_buffer.h b/api/video/frame_buffer.h
index e607a182c2..5f2c5d0f2a 100644
--- a/api/video/frame_buffer.h
+++ b/api/video/frame_buffer.h
@@ -67,6 +67,7 @@ class FrameBuffer {
int GetTotalNumberOfContinuousTemporalUnits() const;
int GetTotalNumberOfDroppedFrames() const;
+ int GetTotalNumberOfDiscardedPackets() const;
size_t CurrentSize() const;
private:
@@ -88,6 +89,8 @@ class FrameBuffer {
void PropagateContinuity(const FrameIterator& frame_it);
void FindNextAndLastDecodableTemporalUnit();
void Clear();
+ void UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
+ FrameIterator end_it);
const bool legacy_frame_id_jump_behavior_;
const size_t max_size_;
@@ -100,6 +103,7 @@ class FrameBuffer {
int num_continuous_temporal_units_ = 0;
int num_dropped_frames_ = 0;
+ int num_discarded_packets_ = 0;
};
} // namespace webrtc
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 472199ef57..cda4dac800 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -116,6 +116,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
// https://www.w3.org/TR/webrtc-stats/#dom-rtcvideoreceiverstats-framesdropped
uint32_t frames_dropped = 0;
uint32_t frames_decoded = 0;
+ // https://w3c.github.io/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsdiscarded
+ uint64_t packets_discarded = 0;
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime
TimeDelta total_decode_time = TimeDelta::Zero();
// https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index 9d7b6e550c..c1f367cb3e 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -127,25 +127,27 @@ PacketBuffer::InsertResult PacketBuffer::InsertPacket(
return result;
}
-void PacketBuffer::ClearTo(uint16_t seq_num) {
+uint32_t PacketBuffer::ClearTo(uint16_t seq_num) {
// We have already cleared past this sequence number, no need to do anything.
if (is_cleared_to_first_seq_num_ &&
AheadOf<uint16_t>(first_seq_num_, seq_num)) {
- return;
+ return 0;
}
// If the packet buffer was cleared between a frame was created and returned.
if (!first_packet_received_)
- return;
+ return 0;
// Avoid iterating over the buffer more than once by capping the number of
// iterations to the `size_` of the buffer.
++seq_num;
+ uint32_t num_cleared_packets = 0;
size_t diff = ForwardDiff<uint16_t>(first_seq_num_, seq_num);
size_t iterations = std::min(diff, buffer_.size());
for (size_t i = 0; i < iterations; ++i) {
auto& stored = buffer_[first_seq_num_ % buffer_.size()];
if (stored != nullptr && AheadOf<uint16_t>(seq_num, stored->seq_num())) {
+ ++num_cleared_packets;
stored = nullptr;
}
++first_seq_num_;
@@ -161,6 +163,8 @@ void PacketBuffer::ClearTo(uint16_t seq_num) {
received_padding_.erase(received_padding_.begin(),
received_padding_.lower_bound(seq_num));
+
+ return num_cleared_packets;
}
void PacketBuffer::Clear() {
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index 495f64bdb3..10a9caacdd 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -80,7 +80,10 @@ class PacketBuffer {
ABSL_MUST_USE_RESULT InsertResult
InsertPacket(std::unique_ptr<Packet> packet);
ABSL_MUST_USE_RESULT InsertResult InsertPadding(uint16_t seq_num);
- void ClearTo(uint16_t seq_num);
+
+ // Clear all packets older than |seq_num|. Returns the number of packets
+ // cleared.
+ uint32_t ClearTo(uint16_t seq_num);
void Clear();
void ForceSpsPpsIdrIsH264Keyframe();
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index e74968bdfd..729f7b7efb 100644
index 729f7b7efb..6e75eb837f 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -799,6 +799,11 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}));
@@ -800,8 +800,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
- RTC_DCHECK_RUN_ON(&main_thread_);
- stats_.packets_discarded += packets_discarded;
+ // Can be called on either the decode queue or the worker thread
+ // See FrameBuffer2 for more details.
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [packets_discarded, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+ }));
}
+void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+}
+
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
RTC_DCHECK_RUN_ON(&main_thread_);
last_codec_type_ = codec_type;
diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h
index 7af28fd982..8d5e208d63 100644
--- a/video/receive_statistics_proxy.h
+++ b/video/receive_statistics_proxy.h
@@ -95,6 +95,7 @@ class ReceiveStatisticsProxy : public VideoStreamBufferControllerStatsObserver,
void OnDecodableFrame(TimeDelta jitter_buffer_delay,
TimeDelta target_delay,
TimeDelta minimum_delay) override;
+ void OnDiscardedPackets(uint32_t packets_discarded) override;
void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
int target_delay_ms,
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 6fe5b247bd..a1d863b3ec 100644
index a1d863b3ec..d8930a8b8e 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -239,6 +239,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
OnCompleteFrameCallback* complete_frame_callback,
scoped_refptr<FrameDecryptorInterface> frame_decryptor,
scoped_refptr<FrameTransformerInterface> frame_transformer)
@@ -282,6 +283,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
config_.rtp.nack,
&rtcp_feedback_buffer_,
&rtcp_feedback_buffer_)),
+ vcm_receive_statistics_(vcm_receive_statistics),
packet_buffer_(kPacketBufferStartSize,
PacketBufferMaxSize(env_.field_trials())),
reference_finder_(std::make_unique<RtpFrameReferenceFinder>()),
@@ -1234,7 +1236,8 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
int64_t unwrapped_rtp_seq_num = rtp_seq_num_unwrapper_.Unwrap(seq_num);
@@ -1237,7 +1237,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.erase(packet_infos_.begin(),
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
- packet_buffer_.ClearTo(seq_num);
+ uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
- vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ if (num_packets_cleared > 0) {
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ }
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h
index 11b9548b76..d993fa104f 100644
--- a/video/rtp_video_stream_receiver2.h
+++ b/video/rtp_video_stream_receiver2.h
@@ -51,6 +51,7 @@
#include "rtc_base/thread_annotations.h"
#include "video/buffered_frame_decryptor.h"
#include "video/unique_timestamp_counter.h"
+#include "video/video_stream_buffer_controller.h"
namespace webrtc {
@@ -93,6 +94,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
RtcpCnameCallback* rtcp_cname_callback,
NackPeriodicProcessor* nack_periodic_processor,
+ VideoStreamBufferControllerStatsObserver* vcm_receive_statistics,
// The KeyFrameRequestSender is optional; if not provided, key frame
// requests are sent via the internal RtpRtcp module.
OnCompleteFrameCallback* complete_frame_callback,
@@ -367,6 +369,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender,
std::unique_ptr<LossNotificationController> loss_notification_controller_
RTC_GUARDED_BY(packet_sequence_checker_);
+ VideoStreamBufferControllerStatsObserver* const vcm_receive_statistics_;
video_coding::PacketBuffer packet_buffer_
RTC_GUARDED_BY(packet_sequence_checker_);
// h26x_packet_buffer_ is nullptr if codec list doens't contain H.264 or
diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc
index ed9edcdd08..7ff917e05c 100644
--- a/video/video_receive_stream2.cc
+++ b/video/video_receive_stream2.cc
@@ -209,6 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2(
&stats_proxy_,
&stats_proxy_,
nack_periodic_processor,
+ &stats_proxy_,
this, // OnCompleteFrameCallback
std::move(config_.frame_decryptor),
std::move(config_.frame_transformer)),
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 83de75ac3f..01063b12f7 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -259,6 +259,7 @@ void VideoStreamBufferController::OnFrameReady(
// Update stats.
UpdateDroppedFrames();
+ UpdateDiscardedPackets();
UpdateFrameBufferTimings(min_receive_time, now);
UpdateTimingFrameInfo();
@@ -324,6 +325,17 @@ void VideoStreamBufferController::UpdateDroppedFrames()
buffer_->GetTotalNumberOfDroppedFrames();
}
+void VideoStreamBufferController::UpdateDiscardedPackets()
+ RTC_RUN_ON(&worker_sequence_checker_) {
+ const int discarded_packets = buffer_->GetTotalNumberOfDiscardedPackets() -
+ packets_discarded_before_last_new_frame_;
+ if (discarded_packets > 0) {
+ stats_proxy_->OnDiscardedPackets(discarded_packets);
+ }
+ packets_discarded_before_last_new_frame_ =
+ buffer_->GetTotalNumberOfDiscardedPackets();
+}
+
void VideoStreamBufferController::UpdateFrameBufferTimings(
Timestamp min_receive_time,
Timestamp now) {
diff --git a/video/video_stream_buffer_controller.h b/video/video_stream_buffer_controller.h
index 43d4544f71..3f3d6e465c 100644
--- a/video/video_stream_buffer_controller.h
+++ b/video/video_stream_buffer_controller.h
@@ -52,6 +52,8 @@ class VideoStreamBufferControllerStatsObserver {
TimeDelta target_delay,
TimeDelta minimum_delay) = 0;
+ virtual void OnDiscardedPackets(uint32_t packets_discarded) = 0;
+
// Various jitter buffer delays determined by VCMTiming.
virtual void OnFrameBufferTimingsUpdated(int estimated_max_decode_time_ms,
int current_delay_ms,
@@ -94,6 +96,7 @@ class VideoStreamBufferController {
void OnTimeout(TimeDelta delay);
void FrameReadyForDecode(uint32_t rtp_timestamp, Timestamp render_time);
void UpdateDroppedFrames() RTC_RUN_ON(&worker_sequence_checker_);
+ void UpdateDiscardedPackets() RTC_RUN_ON(&worker_sequence_checker_);
void UpdateFrameBufferTimings(Timestamp min_receive_time, Timestamp now);
void UpdateTimingFrameInfo();
bool IsTooManyFramesQueued() const RTC_RUN_ON(&worker_sequence_checker_);
@@ -120,6 +123,8 @@ class VideoStreamBufferController {
RTC_GUARDED_BY(&worker_sequence_checker_);
int frames_dropped_before_last_new_frame_
RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
+ int packets_discarded_before_last_new_frame_
+ RTC_GUARDED_BY(&worker_sequence_checker_) = 0;
VCMVideoProtection protection_mode_
RTC_GUARDED_BY(&worker_sequence_checker_) = kProtectionNack;

View File

@ -1,46 +1,221 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748478 - Propagate calculated discarded packets to stats. r=bwc
Subject: Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for
received video. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D135061
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56fbf0469e25fa0d589c51ca112ce534a7c0ab91
This lets us see in the profiler how many received frames and packets we decide
to drop and the reasons why.
Differential Revision: https://phabricator.services.mozilla.com/D135062
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08e252da94c4752eccfd845eef13d8517953cc6a
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163960
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8e9a326a99cd5eaa6e447ff57c01ad9d79a09744
---
video/receive_statistics_proxy.cc | 9 +++++++--
video/rtp_video_stream_receiver2.cc | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
api/video/frame_buffer.cc | 33 +++++++++++++++++++++++++
video/receive_statistics_proxy.cc | 11 +++++++++
video/rtp_video_stream_receiver2.cc | 4 +++
video/video_stream_buffer_controller.cc | 7 ++++++
4 files changed, 55 insertions(+)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index 4981acf0ca..f0c48f3702 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -25,6 +25,7 @@
#include "api/video/encoded_frame.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
@@ -77,7 +78,12 @@ FrameBuffer::FrameBuffer(int max_size,
decoded_frame_history_(max_decode_history) {}
bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
if (!ValidReferences(*frame)) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Invalid references)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Frame " << frame->Id()
<< " has invalid references, dropping frame.";
return false;
@@ -87,23 +93,35 @@ bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
if (legacy_frame_id_jump_behavior_ && frame->is_keyframe() &&
AheadOf(frame->RtpTimestamp(),
*decoded_frame_history_.GetLastDecodedFrameTimestamp())) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (OOO + PicId jump)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING)
<< "Keyframe " << frame->Id()
<< " has newer timestamp but older picture id, clearing buffer.";
Clear();
} else {
// Already decoded past this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Out of order)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
if (frames_.size() == max_size_) {
if (frame->is_keyframe()) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (KF + Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Keyframe " << frame->Id()
<< " inserted into full buffer, clearing buffer.";
Clear();
} else {
// No space for this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
@@ -158,16 +176,31 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
FrameIterator end_it) {
+ uint32_t dropped_ssrc = 0;
+ int64_t dropped_frame_id = 0;
unsigned int num_discarded_packets = 0;
unsigned int num_dropped_frames =
std::count_if(begin_it, end_it, [&](const auto& f) {
if (f.second.encoded_frame) {
const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ dropped_frame_id = f.first;
+ if (!packetInfos.empty()) {
+ dropped_ssrc = packetInfos[0].ssrc();
+ }
num_discarded_packets += packetInfos.size();
}
return f.second.encoded_frame != nullptr;
});
+ if (num_dropped_frames > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Dropping Old Frames", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+ if (num_discarded_packets > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Discarding Old Packets", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+
num_dropped_frames_ += num_dropped_frames;
num_discarded_packets_ += num_discarded_packets;
}
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 729f7b7efb..6e75eb837f 100644
index 6e75eb837f..e8725574a0 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -800,8 +800,13 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
}
@@ -20,6 +20,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
#include "video/video_receive_stream2.h"
@@ -767,6 +768,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
VideoContentType content_type) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnCompleteFrame",
+ "remote_ssrc", remote_ssrc_, "is_keyframe", is_keyframe);
+
// Content type extension is set only for keyframes and should be propagated
// for all the following delta frames. Here we may receive frames out of order
// and miscategorise some delta frames near the layer switch.
@@ -792,6 +796,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDroppedFrames",
+ "remote_ssrc", remote_ssrc_, "frames_dropped", frames_dropped);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [frames_dropped, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -802,6 +808,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
- RTC_DCHECK_RUN_ON(&main_thread_);
- stats_.packets_discarded += packets_discarded;
+ // Can be called on either the decode queue or the worker thread
+ // See FrameBuffer2 for more details.
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [packets_discarded, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.packets_discarded += packets_discarded;
+ }));
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDiscardedPackets",
+ "remote_ssrc", remote_ssrc_, "packets_discarded",
+ packets_discarded);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [packets_discarded, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -830,6 +839,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() {
void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnRttUpdate",
+ "remote_ssrc", remote_ssrc_, "avg_rtt_ms", avg_rtt_ms);
avg_rtt_ms_ = avg_rtt_ms;
}
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index a1d863b3ec..d8930a8b8e 100644
index d8930a8b8e..531098e317 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -1237,7 +1237,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.erase(packet_infos_.begin(),
@@ -44,6 +44,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/ntp_time.h"
@@ -1238,6 +1239,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
- vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ if (num_packets_cleared > 0) {
+ vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
+ }
if (num_packets_cleared > 0) {
+ TRACE_EVENT2("webrtc",
+ "RtpVideoStreamReceiver2::FrameDecoded Cleared Old Packets",
+ "remote_ssrc", config_.rtp.remote_ssrc, "seq_num", seq_num);
vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
}
reference_finder_->ClearTo(seq_num);
}
}
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 01063b12f7..e12ce75ba0 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -31,6 +31,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/trace_event.h"
#include "video/frame_decode_scheduler.h"
#include "video/frame_decode_timing.h"
#include "video/task_queue_frame_decode_scheduler.h"
@@ -152,6 +153,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
std::unique_ptr<EncodedFrame> frame) {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
FrameMetadata metadata(*frame);
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
+ const int64_t frameId = frame->Id();
int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits();
if (buffer_->InsertFrame(std::move(frame))) {
RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!";
@@ -162,6 +166,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
*metadata.receive_time);
}
if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) {
+ TRACE_EVENT2("webrtc",
+ "VideoStreamBufferController::InsertFrame Frame Complete",
+ "remote_ssrc", ssrc, "frame_id", frameId);
stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size,
metadata.contentType);
MaybeScheduleFrameForRelease();

View File

@ -1,221 +1,27 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for
received video. r=bwc
Subject: Bug 1748458 - Add TRACE_EVENT for keyframe requests. r=bwc
This lets us see in the profiler how many received frames and packets we decide
to drop and the reasons why.
Differential Revision: https://phabricator.services.mozilla.com/D135062
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08e252da94c4752eccfd845eef13d8517953cc6a
Also includes:
Bug 1804288 - (fix-de7ae5755b) reimplement Bug 1748458 - Add TRACE_EVENTs for dropped frames and packets for received video. r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D163960
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8e9a326a99cd5eaa6e447ff57c01ad9d79a09744
Differential Revision: https://phabricator.services.mozilla.com/D135113
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5b2a7894ef1cf096d0e8977754507c0820e757fc
---
api/video/frame_buffer.cc | 33 +++++++++++++++++++++++++
video/receive_statistics_proxy.cc | 11 +++++++++
video/rtp_video_stream_receiver2.cc | 4 +++
video/video_stream_buffer_controller.cc | 7 ++++++
4 files changed, 55 insertions(+)
video/rtp_video_stream_receiver2.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc
index 4981acf0ca..f0c48f3702 100644
--- a/api/video/frame_buffer.cc
+++ b/api/video/frame_buffer.cc
@@ -25,6 +25,7 @@
#include "api/video/encoded_frame.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/trace_event.h"
namespace webrtc {
namespace {
@@ -77,7 +78,12 @@ FrameBuffer::FrameBuffer(int max_size,
decoded_frame_history_(max_decode_history) {}
bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
if (!ValidReferences(*frame)) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Invalid references)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Frame " << frame->Id()
<< " has invalid references, dropping frame.";
return false;
@@ -87,23 +93,35 @@ bool FrameBuffer::InsertFrame(std::unique_ptr<EncodedFrame> frame) {
if (legacy_frame_id_jump_behavior_ && frame->is_keyframe() &&
AheadOf(frame->RtpTimestamp(),
*decoded_frame_history_.GetLastDecodedFrameTimestamp())) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (OOO + PicId jump)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING)
<< "Keyframe " << frame->Id()
<< " has newer timestamp but older picture id, clearing buffer.";
Clear();
} else {
// Already decoded past this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Out of order)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
if (frames_.size() == max_size_) {
if (frame->is_keyframe()) {
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frames dropped (KF + Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
RTC_DLOG(LS_WARNING) << "Keyframe " << frame->Id()
<< " inserted into full buffer, clearing buffer.";
Clear();
} else {
// No space for this frame.
+ TRACE_EVENT2("webrtc",
+ "FrameBuffer::InsertFrame Frame dropped (Full buffer)",
+ "remote_ssrc", ssrc, "frame_id", frame->Id());
return false;
}
}
@@ -158,16 +176,31 @@ void FrameBuffer::DropNextDecodableTemporalUnit() {
void FrameBuffer::UpdateDroppedFramesAndDiscardedPackets(FrameIterator begin_it,
FrameIterator end_it) {
+ uint32_t dropped_ssrc = 0;
+ int64_t dropped_frame_id = 0;
unsigned int num_discarded_packets = 0;
unsigned int num_dropped_frames =
std::count_if(begin_it, end_it, [&](const auto& f) {
if (f.second.encoded_frame) {
const auto& packetInfos = f.second.encoded_frame->PacketInfos();
+ dropped_frame_id = f.first;
+ if (!packetInfos.empty()) {
+ dropped_ssrc = packetInfos[0].ssrc();
+ }
num_discarded_packets += packetInfos.size();
}
return f.second.encoded_frame != nullptr;
});
+ if (num_dropped_frames > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Dropping Old Frames", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+ if (num_discarded_packets > 0) {
+ TRACE_EVENT2("webrtc", "FrameBuffer Discarding Old Packets", "remote_ssrc",
+ dropped_ssrc, "frame_id", dropped_frame_id);
+ }
+
num_dropped_frames_ += num_dropped_frames;
num_discarded_packets_ += num_discarded_packets;
}
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 6e75eb837f..e8725574a0 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -20,6 +20,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
#include "video/video_receive_stream2.h"
@@ -767,6 +768,9 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
VideoContentType content_type) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnCompleteFrame",
+ "remote_ssrc", remote_ssrc_, "is_keyframe", is_keyframe);
+
// Content type extension is set only for keyframes and should be propagated
// for all the following delta frames. Here we may receive frames out of order
// and miscategorise some delta frames near the layer switch.
@@ -792,6 +796,8 @@ void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDroppedFrames",
+ "remote_ssrc", remote_ssrc_, "frames_dropped", frames_dropped);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [frames_dropped, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -802,6 +808,9 @@ void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
void ReceiveStatisticsProxy::OnDiscardedPackets(uint32_t packets_discarded) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnDiscardedPackets",
+ "remote_ssrc", remote_ssrc_, "packets_discarded",
+ packets_discarded);
worker_thread_->PostTask(
SafeTask(task_safety_.flag(), [packets_discarded, this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -830,6 +839,8 @@ void ReceiveStatisticsProxy::OnStreamInactive() {
void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms) {
RTC_DCHECK_RUN_ON(&main_thread_);
+ TRACE_EVENT2("webrtc", "ReceiveStatisticsProxy::OnRttUpdate",
+ "remote_ssrc", remote_ssrc_, "avg_rtt_ms", avg_rtt_ms);
avg_rtt_ms_ = avg_rtt_ms;
}
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index d8930a8b8e..531098e317 100644
index 531098e317..7df19cf29b 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -44,6 +44,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
+#include "rtc_base/trace_event.h"
#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/ntp_time.h"
@@ -718,6 +718,12 @@ void RtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived& packet) {
@@ -1238,6 +1239,9 @@ void RtpVideoStreamReceiver2::FrameDecoded(int64_t picture_id) {
packet_infos_.upper_bound(unwrapped_rtp_seq_num));
uint32_t num_packets_cleared = packet_buffer_.ClearTo(seq_num);
if (num_packets_cleared > 0) {
+ TRACE_EVENT2("webrtc",
+ "RtpVideoStreamReceiver2::FrameDecoded Cleared Old Packets",
+ "remote_ssrc", config_.rtp.remote_ssrc, "seq_num", seq_num);
vcm_receive_statistics_->OnDiscardedPackets(num_packets_cleared);
}
reference_finder_->ClearTo(seq_num);
diff --git a/video/video_stream_buffer_controller.cc b/video/video_stream_buffer_controller.cc
index 01063b12f7..e12ce75ba0 100644
--- a/video/video_stream_buffer_controller.cc
+++ b/video/video_stream_buffer_controller.cc
@@ -31,6 +31,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread_annotations.h"
+#include "rtc_base/trace_event.h"
#include "video/frame_decode_scheduler.h"
#include "video/frame_decode_timing.h"
#include "video/task_queue_frame_decode_scheduler.h"
@@ -152,6 +153,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
std::unique_ptr<EncodedFrame> frame) {
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
FrameMetadata metadata(*frame);
+ const uint32_t ssrc =
+ frame->PacketInfos().empty() ? 0 : frame->PacketInfos()[0].ssrc();
+ const int64_t frameId = frame->Id();
int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits();
if (buffer_->InsertFrame(std::move(frame))) {
RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!";
@@ -162,6 +166,9 @@ std::optional<int64_t> VideoStreamBufferController::InsertFrame(
*metadata.receive_time);
}
if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) {
+ TRACE_EVENT2("webrtc",
+ "VideoStreamBufferController::InsertFrame Frame Complete",
+ "remote_ssrc", ssrc, "frame_id", frameId);
stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size,
metadata.contentType);
MaybeScheduleFrameForRelease();
void RtpVideoStreamReceiver2::RequestKeyFrame() {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ TRACE_EVENT2("webrtc", "RtpVideoStreamReceiver2::RequestKeyFrame",
+ "remote_ssrc", config_.rtp.remote_ssrc, "method",
+ keyframe_request_method_ == KeyFrameReqMethod::kPliRtcp ? "PLI"
+ : keyframe_request_method_ == KeyFrameReqMethod::kFirRtcp ? "FIR"
+ : keyframe_request_method_ == KeyFrameReqMethod::kNone ? "None"
+ : "Other");
// TODO(bugs.webrtc.org/10336): Allow the sender to ignore key frame requests
// issued by anything other than the LossNotificationController if it (the
// sender) is relying on LNTF alone.

View File

@ -1,27 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 6 Jan 2022 00:16:00 +0000
Subject: Bug 1748458 - Add TRACE_EVENT for keyframe requests. r=bwc
Date: Wed, 11 Jan 2023 22:42:00 +0000
Subject: Bug 1800942 - Add DCHECKs to
TimestampExtrapolator::ExtrapolateLocalTime. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D135113
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5b2a7894ef1cf096d0e8977754507c0820e757fc
Differential Revision: https://phabricator.services.mozilla.com/D166536
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c5df7f40392464ffc63f44a53ddcaab2091741e0
---
video/rtp_video_stream_receiver2.cc | 6 ++++++
1 file changed, 6 insertions(+)
modules/video_coding/timing/timestamp_extrapolator.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 531098e317..7df19cf29b 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -718,6 +718,12 @@ void RtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived& packet) {
diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc
index 15605033c8..e9a3ce211e 100644
--- a/modules/video_coding/timing/timestamp_extrapolator.cc
+++ b/modules/video_coding/timing/timestamp_extrapolator.cc
@@ -126,6 +126,7 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) {
std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
uint32_t timestamp90khz) const {
int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz);
+ RTC_DCHECK_GE(unwrapped_ts90khz, 0);
void RtpVideoStreamReceiver2::RequestKeyFrame() {
RTC_DCHECK_RUN_ON(&worker_task_checker_);
+ TRACE_EVENT2("webrtc", "RtpVideoStreamReceiver2::RequestKeyFrame",
+ "remote_ssrc", config_.rtp.remote_ssrc, "method",
+ keyframe_request_method_ == KeyFrameReqMethod::kPliRtcp ? "PLI"
+ : keyframe_request_method_ == KeyFrameReqMethod::kFirRtcp ? "FIR"
+ : keyframe_request_method_ == KeyFrameReqMethod::kNone ? "None"
+ : "Other");
// TODO(bugs.webrtc.org/10336): Allow the sender to ignore key frame requests
// issued by anything other than the LossNotificationController if it (the
// sender) is relying on LNTF alone.
if (!first_unwrapped_timestamp_) {
return std::nullopt;

View File

@ -1,23 +1,25 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 11 Jan 2023 22:42:00 +0000
Subject: Bug 1800942 - Add DCHECKs to
TimestampExtrapolator::ExtrapolateLocalTime. r=mjf
Date: Wed, 8 Feb 2023 08:01:00 +0000
Subject: Bug 1814692 - Don't attempt realtime scheduling rtc::PlatformThreads.
r=webrtc-reviewers,bwc
Differential Revision: https://phabricator.services.mozilla.com/D166536
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c5df7f40392464ffc63f44a53ddcaab2091741e0
Differential Revision: https://phabricator.services.mozilla.com/D169036
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9e64a965e26c8379261466e5273c3b383164b2c7
---
modules/video_coding/timing/timestamp_extrapolator.cc | 1 +
1 file changed, 1 insertion(+)
rtc_base/platform_thread.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc
index 15605033c8..e9a3ce211e 100644
--- a/modules/video_coding/timing/timestamp_extrapolator.cc
+++ b/modules/video_coding/timing/timestamp_extrapolator.cc
@@ -126,6 +126,7 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) {
std::optional<Timestamp> TimestampExtrapolator::ExtrapolateLocalTime(
uint32_t timestamp90khz) const {
int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz);
+ RTC_DCHECK_GE(unwrapped_ts90khz, 0);
if (!first_unwrapped_timestamp_) {
return std::nullopt;
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 81e115b568..dafc028c25 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -52,6 +52,9 @@ bool SetPriority(ThreadPriority priority) {
// TODO(tommi): Switch to the same mechanism as Chromium uses for changing
// thread priorities.
return true;
+#elif defined(WEBRTC_MOZILLA_BUILD) && defined(WEBRTC_LINUX)
+ // Only realtime audio uses realtime scheduling in Firefox.
+ return true;
#else
const int policy = SCHED_FIFO;
const int min_prio = sched_get_priority_min(policy);

View File

@ -1,25 +1,74 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 8 Feb 2023 08:01:00 +0000
Subject: Bug 1814692 - Don't attempt realtime scheduling rtc::PlatformThreads.
r=webrtc-reviewers,bwc
From: Jan Grulich <jgrulich@redhat.com>
Date: Fri, 10 Mar 2023 09:21:00 +0000
Subject: Bug 1819035 - get EGL display based on the used platform in the
browser r=webrtc-reviewers,ng
Differential Revision: https://phabricator.services.mozilla.com/D169036
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9e64a965e26c8379261466e5273c3b383164b2c7
Because of a possible misconfiguration or a possible driver issue it
might happen that the browser will use a different driver on X11 and
end up using yet another one for wayland/gbm, which might lead to not
working screen sharing in the better case, but also to a crash in the
other driver (Nvidia). This adds a check for platform the browser runs
on, if it's XWayland or Wayland and based on that query EGL display for
that specific platform, rather than going for the Wayland one only.
Differential Revision: https://phabricator.services.mozilla.com/D171858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c8606497de1f461a6352456e0e511c2ae498d526
---
rtc_base/platform_thread.cc | 3 +++
1 file changed, 3 insertions(+)
.../linux/wayland/egl_dmabuf.cc | 30 +++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc
index 81e115b568..dafc028c25 100644
--- a/rtc_base/platform_thread.cc
+++ b/rtc_base/platform_thread.cc
@@ -52,6 +52,9 @@ bool SetPriority(ThreadPriority priority) {
// TODO(tommi): Switch to the same mechanism as Chromium uses for changing
// thread priorities.
return true;
+#elif defined(WEBRTC_MOZILLA_BUILD) && defined(WEBRTC_LINUX)
+ // Only realtime audio uses realtime scheduling in Firefox.
+ return true;
#else
const int policy = SCHED_FIFO;
const int min_prio = sched_get_priority_min(policy);
diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
index fff976468c..15a447d1b0 100644
--- a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
@@ -13,6 +13,7 @@
#include <asm/ioctl.h>
#include <dlfcn.h>
#include <fcntl.h>
+#include <gdk/gdk.h>
#include <libdrm/drm_fourcc.h>
#include <linux/types.h>
#include <spa/param/video/format-utils.h>
@@ -218,6 +219,26 @@ static void CloseLibrary(void* library) {
}
}
+static bool IsWaylandDisplay() {
+ static auto sGdkWaylandDisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type");
+ if (!sGdkWaylandDisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkWaylandDisplayGetType()));
+}
+
+static bool IsX11Display() {
+ static auto sGdkX11DisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type");
+ if (!sGdkX11DisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkX11DisplayGetType()));
+}
+
static void* g_lib_egl = nullptr;
RTC_NO_SANITIZE("cfi-icall")
@@ -363,8 +384,13 @@ EglDmaBuf::EglDmaBuf() {
return;
}
- egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
- (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ if (IsWaylandDisplay()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ } else if (IsX11Display()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ }
if (egl_.display == EGL_NO_DISPLAY) {
RTC_LOG(LS_ERROR) << "Failed to obtain default EGL display: "

View File

@ -1,74 +1,31 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Fri, 10 Mar 2023 09:21:00 +0000
Subject: Bug 1819035 - get EGL display based on the used platform in the
browser r=webrtc-reviewers,ng
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 27 Feb 2023 16:22:00 +0000
Subject: Bug 1817024 - (fix-fdcfefa708) In PhysicalSocket avoid a non-trivial
designated initializer. r=mjf,webrtc-reviewers
Because of a possible misconfiguration or a possible driver issue it
might happen that the browser will use a different driver on X11 and
end up using yet another one for wayland/gbm, which might lead to not
working screen sharing in the better case, but also to a crash in the
other driver (Nvidia). This adds a check for platform the browser runs
on, if it's XWayland or Wayland and based on that query EGL display for
that specific platform, rather than going for the Wayland one only.
This fixes a build failure in the base-toolchain job with GCC 7.5.0:
In file included from Unified_cpp_threading_gn0.cpp:38:0:
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc: In member function 'int rtc::PhysicalSocket::DoReadFromSocket(void*, size_t, rtc::SocketAddress*, int64_t*)':
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc:463:51: sorry, unimplemented: non-trivial designated initializers not supported
msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
^
Differential Revision: https://phabricator.services.mozilla.com/D171858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c8606497de1f461a6352456e0e511c2ae498d526
Differential Revision: https://phabricator.services.mozilla.com/D171057
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a3447f709befd84a282ca40f29b7a5ea76d5b68d
---
.../linux/wayland/egl_dmabuf.cc | 30 +++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
index fff976468c..15a447d1b0 100644
--- a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
@@ -13,6 +13,7 @@
#include <asm/ioctl.h>
#include <dlfcn.h>
#include <fcntl.h>
+#include <gdk/gdk.h>
#include <libdrm/drm_fourcc.h>
#include <linux/types.h>
#include <spa/param/video/format-utils.h>
@@ -218,6 +219,26 @@ static void CloseLibrary(void* library) {
}
}
+static bool IsWaylandDisplay() {
+ static auto sGdkWaylandDisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_wayland_display_get_type");
+ if (!sGdkWaylandDisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkWaylandDisplayGetType()));
+}
+
+static bool IsX11Display() {
+ static auto sGdkX11DisplayGetType =
+ (GType (*)(void))dlsym(RTLD_DEFAULT, "gdk_x11_display_get_type");
+ if (!sGdkX11DisplayGetType) {
+ return false;
+ }
+ return (G_TYPE_CHECK_INSTANCE_TYPE ((gdk_display_get_default()),
+ sGdkX11DisplayGetType()));
+}
+
static void* g_lib_egl = nullptr;
RTC_NO_SANITIZE("cfi-icall")
@@ -363,8 +384,13 @@ EglDmaBuf::EglDmaBuf() {
return;
}
- egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
- (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ if (IsWaylandDisplay()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ } else if (IsX11Display()) {
+ egl_.display = EglGetPlatformDisplay(EGL_PLATFORM_X11_KHR,
+ (void*)EGL_DEFAULT_DISPLAY, nullptr);
+ }
if (egl_.display == EGL_NO_DISPLAY) {
RTC_LOG(LS_ERROR) << "Failed to obtain default EGL display: "
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 5a75fbb707..809efb8814 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -520,7 +520,7 @@ int PhysicalSocket::DoReadFromSocket(void* buffer,
#if defined(WEBRTC_POSIX)
int received = 0;
iovec iov = {.iov_base = buffer, .iov_len = length};
- msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
+ msghdr msg = {.msg_name = nullptr, .msg_namelen = 0, .msg_iov = &iov, .msg_iovlen = 1};
if (out_addr) {
out_addr->Clear();
msg.msg_name = addr;

View File

@ -1,31 +1,24 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 27 Feb 2023 16:22:00 +0000
Subject: Bug 1817024 - (fix-fdcfefa708) In PhysicalSocket avoid a non-trivial
designated initializer. r=mjf,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Fri, 7 Apr 2023 20:28:00 +0000
Subject: Bug 1819048: Remove this bad assertion. r=webrtc-reviewers,jib
This fixes a build failure in the base-toolchain job with GCC 7.5.0:
In file included from Unified_cpp_threading_gn0.cpp:38:0:
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc: In member function 'int rtc::PhysicalSocket::DoReadFromSocket(void*, size_t, rtc::SocketAddress*, int64_t*)':
.../third_party/libwebrtc/rtc_base/physical_socket_server.cc:463:51: sorry, unimplemented: non-trivial designated initializers not supported
msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
^
Differential Revision: https://phabricator.services.mozilla.com/D171057
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a3447f709befd84a282ca40f29b7a5ea76d5b68d
Differential Revision: https://phabricator.services.mozilla.com/D174978
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5a52e1b0c808edfda82f0abea668699eb68098dc
---
rtc_base/physical_socket_server.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
video/task_queue_frame_decode_scheduler.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index 5a75fbb707..809efb8814 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -520,7 +520,7 @@ int PhysicalSocket::DoReadFromSocket(void* buffer,
#if defined(WEBRTC_POSIX)
int received = 0;
iovec iov = {.iov_base = buffer, .iov_len = length};
- msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
+ msghdr msg = {.msg_name = nullptr, .msg_namelen = 0, .msg_iov = &iov, .msg_iovlen = 1};
if (out_addr) {
out_addr->Clear();
msg.msg_name = addr;
diff --git a/video/task_queue_frame_decode_scheduler.cc b/video/task_queue_frame_decode_scheduler.cc
index 624f8abf4a..dcc83d4a8b 100644
--- a/video/task_queue_frame_decode_scheduler.cc
+++ b/video/task_queue_frame_decode_scheduler.cc
@@ -37,7 +37,8 @@ void TaskQueueFrameDecodeScheduler::ScheduleFrame(
uint32_t rtp,
FrameDecodeTiming::FrameSchedule schedule,
FrameReleaseCallback cb) {
- RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
+ // Mozilla modification, until https://bugs.webrtc.org/14944 is fixed
+ //RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
RTC_DCHECK(!scheduled_rtp_.has_value())
<< "Can not schedule two frames for release at the same time.";
RTC_DCHECK(cb);

View File

@ -1,24 +1,57 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Fri, 7 Apr 2023 20:28:00 +0000
Subject: Bug 1819048: Remove this bad assertion. r=webrtc-reviewers,jib
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 6 Jun 2023 16:37:00 -0700
Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to
portal:pipewire_base;r?pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D174978
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/5a52e1b0c808edfda82f0abea668699eb68098dc
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c
---
video/task_queue_frame_decode_scheduler.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
modules/video_capture/BUILD.gn | 4 ++++
modules/video_capture/linux/device_info_pipewire.cc | 4 ++--
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/video/task_queue_frame_decode_scheduler.cc b/video/task_queue_frame_decode_scheduler.cc
index 624f8abf4a..dcc83d4a8b 100644
--- a/video/task_queue_frame_decode_scheduler.cc
+++ b/video/task_queue_frame_decode_scheduler.cc
@@ -37,7 +37,8 @@ void TaskQueueFrameDecodeScheduler::ScheduleFrame(
uint32_t rtp,
FrameDecodeTiming::FrameSchedule schedule,
FrameReleaseCallback cb) {
- RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
+ // Mozilla modification, until https://bugs.webrtc.org/14944 is fixed
+ //RTC_DCHECK(!stopped_) << "Can not schedule frames after stopped.";
RTC_DCHECK(!scheduled_rtp_.has_value())
<< "Can not schedule two frames for release at the same time.";
RTC_DCHECK(cb);
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a2bf27f645..d9b3471572 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -108,6 +108,10 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"../../media:rtc_media_base",
"../portal",
]
+ if (build_with_mozilla) {
+ configs -= [ "../portal:pipewire_base" ]
+ public_deps = [ "//third_party/pipewire" ]
+ }
}
}
if (is_win) {
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index 0ec0da3933..b802fe580c 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -49,9 +49,9 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
RTC_CHECK(pipewire_session_);
-
if (deviceNumber >= NumberOfDevices())
return -1;
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 4da0c7a90b..8a33d75892 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
- uint32_t productUniqueIdUTF8Length = 0) override;
+ uint32_t productUniqueIdUTF8Length = 0,
+ pid_t* pid = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.

View File

@ -1,57 +1,29 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Tue, 6 Jun 2023 16:37:00 -0700
Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to
portal:pipewire_base;r?pehrsons
From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Wed, 28 Jun 2023 20:45:00 -0400
Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's
RTCPReceiver::RemoteRTCPSenderInfo function working.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602
---
modules/video_capture/BUILD.gn | 4 ++++
modules/video_capture/linux/device_info_pipewire.cc | 4 ++--
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
3 files changed, 8 insertions(+), 3 deletions(-)
modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index a2bf27f645..d9b3471572 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -108,6 +108,10 @@ if (!build_with_chromium || is_linux || is_chromeos) {
"../../media:rtc_media_base",
"../portal",
]
+ if (build_with_mozilla) {
+ configs -= [ "../portal:pipewire_base" ]
+ public_deps = [ "//third_party/pipewire" ]
+ }
}
}
if (is_win) {
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index 0ec0da3933..b802fe580c 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -49,9 +49,9 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+ uint32_t productUniqueIdUTF8Length,
+ pid_t* pid) {
RTC_CHECK(pipewire_session_);
-
if (deviceNumber >= NumberOfDevices())
return -1;
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 3298961fd3..44215c7473 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -394,10 +394,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
int64_t* ntp_timestamp_ms,
int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
- *packet_count = remote_sender_packet_count_;
- *octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *packet_count = remote_sender_.packets_sent;
+ *octet_count = remote_sender_.bytes_sent;
+ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs();
}
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 4da0c7a90b..8a33d75892 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
- uint32_t productUniqueIdUTF8Length = 0) override;
+ uint32_t productUniqueIdUTF8Length = 0,
+ pid_t* pid = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {

View File

@ -1,29 +1,33 @@
From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Wed, 28 Jun 2023 20:45:00 -0400
Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's
RTCPReceiver::RemoteRTCPSenderInfo function working.
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 22 Jun 2023 16:23:00 +0000
Subject: Bug 1837918 - libwebrtc update broke the build on
OpenBSD;r=mjf,webrtc-reviewers
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602
Differential Revision: https://phabricator.services.mozilla.com/D181791
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f
---
modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
modules/video_capture/video_capture_options.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 3298961fd3..44215c7473 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -394,10 +394,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count,
int64_t* ntp_timestamp_ms,
int64_t* remote_ntp_timestamp_ms) const {
MutexLock lock(&rtcp_receiver_lock_);
- *packet_count = remote_sender_packet_count_;
- *octet_count = remote_sender_octet_count_;
- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs();
- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs();
+ *packet_count = remote_sender_.packets_sent;
+ *octet_count = remote_sender_.bytes_sent;
+ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs();
+ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs();
}
diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h
index 6f72f7927e..37965305d9 100644
--- a/modules/video_capture/video_capture_options.h
+++ b/modules/video_capture/video_capture_options.h
@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions {
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
void Init(Callback* callback);
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2() const { return allow_v4l2_; }
void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; }
#endif
@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions {
#endif
private:
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2_ = false;
#endif
#if defined(WEBRTC_USE_PIPEWIRE)

View File

@ -1,33 +1,24 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 22 Jun 2023 16:23:00 +0000
Subject: Bug 1837918 - libwebrtc update broke the build on
OpenBSD;r=mjf,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 5 Jul 2023 19:15:00 +0000
Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size
of encoder_config_.simulcast_layers. r=jib
Differential Revision: https://phabricator.services.mozilla.com/D181791
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f
Differential Revision: https://phabricator.services.mozilla.com/D182813
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f
---
modules/video_capture/video_capture_options.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
video/video_stream_encoder.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h
index 6f72f7927e..37965305d9 100644
--- a/modules/video_capture/video_capture_options.h
+++ b/modules/video_capture/video_capture_options.h
@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions {
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index da42b2a137..a8dd782a74 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -1371,7 +1371,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
void Init(Callback* callback);
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2() const { return allow_v4l2_; }
void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; }
#endif
@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions {
#endif
private:
-#if defined(WEBRTC_LINUX)
+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
bool allow_v4l2_ = false;
#endif
#if defined(WEBRTC_USE_PIPEWIRE)
bool is_svc = false;
bool single_stream_or_non_first_inactive = true;
- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) {
+ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) {
if (encoder_config_.simulcast_layers[i].active) {
single_stream_or_non_first_inactive = false;
break;

View File

@ -1,24 +1,24 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 5 Jul 2023 19:15:00 +0000
Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size
of encoder_config_.simulcast_layers. r=jib
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Fri, 7 Jul 2023 00:58:00 +0000
Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't
have AVX2. r=mjf,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D182813
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f
Differential Revision: https://phabricator.services.mozilla.com/D182695
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024
---
video/video_stream_encoder.cc | 2 +-
webrtc.gni | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index da42b2a137..a8dd782a74 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -1371,7 +1371,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
diff --git a/webrtc.gni b/webrtc.gni
index f55b88a061..167b4d7de0 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -317,7 +317,7 @@ declare_args() {
bool is_svc = false;
bool single_stream_or_non_first_inactive = true;
- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) {
+ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) {
if (encoder_config_.simulcast_layers[i].active) {
single_stream_or_non_first_inactive = false;
break;
# Set this to true to enable the avx2 support in webrtc.
# TODO: Make sure that AVX2 works also for non-clang compilers.
- if (is_clang == true) {
+ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
rtc_enable_avx2 = true
} else {
rtc_enable_avx2 = false

View File

@ -1,24 +1,26 @@
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Fri, 7 Jul 2023 00:58:00 +0000
Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't
have AVX2. r=mjf,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong
thread). r=pehrsons,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D182695
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024
This was causing assertions.
Differential Revision: https://phabricator.services.mozilla.com/D179731
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b
---
webrtc.gni | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
audio/channel_send.cc | 2 --
1 file changed, 2 deletions(-)
diff --git a/webrtc.gni b/webrtc.gni
index f55b88a061..167b4d7de0 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -317,7 +317,7 @@ declare_args() {
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index 70d3eaabbd..c3a3262a6b 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -543,8 +543,6 @@ ChannelSend::ChannelSend(
# Set this to true to enable the avx2 support in webrtc.
# TODO: Make sure that AVX2 works also for non-clang compilers.
- if (is_clang == true) {
+ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) {
rtc_enable_avx2 = true
} else {
rtc_enable_avx2 = false
int error = audio_coding_->RegisterTransportCallback(this);
RTC_DCHECK_EQ(0, error);
- if (frame_transformer)
- InitFrameTransformerDelegate(std::move(frame_transformer));
}
ChannelSend::~ChannelSend() {

View File

@ -1,26 +1,66 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong
thread). r=pehrsons,webrtc-reviewers
Subject: Bug 1838080: Use the current TaskQueue, instead of the current
thread, to init this. r=pehrsons,webrtc-reviewers
This was causing assertions.
There are situations where the current thread is not set, but the current
TaskQueue is (but not vice versa).
Differential Revision: https://phabricator.services.mozilla.com/D179731
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b
Differential Revision: https://phabricator.services.mozilla.com/D180736
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b
---
audio/channel_send.cc | 2 --
1 file changed, 2 deletions(-)
.../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +--
.../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++---
video/rtp_video_stream_receiver2.cc | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/audio/channel_send.cc b/audio/channel_send.cc
index 70d3eaabbd..c3a3262a6b 100644
--- a/audio/channel_send.cc
+++ b/audio/channel_send.cc
@@ -543,8 +543,6 @@ ChannelSend::ChannelSend(
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index 5ef0a80492..de74684a1f 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -96,8 +96,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate::
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc)
+ TaskQueueBase* network_thread, uint32_t ssrc)
: receiver_(receiver),
frame_transformer_(std::move(frame_transformer)),
network_thread_(network_thread),
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
index f08fc692dd..02f2e53923 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc);
+ TaskQueueBase* network_thread, uint32_t ssrc);
int error = audio_coding_->RegisterTransportCallback(this);
RTC_DCHECK_EQ(0, error);
- if (frame_transformer)
- InitFrameTransformerDelegate(std::move(frame_transformer));
void Init();
void Reset();
@@ -71,7 +70,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_
RTC_GUARDED_BY(network_sequence_checker_);
- rtc::Thread* const network_thread_;
+ TaskQueueBase* const network_thread_;
const uint32_t ssrc_;
Clock* const clock_;
bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 7df19cf29b..dcb192cdde 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -336,7 +336,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
frame_transformer_delegate_ =
rtc::make_ref_counted<RtpVideoStreamReceiverFrameTransformerDelegate>(
this, &env_.clock(), std::move(frame_transformer),
- rtc::Thread::Current(), config_.rtp.remote_ssrc);
+ TaskQueueBase::Current(), config_.rtp.remote_ssrc);
frame_transformer_delegate_->Init();
}
}
ChannelSend::~ChannelSend() {

View File

@ -1,66 +1,165 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Use the current TaskQueue, instead of the current
thread, to init this. r=pehrsons,webrtc-reviewers
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 27 Jul 2023 12:42:44 -0500
Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame.
r=ng,webrtc-reviewers
There are situations where the current thread is not set, but the current
TaskQueue is (but not vice versa).
This is necessary to reliably detect what rid a given keyframe is for, for the
purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame.
Differential Revision: https://phabricator.services.mozilla.com/D180736
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b
Differential Revision: https://phabricator.services.mozilla.com/D180737
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36
---
.../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +--
.../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++---
video/rtp_video_stream_receiver2.cc | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
api/frame_transformer_interface.h | 1 +
modules/rtp_rtcp/source/rtp_sender.h | 4 ++++
modules/rtp_rtcp/source/rtp_sender_video.cc | 1 +
...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++----
.../rtp_sender_video_frame_transformer_delegate.h | 2 ++
..._stream_receiver_frame_transformer_delegate.cc | 5 +++++
6 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index 5ef0a80492..de74684a1f 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -96,8 +96,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate::
RtpVideoFrameReceiver* receiver,
Clock* clock,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc)
+ TaskQueueBase* network_thread, uint32_t ssrc)
: receiver_(receiver),
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index 6959445285..47e2fddd3b 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -77,6 +77,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableVideoFrameInterface(Passkey passkey);
virtual ~TransformableVideoFrameInterface() = default;
virtual bool IsKeyFrame() const = 0;
+ virtual const std::string& GetRid() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index d97e4ae036..8336e85e2b 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -145,6 +145,10 @@ class RTPSender {
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) {
+ return rid_;
+ }
+
std::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index e505e282c6..248a85e91d 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -156,6 +156,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
this,
config.frame_transformer,
rtp_sender_->SSRC(),
+ rtp_sender_->Rid(),
config.task_queue_factory)
: nullptr),
enable_av1_even_split_(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index b49468b8f9..04d34eda14 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -55,7 +55,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
- std::vector<uint32_t> csrcs)
+ std::vector<uint32_t> csrcs,
+ const std::string& rid)
: TransformableVideoFrameInterface(Passkey()),
encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
@@ -68,7 +69,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
- csrcs_(csrcs) {
+ csrcs_(csrcs),
+ rid_(rid) {
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
}
@@ -131,6 +133,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}
+ const std::string& GetRid() const override { return rid_; }
+
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -145,16 +149,19 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* task_queue_factory)
: sender_(sender),
frame_transformer_(std::move(frame_transformer)),
network_thread_(network_thread),
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
index f08fc692dd..02f2e53923 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h
@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver,
Clock* clock,
ssrc_(ssrc),
+ rid_(rid),
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -185,7 +192,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
expected_retransmission_time, ssrc_,
- /*csrcs=*/std::vector<uint32_t>()));
+ /*csrcs=*/std::vector<uint32_t>(), rid_));
return true;
}
@@ -287,7 +294,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
index 3580d84402..e4a75a9734 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
@@ -60,6 +60,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
- rtc::Thread* network_thread,
- uint32_t ssrc);
+ TaskQueueBase* network_thread, uint32_t ssrc);
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* send_transport_queue);
void Init();
void Reset();
@@ -71,7 +70,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate
RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_
RTC_GUARDED_BY(network_sequence_checker_);
- rtc::Thread* const network_thread_;
+ TaskQueueBase* const network_thread_;
@@ -108,6 +109,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;
Clock* const clock_;
bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false;
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index 7df19cf29b..dcb192cdde 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -336,7 +336,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2(
frame_transformer_delegate_ =
rtc::make_ref_counted<RtpVideoStreamReceiverFrameTransformerDelegate>(
this, &env_.clock(), std::move(frame_transformer),
- rtc::Thread::Current(), config_.rtp.remote_ssrc);
+ TaskQueueBase::Current(), config_.rtp.remote_ssrc);
frame_transformer_delegate_->Init();
+ const std::string rid_;
// Used when the encoded frames arrives without a current task queue. This can
// happen if a hardware encoder was used.
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> transformation_queue_;
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index de74684a1f..7e0754284a 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -59,6 +59,11 @@ class TransformableVideoReceiverFrame
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
}
}
+ const std::string& GetRid() const override {
+ static const std::string empty;
+ return empty;
+ }
+
VideoFrameMetadata Metadata() const override { return metadata_; }
void SetMetadata(const VideoFrameMetadata& metadata) override {

View File

@ -1,165 +1,38 @@
From: Michael Froman <mjfroman@mac.com>
Date: Thu, 27 Jul 2023 12:42:44 -0500
Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame.
r=ng,webrtc-reviewers
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not
released on itself. r=pehrsons,webrtc-reviewers
This is necessary to reliably detect what rid a given keyframe is for, for the
purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame.
Differential Revision: https://phabricator.services.mozilla.com/D180737
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36
Differential Revision: https://phabricator.services.mozilla.com/D181699
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d
---
api/frame_transformer_interface.h | 1 +
modules/rtp_rtcp/source/rtp_sender.h | 4 ++++
modules/rtp_rtcp/source/rtp_sender_video.cc | 1 +
...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++----
.../rtp_sender_video_frame_transformer_delegate.h | 2 ++
..._stream_receiver_frame_transformer_delegate.cc | 5 +++++
6 files changed, 24 insertions(+), 4 deletions(-)
.../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h
index 6959445285..47e2fddd3b 100644
--- a/api/frame_transformer_interface.h
+++ b/api/frame_transformer_interface.h
@@ -77,6 +77,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface {
RTC_EXPORT explicit TransformableVideoFrameInterface(Passkey passkey);
virtual ~TransformableVideoFrameInterface() = default;
virtual bool IsKeyFrame() const = 0;
+ virtual const std::string& GetRid() const = 0;
virtual VideoFrameMetadata Metadata() const = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index d97e4ae036..8336e85e2b 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -145,6 +145,10 @@ class RTPSender {
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) {
+ return rid_;
+ }
+
std::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index e505e282c6..248a85e91d 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -156,6 +156,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
this,
config.frame_transformer,
rtp_sender_->SSRC(),
+ rtp_sender_->Rid(),
config.task_queue_factory)
: nullptr),
enable_av1_even_split_(
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index b49468b8f9..04d34eda14 100644
index 04d34eda14..9d18d561d2 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -55,7 +55,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t rtp_timestamp,
TimeDelta expected_retransmission_time,
uint32_t ssrc,
- std::vector<uint32_t> csrcs)
+ std::vector<uint32_t> csrcs,
+ const std::string& rid)
: TransformableVideoFrameInterface(Passkey()),
encoded_data_(encoded_image.GetEncodedData()),
pre_transform_payload_size_(encoded_image.size()),
@@ -68,7 +69,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
capture_time_identifier_(encoded_image.CaptureTimeIdentifier()),
expected_retransmission_time_(expected_retransmission_time),
ssrc_(ssrc),
- csrcs_(csrcs) {
+ csrcs_(csrcs),
+ rid_(rid) {
RTC_DCHECK_GE(payload_type_, 0);
RTC_DCHECK_LE(payload_type_, 127);
@@ -34,6 +34,7 @@
#include "api/video_codecs/video_codec.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "rtc_base/checks.h"
+#include "rtc_base/event.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -274,6 +275,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
@@ -131,6 +133,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
return mime_type + CodecTypeToPayloadString(*codec_type_);
}
+ const std::string& GetRid() const override { return rid_; }
+
private:
rtc::scoped_refptr<EncodedImageBufferInterface> encoded_data_;
const size_t pre_transform_payload_size_;
@@ -145,16 +149,19 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface {
uint32_t ssrc_;
std::vector<uint32_t> csrcs_;
+ const std::string rid_;
};
RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate(
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* task_queue_factory)
: sender_(sender),
frame_transformer_(std::move(frame_transformer)),
ssrc_(ssrc),
+ rid_(rid),
transformation_queue_(task_queue_factory->CreateTaskQueue(
"video_frame_transformer",
TaskQueueFactory::Priority::NORMAL)) {}
@@ -185,7 +192,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
frame_transformer_->Transform(std::make_unique<TransformableVideoSenderFrame>(
encoded_image, video_header, payload_type, codec_type, rtp_timestamp,
expected_retransmission_time, ssrc_,
- /*csrcs=*/std::vector<uint32_t>()));
+ /*csrcs=*/std::vector<uint32_t>(), rid_));
return true;
+ // Wait until all pending tasks are executed, to ensure that the last ref
+ // standing is not on the transformation queue.
+ rtc::Event flush;
+ transformation_queue_->PostTask([this, &flush]() {
+ RTC_DCHECK_RUN_ON(transformation_queue_.get());
+ flush.Set();
+ });
+ flush.Wait(rtc::Event::kForever);
}
@@ -287,7 +294,7 @@ std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
return std::make_unique<TransformableVideoSenderFrame>(
encoded_image, new_header, original->GetPayloadType(), new_header.codec,
original->GetTimestamp(), kDefaultRetransmissionsTime,
- original->GetSsrc(), metadata.GetCsrcs());
+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid());
}
} // namespace webrtc
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
index 3580d84402..e4a75a9734 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h
@@ -60,6 +60,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender,
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer,
uint32_t ssrc,
+ const std::string& rid,
TaskQueueFactory* send_transport_queue);
void Init();
@@ -108,6 +109,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;
+ const std::string rid_;
// Used when the encoded frames arrives without a current task queue. This can
// happen if a hardware encoder was used.
std::unique_ptr<TaskQueueBase, TaskQueueDeleter> transformation_queue_;
diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
index de74684a1f..7e0754284a 100644
--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc
@@ -59,6 +59,11 @@ class TransformableVideoReceiverFrame
return frame_->FrameType() == VideoFrameType::kVideoFrameKey;
}
+ const std::string& GetRid() const override {
+ static const std::string empty;
+ return empty;
+ }
+
VideoFrameMetadata Metadata() const override { return metadata_; }
void SetMetadata(const VideoFrameMetadata& metadata) override {
std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(

View File

@ -1,38 +1,38 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 20 Jul 2023 14:24:00 +0000
Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not
released on itself. r=pehrsons,webrtc-reviewers
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx
config r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D181699
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d
Differential Revision: https://phabricator.services.mozilla.com/D172224
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed
---
.../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++
1 file changed, 9 insertions(+)
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
index 04d34eda14..9d18d561d2 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc
@@ -34,6 +34,7 @@
#include "api/video_codecs/video_codec.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "rtc_base/checks.h"
+#include "rtc_base/event.h"
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 9aa50e19ee..09da88cad3 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -27,6 +27,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
+// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here.
+// We don't want to use dmabuf of known broken systems.
+// See FEATURE_DMABUF for details.
+namespace mozilla::gfx {
+bool IsDMABufEnabled();
+}
+
namespace webrtc {
@@ -274,6 +275,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
+ // Wait until all pending tasks are executed, to ensure that the last ref
+ // standing is not on the transformation queue.
+ rtc::Event flush;
+ transformation_queue_->PostTask([this, &flush]() {
+ RTC_DCHECK_RUN_ON(transformation_queue_.get());
+ flush.Set();
+ });
+ flush.Wait(rtc::Event::kForever);
}
std::unique_ptr<TransformableVideoFrameInterface> CloneSenderVideoFrame(
const int kBytesPerPixel = 4;
@@ -268,7 +275,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged(
that->modifier_ =
has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID;
std::vector<const spa_pod*> params;
- const int buffer_types = has_modifier
+ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled()
? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd)
: (1 << SPA_DATA_MemFd);

View File

@ -1,38 +1,47 @@
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx
config r=ng,webrtc-reviewers
Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's
disabled r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D172224
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed
Depends on D172224
Differential Revision: https://phabricator.services.mozilla.com/D172229
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648
---
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 9aa50e19ee..09da88cad3 100644
index 09da88cad3..f98253de2d 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -27,6 +27,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
@@ -406,7 +406,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
RTC_LOG(LS_ERROR) << "Unable to open PipeWire library";
return false;
}
- egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ if (mozilla::gfx::IsDMABufEnabled()) {
+ egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ }
+// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here.
+// We don't want to use dmabuf of known broken systems.
+// See FEATURE_DMABUF for details.
+namespace mozilla::gfx {
+bool IsDMABufEnabled();
+}
+
namespace webrtc {
pw_stream_node_id_ = stream_node_id;
const int kBytesPerPixel = 4;
@@ -268,7 +275,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged(
that->modifier_ =
has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID;
std::vector<const spa_pod*> params;
- const int buffer_types = has_modifier
+ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled()
? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd)
: (1 << SPA_DATA_MemFd);
@@ -495,7 +497,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA,
SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) {
// Modifiers can be used with PipeWire >= 0.3.33
- if (has_required_pw_client_version && has_required_pw_server_version) {
+ if (egl_dmabuf_ &&
+ has_required_pw_client_version && has_required_pw_server_version) {
modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format);
if (!modifiers_.empty()) {
@@ -938,7 +941,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer(
const uint n_planes = spa_buffer->n_datas;
- if (!n_planes) {
+ if (!n_planes || !egl_dmabuf_) {
return false;
}

View File

@ -1,47 +1,56 @@
From: stransky <stransky@redhat.com>
Date: Tue, 29 Aug 2023 12:43:00 +0000
Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's
disabled r=ng,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 28 Sep 2023 14:12:00 +0000
Subject: Bug 1832465 - remove libXtst usage from libwebrtc.
r=ng,webrtc-reviewers
Depends on D172224
Differential Revision: https://phabricator.services.mozilla.com/D172229
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648
Differential Revision: https://phabricator.services.mozilla.com/D189386
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20
---
.../linux/wayland/shared_screencast_stream.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
modules/desktop_capture/BUILD.gn | 3 +++
modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 09da88cad3..f98253de2d 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -406,7 +406,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
RTC_LOG(LS_ERROR) << "Unable to open PipeWire library";
return false;
}
- egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ if (mozilla::gfx::IsDMABufEnabled()) {
+ egl_dmabuf_ = std::make_unique<EglDmaBuf>();
+ }
pw_stream_node_id_ = stream_node_id;
@@ -495,7 +497,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream(
for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA,
SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) {
// Modifiers can be used with PipeWire >= 0.3.33
- if (has_required_pw_client_version && has_required_pw_server_version) {
+ if (egl_dmabuf_ &&
+ has_required_pw_client_version && has_required_pw_server_version) {
modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format);
if (!modifiers_.empty()) {
@@ -938,7 +941,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer(
const uint n_planes = spa_buffer->n_datas;
- if (!n_planes) {
+ if (!n_planes || !egl_dmabuf_) {
return false;
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 1047f30ee4..94741d8fc7 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -387,6 +387,9 @@ rtc_library("desktop_capture") {
"Xrandr",
"Xtst",
]
+ if (build_with_mozilla) {
+ libs -= [ "Xtst" ]
+ }
}
if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire &&
diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc
index d690b0e2ba..3f3617b074 100644
--- a/modules/desktop_capture/linux/x11/shared_x_display.cc
+++ b/modules/desktop_capture/linux/x11/shared_x_display.cc
@@ -11,7 +11,9 @@
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include <X11/Xlib.h>
+#if !defined(WEBRTC_MOZILLA_BUILD)
#include <X11/extensions/XTest.h>
+#endif
#include <algorithm>
@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() {
}
void SharedXDisplay::IgnoreXServerGrabs() {
+#if !defined(WEBRTC_MOZILLA_BUILD)
int test_event_base = 0;
int test_error_base = 0;
int major = 0;
@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() {
&minor)) {
XTestGrabControl(display(), true);
}
+#endif
}
} // namespace webrtc

View File

@ -1,56 +1,30 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 28 Sep 2023 14:12:00 +0000
Subject: Bug 1832465 - remove libXtst usage from libwebrtc.
Date: Thu, 5 Oct 2023 14:21:00 +0000
Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes.
r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189386
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20
Differential Revision: https://phabricator.services.mozilla.com/D190104
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b
---
modules/desktop_capture/BUILD.gn | 3 +++
modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++
2 files changed, 7 insertions(+)
testing/libfuzzer/fuzzer_test.gni | 2 ++
testing/test.gni | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 testing/libfuzzer/fuzzer_test.gni
create mode 100644 testing/test.gni
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 1047f30ee4..94741d8fc7 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -387,6 +387,9 @@ rtc_library("desktop_capture") {
"Xrandr",
"Xtst",
]
+ if (build_with_mozilla) {
+ libs -= [ "Xtst" ]
+ }
}
if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire &&
diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc
index d690b0e2ba..3f3617b074 100644
--- a/modules/desktop_capture/linux/x11/shared_x_display.cc
+++ b/modules/desktop_capture/linux/x11/shared_x_display.cc
@@ -11,7 +11,9 @@
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include <X11/Xlib.h>
+#if !defined(WEBRTC_MOZILLA_BUILD)
#include <X11/extensions/XTest.h>
+#endif
#include <algorithm>
@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() {
}
void SharedXDisplay::IgnoreXServerGrabs() {
+#if !defined(WEBRTC_MOZILLA_BUILD)
int test_event_base = 0;
int test_error_base = 0;
int major = 0;
@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() {
&minor)) {
XTestGrabControl(display(), true);
}
+#endif
}
} // namespace webrtc
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni
new file mode 100644
index 0000000000..8fdf3cdad2
--- /dev/null
+++ b/testing/libfuzzer/fuzzer_test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/libfuzzer
+# to allow BUILD.gn imports to succeed.
diff --git a/testing/test.gni b/testing/test.gni
new file mode 100644
index 0000000000..f46fa82778
--- /dev/null
+++ b/testing/test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/test.gni
+# to allow BUILD.gn imports to succeed.

View File

@ -1,30 +1,40 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 5 Oct 2023 14:21:00 +0000
Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes.
r=ng,webrtc-reviewers
Date: Tue, 14 Feb 2023 03:27:00 +0000
Subject: Bug 1816173 - pt12 - add shim config for
third_party/libwebrtc/testing/{gmock|gtest} r=ng
Differential Revision: https://phabricator.services.mozilla.com/D190104
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b
We don't vendor third_party/libwebrtc/third_party/gmock
third_party/libwebrtc/third_party/gtest, so:
- add BUILD.gn to avoid scattered BUILD.gn changes
Differential Revision: https://phabricator.services.mozilla.com/D169674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc
---
testing/libfuzzer/fuzzer_test.gni | 2 ++
testing/test.gni | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 testing/libfuzzer/fuzzer_test.gni
create mode 100644 testing/test.gni
testing/gmock/BUILD.gn | 5 +++++
testing/gtest/BUILD.gn | 5 +++++
2 files changed, 10 insertions(+)
create mode 100644 testing/gmock/BUILD.gn
create mode 100644 testing/gtest/BUILD.gn
diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni
diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn
new file mode 100644
index 0000000000..8fdf3cdad2
index 0000000000..a2a1efdea9
--- /dev/null
+++ b/testing/libfuzzer/fuzzer_test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/libfuzzer
+# to allow BUILD.gn imports to succeed.
diff --git a/testing/test.gni b/testing/test.gni
+++ b/testing/gmock/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gmock") {
+}
diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn
new file mode 100644
index 0000000000..f46fa82778
index 0000000000..c9c2703c37
--- /dev/null
+++ b/testing/test.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new testing/test.gni
+# to allow BUILD.gn imports to succeed.
+++ b/testing/gtest/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gtest") {
+}

View File

@ -1,40 +1,28 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 14 Feb 2023 03:27:00 +0000
Subject: Bug 1816173 - pt12 - add shim config for
third_party/libwebrtc/testing/{gmock|gtest} r=ng
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:25:00 +0000
Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr
RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8.
r=webrtc-reviewers,mjf
We don't vendor third_party/libwebrtc/third_party/gmock
third_party/libwebrtc/third_party/gtest, so:
- add BUILD.gn to avoid scattered BUILD.gn changes
Differential Revision: https://phabricator.services.mozilla.com/D169674
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc
Differential Revision: https://phabricator.services.mozilla.com/D191308
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d
---
testing/gmock/BUILD.gn | 5 +++++
testing/gtest/BUILD.gn | 5 +++++
2 files changed, 10 insertions(+)
create mode 100644 testing/gmock/BUILD.gn
create mode 100644 testing/gtest/BUILD.gn
api/video/video_frame_type.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn
new file mode 100644
index 0000000000..a2a1efdea9
--- /dev/null
+++ b/testing/gmock/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gmock") {
+}
diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn
new file mode 100644
index 0000000000..c9c2703c37
--- /dev/null
+++ b/testing/gtest/BUILD.gn
@@ -0,0 +1,5 @@
+import("//third_party/libaom/options.gni")
+import("../../webrtc.gni")
+
+rtc_library("gtest") {
+}
diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h
index 9079829ff8..3665a80cd8 100644
--- a/api/video/video_frame_type.h
+++ b/api/video/video_frame_type.h
@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString(
case VideoFrameType::kVideoFrameDelta:
return "delta";
}
+// Mozilla:
+// gcc-8 complains about a constexpr function calling a non-constexpr ditto.
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9)
RTC_CHECK_NOTREACHED();
+#endif
return "";
}

View File

@ -1,28 +1,41 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:25:00 +0000
Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr
RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8.
r=webrtc-reviewers,mjf
Date: Wed, 18 Oct 2023 17:21:00 +0000
Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on
top of video_capture_impl.cc. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D191308
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d
The annotations were added in M116:
https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5
Note that this was never unsafe, since _dataCallbacks is only written on the
same thread that we are patching here. This patch however, adds helpful static
analysis.
Differential Revision: https://phabricator.services.mozilla.com/D191301
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1
---
api/video/video_frame_type.h | 4 ++++
1 file changed, 4 insertions(+)
modules/video_capture/video_capture_impl.cc | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h
index 9079829ff8..3665a80cd8 100644
--- a/api/video/video_frame_type.h
+++ b/api/video/video_frame_type.h
@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString(
case VideoFrameType::kVideoFrameDelta:
return "delta";
}
+// Mozilla:
+// gcc-8 complains about a constexpr function calling a non-constexpr ditto.
+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9)
RTC_CHECK_NOTREACHED();
+#endif
return "";
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 1a12020b64..dad8bee1f8 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback(
}
int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() {
- if (_dataCallBacks.empty()) {
- return StopCapture();
- } else {
- return 0;
+ RTC_DCHECK_RUN_ON(&api_checker_);
+ {
+ MutexLock lock(&api_lock_);
+ if (!_dataCallBacks.empty()) {
+ return 0;
+ }
}
+ return StopCapture();
}
int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {

View File

@ -1,41 +1,27 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 18 Oct 2023 17:21:00 +0000
Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on
top of video_capture_impl.cc. r=webrtc-reviewers,mjf
Subject: Bug 1859786 - Fix clang-tidy warning in video_capture_impl.cc.
r=webrtc-reviewers,mjf
The annotations were added in M116:
https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5
clang-tidy says:
'auto dataCallBack' can be declared as 'auto *dataCallBack'
Note that this was never unsafe, since _dataCallbacks is only written on the
same thread that we are patching here. This patch however, adds helpful static
analysis.
Differential Revision: https://phabricator.services.mozilla.com/D191301
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1
Differential Revision: https://phabricator.services.mozilla.com/D191302
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/26c84d214137a1b0de0902c7038756964e5786f4
---
modules/video_capture/video_capture_impl.cc | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
modules/video_capture/video_capture_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc
index 1a12020b64..dad8bee1f8 100644
index dad8bee1f8..46fff89a52 100644
--- a/modules/video_capture/video_capture_impl.cc
+++ b/modules/video_capture/video_capture_impl.cc
@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback(
}
@@ -134,7 +134,7 @@ int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {
int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() {
- if (_dataCallBacks.empty()) {
- return StopCapture();
- } else {
- return 0;
+ RTC_DCHECK_RUN_ON(&api_checker_);
+ {
+ MutexLock lock(&api_lock_);
+ if (!_dataCallBacks.empty()) {
+ return 0;
+ }
UpdateFrameCount(); // frame count used for local frame rate callback.
- for (auto dataCallBack : _dataCallBacks) {
+ for (auto* dataCallBack : _dataCallBacks) {
dataCallBack->OnFrame(captureFrame);
}
+ return StopCapture();
}
int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,64 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 7 Dec 2022 17:09:00 +0000
Subject: Bug 1744645 - pt1 - add a couple empty gni files to help with
BUILD.gn corrections. r=ng
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 15 Nov 2023 22:33:00 +0000
Subject: Bug 1863041 - P0 - add device filter control to
RTCCameraVideoCapturer;r=pehrsons,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D163991
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/81d86382ee468f3b36deed00d0c9d59eb85524be
I have filed this bug upstream: https://bugs.chromium.org/p/webrtc/issues/detail?id=15639
Differential Revision: https://phabricator.services.mozilla.com/D193172
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91a763d768b74acc9cf4828f91a86df4a7b092ce
---
tools/generate_stubs/rules.gni | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 tools/generate_stubs/rules.gni
.../capturer/RTCCameraVideoCapturer.h | 5 ++++-
.../capturer/RTCCameraVideoCapturer.m | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/tools/generate_stubs/rules.gni b/tools/generate_stubs/rules.gni
new file mode 100644
index 0000000000..1d9f36eb72
--- /dev/null
+++ b/tools/generate_stubs/rules.gni
@@ -0,0 +1,2 @@
+# "empty" file in place of importing new tools/generate_stubs
+# to allow BUILD.gn imports to succeed.
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
index 370bfa70f0..b1f3f64f74 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
@@ -26,7 +26,10 @@ NS_EXTENSION_UNAVAILABLE_IOS("Camera not available in app extensions.")
@property(readonly, nonatomic) AVCaptureSession *captureSession;
// Returns list of available capture devices that support video capture.
-+ (NSArray<AVCaptureDevice *> *)captureDevices;
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes;
+// Returns list of default capture devices types
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes;
// Returns list of formats that are supported by this class for this device.
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
index d25f5e20ae..4f92f56807 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -118,14 +118,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-+ (NSArray<AVCaptureDevice *> *)captureDevices {
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes {
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
- discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ]
+ discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
return session.devices;
}
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes {
+ NSArray *types = @[ AVCaptureDeviceTypeBuiltInWideAngleCamera ];
+#if !defined(WEBRTC_IOS)
+ if (@available(macOS 14.0, *)) {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternal];
+ } else {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternalUnknown];
+ }
+#endif
+ return types;
+}
+
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device {
// Support opening the device in any format. We make sure it's converted to a format we
// can handle, if needed, in the method `-setupVideoDataOutput`.

View File

@ -1,64 +1,36 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Wed, 15 Nov 2023 22:33:00 +0000
Subject: Bug 1863041 - P0 - add device filter control to
RTCCameraVideoCapturer;r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 4 Dec 2023 12:57:00 -0600
Subject: Bug 1867099 - (fix-66b7275561) disable wgc capture yellow-line
removal. r?ng!
I have filed this bug upstream: https://bugs.chromium.org/p/webrtc/issues/detail?id=15639
Differential Revision: https://phabricator.services.mozilla.com/D193172
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91a763d768b74acc9cf4828f91a86df4a7b092ce
This code won't build until we support building with
Win 10 SDK v10.0.20348.0 or newer.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0aac94794aad2ddb637f5076bc08706a11866737
---
.../capturer/RTCCameraVideoCapturer.h | 5 ++++-
.../capturer/RTCCameraVideoCapturer.m | 17 +++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
modules/desktop_capture/win/wgc_capture_session.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
index 370bfa70f0..b1f3f64f74 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.h
@@ -26,7 +26,10 @@ NS_EXTENSION_UNAVAILABLE_IOS("Camera not available in app extensions.")
@property(readonly, nonatomic) AVCaptureSession *captureSession;
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
index 1c86f8ed1b..f9429134dc 100644
--- a/modules/desktop_capture/win/wgc_capture_session.cc
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
@@ -188,6 +188,11 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
}
}
// Returns list of available capture devices that support video capture.
-+ (NSArray<AVCaptureDevice *> *)captureDevices;
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes;
+// Returns list of default capture devices types
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes;
// Returns list of formats that are supported by this class for this device.
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device;
diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
index d25f5e20ae..4f92f56807 100644
--- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
+++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m
@@ -118,14 +118,27 @@ const int64_t kNanosecondsPerSecond = 1000000000;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-+ (NSArray<AVCaptureDevice *> *)captureDevices {
++ (NSArray<AVCaptureDevice *> *)captureDevicesWithDeviceTypes:
+ (NSArray<AVCaptureDeviceType> *)deviceTypes {
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession
- discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInWideAngleCamera ]
+ discoverySessionWithDeviceTypes:deviceTypes
mediaType:AVMediaTypeVideo
position:AVCaptureDevicePositionUnspecified];
return session.devices;
}
++ (NSArray<AVCaptureDeviceType> *)defaultCaptureDeviceTypes {
+ NSArray *types = @[ AVCaptureDeviceTypeBuiltInWideAngleCamera ];
+#if !defined(WEBRTC_IOS)
+ if (@available(macOS 14.0, *)) {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternal];
+ } else {
+ types = [types arrayByAddingObject:AVCaptureDeviceTypeExternalUnknown];
+ }
+// Until Mozilla builds with Win 10 SDK v10.0.20348.0 or newer, this
+// code will not build. Once we support the newer SDK, Bug 1868198
+// exists to decide if we ever want to use this code since it is
+// removing an indicator that capture is happening.
+#if !defined(WEBRTC_MOZILLA_BUILD)
// By default, the WGC capture API adds a yellow border around the captured
// window or display to indicate that a capture is in progress. The section
// below is an attempt to remove this yellow border to make the capture
@@ -199,6 +204,7 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
&session3))) {
session3->put_IsBorderRequired(false);
}
+#endif
+ return types;
+}
+
+ (NSArray<AVCaptureDeviceFormat *> *)supportedFormatsForDevice:(AVCaptureDevice *)device {
// Support opening the device in any format. We make sure it's converted to a format we
// can handle, if needed, in the method `-setupVideoDataOutput`.
allow_zero_hertz_ = options.allow_wgc_zero_hertz();

View File

@ -1,36 +1,121 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 4 Dec 2023 12:57:00 -0600
Subject: Bug 1867099 - (fix-66b7275561) disable wgc capture yellow-line
removal. r?ng!
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 30 Nov 2023 11:49:00 +0000
Subject: Bug 1844020 - Add option to DeviceInfo::GetDeviceName() identifying a
placeholder device r=pehrsons,webrtc-reviewers
This code won't build until we support building with
Win 10 SDK v10.0.20348.0 or newer.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0aac94794aad2ddb637f5076bc08706a11866737
Adds a new parameter "deviceIsPlaceholder" that will be set to true in
case the returned device is not a real device but a placeholder that is
just used to inform about camera device existence.
Differential Revision: https://phabricator.services.mozilla.com/D189929
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ed31b2acb5fbca3e2d0691a64bc52e65952070c0
---
modules/desktop_capture/win/wgc_capture_session.cc | 6 ++++++
1 file changed, 6 insertions(+)
modules/video_capture/linux/device_info_pipewire.cc | 4 +++-
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
modules/video_capture/linux/device_info_v4l2.cc | 3 ++-
modules/video_capture/linux/device_info_v4l2.h | 3 ++-
modules/video_capture/video_capture.h | 3 ++-
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
index 1c86f8ed1b..f9429134dc 100644
--- a/modules/desktop_capture/win/wgc_capture_session.cc
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
@@ -188,6 +188,11 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
}
}
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index b802fe580c..db2a3c7099 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -50,8 +50,10 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
RTC_CHECK(pipewire_session_);
+
if (deviceNumber >= NumberOfDevices())
return -1;
+// Until Mozilla builds with Win 10 SDK v10.0.20348.0 or newer, this
+// code will not build. Once we support the newer SDK, Bug 1868198
+// exists to decide if we ever want to use this code since it is
+// removing an indicator that capture is happening.
+#if !defined(WEBRTC_MOZILLA_BUILD)
// By default, the WGC capture API adds a yellow border around the captured
// window or display to indicate that a capture is in progress. The section
// below is an attempt to remove this yellow border to make the capture
@@ -199,6 +204,7 @@ HRESULT WgcCaptureSession::StartCapture(const DesktopCaptureOptions& options) {
&session3))) {
session3->put_IsBorderRequired(false);
}
+#endif
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 8a33d75892..00715c94bc 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -30,7 +30,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 04caaea592..401c38f9c5 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -232,7 +232,8 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* /*productUniqueIdUTF8*/,
uint32_t /*productUniqueIdUTF8Length*/,
- pid_t* /*pid*/) {
+ pid_t* /*pid*/,
+ bool* /*deviceIsPlaceholder*/) {
// Travel through /dev/video [0-63]
uint32_t count = 0;
char device[20];
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 0bec3eb765..55415845ad 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -36,7 +36,8 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid=0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 43a6a7f832..f59c34f8b2 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -74,7 +74,8 @@ class VideoCaptureModule : public RefCountInterface {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) = 0;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) = 0;
allow_zero_hertz_ = options.allow_wgc_zero_hertz();
// Returns the number of capabilities this device.
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index f6927281f3..8ca741239c 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -173,7 +173,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index e6dfaed366..a9a1449b99 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -51,7 +51,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) override;
+ pid_t* pid,
+ bool* deviceIsPlaceholder) override;
/*
* Display OS /capture device specific settings dialog

View File

@ -1,121 +1,107 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 30 Nov 2023 11:49:00 +0000
Subject: Bug 1844020 - Add option to DeviceInfo::GetDeviceName() identifying a
placeholder device r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 18 Dec 2023 15:00:00 +0000
Subject: Bug 1867099 - revert libwebrtc 8602f604e0. r=bwc
Adds a new parameter "deviceIsPlaceholder" that will be set to true in
case the returned device is not a real device but a placeholder that is
just used to inform about camera device existence.
Upstream 8602f604e0 removed code sending BYEs which breaks some of
our wpt. They've opened a bug for a real fix here:
https://bugs.chromium.org/p/webrtc/issues/detail?id=15664
Differential Revision: https://phabricator.services.mozilla.com/D189929
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ed31b2acb5fbca3e2d0691a64bc52e65952070c0
I've opened Bug 1870643 to track the real fix and upstream bug.
Differential Revision: https://phabricator.services.mozilla.com/D196729
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d92a578327f524ec3e1c144c82492a4c76b8266f
---
modules/video_capture/linux/device_info_pipewire.cc | 4 +++-
modules/video_capture/linux/device_info_pipewire.h | 3 ++-
modules/video_capture/linux/device_info_v4l2.cc | 3 ++-
modules/video_capture/linux/device_info_v4l2.h | 3 ++-
modules/video_capture/video_capture.h | 3 ++-
modules/video_capture/windows/device_info_ds.cc | 3 ++-
modules/video_capture/windows/device_info_ds.h | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
call/rtp_video_sender.cc | 1 +
modules/rtp_rtcp/source/rtcp_sender.cc | 19 +++++++++++++++++--
.../rtp_rtcp/source/rtcp_sender_unittest.cc | 5 +++--
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 2 +-
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index b802fe580c..db2a3c7099 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -50,8 +50,10 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
RTC_CHECK(pipewire_session_);
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index e97112c617..b92d915ad8 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -514,6 +514,7 @@ void RtpVideoSender::SetActiveModulesLocked(bool sending) {
active_ = sending;
for (size_t i = 0; i < rtp_streams_.size(); ++i) {
RtpRtcpInterface& rtp_module = *rtp_streams_[i].rtp_rtcp;
+ // Sends a kRtcpByeCode when going from true to false.
rtp_module.SetSendingStatus(sending);
rtp_module.SetSendingMediaStatus(sending);
if (sending) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc
index 051d77c4f7..b545633f25 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -223,8 +223,23 @@ bool RTCPSender::Sending() const {
void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
bool sending) {
- MutexLock lock(&mutex_rtcp_sender_);
- sending_ = sending;
+ bool sendRTCPBye = false;
+ {
+ MutexLock lock(&mutex_rtcp_sender_);
+
if (deviceNumber >= NumberOfDevices())
return -1;
+ if (method_ != RtcpMode::kOff) {
+ if (sending == false && sending_ == true) {
+ // Trigger RTCP bye
+ sendRTCPBye = true;
+ }
+ }
+ sending_ = sending;
+ }
+ if (sendRTCPBye) {
+ if (SendRTCP(feedback_state, kRtcpBye) != 0) {
+ RTC_LOG(LS_WARNING) << "Failed to send RTCP BYE";
+ }
+ }
}
diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h
index 8a33d75892..00715c94bc 100644
--- a/modules/video_capture/linux/device_info_pipewire.h
+++ b/modules/video_capture/linux/device_info_pipewire.h
@@ -30,7 +30,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = nullptr,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc
index 04caaea592..401c38f9c5 100644
--- a/modules/video_capture/linux/device_info_v4l2.cc
+++ b/modules/video_capture/linux/device_info_v4l2.cc
@@ -232,7 +232,8 @@ int32_t DeviceInfoV4l2::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* /*productUniqueIdUTF8*/,
uint32_t /*productUniqueIdUTF8Length*/,
- pid_t* /*pid*/) {
+ pid_t* /*pid*/,
+ bool* /*deviceIsPlaceholder*/) {
// Travel through /dev/video [0-63]
uint32_t count = 0;
char device[20];
diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h
index 0bec3eb765..55415845ad 100644
--- a/modules/video_capture/linux/device_info_v4l2.h
+++ b/modules/video_capture/linux/device_info_v4l2.h
@@ -36,7 +36,8 @@ class DeviceInfoV4l2 : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid=0) override;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) override;
/*
* Fills the membervariable _captureCapabilities with capabilites for the
* given device name.
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index 43a6a7f832..f59c34f8b2 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -74,7 +74,8 @@ class VideoCaptureModule : public RefCountInterface {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8 = 0,
uint32_t productUniqueIdUTF8Length = 0,
- pid_t* pid = 0) = 0;
+ pid_t* pid = 0,
+ bool* deviceIsPlaceholder = 0) = 0;
void RTCPSender::SetNonSenderRttMeasurement(bool enabled) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index 3a77df5e3e..deda5f71c8 100644
--- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -347,12 +347,13 @@ TEST_F(RtcpSenderTest, SendBye) {
EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
// Returns the number of capabilities this device.
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc
index f6927281f3..8ca741239c 100644
--- a/modules/video_capture/windows/device_info_ds.cc
+++ b/modules/video_capture/windows/device_info_ds.cc
@@ -173,7 +173,8 @@ int32_t DeviceInfoDS::GetDeviceName(uint32_t deviceNumber,
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) {
+ pid_t* pid,
+ bool* deviceIsPlaceholder) {
MutexLock lock(&_apiLock);
const int32_t result = GetDeviceInfo(
deviceNumber, deviceNameUTF8, deviceNameLength, deviceUniqueIdUTF8,
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index e6dfaed366..a9a1449b99 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -51,7 +51,8 @@ class DeviceInfoDS : public DeviceInfoImpl {
uint32_t deviceUniqueIdUTF8Length,
char* productUniqueIdUTF8,
uint32_t productUniqueIdUTF8Length,
- pid_t* pid) override;
+ pid_t* pid,
+ bool* deviceIsPlaceholder) override;
-TEST_F(RtcpSenderTest, StopSendingDoesNotTriggersBye) {
+TEST_F(RtcpSenderTest, StopSendingTriggersBye) {
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
rtcp_sender->SetSendingStatus(feedback_state(), true);
rtcp_sender->SetSendingStatus(feedback_state(), false);
- EXPECT_EQ(0, parser()->bye()->num_packets());
+ EXPECT_EQ(1, parser()->bye()->num_packets());
+ EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
TEST_F(RtcpSenderTest, SendFir) {
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 83d507357d..7286088e2b 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -321,6 +321,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() {
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
if (rtcp_sender_.Sending() != sending) {
+ // Sends RTCP BYE when going from true to false
rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending);
}
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index f14b7ca244..865f523e36 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -283,7 +283,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// Returns the FlexFEC SSRC, if there is one.
virtual std::optional<uint32_t> FlexfecSsrc() const = 0;
- // Sets sending status.
+ // Sets sending status. Sends kRtcpByeCode when going from true to false.
// Returns -1 on failure else 0.
virtual int32_t SetSendingStatus(bool sending) = 0;
/*
* Display OS /capture device specific settings dialog

View File

@ -1,107 +1,33 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 18 Dec 2023 15:00:00 +0000
Subject: Bug 1867099 - revert libwebrtc 8602f604e0. r=bwc
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 2 Feb 2024 18:43:00 +0000
Subject: Bug 1878010 - Fix webrtc::VideoCaptureFactory for BSD.
r=grulja,gaston,webrtc-reviewers,mjf
Upstream 8602f604e0 removed code sending BYEs which breaks some of
our wpt. They've opened a bug for a real fix here:
https://bugs.chromium.org/p/webrtc/issues/detail?id=15664
I've opened Bug 1870643 to track the real fix and upstream bug.
Differential Revision: https://phabricator.services.mozilla.com/D196729
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d92a578327f524ec3e1c144c82492a4c76b8266f
Differential Revision: https://phabricator.services.mozilla.com/D200427
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f890637efe5abc0020fab83ff2224313cd0c8460
---
call/rtp_video_sender.cc | 1 +
modules/rtp_rtcp/source/rtcp_sender.cc | 19 +++++++++++++++++--
.../rtp_rtcp/source/rtcp_sender_unittest.cc | 5 +++--
modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 +
modules/rtp_rtcp/source/rtp_rtcp_interface.h | 2 +-
5 files changed, 23 insertions(+), 5 deletions(-)
modules/video_capture/video_capture_factory.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index e97112c617..b92d915ad8 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -514,6 +514,7 @@ void RtpVideoSender::SetActiveModulesLocked(bool sending) {
active_ = sending;
for (size_t i = 0; i < rtp_streams_.size(); ++i) {
RtpRtcpInterface& rtp_module = *rtp_streams_[i].rtp_rtcp;
+ // Sends a kRtcpByeCode when going from true to false.
rtp_module.SetSendingStatus(sending);
rtp_module.SetSendingMediaStatus(sending);
if (sending) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc
index 051d77c4f7..b545633f25 100644
--- a/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -223,8 +223,23 @@ bool RTCPSender::Sending() const {
void RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
bool sending) {
- MutexLock lock(&mutex_rtcp_sender_);
- sending_ = sending;
+ bool sendRTCPBye = false;
+ {
+ MutexLock lock(&mutex_rtcp_sender_);
+
+ if (method_ != RtcpMode::kOff) {
+ if (sending == false && sending_ == true) {
+ // Trigger RTCP bye
+ sendRTCPBye = true;
+ }
+ }
+ sending_ = sending;
+ }
+ if (sendRTCPBye) {
+ if (SendRTCP(feedback_state, kRtcpBye) != 0) {
+ RTC_LOG(LS_WARNING) << "Failed to send RTCP BYE";
+ }
+ }
}
void RTCPSender::SetNonSenderRttMeasurement(bool enabled) {
diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index 3a77df5e3e..deda5f71c8 100644
--- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -347,12 +347,13 @@ TEST_F(RtcpSenderTest, SendBye) {
EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
-TEST_F(RtcpSenderTest, StopSendingDoesNotTriggersBye) {
+TEST_F(RtcpSenderTest, StopSendingTriggersBye) {
auto rtcp_sender = CreateRtcpSender(GetDefaultConfig());
rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize);
rtcp_sender->SetSendingStatus(feedback_state(), true);
rtcp_sender->SetSendingStatus(feedback_state(), false);
- EXPECT_EQ(0, parser()->bye()->num_packets());
+ EXPECT_EQ(1, parser()->bye()->num_packets());
+ EXPECT_EQ(kSenderSsrc, parser()->bye()->sender_ssrc());
}
TEST_F(RtcpSenderTest, SendFir) {
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 83d507357d..7286088e2b 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -321,6 +321,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() {
int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
if (rtcp_sender_.Sending() != sending) {
+ // Sends RTCP BYE when going from true to false
rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending);
}
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index f14b7ca244..865f523e36 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -283,7 +283,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface {
// Returns the FlexFEC SSRC, if there is one.
virtual std::optional<uint32_t> FlexfecSsrc() const = 0;
- // Sets sending status.
+ // Sets sending status. Sends kRtcpByeCode when going from true to false.
// Returns -1 on failure else 0.
virtual int32_t SetSendingStatus(bool sending) = 0;
diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc
index e085ac2df8..2790fbbe1c 100644
--- a/modules/video_capture/video_capture_factory.cc
+++ b/modules/video_capture/video_capture_factory.cc
@@ -24,7 +24,7 @@ rtc::scoped_refptr<VideoCaptureModule> VideoCaptureFactory::Create(
const char* deviceUniqueIdUTF8) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::Create(options,
@@ -40,7 +40,7 @@ VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
VideoCaptureOptions* options) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(options);

View File

@ -1,33 +1,74 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 2 Feb 2024 18:43:00 +0000
Subject: Bug 1878010 - Fix webrtc::VideoCaptureFactory for BSD.
r=grulja,gaston,webrtc-reviewers,mjf
From: Dan Baker <dbaker@mozilla.com>
Date: Thu, 14 Mar 2024 10:51:00 -0600
Subject: Bug 1883116 - (fix-e79e722834) add enviroment_factory to libwebrtc
build and enforce providing clock and task_queue when creating Environment
Differential Revision: https://phabricator.services.mozilla.com/D200427
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f890637efe5abc0020fab83ff2224313cd0c8460
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4ab03b38dc67f9b06162444da
---
modules/video_capture/video_capture_factory.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
BUILD.gn | 1 +
api/environment/environment_factory.cc | 10 ++++++++++
api/task_queue/BUILD.gn | 5 +++++
3 files changed, 16 insertions(+)
diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc
index e085ac2df8..2790fbbe1c 100644
--- a/modules/video_capture/video_capture_factory.cc
+++ b/modules/video_capture/video_capture_factory.cc
@@ -24,7 +24,7 @@ rtc::scoped_refptr<VideoCaptureModule> VideoCaptureFactory::Create(
const char* deviceUniqueIdUTF8) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::Create(options,
@@ -40,7 +40,7 @@ VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo(
VideoCaptureOptions* options) {
// This is only implemented on pure Linux and WEBRTC_LINUX is defined for
// Android as well
-#if !defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
+#if (!defined(WEBRTC_LINUX) && !defined(WEBRTC_BSD)) || defined(WEBRTC_ANDROID)
return nullptr;
#else
return videocapturemodule::VideoCaptureImpl::CreateDeviceInfo(options);
diff --git a/BUILD.gn b/BUILD.gn
index 592696f317..5f81529ed4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -621,6 +621,7 @@ if (!build_with_chromium) {
if (build_with_mozilla) {
deps += [
+ "api/environment:environment_factory",
"api/video:video_frame",
"api/video:video_rtp_headers",
"test:rtp_test_utils",
diff --git a/api/environment/environment_factory.cc b/api/environment/environment_factory.cc
index 293ef6cf8a..b9cb6b4f53 100644
--- a/api/environment/environment_factory.cc
+++ b/api/environment/environment_factory.cc
@@ -102,12 +102,22 @@ Environment EnvironmentFactory::CreateWithDefaults() && {
if (field_trials_ == nullptr) {
Set(std::make_unique<FieldTrialBasedConfig>());
}
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // We want to use our clock, not GetRealTimeClockRaw, and we avoid
+ // building the code under third_party/libwebrtc/task_queue. To
+ // ensure we're setting up things correctly, namely providing an
+ // Environment object with a preset task_queue_factory and clock,
+ // we'll do a release assert here.
+ RTC_CHECK(clock_);
+ RTC_CHECK(task_queue_factory_);
+#else
if (clock_ == nullptr) {
Set(Clock::GetRealTimeClock());
}
if (task_queue_factory_ == nullptr) {
Set(CreateDefaultTaskQueueFactory(field_trials_));
}
+#endif
if (event_log_ == nullptr) {
Set(std::make_unique<RtcEventLogNull>());
}
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index bacc3ca87a..5c3dd242b6 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -83,6 +83,10 @@ rtc_library("task_queue_test") {
}
rtc_library("default_task_queue_factory") {
+# Mozilla - disable this entire target to avoid inclusion of code we want
+# to avoid. Better here than trying to wack-a-mole for places that list
+# it as a dependency.
+if (!build_with_mozilla) {
visibility = [ "*" ]
if (!is_ios && !is_android) {
# Internally webrtc shouldn't rely on any specific TaskQueue implementation
@@ -121,6 +125,7 @@ rtc_library("default_task_queue_factory") {
sources += [ "default_task_queue_factory_stdlib.cc" ]
deps += [ "../../rtc_base:rtc_task_queue_stdlib" ]
}
+} # of if (!build_with_mozilla) {
}
rtc_library("pending_task_safety_flag") {

View File

@ -1,74 +1,39 @@
From: Dan Baker <dbaker@mozilla.com>
Date: Thu, 14 Mar 2024 10:51:00 -0600
Subject: Bug 1883116 - (fix-e79e722834) add enviroment_factory to libwebrtc
build and enforce providing clock and task_queue when creating Environment
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 10 Apr 2024 21:54:00 +0000
Subject: Bug 1888181 - (fix-52fec7d3) Limit scope of race checker in
VideoCaptureModuleV4L2::StartCapture. r=mjf
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2185cab977988fd4ab03b38dc67f9b06162444da
TSAN detects a race between destroying the scoped race checker in StartCapture
and creating the scoped race checker in CaptureProcess, because once the capture
thread has been created (and given its run function) there is no synchronization
before the run function starts to run.
This patch avoids the race by destroying the StartCapture scoped race checker
before creating the capture thread.
Differential Revision: https://phabricator.services.mozilla.com/D207203
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b046a1446cee5ab485d4868b3ca9784b16b2d02f
---
BUILD.gn | 1 +
api/environment/environment_factory.cc | 10 ++++++++++
api/task_queue/BUILD.gn | 5 +++++
3 files changed, 16 insertions(+)
modules/video_capture/linux/video_capture_v4l2.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/BUILD.gn b/BUILD.gn
index 592696f317..5f81529ed4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -621,6 +621,7 @@ if (!build_with_chromium) {
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 6d8a5e463f..db2450a2c7 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -129,6 +129,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
}
if (build_with_mozilla) {
deps += [
+ "api/environment:environment_factory",
"api/video:video_frame",
"api/video:video_rtp_headers",
"test:rtp_test_utils",
diff --git a/api/environment/environment_factory.cc b/api/environment/environment_factory.cc
index 293ef6cf8a..b9cb6b4f53 100644
--- a/api/environment/environment_factory.cc
+++ b/api/environment/environment_factory.cc
@@ -102,12 +102,22 @@ Environment EnvironmentFactory::CreateWithDefaults() && {
if (field_trials_ == nullptr) {
Set(std::make_unique<FieldTrialBasedConfig>());
}
+#if defined(WEBRTC_MOZILLA_BUILD)
+ // We want to use our clock, not GetRealTimeClockRaw, and we avoid
+ // building the code under third_party/libwebrtc/task_queue. To
+ // ensure we're setting up things correctly, namely providing an
+ // Environment object with a preset task_queue_factory and clock,
+ // we'll do a release assert here.
+ RTC_CHECK(clock_);
+ RTC_CHECK(task_queue_factory_);
+#else
if (clock_ == nullptr) {
Set(Clock::GetRealTimeClock());
}
if (task_queue_factory_ == nullptr) {
Set(CreateDefaultTaskQueueFactory(field_trials_));
}
+#endif
if (event_log_ == nullptr) {
Set(std::make_unique<RtcEventLogNull>());
}
diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn
index bacc3ca87a..5c3dd242b6 100644
--- a/api/task_queue/BUILD.gn
+++ b/api/task_queue/BUILD.gn
@@ -83,6 +83,10 @@ rtc_library("task_queue_test") {
}
+ {
// We don't want members above to be guarded by capture_checker_ as
// it's meant to be for members that are accessed on the API thread
// only when we are not capturing. The code above can be called many
@@ -298,6 +299,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
_requestedCapability = capability;
_captureStarted = true;
_streaming = true;
+ }
rtc_library("default_task_queue_factory") {
+# Mozilla - disable this entire target to avoid inclusion of code we want
+# to avoid. Better here than trying to wack-a-mole for places that list
+# it as a dependency.
+if (!build_with_mozilla) {
visibility = [ "*" ]
if (!is_ios && !is_android) {
# Internally webrtc shouldn't rely on any specific TaskQueue implementation
@@ -121,6 +125,7 @@ rtc_library("default_task_queue_factory") {
sources += [ "default_task_queue_factory_stdlib.cc" ]
deps += [ "../../rtc_base:rtc_task_queue_stdlib" ]
}
+} # of if (!build_with_mozilla) {
}
rtc_library("pending_task_safety_flag") {
// start capture thread;
if (_captureThread.empty()) {

View File

@ -1,39 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 10 Apr 2024 21:54:00 +0000
Subject: Bug 1888181 - (fix-52fec7d3) Limit scope of race checker in
VideoCaptureModuleV4L2::StartCapture. r=mjf
Date: Fri, 19 Apr 2024 06:09:00 +0000
Subject: Bug 1892221 - Initialize VideoCaptureModuleV4L2::_streaming in ctor.
r=webrtc-reviewers,dbaker
TSAN detects a race between destroying the scoped race checker in StartCapture
and creating the scoped race checker in CaptureProcess, because once the capture
thread has been created (and given its run function) there is no synchronization
before the run function starts to run.
This patch avoids the race by destroying the StartCapture scoped race checker
before creating the capture thread.
Differential Revision: https://phabricator.services.mozilla.com/D207203
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b046a1446cee5ab485d4868b3ca9784b16b2d02f
Differential Revision: https://phabricator.services.mozilla.com/D207926
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/00c4bd7039dc8992dd93d4a5948a9260b72ec2a8
---
modules/video_capture/linux/video_capture_v4l2.cc | 2 ++
1 file changed, 2 insertions(+)
modules/video_capture/linux/video_capture_v4l2.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 6d8a5e463f..db2450a2c7 100644
index db2450a2c7..74af348a6c 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -129,6 +129,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
}
@@ -62,6 +62,7 @@ VideoCaptureModuleV4L2::VideoCaptureModuleV4L2()
_deviceId(-1),
_deviceFd(-1),
_buffersAllocatedByDevice(-1),
+ _streaming(false),
_captureStarted(false),
_pool(NULL) {}
+ {
// We don't want members above to be guarded by capture_checker_ as
// it's meant to be for members that are accessed on the API thread
// only when we are not capturing. The code above can be called many
@@ -298,6 +299,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
_requestedCapability = capability;
_captureStarted = true;
_streaming = true;
+ }
// start capture thread;
if (_captureThread.empty()) {

View File

@ -1,23 +1,52 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 19 Apr 2024 06:09:00 +0000
Subject: Bug 1892221 - Initialize VideoCaptureModuleV4L2::_streaming in ctor.
r=webrtc-reviewers,dbaker
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 2 May 2024 00:47:00 -0700
Subject: Bug 1892299 - fix-afaae4e38a - fix adapted_track_source build
exclusion;r?mjf
Differential Revision: https://phabricator.services.mozilla.com/D207926
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/00c4bd7039dc8992dd93d4a5948a9260b72ec2a8
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/60304c5d8a86fdecfe7527e75629dbc65fc9cbc1
---
modules/video_capture/linux/video_capture_v4l2.cc | 1 +
1 file changed, 1 insertion(+)
media/BUILD.gn | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index db2450a2c7..74af348a6c 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -62,6 +62,7 @@ VideoCaptureModuleV4L2::VideoCaptureModuleV4L2()
_deviceId(-1),
_deviceFd(-1),
_buffersAllocatedByDevice(-1),
+ _streaming(false),
_captureStarted(false),
_pool(NULL) {}
diff --git a/media/BUILD.gn b/media/BUILD.gn
index c55930ca14..808222978a 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -55,6 +55,11 @@ rtc_library("rtc_media_base") {
"base/video_broadcaster.h", # Used downstream
"base/video_common.h", # Used downstream
]
+ if (build_with_mozilla) {
+ sources -= [
+ "base/adapted_video_track_source.h",
+ ]
+ }
deps = [
":adapted_video_track_source",
":codec",
@@ -126,12 +131,6 @@ rtc_library("rtc_media_base") {
"../rtc_base/third_party/sigslot",
"../video/config:encoder_config",
]
- if (build_with_mozilla) {
- sources -= [
- "base/adapted_video_track_source.cc",
- "base/adapted_video_track_source.h",
- ]
- }
}
rtc_library("adapted_video_track_source") {
@@ -139,6 +138,12 @@ rtc_library("adapted_video_track_source") {
"base/adapted_video_track_source.cc",
"base/adapted_video_track_source.h",
]
+ if (build_with_mozilla) {
+ sources -= [
+ "base/adapted_video_track_source.cc",
+ "base/adapted_video_track_source.h",
+ ]
+ }
deps = [
":video_adapter",
":video_broadcaster",

View File

@ -1,52 +1,44 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 2 May 2024 00:47:00 -0700
Subject: Bug 1892299 - fix-afaae4e38a - fix adapted_track_source build
exclusion;r?mjf
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Invert _captureThread check in
VideoCaptureModuleV4L2::StartCapture. r=webrtc-reviewers,mjf
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/60304c5d8a86fdecfe7527e75629dbc65fc9cbc1
Differential Revision: https://phabricator.services.mozilla.com/D208186
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ed6737b8214bf664642eb17cbf66a8c8450e569
---
media/BUILD.gn | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
.../video_capture/linux/video_capture_v4l2.cc | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/media/BUILD.gn b/media/BUILD.gn
index c55930ca14..808222978a 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -55,6 +55,11 @@ rtc_library("rtc_media_base") {
"base/video_broadcaster.h", # Used downstream
"base/video_common.h", # Used downstream
]
+ if (build_with_mozilla) {
+ sources -= [
+ "base/adapted_video_track_source.h",
+ ]
+ }
deps = [
":adapted_video_track_source",
":codec",
@@ -126,12 +131,6 @@ rtc_library("rtc_media_base") {
"../rtc_base/third_party/sigslot",
"../video/config:encoder_config",
]
- if (build_with_mozilla) {
- sources -= [
- "base/adapted_video_track_source.cc",
- "base/adapted_video_track_source.h",
- ]
- }
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 74af348a6c..29ca864e19 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,16 +303,19 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
// start capture thread;
- if (_captureThread.empty()) {
- quit_ = false;
- _captureThread = rtc::PlatformThread::SpawnJoinable(
- [self = scoped_refptr(this)] {
- while (self->CaptureProcess()) {
- }
- },
- "CaptureThread",
- rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
+ if (!_captureThread.empty()) {
+ return 0;
}
+
+ quit_ = false;
+
+ _captureThread = rtc::PlatformThread::SpawnJoinable(
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
+ }
+ },
+ "CaptureThread",
+ rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
return 0;
}
rtc_library("adapted_video_track_source") {
@@ -139,6 +138,12 @@ rtc_library("adapted_video_track_source") {
"base/adapted_video_track_source.cc",
"base/adapted_video_track_source.h",
]
+ if (build_with_mozilla) {
+ sources -= [
+ "base/adapted_video_track_source.cc",
+ "base/adapted_video_track_source.h",
+ ]
+ }
deps = [
":video_adapter",
":video_broadcaster",

View File

@ -1,44 +1,31 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Invert _captureThread check in
VideoCaptureModuleV4L2::StartCapture. r=webrtc-reviewers,mjf
Subject: Bug 1892329 - Fix threading issues in VideoCaptureModuleV4L2 once and
for all. r=webrtc-reviewers,mjf
Differential Revision: https://phabricator.services.mozilla.com/D208186
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ed6737b8214bf664642eb17cbf66a8c8450e569
Differential Revision: https://phabricator.services.mozilla.com/D208187
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/65e120a9c1dcb9c8f1c8930e808b03aa149eaf40
---
.../video_capture/linux/video_capture_v4l2.cc | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
modules/video_capture/linux/video_capture_v4l2.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 74af348a6c..29ca864e19 100644
index 29ca864e19..b6e7e79a2a 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -303,16 +303,19 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
@@ -300,7 +300,6 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
_requestedCapability = capability;
_captureStarted = true;
_streaming = true;
- }
// start capture thread;
- if (_captureThread.empty()) {
- quit_ = false;
- _captureThread = rtc::PlatformThread::SpawnJoinable(
- [self = scoped_refptr(this)] {
- while (self->CaptureProcess()) {
- }
- },
- "CaptureThread",
- rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
+ if (!_captureThread.empty()) {
+ return 0;
if (!_captureThread.empty()) {
@@ -308,6 +307,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
+
+ quit_ = false;
+
+ _captureThread = rtc::PlatformThread::SpawnJoinable(
+ [self = scoped_refptr(this)] {
+ while (self->CaptureProcess()) {
+ }
+ },
+ "CaptureThread",
+ rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
return 0;
}
quit_ = false;
+ }
_captureThread = rtc::PlatformThread::SpawnJoinable(
[self = scoped_refptr(this)] {

View File

@ -1,31 +1,23 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 6 May 2024 07:28:00 +0000
Subject: Bug 1892329 - Fix threading issues in VideoCaptureModuleV4L2 once and
for all. r=webrtc-reviewers,mjf
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 17 May 2024 22:30:00 -0500
Subject: Bug 1897501 - (fix-09bb4f09e1) keep default python intepreter as
python3
Differential Revision: https://phabricator.services.mozilla.com/D208187
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/65e120a9c1dcb9c8f1c8930e808b03aa149eaf40
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b21ca84c8b2620a98515624de0e43a237698726c
---
modules/video_capture/linux/video_capture_v4l2.cc | 2 +-
.gn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc
index 29ca864e19..b6e7e79a2a 100644
--- a/modules/video_capture/linux/video_capture_v4l2.cc
+++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -300,7 +300,6 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
_requestedCapability = capability;
_captureStarted = true;
_streaming = true;
- }
diff --git a/.gn b/.gn
index b374016a64..8325a46ed3 100644
--- a/.gn
+++ b/.gn
@@ -13,7 +13,7 @@ buildconfig = "//build/config/BUILDCONFIG.gn"
// start capture thread;
if (!_captureThread.empty()) {
@@ -308,6 +307,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
}
# The python interpreter to use by default. On Windows, this will look
# for vpython3.exe and vpython3.bat.
-script_executable = "vpython3"
+script_executable = "python3"
quit_ = false;
+ }
_captureThread = rtc::PlatformThread::SpawnJoinable(
[self = scoped_refptr(this)] {
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly

View File

@ -1,23 +1,31 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 17 May 2024 22:30:00 -0500
Subject: Bug 1897501 - (fix-09bb4f09e1) keep default python intepreter as
python3
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 23 May 2024 17:28:00 +0000
Subject: Bug 1897459 - P0 - for BSD do not build physical_socket_server in
libwebrtc;r=mjf,webrtc-reviewers
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b21ca84c8b2620a98515624de0e43a237698726c
libwebrtc added the use of several non-portable socket options in this code.
Firefox does not use any of the code in this file, but there is a header dependency chain leading from code that is used.
Differential Revision: https://phabricator.services.mozilla.com/D210858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4e7b3c485e549e7e35b227b517acadbbad957004
---
.gn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rtc_base/BUILD.gn | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.gn b/.gn
index b374016a64..8325a46ed3 100644
--- a/.gn
+++ b/.gn
@@ -13,7 +13,7 @@ buildconfig = "//build/config/BUILDCONFIG.gn"
# The python interpreter to use by default. On Windows, this will look
# for vpython3.exe and vpython3.bat.
-script_executable = "vpython3"
+script_executable = "python3"
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index db74b5a811..6f8e2d1d98 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -999,6 +999,12 @@ rtc_library("threading") {
"thread.cc",
"thread.h",
]
+ if (is_bsd && build_with_mozilla) {
+ sources -= [
+ "physical_socket_server.cc",
+ "physical_socket_server.h",
+ ]
+ }
deps = [
":async_dns_resolver",
":byte_order",

View File

@ -1,31 +1,48 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 23 May 2024 17:28:00 +0000
Subject: Bug 1897459 - P0 - for BSD do not build physical_socket_server in
libwebrtc;r=mjf,webrtc-reviewers
Subject: Bug 1897459 - P2 - for BSD reference null socket server
instead;r=mjf,webrtc-reviewers
libwebrtc added the use of several non-portable socket options in this code.
Firefox does not use any of the code in this file, but there is a header dependency chain leading from code that is used.
Differential Revision: https://phabricator.services.mozilla.com/D210858
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4e7b3c485e549e7e35b227b517acadbbad957004
Differential Revision: https://phabricator.services.mozilla.com/D211095
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0993ae41fb7db1624dedc5cf2278cd5a505f18f5
---
rtc_base/BUILD.gn | 6 ++++++
1 file changed, 6 insertions(+)
rtc_base/internal/default_socket_server.cc | 4 ++--
rtc_base/virtual_socket_server.cc | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index db74b5a811..6f8e2d1d98 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -999,6 +999,12 @@ rtc_library("threading") {
"thread.cc",
"thread.h",
]
+ if (is_bsd && build_with_mozilla) {
+ sources -= [
+ "physical_socket_server.cc",
+ "physical_socket_server.h",
+ ]
+ }
deps = [
":async_dns_resolver",
":byte_order",
diff --git a/rtc_base/internal/default_socket_server.cc b/rtc_base/internal/default_socket_server.cc
index 5632b989fc..cb7b81978a 100644
--- a/rtc_base/internal/default_socket_server.cc
+++ b/rtc_base/internal/default_socket_server.cc
@@ -14,7 +14,7 @@
#include "rtc_base/socket_server.h"
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(WEBRTC_BSD)
#include "rtc_base/null_socket_server.h"
#else
#include "rtc_base/physical_socket_server.h"
@@ -23,7 +23,7 @@
namespace rtc {
std::unique_ptr<SocketServer> CreateDefaultSocketServer() {
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(WEBRTC_BSD)
return std::unique_ptr<SocketServer>(new rtc::NullSocketServer);
#else
return std::unique_ptr<SocketServer>(new rtc::PhysicalSocketServer);
diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc
index dd02281c93..37ec3e6a92 100644
--- a/rtc_base/virtual_socket_server.cc
+++ b/rtc_base/virtual_socket_server.cc
@@ -24,7 +24,9 @@
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/logging.h"
+#if !defined(WEBRTC_BSD)
#include "rtc_base/physical_socket_server.h"
+#endif
#include "rtc_base/socket_address_pair.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"

View File

@ -1,48 +1,59 @@
From: Nico Grunbaum <na-g@nostrum.com>
Date: Thu, 23 May 2024 17:28:00 +0000
Subject: Bug 1897459 - P2 - for BSD reference null socket server
instead;r=mjf,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 21 Jun 2024 16:28:00 -0500
Subject: Bug 1903098 - (fix-cd09858f4a) disable perfetto usage to avoid new
third_party library.
Differential Revision: https://phabricator.services.mozilla.com/D211095
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0993ae41fb7db1624dedc5cf2278cd5a505f18f5
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b050c455caa1d24a0cfa4933ac8cd82c9cd3c347
---
rtc_base/internal/default_socket_server.cc | 4 ++--
rtc_base/virtual_socket_server.cc | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
BUILD.gn | 2 ++
modules/video_coding/generic_decoder.cc | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/rtc_base/internal/default_socket_server.cc b/rtc_base/internal/default_socket_server.cc
index 5632b989fc..cb7b81978a 100644
--- a/rtc_base/internal/default_socket_server.cc
+++ b/rtc_base/internal/default_socket_server.cc
@@ -14,7 +14,7 @@
diff --git a/BUILD.gn b/BUILD.gn
index 5f81529ed4..e94dc7e663 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -278,6 +278,7 @@ config("rtc_prod_config") {
}
#include "rtc_base/socket_server.h"
group("tracing") {
+if (!build_with_mozilla) {
all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ]
if (rtc_use_perfetto) {
if (build_with_chromium) {
@@ -294,6 +295,7 @@ group("tracing") {
[ "//third_party/perfetto/include/perfetto/tracing" ]
}
}
+}
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(WEBRTC_BSD)
#include "rtc_base/null_socket_server.h"
#else
#include "rtc_base/physical_socket_server.h"
@@ -23,7 +23,7 @@
namespace rtc {
std::unique_ptr<SocketServer> CreateDefaultSocketServer() {
-#if defined(__native_client__)
+#if defined(__native_client__) || defined(WEBRTC_BSD)
return std::unique_ptr<SocketServer>(new rtc::NullSocketServer);
#else
return std::unique_ptr<SocketServer>(new rtc::PhysicalSocketServer);
diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc
index dd02281c93..37ec3e6a92 100644
--- a/rtc_base/virtual_socket_server.cc
+++ b/rtc_base/virtual_socket_server.cc
@@ -24,7 +24,9 @@
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/logging.h"
+#if !defined(WEBRTC_BSD)
#include "rtc_base/physical_socket_server.h"
+#endif
#include "rtc_base/socket_address_pair.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
if (rtc_use_perfetto) {
rtc_library("webrtc_libperfetto") {
diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc
index 1f2c6004e8..99a8746790 100644
--- a/modules/video_coding/generic_decoder.cc
+++ b/modules/video_coding/generic_decoder.cc
@@ -103,9 +103,9 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
std::optional<int32_t> decode_time_ms,
std::optional<uint8_t> qp) {
RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point";
- TRACE_EVENT(
- "webrtc", "VCMDecodedFrameCallback::Decoded",
- perfetto::TerminatingFlow::ProcessScoped(decodedImage.rtp_timestamp()));
+ TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
+ TRACE_EVENT_SCOPE_GLOBAL, "timestamp",
+ decodedImage.rtp_timestamp());
// TODO(holmer): We should improve this so that we can handle multiple
// callbacks from one call to Decode().
std::optional<FrameInfo> frame_info;
@@ -293,8 +293,8 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, Timestamp now) {
int32_t VCMGenericDecoder::Decode(const EncodedImage& frame,
Timestamp now,
int64_t render_time_ms) {
- TRACE_EVENT("webrtc", "VCMGenericDecoder::Decode",
- perfetto::Flow::ProcessScoped(frame.RtpTimestamp()));
+ TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
+ frame.RtpTimestamp());
FrameInfo frame_info;
frame_info.rtp_timestamp = frame.RtpTimestamp();
frame_info.decode_start = now;

View File

@ -1,59 +1,30 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Fri, 21 Jun 2024 16:28:00 -0500
Subject: Bug 1903098 - (fix-cd09858f4a) disable perfetto usage to avoid new
third_party library.
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 25 Jul 2024 10:07:00 -0500
Subject: Bug 1909234 - (fix-4fec6f9c67dc) Hollow out the new ssl_adapter lib.
r?mjf
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b050c455caa1d24a0cfa4933ac8cd82c9cd3c347
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee2f06666bcc6d22c4d7c93b78fb52d28452d055
---
BUILD.gn | 2 ++
modules/video_coding/generic_decoder.cc | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
rtc_base/BUILD.gn | 2 ++
1 file changed, 2 insertions(+)
diff --git a/BUILD.gn b/BUILD.gn
index 5f81529ed4..e94dc7e663 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -278,6 +278,7 @@ config("rtc_prod_config") {
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 6f8e2d1d98..c659427577 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1619,6 +1619,7 @@ if (!build_with_mozilla) {
}
group("tracing") {
rtc_library("ssl_adapter") {
+if (!build_with_mozilla) {
all_dependent_configs = [ "//third_party/perfetto/gn:public_config" ]
if (rtc_use_perfetto) {
if (build_with_chromium) {
@@ -294,6 +295,7 @@ group("tracing") {
[ "//third_party/perfetto/include/perfetto/tracing" ]
visibility = [ "*" ]
sources = [
"openssl_adapter.cc",
@@ -1668,6 +1669,7 @@ rtc_library("ssl_adapter") {
configs += [ "..:external_ssl_library" ]
}
}
+}
if (rtc_use_perfetto) {
rtc_library("webrtc_libperfetto") {
diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc
index 1f2c6004e8..99a8746790 100644
--- a/modules/video_coding/generic_decoder.cc
+++ b/modules/video_coding/generic_decoder.cc
@@ -103,9 +103,9 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
std::optional<int32_t> decode_time_ms,
std::optional<uint8_t> qp) {
RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point";
- TRACE_EVENT(
- "webrtc", "VCMDecodedFrameCallback::Decoded",
- perfetto::TerminatingFlow::ProcessScoped(decodedImage.rtp_timestamp()));
+ TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
+ TRACE_EVENT_SCOPE_GLOBAL, "timestamp",
+ decodedImage.rtp_timestamp());
// TODO(holmer): We should improve this so that we can handle multiple
// callbacks from one call to Decode().
std::optional<FrameInfo> frame_info;
@@ -293,8 +293,8 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, Timestamp now) {
int32_t VCMGenericDecoder::Decode(const EncodedImage& frame,
Timestamp now,
int64_t render_time_ms) {
- TRACE_EVENT("webrtc", "VCMGenericDecoder::Decode",
- perfetto::Flow::ProcessScoped(frame.RtpTimestamp()));
+ TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
+ frame.RtpTimestamp());
FrameInfo frame_info;
frame_info.rtp_timestamp = frame.RtpTimestamp();
frame_info.decode_start = now;
rtc_source_set("gtest_prod") {
sources = [ "gtest_prod_util.h" ]

View File

@ -1,30 +1,26 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Thu, 25 Jul 2024 10:07:00 -0500
Subject: Bug 1909234 - (fix-4fec6f9c67dc) Hollow out the new ssl_adapter lib.
r?mjf
Date: Fri, 26 Jul 2024 09:26:00 -0500
Subject: Bug 1909234 - (fix-a0d1a51217) Move this errant include where it
belongs. r?mjf
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee2f06666bcc6d22c4d7c93b78fb52d28452d055
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6baf67202c67b27c6464cb8e4dbb419485aa6c4c
---
rtc_base/BUILD.gn | 2 ++
1 file changed, 2 insertions(+)
api/test/network_emulation/BUILD.gn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index 6f8e2d1d98..c659427577 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1619,6 +1619,7 @@ if (!build_with_mozilla) {
}
diff --git a/api/test/network_emulation/BUILD.gn b/api/test/network_emulation/BUILD.gn
index bb4af451b7..447309828f 100644
--- a/api/test/network_emulation/BUILD.gn
+++ b/api/test/network_emulation/BUILD.gn
@@ -6,10 +6,10 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
rtc_library("ssl_adapter") {
+if (!build_with_mozilla) {
visibility = [ "*" ]
sources = [
"openssl_adapter.cc",
@@ -1668,6 +1669,7 @@ rtc_library("ssl_adapter") {
configs += [ "..:external_ssl_library" ]
}
}
+}
-import("//third_party/protobuf/proto_library.gni")
import("../../../webrtc.gni")
rtc_source_set("gtest_prod") {
sources = [ "gtest_prod_util.h" ]
if (rtc_enable_protobuf) {
+ import("//third_party/protobuf/proto_library.gni")
proto_library("network_config_schedule_proto") {
visibility = [ "*" ]
sources = [ "network_config_schedule.proto" ]

View File

@ -1,26 +1,25 @@
From: Byron Campen <docfaraday@gmail.com>
Date: Fri, 26 Jul 2024 09:26:00 -0500
Subject: Bug 1909234 - (fix-a0d1a51217) Move this errant include where it
belongs. r?mjf
From: Dan Baker <dbaker@mozilla.com>
Date: Tue, 27 Aug 2024 14:09:00 -0600
Subject: Bug 1912989 - (fix-2360208f7d) Removed build command causing failure.
- moz.build file updates
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6baf67202c67b27c6464cb8e4dbb419485aa6c4c
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fd4bc7427678a45283f0f56418ee2c70fac711e6
---
api/test/network_emulation/BUILD.gn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
.gn | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/api/test/network_emulation/BUILD.gn b/api/test/network_emulation/BUILD.gn
index bb4af451b7..447309828f 100644
--- a/api/test/network_emulation/BUILD.gn
+++ b/api/test/network_emulation/BUILD.gn
@@ -6,10 +6,10 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
diff --git a/.gn b/.gn
index 8325a46ed3..52acee7e60 100644
--- a/.gn
+++ b/.gn
@@ -38,7 +38,9 @@ no_check_targets = [
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
[ "//build_overrides/build.gni" ]
-import("//third_party/protobuf/proto_library.gni")
import("../../../webrtc.gni")
-export_compile_commands = [ "*" ]
+# Normally, we'd use 'if (!build_with_mozilla)', but that flag isn't
+# available yet.
+#export_compile_commands = [ "*" ]
if (rtc_enable_protobuf) {
+ import("//third_party/protobuf/proto_library.gni")
proto_library("network_config_schedule_proto") {
visibility = [ "*" ]
sources = [ "network_config_schedule.proto" ]
default_args = {
# Webrtc does not support component builds because we are not using the

View File

@ -1,25 +1,82 @@
From: Dan Baker <dbaker@mozilla.com>
Date: Tue, 27 Aug 2024 14:09:00 -0600
Subject: Bug 1912989 - (fix-2360208f7d) Removed build command causing failure.
- moz.build file updates
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 27 Aug 2024 10:01:00 +0000
Subject: Bug 1914835 - With ScreenCaptureKit embed the mouse cursor directly.
r=webrtc-reviewers,ng
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fd4bc7427678a45283f0f56418ee2c70fac711e6
The MouseCursorMonitor on macOS is rather expensive, as for every pulled frame
it compares all pixels of the cursors used for the current and last frames.
Getting to the pixels may also incur a conversion.
Note that this comparison happens even if the backend reports it had embedded
the cursor already, as the embedding only affects composing the monitored cursor
into a captured frame.
Differential Revision: https://phabricator.services.mozilla.com/D220092
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ca7b371646d8aa40b2c3faf54570fcd1331a677
---
.gn | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
.../desktop_capture/mac/screen_capturer_sck.h | 3 +++
.../desktop_capture/mac/screen_capturer_sck.mm | 17 ++++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.gn b/.gn
index 8325a46ed3..52acee7e60 100644
--- a/.gn
+++ b/.gn
@@ -38,7 +38,9 @@ no_check_targets = [
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
[ "//build_overrides/build.gni" ]
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.h b/modules/desktop_capture/mac/screen_capturer_sck.h
index 2c5241d33e..105cbf0783 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.h
+++ b/modules/desktop_capture/mac/screen_capturer_sck.h
@@ -18,6 +18,9 @@
-export_compile_commands = [ "*" ]
+# Normally, we'd use 'if (!build_with_mozilla)', but that flag isn't
+# available yet.
+#export_compile_commands = [ "*" ]
namespace webrtc {
default_args = {
# Webrtc does not support component builds because we are not using the
+// Returns true if the ScreenCaptureKit capturer is available.
+bool ScreenCapturerSckAvailable();
+
// A DesktopCapturer implementation that uses ScreenCaptureKit.
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(
const DesktopCaptureOptions& options);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index fe44694d3a..ab4d9137a0 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -24,6 +24,8 @@
using webrtc::DesktopFrameIOSurface;
+#define SCK_AVAILABLE @available(macOS 14.0, *)
+
namespace webrtc {
class ScreenCapturerSck;
} // namespace webrtc
@@ -48,6 +50,14 @@ API_AVAILABLE(macos(14.0))
namespace webrtc {
+bool ScreenCapturerSckAvailable() {
+ bool sonomaOrHigher = false;
+ if (SCK_AVAILABLE) {
+ sonomaOrHigher = true;
+ }
+ return sonomaOrHigher;
+}
+
class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapturer {
public:
explicit ScreenCapturerSck(const DesktopCaptureOptions& options);
@@ -353,11 +363,10 @@ void ScreenCapturerSck::StartOrReconfigureCapturer() {
}
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOptions& options) {
- if (@available(macOS 14.0, *)) {
+ if (SCK_AVAILABLE) {
return std::make_unique<ScreenCapturerSck>(options);
- } else {
- return nullptr;
}
+ return nullptr;
}
} // namespace webrtc
@@ -419,3 +428,5 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
}
@end
+
+#undef SCK_AVAILABLE

View File

@ -1,82 +1,28 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 27 Aug 2024 10:01:00 +0000
Subject: Bug 1914835 - With ScreenCaptureKit embed the mouse cursor directly.
r=webrtc-reviewers,ng
Date: Wed, 28 Aug 2024 07:50:00 +0000
Subject: Bug 1915082 - From ScreenCapturerSck request frames in sRGB
colorspace. r=webrtc-reviewers,ng
The MouseCursorMonitor on macOS is rather expensive, as for every pulled frame
it compares all pixels of the cursors used for the current and last frames.
Getting to the pixels may also incur a conversion.
The desktop capture path has no colorspace handling for RGB, and libyuv assumes
sRGB by default. ScreenCaptureKit returns frames in the display's colorspace
unless told otherwise. On modern macs this is 'Display P3' and will render
inaccurately when interpreted as sRGB.
Note that this comparison happens even if the backend reports it had embedded
the cursor already, as the embedding only affects composing the monitored cursor
into a captured frame.
Differential Revision: https://phabricator.services.mozilla.com/D220092
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ca7b371646d8aa40b2c3faf54570fcd1331a677
Differential Revision: https://phabricator.services.mozilla.com/D220219
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6f6acc479b373662d4ed3ef3be84c3581622297f
---
.../desktop_capture/mac/screen_capturer_sck.h | 3 +++
.../desktop_capture/mac/screen_capturer_sck.mm | 17 ++++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
modules/desktop_capture/mac/screen_capturer_sck.mm | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.h b/modules/desktop_capture/mac/screen_capturer_sck.h
index 2c5241d33e..105cbf0783 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.h
+++ b/modules/desktop_capture/mac/screen_capturer_sck.h
@@ -18,6 +18,9 @@
namespace webrtc {
+// Returns true if the ScreenCaptureKit capturer is available.
+bool ScreenCapturerSckAvailable();
+
// A DesktopCapturer implementation that uses ScreenCaptureKit.
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(
const DesktopCaptureOptions& options);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index fe44694d3a..ab4d9137a0 100644
index ab4d9137a0..af1a4e360b 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -24,6 +24,8 @@
using webrtc::DesktopFrameIOSurface;
+#define SCK_AVAILABLE @available(macOS 14.0, *)
+
namespace webrtc {
class ScreenCapturerSck;
} // namespace webrtc
@@ -48,6 +50,14 @@ API_AVAILABLE(macos(14.0))
namespace webrtc {
+bool ScreenCapturerSckAvailable() {
+ bool sonomaOrHigher = false;
+ if (SCK_AVAILABLE) {
+ sonomaOrHigher = true;
+ }
+ return sonomaOrHigher;
+}
+
class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapturer {
public:
explicit ScreenCapturerSck(const DesktopCaptureOptions& options);
@@ -353,11 +363,10 @@ void ScreenCapturerSck::StartOrReconfigureCapturer() {
}
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOptions& options) {
- if (@available(macOS 14.0, *)) {
+ if (SCK_AVAILABLE) {
return std::make_unique<ScreenCapturerSck>(options);
- } else {
- return nullptr;
}
+ return nullptr;
}
} // namespace webrtc
@@ -419,3 +428,5 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
}
@end
+
+#undef SCK_AVAILABLE
@@ -245,6 +245,7 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
excludingWindows:@[]];
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
config.pixelFormat = kCVPixelFormatType_32BGRA;
+ config.colorSpaceName = kCGColorSpaceSRGB;
config.showsCursor = capture_options_.prefer_cursor_embedded();
config.width = filter.contentRect.size.width * filter.pointPixelScale;
config.height = filter.contentRect.size.height * filter.pointPixelScale;

View File

@ -1,28 +1,27 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Wed, 28 Aug 2024 07:50:00 +0000
Subject: Bug 1915082 - From ScreenCapturerSck request frames in sRGB
colorspace. r=webrtc-reviewers,ng
Date: Thu, 29 Aug 2024 08:31:00 +0000
Subject: Bug 1914837 - Always initialize DesktopCapturer::pid.
r=webrtc-reviewers,ng
The desktop capture path has no colorspace handling for RGB, and libyuv assumes
sRGB by default. ScreenCaptureKit returns frames in the display's colorspace
unless told otherwise. On modern macs this is 'Display P3' and will render
inaccurately when interpreted as sRGB.
This member is patched on top of libwebrtc. New backends could be added from
under us. It needs to be initialized.
Differential Revision: https://phabricator.services.mozilla.com/D220219
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6f6acc479b373662d4ed3ef3be84c3581622297f
Differential Revision: https://phabricator.services.mozilla.com/D220265
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fdf5b0a81b0c0e87d31c5963091681a0e5960678
---
modules/desktop_capture/mac/screen_capturer_sck.mm | 1 +
1 file changed, 1 insertion(+)
modules/desktop_capture/desktop_capturer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index ab4d9137a0..af1a4e360b 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -245,6 +245,7 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
excludingWindows:@[]];
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
config.pixelFormat = kCVPixelFormatType_32BGRA;
+ config.colorSpaceName = kCGColorSpaceSRGB;
config.showsCursor = capture_options_.prefer_cursor_embedded();
config.width = filter.contentRect.size.width * filter.pointPixelScale;
config.height = filter.contentRect.size.height * filter.pointPixelScale;
diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h
index 2c9c419bcd..29e05938dc 100644
--- a/modules/desktop_capture/desktop_capturer.h
+++ b/modules/desktop_capture/desktop_capturer.h
@@ -82,7 +82,7 @@ class RTC_EXPORT DesktopCapturer {
struct Source {
// The unique id to represent a Source of current DesktopCapturer.
SourceId id;
- pid_t pid;
+ pid_t pid = 0;
// Title of the window or screen in UTF-8 encoding, maybe empty. This field
// should not be used to identify a source.

View File

@ -1,27 +1,190 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 29 Aug 2024 08:31:00 +0000
Subject: Bug 1914837 - Always initialize DesktopCapturer::pid.
r=webrtc-reviewers,ng
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 5 Sep 2024 16:04:00 +0000
Subject: Bug 1830275 - Add missing support for device change notifications
r=pehrsons,webrtc-reviewers
This member is patched on top of libwebrtc. New backends could be added from
under us. It needs to be initialized.
Registers each DeviceInfoPipeWire in PipeWireSession we use and calls
DeviceChange() for each once there is a new camera added or removed to
invoke OnDeviceChange() for every registered VideoInputFeedback.
Differential Revision: https://phabricator.services.mozilla.com/D220265
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fdf5b0a81b0c0e87d31c5963091681a0e5960678
Differential Revision: https://phabricator.services.mozilla.com/D219218
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/60eb5ef11c8df7eb6e0d616cb76885d9109f114d
---
modules/desktop_capture/desktop_capturer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
.../linux/device_info_pipewire.cc | 10 +++-
.../video_capture/linux/pipewire_session.cc | 47 ++++++++++++++++++-
.../video_capture/linux/pipewire_session.h | 26 +++++++++-
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h
index 2c9c419bcd..29e05938dc 100644
--- a/modules/desktop_capture/desktop_capturer.h
+++ b/modules/desktop_capture/desktop_capturer.h
@@ -82,7 +82,7 @@ class RTC_EXPORT DesktopCapturer {
struct Source {
// The unique id to represent a Source of current DesktopCapturer.
SourceId id;
- pid_t pid;
+ pid_t pid = 0;
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index db2a3c7099..a0607b4aba 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -29,13 +29,19 @@
namespace webrtc {
namespace videocapturemodule {
DeviceInfoPipeWire::DeviceInfoPipeWire(VideoCaptureOptions* options)
- : DeviceInfoImpl(), pipewire_session_(options->pipewire_session()) {}
+ : DeviceInfoImpl(), pipewire_session_(options->pipewire_session()) {
+ const bool ret = pipewire_session_->RegisterDeviceInfo(this);
+ RTC_CHECK(ret);
+}
// Title of the window or screen in UTF-8 encoding, maybe empty. This field
// should not be used to identify a source.
int32_t DeviceInfoPipeWire::Init() {
return 0;
}
-DeviceInfoPipeWire::~DeviceInfoPipeWire() = default;
+DeviceInfoPipeWire::~DeviceInfoPipeWire() {
+ const bool ret = pipewire_session_->DeRegisterDeviceInfo(this);
+ RTC_CHECK(ret);
+}
uint32_t DeviceInfoPipeWire::NumberOfDevices() {
RTC_CHECK(pipewire_session_);
diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc
index e9f7f765a5..29e454f00b 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -9,6 +9,7 @@
*/
#include "modules/video_capture/linux/pipewire_session.h"
+#include "modules/video_capture/linux/device_info_pipewire.h"
#include <spa/monitor/device.h>
#include <spa/param/format-utils.h>
@@ -278,6 +279,28 @@ void PipeWireSession::InitPipeWire(int fd) {
Finish(VideoCaptureOptions::Status::ERROR);
}
+bool PipeWireSession::RegisterDeviceInfo(DeviceInfoPipeWire* device_info) {
+ RTC_CHECK(device_info);
+ MutexLock lock(&device_info_lock_);
+ auto it = std::find(device_info_list_.begin(), device_info_list_.end(), device_info);
+ if (it == device_info_list_.end()) {
+ device_info_list_.push_back(device_info);
+ return true;
+ }
+ return false;
+}
+
+bool PipeWireSession::DeRegisterDeviceInfo(DeviceInfoPipeWire* device_info) {
+ RTC_CHECK(device_info);
+ MutexLock lock(&device_info_lock_);
+ auto it = std::find(device_info_list_.begin(), device_info_list_.end(), device_info);
+ if (it != device_info_list_.end()) {
+ device_info_list_.erase(it);
+ return true;
+ }
+ return false;
+}
+
RTC_NO_SANITIZE("cfi-icall")
bool PipeWireSession::StartPipeWire(int fd) {
pw_init(/*argc=*/nullptr, /*argv=*/nullptr);
@@ -350,6 +373,21 @@ void PipeWireSession::PipeWireSync() {
sync_seq_ = pw_core_sync(pw_core_, PW_ID_CORE, sync_seq_);
}
+void PipeWireSession::NotifyDeviceChange() {
+ RTC_LOG(LS_INFO) << "Notify about device list changes";
+ MutexLock lock(&device_info_lock_);
+
+ // It makes sense to notify about device changes only once we are
+ // properly initialized.
+ if (status_ != VideoCaptureOptions::Status::SUCCESS) {
+ return;
+ }
+
+ for (auto* deviceInfo : device_info_list_) {
+ deviceInfo->DeviceChange();
+ }
+}
+
// static
void PipeWireSession::OnCoreError(void* data,
uint32_t id,
@@ -408,6 +446,8 @@ void PipeWireSession::OnRegistryGlobal(void* data,
that->nodes_.push_back(PipeWireNode::Create(that, id, props));
that->PipeWireSync();
+
+ that->NotifyDeviceChange();
}
// static
@@ -419,10 +459,15 @@ void PipeWireSession::OnRegistryGlobalRemove(void* data, uint32_t id) {
return node->id() == id;
});
that->nodes_.erase(it, that->nodes_.end());
+
+ that->NotifyDeviceChange();
}
void PipeWireSession::Finish(VideoCaptureOptions::Status status) {
- status_ = status;
+ {
+ MutexLock lock(&device_info_lock_);
+ status_ = status;
+ }
webrtc::MutexLock lock(&callback_lock_);
diff --git a/modules/video_capture/linux/pipewire_session.h b/modules/video_capture/linux/pipewire_session.h
index 84273ea695..1f3a00614f 100644
--- a/modules/video_capture/linux/pipewire_session.h
+++ b/modules/video_capture/linux/pipewire_session.h
@@ -29,6 +29,7 @@
namespace webrtc {
namespace videocapturemodule {
+class DeviceInfoPipeWire;
class PipeWireSession;
class VideoCaptureModulePipeWire;
@@ -97,6 +98,21 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
void Init(VideoCaptureOptions::Callback* callback,
int fd = kInvalidPipeWireFd);
+
+ // [De]Register DeviceInfo for device change updates
+ // These methods will add or remove references to DeviceInfo
+ // objects that we want to notify about device changes.
+ // NOTE: We do not take ownership of these objects and
+ // they should never be released by us. All the instances
+ // of DeviceInfoPipeWire must outlive their registration.
+
+ // Returns true when DeviceInfo was successfuly registered
+ // or false otherwise, when it was already registered before.
+ bool RegisterDeviceInfo(DeviceInfoPipeWire* device_info);
+ // Returns true when DeviceInfo was successfuly unregistered
+ // or false otherwise, when it was not previously registered.
+ bool DeRegisterDeviceInfo(DeviceInfoPipeWire* device_info);
+
const std::deque<PipeWireNode::PipeWireNodePtr>& nodes() const {
return nodes_;
}
@@ -111,6 +127,8 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
void StopPipeWire();
void PipeWireSync();
+ void NotifyDeviceChange();
+
static void OnCoreError(void* data,
uint32_t id,
int seq,
@@ -133,7 +151,13 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
VideoCaptureOptions::Callback* callback_ RTC_GUARDED_BY(&callback_lock_) =
nullptr;
- VideoCaptureOptions::Status status_;
+ webrtc::Mutex device_info_lock_;
+ std::vector<DeviceInfoPipeWire*> device_info_list_
+ RTC_GUARDED_BY(device_info_lock_);
+ // Guard with device_info_lock, because currently it's the only place where
+ // we use this status information.
+ VideoCaptureOptions::Status status_
+ RTC_GUARDED_BY(device_info_lock_);
struct pw_thread_loop* pw_main_loop_ = nullptr;
struct pw_context* pw_context_ = nullptr;

View File

@ -1,190 +1,23 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 5 Sep 2024 16:04:00 +0000
Subject: Bug 1830275 - Add missing support for device change notifications
r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 17 Sep 2024 13:33:00 -0500
Subject: Bug 1918268 - (fix-96c1b9c5ea) provide template arg for optional to
fix compile error
Registers each DeviceInfoPipeWire in PipeWireSession we use and calls
DeviceChange() for each once there is a new camera added or removed to
invoke OnDeviceChange() for every registered VideoInputFeedback.
Differential Revision: https://phabricator.services.mozilla.com/D219218
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/60eb5ef11c8df7eb6e0d616cb76885d9109f114d
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ca2211dbb0dd8864768cdcce1ea146bdbb0faeda
---
.../linux/device_info_pipewire.cc | 10 +++-
.../video_capture/linux/pipewire_session.cc | 47 ++++++++++++++++++-
.../video_capture/linux/pipewire_session.h | 26 +++++++++-
3 files changed, 79 insertions(+), 4 deletions(-)
video/video_send_stream_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc
index db2a3c7099..a0607b4aba 100644
--- a/modules/video_capture/linux/device_info_pipewire.cc
+++ b/modules/video_capture/linux/device_info_pipewire.cc
@@ -29,13 +29,19 @@
namespace webrtc {
namespace videocapturemodule {
DeviceInfoPipeWire::DeviceInfoPipeWire(VideoCaptureOptions* options)
- : DeviceInfoImpl(), pipewire_session_(options->pipewire_session()) {}
+ : DeviceInfoImpl(), pipewire_session_(options->pipewire_session()) {
+ const bool ret = pipewire_session_->RegisterDeviceInfo(this);
+ RTC_CHECK(ret);
+}
int32_t DeviceInfoPipeWire::Init() {
return 0;
diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc
index 77f40f9001..0514ee9456 100644
--- a/video/video_send_stream_impl.cc
+++ b/video/video_send_stream_impl.cc
@@ -782,7 +782,7 @@ MediaStreamAllocationConfig VideoSendStreamImpl::GetAllocationConfig() const {
!config_.suspend_below_min_bitrate,
encoder_bitrate_priority_,
(content_type_ == VideoEncoderConfig::ContentType::kRealtimeVideo)
- ? std::optional(TrackRateElasticity::kCanConsumeExtraRate)
+ ? std::optional<TrackRateElasticity>(TrackRateElasticity::kCanConsumeExtraRate)
: std::nullopt};
}
-DeviceInfoPipeWire::~DeviceInfoPipeWire() = default;
+DeviceInfoPipeWire::~DeviceInfoPipeWire() {
+ const bool ret = pipewire_session_->DeRegisterDeviceInfo(this);
+ RTC_CHECK(ret);
+}
uint32_t DeviceInfoPipeWire::NumberOfDevices() {
RTC_CHECK(pipewire_session_);
diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc
index e9f7f765a5..29e454f00b 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -9,6 +9,7 @@
*/
#include "modules/video_capture/linux/pipewire_session.h"
+#include "modules/video_capture/linux/device_info_pipewire.h"
#include <spa/monitor/device.h>
#include <spa/param/format-utils.h>
@@ -278,6 +279,28 @@ void PipeWireSession::InitPipeWire(int fd) {
Finish(VideoCaptureOptions::Status::ERROR);
}
+bool PipeWireSession::RegisterDeviceInfo(DeviceInfoPipeWire* device_info) {
+ RTC_CHECK(device_info);
+ MutexLock lock(&device_info_lock_);
+ auto it = std::find(device_info_list_.begin(), device_info_list_.end(), device_info);
+ if (it == device_info_list_.end()) {
+ device_info_list_.push_back(device_info);
+ return true;
+ }
+ return false;
+}
+
+bool PipeWireSession::DeRegisterDeviceInfo(DeviceInfoPipeWire* device_info) {
+ RTC_CHECK(device_info);
+ MutexLock lock(&device_info_lock_);
+ auto it = std::find(device_info_list_.begin(), device_info_list_.end(), device_info);
+ if (it != device_info_list_.end()) {
+ device_info_list_.erase(it);
+ return true;
+ }
+ return false;
+}
+
RTC_NO_SANITIZE("cfi-icall")
bool PipeWireSession::StartPipeWire(int fd) {
pw_init(/*argc=*/nullptr, /*argv=*/nullptr);
@@ -350,6 +373,21 @@ void PipeWireSession::PipeWireSync() {
sync_seq_ = pw_core_sync(pw_core_, PW_ID_CORE, sync_seq_);
}
+void PipeWireSession::NotifyDeviceChange() {
+ RTC_LOG(LS_INFO) << "Notify about device list changes";
+ MutexLock lock(&device_info_lock_);
+
+ // It makes sense to notify about device changes only once we are
+ // properly initialized.
+ if (status_ != VideoCaptureOptions::Status::SUCCESS) {
+ return;
+ }
+
+ for (auto* deviceInfo : device_info_list_) {
+ deviceInfo->DeviceChange();
+ }
+}
+
// static
void PipeWireSession::OnCoreError(void* data,
uint32_t id,
@@ -408,6 +446,8 @@ void PipeWireSession::OnRegistryGlobal(void* data,
that->nodes_.push_back(PipeWireNode::Create(that, id, props));
that->PipeWireSync();
+
+ that->NotifyDeviceChange();
}
// static
@@ -419,10 +459,15 @@ void PipeWireSession::OnRegistryGlobalRemove(void* data, uint32_t id) {
return node->id() == id;
});
that->nodes_.erase(it, that->nodes_.end());
+
+ that->NotifyDeviceChange();
}
void PipeWireSession::Finish(VideoCaptureOptions::Status status) {
- status_ = status;
+ {
+ MutexLock lock(&device_info_lock_);
+ status_ = status;
+ }
webrtc::MutexLock lock(&callback_lock_);
diff --git a/modules/video_capture/linux/pipewire_session.h b/modules/video_capture/linux/pipewire_session.h
index 84273ea695..1f3a00614f 100644
--- a/modules/video_capture/linux/pipewire_session.h
+++ b/modules/video_capture/linux/pipewire_session.h
@@ -29,6 +29,7 @@
namespace webrtc {
namespace videocapturemodule {
+class DeviceInfoPipeWire;
class PipeWireSession;
class VideoCaptureModulePipeWire;
@@ -97,6 +98,21 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
void Init(VideoCaptureOptions::Callback* callback,
int fd = kInvalidPipeWireFd);
+
+ // [De]Register DeviceInfo for device change updates
+ // These methods will add or remove references to DeviceInfo
+ // objects that we want to notify about device changes.
+ // NOTE: We do not take ownership of these objects and
+ // they should never be released by us. All the instances
+ // of DeviceInfoPipeWire must outlive their registration.
+
+ // Returns true when DeviceInfo was successfuly registered
+ // or false otherwise, when it was already registered before.
+ bool RegisterDeviceInfo(DeviceInfoPipeWire* device_info);
+ // Returns true when DeviceInfo was successfuly unregistered
+ // or false otherwise, when it was not previously registered.
+ bool DeRegisterDeviceInfo(DeviceInfoPipeWire* device_info);
+
const std::deque<PipeWireNode::PipeWireNodePtr>& nodes() const {
return nodes_;
}
@@ -111,6 +127,8 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
void StopPipeWire();
void PipeWireSync();
+ void NotifyDeviceChange();
+
static void OnCoreError(void* data,
uint32_t id,
int seq,
@@ -133,7 +151,13 @@ class PipeWireSession : public rtc::RefCountedNonVirtual<PipeWireSession> {
VideoCaptureOptions::Callback* callback_ RTC_GUARDED_BY(&callback_lock_) =
nullptr;
- VideoCaptureOptions::Status status_;
+ webrtc::Mutex device_info_lock_;
+ std::vector<DeviceInfoPipeWire*> device_info_list_
+ RTC_GUARDED_BY(device_info_lock_);
+ // Guard with device_info_lock, because currently it's the only place where
+ // we use this status information.
+ VideoCaptureOptions::Status status_
+ RTC_GUARDED_BY(device_info_lock_);
struct pw_thread_loop* pw_main_loop_ = nullptr;
struct pw_context* pw_context_ = nullptr;

View File

@ -1,23 +1,21 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 17 Sep 2024 13:33:00 -0500
Subject: Bug 1918268 - (fix-96c1b9c5ea) provide template arg for optional to
fix compile error
Date: Wed, 18 Sep 2024 11:14:00 -0500
Subject: Bug 1918268 - (fix-ec5a968070) readd an include that upstream removed
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ca2211dbb0dd8864768cdcce1ea146bdbb0faeda
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8c080511a17a87c65771747faa74f859b7fe70bb
---
video/video_send_stream_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
api/transport/network_control.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc
index 77f40f9001..0514ee9456 100644
--- a/video/video_send_stream_impl.cc
+++ b/video/video_send_stream_impl.cc
@@ -782,7 +782,7 @@ MediaStreamAllocationConfig VideoSendStreamImpl::GetAllocationConfig() const {
!config_.suspend_below_min_bitrate,
encoder_bitrate_priority_,
(content_type_ == VideoEncoderConfig::ContentType::kRealtimeVideo)
- ? std::optional(TrackRateElasticity::kCanConsumeExtraRate)
+ ? std::optional<TrackRateElasticity>(TrackRateElasticity::kCanConsumeExtraRate)
: std::nullopt};
}
diff --git a/api/transport/network_control.h b/api/transport/network_control.h
index 90cdebe9bb..0f712da8bb 100644
--- a/api/transport/network_control.h
+++ b/api/transport/network_control.h
@@ -17,6 +17,7 @@
#include "absl/base/attributes.h"
#include "api/environment/environment.h"
#include "api/field_trials_view.h"
+#include "api/rtc_event_log/rtc_event_log.h"
#include "api/transport/network_types.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"

View File

@ -1,21 +1,23 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Wed, 18 Sep 2024 11:14:00 -0500
Subject: Bug 1918268 - (fix-ec5a968070) readd an include that upstream removed
Date: Thu, 19 Sep 2024 13:23:00 -0500
Subject: Bug 1918268 - (fix-2bc77cebf2) our base-toolchains builds need the
struct name to build
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8c080511a17a87c65771747faa74f859b7fe70bb
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1055b3892393f16136a29d12e616f29b010ab2c9
---
api/transport/network_control.h | 1 +
1 file changed, 1 insertion(+)
modules/audio_coding/neteq/neteq_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/api/transport/network_control.h b/api/transport/network_control.h
index 90cdebe9bb..0f712da8bb 100644
--- a/api/transport/network_control.h
+++ b/api/transport/network_control.h
@@ -17,6 +17,7 @@
#include "absl/base/attributes.h"
#include "api/environment/environment.h"
#include "api/field_trials_view.h"
+#include "api/rtc_event_log/rtc_event_log.h"
#include "api/transport/network_types.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 35075108a1..1ed6fda8e7 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -108,7 +108,7 @@ NetEqImpl::Dependencies::Dependencies(
stats.get())),
neteq_controller(controller_factory.Create(
env,
- {.allow_time_stretching = !config.for_test_no_time_stretching,
+ NetEqController::Config{.allow_time_stretching = !config.for_test_no_time_stretching,
.max_packets_in_buffer =
static_cast<int>(config.max_packets_in_buffer),
.base_min_delay_ms = config.min_delay_ms,

View File

@ -1,23 +1,753 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 19 Sep 2024 13:23:00 -0500
Subject: Bug 1918268 - (fix-2bc77cebf2) our base-toolchains builds need the
struct name to build
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 21:04:00 +0000
Subject: Bug 1918096 - Integrate SCContentSharingPicker into
ScreenCapturerSck. r=webrtc-reviewers,padenot,dbaker
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/1055b3892393f16136a29d12e616f29b010ab2c9
This works by creating ScreenCapturerSck with a sck_allow_system_picker
DesktopCaptureOptions flag.
The flow is similar to the Pipewire capturer in that SelectSource has no effect.
Start() brings up the system picker, and:
- automatically starts capture on selection, also reconfigures on future
selection changes.
- signals a stop by setting the permanent error flag on cancel or error.
The system picker is configured for both single display and multiple windows to
give users as much power over what they share as possible. There is an
application mode also, but other browsers are not allowing access to that as of
now.
Differential Revision: https://phabricator.services.mozilla.com/D221851
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/86a5d2db126efcee95a63e3079cda88747049197
---
modules/audio_coding/neteq/neteq_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
modules/desktop_capture/BUILD.gn | 2 +
.../desktop_capture/desktop_capture_options.h | 9 +
modules/desktop_capture/desktop_capturer.cc | 8 +-
.../desktop_capture/mac/sck_picker_handle.h | 49 +++
.../desktop_capture/mac/sck_picker_handle.mm | 68 ++++
.../desktop_capture/mac/screen_capturer_sck.h | 7 +
.../mac/screen_capturer_sck.mm | 291 ++++++++++++++++--
7 files changed, 415 insertions(+), 19 deletions(-)
create mode 100644 modules/desktop_capture/mac/sck_picker_handle.h
create mode 100644 modules/desktop_capture/mac/sck_picker_handle.mm
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 35075108a1..1ed6fda8e7 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -108,7 +108,7 @@ NetEqImpl::Dependencies::Dependencies(
stats.get())),
neteq_controller(controller_factory.Create(
env,
- {.allow_time_stretching = !config.for_test_no_time_stretching,
+ NetEqController::Config{.allow_time_stretching = !config.for_test_no_time_stretching,
.max_packets_in_buffer =
static_cast<int>(config.max_packets_in_buffer),
.base_min_delay_ms = config.min_delay_ms,
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 94741d8fc7..3940323d7e 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -600,6 +600,8 @@ if (is_mac) {
"mac/desktop_frame_iosurface.mm",
"mac/desktop_frame_provider.h",
"mac/desktop_frame_provider.mm",
+ "mac/sck_picker_handle.h",
+ "mac/sck_picker_handle.mm",
"mac/screen_capturer_mac.h",
"mac/screen_capturer_mac.mm",
"mac/screen_capturer_sck.h",
diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h
index c44ec6a9e8..51785a4085 100644
--- a/modules/desktop_capture/desktop_capture_options.h
+++ b/modules/desktop_capture/desktop_capture_options.h
@@ -79,6 +79,14 @@ class RTC_EXPORT DesktopCaptureOptions {
// new versions of macOS that remove support for the CGDisplay-based APIs.
bool allow_sck_capturer() const { return allow_sck_capturer_; }
void set_allow_sck_capturer(bool allow) { allow_sck_capturer_ = allow; }
+
+ // If ScreenCaptureKit is used for desktop capture and this flag is
+ // set, the ScreenCaptureKit backend will use SCContentSharingPicker for
+ // picking source.
+ bool allow_sck_system_picker() const { return allow_sck_system_picker_; }
+ void set_allow_sck_system_picker(bool allow) {
+ allow_sck_system_picker_ = allow;
+ }
#endif
const rtc::scoped_refptr<FullScreenWindowDetector>&
@@ -243,6 +251,7 @@ class RTC_EXPORT DesktopCaptureOptions {
rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
bool allow_iosurface_ = false;
bool allow_sck_capturer_ = false;
+ bool allow_sck_system_picker_ = false;
#endif
rtc::scoped_refptr<FullScreenWindowDetector> full_screen_window_detector_;
diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc
index a52a76c262..02f11b3867 100644
--- a/modules/desktop_capture/desktop_capturer.cc
+++ b/modules/desktop_capture/desktop_capturer.cc
@@ -30,6 +30,10 @@
#include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
#endif
+#if defined(WEBRTC_MAC)
+#include "modules/desktop_capture/mac/screen_capturer_sck.h"
+#endif
+
namespace webrtc {
void LogDesktopCapturerFullscreenDetectorUsage() {
@@ -117,11 +121,13 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateGenericCapturer(
capturer = std::make_unique<BaseCapturerPipeWire>(
options, CaptureType::kAnyScreenContent);
}
+#elif defined(WEBRTC_MAC)
+ capturer = CreateGenericCapturerSck(options);
+#endif
if (capturer && options.detect_updated_region()) {
capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
}
-#endif // defined(WEBRTC_USE_PIPEWIRE)
return capturer;
}
diff --git a/modules/desktop_capture/mac/sck_picker_handle.h b/modules/desktop_capture/mac/sck_picker_handle.h
new file mode 100644
index 0000000000..c2279733b6
--- /dev/null
+++ b/modules/desktop_capture/mac/sck_picker_handle.h
@@ -0,0 +1,49 @@
+/*
+ * 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 MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
+#define MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
+
+#include <os/availability.h>
+#include <cstddef>
+#include <memory>
+#include "modules/desktop_capture/desktop_capturer.h"
+
+@class SCContentSharingPicker;
+@class SCStream;
+
+namespace webrtc {
+
+// Helper class to manage multiple users of SCContentSharingPicker.
+//
+// The `active` and `maximumStreamCount` properties are automatically managed on
+// `SCContentSharingPicker.sharedPicker`, which is what is returned from
+// GetPicker().
+//
+// When using this class, for stream limits to work, only create one stream per
+// handle.
+//
+// Designed for single thread use.
+class API_AVAILABLE(macos(14.0)) SckPickerHandleInterface {
+ public:
+ virtual ~SckPickerHandleInterface() = default;
+ // Effectively identical to `SCContentSharingPicker.sharedPicker`.
+ virtual SCContentSharingPicker* GetPicker() const = 0;
+ // A SourceId unique to this handle.
+ virtual DesktopCapturer::SourceId Source() const = 0;
+};
+
+// Returns a newly created picker handle if the stream count limit has not been
+// reached, null otherwise.
+std::unique_ptr<SckPickerHandleInterface> API_AVAILABLE(macos(14.0)) CreateSckPickerHandle();
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
diff --git a/modules/desktop_capture/mac/sck_picker_handle.mm b/modules/desktop_capture/mac/sck_picker_handle.mm
new file mode 100644
index 0000000000..25e98b671f
--- /dev/null
+++ b/modules/desktop_capture/mac/sck_picker_handle.mm
@@ -0,0 +1,68 @@
+/*
+ * 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 "sck_picker_handle.h"
+
+#import <ScreenCaptureKit/ScreenCaptureKit.h>
+
+#include "api/sequence_checker.h"
+
+namespace webrtc {
+
+class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+ public:
+ explicit SckPickerHandle(DesktopCapturer::SourceId source) : source_(source) {
+ RTC_DCHECK_RUN_ON(&checker_);
+ RTC_CHECK_LE(sHandleCount, maximumStreamCount);
+ if (sHandleCount++ == 0) {
+ auto* picker = GetPicker();
+ picker.maximumStreamCount = [NSNumber numberWithUnsignedInt:maximumStreamCount];
+ picker.active = YES;
+ }
+ }
+
+ ~SckPickerHandle() {
+ RTC_DCHECK_RUN_ON(&checker_);
+ if (--sHandleCount > 0) {
+ return;
+ }
+ GetPicker().active = NO;
+ }
+
+ SCContentSharingPicker* GetPicker() const override {
+ return SCContentSharingPicker.sharedPicker;
+ }
+
+ DesktopCapturer::SourceId Source() const override {
+ return source_;
+ }
+
+ static bool AtCapacity() { return sHandleCount == maximumStreamCount; }
+
+ private:
+ // 100 is an arbitrary number that seems high enough to never get reached, while still providing
+ // a reasonably low upper bound.
+ static constexpr size_t maximumStreamCount = 100;
+ static size_t sHandleCount;
+ SequenceChecker checker_;
+ const DesktopCapturer::SourceId source_;
+};
+
+size_t SckPickerHandle::sHandleCount = 0;
+
+std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() API_AVAILABLE(macos(14.0)) {
+ if (SckPickerHandle::AtCapacity()) {
+ return nullptr;
+ }
+ static DesktopCapturer::SourceId unique_source_id = 0;
+ return std::make_unique<SckPickerHandle>(++unique_source_id);
+}
+
+} // namespace webrtc
\ No newline at end of file
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.h b/modules/desktop_capture/mac/screen_capturer_sck.h
index 105cbf0783..eb3a370eed 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.h
+++ b/modules/desktop_capture/mac/screen_capturer_sck.h
@@ -21,10 +21,17 @@ namespace webrtc {
// Returns true if the ScreenCaptureKit capturer is available.
bool ScreenCapturerSckAvailable();
+// Returns true if the ScreenCaptureKit capturer is available using SCContentSharingPicker
+// for picking a generic source.
+bool GenericCapturerSckWithPickerAvailable();
+
// A DesktopCapturer implementation that uses ScreenCaptureKit.
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(
const DesktopCaptureOptions& options);
+std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(
+ const DesktopCaptureOptions& options);
+
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_SCK_H_
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index af1a4e360b..b92399e6b6 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -20,11 +20,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/time_utils.h"
+#include "sck_picker_handle.h"
#include "sdk/objc/helpers/scoped_cftyperef.h"
using webrtc::DesktopFrameIOSurface;
#define SCK_AVAILABLE @available(macOS 14.0, *)
+#define SCCSPICKER_AVAILABLE @available(macOS 15.0, *)
namespace webrtc {
class ScreenCapturerSck;
@@ -35,7 +37,7 @@ class ScreenCapturerSck;
// Also, the `SCContentFilter` fields `contentRect` and `pointPixelScale` were introduced in
// macOS 14.
API_AVAILABLE(macos(14.0))
-@interface SckHelper : NSObject <SCStreamDelegate, SCStreamOutput>
+@interface SckHelper : NSObject <SCStreamDelegate, SCStreamOutput, SCContentSharingPickerObserver>
- (instancetype)initWithCapturer:(webrtc::ScreenCapturerSck*)capturer;
@@ -58,10 +60,18 @@ bool ScreenCapturerSckAvailable() {
return sonomaOrHigher;
}
+bool GenericCapturerSckWithPickerAvailable() {
+ bool available = false;
+ if (SCCSPICKER_AVAILABLE) {
+ available = true;
+ }
+ return available;
+}
+
class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapturer {
public:
explicit ScreenCapturerSck(const DesktopCaptureOptions& options);
-
+ ScreenCapturerSck(const DesktopCaptureOptions& options, SCContentSharingPickerMode modes);
ScreenCapturerSck(const ScreenCapturerSck&) = delete;
ScreenCapturerSck& operator=(const ScreenCapturerSck&) = delete;
@@ -71,12 +81,27 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
void Start(DesktopCapturer::Callback* callback) override;
void SetMaxFrameRate(uint32_t max_frame_rate) override;
void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
bool SelectSource(SourceId id) override;
+ // Prep for implementing DelegatedSourceListController interface, for now used by Start().
+ // Triggers SCContentSharingPicker. Runs on the caller's thread.
+ void EnsureVisible();
+ // Helper functions to forward SCContentSharingPickerObserver notifications to
+ // source_list_observer_.
+ void NotifySourceSelection(SCContentFilter* filter, SCStream* stream);
+ void NotifySourceCancelled(SCStream* stream);
+ void NotifySourceError();
+
+ // Called after a SCStreamDelegate stop notification.
+ void NotifyCaptureStopped(SCStream* stream);
// Called by SckHelper when shareable content is returned by ScreenCaptureKit. `content` will be
// nil if an error occurred. May run on an arbitrary thread.
void OnShareableContentCreated(SCShareableContent* content);
+ // Start capture with the given filter. Creates or updates stream_ as needed.
+ void StartWithFilter(SCContentFilter* filter) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
+
// Called by SckHelper to notify of a newly captured frame. May run on an arbitrary thread.
void OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment);
@@ -96,9 +121,20 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// thread.
Callback* callback_ = nullptr;
+ // Helper class that tracks the number of capturers needing SCContentSharingPicker to stay active.
+ // Only used on the caller's thread.
+ std::unique_ptr<SckPickerHandleInterface> picker_handle_;
+
+ // Flag to track if we have added ourselves as observer to picker_handle_.
+ // Only used on the caller's thread.
+ bool picker_handle_registered_ = false;
+
// Options passed to the constructor. May be accessed on any thread, but the options are
// unchanged during the capturer's lifetime.
- DesktopCaptureOptions capture_options_;
+ const DesktopCaptureOptions capture_options_;
+
+ // Modes to use iff using the system picker. See docs on SCContentSharingPickerMode.
+ const SCContentSharingPickerMode picker_modes_;
// Signals that a permanent error occurred. This may be set on any thread, and is read by
// CaptureFrame() which runs on the caller's thread.
@@ -110,6 +146,9 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// Provides captured desktop frames.
SCStream* __strong stream_ RTC_GUARDED_BY(lock_);
+ // Current filter on stream_.
+ SCContentFilter* __strong filter_ RTC_GUARDED_BY(lock_);
+
// Currently selected display, or 0 if the full desktop is selected. This capturer does not
// support full-desktop capture, and will fall back to the first display.
CGDirectDisplayID current_display_ RTC_GUARDED_BY(lock_) = 0;
@@ -118,7 +157,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// caller's thread.
MacDesktopConfiguration desktop_config_;
- Mutex latest_frame_lock_;
+ Mutex latest_frame_lock_ RTC_ACQUIRED_AFTER(lock_);
std::unique_ptr<SharedDesktopFrame> latest_frame_ RTC_GUARDED_BY(latest_frame_lock_);
int32_t latest_frame_dpi_ RTC_GUARDED_BY(latest_frame_lock_) = kStandardDPI;
@@ -133,18 +172,50 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
};
ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options)
- : capture_options_(options) {
+ : ScreenCapturerSck(options, SCContentSharingPickerModeSingleDisplay) {}
+
+ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options, SCContentSharingPickerMode modes)
+ : capture_options_(options),
+ picker_modes_(modes) {
+ picker_handle_ = CreateSckPickerHandle();
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " created. allow_sck_system_picker="
+ << capture_options_.allow_sck_system_picker() << ", source="
+ << (picker_handle_ ? picker_handle_->Source() : -1) << ", mode=" << ([&modes] {
+ std::stringstream ss;
+ bool empty = true;
+ auto maybeAppend = [&](auto mode, auto* str) {
+ if (modes & mode) {
+ if (!empty) {
+ ss << "|";
+ }
+ empty = false;
+ ss << str;
+ }
+ };
+ maybeAppend(SCContentSharingPickerModeSingleWindow, "SingleWindow");
+ maybeAppend(SCContentSharingPickerModeMultipleWindows, "MultiWindow");
+ maybeAppend(SCContentSharingPickerModeSingleApplication, "SingleApp");
+ maybeAppend(SCContentSharingPickerModeMultipleApplications, "MultiApp");
+ maybeAppend(SCContentSharingPickerModeSingleDisplay, "SingleDisplay");
+ return ss.str();
+ })();
helper_ = [[SckHelper alloc] initWithCapturer:this];
}
ScreenCapturerSck::~ScreenCapturerSck() {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " destroyed.";
[stream_ stopCaptureWithCompletionHandler:nil];
[helper_ releaseCapturer];
}
void ScreenCapturerSck::Start(DesktopCapturer::Callback* callback) {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
callback_ = callback;
desktop_config_ = capture_options_.configuration_monitor()->desktop_configuration();
+ if (capture_options_.allow_sck_system_picker()) {
+ EnsureVisible();
+ return;
+ }
StartOrReconfigureCapturer();
}
@@ -156,6 +227,7 @@ void ScreenCapturerSck::CaptureFrame() {
int64_t capture_start_time_millis = rtc::TimeMillis();
if (permanent_error_) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_PERMANENT";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@@ -181,14 +253,120 @@ void ScreenCapturerSck::CaptureFrame() {
}
if (frame) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> SUCCESS";
frame->set_capture_time_ms(rtc::TimeSince(capture_start_time_millis));
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
} else {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_TEMPORARY";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
}
}
+void ScreenCapturerSck::EnsureVisible() {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ if (picker_handle_) {
+ if (!picker_handle_registered_) {
+ picker_handle_registered_ = true;
+ [picker_handle_->GetPicker() addObserver:helper_];
+ }
+ } else {
+ // We reached the maximum number of streams.
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this
+ << " EnsureVisible() reached the maximum number of streams.";
+ permanent_error_ = true;
+ return;
+ }
+ SCContentSharingPicker* picker = picker_handle_->GetPicker();
+ SCStream* stream;
+ {
+ MutexLock lock(&lock_);
+ stream = stream_;
+ stream_ = nil;
+ filter_ = nil;
+ }
+ [stream removeStreamOutput:helper_ type:SCStreamOutputTypeScreen error:nil];
+ [stream stopCaptureWithCompletionHandler:nil];
+ SCContentSharingPickerConfiguration* config = picker.defaultConfiguration;
+ config.allowedPickerModes = picker_modes_;
+ picker.defaultConfiguration = config;
+ // Pick a sensible style to start out with, based on our current mode.
+ // Default to Screen because if using Window the picker automatically hides
+ // our current window to show others.
+ SCShareableContentStyle style = SCShareableContentStyleDisplay;
+ if (picker_modes_ == SCContentSharingPickerModeSingleDisplay) {
+ style = SCShareableContentStyleDisplay;
+ } else if (picker_modes_ == SCContentSharingPickerModeSingleWindow ||
+ picker_modes_ == SCContentSharingPickerModeMultipleWindows) {
+ style = SCShareableContentStyleWindow;
+ } else if (picker_modes_ == SCContentSharingPickerModeSingleApplication ||
+ picker_modes_ == SCContentSharingPickerModeMultipleApplications) {
+ style = SCShareableContentStyleApplication;
+ }
+ // This dies silently if maximumStreamCount is already running. We need our
+ // own stream count bookkeeping because of this, and to be able to unset `active`.
+ [picker presentPickerForStream:stream usingContentStyle:style];
+}
+
+void ScreenCapturerSck::NotifySourceSelection(SCContentFilter* filter, SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ // The picker selected a source for another capturer.
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ". stream_ != stream.";
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ". Starting.";
+ StartWithFilter(filter);
+}
+
+void ScreenCapturerSck::NotifySourceCancelled(SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ // The picker was cancelled for another capturer.
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ if (!stream_) {
+ // The initial picker was cancelled. There is no stream to fall back to.
+ permanent_error_ = true;
+ }
+}
+
+void ScreenCapturerSck::NotifySourceError() {
+ {
+ MutexLock lock(&lock_);
+ if (stream_) {
+ // The picker failed to start. But fear not, it was not our picker,
+ // we already have a stream!
+ return;
+ }
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ permanent_error_ = true;
+}
+
+void ScreenCapturerSck::NotifyCaptureStopped(SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ permanent_error_ = true;
+}
+
+bool ScreenCapturerSck::GetSourceList(SourceList* sources) {
+ sources->clear();
+ if (capture_options_.allow_sck_system_picker() && picker_handle_) {
+ sources->push_back({picker_handle_->Source()});
+ }
+ return true;
+}
+
bool ScreenCapturerSck::SelectSource(SourceId id) {
+ if (capture_options_.allow_sck_system_picker()) {
+ return true;
+ }
+
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " SelectSource(id=" << id << ").";
bool stream_started = false;
{
MutexLock lock(&lock_);
@@ -209,20 +387,23 @@ bool ScreenCapturerSck::SelectSource(SourceId id) {
void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
if (!content) {
- RTC_LOG(LS_ERROR) << "getShareableContent failed.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " getShareableContent failed.";
permanent_error_ = true;
return;
}
if (!content.displays.count) {
- RTC_LOG(LS_ERROR) << "getShareableContent returned no displays.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this
+ << " getShareableContent returned no displays.";
permanent_error_ = true;
return;
}
+ MutexLock lock(&lock_);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__
+ << ". current_display_=" << current_display_;
SCDisplay* captured_display;
{
- MutexLock lock(&lock_);
for (SCDisplay* display in content.displays) {
if (current_display_ == display.displayID) {
captured_display = display;
@@ -232,9 +413,10 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
if (!captured_display) {
if (current_display_ == static_cast<CGDirectDisplayID>(kFullDesktopScreenId)) {
RTC_LOG(LS_WARNING)
- << "Full screen capture is not supported, falling back to first display.";
+ << "ScreenCapturerSck " << this
+ << " Full screen capture is not supported, falling back to first display.";
} else {
- RTC_LOG(LS_WARNING) << "Display " << current_display_
+ RTC_LOG(LS_WARNING) << "ScreenCapturerSck " << this << " Display " << current_display_
<< " not found, falling back to first display.";
}
captured_display = content.displays.firstObject;
@@ -243,26 +425,30 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:captured_display
excludingWindows:@[]];
+ StartWithFilter(filter);
+}
+
+void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
+ lock_.AssertHeld();
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
config.pixelFormat = kCVPixelFormatType_32BGRA;
config.colorSpaceName = kCGColorSpaceSRGB;
config.showsCursor = capture_options_.prefer_cursor_embedded();
- config.width = filter.contentRect.size.width * filter.pointPixelScale;
- config.height = filter.contentRect.size.height * filter.pointPixelScale;
- config.captureResolution = SCCaptureResolutionNominal;
+ config.captureResolution = SCCaptureResolutionAutomatic;
{
MutexLock lock(&latest_frame_lock_);
latest_frame_dpi_ = filter.pointPixelScale * kStandardDPI;
}
- MutexLock lock(&lock_);
+ filter_ = filter;
if (stream_) {
- RTC_LOG(LS_INFO) << "Updating stream configuration.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration.";
[stream_ updateContentFilter:filter completionHandler:nil];
[stream_ updateConfiguration:config completionHandler:nil];
} else {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Creating new stream.";
stream_ = [[SCStream alloc] initWithFilter:filter configuration:config delegate:helper_];
// TODO: crbug.com/327458809 - Choose an appropriate sampleHandlerQueue for best performance.
@@ -273,7 +459,8 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
error:&add_stream_output_error];
if (!add_stream_output_result) {
stream_ = nil;
- RTC_LOG(LS_ERROR) << "addStreamOutput failed.";
+ filter_ = nil;
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " addStreamOutput failed.";
permanent_error_ = true;
return;
}
@@ -283,9 +470,9 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
// It should be safe to access `this` here, because the C++ destructor calls
// stopCaptureWithCompletionHandler on the stream, which cancels this handler.
permanent_error_ = true;
- RTC_LOG(LS_ERROR) << "startCaptureWithCompletionHandler failed.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " Starting failed.";
} else {
- RTC_LOG(LS_INFO) << "Capture started.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Capture started.";
}
};
@@ -294,6 +481,9 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
}
void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
+ << " width=" << IOSurfaceGetWidth(io_surface)
+ << ", height=" << IOSurfaceGetHeight(io_surface) << ".";
rtc::ScopedCFTypeRef<IOSurfaceRef> scoped_io_surface(io_surface, rtc::RetainPolicy::RETAIN);
std::unique_ptr<DesktopFrameIOSurface> desktop_frame_io_surface =
DesktopFrameIOSurface::Wrap(scoped_io_surface);
@@ -352,6 +542,15 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef
}
void ScreenCapturerSck::StartOrReconfigureCapturer() {
+ if (capture_options_.allow_sck_system_picker()) {
+ MutexLock lock(&lock_);
+ if (filter_) {
+ StartWithFilter(filter_);
+ }
+ return;
+ }
+
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
// The copy is needed to avoid capturing `this` in the Objective-C block. Accessing `helper_`
// inside the block is equivalent to `this->helper_` and would crash (UAF) if `this` is
// deleted before the block is executed.
@@ -370,6 +569,17 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
return nullptr;
}
+std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOptions& options) {
+ if (SCCSPICKER_AVAILABLE) {
+ if (options.allow_sck_system_picker()) {
+ return std::make_unique<ScreenCapturerSck>(
+ options,
+ SCContentSharingPickerModeSingleDisplay | SCContentSharingPickerModeMultipleWindows);
+ }
+ }
+ return nullptr;
+}
+
} // namespace webrtc
@implementation SckHelper {
@@ -394,6 +604,50 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
}
}
+- (void)stream:(SCStream*)stream didStopWithError:(NSError*)error {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifyCaptureStopped(stream);
+ }
+}
+
+- (void)userDidStopStream:(SCStream*)stream NS_SWIFT_NAME(userDidStopStream(_:))
+ API_AVAILABLE(macos(14.4)) {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifyCaptureStopped(stream);
+ }
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker*)picker
+ didUpdateWithFilter:(SCContentFilter*)filter
+ forStream:(SCStream*)stream {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifySourceSelection(filter, stream);
+ }
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker*)picker didCancelForStream:(SCStream*)stream {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifySourceCancelled(stream);
+ }
+}
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError*)error {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__
+ << ". error.code=" << error.code;
+ if (_capturer) {
+ _capturer->NotifySourceError();
+ }
+}
+
- (void)stream:(SCStream*)stream
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
ofType:(SCStreamOutputType)type {
@@ -425,6 +679,7 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
- (void)releaseCapturer {
webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
_capturer = nullptr;
}

View File

@ -1,753 +1,81 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 21:04:00 +0000
Subject: Bug 1918096 - Integrate SCContentSharingPicker into
ScreenCapturerSck. r=webrtc-reviewers,padenot,dbaker
Date: Thu, 12 Sep 2024 22:36:00 +0000
Subject: Bug 1918096 - In ScreenCapturerSck improve dictionary ergonomics.
r=webrtc-reviewers,ng
This works by creating ScreenCapturerSck with a sck_allow_system_picker
DesktopCaptureOptions flag.
The flow is similar to the Pipewire capturer in that SelectSource has no effect.
Start() brings up the system picker, and:
- automatically starts capture on selection, also reconfigures on future
selection changes.
- signals a stop by setting the permanent error flag on cancel or error.
The system picker is configured for both single display and multiple windows to
give users as much power over what they share as possible. There is an
application mode also, but other browsers are not allowing access to that as of
now.
Differential Revision: https://phabricator.services.mozilla.com/D221851
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/86a5d2db126efcee95a63e3079cda88747049197
Differential Revision: https://phabricator.services.mozilla.com/D221940
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/aabf0bd94f282ae97a010016058446e45fc781c8
---
modules/desktop_capture/BUILD.gn | 2 +
.../desktop_capture/desktop_capture_options.h | 9 +
modules/desktop_capture/desktop_capturer.cc | 8 +-
.../desktop_capture/mac/sck_picker_handle.h | 49 +++
.../desktop_capture/mac/sck_picker_handle.mm | 68 ++++
.../desktop_capture/mac/screen_capturer_sck.h | 7 +
.../mac/screen_capturer_sck.mm | 291 ++++++++++++++++--
7 files changed, 415 insertions(+), 19 deletions(-)
create mode 100644 modules/desktop_capture/mac/sck_picker_handle.h
create mode 100644 modules/desktop_capture/mac/sck_picker_handle.mm
.../mac/screen_capturer_sck.mm | 25 ++++++++-----------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 94741d8fc7..3940323d7e 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -600,6 +600,8 @@ if (is_mac) {
"mac/desktop_frame_iosurface.mm",
"mac/desktop_frame_provider.h",
"mac/desktop_frame_provider.mm",
+ "mac/sck_picker_handle.h",
+ "mac/sck_picker_handle.mm",
"mac/screen_capturer_mac.h",
"mac/screen_capturer_mac.mm",
"mac/screen_capturer_sck.h",
diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h
index c44ec6a9e8..51785a4085 100644
--- a/modules/desktop_capture/desktop_capture_options.h
+++ b/modules/desktop_capture/desktop_capture_options.h
@@ -79,6 +79,14 @@ class RTC_EXPORT DesktopCaptureOptions {
// new versions of macOS that remove support for the CGDisplay-based APIs.
bool allow_sck_capturer() const { return allow_sck_capturer_; }
void set_allow_sck_capturer(bool allow) { allow_sck_capturer_ = allow; }
+
+ // If ScreenCaptureKit is used for desktop capture and this flag is
+ // set, the ScreenCaptureKit backend will use SCContentSharingPicker for
+ // picking source.
+ bool allow_sck_system_picker() const { return allow_sck_system_picker_; }
+ void set_allow_sck_system_picker(bool allow) {
+ allow_sck_system_picker_ = allow;
+ }
#endif
const rtc::scoped_refptr<FullScreenWindowDetector>&
@@ -243,6 +251,7 @@ class RTC_EXPORT DesktopCaptureOptions {
rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
bool allow_iosurface_ = false;
bool allow_sck_capturer_ = false;
+ bool allow_sck_system_picker_ = false;
#endif
rtc::scoped_refptr<FullScreenWindowDetector> full_screen_window_detector_;
diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc
index a52a76c262..02f11b3867 100644
--- a/modules/desktop_capture/desktop_capturer.cc
+++ b/modules/desktop_capture/desktop_capturer.cc
@@ -30,6 +30,10 @@
#include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
#endif
+#if defined(WEBRTC_MAC)
+#include "modules/desktop_capture/mac/screen_capturer_sck.h"
+#endif
+
namespace webrtc {
void LogDesktopCapturerFullscreenDetectorUsage() {
@@ -117,11 +121,13 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateGenericCapturer(
capturer = std::make_unique<BaseCapturerPipeWire>(
options, CaptureType::kAnyScreenContent);
}
+#elif defined(WEBRTC_MAC)
+ capturer = CreateGenericCapturerSck(options);
+#endif
if (capturer && options.detect_updated_region()) {
capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
}
-#endif // defined(WEBRTC_USE_PIPEWIRE)
return capturer;
}
diff --git a/modules/desktop_capture/mac/sck_picker_handle.h b/modules/desktop_capture/mac/sck_picker_handle.h
new file mode 100644
index 0000000000..c2279733b6
--- /dev/null
+++ b/modules/desktop_capture/mac/sck_picker_handle.h
@@ -0,0 +1,49 @@
+/*
+ * 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 MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
+#define MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
+
+#include <os/availability.h>
+#include <cstddef>
+#include <memory>
+#include "modules/desktop_capture/desktop_capturer.h"
+
+@class SCContentSharingPicker;
+@class SCStream;
+
+namespace webrtc {
+
+// Helper class to manage multiple users of SCContentSharingPicker.
+//
+// The `active` and `maximumStreamCount` properties are automatically managed on
+// `SCContentSharingPicker.sharedPicker`, which is what is returned from
+// GetPicker().
+//
+// When using this class, for stream limits to work, only create one stream per
+// handle.
+//
+// Designed for single thread use.
+class API_AVAILABLE(macos(14.0)) SckPickerHandleInterface {
+ public:
+ virtual ~SckPickerHandleInterface() = default;
+ // Effectively identical to `SCContentSharingPicker.sharedPicker`.
+ virtual SCContentSharingPicker* GetPicker() const = 0;
+ // A SourceId unique to this handle.
+ virtual DesktopCapturer::SourceId Source() const = 0;
+};
+
+// Returns a newly created picker handle if the stream count limit has not been
+// reached, null otherwise.
+std::unique_ptr<SckPickerHandleInterface> API_AVAILABLE(macos(14.0)) CreateSckPickerHandle();
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_MAC_SCK_PICKER_HANDLE_H_
diff --git a/modules/desktop_capture/mac/sck_picker_handle.mm b/modules/desktop_capture/mac/sck_picker_handle.mm
new file mode 100644
index 0000000000..25e98b671f
--- /dev/null
+++ b/modules/desktop_capture/mac/sck_picker_handle.mm
@@ -0,0 +1,68 @@
+/*
+ * 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 "sck_picker_handle.h"
+
+#import <ScreenCaptureKit/ScreenCaptureKit.h>
+
+#include "api/sequence_checker.h"
+
+namespace webrtc {
+
+class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+ public:
+ explicit SckPickerHandle(DesktopCapturer::SourceId source) : source_(source) {
+ RTC_DCHECK_RUN_ON(&checker_);
+ RTC_CHECK_LE(sHandleCount, maximumStreamCount);
+ if (sHandleCount++ == 0) {
+ auto* picker = GetPicker();
+ picker.maximumStreamCount = [NSNumber numberWithUnsignedInt:maximumStreamCount];
+ picker.active = YES;
+ }
+ }
+
+ ~SckPickerHandle() {
+ RTC_DCHECK_RUN_ON(&checker_);
+ if (--sHandleCount > 0) {
+ return;
+ }
+ GetPicker().active = NO;
+ }
+
+ SCContentSharingPicker* GetPicker() const override {
+ return SCContentSharingPicker.sharedPicker;
+ }
+
+ DesktopCapturer::SourceId Source() const override {
+ return source_;
+ }
+
+ static bool AtCapacity() { return sHandleCount == maximumStreamCount; }
+
+ private:
+ // 100 is an arbitrary number that seems high enough to never get reached, while still providing
+ // a reasonably low upper bound.
+ static constexpr size_t maximumStreamCount = 100;
+ static size_t sHandleCount;
+ SequenceChecker checker_;
+ const DesktopCapturer::SourceId source_;
+};
+
+size_t SckPickerHandle::sHandleCount = 0;
+
+std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() API_AVAILABLE(macos(14.0)) {
+ if (SckPickerHandle::AtCapacity()) {
+ return nullptr;
+ }
+ static DesktopCapturer::SourceId unique_source_id = 0;
+ return std::make_unique<SckPickerHandle>(++unique_source_id);
+}
+
+} // namespace webrtc
\ No newline at end of file
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.h b/modules/desktop_capture/mac/screen_capturer_sck.h
index 105cbf0783..eb3a370eed 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.h
+++ b/modules/desktop_capture/mac/screen_capturer_sck.h
@@ -21,10 +21,17 @@ namespace webrtc {
// Returns true if the ScreenCaptureKit capturer is available.
bool ScreenCapturerSckAvailable();
+// Returns true if the ScreenCaptureKit capturer is available using SCContentSharingPicker
+// for picking a generic source.
+bool GenericCapturerSckWithPickerAvailable();
+
// A DesktopCapturer implementation that uses ScreenCaptureKit.
std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(
const DesktopCaptureOptions& options);
+std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(
+ const DesktopCaptureOptions& options);
+
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_SCK_H_
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index af1a4e360b..b92399e6b6 100644
index b92399e6b6..96d54c5c03 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -20,11 +20,13 @@
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/time_utils.h"
+#include "sck_picker_handle.h"
#include "sdk/objc/helpers/scoped_cftyperef.h"
@@ -103,7 +103,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
void StartWithFilter(SCContentFilter* filter) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
using webrtc::DesktopFrameIOSurface;
#define SCK_AVAILABLE @available(macOS 14.0, *)
+#define SCCSPICKER_AVAILABLE @available(macOS 15.0, *)
namespace webrtc {
class ScreenCapturerSck;
@@ -35,7 +37,7 @@ class ScreenCapturerSck;
// Also, the `SCContentFilter` fields `contentRect` and `pointPixelScale` were introduced in
// macOS 14.
API_AVAILABLE(macos(14.0))
-@interface SckHelper : NSObject <SCStreamDelegate, SCStreamOutput>
+@interface SckHelper : NSObject <SCStreamDelegate, SCStreamOutput, SCContentSharingPickerObserver>
- (instancetype)initWithCapturer:(webrtc::ScreenCapturerSck*)capturer;
@@ -58,10 +60,18 @@ bool ScreenCapturerSckAvailable() {
return sonomaOrHigher;
}
+bool GenericCapturerSckWithPickerAvailable() {
+ bool available = false;
+ if (SCCSPICKER_AVAILABLE) {
+ available = true;
+ }
+ return available;
+}
+
class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapturer {
public:
explicit ScreenCapturerSck(const DesktopCaptureOptions& options);
-
+ ScreenCapturerSck(const DesktopCaptureOptions& options, SCContentSharingPickerMode modes);
ScreenCapturerSck(const ScreenCapturerSck&) = delete;
ScreenCapturerSck& operator=(const ScreenCapturerSck&) = delete;
@@ -71,12 +81,27 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
void Start(DesktopCapturer::Callback* callback) override;
void SetMaxFrameRate(uint32_t max_frame_rate) override;
void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
bool SelectSource(SourceId id) override;
+ // Prep for implementing DelegatedSourceListController interface, for now used by Start().
+ // Triggers SCContentSharingPicker. Runs on the caller's thread.
+ void EnsureVisible();
+ // Helper functions to forward SCContentSharingPickerObserver notifications to
+ // source_list_observer_.
+ void NotifySourceSelection(SCContentFilter* filter, SCStream* stream);
+ void NotifySourceCancelled(SCStream* stream);
+ void NotifySourceError();
+
+ // Called after a SCStreamDelegate stop notification.
+ void NotifyCaptureStopped(SCStream* stream);
// Called by SckHelper when shareable content is returned by ScreenCaptureKit. `content` will be
// nil if an error occurred. May run on an arbitrary thread.
void OnShareableContentCreated(SCShareableContent* content);
+ // Start capture with the given filter. Creates or updates stream_ as needed.
+ void StartWithFilter(SCContentFilter* filter) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
+
// Called by SckHelper to notify of a newly captured frame. May run on an arbitrary thread.
void OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment);
- void OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment);
+ void OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment);
@@ -96,9 +121,20 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// thread.
Callback* callback_ = nullptr;
+ // Helper class that tracks the number of capturers needing SCContentSharingPicker to stay active.
+ // Only used on the caller's thread.
+ std::unique_ptr<SckPickerHandleInterface> picker_handle_;
+
+ // Flag to track if we have added ourselves as observer to picker_handle_.
+ // Only used on the caller's thread.
+ bool picker_handle_registered_ = false;
+
// Options passed to the constructor. May be accessed on any thread, but the options are
// unchanged during the capturer's lifetime.
- DesktopCaptureOptions capture_options_;
+ const DesktopCaptureOptions capture_options_;
+
+ // Modes to use iff using the system picker. See docs on SCContentSharingPickerMode.
+ const SCContentSharingPickerMode picker_modes_;
// Signals that a permanent error occurred. This may be set on any thread, and is read by
// CaptureFrame() which runs on the caller's thread.
@@ -110,6 +146,9 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// Provides captured desktop frames.
SCStream* __strong stream_ RTC_GUARDED_BY(lock_);
+ // Current filter on stream_.
+ SCContentFilter* __strong filter_ RTC_GUARDED_BY(lock_);
+
// Currently selected display, or 0 if the full desktop is selected. This capturer does not
// support full-desktop capture, and will fall back to the first display.
CGDirectDisplayID current_display_ RTC_GUARDED_BY(lock_) = 0;
@@ -118,7 +157,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// caller's thread.
MacDesktopConfiguration desktop_config_;
- Mutex latest_frame_lock_;
+ Mutex latest_frame_lock_ RTC_ACQUIRED_AFTER(lock_);
std::unique_ptr<SharedDesktopFrame> latest_frame_ RTC_GUARDED_BY(latest_frame_lock_);
int32_t latest_frame_dpi_ RTC_GUARDED_BY(latest_frame_lock_) = kStandardDPI;
@@ -133,18 +172,50 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
};
ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options)
- : capture_options_(options) {
+ : ScreenCapturerSck(options, SCContentSharingPickerModeSingleDisplay) {}
+
+ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options, SCContentSharingPickerMode modes)
+ : capture_options_(options),
+ picker_modes_(modes) {
+ picker_handle_ = CreateSckPickerHandle();
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " created. allow_sck_system_picker="
+ << capture_options_.allow_sck_system_picker() << ", source="
+ << (picker_handle_ ? picker_handle_->Source() : -1) << ", mode=" << ([&modes] {
+ std::stringstream ss;
+ bool empty = true;
+ auto maybeAppend = [&](auto mode, auto* str) {
+ if (modes & mode) {
+ if (!empty) {
+ ss << "|";
+ }
+ empty = false;
+ ss << str;
+ }
+ };
+ maybeAppend(SCContentSharingPickerModeSingleWindow, "SingleWindow");
+ maybeAppend(SCContentSharingPickerModeMultipleWindows, "MultiWindow");
+ maybeAppend(SCContentSharingPickerModeSingleApplication, "SingleApp");
+ maybeAppend(SCContentSharingPickerModeMultipleApplications, "MultiApp");
+ maybeAppend(SCContentSharingPickerModeSingleDisplay, "SingleDisplay");
+ return ss.str();
+ })();
helper_ = [[SckHelper alloc] initWithCapturer:this];
}
ScreenCapturerSck::~ScreenCapturerSck() {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " destroyed.";
[stream_ stopCaptureWithCompletionHandler:nil];
[helper_ releaseCapturer];
}
void ScreenCapturerSck::Start(DesktopCapturer::Callback* callback) {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
callback_ = callback;
desktop_config_ = capture_options_.configuration_monitor()->desktop_configuration();
+ if (capture_options_.allow_sck_system_picker()) {
+ EnsureVisible();
+ return;
+ }
StartOrReconfigureCapturer();
}
@@ -156,6 +227,7 @@ void ScreenCapturerSck::CaptureFrame() {
int64_t capture_start_time_millis = rtc::TimeMillis();
if (permanent_error_) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_PERMANENT";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@@ -181,14 +253,120 @@ void ScreenCapturerSck::CaptureFrame() {
}
if (frame) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> SUCCESS";
frame->set_capture_time_ms(rtc::TimeSince(capture_start_time_millis));
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
} else {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_TEMPORARY";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
private:
// Called when starting the capturer or the configuration has changed (either from a
@@ -480,10 +480,13 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
}
}
+void ScreenCapturerSck::EnsureVisible() {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ if (picker_handle_) {
+ if (!picker_handle_registered_) {
+ picker_handle_registered_ = true;
+ [picker_handle_->GetPicker() addObserver:helper_];
+ }
+ } else {
+ // We reached the maximum number of streams.
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this
+ << " EnsureVisible() reached the maximum number of streams.";
+ permanent_error_ = true;
+ return;
+ }
+ SCContentSharingPicker* picker = picker_handle_->GetPicker();
+ SCStream* stream;
+ {
+ MutexLock lock(&lock_);
+ stream = stream_;
+ stream_ = nil;
+ filter_ = nil;
+ }
+ [stream removeStreamOutput:helper_ type:SCStreamOutputTypeScreen error:nil];
+ [stream stopCaptureWithCompletionHandler:nil];
+ SCContentSharingPickerConfiguration* config = picker.defaultConfiguration;
+ config.allowedPickerModes = picker_modes_;
+ picker.defaultConfiguration = config;
+ // Pick a sensible style to start out with, based on our current mode.
+ // Default to Screen because if using Window the picker automatically hides
+ // our current window to show others.
+ SCShareableContentStyle style = SCShareableContentStyleDisplay;
+ if (picker_modes_ == SCContentSharingPickerModeSingleDisplay) {
+ style = SCShareableContentStyleDisplay;
+ } else if (picker_modes_ == SCContentSharingPickerModeSingleWindow ||
+ picker_modes_ == SCContentSharingPickerModeMultipleWindows) {
+ style = SCShareableContentStyleWindow;
+ } else if (picker_modes_ == SCContentSharingPickerModeSingleApplication ||
+ picker_modes_ == SCContentSharingPickerModeMultipleApplications) {
+ style = SCShareableContentStyleApplication;
+ }
+ // This dies silently if maximumStreamCount is already running. We need our
+ // own stream count bookkeeping because of this, and to be able to unset `active`.
+ [picker presentPickerForStream:stream usingContentStyle:style];
+}
-void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment) {
+void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment) {
RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
<< " width=" << IOSurfaceGetWidth(io_surface)
<< ", height=" << IOSurfaceGetHeight(io_surface) << ".";
+
+void ScreenCapturerSck::NotifySourceSelection(SCContentFilter* filter, SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ // The picker selected a source for another capturer.
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ". stream_ != stream.";
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ". Starting.";
+ StartWithFilter(filter);
+}
+ const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
+
+void ScreenCapturerSck::NotifySourceCancelled(SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ // The picker was cancelled for another capturer.
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ if (!stream_) {
+ // The initial picker was cancelled. There is no stream to fall back to.
+ permanent_error_ = true;
+ }
+}
+
+void ScreenCapturerSck::NotifySourceError() {
+ {
+ MutexLock lock(&lock_);
+ if (stream_) {
+ // The picker failed to start. But fear not, it was not our picker,
+ // we already have a stream!
+ return;
+ }
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ permanent_error_ = true;
+}
+
+void ScreenCapturerSck::NotifyCaptureStopped(SCStream* stream) {
+ MutexLock lock(&lock_);
+ if (stream_ != stream) {
+ return;
+ }
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
+ permanent_error_ = true;
+}
+
+bool ScreenCapturerSck::GetSourceList(SourceList* sources) {
+ sources->clear();
+ if (capture_options_.allow_sck_system_picker() && picker_handle_) {
+ sources->push_back({picker_handle_->Source()});
+ }
+ return true;
+}
+
bool ScreenCapturerSck::SelectSource(SourceId id) {
+ if (capture_options_.allow_sck_system_picker()) {
+ return true;
+ }
+
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " SelectSource(id=" << id << ").";
bool stream_started = false;
{
MutexLock lock(&lock_);
@@ -209,20 +387,23 @@ bool ScreenCapturerSck::SelectSource(SourceId id) {
void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
if (!content) {
- RTC_LOG(LS_ERROR) << "getShareableContent failed.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " getShareableContent failed.";
permanent_error_ = true;
return;
}
if (!content.displays.count) {
- RTC_LOG(LS_ERROR) << "getShareableContent returned no displays.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this
+ << " getShareableContent returned no displays.";
permanent_error_ = true;
return;
}
+ MutexLock lock(&lock_);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__
+ << ". current_display_=" << current_display_;
SCDisplay* captured_display;
{
- MutexLock lock(&lock_);
for (SCDisplay* display in content.displays) {
if (current_display_ == display.displayID) {
captured_display = display;
@@ -232,9 +413,10 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
if (!captured_display) {
if (current_display_ == static_cast<CGDirectDisplayID>(kFullDesktopScreenId)) {
RTC_LOG(LS_WARNING)
- << "Full screen capture is not supported, falling back to first display.";
+ << "ScreenCapturerSck " << this
+ << " Full screen capture is not supported, falling back to first display.";
} else {
- RTC_LOG(LS_WARNING) << "Display " << current_display_
+ RTC_LOG(LS_WARNING) << "ScreenCapturerSck " << this << " Display " << current_display_
<< " not found, falling back to first display.";
}
captured_display = content.displays.firstObject;
@@ -243,26 +425,30 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:captured_display
excludingWindows:@[]];
+ StartWithFilter(filter);
+}
+
+void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
+ lock_.AssertHeld();
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
config.pixelFormat = kCVPixelFormatType_32BGRA;
config.colorSpaceName = kCGColorSpaceSRGB;
config.showsCursor = capture_options_.prefer_cursor_embedded();
- config.width = filter.contentRect.size.width * filter.pointPixelScale;
- config.height = filter.contentRect.size.height * filter.pointPixelScale;
- config.captureResolution = SCCaptureResolutionNominal;
+ config.captureResolution = SCCaptureResolutionAutomatic;
{
MutexLock lock(&latest_frame_lock_);
latest_frame_dpi_ = filter.pointPixelScale * kStandardDPI;
}
- MutexLock lock(&lock_);
+ filter_ = filter;
if (stream_) {
- RTC_LOG(LS_INFO) << "Updating stream configuration.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration.";
[stream_ updateContentFilter:filter completionHandler:nil];
[stream_ updateConfiguration:config completionHandler:nil];
} else {
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Creating new stream.";
stream_ = [[SCStream alloc] initWithFilter:filter configuration:config delegate:helper_];
// TODO: crbug.com/327458809 - Choose an appropriate sampleHandlerQueue for best performance.
@@ -273,7 +459,8 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
error:&add_stream_output_error];
if (!add_stream_output_result) {
stream_ = nil;
- RTC_LOG(LS_ERROR) << "addStreamOutput failed.";
+ filter_ = nil;
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " addStreamOutput failed.";
permanent_error_ = true;
return;
}
@@ -283,9 +470,9 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
// It should be safe to access `this` here, because the C++ destructor calls
// stopCaptureWithCompletionHandler on the stream, which cancels this handler.
permanent_error_ = true;
- RTC_LOG(LS_ERROR) << "startCaptureWithCompletionHandler failed.";
+ RTC_LOG(LS_ERROR) << "ScreenCapturerSck " << this << " Starting failed.";
} else {
- RTC_LOG(LS_INFO) << "Capture started.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Capture started.";
}
};
@@ -294,6 +481,9 @@ void ScreenCapturerSck::OnShareableContentCreated(SCShareableContent* content) {
}
void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment) {
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
+ << " width=" << IOSurfaceGetWidth(io_surface)
+ << ", height=" << IOSurfaceGetHeight(io_surface) << ".";
rtc::ScopedCFTypeRef<IOSurfaceRef> scoped_io_surface(io_surface, rtc::RetainPolicy::RETAIN);
std::unique_ptr<DesktopFrameIOSurface> desktop_frame_io_surface =
DesktopFrameIOSurface::Wrap(scoped_io_surface);
@@ -352,6 +542,15 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef
}
@@ -505,28 +508,20 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef
}
void ScreenCapturerSck::StartOrReconfigureCapturer() {
+ if (capture_options_.allow_sck_system_picker()) {
+ MutexLock lock(&lock_);
+ if (filter_) {
+ StartWithFilter(filter_);
+ }
+ return;
+ }
+
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " " << __func__ << ".";
// The copy is needed to avoid capturing `this` in the Objective-C block. Accessing `helper_`
// inside the block is equivalent to `this->helper_` and would crash (UAF) if `this` is
// deleted before the block is executed.
@@ -370,6 +569,17 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
return nullptr;
}
if (!dirty) {
- const void* dirty_rects_ptr =
- CFDictionaryGetValue(attachment, (__bridge CFStringRef)SCStreamFrameInfoDirtyRects);
- if (!dirty_rects_ptr) {
+ if (!dirty_rects) {
// This is never expected to happen - SCK attaches a non-empty dirty-rects list to every
// frame, even when nothing has changed.
return;
}
- if (CFGetTypeID(dirty_rects_ptr) != CFArrayGetTypeID()) {
- return;
- }
-
- CFArrayRef dirty_rects_array = static_cast<CFArrayRef>(dirty_rects_ptr);
- int size = CFArrayGetCount(dirty_rects_array);
- for (int i = 0; i < size; i++) {
- const void* rect_ptr = CFArrayGetValueAtIndex(dirty_rects_array, i);
+ for (NSUInteger i = 0; i < dirty_rects.count; i++) {
+ const auto* rect_ptr = (__bridge CFDictionaryRef)dirty_rects[i];
if (CFGetTypeID(rect_ptr) != CFDictionaryGetTypeID()) {
// This is never expected to happen - the dirty-rects attachment should always be an array
// of dictionaries.
return;
}
CGRect rect{};
- CGRectMakeWithDictionaryRepresentation(static_cast<CFDictionaryRef>(rect_ptr), &rect);
+ CGRectMakeWithDictionaryRepresentation(rect_ptr, &rect);
if (!CGRectIsEmpty(rect)) {
dirty = true;
break;
@@ -673,7 +668,7 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOp
+std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOptions& options) {
+ if (SCCSPICKER_AVAILABLE) {
+ if (options.allow_sck_system_picker()) {
+ return std::make_unique<ScreenCapturerSck>(
+ options,
+ SCContentSharingPickerModeSingleDisplay | SCContentSharingPickerModeMultipleWindows);
+ }
+ }
+ return nullptr;
+}
+
} // namespace webrtc
@implementation SckHelper {
@@ -394,6 +604,50 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
webrtc::MutexLock lock(&_capturer_lock);
if (_capturer) {
- _capturer->OnNewIOSurface(ioSurface, attachment);
+ _capturer->OnNewIOSurface(ioSurface, (__bridge NSDictionary*)attachment);
}
}
+- (void)stream:(SCStream*)stream didStopWithError:(NSError*)error {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifyCaptureStopped(stream);
+ }
+}
+
+- (void)userDidStopStream:(SCStream*)stream NS_SWIFT_NAME(userDidStopStream(_:))
+ API_AVAILABLE(macos(14.4)) {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifyCaptureStopped(stream);
+ }
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker*)picker
+ didUpdateWithFilter:(SCContentFilter*)filter
+ forStream:(SCStream*)stream {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifySourceSelection(filter, stream);
+ }
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker*)picker didCancelForStream:(SCStream*)stream {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
+ if (_capturer) {
+ _capturer->NotifySourceCancelled(stream);
+ }
+}
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError*)error {
+ webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__
+ << ". error.code=" << error.code;
+ if (_capturer) {
+ _capturer->NotifySourceError();
+ }
+}
+
- (void)stream:(SCStream*)stream
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
ofType:(SCStreamOutputType)type {
@@ -425,6 +679,7 @@ std::unique_ptr<DesktopCapturer> CreateScreenCapturerSck(const DesktopCaptureOpt
- (void)releaseCapturer {
webrtc::MutexLock lock(&_capturer_lock);
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << _capturer << " " << __func__ << ".";
_capturer = nullptr;
}

View File

@ -1,81 +1,277 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 22:36:00 +0000
Subject: Bug 1918096 - In ScreenCapturerSck improve dictionary ergonomics.
r=webrtc-reviewers,ng
Subject: Bug 1918096 - In ScreenCapturerSck adapt to sources that change
resolution. r=webrtc-reviewers,ng
Differential Revision: https://phabricator.services.mozilla.com/D221940
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/aabf0bd94f282ae97a010016058446e45fc781c8
If the resolution is smaller than the allocated surface, we crop.
If the resolution is larger than the allocated surface, we reconfigure with a
larger surface.
The allocated surface has the size we told it to have in the
SCStreamConfiguration, in pixels.
If the source is a screen, the size is pretty static. Changing display settings
could affect it.
If the source is a window, the size is initially the size of the window. The
user resizing the window affects the size.
If the source is multiple windows, the size initially seems to be that of the
display they're sitting on. Windows across multiple displays are not captured
into the same surface, as of macOS 14.
Differential Revision: https://phabricator.services.mozilla.com/D221941
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bc6215142feaab1a3f7820006129219504851bc8
---
.../mac/screen_capturer_sck.mm | 25 ++++++++-----------
1 file changed, 10 insertions(+), 15 deletions(-)
.../mac/desktop_frame_iosurface.h | 9 +-
.../mac/desktop_frame_iosurface.mm | 37 ++++++--
.../mac/screen_capturer_sck.mm | 89 +++++++++++++++++--
3 files changed, 120 insertions(+), 15 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index b92399e6b6..96d54c5c03 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -103,7 +103,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
void StartWithFilter(SCContentFilter* filter) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
diff --git a/modules/desktop_capture/mac/desktop_frame_iosurface.h b/modules/desktop_capture/mac/desktop_frame_iosurface.h
index 73da0f693c..ed90e40993 100644
--- a/modules/desktop_capture/mac/desktop_frame_iosurface.h
+++ b/modules/desktop_capture/mac/desktop_frame_iosurface.h
@@ -26,7 +26,7 @@ class DesktopFrameIOSurface final : public DesktopFrame {
// Lock an IOSurfaceRef containing a snapshot of a display. Return NULL if
// failed to lock.
static std::unique_ptr<DesktopFrameIOSurface> Wrap(
- rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, CGRect rect = {});
// Called by SckHelper to notify of a newly captured frame. May run on an arbitrary thread.
- void OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment);
+ void OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment);
~DesktopFrameIOSurface() override;
@@ -35,7 +35,12 @@ class DesktopFrameIOSurface final : public DesktopFrame {
private:
// Called when starting the capturer or the configuration has changed (either from a
@@ -480,10 +480,13 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
// This constructor expects `io_surface` to hold a non-null IOSurfaceRef.
- explicit DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
+ DesktopFrameIOSurface(
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface,
+ uint8_t* data,
+ int32_t width,
+ int32_t height,
+ int32_t stride);
const rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
};
diff --git a/modules/desktop_capture/mac/desktop_frame_iosurface.mm b/modules/desktop_capture/mac/desktop_frame_iosurface.mm
index b59b319db9..7a5b595f19 100644
--- a/modules/desktop_capture/mac/desktop_frame_iosurface.mm
+++ b/modules/desktop_capture/mac/desktop_frame_iosurface.mm
@@ -17,7 +17,7 @@ namespace webrtc {
// static
std::unique_ptr<DesktopFrameIOSurface> DesktopFrameIOSurface::Wrap(
- rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface) {
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, CGRect rect) {
if (!io_surface) {
return nullptr;
}
@@ -40,14 +40,39 @@ std::unique_ptr<DesktopFrameIOSurface> DesktopFrameIOSurface::Wrap(
return nullptr;
}
- return std::unique_ptr<DesktopFrameIOSurface>(new DesktopFrameIOSurface(io_surface));
+ size_t surfaceWidth = IOSurfaceGetWidth(io_surface.get());
+ size_t surfaceHeight = IOSurfaceGetHeight(io_surface.get());
+ uint8_t* data = static_cast<uint8_t*>(IOSurfaceGetBaseAddress(io_surface.get()));
+ size_t offset = 0;
+ size_t width = surfaceWidth;
+ size_t height = surfaceHeight;
+ size_t offsetColumns = 0;
+ size_t offsetRows = 0;
+ int32_t stride = IOSurfaceGetBytesPerRow(io_surface.get());
+ if (rect.size.width > 0 && rect.size.height > 0) {
+ width = std::floor(rect.size.width);
+ height = std::floor(rect.size.height);
+ offsetColumns = std::ceil(rect.origin.x);
+ offsetRows = std::ceil(rect.origin.y);
+ RTC_CHECK_GE(surfaceWidth, offsetColumns + width);
+ RTC_CHECK_GE(surfaceHeight, offsetRows + height);
+ offset = stride * offsetRows + bytes_per_pixel * offsetColumns;
+ }
+
+ RTC_LOG(LS_VERBOSE) << "DesktopFrameIOSurface wrapping IOSurface with size " << surfaceWidth << "x"
+ << surfaceHeight << ". Cropping to (" << offsetColumns << "," << offsetRows << "; "
+ << width << "x" << height << "). Stride=" << stride / bytes_per_pixel
+ << ", buffer-offset-px=" << offset / bytes_per_pixel << ", buffer-offset-bytes=" << offset;
+
+ return std::unique_ptr<DesktopFrameIOSurface>(new DesktopFrameIOSurface(io_surface, data + offset, width, height, stride));
}
-void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment) {
+void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment) {
RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
<< " width=" << IOSurfaceGetWidth(io_surface)
<< ", height=" << IOSurfaceGetHeight(io_surface) << ".";
-DesktopFrameIOSurface::DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface)
+DesktopFrameIOSurface::DesktopFrameIOSurface(
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, uint8_t* data, int32_t width, int32_t height, int32_t stride)
: DesktopFrame(
- DesktopSize(IOSurfaceGetWidth(io_surface.get()), IOSurfaceGetHeight(io_surface.get())),
- IOSurfaceGetBytesPerRow(io_surface.get()),
- static_cast<uint8_t*>(IOSurfaceGetBaseAddress(io_surface.get())),
+ DesktopSize(width, height),
+ stride,
+ data,
nullptr),
io_surface_(io_surface) {
RTC_DCHECK(io_surface_);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 96d54c5c03..f331bafdfd 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -169,6 +169,12 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// TODO: crbug.com/327458809 - Replace this flag with ScreenCapturerHelper to more accurately
// track the dirty rectangles from the SCStreamFrameInfoDirtyRects attachment.
bool frame_is_dirty_ RTC_GUARDED_BY(latest_frame_lock_) = true;
+
+ const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
+ // Tracks whether a reconfigure is needed.
+ bool frame_needs_reconfigure_ RTC_GUARDED_BY(latest_frame_lock_) = false;
+ // If a reconfigure is needed, this will be set to the size in pixels required to fit the entire
+ // source without downscaling.
+ std::optional<CGSize> frame_reconfigure_img_size_ RTC_GUARDED_BY(latest_frame_lock_);
};
ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options)
@@ -240,6 +246,7 @@ void ScreenCapturerSck::CaptureFrame() {
}
std::unique_ptr<DesktopFrame> frame;
+ bool needs_reconfigure = false;
{
MutexLock lock(&latest_frame_lock_);
if (latest_frame_) {
@@ -250,6 +257,8 @@ void ScreenCapturerSck::CaptureFrame() {
frame_is_dirty_ = false;
}
}
+ needs_reconfigure = frame_needs_reconfigure_;
+ frame_needs_reconfigure_ = false;
}
if (frame) {
@@ -260,6 +269,10 @@ void ScreenCapturerSck::CaptureFrame() {
RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_TEMPORARY";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
}
+
+ if (needs_reconfigure) {
+ StartOrReconfigureCapturer();
+ }
}
void ScreenCapturerSck::EnsureVisible() {
@@ -283,6 +296,9 @@ void ScreenCapturerSck::EnsureVisible() {
stream = stream_;
stream_ = nil;
filter_ = nil;
+ MutexLock lock2(&latest_frame_lock_);
+ frame_needs_reconfigure_ = false;
+ frame_reconfigure_img_size_ = std::nullopt;
}
[stream removeStreamOutput:helper_ type:SCStreamOutputTypeScreen error:nil];
[stream stopCaptureWithCompletionHandler:nil];
@@ -439,12 +455,21 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
{
MutexLock lock(&latest_frame_lock_);
latest_frame_dpi_ = filter.pointPixelScale * kStandardDPI;
+ if (filter_ != filter) {
+ frame_reconfigure_img_size_ = std::nullopt;
+ }
+ auto sourceImgRect = frame_reconfigure_img_size_.value_or(CGSizeMake(
+ filter.contentRect.size.width * filter.pointPixelScale,
+ filter.contentRect.size.height * filter.pointPixelScale));
+ config.width = sourceImgRect.width;
+ config.height = sourceImgRect.height;
}
filter_ = filter;
if (stream_) {
- RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration to size="
+ << config.width << "x" << config.height << ".";
[stream_ updateContentFilter:filter completionHandler:nil];
[stream_ updateConfiguration:config completionHandler:nil];
} else {
@@ -481,20 +506,63 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
}
void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment) {
- RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
- << " width=" << IOSurfaceGetWidth(io_surface)
- << ", height=" << IOSurfaceGetHeight(io_surface) << ".";
-
+ double scaleFactor = 1;
+ double contentScale = 1;
+ CGRect contentRect = {};
+ CGRect boundingRect = {};
+ CGRect overlayRect = {};
const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
+ if (auto factor = (NSNumber *)attachment[SCStreamFrameInfoScaleFactor]) {
+ scaleFactor = [factor floatValue];
+ }
+ if (auto scale = (NSNumber *)attachment[SCStreamFrameInfoContentScale]) {
+ contentScale = [scale floatValue];
+ }
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoContentRect]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &contentRect)) {
+ contentRect = CGRect();
+ }
+ }
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoBoundingRect]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &boundingRect)) {
+ boundingRect = CGRect();
+ }
+ }
+ if (@available(macOS 14.2, *)) {
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoPresenterOverlayContentRect ]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &overlayRect)) {
+ overlayRect = CGRect();
+ }
+ }
+ }
+
+
+ auto imgBoundingRect = CGRectMake(
+ scaleFactor * boundingRect.origin.x,
+ scaleFactor * boundingRect.origin.y,
+ scaleFactor * boundingRect.size.width,
+ scaleFactor * boundingRect.size.height);
rtc::ScopedCFTypeRef<IOSurfaceRef> scoped_io_surface(io_surface, rtc::RetainPolicy::RETAIN);
std::unique_ptr<DesktopFrameIOSurface> desktop_frame_io_surface =
DesktopFrameIOSurface::Wrap(scoped_io_surface);
@@ -505,28 +508,20 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef
- DesktopFrameIOSurface::Wrap(scoped_io_surface);
+ DesktopFrameIOSurface::Wrap(scoped_io_surface, imgBoundingRect);
if (!desktop_frame_io_surface) {
RTC_LOG(LS_ERROR) << "Failed to lock IOSurface.";
return;
}
if (!dirty) {
- const void* dirty_rects_ptr =
- CFDictionaryGetValue(attachment, (__bridge CFStringRef)SCStreamFrameInfoDirtyRects);
- if (!dirty_rects_ptr) {
+ if (!dirty_rects) {
// This is never expected to happen - SCK attaches a non-empty dirty-rects list to every
// frame, even when nothing has changed.
return;
+ const size_t width = IOSurfaceGetWidth(io_surface);
+ const size_t height = IOSurfaceGetHeight(io_surface);
+
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
+ << ". New surface: width=" << width << ", height=" << height
+ << ", contentRect=" << NSStringFromRect(contentRect).UTF8String
+ << ", boundingRect=" << NSStringFromRect(boundingRect).UTF8String
+ << ", overlayRect=(" << NSStringFromRect(overlayRect).UTF8String
+ << ", scaleFactor=" << scaleFactor << ", contentScale=" << contentScale
+ << ". Cropping to rect " << NSStringFromRect(imgBoundingRect).UTF8String
+ << ".";
+
std::unique_ptr<SharedDesktopFrame> frame =
SharedDesktopFrame::Wrap(std::move(desktop_frame_io_surface));
@@ -529,8 +597,15 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
}
- if (CFGetTypeID(dirty_rects_ptr) != CFArrayGetTypeID()) {
- return;
- }
-
- CFArrayRef dirty_rects_array = static_cast<CFArrayRef>(dirty_rects_ptr);
- int size = CFArrayGetCount(dirty_rects_array);
- for (int i = 0; i < size; i++) {
- const void* rect_ptr = CFArrayGetValueAtIndex(dirty_rects_array, i);
+ for (NSUInteger i = 0; i < dirty_rects.count; i++) {
+ const auto* rect_ptr = (__bridge CFDictionaryRef)dirty_rects[i];
if (CFGetTypeID(rect_ptr) != CFDictionaryGetTypeID()) {
// This is never expected to happen - the dirty-rects attachment should always be an array
// of dictionaries.
return;
}
CGRect rect{};
- CGRectMakeWithDictionaryRepresentation(static_cast<CFDictionaryRef>(rect_ptr), &rect);
+ CGRectMakeWithDictionaryRepresentation(rect_ptr, &rect);
if (!CGRectIsEmpty(rect)) {
dirty = true;
break;
@@ -673,7 +668,7 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(const DesktopCaptureOp
webrtc::MutexLock lock(&_capturer_lock);
if (_capturer) {
- _capturer->OnNewIOSurface(ioSurface, attachment);
+ _capturer->OnNewIOSurface(ioSurface, (__bridge NSDictionary*)attachment);
}
}
+ MutexLock lock(&latest_frame_lock_);
+ if (contentScale > 0 && contentScale < 1) {
+ frame_needs_reconfigure_ = true;
+ double scale = 1 / contentScale;
+ frame_reconfigure_img_size_ = CGSizeMake(
+ std::ceil(scale * width),
+ std::ceil(scale * height));
+ }
if (dirty) {
- MutexLock lock(&latest_frame_lock_);
frame_is_dirty_ = true;
std::swap(latest_frame_, frame);
}

View File

@ -1,277 +1,48 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 22:36:00 +0000
Subject: Bug 1918096 - In ScreenCapturerSck adapt to sources that change
resolution. r=webrtc-reviewers,ng
Subject: Bug 1918096 - In ScreenCapturerSck skip some processing when
possible. r=webrtc-reviewers,ng
If the resolution is smaller than the allocated surface, we crop.
If the resolution is larger than the allocated surface, we reconfigure with a
larger surface.
No need to update the last frame unless it has changed.
The allocated surface has the size we told it to have in the
SCStreamConfiguration, in pixels.
If the source is a screen, the size is pretty static. Changing display settings
could affect it.
If the source is a window, the size is initially the size of the window. The
user resizing the window affects the size.
If the source is multiple windows, the size initially seems to be that of the
display they're sitting on. Windows across multiple displays are not captured
into the same surface, as of macOS 14.
Differential Revision: https://phabricator.services.mozilla.com/D221941
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bc6215142feaab1a3f7820006129219504851bc8
Differential Revision: https://phabricator.services.mozilla.com/D221942
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d52f2fd575479da72508033b3a2151906e2bf19
---
.../mac/desktop_frame_iosurface.h | 9 +-
.../mac/desktop_frame_iosurface.mm | 37 ++++++--
.../mac/screen_capturer_sck.mm | 89 +++++++++++++++++--
3 files changed, 120 insertions(+), 15 deletions(-)
.../desktop_capture/mac/screen_capturer_sck.mm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/modules/desktop_capture/mac/desktop_frame_iosurface.h b/modules/desktop_capture/mac/desktop_frame_iosurface.h
index 73da0f693c..ed90e40993 100644
--- a/modules/desktop_capture/mac/desktop_frame_iosurface.h
+++ b/modules/desktop_capture/mac/desktop_frame_iosurface.h
@@ -26,7 +26,7 @@ class DesktopFrameIOSurface final : public DesktopFrame {
// Lock an IOSurfaceRef containing a snapshot of a display. Return NULL if
// failed to lock.
static std::unique_ptr<DesktopFrameIOSurface> Wrap(
- rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, CGRect rect = {});
~DesktopFrameIOSurface() override;
@@ -35,7 +35,12 @@ class DesktopFrameIOSurface final : public DesktopFrame {
private:
// This constructor expects `io_surface` to hold a non-null IOSurfaceRef.
- explicit DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
+ DesktopFrameIOSurface(
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface,
+ uint8_t* data,
+ int32_t width,
+ int32_t height,
+ int32_t stride);
const rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
};
diff --git a/modules/desktop_capture/mac/desktop_frame_iosurface.mm b/modules/desktop_capture/mac/desktop_frame_iosurface.mm
index b59b319db9..7a5b595f19 100644
--- a/modules/desktop_capture/mac/desktop_frame_iosurface.mm
+++ b/modules/desktop_capture/mac/desktop_frame_iosurface.mm
@@ -17,7 +17,7 @@ namespace webrtc {
// static
std::unique_ptr<DesktopFrameIOSurface> DesktopFrameIOSurface::Wrap(
- rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface) {
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, CGRect rect) {
if (!io_surface) {
return nullptr;
}
@@ -40,14 +40,39 @@ std::unique_ptr<DesktopFrameIOSurface> DesktopFrameIOSurface::Wrap(
return nullptr;
}
- return std::unique_ptr<DesktopFrameIOSurface>(new DesktopFrameIOSurface(io_surface));
+ size_t surfaceWidth = IOSurfaceGetWidth(io_surface.get());
+ size_t surfaceHeight = IOSurfaceGetHeight(io_surface.get());
+ uint8_t* data = static_cast<uint8_t*>(IOSurfaceGetBaseAddress(io_surface.get()));
+ size_t offset = 0;
+ size_t width = surfaceWidth;
+ size_t height = surfaceHeight;
+ size_t offsetColumns = 0;
+ size_t offsetRows = 0;
+ int32_t stride = IOSurfaceGetBytesPerRow(io_surface.get());
+ if (rect.size.width > 0 && rect.size.height > 0) {
+ width = std::floor(rect.size.width);
+ height = std::floor(rect.size.height);
+ offsetColumns = std::ceil(rect.origin.x);
+ offsetRows = std::ceil(rect.origin.y);
+ RTC_CHECK_GE(surfaceWidth, offsetColumns + width);
+ RTC_CHECK_GE(surfaceHeight, offsetRows + height);
+ offset = stride * offsetRows + bytes_per_pixel * offsetColumns;
+ }
+
+ RTC_LOG(LS_VERBOSE) << "DesktopFrameIOSurface wrapping IOSurface with size " << surfaceWidth << "x"
+ << surfaceHeight << ". Cropping to (" << offsetColumns << "," << offsetRows << "; "
+ << width << "x" << height << "). Stride=" << stride / bytes_per_pixel
+ << ", buffer-offset-px=" << offset / bytes_per_pixel << ", buffer-offset-bytes=" << offset;
+
+ return std::unique_ptr<DesktopFrameIOSurface>(new DesktopFrameIOSurface(io_surface, data + offset, width, height, stride));
}
-DesktopFrameIOSurface::DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface)
+DesktopFrameIOSurface::DesktopFrameIOSurface(
+ rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface, uint8_t* data, int32_t width, int32_t height, int32_t stride)
: DesktopFrame(
- DesktopSize(IOSurfaceGetWidth(io_surface.get()), IOSurfaceGetHeight(io_surface.get())),
- IOSurfaceGetBytesPerRow(io_surface.get()),
- static_cast<uint8_t*>(IOSurfaceGetBaseAddress(io_surface.get())),
+ DesktopSize(width, height),
+ stride,
+ data,
nullptr),
io_surface_(io_surface) {
RTC_DCHECK(io_surface_);
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 96d54c5c03..f331bafdfd 100644
index f331bafdfd..ddaf9a9624 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -169,6 +169,12 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final : public DesktopCapture
// TODO: crbug.com/327458809 - Replace this flag with ScreenCapturerHelper to more accurately
// track the dirty rectangles from the SCStreamFrameInfoDirtyRects attachment.
bool frame_is_dirty_ RTC_GUARDED_BY(latest_frame_lock_) = true;
+
+ // Tracks whether a reconfigure is needed.
+ bool frame_needs_reconfigure_ RTC_GUARDED_BY(latest_frame_lock_) = false;
+ // If a reconfigure is needed, this will be set to the size in pixels required to fit the entire
+ // source without downscaling.
+ std::optional<CGSize> frame_reconfigure_img_size_ RTC_GUARDED_BY(latest_frame_lock_);
};
ScreenCapturerSck::ScreenCapturerSck(const DesktopCaptureOptions& options)
@@ -240,6 +246,7 @@ void ScreenCapturerSck::CaptureFrame() {
}
std::unique_ptr<DesktopFrame> frame;
+ bool needs_reconfigure = false;
{
MutexLock lock(&latest_frame_lock_);
if (latest_frame_) {
@@ -250,6 +257,8 @@ void ScreenCapturerSck::CaptureFrame() {
frame_is_dirty_ = false;
}
}
+ needs_reconfigure = frame_needs_reconfigure_;
+ frame_needs_reconfigure_ = false;
}
if (frame) {
@@ -260,6 +269,10 @@ void ScreenCapturerSck::CaptureFrame() {
RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " CaptureFrame() -> ERROR_TEMPORARY";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
}
+
+ if (needs_reconfigure) {
+ StartOrReconfigureCapturer();
+ }
}
void ScreenCapturerSck::EnsureVisible() {
@@ -283,6 +296,9 @@ void ScreenCapturerSck::EnsureVisible() {
stream = stream_;
stream_ = nil;
filter_ = nil;
+ MutexLock lock2(&latest_frame_lock_);
+ frame_needs_reconfigure_ = false;
+ frame_reconfigure_img_size_ = std::nullopt;
}
[stream removeStreamOutput:helper_ type:SCStreamOutputTypeScreen error:nil];
[stream stopCaptureWithCompletionHandler:nil];
@@ -439,12 +455,21 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
{
MutexLock lock(&latest_frame_lock_);
latest_frame_dpi_ = filter.pointPixelScale * kStandardDPI;
+ if (filter_ != filter) {
+ frame_reconfigure_img_size_ = std::nullopt;
+ }
+ auto sourceImgRect = frame_reconfigure_img_size_.value_or(CGSizeMake(
+ filter.contentRect.size.width * filter.pointPixelScale,
+ filter.contentRect.size.height * filter.pointPixelScale));
+ config.width = sourceImgRect.width;
+ config.height = sourceImgRect.height;
}
filter_ = filter;
if (stream_) {
- RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration.";
+ RTC_LOG(LS_INFO) << "ScreenCapturerSck " << this << " Updating stream configuration to size="
+ << config.width << "x" << config.height << ".";
[stream_ updateContentFilter:filter completionHandler:nil];
[stream_ updateConfiguration:config completionHandler:nil];
} else {
@@ -481,20 +506,63 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
}
void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment) {
- RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
- << " width=" << IOSurfaceGetWidth(io_surface)
- << ", height=" << IOSurfaceGetHeight(io_surface) << ".";
-
+ double scaleFactor = 1;
+ double contentScale = 1;
+ CGRect contentRect = {};
+ CGRect boundingRect = {};
+ CGRect overlayRect = {};
@@ -511,6 +511,7 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
CGRect contentRect = {};
CGRect boundingRect = {};
CGRect overlayRect = {};
+ SCFrameStatus status = SCFrameStatusStopped;
const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
+ if (auto factor = (NSNumber *)attachment[SCStreamFrameInfoScaleFactor]) {
+ scaleFactor = [factor floatValue];
+ }
+ if (auto scale = (NSNumber *)attachment[SCStreamFrameInfoContentScale]) {
+ contentScale = [scale floatValue];
+ }
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoContentRect]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &contentRect)) {
+ contentRect = CGRect();
+ }
+ }
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoBoundingRect]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &boundingRect)) {
+ boundingRect = CGRect();
+ }
+ }
+ if (@available(macOS 14.2, *)) {
+ if (const auto* rectDict = (__bridge CFDictionaryRef)attachment[SCStreamFrameInfoPresenterOverlayContentRect ]) {
+ if (!CGRectMakeWithDictionaryRepresentation(rectDict, &overlayRect)) {
+ overlayRect = CGRect();
+ }
+ }
+ }
+
+
+ auto imgBoundingRect = CGRectMake(
+ scaleFactor * boundingRect.origin.x,
+ scaleFactor * boundingRect.origin.y,
+ scaleFactor * boundingRect.size.width,
+ scaleFactor * boundingRect.size.height);
rtc::ScopedCFTypeRef<IOSurfaceRef> scoped_io_surface(io_surface, rtc::RetainPolicy::RETAIN);
std::unique_ptr<DesktopFrameIOSurface> desktop_frame_io_surface =
- DesktopFrameIOSurface::Wrap(scoped_io_surface);
+ DesktopFrameIOSurface::Wrap(scoped_io_surface, imgBoundingRect);
if (!desktop_frame_io_surface) {
RTC_LOG(LS_ERROR) << "Failed to lock IOSurface.";
return;
}
+ const size_t width = IOSurfaceGetWidth(io_surface);
+ const size_t height = IOSurfaceGetHeight(io_surface);
+
+ RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
+ << ". New surface: width=" << width << ", height=" << height
+ << ", contentRect=" << NSStringFromRect(contentRect).UTF8String
+ << ", boundingRect=" << NSStringFromRect(boundingRect).UTF8String
+ << ", overlayRect=(" << NSStringFromRect(overlayRect).UTF8String
+ << ", scaleFactor=" << scaleFactor << ", contentScale=" << contentScale
+ << ". Cropping to rect " << NSStringFromRect(imgBoundingRect).UTF8String
+ << ".";
+
std::unique_ptr<SharedDesktopFrame> frame =
SharedDesktopFrame::Wrap(std::move(desktop_frame_io_surface));
@@ -529,8 +597,15 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
if (auto factor = (NSNumber *)attachment[SCStreamFrameInfoScaleFactor]) {
scaleFactor = [factor floatValue];
@@ -536,6 +537,22 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
}
}
+ MutexLock lock(&latest_frame_lock_);
+ if (contentScale > 0 && contentScale < 1) {
+ frame_needs_reconfigure_ = true;
+ double scale = 1 / contentScale;
+ frame_reconfigure_img_size_ = CGSizeMake(
+ std::ceil(scale * width),
+ std::ceil(scale * height));
+ if (auto statusNr = (NSNumber *)attachment[SCStreamFrameInfoStatus]) {
+ status = (SCFrameStatus)[statusNr integerValue];
+ }
if (dirty) {
- MutexLock lock(&latest_frame_lock_);
frame_is_dirty_ = true;
std::swap(latest_frame_, frame);
}
+
+ switch (status) {
+ case SCFrameStatusBlank:
+ case SCFrameStatusIdle:
+ case SCFrameStatusSuspended:
+ case SCFrameStatusStopped:
+ // No new frame. Ignore.
+ return;
+ case SCFrameStatusComplete:
+ case SCFrameStatusStarted:
+ // New frame. Process it.
+ break;
+ }
auto imgBoundingRect = CGRectMake(
scaleFactor * boundingRect.origin.x,

View File

@ -1,48 +1,138 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 22:36:00 +0000
Subject: Bug 1918096 - In ScreenCapturerSck skip some processing when
possible. r=webrtc-reviewers,ng
Date: Fri, 13 Sep 2024 09:48:00 +0000
Subject: Bug 1918096 - Make SckPickerHandle thread safe. r=padenot
No need to update the last frame unless it has changed.
We cannot guarantee that the thread it is used on is static, as both the
VideoCapture and DesktopCapture threads can come and go.
Differential Revision: https://phabricator.services.mozilla.com/D221942
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d52f2fd575479da72508033b3a2151906e2bf19
Differential Revision: https://phabricator.services.mozilla.com/D222082
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/cfcdd5339805363c495841abc4b4f82cd287f712
---
.../desktop_capture/mac/screen_capturer_sck.mm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
.../desktop_capture/mac/sck_picker_handle.mm | 90 +++++++++++++------
1 file changed, 62 insertions(+), 28 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index f331bafdfd..ddaf9a9624 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -511,6 +511,7 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
CGRect contentRect = {};
CGRect boundingRect = {};
CGRect overlayRect = {};
+ SCFrameStatus status = SCFrameStatusStopped;
const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
if (auto factor = (NSNumber *)attachment[SCStreamFrameInfoScaleFactor]) {
scaleFactor = [factor floatValue];
@@ -536,6 +537,22 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* at
}
}
diff --git a/modules/desktop_capture/mac/sck_picker_handle.mm b/modules/desktop_capture/mac/sck_picker_handle.mm
index 25e98b671f..0f26be79d1 100644
--- a/modules/desktop_capture/mac/sck_picker_handle.mm
+++ b/modules/desktop_capture/mac/sck_picker_handle.mm
@@ -12,57 +12,91 @@
+ if (auto statusNr = (NSNumber *)attachment[SCStreamFrameInfoStatus]) {
+ status = (SCFrameStatus)[statusNr integerValue];
#import <ScreenCaptureKit/ScreenCaptureKit.h>
-#include "api/sequence_checker.h"
+#include "absl/base/attributes.h"
+#include "rtc_base/synchronization/mutex.h"
+
+#include <memory>
+#include <optional>
namespace webrtc {
-class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+class SckPickerProxy;
+
+class API_AVAILABLE(macos(14.0)) SckPickerProxy {
public:
- explicit SckPickerHandle(DesktopCapturer::SourceId source) : source_(source) {
- RTC_DCHECK_RUN_ON(&checker_);
- RTC_CHECK_LE(sHandleCount, maximumStreamCount);
- if (sHandleCount++ == 0) {
+ static SckPickerProxy* Get() {
+ static SckPickerProxy* sPicker = new SckPickerProxy();
+ return sPicker;
+ }
+
+ switch (status) {
+ case SCFrameStatusBlank:
+ case SCFrameStatusIdle:
+ case SCFrameStatusSuspended:
+ case SCFrameStatusStopped:
+ // No new frame. Ignore.
+ return;
+ case SCFrameStatusComplete:
+ case SCFrameStatusStarted:
+ // New frame. Process it.
+ break;
+ bool AtCapacity() const {
+ MutexLock lock(&mutex_);
+ return AtCapacityLocked();
+ }
+
+ SCContentSharingPicker* GetPicker() const { return SCContentSharingPicker.sharedPicker; }
+
+ ABSL_MUST_USE_RESULT std::optional<DesktopCapturer::SourceId> AcquireSourceId() {
+ MutexLock lock(&mutex_);
+ if (AtCapacityLocked()) {
+ return std::nullopt;
+ }
+ if (handle_count_++ == 0) {
auto* picker = GetPicker();
picker.maximumStreamCount = [NSNumber numberWithUnsignedInt:maximumStreamCount];
picker.active = YES;
}
+ return ++unique_source_id_;
}
auto imgBoundingRect = CGRectMake(
scaleFactor * boundingRect.origin.x,
- ~SckPickerHandle() {
- RTC_DCHECK_RUN_ON(&checker_);
- if (--sHandleCount > 0) {
+ void RelinquishSourceId(DesktopCapturer::SourceId source) {
+ MutexLock lock(&mutex_);
+ if (--handle_count_ > 0) {
return;
}
GetPicker().active = NO;
}
- SCContentSharingPicker* GetPicker() const override {
- return SCContentSharingPicker.sharedPicker;
+ private:
+ bool AtCapacityLocked() const {
+ mutex_.AssertHeld();
+ return handle_count_ == maximumStreamCount;
}
- DesktopCapturer::SourceId Source() const override {
- return source_;
+ mutable Mutex mutex_;
+ // 100 is an arbitrary number that seems high enough to never get reached, while still providing
+ // a reasonably low upper bound.
+ static constexpr size_t maximumStreamCount = 100;
+ size_t handle_count_ RTC_GUARDED_BY(mutex_) = 0;
+ DesktopCapturer::SourceId unique_source_id_ RTC_GUARDED_BY(mutex_) = 0;
+};
+
+class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+ public:
+ static std::unique_ptr<SckPickerHandle> Create(SckPickerProxy* proxy) {
+ std::optional<DesktopCapturer::SourceId> id = proxy->AcquireSourceId();
+ if (!id) {
+ return nullptr;
+ }
+ return std::unique_ptr<SckPickerHandle>(new SckPickerHandle(proxy, *id));
}
- static bool AtCapacity() { return sHandleCount == maximumStreamCount; }
+ ~SckPickerHandle() { proxy_->RelinquishSourceId(source_); }
+
+ SCContentSharingPicker* GetPicker() const override { return proxy_->GetPicker(); }
+
+ DesktopCapturer::SourceId Source() const override { return source_; }
private:
- // 100 is an arbitrary number that seems high enough to never get reached, while still providing
- // a reasonably low upper bound.
- static constexpr size_t maximumStreamCount = 100;
- static size_t sHandleCount;
- SequenceChecker checker_;
+ SckPickerHandle(SckPickerProxy* proxy, DesktopCapturer::SourceId source)
+ : proxy_(proxy), source_(source) {}
+
+ SckPickerProxy* const proxy_;
const DesktopCapturer::SourceId source_;
};
-size_t SckPickerHandle::sHandleCount = 0;
-
-std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() API_AVAILABLE(macos(14.0)) {
- if (SckPickerHandle::AtCapacity()) {
- return nullptr;
- }
- static DesktopCapturer::SourceId unique_source_id = 0;
- return std::make_unique<SckPickerHandle>(++unique_source_id);
+std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() {
+ return SckPickerHandle::Create(SckPickerProxy::Get());
}
-} // namespace webrtc
\ No newline at end of file
+} // namespace webrtc

View File

@ -1,138 +1,37 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Fri, 13 Sep 2024 09:48:00 +0000
Subject: Bug 1918096 - Make SckPickerHandle thread safe. r=padenot
Date: Mon, 16 Sep 2024 14:51:00 +0000
Subject: Bug 1918996 - Use SCShareableContentStyleNone on macOS 15.
r=webrtc-reviewers,jib
We cannot guarantee that the thread it is used on is static, as both the
VideoCapture and DesktopCapture threads can come and go.
Differential Revision: https://phabricator.services.mozilla.com/D222082
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/cfcdd5339805363c495841abc4b4f82cd287f712
Differential Revision: https://phabricator.services.mozilla.com/D222270
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ade6f6dc0c5a5df1c87e78a45b2878c4ade54358
---
.../desktop_capture/mac/sck_picker_handle.mm | 90 +++++++++++++------
1 file changed, 62 insertions(+), 28 deletions(-)
modules/desktop_capture/mac/screen_capturer_sck.mm | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/modules/desktop_capture/mac/sck_picker_handle.mm b/modules/desktop_capture/mac/sck_picker_handle.mm
index 25e98b671f..0f26be79d1 100644
--- a/modules/desktop_capture/mac/sck_picker_handle.mm
+++ b/modules/desktop_capture/mac/sck_picker_handle.mm
@@ -12,57 +12,91 @@
#import <ScreenCaptureKit/ScreenCaptureKit.h>
-#include "api/sequence_checker.h"
+#include "absl/base/attributes.h"
+#include "rtc_base/synchronization/mutex.h"
+
+#include <memory>
+#include <optional>
namespace webrtc {
-class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+class SckPickerProxy;
+
+class API_AVAILABLE(macos(14.0)) SckPickerProxy {
public:
- explicit SckPickerHandle(DesktopCapturer::SourceId source) : source_(source) {
- RTC_DCHECK_RUN_ON(&checker_);
- RTC_CHECK_LE(sHandleCount, maximumStreamCount);
- if (sHandleCount++ == 0) {
+ static SckPickerProxy* Get() {
+ static SckPickerProxy* sPicker = new SckPickerProxy();
+ return sPicker;
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index ddaf9a9624..9136915033 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -305,10 +305,18 @@ void ScreenCapturerSck::EnsureVisible() {
SCContentSharingPickerConfiguration* config = picker.defaultConfiguration;
config.allowedPickerModes = picker_modes_;
picker.defaultConfiguration = config;
+ SCShareableContentStyle style = SCShareableContentStyleNone;
// Pick a sensible style to start out with, based on our current mode.
- // Default to Screen because if using Window the picker automatically hides
- // our current window to show others.
- SCShareableContentStyle style = SCShareableContentStyleDisplay;
+ if (@available(macOS 15, *)) {
+ // Stick with None because if we use Display, the picker doesn't let us
+ // pick a window when first opened. Behaves like Window in 14 except doesn't
+ // change window focus.
+ } else {
+ // Default to Display because if using Window the picker automatically hides
+ // our current window to show others. Saves a click compared to None when
+ // picking a display.
+ style = SCShareableContentStyleDisplay;
+ }
+
+ bool AtCapacity() const {
+ MutexLock lock(&mutex_);
+ return AtCapacityLocked();
+ }
+
+ SCContentSharingPicker* GetPicker() const { return SCContentSharingPicker.sharedPicker; }
+
+ ABSL_MUST_USE_RESULT std::optional<DesktopCapturer::SourceId> AcquireSourceId() {
+ MutexLock lock(&mutex_);
+ if (AtCapacityLocked()) {
+ return std::nullopt;
+ }
+ if (handle_count_++ == 0) {
auto* picker = GetPicker();
picker.maximumStreamCount = [NSNumber numberWithUnsignedInt:maximumStreamCount];
picker.active = YES;
}
+ return ++unique_source_id_;
}
- ~SckPickerHandle() {
- RTC_DCHECK_RUN_ON(&checker_);
- if (--sHandleCount > 0) {
+ void RelinquishSourceId(DesktopCapturer::SourceId source) {
+ MutexLock lock(&mutex_);
+ if (--handle_count_ > 0) {
return;
}
GetPicker().active = NO;
}
- SCContentSharingPicker* GetPicker() const override {
- return SCContentSharingPicker.sharedPicker;
+ private:
+ bool AtCapacityLocked() const {
+ mutex_.AssertHeld();
+ return handle_count_ == maximumStreamCount;
}
- DesktopCapturer::SourceId Source() const override {
- return source_;
+ mutable Mutex mutex_;
+ // 100 is an arbitrary number that seems high enough to never get reached, while still providing
+ // a reasonably low upper bound.
+ static constexpr size_t maximumStreamCount = 100;
+ size_t handle_count_ RTC_GUARDED_BY(mutex_) = 0;
+ DesktopCapturer::SourceId unique_source_id_ RTC_GUARDED_BY(mutex_) = 0;
+};
+
+class API_AVAILABLE(macos(14.0)) SckPickerHandle : public SckPickerHandleInterface {
+ public:
+ static std::unique_ptr<SckPickerHandle> Create(SckPickerProxy* proxy) {
+ std::optional<DesktopCapturer::SourceId> id = proxy->AcquireSourceId();
+ if (!id) {
+ return nullptr;
+ }
+ return std::unique_ptr<SckPickerHandle>(new SckPickerHandle(proxy, *id));
}
- static bool AtCapacity() { return sHandleCount == maximumStreamCount; }
+ ~SckPickerHandle() { proxy_->RelinquishSourceId(source_); }
+
+ SCContentSharingPicker* GetPicker() const override { return proxy_->GetPicker(); }
+
+ DesktopCapturer::SourceId Source() const override { return source_; }
private:
- // 100 is an arbitrary number that seems high enough to never get reached, while still providing
- // a reasonably low upper bound.
- static constexpr size_t maximumStreamCount = 100;
- static size_t sHandleCount;
- SequenceChecker checker_;
+ SckPickerHandle(SckPickerProxy* proxy, DesktopCapturer::SourceId source)
+ : proxy_(proxy), source_(source) {}
+
+ SckPickerProxy* const proxy_;
const DesktopCapturer::SourceId source_;
};
-size_t SckPickerHandle::sHandleCount = 0;
-
-std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() API_AVAILABLE(macos(14.0)) {
- if (SckPickerHandle::AtCapacity()) {
- return nullptr;
- }
- static DesktopCapturer::SourceId unique_source_id = 0;
- return std::make_unique<SckPickerHandle>(++unique_source_id);
+std::unique_ptr<SckPickerHandleInterface> CreateSckPickerHandle() {
+ return SckPickerHandle::Create(SckPickerProxy::Get());
}
-} // namespace webrtc
\ No newline at end of file
+} // namespace webrtc
if (picker_modes_ == SCContentSharingPickerModeSingleDisplay) {
style = SCShareableContentStyleDisplay;
} else if (picker_modes_ == SCContentSharingPickerModeSingleWindow ||

View File

@ -1,37 +1,50 @@
From: Andreas Pehrson <apehrson@mozilla.com>
Date: Mon, 16 Sep 2024 14:51:00 +0000
Subject: Bug 1918996 - Use SCShareableContentStyleNone on macOS 15.
r=webrtc-reviewers,jib
From: Jan Grulich <jgrulich@redhat.com>
Date: Tue, 24 Sep 2024 11:20:00 +0000
Subject: Bug 1920460 - WebRTC backport: PipeWire camera: get max FPS for each
format when specified as list r=pehrsons,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D222270
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ade6f6dc0c5a5df1c87e78a45b2878c4ade54358
In many cases, the framerate can be specified as list of possible values
and in that case, we would end up with max FPS to be set to 0 as this
case was not handled.
This is a simple backport of an WebRTC upstream change.
Upstream commit: 3aa47cfd30dc965446cf1405bb062b756a62e6d1
Differential Revision: https://phabricator.services.mozilla.com/D223112
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90f241650577182dbd08f8c5b96c645cf48ff397
---
modules/desktop_capture/mac/screen_capturer_sck.mm | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
modules/video_capture/linux/pipewire_session.cc | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index ddaf9a9624..9136915033 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -305,10 +305,18 @@ void ScreenCapturerSck::EnsureVisible() {
SCContentSharingPickerConfiguration* config = picker.defaultConfiguration;
config.allowedPickerModes = picker_modes_;
picker.defaultConfiguration = config;
+ SCShareableContentStyle style = SCShareableContentStyleNone;
// Pick a sensible style to start out with, based on our current mode.
- // Default to Screen because if using Window the picker automatically hides
- // our current window to show others.
- SCShareableContentStyle style = SCShareableContentStyleDisplay;
+ if (@available(macOS 15, *)) {
+ // Stick with None because if we use Display, the picker doesn't let us
+ // pick a window when first opened. Behaves like Window in 14 except doesn't
+ // change window focus.
+ } else {
+ // Default to Display because if using Window the picker automatically hides
+ // our current window to show others. Saves a click compared to None when
+ // picking a display.
+ style = SCShareableContentStyleDisplay;
+ }
if (picker_modes_ == SCContentSharingPickerModeSingleDisplay) {
style = SCShareableContentStyleDisplay;
} else if (picker_modes_ == SCContentSharingPickerModeSingleWindow ||
diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc
index 29e454f00b..dc270b7b3a 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -17,6 +17,8 @@
#include <spa/param/video/raw.h>
#include <spa/pod/parser.h>
+#include <algorithm>
+
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_capture/device_info_impl.h"
#include "rtc_base/logging.h"
@@ -152,9 +154,15 @@ void PipeWireNode::OnNodeParam(void* data,
fract = static_cast<spa_fraction*>(SPA_POD_BODY(val));
- if (choice == SPA_CHOICE_None)
+ if (choice == SPA_CHOICE_None) {
cap.maxFPS = 1.0 * fract[0].num / fract[0].denom;
- else if (choice == SPA_CHOICE_Range && fract[1].num > 0)
+ } else if (choice == SPA_CHOICE_Enum) {
+ for (uint32_t i = 1; i < n_items; i++) {
+ cap.maxFPS = std::max(
+ static_cast<int32_t>(1.0 * fract[i].num / fract[i].denom),
+ cap.maxFPS);
+ }
+ } else if (choice == SPA_CHOICE_Range && fract[1].num > 0)
cap.maxFPS = 1.0 * fract[1].num / fract[1].denom;
}
}

View File

@ -1,50 +1,170 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Tue, 24 Sep 2024 11:20:00 +0000
Subject: Bug 1920460 - WebRTC backport: PipeWire camera: get max FPS for each
format when specified as list r=pehrsons,webrtc-reviewers
Date: Wed, 25 Sep 2024 06:52:00 +0000
Subject: Bug 1920472 - WebRTC backport: PipeWire camera: use exact stream
parameters specified by capability r=pehrsons,webrtc-reviewers
In many cases, the framerate can be specified as list of possible values
and in that case, we would end up with max FPS to be set to 0 as this
case was not handled.
We currently specify stream parameters to be a range for both framerate
and resolution, where preferred value is specified. The preferred value
doesn't seem to be taken into account and we end up accepting resolution
from 1x1 to MAX_INTxMAX_INT. In case the other side tries to first match
with lower resolution than requested, we will happily match it and start
streaming low quality video. We should instead request the exact stream
parameters as specified by requested capability. This capability always
come from what has been originally reported as supported so it shouldn't
happen we don't find a matching stream. This also applies to requested
video format. We previously requested mjpg for streams with resolution
higher than 640x480, but it doesn't necessarily mean the camera supports
mjpg for the requested resolution. Again, refer to requested capability
in this case as it should indicate what is supported and we know we can
request exactly the same video format. It can happen that framerate is
set to 0 as unspecified. In that case keep using a range as before, but
with more sane values.
This is a simple backport of an WebRTC upstream change.
Upstream commit: 3aa47cfd30dc965446cf1405bb062b756a62e6d1
Upstream commit: 9703f8474f156e08e4a96dc36253f1cdccd549e1
Differential Revision: https://phabricator.services.mozilla.com/D223112
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90f241650577182dbd08f8c5b96c645cf48ff397
Differential Revision: https://phabricator.services.mozilla.com/D223119
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/75a999c1bd73f3fe323652aa1def8d2daa3ebb2d
---
modules/video_capture/linux/pipewire_session.cc | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
.../linux/video_capture_pipewire.cc | 85 +++++++++++--------
.../linux/video_capture_pipewire.h | 1 +
2 files changed, 51 insertions(+), 35 deletions(-)
diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc
index 29e454f00b..dc270b7b3a 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -17,6 +17,8 @@
#include <spa/param/video/raw.h>
#include <spa/pod/parser.h>
+#include <algorithm>
+
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_capture/device_info_impl.h"
#include "rtc_base/logging.h"
@@ -152,9 +154,15 @@ void PipeWireNode::OnNodeParam(void* data,
fract = static_cast<spa_fraction*>(SPA_POD_BODY(val));
- if (choice == SPA_CHOICE_None)
+ if (choice == SPA_CHOICE_None) {
cap.maxFPS = 1.0 * fract[0].num / fract[0].denom;
- else if (choice == SPA_CHOICE_Range && fract[1].num > 0)
+ } else if (choice == SPA_CHOICE_Enum) {
+ for (uint32_t i = 1; i < n_items; i++) {
+ cap.maxFPS = std::max(
+ static_cast<int32_t>(1.0 * fract[i].num / fract[i].denom),
+ cap.maxFPS);
+ }
+ } else if (choice == SPA_CHOICE_Range && fract[1].num > 0)
cap.maxFPS = 1.0 * fract[1].num / fract[1].denom;
}
diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc
index b21b55fd7d..e9d99133f5 100644
--- a/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/modules/video_capture/linux/video_capture_pipewire.cc
@@ -52,10 +52,20 @@ VideoType VideoCaptureModulePipeWire::PipeWireRawFormatToVideoType(
if (spa_and_pixel_format.spa_format == spa_format)
return spa_and_pixel_format.video_type;
}
- RTC_LOG(LS_INFO) << "Unsupported pixel format: " << spa_format;
+ RTC_LOG(LS_WARNING) << "Unsupported pixel format: " << spa_format;
return VideoType::kUnknown;
}
+uint32_t VideoCaptureModulePipeWire::VideoTypeToPipeWireRawFormat(
+ VideoType type) {
+ for (const auto& spa_and_pixel_format : kSupportedFormats) {
+ if (spa_and_pixel_format.video_type == type)
+ return spa_and_pixel_format.spa_format;
+ }
+ RTC_LOG(LS_WARNING) << "Unsupported video type: " << static_cast<int>(type);
+ return SPA_VIDEO_FORMAT_UNKNOWN;
+}
+
VideoCaptureModulePipeWire::VideoCaptureModulePipeWire(
VideoCaptureOptions* options)
: VideoCaptureImpl(),
@@ -88,45 +98,53 @@ int32_t VideoCaptureModulePipeWire::Init(const char* deviceUniqueId) {
}
static spa_pod* BuildFormat(spa_pod_builder* builder,
- uint32_t format,
+ VideoType video_type,
uint32_t width,
uint32_t height,
float frame_rate) {
- spa_pod_frame frames[2];
+ spa_pod_frame frame;
+
+ const uint32_t media_subtype = video_type == VideoType::kMJPEG
+ ? SPA_MEDIA_SUBTYPE_mjpg
+ : SPA_MEDIA_SUBTYPE_raw;
- spa_pod_builder_push_object(builder, &frames[0], SPA_TYPE_OBJECT_Format,
+ spa_pod_builder_push_object(builder, &frame, SPA_TYPE_OBJECT_Format,
SPA_PARAM_EnumFormat);
spa_pod_builder_add(builder, SPA_FORMAT_mediaType,
SPA_POD_Id(SPA_MEDIA_TYPE_video), SPA_FORMAT_mediaSubtype,
- SPA_POD_Id(format), 0);
-
- if (format == SPA_MEDIA_SUBTYPE_raw) {
- spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_format, 0);
- spa_pod_builder_push_choice(builder, &frames[1], SPA_CHOICE_Enum, 0);
- spa_pod_builder_id(builder, kSupportedFormats[0].spa_format);
- for (const auto& spa_and_pixel_format : kSupportedFormats)
- spa_pod_builder_id(builder, spa_and_pixel_format.spa_format);
- spa_pod_builder_pop(builder, &frames[1]);
- }
+ SPA_POD_Id(media_subtype), 0);
- spa_rectangle preferred_size = spa_rectangle{width, height};
- spa_rectangle min_size = spa_rectangle{1, 1};
- spa_rectangle max_size = spa_rectangle{4096, 4096};
- spa_pod_builder_add(
- builder, SPA_FORMAT_VIDEO_size,
- SPA_POD_CHOICE_RANGE_Rectangle(&preferred_size, &min_size, &max_size), 0);
+ if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
+ const uint32_t format =
+ VideoCaptureModulePipeWire::VideoTypeToPipeWireRawFormat(video_type);
+ RTC_CHECK(format != SPA_VIDEO_FORMAT_UNKNOWN);
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format),
+ 0);
+ }
- spa_fraction preferred_frame_rate =
- spa_fraction{static_cast<uint32_t>(frame_rate), 1};
- spa_fraction min_frame_rate = spa_fraction{0, 1};
- spa_fraction max_frame_rate = spa_fraction{INT32_MAX, 1};
- spa_pod_builder_add(
- builder, SPA_FORMAT_VIDEO_framerate,
- SPA_POD_CHOICE_RANGE_Fraction(&preferred_frame_rate, &min_frame_rate,
- &max_frame_rate),
- 0);
+ spa_rectangle resolution = spa_rectangle{width, height};
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size,
+ SPA_POD_Rectangle(&resolution), 0);
+
+ // Framerate can be also set to 0 to be unspecified
+ if (frame_rate) {
+ spa_fraction framerate = spa_fraction{static_cast<uint32_t>(frame_rate), 1};
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_framerate,
+ SPA_POD_Fraction(&framerate), 0);
+ } else {
+ // Default to some reasonable values
+ spa_fraction preferred_frame_rate =
+ spa_fraction{static_cast<uint32_t>(30), 1};
+ spa_fraction min_frame_rate = spa_fraction{1, 1};
+ spa_fraction max_frame_rate = spa_fraction{30, 1};
+ spa_pod_builder_add(
+ builder, SPA_FORMAT_VIDEO_framerate,
+ SPA_POD_CHOICE_RANGE_Fraction(&preferred_frame_rate, &min_frame_rate,
+ &max_frame_rate),
+ 0);
+ }
- return static_cast<spa_pod*>(spa_pod_builder_pop(builder, &frames[0]));
+ return static_cast<spa_pod*>(spa_pod_builder_pop(builder, &frame));
}
RTC_NO_SANITIZE("cfi-icall")
@@ -178,13 +196,10 @@ int32_t VideoCaptureModulePipeWire::StartCapture(
uint32_t width = capability.width;
uint32_t height = capability.height;
uint32_t frame_rate = capability.maxFPS;
- bool prefer_jpeg = (width > 640) || (height > 480);
+ VideoType video_type = capability.videoType;
params.push_back(
- BuildFormat(&builder, SPA_MEDIA_SUBTYPE_raw, width, height, frame_rate));
- params.insert(
- prefer_jpeg ? params.begin() : params.end(),
- BuildFormat(&builder, SPA_MEDIA_SUBTYPE_mjpg, width, height, frame_rate));
+ BuildFormat(&builder, video_type, width, height, frame_rate));
int res = pw_stream_connect(
stream_, PW_DIRECTION_INPUT, node_id_,
diff --git a/modules/video_capture/linux/video_capture_pipewire.h b/modules/video_capture/linux/video_capture_pipewire.h
index eeb3b9497c..789f2034d3 100644
--- a/modules/video_capture/linux/video_capture_pipewire.h
+++ b/modules/video_capture/linux/video_capture_pipewire.h
@@ -28,6 +28,7 @@ class VideoCaptureModulePipeWire : public VideoCaptureImpl {
int32_t CaptureSettings(VideoCaptureCapability& settings) override;
static VideoType PipeWireRawFormatToVideoType(uint32_t format);
+ static uint32_t VideoTypeToPipeWireRawFormat(VideoType type);
private:
static void OnStreamParamChanged(void* data,

View File

@ -1,170 +1,104 @@
From: Jan Grulich <jgrulich@redhat.com>
Date: Wed, 25 Sep 2024 06:52:00 +0000
Subject: Bug 1920472 - WebRTC backport: PipeWire camera: use exact stream
parameters specified by capability r=pehrsons,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 1 Oct 2024 21:05:00 +0000
Subject: Bug 1921706 - use relative paths on deps in a few places to avoid
future issues. r=ng,webrtc-reviewers DONTBUILD
We currently specify stream parameters to be a range for both framerate
and resolution, where preferred value is specified. The preferred value
doesn't seem to be taken into account and we end up accepting resolution
from 1x1 to MAX_INTxMAX_INT. In case the other side tries to first match
with lower resolution than requested, we will happily match it and start
streaming low quality video. We should instead request the exact stream
parameters as specified by requested capability. This capability always
come from what has been originally reported as supported so it shouldn't
happen we don't find a matching stream. This also applies to requested
video format. We previously requested mjpg for streams with resolution
higher than 640x480, but it doesn't necessarily mean the camera supports
mjpg for the requested resolution. Again, refer to requested capability
in this case as it should indicate what is supported and we know we can
request exactly the same video format. It can happen that framerate is
set to 0 as unspecified. In that case keep using a range as before, but
with more sane values.
Note: this produces no changes in the generated moz.build files.
This is a simple backport of an WebRTC upstream change.
Upstream commit: 9703f8474f156e08e4a96dc36253f1cdccd549e1
Differential Revision: https://phabricator.services.mozilla.com/D223119
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/75a999c1bd73f3fe323652aa1def8d2daa3ebb2d
Differential Revision: https://phabricator.services.mozilla.com/D224070
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bbec1b95ddb5e00967a0fb002f54f8f24336b904
---
.../linux/video_capture_pipewire.cc | 85 +++++++++++--------
.../linux/video_capture_pipewire.h | 1 +
2 files changed, 51 insertions(+), 35 deletions(-)
modules/audio_coding/BUILD.gn | 2 +-
modules/portal/BUILD.gn | 8 ++++----
modules/video_capture/BUILD.gn | 2 +-
sdk/BUILD.gn | 14 ++++++++++++++
test/BUILD.gn | 6 ++++++
5 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc
index b21b55fd7d..e9d99133f5 100644
--- a/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/modules/video_capture/linux/video_capture_pipewire.cc
@@ -52,10 +52,20 @@ VideoType VideoCaptureModulePipeWire::PipeWireRawFormatToVideoType(
if (spa_and_pixel_format.spa_format == spa_format)
return spa_and_pixel_format.video_type;
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 6fe5ff6a44..ab4854f8e3 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -540,7 +540,7 @@ rtc_library("webrtc_opus_wrapper") {
deps += [ rtc_opus_dir ]
public_configs = [ "//third_party/opus:opus_config" ]
} else if (build_with_mozilla) {
- public_configs = [ "//third_party/opus:opus_config" ]
+ public_configs = [ "../../third_party/opus:opus_config" ]
}
- RTC_LOG(LS_INFO) << "Unsupported pixel format: " << spa_format;
+ RTC_LOG(LS_WARNING) << "Unsupported pixel format: " << spa_format;
return VideoType::kUnknown;
}
+uint32_t VideoCaptureModulePipeWire::VideoTypeToPipeWireRawFormat(
+ VideoType type) {
+ for (const auto& spa_and_pixel_format : kSupportedFormats) {
+ if (spa_and_pixel_format.video_type == type)
+ return spa_and_pixel_format.spa_format;
diff --git a/modules/portal/BUILD.gn b/modules/portal/BUILD.gn
index aff8609b54..901597ecde 100644
--- a/modules/portal/BUILD.gn
+++ b/modules/portal/BUILD.gn
@@ -137,10 +137,10 @@ if (!build_with_mozilla) {
deps -= [ ":pipewire_stubs" ]
defines -= [ "WEBRTC_DLOPEN_PIPEWIRE" ]
public_deps = [
- "//third_party/pipewire",
- "//third_party/drm",
- "//third_party/gbm",
- "//third_party/libepoxy"
+ "../../third_party/pipewire",
+ "../../third_party/drm",
+ "../../third_party/gbm",
+ "../../third_party/libepoxy"
]
}
}
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index d9b3471572..60e191908b 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -110,7 +110,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
]
if (build_with_mozilla) {
configs -= [ "../portal:pipewire_base" ]
- public_deps = [ "//third_party/pipewire" ]
+ public_deps = [ "../../third_party/pipewire" ]
}
}
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index fce3ca62ff..d2a74716dd 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -588,6 +588,20 @@ if (is_ios || is_mac) {
"CoreGraphics.framework",
"CoreVideo.framework",
]
+ if (build_with_mozilla) {
+ deps -= [
+ "//api/video:video_frame",
+ "//api/video:video_rtp_headers",
+ "//common_video",
+ "//rtc_base:checks",
+ ]
+ deps += [
+ "../api/video:video_frame",
+ "../api/video:video_rtp_headers",
+ "../common_video",
+ "../rtc_base:checks",
+ ]
+ }
}
if (!build_with_mozilla) {
diff --git a/test/BUILD.gn b/test/BUILD.gn
index ac80805821..b4fd619f3d 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -483,6 +483,12 @@ rtc_source_set("test_support") {
"//testing/gmock",
"//testing/gtest",
]
+ if (build_with_mozilla) {
+ all_dependent_configs -= [
+ "//third_party/googletest:gmock_config",
+ "//third_party/googletest:gtest_config",
+ ]
+ }
+ RTC_LOG(LS_WARNING) << "Unsupported video type: " << static_cast<int>(type);
+ return SPA_VIDEO_FORMAT_UNKNOWN;
+}
+
VideoCaptureModulePipeWire::VideoCaptureModulePipeWire(
VideoCaptureOptions* options)
: VideoCaptureImpl(),
@@ -88,45 +98,53 @@ int32_t VideoCaptureModulePipeWire::Init(const char* deviceUniqueId) {
}
static spa_pod* BuildFormat(spa_pod_builder* builder,
- uint32_t format,
+ VideoType video_type,
uint32_t width,
uint32_t height,
float frame_rate) {
- spa_pod_frame frames[2];
+ spa_pod_frame frame;
+
+ const uint32_t media_subtype = video_type == VideoType::kMJPEG
+ ? SPA_MEDIA_SUBTYPE_mjpg
+ : SPA_MEDIA_SUBTYPE_raw;
- spa_pod_builder_push_object(builder, &frames[0], SPA_TYPE_OBJECT_Format,
+ spa_pod_builder_push_object(builder, &frame, SPA_TYPE_OBJECT_Format,
SPA_PARAM_EnumFormat);
spa_pod_builder_add(builder, SPA_FORMAT_mediaType,
SPA_POD_Id(SPA_MEDIA_TYPE_video), SPA_FORMAT_mediaSubtype,
- SPA_POD_Id(format), 0);
-
- if (format == SPA_MEDIA_SUBTYPE_raw) {
- spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_format, 0);
- spa_pod_builder_push_choice(builder, &frames[1], SPA_CHOICE_Enum, 0);
- spa_pod_builder_id(builder, kSupportedFormats[0].spa_format);
- for (const auto& spa_and_pixel_format : kSupportedFormats)
- spa_pod_builder_id(builder, spa_and_pixel_format.spa_format);
- spa_pod_builder_pop(builder, &frames[1]);
- }
+ SPA_POD_Id(media_subtype), 0);
- spa_rectangle preferred_size = spa_rectangle{width, height};
- spa_rectangle min_size = spa_rectangle{1, 1};
- spa_rectangle max_size = spa_rectangle{4096, 4096};
- spa_pod_builder_add(
- builder, SPA_FORMAT_VIDEO_size,
- SPA_POD_CHOICE_RANGE_Rectangle(&preferred_size, &min_size, &max_size), 0);
+ if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
+ const uint32_t format =
+ VideoCaptureModulePipeWire::VideoTypeToPipeWireRawFormat(video_type);
+ RTC_CHECK(format != SPA_VIDEO_FORMAT_UNKNOWN);
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format),
+ 0);
+ }
- spa_fraction preferred_frame_rate =
- spa_fraction{static_cast<uint32_t>(frame_rate), 1};
- spa_fraction min_frame_rate = spa_fraction{0, 1};
- spa_fraction max_frame_rate = spa_fraction{INT32_MAX, 1};
- spa_pod_builder_add(
- builder, SPA_FORMAT_VIDEO_framerate,
- SPA_POD_CHOICE_RANGE_Fraction(&preferred_frame_rate, &min_frame_rate,
- &max_frame_rate),
- 0);
+ spa_rectangle resolution = spa_rectangle{width, height};
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size,
+ SPA_POD_Rectangle(&resolution), 0);
+
+ // Framerate can be also set to 0 to be unspecified
+ if (frame_rate) {
+ spa_fraction framerate = spa_fraction{static_cast<uint32_t>(frame_rate), 1};
+ spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_framerate,
+ SPA_POD_Fraction(&framerate), 0);
+ } else {
+ // Default to some reasonable values
+ spa_fraction preferred_frame_rate =
+ spa_fraction{static_cast<uint32_t>(30), 1};
+ spa_fraction min_frame_rate = spa_fraction{1, 1};
+ spa_fraction max_frame_rate = spa_fraction{30, 1};
+ spa_pod_builder_add(
+ builder, SPA_FORMAT_VIDEO_framerate,
+ SPA_POD_CHOICE_RANGE_Fraction(&preferred_frame_rate, &min_frame_rate,
+ &max_frame_rate),
+ 0);
+ }
- return static_cast<spa_pod*>(spa_pod_builder_pop(builder, &frames[0]));
+ return static_cast<spa_pod*>(spa_pod_builder_pop(builder, &frame));
}
RTC_NO_SANITIZE("cfi-icall")
@@ -178,13 +196,10 @@ int32_t VideoCaptureModulePipeWire::StartCapture(
uint32_t width = capability.width;
uint32_t height = capability.height;
uint32_t frame_rate = capability.maxFPS;
- bool prefer_jpeg = (width > 640) || (height > 480);
+ VideoType video_type = capability.videoType;
params.push_back(
- BuildFormat(&builder, SPA_MEDIA_SUBTYPE_raw, width, height, frame_rate));
- params.insert(
- prefer_jpeg ? params.begin() : params.end(),
- BuildFormat(&builder, SPA_MEDIA_SUBTYPE_mjpg, width, height, frame_rate));
+ BuildFormat(&builder, video_type, width, height, frame_rate));
int res = pw_stream_connect(
stream_, PW_DIRECTION_INPUT, node_id_,
diff --git a/modules/video_capture/linux/video_capture_pipewire.h b/modules/video_capture/linux/video_capture_pipewire.h
index eeb3b9497c..789f2034d3 100644
--- a/modules/video_capture/linux/video_capture_pipewire.h
+++ b/modules/video_capture/linux/video_capture_pipewire.h
@@ -28,6 +28,7 @@ class VideoCaptureModulePipeWire : public VideoCaptureImpl {
int32_t CaptureSettings(VideoCaptureCapability& settings) override;
static VideoType PipeWireRawFormatToVideoType(uint32_t format);
+ static uint32_t VideoTypeToPipeWireRawFormat(VideoType type);
private:
static void OnStreamParamChanged(void* data,
rtc_library("fixed_fps_video_frame_writer_adapter") {

View File

@ -1,104 +1,24 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 1 Oct 2024 21:05:00 +0000
Subject: Bug 1921706 - use relative paths on deps in a few places to avoid
future issues. r=ng,webrtc-reviewers DONTBUILD
From: Randell Jesup <rjesup@mozilla.com>
Date: Tue, 1 Oct 2024 21:28:00 +0000
Subject: Bug 1922048: fix comma instead of semicolon in libwebrtc AEC code
r=mjf,webrtc-reviewers
Note: this produces no changes in the generated moz.build files.
Differential Revision: https://phabricator.services.mozilla.com/D224070
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bbec1b95ddb5e00967a0fb002f54f8f24336b904
Differential Revision: https://phabricator.services.mozilla.com/D224242
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fd7a2f8d10cf9d6e862b8f8bb8e675f0d9ddb4bf
---
modules/audio_coding/BUILD.gn | 2 +-
modules/portal/BUILD.gn | 8 ++++----
modules/video_capture/BUILD.gn | 2 +-
sdk/BUILD.gn | 14 ++++++++++++++
test/BUILD.gn | 6 ++++++
5 files changed, 26 insertions(+), 6 deletions(-)
modules/audio_processing/aec3/echo_canceller3.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 6fe5ff6a44..ab4854f8e3 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -540,7 +540,7 @@ rtc_library("webrtc_opus_wrapper") {
deps += [ rtc_opus_dir ]
public_configs = [ "//third_party/opus:opus_config" ]
} else if (build_with_mozilla) {
- public_configs = [ "//third_party/opus:opus_config" ]
+ public_configs = [ "../../third_party/opus:opus_config" ]
}
}
diff --git a/modules/portal/BUILD.gn b/modules/portal/BUILD.gn
index aff8609b54..901597ecde 100644
--- a/modules/portal/BUILD.gn
+++ b/modules/portal/BUILD.gn
@@ -137,10 +137,10 @@ if (!build_with_mozilla) {
deps -= [ ":pipewire_stubs" ]
defines -= [ "WEBRTC_DLOPEN_PIPEWIRE" ]
public_deps = [
- "//third_party/pipewire",
- "//third_party/drm",
- "//third_party/gbm",
- "//third_party/libepoxy"
+ "../../third_party/pipewire",
+ "../../third_party/drm",
+ "../../third_party/gbm",
+ "../../third_party/libepoxy"
]
}
}
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index d9b3471572..60e191908b 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -110,7 +110,7 @@ if (!build_with_chromium || is_linux || is_chromeos) {
]
if (build_with_mozilla) {
configs -= [ "../portal:pipewire_base" ]
- public_deps = [ "//third_party/pipewire" ]
+ public_deps = [ "../../third_party/pipewire" ]
}
}
}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index fce3ca62ff..d2a74716dd 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -588,6 +588,20 @@ if (is_ios || is_mac) {
"CoreGraphics.framework",
"CoreVideo.framework",
]
+ if (build_with_mozilla) {
+ deps -= [
+ "//api/video:video_frame",
+ "//api/video:video_rtp_headers",
+ "//common_video",
+ "//rtc_base:checks",
+ ]
+ deps += [
+ "../api/video:video_frame",
+ "../api/video:video_rtp_headers",
+ "../common_video",
+ "../rtc_base:checks",
+ ]
+ }
}
if (!build_with_mozilla) {
diff --git a/test/BUILD.gn b/test/BUILD.gn
index ac80805821..b4fd619f3d 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -483,6 +483,12 @@ rtc_source_set("test_support") {
"//testing/gmock",
"//testing/gtest",
]
+ if (build_with_mozilla) {
+ all_dependent_configs -= [
+ "//third_party/googletest:gmock_config",
+ "//third_party/googletest:gtest_config",
+ ]
+ }
}
rtc_library("fixed_fps_video_frame_writer_adapter") {
diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc
index 00010ceaea..4b3747e92b 100644
--- a/modules/audio_processing/aec3/echo_canceller3.cc
+++ b/modules/audio_processing/aec3/echo_canceller3.cc
@@ -781,7 +781,7 @@ EchoCanceller3::EchoCanceller3(
linear_output_framer_.reset(
new BlockFramer(/*num_bands=*/1, num_capture_channels_));
linear_output_block_ =
- std::make_unique<Block>(/*num_bands=*/1, num_capture_channels_),
+ std::make_unique<Block>(/*num_bands=*/1, num_capture_channels_);
linear_output_sub_frame_view_ =
std::vector<std::vector<rtc::ArrayView<float>>>(
1, std::vector<rtc::ArrayView<float>>(num_capture_channels_));

View File

@ -1,24 +1,86 @@
From: Randell Jesup <rjesup@mozilla.com>
Date: Tue, 1 Oct 2024 21:28:00 +0000
Subject: Bug 1922048: fix comma instead of semicolon in libwebrtc AEC code
r=mjf,webrtc-reviewers
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 10 Oct 2024 13:42:00 +0000
Subject: Bug 1921707 - libwebrtc preprocessor, .json, .gni, and *.gn changes
r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D224242
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fd7a2f8d10cf9d6e862b8f8bb8e675f0d9ddb4bf
Differential Revision: https://phabricator.services.mozilla.com/D224076
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7017edc7cfc880bb19f94115d4f48a8c58920a9b
---
modules/audio_processing/aec3/echo_canceller3.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
.gn | 4 ++--
media/BUILD.gn | 2 +-
modules/video_coding/BUILD.gn | 2 +-
webrtc.gni | 6 +++---
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc
index 00010ceaea..4b3747e92b 100644
--- a/modules/audio_processing/aec3/echo_canceller3.cc
+++ b/modules/audio_processing/aec3/echo_canceller3.cc
@@ -781,7 +781,7 @@ EchoCanceller3::EchoCanceller3(
linear_output_framer_.reset(
new BlockFramer(/*num_bands=*/1, num_capture_channels_));
linear_output_block_ =
- std::make_unique<Block>(/*num_bands=*/1, num_capture_channels_),
+ std::make_unique<Block>(/*num_bands=*/1, num_capture_channels_);
linear_output_sub_frame_view_ =
std::vector<std::vector<rtc::ArrayView<float>>>(
1, std::vector<rtc::ArrayView<float>>(num_capture_channels_));
diff --git a/.gn b/.gn
index 52acee7e60..e6aa410434 100644
--- a/.gn
+++ b/.gn
@@ -18,7 +18,7 @@ script_executable = "python3"
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
-secondary_source = "//build/secondary/"
+secondary_source = "//libwebrtc/"
# These are the targets to skip header checking by default. The files in targets
# matching these patterns (see "gn help label_pattern" for format) will not have
@@ -36,7 +36,7 @@ no_check_targets = [
# to force additional review for new uses of exec_script, which is strongly
# discouraged except for gypi_to_gn calls.
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
- [ "//build_overrides/build.gni" ]
+ [ "//libwebrtc/build_overrides/build.gni" ]
# Normally, we'd use 'if (!build_with_mozilla)', but that flag isn't
# available yet.
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 808222978a..904f0b42e6 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -7,7 +7,7 @@
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/linux/pkg_config.gni")
-import("//third_party/libaom/options.gni")
+import("//libwebrtc/third_party/libaom/options.gni")
import("../webrtc.gni")
group("media") {
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 396255b135..7c78f5064a 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -7,7 +7,7 @@
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/linux/pkg_config.gni")
-import("//third_party/libaom/options.gni")
+import("//libwebrtc/third_party/libaom/options.gni")
import("../../webrtc.gni")
rtc_library("encoded_frame") {
diff --git a/webrtc.gni b/webrtc.gni
index 167b4d7de0..794857942b 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -11,7 +11,7 @@ import("//build/config/mips.gni")
import("//build/config/ozone.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/sysroot.gni")
-import("//build_overrides/build.gni")
+import("//libwebrtc/build_overrides/build.gni")
if (!build_with_chromium && is_component_build) {
print("The Gn argument `is_component_build` is currently " +
@@ -500,8 +500,8 @@ all_poison_types = [
"software_video_codecs",
]
-absl_include_config = "//third_party/abseil-cpp:absl_include_config"
-absl_define_config = "//third_party/abseil-cpp:absl_define_config"
+absl_include_config = "//libwebrtc/third_party/abseil-cpp:absl_include_config"
+absl_define_config = "//libwebrtc/third_party/abseil-cpp:absl_define_config"
# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
# that are testonly.

View File

@ -1,86 +1,100 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 10 Oct 2024 13:42:00 +0000
Subject: Bug 1921707 - libwebrtc preprocessor, .json, .gni, and *.gn changes
r=ng,webrtc-reviewers
Subject: Bug 1921707 - webrtc.gni - filter out '//third_party/abseil-cpp/'
deps r=ng,webrtc-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D224076
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7017edc7cfc880bb19f94115d4f48a8c58920a9b
Differential Revision: https://phabricator.services.mozilla.com/D224079
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/45b99d1ba95b46896506de1c7dd92f19e4dc9207
---
.gn | 4 ++--
media/BUILD.gn | 2 +-
modules/video_coding/BUILD.gn | 2 +-
webrtc.gni | 6 +++---
4 files changed, 7 insertions(+), 7 deletions(-)
webrtc.gni | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/.gn b/.gn
index 52acee7e60..e6aa410434 100644
--- a/.gn
+++ b/.gn
@@ -18,7 +18,7 @@ script_executable = "python3"
# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
-secondary_source = "//build/secondary/"
+secondary_source = "//libwebrtc/"
# These are the targets to skip header checking by default. The files in targets
# matching these patterns (see "gn help label_pattern" for format) will not have
@@ -36,7 +36,7 @@ no_check_targets = [
# to force additional review for new uses of exec_script, which is strongly
# discouraged except for gypi_to_gn calls.
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist +
- [ "//build_overrides/build.gni" ]
+ [ "//libwebrtc/build_overrides/build.gni" ]
# Normally, we'd use 'if (!build_with_mozilla)', but that flag isn't
# available yet.
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 808222978a..904f0b42e6 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -7,7 +7,7 @@
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/linux/pkg_config.gni")
-import("//third_party/libaom/options.gni")
+import("//libwebrtc/third_party/libaom/options.gni")
import("../webrtc.gni")
group("media") {
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 396255b135..7c78f5064a 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -7,7 +7,7 @@
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/linux/pkg_config.gni")
-import("//third_party/libaom/options.gni")
+import("//libwebrtc/third_party/libaom/options.gni")
import("../../webrtc.gni")
rtc_library("encoded_frame") {
diff --git a/webrtc.gni b/webrtc.gni
index 167b4d7de0..794857942b 100644
index 794857942b..5f917752ff 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -11,7 +11,7 @@ import("//build/config/mips.gni")
import("//build/config/ozone.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/sysroot.gni")
-import("//build_overrides/build.gni")
+import("//libwebrtc/build_overrides/build.gni")
@@ -693,6 +693,36 @@ template("rtc_source_set") {
deps += [ "//third_party/abseil-cpp:absl" ]
}
}
+
+ # Rather than widespread changes to most, if not all, BUILD.gn files
+ # we'll do some filtering on dependencies here.
+ if (build_with_mozilla && defined(deps)) {
+ # Now that abseil-cpp is moved to Mozilla's third_party directory
+ # we remove all the abseil-cpp dependency listings so moz.build
+ # generation succeed.
+ filtered_deps = []
+ foreach (dep, deps) {
+ newdep = string_replace(dep, "//third_party/abseil-cpp/", "")
+ if (newdep == dep) {
+ filtered_deps += [ dep ]
+ }
+ }
+ deps = []
+ deps = filtered_deps
+
+ # We don't build any of the test code, but many of the test
+ # targets list gtest/gmock as a dependency. We can simply
+ # filter them out here.
+ filtered_deps = []
+ foreach (dep, deps) {
+ newdep = string_replace(dep, "//testing/g", "")
+ if (newdep == dep) {
+ filtered_deps += [ dep ]
+ }
+ }
+ deps = []
+ deps = filtered_deps
+ }
}
}
if (!build_with_chromium && is_component_build) {
print("The Gn argument `is_component_build` is currently " +
@@ -500,8 +500,8 @@ all_poison_types = [
"software_video_codecs",
]
@@ -927,6 +957,47 @@ template("rtc_library") {
deps += [ "//third_party/abseil-cpp:absl" ]
}
}
+
+ # Rather than widespread changes to most, if not all, BUILD.gn files
+ # we'll do some filtering on dependencies here.
+ if (build_with_mozilla && defined(deps)) {
+ # Now that abseil-cpp is moved to Mozilla's third_party directory
+ # we remove all the abseil-cpp dependency listings so moz.build
+ # generation succeed.
+ filtered_deps = []
+ foreach (dep, deps) {
+ newdep = string_replace(dep, "//third_party/abseil-cpp/", "")
+ if (newdep == dep) {
+ filtered_deps += [ dep ]
+ }
+ }
+ deps = []
+ deps = filtered_deps
+
+ # We don't build any of the test code, but many of the test
+ # targets list gtest/gmock as a dependency. We can simply
+ # filter them out here.
+ filtered_deps = []
+ foreach (dep, deps) {
+ newdep = string_replace(dep, "//testing/g", "")
+ if (newdep == dep) {
+ filtered_deps += [ dep ]
+ }
+ }
+ deps = []
+ deps = filtered_deps
+
+ # Moving the google build directory requires looking for libwebrtc's
+ # third_party dependencies under libwebrtc/third_party instead of
+ # simply third_party.
+ modified_deps = []
+ foreach (dep, deps) {
+ newdep = string_replace(dep, "//third_party/", "//libwebrtc/third_party/")
+ modified_deps += [ newdep ]
+ }
+ deps = []
+ deps = modified_deps
+ }
}
}
-absl_include_config = "//third_party/abseil-cpp:absl_include_config"
-absl_define_config = "//third_party/abseil-cpp:absl_define_config"
+absl_include_config = "//libwebrtc/third_party/abseil-cpp:absl_include_config"
+absl_define_config = "//libwebrtc/third_party/abseil-cpp:absl_define_config"
# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
# that are testonly.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,21 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Thu, 10 Oct 2024 13:42:00 +0000
Subject: Bug 1921707 - add filtering for new build directory location in
third_party/libwebrtc/webrtc.gni r=ng,webrtc-reviewers
Date: Mon, 14 Oct 2024 17:11:00 -0500
Subject: Bug 1924098 - (fix-8037fc6ffa) upstream missed an include file
Differential Revision: https://phabricator.services.mozilla.com/D224545
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f18c05287ce831369f44715a4174facff4f12652
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c870b16aa4443088c7ddd68a91afe73c8bd04a17
---
webrtc.gni | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
modules/audio_processing/aec3/matched_filter_lag_aggregator.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/webrtc.gni b/webrtc.gni
index 419b176c1c..58b450cbb1 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -548,7 +548,7 @@ template("rtc_test") {
min_sdk_version = 21
target_sdk_version = 23
deps += [
- "//build/android/gtest_apk:native_test_instrumentation_test_runner_java",
+ "//chromium/build/android/gtest_apk:native_test_instrumentation_test_runner_java",
webrtc_root + "test:native_test_java",
]
}
@@ -993,11 +993,21 @@ template("rtc_library") {
modified_deps = []
foreach (dep, deps) {
newdep = string_replace(dep, "//third_party/", "//libwebrtc/third_party/")
+ newdep = string_replace(newdep, "//build", "//chromium/build")
modified_deps += [ newdep ]
}
deps = []
deps = modified_deps
}
+ if (build_with_mozilla && defined(data_deps)) {
+ modified_deps = []
+ foreach (dep, data_deps) {
+ newdep = string_replace(dep, "//build/", "//chromium/build/")
+ modified_deps += [ newdep ]
+ }
+ data_deps = []
+ data_deps = modified_deps
+ }
}
}
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
index 9022424d2f..c15c9960f9 100644
--- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
+++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
@@ -11,6 +11,7 @@
#ifndef MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
#define MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
+#include <memory>
#include <optional>
#include <vector>
@@ -1035,7 +1045,7 @@ template("rtc_executable") {
if (is_win) {
deps += [
# Give executables the default manifest on Windows (a no-op elsewhere).
- "//build/win:default_exe_manifest",
+ "//chromium/build/win:default_exe_manifest",
]
}
}

View File

@ -1,21 +1,177 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 14 Oct 2024 17:11:00 -0500
Subject: Bug 1924098 - (fix-8037fc6ffa) upstream missed an include file
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 14 Oct 2024 17:39:14 -0500
Subject: Bug 1924098 - Cherry-pick upstream libwebrtc commit a8efbb223b r?ng
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/c870b16aa4443088c7ddd68a91afe73c8bd04a17
Upstream commit: https://webrtc.googlesource.com/src/+/a8efbb223be5ec2f8283949a5f3484c2b8576825
[cleanup] Migrate `absl::in_place` to `std::in_place`
Self-explanatory.
Fixed: webrtc:342905193
Change-Id: I3cf1ec99ef6867bb33289977246725badf2bfcfe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363360
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Ho Cheung <hocheung@chromium.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43071}
---
modules/audio_processing/aec3/matched_filter_lag_aggregator.h | 1 +
1 file changed, 1 insertion(+)
modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc | 3 ++-
modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc | 4 ++--
modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc | 4 ++--
modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc | 4 +++-
rtc_base/bitstream_reader_unittest.cc | 4 ++--
8 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
index 9022424d2f..c15c9960f9 100644
--- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
+++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h
@@ -11,6 +11,7 @@
#ifndef MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
#define MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
index 6f70297447..16dcbb59ab 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
@@ -13,6 +13,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <optional>
#include <vector>
+#include <optional>
#include <utility>
#include "modules/rtp_rtcp/source/leb128.h"
@@ -367,7 +368,7 @@ VideoRtpDepacketizerAv1::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
// new coded video sequence can't start from an OBU fragment.
return std::nullopt;
}
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
// To assemble frame, all of the rtp payload is required, including
// aggregation header.
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
index ec8993b191..344bb3f1e1 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
@@ -39,7 +39,7 @@ VideoRtpDepacketizerGeneric::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
RTC_LOG(LS_WARNING) << "Empty payload.";
return std::nullopt;
}
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
const uint8_t* payload_data = rtp_payload.cdata();
uint8_t generic_header = payload_data[0];
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
index e8fd911efe..16d1c2c14c 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
@@ -63,7 +63,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessStapAOrSingleNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
const uint8_t* const payload_data = rtp_payload.cdata();
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
bool modified_buffer = false;
parsed_payload->video_payload = rtp_payload;
parsed_payload->video_header.width = 0;
@@ -235,7 +235,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuaNalu(
return std::nullopt;
}
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
uint8_t fnri = rtp_payload.cdata()[0] & (kH264FBit | kH264NriMask);
uint8_t original_nal_type = rtp_payload.cdata()[1] & kH264TypeMask;
bool first_fragment = (rtp_payload.cdata()[1] & kH264SBit) > 0;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
index d16e638d06..e0ed2215af 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
@@ -71,7 +71,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
}
const uint8_t* const payload_data = rtp_payload.cdata();
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
parsed_payload->video_header.width = 0;
parsed_payload->video_header.height = 0;
parsed_payload->video_header.codec = kVideoCodecH265;
@@ -191,7 +191,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuNalu(
return std::nullopt;
}
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
uint8_t f = rtp_payload.cdata()[0] & kH265FBit;
uint8_t layer_id_h = rtp_payload.cdata()[0] & kH265LayerIDHMask;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
index f4f4a794ea..f18e344baa 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
@@ -20,7 +20,7 @@ namespace webrtc {
std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerRaw::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
parsed->video_payload = std::move(rtp_payload);
return parsed;
}
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
index 157ad37aaa..709415771f 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
@@ -136,7 +136,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerVp8::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
rtc::ArrayView<const uint8_t> payload(rtp_payload.cdata(),
rtp_payload.size());
- std::optional<ParsedRtpPayload> result(absl::in_place);
+ std::optional<ParsedRtpPayload> result(std::in_place);
int offset = ParseRtpPayload(payload, &result->video_header);
if (offset == kFailedToParse)
return std::nullopt;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
index ebd27ffdea..574c7c8530 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
@@ -12,6 +12,8 @@
#include <string.h>
+#include <optional>
+
#include "api/video/video_codec_constants.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/video_coding/codecs/interface/common_constants.h"
@@ -148,7 +150,7 @@ void ParseSsData(BitstreamReader& parser, RTPVideoHeaderVP9* vp9) {
std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerVp9::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
- std::optional<ParsedRtpPayload> result(absl::in_place);
+ std::optional<ParsedRtpPayload> result(std::in_place);
int offset = ParseRtpPayload(rtp_payload, &result->video_header);
if (offset == 0)
return std::nullopt;
diff --git a/rtc_base/bitstream_reader_unittest.cc b/rtc_base/bitstream_reader_unittest.cc
index b9b51a2571..3a48e7d086 100644
--- a/rtc_base/bitstream_reader_unittest.cc
+++ b/rtc_base/bitstream_reader_unittest.cc
@@ -28,7 +28,7 @@ namespace {
TEST(BitstreamReaderTest, InDebugModeRequiresToCheckOkStatusBeforeDestruction) {
const uint8_t bytes[32] = {};
- std::optional<BitstreamReader> reader(absl::in_place, bytes);
+ std::optional<BitstreamReader> reader(std::in_place, bytes);
EXPECT_GE(reader->ReadBits(7), 0u);
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)
@@ -40,7 +40,7 @@ TEST(BitstreamReaderTest, InDebugModeRequiresToCheckOkStatusBeforeDestruction) {
TEST(BitstreamReaderTest, InDebugModeMayCheckRemainingBitsInsteadOfOkStatus) {
const uint8_t bytes[32] = {};
- std::optional<BitstreamReader> reader(absl::in_place, bytes);
+ std::optional<BitstreamReader> reader(std::in_place, bytes);
EXPECT_GE(reader->ReadBit(), 0);
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)

View File

@ -1,177 +1,35 @@
From: Michael Froman <mjfroman@mac.com>
Date: Mon, 14 Oct 2024 17:39:14 -0500
Subject: Bug 1924098 - Cherry-pick upstream libwebrtc commit a8efbb223b r?ng
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 14 Oct 2024 18:40:00 -0500
Subject: Bug 1924098 - (fix-93c9aa1914) add missing include that upstream
missed
Upstream commit: https://webrtc.googlesource.com/src/+/a8efbb223be5ec2f8283949a5f3484c2b8576825
[cleanup] Migrate `absl::in_place` to `std::in_place`
Self-explanatory.
Fixed: webrtc:342905193
Change-Id: I3cf1ec99ef6867bb33289977246725badf2bfcfe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363360
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Ho Cheung <hocheung@chromium.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43071}
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90a6b254783eaa91d0305d8516f27f1ca68c6772
---
modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc | 3 ++-
modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc | 4 ++--
modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc | 4 ++--
modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc | 2 +-
modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc | 4 +++-
rtc_base/bitstream_reader_unittest.cc | 4 ++--
8 files changed, 14 insertions(+), 11 deletions(-)
call/video_receive_stream.h | 1 +
call/video_send_stream.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
index 6f70297447..16dcbb59ab 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc
@@ -13,6 +13,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <optional>
#include <utility>
#include "modules/rtp_rtcp/source/leb128.h"
@@ -367,7 +368,7 @@ VideoRtpDepacketizerAv1::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
// new coded video sequence can't start from an OBU fragment.
return std::nullopt;
}
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
// To assemble frame, all of the rtp payload is required, including
// aggregation header.
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
index ec8993b191..344bb3f1e1 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc
@@ -39,7 +39,7 @@ VideoRtpDepacketizerGeneric::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
RTC_LOG(LS_WARNING) << "Empty payload.";
return std::nullopt;
}
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
const uint8_t* payload_data = rtp_payload.cdata();
uint8_t generic_header = payload_data[0];
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
index e8fd911efe..16d1c2c14c 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc
@@ -63,7 +63,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessStapAOrSingleNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
const uint8_t* const payload_data = rtp_payload.cdata();
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
bool modified_buffer = false;
parsed_payload->video_payload = rtp_payload;
parsed_payload->video_header.width = 0;
@@ -235,7 +235,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuaNalu(
return std::nullopt;
}
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
uint8_t fnri = rtp_payload.cdata()[0] & (kH264FBit | kH264NriMask);
uint8_t original_nal_type = rtp_payload.cdata()[1] & kH264TypeMask;
bool first_fragment = (rtp_payload.cdata()[1] & kH264SBit) > 0;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
index d16e638d06..e0ed2215af 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc
@@ -71,7 +71,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
}
const uint8_t* const payload_data = rtp_payload.cdata();
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
parsed_payload->video_header.width = 0;
parsed_payload->video_header.height = 0;
parsed_payload->video_header.codec = kVideoCodecH265;
@@ -191,7 +191,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuNalu(
return std::nullopt;
}
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed_payload(
- absl::in_place);
+ std::in_place);
uint8_t f = rtp_payload.cdata()[0] & kH265FBit;
uint8_t layer_id_h = rtp_payload.cdata()[0] & kH265LayerIDHMask;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
index f4f4a794ea..f18e344baa 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc
@@ -20,7 +20,7 @@ namespace webrtc {
std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerRaw::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
- std::optional<ParsedRtpPayload> parsed(absl::in_place);
+ std::optional<ParsedRtpPayload> parsed(std::in_place);
parsed->video_payload = std::move(rtp_payload);
return parsed;
}
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
index 157ad37aaa..709415771f 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc
@@ -136,7 +136,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerVp8::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
rtc::ArrayView<const uint8_t> payload(rtp_payload.cdata(),
rtp_payload.size());
- std::optional<ParsedRtpPayload> result(absl::in_place);
+ std::optional<ParsedRtpPayload> result(std::in_place);
int offset = ParseRtpPayload(payload, &result->video_header);
if (offset == kFailedToParse)
return std::nullopt;
diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
index ebd27ffdea..574c7c8530 100644
--- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
+++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc
@@ -12,6 +12,8 @@
#include <string.h>
+#include <optional>
+
#include "api/video/video_codec_constants.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/video_coding/codecs/interface/common_constants.h"
@@ -148,7 +150,7 @@ void ParseSsData(BitstreamReader& parser, RTPVideoHeaderVP9* vp9) {
std::optional<VideoRtpDepacketizer::ParsedRtpPayload>
VideoRtpDepacketizerVp9::Parse(rtc::CopyOnWriteBuffer rtp_payload) {
- std::optional<ParsedRtpPayload> result(absl::in_place);
+ std::optional<ParsedRtpPayload> result(std::in_place);
int offset = ParseRtpPayload(rtp_payload, &result->video_header);
if (offset == 0)
return std::nullopt;
diff --git a/rtc_base/bitstream_reader_unittest.cc b/rtc_base/bitstream_reader_unittest.cc
index b9b51a2571..3a48e7d086 100644
--- a/rtc_base/bitstream_reader_unittest.cc
+++ b/rtc_base/bitstream_reader_unittest.cc
@@ -28,7 +28,7 @@ namespace {
TEST(BitstreamReaderTest, InDebugModeRequiresToCheckOkStatusBeforeDestruction) {
const uint8_t bytes[32] = {};
- std::optional<BitstreamReader> reader(absl::in_place, bytes);
+ std::optional<BitstreamReader> reader(std::in_place, bytes);
EXPECT_GE(reader->ReadBits(7), 0u);
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)
@@ -40,7 +40,7 @@ TEST(BitstreamReaderTest, InDebugModeRequiresToCheckOkStatusBeforeDestruction) {
TEST(BitstreamReaderTest, InDebugModeMayCheckRemainingBitsInsteadOfOkStatus) {
const uint8_t bytes[32] = {};
- std::optional<BitstreamReader> reader(absl::in_place, bytes);
+ std::optional<BitstreamReader> reader(std::in_place, bytes);
EXPECT_GE(reader->ReadBit(), 0);
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index cda4dac800..c6f53e919f 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -25,6 +25,7 @@
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
+#include "api/crypto/frame_encryptor_interface.h"
#include "api/frame_transformer_interface.h"
#include "api/rtp_headers.h"
#include "api/scoped_refptr.h"
diff --git a/call/video_send_stream.h b/call/video_send_stream.h
index 2f5ff4ad3c..f2f9561a03 100644
--- a/call/video_send_stream.h
+++ b/call/video_send_stream.h
@@ -21,6 +21,7 @@
#include "api/adaptation/resource.h"
#include "api/call/transport.h"
#include "api/crypto/crypto_options.h"
+#include "api/crypto/frame_encryptor_interface.h"
#include "api/frame_transformer_interface.h"
#include "api/rtp_parameters.h"
#include "api/rtp_sender_setparameters_callback.h"

View File

@ -1,35 +1,23 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Mon, 14 Oct 2024 18:40:00 -0500
Subject: Bug 1924098 - (fix-93c9aa1914) add missing include that upstream
missed
Date: Tue, 15 Oct 2024 16:13:00 -0500
Subject: Bug 1924098 - (fix-4e41db264b) our base-toolchains builds need the
struct name to build
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/90a6b254783eaa91d0305d8516f27f1ca68c6772
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/479c6364706093d4a863c3514a1031ee4783fb59
---
call/video_receive_stream.h | 1 +
call/video_send_stream.h | 1 +
2 files changed, 2 insertions(+)
call/flexfec_receive_stream_impl.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index cda4dac800..c6f53e919f 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -25,6 +25,7 @@
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "api/crypto/crypto_options.h"
#include "api/crypto/frame_decryptor_interface.h"
+#include "api/crypto/frame_encryptor_interface.h"
#include "api/frame_transformer_interface.h"
#include "api/rtp_headers.h"
#include "api/scoped_refptr.h"
diff --git a/call/video_send_stream.h b/call/video_send_stream.h
index 2f5ff4ad3c..f2f9561a03 100644
--- a/call/video_send_stream.h
+++ b/call/video_send_stream.h
@@ -21,6 +21,7 @@
#include "api/adaptation/resource.h"
#include "api/call/transport.h"
#include "api/crypto/crypto_options.h"
+#include "api/crypto/frame_encryptor_interface.h"
#include "api/frame_transformer_interface.h"
#include "api/rtp_parameters.h"
#include "api/rtp_sender_setparameters_callback.h"
diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc
index bb4122a83f..c70db3d528 100644
--- a/call/flexfec_receive_stream_impl.cc
+++ b/call/flexfec_receive_stream_impl.cc
@@ -114,7 +114,7 @@ FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl(
recovered_packet_receiver)),
rtp_receive_statistics_(ReceiveStatistics::Create(&env.clock())),
rtp_rtcp_(env,
- {.audio = false,
+ RtpRtcpInterface::Configuration{.audio = false,
.receiver_only = true,
.receive_statistics = rtp_receive_statistics_.get(),
.outgoing_transport = config.rtcp_send_transport,

View File

@ -1,23 +1,23 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 15 Oct 2024 16:13:00 -0500
Subject: Bug 1924098 - (fix-4e41db264b) our base-toolchains builds need the
struct name to build
Date: Tue, 15 Oct 2024 16:46:00 -0500
Subject: Bug 1924098 - (fix-e432503389) upstream changed signature of
LibvpxVp9Encoder::InitAndSetControlSettings
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/479c6364706093d4a863c3514a1031ee4783fb59
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fadad7695efe0d9cc6b999a613b9e1f536e660bd
---
call/flexfec_receive_stream_impl.cc | 2 +-
modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc
index bb4122a83f..c70db3d528 100644
--- a/call/flexfec_receive_stream_impl.cc
+++ b/call/flexfec_receive_stream_impl.cc
@@ -114,7 +114,7 @@ FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl(
recovered_packet_receiver)),
rtp_receive_statistics_(ReceiveStatistics::Create(&env.clock())),
rtp_rtcp_(env,
- {.audio = false,
+ RtpRtcpInterface::Configuration{.audio = false,
.receiver_only = true,
.receive_statistics = rtp_receive_statistics_.get(),
.outgoing_transport = config.rtcp_send_transport,
diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
index ea7cb5767e..2e6e53969a 100644
--- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
+++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
@@ -1273,7 +1273,7 @@ int LibvpxVp9Encoder::UpdateCodecFrameSize(
// bugs in trying to do it the "right" way, we basically re-do
// the initialization.
vpx_codec_destroy(encoder_); // clean up old state
- int result = InitAndSetControlSettings(&codec_);
+ int result = InitAndSetControlSettings();
if (result == WEBRTC_VIDEO_CODEC_OK) {
// TODO: Mozilla rates have become much more complicated, we need to store
// more state or find another way of doing this.

View File

@ -1,23 +0,0 @@
From: Michael Froman <mfroman@mozilla.com>
Date: Tue, 15 Oct 2024 16:46:00 -0500
Subject: Bug 1924098 - (fix-e432503389) upstream changed signature of
LibvpxVp9Encoder::InitAndSetControlSettings
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/fadad7695efe0d9cc6b999a613b9e1f536e660bd
---
modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
index ea7cb5767e..2e6e53969a 100644
--- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
+++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
@@ -1273,7 +1273,7 @@ int LibvpxVp9Encoder::UpdateCodecFrameSize(
// bugs in trying to do it the "right" way, we basically re-do
// the initialization.
vpx_codec_destroy(encoder_); // clean up old state
- int result = InitAndSetControlSettings(&codec_);
+ int result = InitAndSetControlSettings();
if (result == WEBRTC_VIDEO_CODEC_OK) {
// TODO: Mozilla rates have become much more complicated, we need to store
// more state or find another way of doing this.

Some files were not shown because too many files have changed in this diff Show More