From 1982f9a2c178ce347ec13a7b3b4abb174151abed Mon Sep 17 00:00:00 2001 From: Xiangfu Date: Tue, 17 Apr 2012 09:59:09 +0800 Subject: [PATCH] add mjpg-streamer config --- .../data/m1/files/etc/config/firewall | 6 ++ .../data/m1/files/etc/init.d/mjpg-streamer | 56 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 milkymist-files/data/m1/files/etc/init.d/mjpg-streamer diff --git a/milkymist-files/data/m1/files/etc/config/firewall b/milkymist-files/data/m1/files/etc/config/firewall index 46ec945..bde345c 100644 --- a/milkymist-files/data/m1/files/etc/config/firewall +++ b/milkymist-files/data/m1/files/etc/config/firewall @@ -139,3 +139,9 @@ config 'redirect' option 'dest_port' '23' option 'name' 'telnet' +config rule + option target 'ACCEPT' + option src 'wan' + option proto 'tcp udp' + option dest_port '8080' + option name 'mjpg' diff --git a/milkymist-files/data/m1/files/etc/init.d/mjpg-streamer b/milkymist-files/data/m1/files/etc/init.d/mjpg-streamer new file mode 100755 index 0000000..a37e8f0 --- /dev/null +++ b/milkymist-files/data/m1/files/etc/init.d/mjpg-streamer @@ -0,0 +1,56 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2011 OpenWrt.org + +START=50 + +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 -y" \ + --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_foreach start_instance 'mjpg-streamer' +} + +stop() { + config_load 'mjpg-streamer' + config_foreach stop_instance 'mjpg-streamer' +}