From defe5eb6fe71edc41689f2ed08d4c9ad2e7e15aa Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Wed, 10 Apr 2019 16:46:01 +0300 Subject: [PATCH] openwrt package --- .bumpversion.cfg | 4 +++ pkg/openwrt/Makefile | 45 ++++++++++++++++++++++++ pkg/openwrt/files/ustreamer.config | 20 +++++++++++ pkg/openwrt/files/ustreamer.init | 55 ++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 pkg/openwrt/Makefile create mode 100644 pkg/openwrt/files/ustreamer.config create mode 100644 pkg/openwrt/files/ustreamer.init diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0472606..e2fdd74 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -14,3 +14,7 @@ replace = VERSION "{new_version}" search = pkgver={current_version} replace = pkgver={new_version} +[bumpversion:file:pkg/openwrt/Makefile] +search = PKG_VERSION:={current_version} +replace = PKG_VERSION:={new_version} + diff --git a/pkg/openwrt/Makefile b/pkg/openwrt/Makefile new file mode 100644 index 0000000..f657872 --- /dev/null +++ b/pkg/openwrt/Makefile @@ -0,0 +1,45 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=ustreamer +PKG_VERSION:=0.67 +PKG_RELEASE:=1 +PKG_MAINTAINER:=Maxim Devaev + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/pi-kvm/ustreamer.git +PKG_SOURCE_VERSION:=v$(PKG_VERSION) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) + +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + +define Package/ustreamer + SECTION:=multimedia + CATEGORY:=Multimedia + TITLE:=uStreamer + DEPENDS:=+libpthread +libjpeg +libv4l +libuuid +libevent2 +libevent2-core +libevent2-extra +libevent2-pthreads + URL:=https://github.com/pi-kvm/ustreamer +endef + +define Package/ustreamer/description + µStreamer - Lightweight and fast MJPG-HTTP streamer +endef + +define Package/ustreamer/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ustreamer $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(CP) ./files/ustreamer.config $(1)/etc/config/ustreamer + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/ustreamer.init $(1)/etc/init.d/ustreamer +endef + +$(eval $(call BuildPackage,ustreamer)) diff --git a/pkg/openwrt/files/ustreamer.config b/pkg/openwrt/files/ustreamer.config new file mode 100644 index 0000000..699fd9d --- /dev/null +++ b/pkg/openwrt/files/ustreamer.config @@ -0,0 +1,20 @@ + +config ustreamer + option enabled '0' + + option device '/dev/video0' + option device_timeout '5' + option input '0' + + option width '640' + option height '480' + option format 'YUYV' + option quality '80' + option desired_fps '0' + option encoder 'CPU' + + option host '::' + option port '8080' + option static '' + option user '' + option password '' diff --git a/pkg/openwrt/files/ustreamer.init b/pkg/openwrt/files/ustreamer.init new file mode 100644 index 0000000..4a15b39 --- /dev/null +++ b/pkg/openwrt/files/ustreamer.init @@ -0,0 +1,55 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2019 OpenWrt.org + +START=90 +STOP=10 + +USE_PROCD=1 +PROG=/usr/bin/ustreamer + +getcfg() { + config_get value ustreamer $1 $2 + return "$value" +} + +start_instance() { + config_get_bool enabled ustreamer enabled 0 + [ "$enabled" -eq 0 ] && return + + local options="" + + options="$options --device='`getcfg device /dev/video0`'" + options="$options --device-timeout='`getcfg device_timeout 5`'" + options="$options --input='`getcfg input 0`'" + + options="$options --width='`getcfg width 640`'" + options="$options --height='`getcfg height 480`'" + options="$options --format='`getcfg format YUYV`'" + options="$options --quality='`getcfg quality 80`'" + options="$options --desired-fps='`getcfg desired_fps 0`'" + options="$options --encoder='`getcfg encoder CPU`'" + + options="$options --host='`getcfg host '::'`'" + local port=`getcfg port 8080` + options="$options --port='$port'" + options="$options --static='`getcfg static ''`'" + options="$options --user='`getcfg user ''`'" + options="$options --passwd='`getcfg password ''`'" + + config-get-bool opt_slowdown ustreamer slowdown 1 + [ "$slowdown" -eq 1 ] && options="$options --slowdown" + + procd_open_instance + procd_set_param command "$PROG" $options + procd_add_mdns http tcp "$port" daemon=ustreamer + procd_close_instance +} + +start_service() { + config_load ustreamer + config_foreach start_instance ustreamer +} + +service_triggers() { + procd_add_reload_trigger ustreamer +}