Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/tg_owt/, media-libs/tg_owt/files/
Date: Tue, 02 Aug 2022 22:07:33
Message-Id: 1659477995.795a0a5e0f5f2053b3fada3ba1f40deb31d16965.gyakovlev@gentoo
1 commit: 795a0a5e0f5f2053b3fada3ba1f40deb31d16965
2 Author: Esteve Varela Colominas <esteve.varela <AT> gmail <DOT> com>
3 AuthorDate: Fri Jul 29 11:10:57 2022 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 2 22:06:35 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=795a0a5e
7
8 media-libs/tg_owt: Bump to 0_pre20220507
9
10 Signed-off-by: Esteve Varela Colominas <esteve.varela <AT> gmail.com>
11 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
12
13 media-libs/tg_owt/Manifest | 1 +
14 .../tg_owt-0_pre20220507-allow-disabling-X11.patch | 117 ++++++++++++++++++++
15 .../tg_owt-0_pre20220507-unbundle-crc32c.patch | 72 +++++++++++++
16 media-libs/tg_owt/tg_owt-0_pre20220507.ebuild | 118 +++++++++++++++++++++
17 4 files changed, 308 insertions(+)
18
19 diff --git a/media-libs/tg_owt/Manifest b/media-libs/tg_owt/Manifest
20 index 342b3ec53144..c9992c75fd83 100644
21 --- a/media-libs/tg_owt/Manifest
22 +++ b/media-libs/tg_owt/Manifest
23 @@ -1,2 +1,3 @@
24 DIST libyuv-ad890067f661dc747a975bc55ba3767fe30d4452.tar.gz 473845 BLAKE2B 664be51c166440e6b03fa98f65d907efc446800804058a5ea7fdf944e12cb1237a1487e83fbe9a2f1ce4c73521234e43632f921ad0333507737d81e1cb23ce8f SHA512 f97529b80a786e2e92443caabebd6d85a42641e10c3d2940b0f69bedf3b8a96c69c3247abddd059c4ddd6f78107ab7214222a4267a559fc2086c8edf5ea1afbc
25 DIST tg_owt-0_pre20220209.tar.gz 16501237 BLAKE2B fb04aca8803645cc107a7e7fbab8d6020ad91f487ece0445aba29dd1127270e8b3a33d51bb35cfc916168df78cbdc98987610b39fd2cf7b86821b4f9733783c9 SHA512 0a35ce3379887b115117188aa8dce44bf89e23ad6f9fab7320a1cd55cdd534bae4c240778a37cb9588cd6acea1e7a83c22c113d608f7bfd5272ee22bb2773af3
26 +DIST tg_owt-0_pre20220507.tar.gz 15799740 BLAKE2B f12f3ecdfb0c7cfdae12af4734ddf22da4d95fd991b8a8ba17515f9d5c22a2f12b81967c0af15ac150c99129701c50c9384ea0e0240bf2366e176c833b14f7db SHA512 6902c65a1be0bcf300f08c274109ed53cdf92b7aff35915045c3989899fc2584cce3fe9df0e8ac29e708fcc575453fe5a6affaea85787f9c4fcc3bcde3b85711
27
28 diff --git a/media-libs/tg_owt/files/tg_owt-0_pre20220507-allow-disabling-X11.patch b/media-libs/tg_owt/files/tg_owt-0_pre20220507-allow-disabling-X11.patch
29 new file mode 100644
30 index 000000000000..71b587f471bb
31 --- /dev/null
32 +++ b/media-libs/tg_owt/files/tg_owt-0_pre20220507-allow-disabling-X11.patch
33 @@ -0,0 +1,117 @@
34 +Add -DTG_OWT_USE_X11
35 +
36 +Allows disabling X11 desktop capturing independently of pipewire support, for
37 +the few people that run wayland without any X11 support whatsoever.
38 +
39 +This setup is untested, but supported by the GNI build system, see:
40 +* src/modules/desktop_capture/BUILD.gn (option rtc_use_x11_extensions)
41 +
42 +Toggling the WEBRTC_USE_X11 define also affects some files under
43 +src/modules/audio_device, but that falls under "X11 support", regardless...
44 +
45 +--- tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41.orig/CMakeLists.txt
46 ++++ tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41/CMakeLists.txt
47 +@@ -21,11 +21,13 @@
48 +
49 + option(BUILD_SHARED_LIBS "Builds shared libraries instead of static." OFF)
50 + option(TG_OWT_USE_PROTOBUF "Use protobuf to generate additional headers. Useful for packaged build." ${BUILD_SHARED_LIBS})
51 ++option(TG_OWT_USE_X11 "Use X11 for desktop capture on non-Apple Unix." ON)
52 + option(TG_OWT_USE_PIPEWIRE "Use pipewire for desktop capture on non-Apple Unix." ON)
53 + option(TG_OWT_DLOPEN_PIPEWIRE "dlopen pipewire 0.3 for desktop capture on non-Apple Unix." ${not_packaged_build})
54 + option(TG_OWT_BUILD_AUDIO_BACKENDS "Build webrtc audio backends." OFF)
55 +
56 + if (NOT UNIX OR APPLE)
57 ++ set(TG_OWT_USE_X11 OFF)
58 + set(TG_OWT_USE_PIPEWIRE OFF)
59 + endif()
60 +
61 +@@ -97,6 +99,10 @@
62 + add_library(tg_owt)
63 + init_target(tg_owt)
64 +
65 ++if (TG_OWT_USE_X11)
66 ++ link_x11(tg_owt)
67 ++endif()
68 ++
69 + if (TG_OWT_USE_PIPEWIRE)
70 + if (TG_OWT_DLOPEN_PIPEWIRE)
71 + include(cmake/generate_stubs.cmake)
72 +@@ -189,10 +195,6 @@
73 + include(cmake/libwebrtcbuild.cmake)
74 + target_link_libraries(tg_owt PUBLIC tg_owt::libwebrtcbuild)
75 +
76 +-if (UNIX AND NOT APPLE)
77 +- link_x11(tg_owt)
78 +-endif()
79 +-
80 + function(add_sublibrary postfix)
81 + add_library(tg_owt_${postfix} OBJECT)
82 + init_feature_target(tg_owt_${postfix} ${postfix})
83 +@@ -2370,6 +2372,39 @@
84 + )
85 + endif()
86 +
87 ++if (NOT TG_OWT_USE_X11)
88 ++ remove_target_sources(tg_owt ${webrtc_loc}
89 ++ # src/modules/desktop_capture/BUILD.gn (rtc_use_x11_extensions)
90 ++ modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.cc
91 ++ modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.h
92 ++ modules/desktop_capture/linux/x11/screen_capturer_x11.cc
93 ++ modules/desktop_capture/linux/x11/screen_capturer_x11.h
94 ++ modules/desktop_capture/linux/x11/shared_x_display.cc
95 ++ modules/desktop_capture/linux/x11/shared_x_display.h
96 ++ modules/desktop_capture/linux/x11/window_capturer_x11.cc
97 ++ modules/desktop_capture/linux/x11/window_capturer_x11.h
98 ++ modules/desktop_capture/linux/x11/window_finder_x11.cc
99 ++ modules/desktop_capture/linux/x11/window_finder_x11.h
100 ++ modules/desktop_capture/linux/x11/window_list_utils.cc
101 ++ modules/desktop_capture/linux/x11/window_list_utils.h
102 ++ modules/desktop_capture/linux/x11/x_atom_cache.cc
103 ++ modules/desktop_capture/linux/x11/x_atom_cache.h
104 ++ modules/desktop_capture/linux/x11/x_error_trap.cc
105 ++ modules/desktop_capture/linux/x11/x_error_trap.h
106 ++ modules/desktop_capture/linux/x11/x_server_pixel_buffer.cc
107 ++ modules/desktop_capture/linux/x11/x_server_pixel_buffer.h
108 ++ modules/desktop_capture/linux/x11/x_window_property.cc
109 ++ modules/desktop_capture/linux/x11/x_window_property.h
110 ++
111 ++ # screen_drawer_linux.cc depends on x11, rest are revdeps
112 ++ modules/desktop_capture/screen_drawer.cc
113 ++ modules/desktop_capture/screen_drawer.h
114 ++ modules/desktop_capture/screen_drawer_linux.cc
115 ++ modules/desktop_capture/screen_drawer_lock_posix.cc
116 ++ modules/desktop_capture/screen_drawer_lock_posix.h
117 ++ )
118 ++endif()
119 ++
120 + if (NOT TG_OWT_USE_PIPEWIRE)
121 + remove_target_sources(tg_owt ${webrtc_loc}
122 + modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
123 +--- tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41.orig/cmake/libwebrtcbuild.cmake
124 ++++ tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41/cmake/libwebrtcbuild.cmake
125 +@@ -29,6 +29,13 @@
126 + BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0
127 + )
128 +
129 ++if (TG_OWT_USE_X11)
130 ++ target_compile_definitions(libwebrtcbuild
131 ++ INTERFACE
132 ++ WEBRTC_USE_X11
133 ++ )
134 ++endif()
135 ++
136 + if (TG_OWT_USE_PIPEWIRE)
137 + target_compile_definitions(libwebrtcbuild
138 + INTERFACE
139 +@@ -65,11 +72,6 @@
140 + INTERFACE
141 + WEBRTC_MAC
142 + )
143 +- else()
144 +- target_compile_definitions(libwebrtcbuild
145 +- INTERFACE
146 +- WEBRTC_USE_X11
147 +- )
148 + endif()
149 +
150 + if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
151
152 diff --git a/media-libs/tg_owt/files/tg_owt-0_pre20220507-unbundle-crc32c.patch b/media-libs/tg_owt/files/tg_owt-0_pre20220507-unbundle-crc32c.patch
153 new file mode 100644
154 index 000000000000..44283c24384c
155 --- /dev/null
156 +++ b/media-libs/tg_owt/files/tg_owt-0_pre20220507-unbundle-crc32c.patch
157 @@ -0,0 +1,72 @@
158 +Use system's crc32c if found
159 +
160 +--- tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41.orig/CMakeLists.txt
161 ++++ tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41/CMakeLists.txt
162 +@@ -147,7 +147,6 @@
163 +
164 + target_link_libraries(tg_owt
165 + PRIVATE
166 +- tg_owt::libcrc32c
167 + tg_owt::libpffft
168 + tg_owt::librnnoise
169 + tg_owt::libsrtp
170 +@@ -185,6 +184,7 @@
171 + link_libabsl(tg_owt)
172 + link_libopenh264(tg_owt)
173 + link_libvpx(tg_owt)
174 ++link_crc32c(tg_owt)
175 +
176 + if (TG_OWT_BUILD_AUDIO_BACKENDS AND (UNIX AND NOT APPLE))
177 + link_libalsa(tg_owt)
178 +@@ -2599,7 +2599,6 @@
179 +
180 + set(export_targets
181 + ${tg_owt_export}
182 +- libcrc32c
183 + libpffft
184 + librnnoise
185 + libsrtp
186 +@@ -2617,6 +2616,9 @@
187 + if (NOT LIBOPENH264_FOUND)
188 + list(APPEND export_targets libopenh264)
189 + endif()
190 ++if (NOT Crc32c_FOUND)
191 ++ list(APPEND export_targets libcrc32c)
192 ++endif()
193 +
194 + export(
195 + TARGETS ${export_targets}
196 +--- tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41.orig/cmake/external.cmake
197 ++++ tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41/cmake/external.cmake
198 +@@ -166,6 +166,20 @@
199 + endif()
200 + endfunction()
201 +
202 ++# crc32c
203 ++function(link_crc32c target_name)
204 ++ if (TG_OWT_PACKAGED_BUILD)
205 ++ find_package(Crc32c)
206 ++ set(Crc32c_FOUND ${Crc32c_FOUND} PARENT_SCOPE)
207 ++ if (Crc32c_FOUND)
208 ++ target_link_libraries(${target_name} PRIVATE Crc32c::crc32c)
209 ++ endif()
210 ++ endif()
211 ++ if (NOT Crc32c_FOUND)
212 ++ target_link_libraries(${target_name} PRIVATE tg_owt::libcrc32c)
213 ++ endif()
214 ++endfunction()
215 ++
216 + function(link_glib target_name)
217 + find_package(PkgConfig REQUIRED)
218 + pkg_check_modules(GLIB2 REQUIRED glib-2.0)
219 +--- tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41.orig/src/net/dcsctp/packet/crc32c.cc
220 ++++ tg_owt-10d5f4bf77333ef6b43516f90d2ce13273255f41/src/net/dcsctp/packet/crc32c.cc
221 +@@ -11,7 +11,7 @@
222 +
223 + #include <cstdint>
224 +
225 +-#include "third_party/crc32c/src/include/crc32c/crc32c.h"
226 ++#include "crc32c/crc32c.h"
227 +
228 + namespace dcsctp {
229 +
230
231 diff --git a/media-libs/tg_owt/tg_owt-0_pre20220507.ebuild b/media-libs/tg_owt/tg_owt-0_pre20220507.ebuild
232 new file mode 100644
233 index 000000000000..384b3d7cafce
234 --- /dev/null
235 +++ b/media-libs/tg_owt/tg_owt-0_pre20220507.ebuild
236 @@ -0,0 +1,118 @@
237 +# Copyright 2020-2022 Gentoo Authors
238 +# Distributed under the terms of the GNU General Public License v2
239 +
240 +EAPI=8
241 +
242 +inherit cmake flag-o-matic
243 +
244 +DESCRIPTION="WebRTC build for Telegram"
245 +HOMEPAGE="https://github.com/desktop-app/tg_owt"
246 +
247 +TG_OWT_COMMIT="10d5f4bf77333ef6b43516f90d2ce13273255f41"
248 +LIBYUV_COMMIT="ad890067f661dc747a975bc55ba3767fe30d4452"
249 +SRC_URI="https://github.com/desktop-app/tg_owt/archive/${TG_OWT_COMMIT}.tar.gz -> ${P}.tar.gz
250 + https://archive.org/download/libyuv-${LIBYUV_COMMIT}.tar/libyuv-${LIBYUV_COMMIT}.tar.gz"
251 +S="${WORKDIR}/${PN}-${TG_OWT_COMMIT}"
252 +# Fetch libyuv archive from: https://chromium.googlesource.com/libyuv/libyuv/+archive/${LIBYUV_COMMIT}.tar.gz
253 +
254 +LICENSE="BSD"
255 +SLOT="0/${PV##*pre}"
256 +KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
257 +IUSE="screencast +X"
258 +
259 +# This package's USE flags may change the ABI and require a rebuild of
260 +# dependent pacakges. As such, one should make sure to depend on
261 +# media-libs/tg_owt[x=,y=,z=] for any package that uses this.
262 +
263 +# Bundled libs:
264 +# - libyuv (no stable versioning, www-client/chromium and media-libs/libvpx bundle it)
265 +# - libsrtp (project uses private APIs)
266 +# - pffft (no stable versioning, patched)
267 +DEPEND="
268 + >=dev-cpp/abseil-cpp-20211102.0:=[cxx17(+)]
269 + dev-libs/openssl:=
270 + dev-libs/protobuf:=
271 + media-libs/libjpeg-turbo:=
272 + >=media-libs/libvpx-1.10.0:=
273 + media-libs/openh264:=
274 + media-libs/opus
275 + media-video/ffmpeg:=
276 + dev-libs/crc32c
277 + screencast? (
278 + dev-libs/glib:2
279 + media-video/pipewire:=
280 + )
281 + X? (
282 + x11-libs/libX11
283 + x11-libs/libXcomposite
284 + x11-libs/libXdamage
285 + x11-libs/libXext
286 + x11-libs/libXfixes
287 + x11-libs/libXrender
288 + x11-libs/libXrandr
289 + x11-libs/libXtst
290 + )
291 +"
292 +RDEPEND="${DEPEND}"
293 +BDEPEND="virtual/pkgconfig"
294 +
295 +PATCHES=(
296 + "${FILESDIR}/tg_owt-0_pre20220507-allow-disabling-X11.patch"
297 + "${FILESDIR}/tg_owt-0_pre20220507-unbundle-crc32c.patch"
298 +)
299 +
300 +src_unpack() {
301 + unpack "${P}.tar.gz"
302 + cd "${S}/src/third_party/libyuv" || die
303 + unpack "libyuv-${LIBYUV_COMMIT}.tar.gz"
304 +}
305 +
306 +src_prepare() {
307 + # libopenh264 has GENERATED files with yasm that aren't excluded by
308 + # EXCLUDE_FROM_ALL, and I have no clue how to avoid this.
309 + # These source files aren't used with system-openh264, anyway.
310 + sed -i '/include(cmake\/libopenh264.cmake)/d' CMakeLists.txt || die
311 +
312 + # The sources for libcrc32c aren't available, avoid needing them
313 + sed -i '/include(cmake\/libcrc32c.cmake)/d' CMakeLists.txt || die
314 +
315 + # "lol" said the scorpion, "lmao"
316 + sed -i '/if (BUILD_SHARED_LIBS)/{n;n;s/WARNING/DEBUG/}' CMakeLists.txt || die
317 +
318 + cmake_src_prepare
319 +}
320 +
321 +src_configure() {
322 + # Defined by -DCMAKE_BUILD_TYPE=Release, avoids crashes
323 + # see https://bugs.gentoo.org/754012
324 + # EAPI 8 still wipes this flag.
325 + append-cppflags '-DNDEBUG'
326 +
327 + local mycmakeargs=(
328 + -DTG_OWT_USE_X11=$(usex X)
329 + -DTG_OWT_USE_PIPEWIRE=$(usex screencast)
330 + )
331 + cmake_src_configure
332 +}
333 +
334 +src_install() {
335 + cmake_src_install
336 +
337 + # Save about 15MB of useless headers
338 + rm -r "${ED}/usr/include/tg_owt/rtc_base/third_party" || die
339 + rm -r "${ED}/usr/include/tg_owt/common_audio/third_party" || die
340 + rm -r "${ED}/usr/include/tg_owt/modules/third_party" || die
341 + rm -r "${ED}/usr/include/tg_owt/third_party" || die
342 +
343 + # Install a few headers anyway, as required by net-im/telegram-desktop...
344 + local headers=(
345 + third_party/libyuv/include
346 + rtc_base/third_party/sigslot
347 + rtc_base/third_party/base64
348 + )
349 + for dir in "${headers[@]}"; do
350 + pushd "${S}/src/${dir}" > /dev/null || die
351 + find -type f -name "*.h" -exec install -Dm644 '{}' "${ED}/usr/include/tg_owt/${dir}/{}" \; || die
352 + popd > /dev/null || die
353 + done
354 +}