diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index ac9a5c26..ffca1c9c 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -401,6 +401,8 @@ "edt_conf_v4l2_cropRight_title": "Crop right", "edt_conf_v4l2_cropTop_expl": "Count of pixels on the top side that are removed from the picture.", "edt_conf_v4l2_cropTop_title": "Crop top", + "edt_conf_v4l2_cropWidthValidation_error": "Crop left + Crop right cannot be greater than Width ($1)", + "edt_conf_v4l2_cropHeightValidation_error": "Crop top + Crop bottom cannot be greater than Height ($1)", "edt_conf_v4l2_device_expl": "The path to the USB capture interface. Set to 'Automatic' for automatic detection. Example: '/dev/video0'", "edt_conf_v4l2_device_title": "Device", "edt_conf_v4l2_framerate_expl": "The supported frames per second of the active device", diff --git a/assets/webconfig/js/content_grabber.js b/assets/webconfig/js/content_grabber.js index ed0f5248..dbf1c49f 100755 --- a/assets/webconfig/js/content_grabber.js +++ b/assets/webconfig/js/content_grabber.js @@ -80,6 +80,57 @@ $(document).ready(function () { requestWriteConfig(conf_editor_instCapt.getValue()); }); + JSONEditor.defaults.custom_validators.push(function (schema, value, path) { + var errors = []; + + if (path === "root.grabberV4L2" || path === "root.framegrabber") { + var editor; + switch (path) { + case "root.framegrabber": + editor = conf_editor_screen; + break; + case "root.grabberV4L2": + editor = conf_editor_video; + break; + } + + if (value.cropLeft || value.cropRight) { + var width = editor.getEditor(path + ".width").getValue(); + if (value.cropLeft + value.cropRight > width) { + errors.push({ + path: path, + property: 'maximum', + message: $.i18n('edt_conf_v4l2_cropWidthValidation_error', width) + }); + } + } + + if (value.cropTop || value.cropBottom) { + var height = editor.getEditor(path + ".height").getValue(); + if (value.cropTop + value.cropBottom > height) { + errors.push({ + path: path, + property: 'maximum', + message: $.i18n('edt_conf_v4l2_cropHeightValidation_error', height) + }); + } + } + } + return errors; + }); + + function updateCropForWidth(editor, path) { + var width = editor.getEditor(path+".width").getValue(); + updateJsonEditorRange(editor.getEditor(path), 'cropLeft', 0, width); + updateJsonEditorRange(editor.getEditor(path), 'cropRight', 0, width); + } + + function updateCropForHeight(editor, path) { + var height = editor.getEditor(path + ".height").getValue(); + updateJsonEditorRange(editor.getEditor(path), 'cropTop', 0, height); + updateJsonEditorRange(editor.getEditor(path), 'cropBottom', 0, height); + } + // Framegrabber conf_editor_screen = createJsonEditor('editor_container_screengrabber', { framegrabber: window.schema.framegrabber @@ -116,10 +167,26 @@ $(document).ready(function () { updateJsonEditorSelection(screenGrabberOptions, "type", {}, enumVals, enumTitelVals, enumDefaultVal); }); + conf_editor_screen.on('ready', function () { + updateCropForWidth(conf_editor_screen, "root.framegrabber"); + updateCropForHeight(conf_editor_screen, "root.framegrabber"); + }); + conf_editor_screen.on('change', function () { + conf_editor_screen.validate().length || window.readOnlyMode ? $('#btn_submit_screengrabber').attr('disabled', true) : $('#btn_submit_screengrabber').attr('disabled', false); + }); + + conf_editor_screen.watch('root.framegrabber.type', () => { var selectedType = conf_editor_screen.getEditor("root.framegrabber.type").getValue(); filterScreenInputOptions(selectedType); - conf_editor_screen.validate().length || window.readOnlyMode ? $('#btn_submit_screengrabber').attr('disabled', true) : $('#btn_submit_screengrabber').attr('disabled', false); + }); + + conf_editor_screen.watch('root.framegrabber.width', () => { + updateCropForWidth(conf_editor_screen, "root.framegrabber"); + }); + + conf_editor_screen.watch('root.framegrabber.height', () => { + updateCropForHeight(conf_editor_screen, "root.framegrabber"); }); function showScreenInputOptions(el, state) { @@ -188,6 +255,9 @@ $(document).ready(function () { window.readOnlyMode ? $('#btn_submit_videograbber').attr('disabled', true) : $('#btn_submit_videograbber').attr('disabled', false); } } + else { + $('#btn_submit_videograbber').attr('disabled', true); + } }); conf_editor_video.watch('root.grabberV4L2.available_devices', () => { @@ -244,10 +314,8 @@ $(document).ready(function () { var deviceProperties = getPropertiesOfDevice(deviceSelected); var formats = deviceProperties.video_inputs[videoInputSelected].formats; - //Hide, if only one record available for selection - if (formats.length <= 1) { - addSchemaElements.access = "expert"; - } + + addSchemaElements.access = "advanced"; for (var i = 0; i < formats.length; i++) { if (formats[i].format) { @@ -375,6 +443,10 @@ $(document).ready(function () { var height = parseInt(formats[formatIdx].resolutions[resolutionSelected].height); conf_editor_video.getEditor("root.grabberV4L2.height").setValue(height); + //Update crop rage depending on selected resolution + updateCropForWidth(conf_editor_video, "root.grabberV4L2"); + updateCropForHeight(conf_editor_video, "root.grabberV4L2"); + var fps = formats[formatIdx].resolutions[resolutionSelected].fps; if (!fps) { enumVals.push("NONE"); @@ -415,7 +487,7 @@ $(document).ready(function () { } //Show Frameskipping only when more than 2 fps - if (fps > 2) { + if (fps > 2 && storedAccess === "expert" ) { showVideoInputOptions(["fpsSoftwareDecimation"], true); } else { diff --git a/assets/webconfig/js/ui_utils.js b/assets/webconfig/js/ui_utils.js index 1de5eeb1..0ca62db9 100644 --- a/assets/webconfig/js/ui_utils.js +++ b/assets/webconfig/js/ui_utils.js @@ -213,7 +213,6 @@ function initLanguageSelection() langText = availLangText[langIdx]; } } - //console.log("langLocale: ", langLocale, "langText: ", langText); $('#language-select').prop('title', langText); $("#language-select").val(langIdx); @@ -661,6 +660,33 @@ function updateJsonEditorMultiSelection(editor, key, addElements, newEnumVals, n editor.addObjectProperty(key); } +function updateJsonEditorRange(editor, key, minimum, maximum, defaultValue, step) { + + var orginalProperties = editor.schema.properties[key]; + var newSchema = []; + newSchema[key] = orginalProperties; + + if (minimum) { + newSchema[key]["minimum"] = minimum; + } + if (maximum) { + newSchema[key]["maximum"] = maximum; + } + if (defaultValue) { + newSchema[key]["default"] = defaultValue; + } + if (step) { + newSchema[key]["step"] = step; + } + + editor.original_schema.properties[key] = orginalProperties; + editor.schema.properties[key] = newSchema[key]; + + editor.removeObjectProperty(key); + delete editor.cached_editors[key]; + editor.addObjectProperty(key); +} + function buildWL(link,linkt,cl) { var baseLink = "https://docs.hyperion-project.org/"; diff --git a/libsrc/hyperion/schema/schema-framegrabber.json b/libsrc/hyperion/schema/schema-framegrabber.json index aad0a8ff..12709f07 100644 --- a/libsrc/hyperion/schema/schema-framegrabber.json +++ b/libsrc/hyperion/schema/schema-framegrabber.json @@ -1,101 +1,90 @@ { "type" : "object", "title" : "edt_conf_fg_heading_title", - "properties" : - { - "type" : - { - "type" : "string", - "title" : "edt_conf_fg_type_title", - "enum" : ["auto","amlogic","dispmanx","dx","framebuffer","osx","qt","x11", "xcb"], - "options": - { - "enum_titles": ["edt_conf_enum_automatic","AMLogic","DispmanX","DirectX9","Framebuffer","OSX","QT","X11","XCB"] + "properties": { + "type": { + "type": "string", + "title": "edt_conf_fg_type_title", + "enum": [ "auto", "amlogic", "dispmanx", "dx", "framebuffer", "osx", "qt", "x11", "xcb" ], + "options": { + "enum_titles": [ "edt_conf_enum_automatic", "AMLogic", "DispmanX", "DirectX9", "Framebuffer", "OSX", "QT", "X11", "XCB" ] }, - "default" : "auto", - "propertyOrder" : 1 + "default": "auto", + "propertyOrder": 1 }, - "width" : - { - "type" : "integer", - "title" : "edt_conf_fg_width_title", - "minimum" : 10, - "default" : 80, - "append" : "edt_append_pixel", - "propertyOrder" : 2 + "display": { + "type": "integer", + "title": "edt_conf_fg_display_title", + "minimum": 0, + "default": 0, + "propertyOrder": 2 }, - "height" : - { - "type" : "integer", - "title" : "edt_conf_fg_height_title", - "minimum" : 10, - "default" : 45, - "append" : "edt_append_pixel", - "propertyOrder" : 3 + "width": { + "type": "integer", + "title": "edt_conf_fg_width_title", + "minimum": 10, + "default": 80, + "append": "edt_append_pixel", + "propertyOrder": 3 }, - "frequency_Hz" : - { - "type" : "integer", - "title" : "edt_conf_fg_frequency_Hz_title", - "minimum" : 1, - "default" : 10, - "append" : "edt_append_hz", - "propertyOrder" : 4 + "height": { + "type": "integer", + "title": "edt_conf_fg_height_title", + "minimum": 10, + "default": 45, + "append": "edt_append_pixel", + "propertyOrder": 4 }, - "cropLeft" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropLeft_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 5 + "frequency_Hz": { + "type": "integer", + "title": "edt_conf_fg_frequency_Hz_title", + "minimum": 1, + "default": 10, + "append": "edt_append_hz", + "propertyOrder": 5 }, - "cropRight" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropRight_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 6 + "cropLeft": { + "type": "integer", + "title": "edt_conf_v4l2_cropLeft_title", + "minimum": 0, + "default": 0, + "append": "edt_append_pixel", + "propertyOrder": 6 }, - "cropTop" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropTop_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 7 + "cropRight": { + "type": "integer", + "title": "edt_conf_v4l2_cropRight_title", + "minimum": 0, + "default": 0, + "append": "edt_append_pixel", + "propertyOrder": 7 }, - "cropBottom" : - { - "type" : "integer", - "title" : "edt_conf_v4l2_cropBottom_title", - "minimum" : 0, - "default" : 0, - "append" : "edt_append_pixel", - "propertyOrder" : 8 + "cropTop": { + "type": "integer", + "title": "edt_conf_v4l2_cropTop_title", + "minimum": 0, + "default": 0, + "append": "edt_append_pixel", + "propertyOrder": 8 }, - "pixelDecimation" : - { - "type" : "integer", - "title" : "edt_conf_fg_pixelDecimation_title", - "minimum" : 1, - "maximum" : 30, - "default" : 8, - "propertyOrder" : 9 + "cropBottom": { + "type": "integer", + "title": "edt_conf_v4l2_cropBottom_title", + "minimum": 0, + "default": 0, + "append": "edt_append_pixel", + "propertyOrder": 9 }, - "display" : - { - "type" : "integer", - "title" : "edt_conf_fg_display_title", - "minimum" : 0, - "default" : 0, - "propertyOrder" : 10 + "pixelDecimation": { + "type": "integer", + "title": "edt_conf_fg_pixelDecimation_title", + "minimum": 1, + "maximum": 30, + "default": 8, + "propertyOrder": 10 } + }, "additionalProperties" : false } diff --git a/libsrc/hyperion/schema/schema-grabberV4L2.json b/libsrc/hyperion/schema/schema-grabberV4L2.json index 1325998a..d4b659c5 100644 --- a/libsrc/hyperion/schema/schema-grabberV4L2.json +++ b/libsrc/hyperion/schema/schema-grabberV4L2.json @@ -49,6 +49,7 @@ "title": "edt_conf_v4l2_encoding_title", "default": "auto", "required": true, + "access": "advanced", "propertyOrder": 6 }, "resolutions": { @@ -109,7 +110,7 @@ "maximum": 60, "default": 0, "required": true, - "access": "advanced", + "access": "expert", "propertyOrder": 12 }, "flip": { @@ -133,6 +134,38 @@ "required": true, "propertyOrder": 14 }, + "hardware_brightness": { + "type": "integer", + "title": "edt_conf_v4l2_hardware_brightness_title", + "default": 0, + "required": true, + "access": "expert", + "propertyOrder": 15 + }, + "hardware_contrast": { + "type": "integer", + "title": "edt_conf_v4l2_hardware_contrast_title", + "default": 0, + "required": true, + "access": "expert", + "propertyOrder": 16 + }, + "hardware_saturation": { + "type": "integer", + "title": "edt_conf_v4l2_hardware_saturation_title", + "default": 0, + "required": true, + "access": "expert", + "propertyOrder": 17 + }, + "hardware_hue": { + "type": "integer", + "title": "edt_conf_v4l2_hardware_hue_title", + "default": 0, + "required": true, + "access": "expert", + "propertyOrder": 18 + }, "cropLeft": { "type": "integer", "title": "edt_conf_v4l2_cropLeft_title", @@ -140,8 +173,7 @@ "default": 0, "append": "edt_append_pixel", "required": true, - "access": "advanced", - "propertyOrder": 15 + "propertyOrder": 19 }, "cropRight": { "type": "integer", @@ -150,8 +182,7 @@ "default": 0, "append": "edt_append_pixel", "required": true, - "access": "advanced", - "propertyOrder": 16 + "propertyOrder": 20 }, "cropTop": { "type": "integer", @@ -160,8 +191,7 @@ "default": 0, "append": "edt_append_pixel", "required": true, - "access": "advanced", - "propertyOrder": 17 + "propertyOrder": 21 }, "cropBottom": { "type": "integer", @@ -170,23 +200,23 @@ "default": 0, "append": "edt_append_pixel", "required": true, - "access": "advanced", - "propertyOrder": 18 + "propertyOrder": 22 }, "cecDetection": { "type": "boolean", "title": "edt_conf_v4l2_cecDetection_title", "default": false, "required": true, - "propertyOrder": 19 + "access": "advanced", + "propertyOrder": 23 }, "signalDetection": { "type": "boolean", "title": "edt_conf_v4l2_signalDetection_title", "default": false, "required": true, - "access": "advanced", - "propertyOrder": 20 + "access": "expert", + "propertyOrder": 24 }, "redSignalThreshold": { "type": "integer", @@ -200,9 +230,9 @@ "signalDetection": true } }, - "access": "advanced", + "access": "expert", "required": true, - "propertyOrder": 21 + "propertyOrder": 25 }, "greenSignalThreshold": { "type": "integer", @@ -217,8 +247,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 22 + "access": "expert", + "propertyOrder": 26 }, "blueSignalThreshold": { "type": "integer", @@ -233,8 +263,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 23 + "access": "expert", + "propertyOrder": 27 }, "noSignalCounterThreshold": { "type": "integer", @@ -248,8 +278,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 24 + "access": "expert", + "propertyOrder": 28 }, "sDVOffsetMin": { "type": "number", @@ -264,8 +294,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 25 + "access": "expert", + "propertyOrder": 29 }, "sDVOffsetMax": { "type": "number", @@ -280,8 +310,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 26 + "access": "expert", + "propertyOrder": 30 }, "sDHOffsetMin": { "type": "number", @@ -296,8 +326,8 @@ } }, "required": true, - "access": "advanced", - "propertyOrder": 27 + "access": "expert", + "propertyOrder": 31 }, "sDHOffsetMax": { "type": "number", @@ -312,38 +342,6 @@ } }, "required": true, - "propertyOrder": 28 - }, - "hardware_brightness": { - "type": "integer", - "title": "edt_conf_v4l2_hardware_brightness_title", - "default": 0, - "required": true, - "access": "advanced", - "propertyOrder": 29 - }, - "hardware_contrast": { - "type": "integer", - "title": "edt_conf_v4l2_hardware_contrast_title", - "default": 0, - "required": true, - "access": "advanced", - "propertyOrder": 30 - }, - "hardware_saturation": { - "type": "integer", - "title": "edt_conf_v4l2_hardware_saturation_title", - "default": 0, - "required": true, - "access": "advanced", - "propertyOrder": 31 - }, - "hardware_hue": { - "type": "integer", - "title": "edt_conf_v4l2_hardware_hue_title", - "default": 0, - "required": true, - "access": "advanced", "propertyOrder": 32 } },