Skip to content

Commit

Permalink
Bug 1934695 - Vendor libwebrtc from a5d71009ac
Browse files Browse the repository at this point in the history
We cherry-picked this in bug 1930598.

Upstream commit: https://webrtc.googlesource.com/src/+/a5d71009ac1dce7da23813dc9413c03073cfa8ca
    PipeWire camera: use better unique device name for camera devices

    Originally we used node id from PipeWire as an unique device name and
    while this works, it will change everytime PipeWire is restarted. This
    has an impact on default camera selection, where for example Firefox can
    automatically request a camera device that was used before, but this can
    break with the next PipeWire restart.

    Bug: webrtc:42225999
    Change-Id: I9440ee065ffeaa1ffb911a4dc7c405d57c9416dc
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/367880
    Commit-Queue: Jan Grulich <[email protected]>
    Reviewed-by: Ilya Nikolaevskiy <[email protected]>
    Cr-Commit-Position: refs/heads/main@{#43387}
  • Loading branch information
mfromanmoz committed Dec 5, 2024
1 parent 0c1bc71 commit ae05481
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 329 deletions.
3 changes: 3 additions & 0 deletions third_party/libwebrtc/README.moz-ff-commit
Original file line number Diff line number Diff line change
Expand Up @@ -33963,3 +33963,6 @@ badfd6347e
# MOZ_LIBWEBRTC_SRC=/Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
9fb71e3b01
# MOZ_LIBWEBRTC_SRC=/Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
a5d71009ac
2 changes: 2 additions & 0 deletions third_party/libwebrtc/README.mozilla
Original file line number Diff line number Diff line change
Expand Up @@ -22668,3 +22668,5 @@ libwebrtc updated from /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-lib
libwebrtc updated from /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-12-05T22:16:45.953963+00:00.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-12-05T22:18:19.097360+00:00.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/mfroman/no_tm_backup/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-12-05T22:19:55.432580+00:00.
2 changes: 1 addition & 1 deletion third_party/libwebrtc/moz-patch-stack/0114.patch
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ index db2a3c7099..a0607b4aba 100644
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 85ccb289d8..dc270b7b3a 100644
index 98eb656096..0b1504170b 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -9,6 +9,7 @@
Expand Down
70 changes: 16 additions & 54 deletions third_party/libwebrtc/moz-patch-stack/0136.patch
Original file line number Diff line number Diff line change
@@ -1,59 +1,21 @@
From: Jan Grulich <[email protected]>
Date: Tue, 12 Nov 2024 12:28:00 +0000
Subject: Bug 1930598 - WebRTC backport: PipeWire camera: use better unique
device name for camera devices r=pehrsons,webrtc-reviewers
From: Michael Froman <[email protected]>
Date: Thu, 21 Nov 2024 13:57:00 -0600
Subject: Bug 1928110 - (fix-d259a754a8) add missing include

Originally we used node id from PipeWire as an unique device name and
while this works, it will change everytime PipeWire is restarted. This
has an impact on default camera selection, where for example Firefox can
automatically request a camera device that was used before, but this can
break with the next PipeWire restart.

This is a simple backport of an WebRTC upstream change.

Upstream commit: a5d71009ac1dce7da23813dc9413c03073cfa8ca

Differential Revision: https://phabricator.services.mozilla.com/D228635
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b48b48759149275fc393d76c851f5b8cb75c63ed
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/250798952aa5b1f0c4996bcd95c77e917d44f738
---
modules/video_capture/linux/pipewire_session.cc | 2 +-
modules/video_capture/linux/video_capture_pipewire.cc | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
rtc_base/ssl_stream_adapter.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc
index dc270b7b3a..0b1504170b 100644
--- a/modules/video_capture/linux/pipewire_session.cc
+++ b/modules/video_capture/linux/pipewire_session.cc
@@ -76,7 +76,7 @@ PipeWireNode::PipeWireNode(PipeWireSession* session,
: session_(session),
id_(id),
display_name_(spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION)),
- unique_id_(rtc::ToString(id)) {
+ unique_id_(spa_dict_lookup(props, PW_KEY_NODE_NAME)) {
RTC_LOG(LS_VERBOSE) << "Found Camera: " << display_name_;

proxy_ = static_cast<pw_proxy*>(pw_registry_bind(
diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc
index e9d99133f5..f6cd57ac36 100644
--- a/modules/video_capture/linux/video_capture_pipewire.cc
+++ b/modules/video_capture/linux/video_capture_pipewire.cc
@@ -83,12 +83,15 @@ int32_t VideoCaptureModulePipeWire::Init(const char* deviceUniqueId) {
RTC_CHECK_RUNS_SERIALIZED(&capture_checker_);
RTC_DCHECK_RUN_ON(&api_checker_);

- std::optional<int> id;
- id = rtc::StringToNumber<int>(deviceUniqueId);
- if (id == std::nullopt)
+ auto node =
+ std::find_if(session_->nodes_.begin(), session_->nodes_.end(),
+ [deviceUniqueId](const PipeWireNode::PipeWireNodePtr& node) {
+ return node->unique_id() == deviceUniqueId;
+ });
+ if (node == session_->nodes_.end())
return -1;
diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h
index ece5b44ac5..b9041d0b5e 100644
--- a/rtc_base/ssl_stream_adapter.h
+++ b/rtc_base/ssl_stream_adapter.h
@@ -15,6 +15,7 @@
#include <stdint.h>

- node_id_ = id.value();
+ node_id_ = (*node)->id();
#include <memory>
+#include <optional>
#include <string>
#include <vector>

const int len = strlen(deviceUniqueId);
_deviceUniqueId = new (std::nothrow) char[len + 1];
217 changes: 200 additions & 17 deletions third_party/libwebrtc/moz-patch-stack/0137.patch
Original file line number Diff line number Diff line change
@@ -1,21 +1,204 @@
From: Michael Froman <[email protected]>
Date: Thu, 21 Nov 2024 13:57:00 -0600
Subject: Bug 1928110 - (fix-d259a754a8) add missing include
From: Nico Grunbaum <[email protected]>
Date: Wed, 27 Nov 2024 03:41:00 +0000
Subject: Bug 1921154 - libwebrtc build related changes for
AV1;r=mjf,webrtc-reviewers

Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/250798952aa5b1f0c4996bcd95c77e917d44f738
These are most of the changes needed to get a build with AV1.
The crypto/openssl changes are later altered in the stack adding an NSPR based implementation of the functionality that was missing.

Differential Revision: https://phabricator.services.mozilla.com/D228540
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4527c41ef71d7683c60d9c435991a0d93bc5ce4d
---
rtc_base/ssl_stream_adapter.h | 1 +
1 file changed, 1 insertion(+)
BUILD.gn | 4 ++++
media/BUILD.gn | 24 ++++++++++++++----------
rtc_base/BUILD.gn | 44 ++++++++++++++++++++++++--------------------
webrtc.gni | 4 ++--
4 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h
index ece5b44ac5..b9041d0b5e 100644
--- a/rtc_base/ssl_stream_adapter.h
+++ b/rtc_base/ssl_stream_adapter.h
@@ -15,6 +15,7 @@
#include <stdint.h>

#include <memory>
+#include <optional>
#include <string>
#include <vector>
diff --git a/BUILD.gn b/BUILD.gn
index f11d86d211..6f75ecbbf5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -524,6 +524,9 @@ if (!rtc_build_ssl) {
"crypto",
"ssl",
]
+ if (build_with_mozilla) {
+ libs = []
+ }
}
}

@@ -619,6 +622,7 @@ if (!build_with_chromium) {
"api/environment:environment_factory",
"api/video:video_frame",
"api/video:video_rtp_headers",
+ "api/video_codecs:builtin_video_decoder_factory",
"test:rtp_test_utils",
]
# Added when we removed deps in other places to avoid building
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 76f45d7045..aa6ea24934 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -12,12 +12,10 @@ import("../webrtc.gni")

group("media") {
deps = []
- if (!build_with_mozilla) {
- deps += [
- ":rtc_media",
- ":rtc_media_base",
- ]
- }
+ deps += [
+ ":rtc_media",
+ ":rtc_media_base",
+ ]
}

config("rtc_media_defines_config") {
@@ -273,6 +271,9 @@ rtc_library("media_engine") {
"base/media_engine.cc",
"base/media_engine.h",
]
+ deps -= [
+ ":media_channel_impl",
+ ]
}
}

@@ -403,6 +404,7 @@ rtc_library("codec") {
]
}

+# MOZILLA Bug 1931241 - how much of this do we need?
rtc_library("rtp_utils") {
if (!build_with_mozilla) {
sources = [
@@ -448,7 +450,6 @@ rtc_library("media_constants") {
}

rtc_library("turn_utils") {
-if (!build_with_mozilla) {
sources = [
"base/turn_utils.cc",
"base/turn_utils.h",
@@ -459,17 +460,14 @@ if (!build_with_mozilla) {
"../rtc_base/system:rtc_export",
]
}
-}

rtc_library("rid_description") {
-if (!build_with_mozilla) {
sources = [
"base/rid_description.cc",
"base/rid_description.h",
]
deps = []
}
-}

rtc_library("rtc_simulcast_encoder_adapter") {
visibility = [ "*" ]
@@ -715,6 +713,12 @@ rtc_library("rtc_audio_video") {
"engine/webrtc_voice_engine.cc",
"engine/webrtc_voice_engine.h",
]
+ if (build_with_mozilla) {
+ sources -= [
+ "engine/webrtc_video_engine.cc",
+ "engine/webrtc_voice_engine.cc",
+ ]
+ }

public_configs = []
if (!build_with_chromium) {
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index be88e2c586..c12590eadc 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1526,29 +1526,32 @@ rtc_source_set("ssl_header") {
}

rtc_source_set("digest") {
- visibility = [ "*" ]
- sources = [
- "message_digest.cc",
- "message_digest.h",
- "openssl_digest.cc",
- "openssl_digest.h",
- ]
- deps = [
- ":checks",
- ":ssl_header",
- ":stringutils",
- "//third_party/abseil-cpp/absl/strings:string_view",
- ]
-
- # If we are building the SSL library ourselves, we know it's BoringSSL.
- if (rtc_build_ssl) {
- deps += [ "//third_party/boringssl" ]
- } else {
- configs += [ "..:external_ssl_library" ]
- }
+if (!build_with_mozilla) {
+ visibility = [ "*" ]
+ sources = [
+ "message_digest.cc",
+ "message_digest.h",
+ "openssl_digest.cc",
+ "openssl_digest.h",
+ ]
+ deps = [
+ ":checks",
+ ":ssl_header",
+ ":stringutils",
+ "//third_party/abseil-cpp/absl/strings:string_view",
+ ]
+
+ # If we are building the SSL library ourselves, we know it's BoringSSL.
+ if (rtc_build_ssl) {
+ deps += [ "//third_party/boringssl" ]
+ } else {
+ configs += [ "..:external_ssl_library" ]
+ }
+}
}

rtc_library("crypto_random") {
+if (!build_with_mozilla) {
visibility = [ "*" ]
sources = [
"crypto_random.cc",
@@ -1569,6 +1572,7 @@ rtc_library("crypto_random") {
configs += [ "..:external_ssl_library" ]
}
}
+}

rtc_library("ssl") {
if (!build_with_mozilla) {
diff --git a/webrtc.gni b/webrtc.gni
index d29bf59424..6e86706f29 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -125,7 +125,7 @@ declare_args() {

# Used to specify an external OpenSSL include path when not compiling the
# library that comes with WebRTC (i.e. rtc_build_ssl == 0).
- rtc_ssl_root = "unused"
+ rtc_ssl_root = ""

# Enable when an external authentication mechanism is used for performing
# packet authentication for RTP packets instead of libsrtp.
@@ -346,7 +346,7 @@ declare_args() {
}

# Enable liboam only on non-mozilla builds.
-enable_libaom = !build_with_mozilla
+enable_libaom = true

# Make it possible to provide custom locations for some libraries (move these
# up into declare_args should we need to actually use them for the GN build).
Loading

0 comments on commit ae05481

Please sign in to comment.