Browse Source

Merge pull request #114 from roger-/master

add mjpg-streamer
sbyx 10 years ago
parent
commit
7feec87677

+ 23
- 0
multimedia/mjpg-streamer/Config.in View File

@@ -0,0 +1,23 @@
1
+if PACKAGE_mjpg-streamer
2
+
3
+config MJPG_STREAMER_INPUT_FILE
4
+	bool "Install input file library"
5
+	default y
6
+
7
+config MJPG_STREAMER_INPUT_UVC
8
+	bool "Install input uvc library"
9
+	default y
10
+
11
+config MJPG_STREAMER_OUTPUT_FILE
12
+	bool "Install output file library"
13
+	default y
14
+
15
+config MJPG_STREAMER_OUTPUT_HTTP
16
+	bool "Install output http library"
17
+	default y
18
+
19
+config MJPG_STREAMER_WWW
20
+	bool "Install WWW files"
21
+	default y
22
+
23
+endif

+ 75
- 0
multimedia/mjpg-streamer/Makefile View File

@@ -0,0 +1,75 @@
1
+#
2
+# Copyright (C) 2006-2013 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=mjpg-streamer
11
+PKG_REV:=181
12
+PKG_VERSION:=r$(PKG_REV)
13
+PKG_RELEASE:=1
14
+PKG_MAINTAINER:=Roger D <rogerdammit@gmail.com>
15
+
16
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17
+PKG_SOURCE_URL:=https://svn.code.sf.net/p/mjpg-streamer/code/mjpg-streamer
18
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
19
+PKG_SOURCE_VERSION:=$(PKG_REV)
20
+PKG_SOURCE_PROTO:=svn
21
+
22
+include $(INCLUDE_DIR)/package.mk
23
+
24
+define Package/mjpg-streamer
25
+  SECTION:=multimedia
26
+  CATEGORY:=Multimedia
27
+  TITLE:=MJPG-streamer
28
+  DEPENDS:=+libpthread +libjpeg
29
+  URL:=http://mjpg-streamer.wiki.sourceforge.net/
30
+  MENU:=1
31
+endef
32
+
33
+define Package/mjpg-streamer/description
34
+ Streaming application for Linux-UVC compatible webcams
35
+endef
36
+
37
+define Package/mjpg-streamer/config
38
+  source "$(SOURCE)/Config.in"
39
+endef
40
+
41
+EXTRA_CFLAGS += $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS)
42
+
43
+define Package/mjpg-streamer/conffiles
44
+/etc/config/mjpg-streamer
45
+endef
46
+
47
+define Package/mjpg-streamer/install
48
+	$(INSTALL_DIR) $(1)/usr/bin
49
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mjpg_streamer $(1)/usr/bin/
50
+	$(INSTALL_DIR) $(1)/etc/config
51
+	$(CP) ./files/mjpg-streamer.config $(1)/etc/config/mjpg-streamer
52
+	$(INSTALL_DIR) $(1)/etc/init.d
53
+	$(INSTALL_BIN) ./files/mjpg-streamer.init $(1)/etc/init.d/mjpg-streamer
54
+	$(INSTALL_DIR) $(1)/etc/hotplug.d/usb
55
+	$(INSTALL_DATA) ./files/mjpg-streamer.hotplug $(1)/etc/hotplug.d/usb/20-mjpg-streamer
56
+	$(INSTALL_DIR) $(1)/usr/lib
57
+ifeq ($(CONFIG_MJPG_STREAMER_INPUT_FILE),y)
58
+	$(CP) $(PKG_BUILD_DIR)/input_file.so $(1)/usr/lib
59
+endif
60
+ifeq ($(CONFIG_MJPG_STREAMER_INPUT_UVC),y)
61
+	$(CP) $(PKG_BUILD_DIR)/input_uvc.so $(1)/usr/lib
62
+endif
63
+ifeq ($(CONFIG_MJPG_STREAMER_OUTPUT_FILE),y)
64
+	$(CP) $(PKG_BUILD_DIR)/output_file.so $(1)/usr/lib
65
+endif
66
+ifeq ($(CONFIG_MJPG_STREAMER_OUTPUT_HTTP),y)
67
+	$(CP) $(PKG_BUILD_DIR)/output_http.so $(1)/usr/lib
68
+endif
69
+ifeq ($(CONFIG_MJPG_STREAMER_WWW),y)
70
+	$(INSTALL_DIR) $(1)/www/webcam
71
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/www/* $(1)/www/webcam
72
+endif
73
+endef
74
+
75
+$(eval $(call BuildPackage,mjpg-streamer))

+ 11
- 0
multimedia/mjpg-streamer/files/mjpg-streamer.config View File

@@ -0,0 +1,11 @@
1
+config mjpg-streamer 'core'
2
+	option enabled '0'
3
+	option input 'uvc'
4
+	option output 'http'
5
+	option device '/dev/video0'
6
+	option resolution '640x480'
7
+	option fps '5'
8
+	option www '/www/webcam'
9
+	option port '8080'
10
+	option username 'openwrt'
11
+	option password 'openwrt'

+ 10
- 0
multimedia/mjpg-streamer/files/mjpg-streamer.hotplug View File

@@ -0,0 +1,10 @@
1
+case "$ACTION" in
2
+	add)
3
+		# start process
4
+		/etc/init.d/mjpg-streamer start
5
+		;;
6
+	remove)
7
+		# stop process
8
+		/etc/init.d/mjpg-streamer stop
9
+		;;
10
+esac

+ 87
- 0
multimedia/mjpg-streamer/files/mjpg-streamer.init View File

@@ -0,0 +1,87 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2009-2013 OpenWrt.org
3
+
4
+START=90
5
+STOP=10
6
+
7
+USE_PROCD=1
8
+PROG=/usr/bin/mjpg_streamer
9
+
10
+error() {
11
+	echo "${initscript}:" "$@" 1>&2
12
+}
13
+
14
+start_instance() {
15
+	local s="$1"
16
+
17
+	config_get_bool enabled "$1" 'enabled' 0
18
+	[ $enabled -eq 0 ] && return
19
+
20
+	config_get input "$s" 'input'
21
+	if [ -z "$input" ]; then
22
+		error "in section '$s' option input is missing"
23
+		return 1
24
+	fi
25
+
26
+	config_get output "$s" 'output'
27
+	if [ -z "$output" ]; then
28
+		error "in section '$s' option output is missing"
29
+		return 1
30
+	fi
31
+
32
+	local input_arg
33
+	if [ "x$input" = 'xuvc' ]; then
34
+		input_arg="input_uvc.so"
35
+
36
+		config_get device "$s" 'device'
37
+		if [ ! -c "$device" ]; then
38
+			error "device '$device' does not exist"
39
+			return 1
40
+		fi
41
+		input_arg="${input_arg} --device $device"
42
+
43
+		config_get fps "$s" 'fps'
44
+		[ -n "$fps" ] && input_arg="${input_arg} --fps $fps"
45
+
46
+		config_get resolution "$s" 'resolution'
47
+		[ -n "$resolution" ] && input_arg="${input_arg} --resolution $resolution"
48
+	fi
49
+
50
+	if [ -z "$input_arg" ]; then
51
+		error "unsuported input option '$input' in section '$s'"
52
+		return 1
53
+	fi
54
+
55
+	local output_arg
56
+	if [ "x$output" = 'xhttp' ]; then
57
+		output_arg="output_http.so"
58
+
59
+		config_get port "$s" 'port'
60
+		[ -n "$port" ] && output_arg="${output_arg} --port $port"
61
+
62
+		config_get www "$s" 'www'
63
+		[ -n "$www" ] && output_arg="${output_arg} --www $www"
64
+
65
+		config_get username "$s" 'username'
66
+		config_get password "$s" 'password'
67
+		[ -n "$username" ] && [ -n "$password" ] && output_arg="${output_arg} --credentials $username:$password"
68
+	fi
69
+
70
+	if [ -z "$output_arg" ]; then
71
+		error "unsuported output option '$output' in section '$s'"
72
+		return 1
73
+	fi
74
+
75
+	procd_open_instance
76
+	procd_set_param command "$PROG" --input "$input_arg" --output "$output_arg"
77
+	procd_close_instance
78
+}
79
+
80
+start_service() {
81
+	config_load 'mjpg-streamer'
82
+	config_foreach start_instance 'mjpg-streamer'
83
+}
84
+
85
+service_triggers() {
86
+	procd_add_reload_trigger 'mjpg-streamer'
87
+}