summaryrefslogtreecommitdiff
blob: 43dd4267f6c0799ab047eda2c32407e38c08148b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 2020-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit cmake

TG_OWT_COMMIT="7f965710b93c4dadd7e6f1ac739e708694df7929"
LIBVPX_COMMIT="5b63f0f821e94f8072eb483014cfc33b05978bb9"
LIBYUV_COMMIT="ad890067f661dc747a975bc55ba3767fe30d4452"

DESCRIPTION="WebRTC build for Telegram"
HOMEPAGE="https://github.com/desktop-app/tg_owt"
SRC_URI="https://github.com/desktop-app/tg_owt/archive/${TG_OWT_COMMIT}.tar.gz -> ${P}.tar.gz
	https://github.com/webmproject/libvpx/archive/${LIBVPX_COMMIT}.tar.gz -> libvpx-${LIBVPX_COMMIT}.tar.gz
	https://archive.org/download/libyuv-${LIBYUV_COMMIT}.tar/libyuv-${LIBYUV_COMMIT}.tar.gz"
# Fetch libyuv archive from: https://chromium.googlesource.com/libyuv/libyuv/+archive/${LIBYUV_COMMIT}.tar.gz

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~ppc64"
IUSE="pulseaudio"

# Bundled libs:
# - libvpx (media-libs/libvpx, requires git version, post v1.9.0)
# - libyuv (no stable versioning)
# - libsrtp (project uses private APIs)
# - pffft (no stable versioning, patched)
# Bundled libs that will be unbundled at a later date (upstream support is in the works):
# - net-libs/usrsctp
# - dev-libs/libevent:=
# - dev-cpp/abseil-cpp
# - media-libs/openh264:=
# dev-lang/yasm is required for libvpx
# media-libs/libjpeg-turbo is required for libyuv
DEPEND="
	dev-libs/openssl:=
	dev-libs/protobuf:=
	media-libs/alsa-lib
	media-libs/libjpeg-turbo:=
	media-libs/opus
	media-video/ffmpeg:=
	!pulseaudio? ( media-sound/apulse[sdk] )
	pulseaudio? ( media-sound/pulseaudio )
"
RDEPEND="${DEPEND}"
BDEPEND="
	virtual/pkgconfig
	amd64? ( dev-lang/yasm )
"

S="${WORKDIR}/${PN}-${TG_OWT_COMMIT}"

src_unpack() {
	unpack "${P}.tar.gz"
	unpack "libvpx-${LIBVPX_COMMIT}.tar.gz"
	mv -T "libvpx-${LIBVPX_COMMIT}" "$S/src/third_party/libvpx/source/libvpx" || die
	cd "$S/src/third_party/libyuv" || die
	unpack "libyuv-${LIBYUV_COMMIT}.tar.gz"
}

src_prepare() {
	# Can cause race conditions when no webcam is available or webcam is blocked
	# See https://bugs.debian.org/982556
	sed -i -e 's/#ifndef NO_MAIN_THREAD_WRAPPING/#if 0/' src/rtc_base/thread.cc || die

	# Causes forced inclusion of SSE2, so we strip it out on x86* arches
	# https://github.com/desktop-app/tg_owt/pull/57
	if ! use amd64 && ! use x86; then
		sed -i '/modules\/desktop_capture/d' CMakeLists.txt || die
	fi

	cmake_src_prepare
}

src_configure() {
	# Defined by -DCMAKE_BUILD_TYPE=Release, avoids crashes
	# see https://bugs.gentoo.org/754012
	append-cppflags '-DNDEBUG'

	append-flags '-fPIC'
	cmake_src_configure
}