packages/mpjpg-streamer: use new service functions
authorNicolas Thill <nico@openwrt.org>
Wed, 16 Nov 2011 09:44:16 +0000 (09:44 +0000)
committerNicolas Thill <nico@openwrt.org>
Wed, 16 Nov 2011 09:44:16 +0000 (09:44 +0000)
SVN-Revision: 29175

multimedia/mjpg-streamer/Makefile
multimedia/mjpg-streamer/files/mjpg-streamer.config
multimedia/mjpg-streamer/files/mjpg-streamer.init

index 5f59a174464f8b101ab7ded0f29bf28364e1f140..768edebe3c6eaf0dd101d99dec4e63564708f3b4 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=mjpg-streamer
 PKG_REV:=148
 PKG_VERSION:=r$(PKG_REV)
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer/mjpg-streamer/
index 1b1f7d7f98d1774abf36e752e1c0ca4719ebc5d4..5691c3ae8f089184e525a9528ad98f93f65ed095 100644 (file)
@@ -1,6 +1,6 @@
 config mjpg-streamer core
+       option enabled          "0"
        option device           "/dev/video0"
        option resolution       "640x480"
        option fps              "5"
        option port             "8080"
-       option enabled          "true"
index 7b92c899d960f9bc90d5c901d9b6b063ebbc4d89..5a45968525780ce00cd632d6012aa1df3ac10897 100644 (file)
@@ -1,23 +1,56 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2009 OpenWrt.org
+# Copyright (C) 2009-2011 OpenWrt.org
+
 START=50
 
-SSD=start-stop-daemon
-NAME=mjpg_streamer
-PIDF=/var/run/$NAME.pid
-PROG=/usr/bin/$NAME
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+PROG=/usr/bin/mjpg_streamer
+
+error() {
+       echo "${initscript}:" "$@" 1>&2
+}
+
+section_enabled() {
+       config_get_bool enabled "$1" 'enabled' 0
+       [ $enabled -gt 0 ]
+}
+
+start_instance() {
+       local s="$1"
+
+       section_enabled "$s" || return 1
+
+       config_get device "$s" 'device'
+       config_get resolution "$s" 'resolution'
+       config_get fps "$s" 'fps'
+       config_get port "$s" 'port'
+
+       [ -c "$device" ] || {
+               error "device '$device' does not exist"
+               return 1
+       }
+
+       service_start /usr/bin/mjpg_streamer --input "input_uvc.so \
+               --device $device --fps $fps --resolution $resolution" \
+               --output "output_http.so --port $port"
+}
+
+stop_instance() {
+       local s="$1"
+
+       section_enabled "$s" || return 1
+
+       service_stop /usr/bin/mjpg_streamer
+}
 
 start() {
-       config_load mjpg-streamer
-       config_get device core device
-       config_get resolution core resolution
-       config_get fps core fps
-       config_get port core port
-       config_get_bool enabled core enabled
-       [ $enabled -gt 0 -a -c $device ] && sleep 3 && $SSD -S -m -p $PIDF -q -x $PROG -- --input "input_uvc.so --device $device --fps $fps --resolution $resolution" --output "output_http.so --port $port" &
+       config_load 'mjpg-streamer'
+       config_foreach start_instance 'mjpg-streamer'
 }
 
 stop() {
-       $SSD -K -p $PIDF
+       config_load 'mjpg-streamer'
+       config_foreach stop_instance 'mjpg-streamer'
 }
-