aboutsummaryrefslogtreecommitdiff
blob: 19ab175580d0865461c1d761430503f50f4b5ed4 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright 2019-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit desktop eutils linux-mod readme.gentoo-r1 xdg

DESCRIPTION="Use android phone as webcam, using a v4l device driver and app"
HOMEPAGE="https://www.dev47apps.com/droidcam/linux/
	https://github.com/aramg/droidcam"
SRC_URI="https://github.com/aramg/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

KEYWORDS="~amd64"
LICENSE="GPL-2"
SLOT="0"

IUSE="gtk"

# Requires connection to phone
RESTRICT="test"

DEPEND="
	app-pda/libplist
	app-pda/libusbmuxd
	dev-libs/glib
	dev-libs/libappindicator:3
	dev-libs/libxml2
	dev-util/android-tools
	media-libs/alsa-lib
	media-libs/libjpeg-turbo
	>=media-libs/speex-1.2.0-r1
	media-video/ffmpeg
	gtk? (
		dev-cpp/gtkmm:3.0
		x11-libs/gdk-pixbuf
		x11-libs/gtk+:3
		x11-libs/libX11
		x11-libs/pango
	)
"

BDEPEND="virtual/pkgconfig"

RDEPEND="${DEPEND}"

DOCS=( README.md README-DKMS.md )
DISABLE_AUTOFORMATTING="true"
DOC_CONTENTS="
		The default resolution for v4l2loopback-dc[1] is 640x480. You can override the
		value by copying droidcam.conf.default to /etc/modprobe.d/droidcam.conf
		and modifying 'width' and 'height'.
		[1] https://github.com/aramg/droidcam/issues/56
"

BUILD_TARGETS="all"
MODULE_NAMES="v4l2loopback-dc(video:${S}/v4l2loopback:${S}/v4l2loopback)"
MODULESD_V4L2LOOPBACK_DC_ENABLED="yes"

CONFIG_CHECK="~SND_ALOOP VIDEO_DEV MEDIA_SUPPORT MEDIA_CAMERA_SUPPORT"
ERROR_SND_ALOOP="CONFIG_SND_ALOOP is required for audio support"

PATCHES="${FILESDIR}/${PN}-makefile-fixes.patch"

src_prepare() {
	if ! use gtk ; then
		sed -i -e '/cflags gtk+/d' Makefile || die
	else
		# remove path and extension from icon entry
		sed -i -e 's/Icon=\/opt\/droidcam-icon.png/Icon=droidcam/g' droidcam.desktop || die
		xdg_src_prepare
	fi
	linux-mod_pkg_setup
}

src_configure() {
	set_arch_to_kernel
	default
}

src_compile() {
	if use gtk ; then
		emake droidcam
	fi
	emake droidcam-cli
	KERNELRELEASE="${KV_FULL}" linux-mod_src_compile
}

src_test() {
	pushd "v4l2loopback"
	default
	./test || die
	popd
}

pkg_preinst() {
	xdg_pkg_preinst
}

src_install() {
	if use gtk ; then
		dobin droidcam
		newicon -s 32 icon.png droidcam.png
		newicon -s 48 icon2.png droidcam.png
		domenu droidcam.desktop
	fi
	dobin "${PN}-cli"

	readme.gentoo_create_doc

	# The cli and gui do not auto load the module if unloaded (why not tho?)
	# so we just put it in modules-load.d to make sure it always works
	insinto /etc/modules-load.d
	doins "${FILESDIR}"/${PN}-video.conf
	if linux_config_exists ; then
		if linux_chkconfig_module SND_ALOOP ; then
			doins "${FILESDIR}"/${PN}-audio.conf
		fi
	fi

	newdoc "${FILESDIR}"/${PN}-modprobe.conf ${PN}.conf.default
	einstalldocs
	linux-mod_src_install
}

pkg_postinst() {
	if use gtk ; then
		xdg_pkg_postinst
	else
		elog
		elog "Only droidcam-cli has been installed since 'gtk' flag was not set"
		elog
	fi

	linux-mod_pkg_postinst
	readme.gentoo_print_elog

	elog "Links to the Android/iPhone/iPad apps can be reached at"
	elog "https://www.dev47apps.com/"
}

pkg_postrm() {
	if use gtk ; then
		xdg_pkg_postrm
	fi

	linux-mod_pkg_postrm
}