add chinese translations for luci-app-mjpg-streamer
[project/luci.git] / applications / luci-app-mjpg-streamer / luasrc / model / cbi / mjpg-streamer.lua
1 -- Copyright 2014 Roger D <rogerdammit@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 m = Map("mjpg-streamer", "MJPG-streamer", translate("mjpg streamer is a streaming application for Linux-UVC compatible webcams"))
5
6 --- General settings ---
7
8 section_gen = m:section(TypedSection, "mjpg-streamer", translate("General"))
9     section_gen.addremove=false
10     section_gen.anonymous=true
11
12 enabled = section_gen:option(Flag, "enabled", translate("Enabled"), translate("Enable MJPG-streamer"))
13
14 input = section_gen:option(ListValue, "input",  translate("Input plugin"))
15    input:depends("enabled", "1")
16    input:value("uvc", "UVC")
17    ---input:value("file", "File")
18    input.optional = false
19
20 output = section_gen:option(ListValue, "output",  translate("Output plugin"))
21    output:depends("enabled", "1")
22    output:value("http", "HTTP")
23    output:value("file", "File")
24    output.optional = false
25
26
27 --- Plugin settings ---
28
29 s = m:section(TypedSection, "mjpg-streamer", translate("Plugin settings"))
30     s.addremove=false
31     s.anonymous=true
32
33     s:tab("output_http", translate("HTTP output"))
34     s:tab("output_file", translate("File output"))
35     s:tab("input_uvc", translate("UVC input"))
36     ---s:tab("input_file", translate("File input"))
37
38
39 --- Input UVC settings ---
40
41 this_tab = "input_uvc"
42
43 device = s:taboption(this_tab, Value, "device", translate("Device"))
44     device.default="/dev/video0"
45     --device.datatype = "device"
46     device:value("/dev/video0", "/dev/video0")
47     device:value("/dev/video1", "/dev/video1")
48     device:value("/dev/video2", "/dev/video2")
49     device.optional = false
50
51 resolution = s:taboption(this_tab, Value, "resolution", translate("Resolution"))
52     resolution.default = "640x480"
53     resolution:value("320x240", "320x240")
54     resolution:value("640x480", "640x480")
55     resolution:value("800x600", "800x600")
56     resolution:value("864x480", "864x480")
57     resolution:value("960x544", "960x544")
58     resolution:value("960x720", "960x720")
59     resolution:value("1280x720", "1280x720")
60     resolution:value("1280x960", "1280x960")
61     resolution:value("1920x1080", "1920x1080")
62     resolution.optional = true
63
64 fps = s:taboption(this_tab, Value, "fps", translate("Frames per second"))
65     fps.datatype = "and(uinteger, min(1))"
66     fps.placeholder = "5"
67     fps.optional = true
68
69 yuv = s:taboption(this_tab, Flag, "yuv", translate("Enable YUYV format"), translate("Automatic disabling of MJPEG mode"))
70
71 quality = s:taboption(this_tab, Value, "quality", translate("JPEG compression quality"), translate("Set the quality in percent. This setting activates YUYV format, disables MJPEG"))
72     quality.datatype = "range(0, 100)"
73
74 minimum_size = s:taboption(this_tab, Value, "minimum_size", translate("Drop frames smaller then this limit"),translate("Set the minimum size if the webcam produces small-sized garbage frames. May happen under low light conditions"))
75     minimum_size.datatype = "uinteger"
76
77 no_dynctrl = s:taboption(this_tab, Flag, "no_dynctrl", translate("Don't initalize dynctrls"), translate("Do not initalize dynctrls of Linux-UVC driver"))
78
79 led = s:taboption(this_tab, ListValue, "led", translate("Led control"))
80     led:value("on", translate("On"))
81     led:value("off", translate("Off"))
82     led:value("blink", translate("Blink"))
83     led:value("auto", translate("Auto"))
84     led.optional = true
85
86
87 --- Output HTTP settings ---
88
89 this_tab = "output_http"
90
91 port=s:taboption(this_tab, Value, "port", translate("Port"), translate("TCP port for this HTTP server"))
92     port.datatype = "port"
93     port.placeholder = "8080"
94
95 enable_auth = s:taboption(this_tab, Flag, "enable_auth", translate("Authentication required"), translate("Ask for username and password on connect"))
96     enable_auth.default = false
97
98 username = s:taboption(this_tab, Value, "username", translate("Username"))
99     username:depends("enable_auth", "1")
100     username.optional = false
101
102 password = s:taboption(this_tab, Value, "password", translate("Password"))
103     password:depends("enable_auth", "1")
104     password.password = true
105     password.optional = false
106     password.default = false
107
108 www = s:taboption(this_tab, Value, "www", translate("WWW folder"), translate("Folder that contains webpages"))
109     www.datatype = "directory"
110     www.default = "/www/webcam/"
111     www.optional = false
112
113
114 --- HTTP preview  ---
115
116 html = [[
117 <style media="screen" type="text/css">
118     .img-preview {
119         display: inline-block;
120         height: auto;
121         width: 640px;
122         padding: 4px;
123         line-height: 1.428571429;
124         background-color: #fff;
125         border: 1px solid #ddd;
126         border-radius: 4px;
127         -webkit-transition: all .2s ease-in-out;
128         transition: all .2s ease-in-out;
129         margin-bottom: 5px;
130         display: none;
131     }
132 </style>
133
134 <div id="videodiv">
135         <img id="video_preview" class="img-preview" onerror="on_error()" onload="on_load()"/>
136         <p id="stream_status" style="text-align: center; color: orange; font-weight:bold;">Stream unavailable</p>
137 </div>
138
139 <script type="text/javascript">
140
141 function init_stream() {
142     console.log('init_stream');
143     start_stream()
144 }
145
146 function _start_stream() {
147         console.log('_start_stream');
148
149         port = document.getElementById('cbid.mjpg-streamer.core.port').value
150
151         if (document.getElementById('cbid.mjpg-streamer.core.enable_auth').checked) {
152             user = document.getElementById('cbid.mjpg-streamer.core.username').value
153             pass = document.getElementById('cbid.mjpg-streamer.core.password').value
154             login = user + ":" + pass + "@"
155         } else {
156             login = ""
157         }
158
159         img = document.getElementById('video_preview');
160         img.src = 'http://' + login + location.hostname + ':' + port + '/?action=snapshot';
161 }
162
163 function start_stream() {
164         console.log('start_stream');
165
166         setTimeout(function() { _start_stream(); }, 500);
167 }
168
169 function on_error() {
170     console.log('on_error');
171
172     img = document.getElementById('video_preview');
173     img.style.display = 'none';
174
175     stream_stat = document.getElementById('stream_status');
176     stream_stat.style.display = 'block';
177
178     start_stream();
179 }
180
181 function on_load() {
182     console.log('on_load');
183
184     img = document.getElementById('video_preview');
185     img.style.display = 'block';
186
187     stream_stat = document.getElementById('stream_status');
188     stream_stat.style.display = 'none';
189 }
190
191 init_stream()
192
193 </script>
194 ]]
195
196 preview = s:taboption(this_tab, DummyValue, "_dummy", html)
197     preview:depends("output", "http")
198
199 --- Output file settings ---
200
201 this_tab = "output_file"
202
203 folder=s:taboption(this_tab, Value, "folder", translate("Folder"), translate("Set folder to save pictures"))
204     folder.placeholder="/tmp/images"
205     folder.datatype = "directory"
206
207 --mjpeg=s:taboption(this_tab, Value, "mjpeg", translate("Mjpeg output"), translate("Check to save the stream to an mjpeg file"))
208
209 delay=s:taboption(this_tab, Value, "delay", translate("Interval between saving pictures"), translate("Set the inteval in millisecond"))
210     delay.placeholder="5000"
211     delay.datatype = "uinteger"
212
213 ringbuffer=s:taboption(this_tab, Value, "ringbuffer", translate("Ring buffer size"), translate("Max. number of pictures to hold"))
214     ringbuffer.placeholder="10"
215     ringbuffer.datatype = "uinteger"
216
217 exceed=s:taboption(this_tab, Value, "exceed", translate("Exceed"), translate("Allow ringbuffer to exceed limit by this amount"))
218     exceed.datatype = "uinteger"
219
220 command=s:taboption(this_tab, Value, "command", translate("Command to run"), translate("Execute command after saving picture. Mjpg-streamer parse the filename as first parameter to your script."))
221
222
223 return m