tvheadend: multiple improvements 16475/head
authorMarius Dinu <m95d+git@psihoexpert.ro>
Fri, 27 Aug 2021 07:21:53 +0000 (10:21 +0300)
committerMarius Dinu <m95d+git@psihoexpert.ro>
Fri, 27 Aug 2021 15:44:29 +0000 (18:44 +0300)
- 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 <m95d+git@psihoexpert.ro>
multimedia/tvheadend/Config.in
multimedia/tvheadend/Makefile
multimedia/tvheadend/files/dvb.hotplug [new file with mode: 0644]
multimedia/tvheadend/files/tvheadend.init

index 61a3774a8b51268f2f165812540eb95f6fa98be8..5ed49e266f75175e758741bc5686e1b97cc6da87 100644 (file)
-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.
index ebcc8f586811dd327ed924ab29895fe425d2aa50..f2df7070c9128ccd5724bb5b3c2c5c03cc0948fd 100644 (file)
@@ -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 <m95d+git@psihoexpert.ro>
 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 (file)
index 0000000..8736aec
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+case "$ACTION" in
+  add)
+    chown -R root:dvb /dev/dvb/*/*
+    chmod -R 660 /dev/dvb/*/*
+    ;;
+esac
index 31702e1087ae4f684e571b97eb8826dfcc9f27ee..573ef33ad275997eccb2a5c54c5f23aa582c62f3 100644 (file)
@@ -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
 }