if device_details['username']:
camera_config['netcam_userpass'] = device_details['username'] + ':' + device_details['password']
+ camera_config['netcam_keepalive'] = device_details.get('keep_alive')
+ camera_config['netcam_tolerant_check'] = True
+
if device_details.get('camera_index') == 'udp':
camera_config['rtsp_uses_tcp'] = False
data['hue'] = max(1, int(round(int(ui['hue']) * 2.55)))
else: # assuming netcam
- # leave netcam_url unchanged
- # leave netcam_userpass unchanged
- data['netcam_keepalive'] = True
- data['netcam_tolerant_check'] = True
-
if data.get('netcam_url', old_config.get('netcam_url', '')).startswith('rtsp'):
# motion uses the configured width and height for RTSP cameras
width = int(ui['resolution'].split('x')[0])
called = [False]
status_2xx = [False]
+ http_11 = [False]
def do_request(on_response):
if data['username']:
called[0] = True
if content_type in ['image/jpg', 'image/jpeg', 'image/pjpg'] and allow_jpeg:
- callback([{'id': 1, 'name': 'JPEG Network Camera'}])
+ callback([{'id': 1, 'name': 'JPEG Network Camera', 'keep_alive': http_11[0]}])
elif content_type.startswith('multipart/x-mixed-replace'):
- callback([{'id': 1, 'name': 'MJPEG Network Camera'}])
+ callback([{'id': 1, 'name': 'MJPEG Network Camera', 'keep_alive': http_11[0]}])
else:
callback(error='not a supported network camera')
else:
# check for the status header
- m = re.match('^http/1.\d (\d+) ', header)
- if m and int(m.group(1)) / 100 == 2:
- status_2xx[0] = True
+ m = re.match('^http/1.(\d) (\d+) ', header)
+ if m:
+ if int(m.group(2)) / 100 == 2:
+ status_2xx[0] = True
+
+ if m.group(1) == '1':
+ http_11[0] = True
def on_response(response):
if not called[0]:
}
data.cameras.forEach(function (info) {
- addCameraSelect.append('<option value="' + info.id + '">' + info.name + '</option>');
+ var option = $('<option value="' + info.id + '">' + info.name + '</option>');
+ option[0]._extra_attrs = {};
+ Object.keys(info).forEach(function (key) {
+ if (key == 'id' || key == 'name') {
+ return;
+ }
+
+ var value = info[key];
+ option[0]._extra_attrs[key] = value;
+ });
+
+ addCameraSelect.append(option);
});
if (!data.cameras || !data.cameras.length) {
data.proto = 'v4l2';
data.uri = addCameraSelect.val();
}
+
+ /* add all extra attributes */
+ var option = addCameraSelect.find('option:eq(' + addCameraSelect[0].selectedIndex + ')')[0];
+ Object.keys(option._extra_attrs).forEach(function (key) {
+ var value = option._extra_attrs[key];
+ data[key] = value;
+ });
beginProgress();
ajax('POST', baseUri + 'config/add/', data, function (data) {