From 4a387bc568d25697c25575fdbd95d6d7d96bb9a8 Mon Sep 17 00:00:00 2001 From: Marius Dinu Date: Fri, 27 Aug 2021 10:21:53 +0300 Subject: [PATCH] tvheadend: multiple improvements - Added menuconfig options: - TV sources and protocols: SAT>IP, IPTV, HDHomeRun - SoftCAM (3 options) - Image cache (default changed to OFF) - Trace debug option (default changed to OFF) - Added menuconfig descriptions. - Removed codecs. - Made PIE option dependent on global OpenWRT PIE setting. - Run as regular user, not root. - Added USB hotplug script to change DVB tuners permissions. - Fixed a first-start bug(?) that I encountered: admin account created but not saved. Signed-off-by: Marius Dinu --- multimedia/tvheadend/Config.in | 94 +++++++++++++++++++++-- multimedia/tvheadend/Makefile | 64 ++++++++++++++- multimedia/tvheadend/files/dvb.hotplug | 7 ++ multimedia/tvheadend/files/tvheadend.init | 19 ++++- 4 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 multimedia/tvheadend/files/dvb.hotplug diff --git a/multimedia/tvheadend/Config.in b/multimedia/tvheadend/Config.in index 61a3774a8b..5ed49e266f 100644 --- a/multimedia/tvheadend/Config.in +++ b/multimedia/tvheadend/Config.in @@ -1,17 +1,101 @@ -config TVHEADEND_CWC_SUPPORT - bool "NewCamd support" - default y +comment "Input & output support" config TVHEADEND_LINUXDVB_SUPPORT - bool "Linux DVB support" + bool "DVB tuners" default y + help + Include support for DVB tuners. + Note: Kernel driver(s) and firmware must also be installed. config TVHEADEND_DVBSCAN_SUPPORT bool "Fetch DVB-scan data" depends on TVHEADEND_LINUXDVB_SUPPORT default TVHEADEND_LINUXDVB_SUPPORT + help + Download and include DVB scan tables. + +config TVHEADEND_IPTV + bool "IPTV client" + default y + help + Include IP-TV client. + +config TVHEADEND_SATIP_CLIENT + bool "SAT>IP client" + default y + help + Include SAT>IP client. This allows tvheadend to receive streams from a SAT>IP server. + SAT>IP is a client-server communication protocol in which SAT>IP servers, + connected to one or more DVB broadcast sources, send the program requested + by an SAT>IP client over an IP based network. + The main difference of SAT>IP to other IP-based TV distribution systems + such as IP-TV and DLNA is that the SAT>IP client does not select a program + from a server specific list, but has to specify the DVB reception parameters + such as the signal source, frequency, polarisation, modulation, PIDs and others. + +config TVHEADEND_SATIP_SERVER + bool "SAT>IP server" + default y + help + Include SAT>IP server. This allows tvheadend to stream to SAT>IP clients. + SAT>IP is a client-server communication protocol in which SAT>IP servers, + connected to one or more DVB broadcast sources, send the program requested + by an SAT>IP client over an IP based network. + The main difference of SAT>IP to other IP-based TV distribution systems + such as IP-TV and DLNA is that the SAT>IP client does not select a program + from a server specific list, but has to specify the DVB reception parameters + such as the signal source, frequency, polarisation, modulation, PIDs and others. + +config TVHEADEND_HDHOMERUN_CLIENT + bool "HDHomeRun client" + default y + help + Include HDHomeRun client. + HDHomeRun is a network-attached, digital television tuner box. + +comment "SoftCAM (Software Conditional Access Module)" + +config TVHEADEND_CWC_SUPPORT + bool "CWC newcamd" + default y + help + Support descrambling using Code Word Client newcamd protocol. + +config TVHEADEND_CAPMT_SUPPORT + bool "CWC capmnt" + default y + help + Support descrambling using Code Word Client capmnt (Linux Network DVBAPI) protocol. + +config TVHEADEND_CONSTCW_SUPPORT + bool "CCW" + default y + help + Support descrambling using Constant Code Word. + +comment "Other options" config TVHEADEND_AVAHI_SUPPORT - bool "Avahi client support" + bool "Avahi client" select PACKAGE_libavahi-client default n + help + Enables the opensource implementation of Apple's zero configuration protocol. + Tvheadend will advertise itself on the network using this protocol. + +config TVHEADEND_IMAGECACHE + bool "Image cache" + default n + help + Support caching TV station logos and other images on disk. + Note: Activating disk cache will increase fash memory wear. + Selecting this option does not automatically enable disk caching. It only includes support for it. + +config TVHEADEND_TRACE + bool "Low level debug trace" + default n + help + Support low level debug trace for tvheadend subsystems. + For a list of available subsystems, run "tvheadend --subsystems" in OpenWRT console. + Note: Selecting this option does not automatically enable trace logging. + It only includes support for --trace command line option and GUI. diff --git a/multimedia/tvheadend/Makefile b/multimedia/tvheadend/Makefile index ebcc8f5868..f2df7070c9 100644 --- a/multimedia/tvheadend/Makefile +++ b/multimedia/tvheadend/Makefile @@ -30,6 +30,7 @@ define Package/tvheadend CATEGORY:=Multimedia TITLE:=Tvheadend is a TV streaming server for Linux DEPENDS:=+libopenssl +librt +zlib +libffi +TVHEADEND_AVAHI_SUPPORT:libavahi-client $(ICONV_DEPENDS) + USERID:=tvheadend:dvb URL:=https://tvheadend.org MAINTAINER:=Marius Dinu endef @@ -48,10 +49,12 @@ define Package/tvheadend/config endmenu endef -ifeq ($(CONFIG_TVHEADEND_CWC_SUPPORT),) - CONFIGURE_ARGS += --disable-cwc +# Generic build options +ifneq ($(CONFIG_PKG_ASLR_PIE_NONE),) + CONFIGURE_ARGS += --disable-pie endif +# TV sources ifeq ($(CONFIG_TVHEADEND_LINUXDVB_SUPPORT),) CONFIGURE_ARGS += --disable-linuxdvb endif @@ -60,17 +63,72 @@ ifeq ($(CONFIG_TVHEADEND_DVBSCAN_SUPPORT),) CONFIGURE_ARGS += --disable-dvbscan endif +ifeq ($(CONFIG_TVHEADEND_IPTV),) + CONFIGURE_ARGS += --disable-iptv +endif + +ifeq ($(CONFIG_TVHEADEND_SATIP_SERVER),) + CONFIGURE_ARGS += --disable-satip_server +endif + +ifeq ($(CONFIG_TVHEADEND_SATIP_CLIENT),) + CONFIGURE_ARGS += --disable-satip_client +endif + +ifeq ($(CONFIG_TVHEADEND_HDHOMERUN_CLIENT),) + CONFIGURE_ARGS += --disable-hdhomerun_static +else + CONFIGURE_ARGS += --enable-hdhomerun_client +endif + +# Descrambling +ifeq ($(CONFIG_TVHEADEND_CWC_SUPPORT),) + CONFIGURE_ARGS += --disable-cwc +endif + +ifeq ($(CONFIG_TVHEADEND_CAPMT_SUPPORT),) + CONFIGURE_ARGS += --disable-capmt +endif + +ifeq ($(CONFIG_TVHEADEND_CCW_SUPPORT),) + CONFIGURE_ARGS += --disable-constcw +endif + +# Other options ifeq ($(CONFIG_TVHEADEND_AVAHI_SUPPORT),) CONFIGURE_ARGS += --disable-avahi else CONFIGURE_ARGS += --enable-avahi endif +ifeq ($(CONFIG_TVHEADEND_IMAGECACHE),) + CONFIGURE_ARGS += --disable-imagecache +else + CONFIGURE_ARGS += --enable-imagecache +endif + +ifeq ($(CONFIG_TVHEADEND_TRACE),) + CONFIGURE_ARGS += --disable-trace +endif + +# libav and ffmpeg are broken, so remove codecs too. CONFIGURE_ARGS += \ --arch=$(ARCH) \ --disable-dbus_1 \ --disable-libav \ --disable-ffmpeg_static \ + --disable-libx264 \ + --disable-libx264_static \ + --disable-libx265 \ + --disable-libx265_static \ + --disable-libvpx \ + --disable-libvpx_static \ + --disable-libtheora \ + --disable-libtheora_static \ + --disable-libvorbis \ + --disable-libvorbis_static \ + --disable-libfdkaac \ + --disable-libfdkaac_static \ --enable-bundle \ --nowerror=unused-variable @@ -89,6 +147,8 @@ define Package/tvheadend/install $(INSTALL_BIN) ./files/tvheadend.init $(1)/etc/init.d/tvheadend $(INSTALL_DIR) $(1)/etc/config $(INSTALL_CONF) ./files/tvheadend.config $(1)/etc/config/tvheadend + $(INSTALL_DIR) $(1)/etc/hotplug.d/usb + $(INSTALL_BIN) ./files/dvb.hotplug $(1)/etc/hotplug.d/usb/50-dvb $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/build.linux/tvheadend $(1)/usr/bin/ diff --git a/multimedia/tvheadend/files/dvb.hotplug b/multimedia/tvheadend/files/dvb.hotplug new file mode 100644 index 0000000000..8736aecd28 --- /dev/null +++ b/multimedia/tvheadend/files/dvb.hotplug @@ -0,0 +1,7 @@ +#!/bin/sh +case "$ACTION" in + add) + chown -R root:dvb /dev/dvb/*/* + chmod -R 660 /dev/dvb/*/* + ;; +esac diff --git a/multimedia/tvheadend/files/tvheadend.init b/multimedia/tvheadend/files/tvheadend.init index 31702e1087..573ef33ad2 100644 --- a/multimedia/tvheadend/files/tvheadend.init +++ b/multimedia/tvheadend/files/tvheadend.init @@ -9,8 +9,22 @@ PROG=/usr/bin/tvheadend TEMP_CONFIG=/tmp/tvheadend PERSISTENT_CONFIG=/etc/tvheadend +# If you change the user, update the owner of tvheadend configuration directory and files! +# If you change the group, update USB hotplug script for DVB devices in /dev/hotplug.d/usb/ +# otherwise, tvheadend won't have permissions to open newly connected tuners! +# Also update all other packages that use the dvb group. +TVH_USER=tvheadend +TVH_GROUP=dvb + + execute_first_run() { - "$PROG" -c "$1" -B -C -A >/dev/null 2>&1 + mkdir -p "$1" + chown -R $TVH_USER "$1" + # This should create a new configuration including an admin account with no name and no password, + # but it aborts (-A) without saving it: + #"$PROG" -c "$1" -B -C -A -u $TVH_USER -g $TVH_GROUP >/dev/null 2>&1 + # Instead, run it for 10s then kill it: + "$PROG" -c "$1" -B -C -u $TVH_USER -g $TVH_GROUP & TVH_PID=$! ; sleep 10 ; kill $TVH_PID ; sleep 2 } ensure_config_exists() { @@ -65,7 +79,8 @@ start_service() { ensure_config_exists procd_open_instance procd_set_param file /etc/config/tvheadend - procd_set_param command "$PROG" -B + chown -R root:$TVH_GROUP /dev/dvb/*/* + procd_set_param command "$PROG" -B -u $TVH_USER -g $TVH_GROUP load_uci_config procd_close_instance }