mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
c135d91986
* - New Media Foundation grabber - JsonAPI available grabber fix - commented json config removed * Added libjpeg-turbo to dependencies * Fix OSX build Removed Azure Pipelines from build scripts * Remove Platform from Dashboard * Correct Grabber Namings * Grabber UI improvements, generic JSONEditor Selection Update * Active grabber fix * Stop Framebuffer grabber on failure * - Image format NV12 and I420 added - Flip mode - Scaling factor for MJPEG - VSCode (compile before run) - CI (push) dependency libjpeg-turbo added * Refactor MediaFoundation (Part 1) * Remove QDebug output * Added image flipping ability to MF Grabber * fix issue 1160 * -Reload MF Grabber only once per WebUI update - Cleanup * Improvements * - Set 'Software Frame Decimation' begin to 0 - Removed grabber specific device name from Log - Keep pixel format when switching resolution - Display 'Flip mode' correct in Log - BGR24 images always flipped * Refactor MediaFoundation (Part 2) * Refactor V4L2 grabber (part 1) (#62) * Media Foundation grabber adapted to V4L2 change * Enable Media Foundation grabber on windows * Have fps as int, fix height typo * Added video standards to JsonAPI output * Error handling in source reader improved * Fix "Frame to small" error * Discovery VideoSources and Dynamically Update Editor * Hide all element when no video grabber discovered, upate naming * Do not show unsupported grabbers * Copy Log to Clipboard * Update Grabber schema and Defaults * Update access levels and validate crop ranges * Height and width in Qt grabber corrected * Correct formatting * Untabify * Global component states across instances * Components divided on the dashboard * refactor * Fix Merge-issues * Database migration aligning with updated grabber model * Align Grabber.js with new utility functions * Allow editor-validation for enum-lists * Handle "Show Explainations scenario" correctly * Grabber - Ensure save is only possible on valid content * Dashboard update + fix GlobalSignal connection * Ensure default database is populated with current release * Correct grabber4L2 access level * Display Signal detection area in preview * Write Hyperion version into default config on compiling. * Create defaultconfig.json dynamically * WebUI changes * Correct grabber config look-ups * Refactor i18n language loading * Fix en.json * Split global capture from instance capture config * Update grabber default values * Standalone grabber: Add --debug switch * Enhance showInputOptionsForKey for multiple keys * Add grabber instance link to system grabber config * Only show signal detection area, if grabber is enabled * Always show Active element on grabber page * Remote control - Only display gabber status, if global grabber is enabled * WebUI optimization (thx to @mkcologne) Start Grabber only when global settings are enabled Fixed an issue in the WebUI preview * V4L2/MF changes * Jsoneditor, Correct translation for default values * Refactor LED-Device handling in UI and make element naming consistent * MF Discovery extended * Fix LGTM finding * Support Grabber Bri, Hue, Sat and Con in UI, plus their defaults * Concider Access level for item filtering * Concider Access level for item filtering * Revert "Concider Access level for item filtering" This reverts commit 5b0ce3c0f2de67e0c43788190cfff45614706129. * Disable fpsSoftwareDecimation for framegrabber, as not supported yet * JSON-Editor- Add updated schema for validation on dynamic elements * added V4L2 color IDs * LGTM findings fix * destroy SR callback only on exit * Grabber.js - Hide elements not supported by platform * Fixed freezing start effect * Grabber UI - Hardware controls - Show current values and allow to reset to defaults * Grabber - Discovery - Add current values to properties * Small things * Clean-up Effects and have ENDLESS consistently defined * Fix on/off/on priority during startup, by initializing _prevVisComp in line with background priority * Add missing translation mappings * DirectX Grabber reactivated/ QT Grabber size decimation fixed * typo in push-master workflow * Use PreciseTimer for Grabber to ensure stable FPS timing * Set default Screencapture rate consistently * Fix libjpeg-turbo download * Remove Zero character from file * docker-compile Add PLATFORM parameter, only copy output file after successful compile * Framebuffer, Dispmanx, OSX, AML Grabber discovery, various clean-up and consistencies across grabbers * Fix merge problem - on docker-compile Add PLATFORM parameter, only copy output file after successful compile * Fix definition * OSXFRameGrabber - Revert cast * Clean-ups nach Feedback * Disable certain libraries when building armlogic via standard stretch image as developer * Add CEC availability to ServerInfo to have it platform independent * Grabber UI - Fix problem that crop values are not populated when refining editor rage * Preserve value when updating json-editor range * LEDVisualisation - Clear image when source changes * Fix - Preserve value when updating json-editor range * LEDVisualisation - Clear image when no component is active * Allow to have password handled by Password-Manager (#1263) * Update default signal detection area to green assuming rainbow grabber * LED Visualisation - Handle empty priority update * Fix yuv420 in v4l2 grabber * V4L2-Grabber discovery - Only report grabbers with valid video input information * Grabber - Update static variables to have them working in release build * LED Visualisation - ClearImage when no priorities * LED Visualisation - Fix Logo resizing issue * LED Visualisation - Have nearly black background and negative logo Co-authored-by: LordGrey <lordgrey.emmel@gmail.com> Co-authored-by: LordGrey <48840279+Lord-Grey@users.noreply.github.com>
793 lines
29 KiB
JavaScript
Executable File
793 lines
29 KiB
JavaScript
Executable File
$(document).ready(function () {
|
|
performTranslation();
|
|
|
|
var conf_editor_video = null;
|
|
var conf_editor_screen = null;
|
|
|
|
// Screen-Grabber
|
|
$('#conf_cont').append(createRow('conf_cont_screen'));
|
|
$('#conf_cont_screen').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_screengrabber', 'btn_submit_screengrabber', 'panel-system', 'screengrabberPanelId'));
|
|
if (window.showOptHelp) {
|
|
$('#conf_cont_screen').append(createHelpTable(window.schema.framegrabber.properties, $.i18n("edt_conf_fg_heading_title"), "screengrabberHelpPanelId"));
|
|
}
|
|
|
|
// Video-Grabber
|
|
$('#conf_cont').append(createRow('conf_cont_video'));
|
|
$('#conf_cont_video').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_videograbber', 'btn_submit_videograbber', 'panel-system', 'videograbberPanelId'));
|
|
|
|
if (storedAccess === 'expert') {
|
|
var conf_cont_video_footer = document.getElementById("editor_container_videograbber").nextElementSibling;
|
|
$(conf_cont_video_footer).prepend('<button class="btn btn-primary mdi-24px" id="btn_videograbber_set_defaults" disabled data-toggle="tooltip" data-placement="top" title="' + $.i18n("edt_conf_v4l2_hardware_set_defaults_tip") + '">'
|
|
+ '<i class= "fa fa-fw fa-undo" ></i >' + $.i18n("edt_conf_v4l2_hardware_set_defaults") + '</button > ');
|
|
}
|
|
|
|
if (window.showOptHelp) {
|
|
$('#conf_cont_video').append(createHelpTable(window.schema.grabberV4L2.properties, $.i18n("edt_conf_v4l2_heading_title"), "videograbberHelpPanelId"));
|
|
}
|
|
|
|
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, path, 'cropLeft', 0, width);
|
|
updateJsonEditorRange(editor, path, 'cropRight', 0, width);
|
|
}
|
|
|
|
function updateCropForHeight(editor, path) {
|
|
var height = editor.getEditor(path + ".height").getValue();
|
|
updateJsonEditorRange(editor, path, 'cropTop', 0, height);
|
|
updateJsonEditorRange(editor, path, 'cropBottom', 0, height);
|
|
}
|
|
|
|
// Screen-Grabber
|
|
conf_editor_screen = createJsonEditor('editor_container_screengrabber', {
|
|
framegrabber: window.schema.framegrabber
|
|
}, true, true);
|
|
|
|
conf_editor_screen.on('ready', function () {
|
|
// Trigger conf_editor_screen.watch - 'root.framegrabber.enable'
|
|
var screenEnable = window.serverConfig.framegrabber.enable;
|
|
conf_editor_screen.getEditor("root.framegrabber.enable").setValue(screenEnable);
|
|
});
|
|
|
|
conf_editor_screen.on('change', function () {
|
|
|
|
if (!conf_editor_screen.validate().length) {
|
|
var deviceSelected = conf_editor_screen.getEditor("root.framegrabber.available_devices").getValue();
|
|
switch (deviceSelected) {
|
|
case "SELECT":
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", ["enable", "available_devices"], false);
|
|
break;
|
|
case "NONE":
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", ["enable", "available_devices"], false);
|
|
break;
|
|
default:
|
|
window.readOnlyMode ? $('#btn_submit_screengrabber').attr('disabled', true) : $('#btn_submit_screengrabber').attr('disabled', false);
|
|
break;
|
|
}
|
|
}
|
|
else {
|
|
$('#btn_submit_screengrabber').attr('disabled', true);
|
|
}
|
|
});
|
|
|
|
conf_editor_screen.watch('root.framegrabber.enable', () => {
|
|
|
|
var screenEnable = conf_editor_screen.getEditor("root.framegrabber.enable").getValue();
|
|
if (screenEnable) {
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", "enable", true);
|
|
if (window.showOptHelp) {
|
|
$('#screengrabberHelpPanelId').show();
|
|
}
|
|
discoverInputSources("screen");
|
|
}
|
|
else {
|
|
$('#btn_submit_screengrabber').attr('disabled', false);
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", "enable", false);
|
|
$('#screengrabberHelpPanelId').hide();
|
|
}
|
|
|
|
});
|
|
|
|
conf_editor_screen.watch('root.framegrabber.available_devices', () => {
|
|
|
|
var deviceSelected = conf_editor_screen.getEditor("root.framegrabber.available_devices").getValue();
|
|
if (deviceSelected === "SELECT" || deviceSelected === "NONE" || deviceSelected === "") {
|
|
$('#btn_submit_screengrabber').attr('disabled', true);
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", ["enable", "available_devices"], false);
|
|
}
|
|
else {
|
|
showInputOptionsForKey(conf_editor_screen, "framegrabber", ["enable", "available_devices"], true);
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("screen", deviceSelected);
|
|
|
|
//Update hidden input element
|
|
conf_editor_screen.getEditor("root.framegrabber.device").setValue(deviceProperties.device);
|
|
|
|
var video_inputs = deviceProperties.video_inputs;
|
|
if (video_inputs.length <= 1) {
|
|
addSchemaElements.access = "expert";
|
|
}
|
|
|
|
for (const video_input of video_inputs) {
|
|
enumVals.push(video_input.inputIdx.toString());
|
|
enumTitelVals.push(video_input.name);
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredVideoInput = window.serverConfig.framegrabber.input.toString();
|
|
if ($.inArray(configuredVideoInput, enumVals) != -1) {
|
|
enumDefaultVal = configuredVideoInput;
|
|
}
|
|
}
|
|
updateJsonEditorSelection(conf_editor_screen, 'root.framegrabber',
|
|
'device_inputs', addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_screen.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_screengrabber').attr('disabled', false);
|
|
}
|
|
}
|
|
});
|
|
|
|
conf_editor_screen.watch('root.framegrabber.device_inputs', () => {
|
|
var deviceSelected = conf_editor_screen.getEditor("root.framegrabber.available_devices").getValue();
|
|
var videoInputSelected = conf_editor_screen.getEditor("root.framegrabber.device_inputs").getValue();
|
|
|
|
//Update hidden input element
|
|
conf_editor_screen.getEditor("root.framegrabber.input").setValue(parseInt(videoInputSelected));
|
|
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("screen", deviceSelected);
|
|
|
|
var formats = deviceProperties.video_inputs[videoInputSelected].formats;
|
|
var formatIdx = 0;
|
|
|
|
var resolutions = formats[formatIdx].resolutions;
|
|
if (resolutions.length <= 1) {
|
|
addSchemaElements.access = "advanced";
|
|
} else {
|
|
resolutions.sort(compareTwoValues('width', 'height', 'asc'));
|
|
}
|
|
|
|
for (var i = 0; i < resolutions.length; i++) {
|
|
enumVals.push(i.toString());
|
|
var resolutionText = resolutions[i].width + "x" + resolutions[i].height;
|
|
enumTitelVals.push(resolutionText);
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredResolutionText = window.serverConfig.framegrabber.width + "x" + window.serverConfig.framegrabber.height;
|
|
var idx = $.inArray(configuredResolutionText, enumTitelVals)
|
|
if (idx != -1) {
|
|
enumDefaultVal = idx.toString();
|
|
}
|
|
}
|
|
|
|
updateJsonEditorSelection(conf_editor_screen, 'root.framegrabber',
|
|
'resolutions', addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_screen.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_screengrabber').attr('disabled', false);
|
|
}
|
|
});
|
|
|
|
conf_editor_screen.watch('root.framegrabber.resolutions', () => {
|
|
var deviceSelected = conf_editor_screen.getEditor("root.framegrabber.available_devices").getValue();
|
|
var videoInputSelected = conf_editor_screen.getEditor("root.framegrabber.device_inputs").getValue();
|
|
var resolutionSelected = conf_editor_screen.getEditor("root.framegrabber.resolutions").getValue();
|
|
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("screen", deviceSelected);
|
|
|
|
var formats = deviceProperties.video_inputs[videoInputSelected].formats;
|
|
var formatIdx = 0;
|
|
|
|
//Update hidden resolution related elements
|
|
var width = parseInt(formats[formatIdx].resolutions[resolutionSelected].width);
|
|
conf_editor_screen.getEditor("root.framegrabber.width").setValue(width);
|
|
|
|
var height = parseInt(formats[formatIdx].resolutions[resolutionSelected].height);
|
|
conf_editor_screen.getEditor("root.framegrabber.height").setValue(height);
|
|
|
|
//Update crop rage depending on selected resolution
|
|
updateCropForWidth(conf_editor_screen, "root.framegrabber");
|
|
updateCropForHeight(conf_editor_screen, "root.framegrabber");
|
|
|
|
var fps = formats[formatIdx].resolutions[resolutionSelected].fps;
|
|
if (!fps) {
|
|
enumVals.push("NONE");
|
|
addSchemaElements.options = { "hidden": true };
|
|
} else {
|
|
fps.sort((a, b) => a - b);
|
|
for (var i = 0; i < fps.length; i++) {
|
|
enumVals.push(fps[i].toString());
|
|
}
|
|
}
|
|
|
|
if (enumVals.length <= 1) {
|
|
addSchemaElements.access = "expert";
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredFps = window.serverConfig.framegrabber.fps.toString();
|
|
if ($.inArray(configuredFps, enumVals) != -1) {
|
|
enumDefaultVal = configuredFps;
|
|
}
|
|
}
|
|
updateJsonEditorSelection(conf_editor_screen, 'root.framegrabber',
|
|
'framerates', addSchemaElements, enumVals, [], enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_screen.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_screengrabber').attr('disabled', false);
|
|
}
|
|
});
|
|
|
|
conf_editor_screen.watch('root.framegrabber.framerates', () => {
|
|
//Update hidden fps element
|
|
var fps = 0;
|
|
var framerates = conf_editor_screen.getEditor("root.framegrabber.framerates").getValue();
|
|
if (framerates !== "NONE") {
|
|
fps = parseInt(framerates);
|
|
}
|
|
conf_editor_screen.getEditor("root.framegrabber.fps").setValue(fps);
|
|
});
|
|
|
|
|
|
$('#btn_submit_screengrabber').off().on('click', function () {
|
|
var saveOptions = conf_editor_screen.getValue();
|
|
|
|
var instCaptOptions = window.serverConfig.instCapture;
|
|
instCaptOptions.systemEnable = true;
|
|
saveOptions.instCapture = instCaptOptions;
|
|
|
|
requestWriteConfig(saveOptions);
|
|
});
|
|
|
|
// External Input Sources (Video-Grabbers)
|
|
|
|
var configuredDevice = "";
|
|
var discoveredInputSources = {};
|
|
var deviceProperties = {};
|
|
|
|
function updateDeviceProperties(deviceProperties, property, key) {
|
|
var properties = {};
|
|
if (deviceProperties) {
|
|
if (deviceProperties.hasOwnProperty(property)) {
|
|
properties = deviceProperties[property];
|
|
}
|
|
}
|
|
updateJsonEditorRange(conf_editor_video, "root.grabberV4L2", key,
|
|
properties.minValue,
|
|
properties.maxValue,
|
|
properties.current,
|
|
properties.step,
|
|
true);
|
|
|
|
if (jQuery.isEmptyObject(properties)) {
|
|
showInputOptionForItem(conf_editor_video, "grabberV4L2", key, false);
|
|
} else {
|
|
showInputOptionForItem(conf_editor_video, "grabberV4L2", key, true);
|
|
}
|
|
}
|
|
|
|
conf_editor_video = createJsonEditor('editor_container_videograbber', {
|
|
grabberV4L2: window.schema.grabberV4L2
|
|
}, true, true);
|
|
|
|
conf_editor_video.on('ready', function () {
|
|
// Trigger conf_editor_video.watch - 'root.grabberV4L2.enable'
|
|
var videoEnable = window.serverConfig.grabberV4L2.enable;
|
|
conf_editor_video.getEditor("root.grabberV4L2.enable").setValue(videoEnable);
|
|
});
|
|
|
|
conf_editor_video.on('change', function () {
|
|
|
|
// Hide elements not supported by the backend
|
|
if (window.serverInfo.cec.enabled === false) {
|
|
showInputOptionForItem(conf_editor_video, "grabberV4L2", "cecDetection", false);
|
|
}
|
|
|
|
// Validate the current editor's content
|
|
if (!conf_editor_video.validate().length) {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
switch (deviceSelected) {
|
|
case "SELECT":
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", ["enable", "available_devices"], false);
|
|
break;
|
|
case "NONE":
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", ["enable", "available_devices"], false);
|
|
break;
|
|
default:
|
|
window.readOnlyMode ? $('#btn_submit_videograbber').attr('disabled', true) : $('#btn_submit_videograbber').attr('disabled', false);
|
|
break;
|
|
}
|
|
}
|
|
else {
|
|
$('#btn_submit_videograbber').attr('disabled', true);
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.enable', () => {
|
|
|
|
var videoEnable = conf_editor_video.getEditor("root.grabberV4L2.enable").getValue();
|
|
if (videoEnable) {
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", "enable", true);
|
|
$('#btn_videograbber_set_defaults').show();
|
|
if (window.showOptHelp) {
|
|
$('#videograbberHelpPanelId').show();
|
|
}
|
|
discoverInputSources("video");
|
|
}
|
|
else {
|
|
$('#btn_submit_videograbber').attr('disabled', false);
|
|
$('#btn_videograbber_set_defaults').hide();
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", "enable", false);
|
|
$('#videograbberHelpPanelId').hide();
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.available_devices', () => {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
if (deviceSelected === "SELECT" || deviceSelected === "NONE" || deviceSelected === "") {
|
|
$('#btn_submit_videograbber').attr('disabled', true);
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", ["enable", "available_devices"], false);
|
|
}
|
|
else {
|
|
showInputOptionsForKey(conf_editor_video, "grabberV4L2", ["enable", "available_devices"], true);
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("video", deviceSelected);
|
|
|
|
//Update hidden input element
|
|
conf_editor_video.getEditor("root.grabberV4L2.device").setValue(deviceProperties.device);
|
|
|
|
if (deviceProperties.hasOwnProperty('default') && !jQuery.isEmptyObject(deviceProperties.default.properties)) {
|
|
$('#btn_videograbber_set_defaults').attr('disabled', false);
|
|
} else {
|
|
$('#btn_videograbber_set_defaults').attr('disabled', true);
|
|
}
|
|
|
|
//If configured device is selected, use the saved values as current values
|
|
if (deviceSelected === configuredDevice) {
|
|
// Only if the device reported properties, use the configured values. In case no properties are presented, the device properties cannot be controlled.
|
|
if (deviceProperties.hasOwnProperty('properties') && !jQuery.isEmptyObject(deviceProperties.properties)) {
|
|
let properties = {
|
|
brightness: { current: window.serverConfig.grabberV4L2.hardware_brightness },
|
|
contrast: { current: window.serverConfig.grabberV4L2.hardware_contrast },
|
|
saturation: { current: window.serverConfig.grabberV4L2.hardware_saturation },
|
|
hue: { current: window.serverConfig.grabberV4L2.hardware_hue }
|
|
}
|
|
deviceProperties.properties = properties;
|
|
}
|
|
}
|
|
|
|
updateDeviceProperties(deviceProperties.properties, "brightness", "hardware_brightness");
|
|
updateDeviceProperties(deviceProperties.properties, "contrast", "hardware_contrast");
|
|
updateDeviceProperties(deviceProperties.properties, "saturation", "hardware_saturation");
|
|
updateDeviceProperties(deviceProperties.properties, "hue", "hardware_hue");
|
|
|
|
var video_inputs = deviceProperties.video_inputs;
|
|
if (video_inputs.length <= 1) {
|
|
addSchemaElements.access = "expert";
|
|
}
|
|
|
|
for (const video_input of video_inputs) {
|
|
enumVals.push(video_input.inputIdx.toString());
|
|
enumTitelVals.push(video_input.name);
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredVideoInput = window.serverConfig.grabberV4L2.input.toString();
|
|
if ($.inArray(configuredVideoInput, enumVals) != -1) {
|
|
enumDefaultVal = configuredVideoInput;
|
|
}
|
|
}
|
|
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'device_inputs', addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, false, false);
|
|
}
|
|
|
|
if (conf_editor_video.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_videograbber').attr('disabled', false);
|
|
}
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.device_inputs', () => {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
var videoInputSelected = conf_editor_video.getEditor("root.grabberV4L2.device_inputs").getValue();
|
|
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("video", deviceSelected);
|
|
var formats = deviceProperties.video_inputs[videoInputSelected].formats;
|
|
|
|
addSchemaElements.access = "advanced";
|
|
|
|
for (var i = 0; i < formats.length; i++) {
|
|
if (formats[i].format) {
|
|
enumVals.push(formats[i].format);
|
|
enumTitelVals.push(formats[i].format.toUpperCase());
|
|
}
|
|
else {
|
|
enumVals.push("NONE");
|
|
}
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredEncoding = window.serverConfig.grabberV4L2.encoding;
|
|
if ($.inArray(configuredEncoding, enumVals) != -1) {
|
|
enumDefaultVal = configuredEncoding;
|
|
}
|
|
}
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'encoding', addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, false);
|
|
}
|
|
|
|
var enumVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var standards = deviceProperties.video_inputs[videoInputSelected].standards;
|
|
if (!standards) {
|
|
enumVals.push("NONE");
|
|
addSchemaElements.options = { "hidden": true };
|
|
} else {
|
|
enumVals = standards;
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredStandard = window.serverConfig.grabberV4L2.standard;
|
|
if ($.inArray(configuredStandard, enumVals) != -1) {
|
|
enumDefaultVal = configuredStandard;
|
|
}
|
|
}
|
|
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'standard', addSchemaElements, enumVals, [], enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_video.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_videograbber').attr('disabled', false);
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.encoding', () => {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
var videoInputSelected = conf_editor_video.getEditor("root.grabberV4L2.device_inputs").getValue();
|
|
var formatSelected = conf_editor_video.getEditor("root.grabberV4L2.encoding").getValue();
|
|
|
|
//Update hidden input element
|
|
conf_editor_video.getEditor("root.grabberV4L2.input").setValue(parseInt(videoInputSelected));
|
|
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("video", deviceSelected);
|
|
|
|
var formats = deviceProperties.video_inputs[videoInputSelected].formats;
|
|
var formatIdx = 0;
|
|
if (formatSelected !== "NONE") {
|
|
formatIdx = formats.findIndex(x => x.format === formatSelected);
|
|
}
|
|
|
|
var resolutions = formats[formatIdx].resolutions;
|
|
if (resolutions.length <= 1) {
|
|
addSchemaElements.access = "advanced";
|
|
} else {
|
|
resolutions.sort(compareTwoValues('width', 'height', 'asc'));
|
|
}
|
|
|
|
for (var i = 0; i < resolutions.length; i++) {
|
|
enumVals.push(i.toString());
|
|
var resolutionText = resolutions[i].width + "x" + resolutions[i].height;
|
|
enumTitelVals.push(resolutionText);
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredResolutionText = window.serverConfig.grabberV4L2.width + "x" + window.serverConfig.grabberV4L2.height;
|
|
var idx = $.inArray(configuredResolutionText, enumTitelVals)
|
|
if (idx != -1) {
|
|
enumDefaultVal = idx.toString();
|
|
}
|
|
}
|
|
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'resolutions', addSchemaElements, enumVals, enumTitelVals, enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_video.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_videograbber').attr('disabled', false);
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.resolutions', () => {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
var videoInputSelected = conf_editor_video.getEditor("root.grabberV4L2.device_inputs").getValue();
|
|
var formatSelected = conf_editor_video.getEditor("root.grabberV4L2.encoding").getValue();
|
|
var resolutionSelected = conf_editor_video.getEditor("root.grabberV4L2.resolutions").getValue();
|
|
|
|
var addSchemaElements = {};
|
|
var enumVals = [];
|
|
var enumDefaultVal = "";
|
|
|
|
var deviceProperties = getPropertiesOfDevice("video", deviceSelected);
|
|
|
|
var formats = deviceProperties.video_inputs[videoInputSelected].formats;
|
|
var formatIdx = 0;
|
|
if (formatSelected !== "NONE") {
|
|
formatIdx = formats.findIndex(x => x.format === formatSelected);
|
|
}
|
|
|
|
//Update hidden resolution related elements
|
|
var width = parseInt(formats[formatIdx].resolutions[resolutionSelected].width);
|
|
conf_editor_video.getEditor("root.grabberV4L2.width").setValue(width);
|
|
|
|
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) {
|
|
addSchemaElements.options = { "hidden": true };
|
|
} else {
|
|
fps.sort((a, b) => a - b);
|
|
for (var i = 0; i < fps.length; i++) {
|
|
enumVals.push(fps[i].toString());
|
|
}
|
|
}
|
|
|
|
if (enumVals.length <= 1) {
|
|
addSchemaElements.access = "expert";
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
if (deviceSelected === configuredDevice) {
|
|
var configuredFps = window.serverConfig.grabberV4L2.fps.toString();
|
|
if ($.inArray(configuredFps, enumVals) != -1) {
|
|
enumDefaultVal = configuredFps;
|
|
}
|
|
}
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'framerates', addSchemaElements, enumVals, [], enumDefaultVal, false);
|
|
}
|
|
|
|
if (conf_editor_video.validate().length && !window.readOnlyMode) {
|
|
$('#btn_submit_videograbber').attr('disabled', false);
|
|
}
|
|
});
|
|
|
|
conf_editor_video.watch('root.grabberV4L2.framerates', () => {
|
|
//Update hidden fps element
|
|
var fps = 0;
|
|
var framerates = conf_editor_video.getEditor("root.grabberV4L2.framerates").getValue();
|
|
if (framerates !== "NONE") {
|
|
fps = parseInt(framerates);
|
|
}
|
|
//Show Frameskipping only when more than 2 fps
|
|
if (fps > 2) {
|
|
showInputOptionForItem(conf_editor_video, "grabberV4L2", "fpsSoftwareDecimation", true);
|
|
}
|
|
else {
|
|
showInputOptionForItem(conf_editor_video, "grabberV4L2", "fpsSoftwareDecimation", false);
|
|
}
|
|
conf_editor_video.getEditor("root.grabberV4L2.fps").setValue(fps);
|
|
});
|
|
|
|
$('#btn_submit_videograbber').off().on('click', function () {
|
|
var saveOptions = conf_editor_video.getValue();
|
|
|
|
var instCaptOptions = window.serverConfig.instCapture;
|
|
instCaptOptions.v4lEnable = true;
|
|
saveOptions.instCapture = instCaptOptions;
|
|
|
|
requestWriteConfig(saveOptions);
|
|
});
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
$('#btn_videograbber_set_defaults').off().on('click', function () {
|
|
var deviceSelected = conf_editor_video.getEditor("root.grabberV4L2.available_devices").getValue();
|
|
var deviceProperties = getPropertiesOfDevice("video", deviceSelected);
|
|
|
|
var defaultDeviceProperties = {};
|
|
if (deviceProperties.hasOwnProperty('default')) {
|
|
if (deviceProperties.default.hasOwnProperty('properties')) {
|
|
defaultDeviceProperties = deviceProperties.default.properties;
|
|
if (defaultDeviceProperties.brightness) {
|
|
conf_editor_video.getEditor("root.grabberV4L2.hardware_brightness").setValue(defaultDeviceProperties.brightness);
|
|
}
|
|
if (defaultDeviceProperties.contrast) {
|
|
conf_editor_video.getEditor("root.grabberV4L2.hardware_contrast").setValue(defaultDeviceProperties.contrast);
|
|
}
|
|
if (defaultDeviceProperties.saturation) {
|
|
conf_editor_video.getEditor("root.grabberV4L2.hardware_saturation").setValue(defaultDeviceProperties.saturation);
|
|
}
|
|
if (defaultDeviceProperties.hue) {
|
|
conf_editor_video.getEditor("root.grabberV4L2.hardware_hue").setValue(defaultDeviceProperties.hue);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
//create introduction
|
|
if (window.showOptHelp) {
|
|
createHint("intro", $.i18n('conf_grabber_fg_intro'), "editor_container_screengrabber");
|
|
createHint("intro", $.i18n('conf_grabber_v4l_intro'), "editor_container_videograbber");
|
|
}
|
|
|
|
removeOverlay();
|
|
|
|
// build dynamic screen input enum
|
|
var updateScreenSourcesList = function (type, discoveryInfo) {
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
var addSelect = false;
|
|
|
|
if (jQuery.isEmptyObject(discoveryInfo)) {
|
|
enumVals.push("NONE");
|
|
enumTitelVals.push($.i18n('edt_conf_grabber_discovered_none'));
|
|
}
|
|
else {
|
|
for (const device of discoveryInfo) {
|
|
enumVals.push(device.device_name);
|
|
}
|
|
conf_editor_screen.getEditor('root.framegrabber').enable();
|
|
configuredDevice = window.serverConfig.framegrabber.available_devices;
|
|
|
|
if ($.inArray(configuredDevice, enumVals) != -1) {
|
|
enumDefaultVal = configuredDevice;
|
|
}
|
|
else {
|
|
addSelect = true;
|
|
}
|
|
}
|
|
if (enumVals.length > 0) {
|
|
updateJsonEditorSelection(conf_editor_screen, 'root.framegrabber',
|
|
'available_devices', {}, enumVals, enumTitelVals, enumDefaultVal, addSelect, false);
|
|
}
|
|
}
|
|
|
|
// build dynamic video input enum
|
|
var updateVideoSourcesList = function (type, discoveryInfo) {
|
|
var enumVals = [];
|
|
var enumTitelVals = [];
|
|
var enumDefaultVal = "";
|
|
var addSelect = false;
|
|
|
|
if (jQuery.isEmptyObject(discoveryInfo)) {
|
|
enumVals.push("NONE");
|
|
enumTitelVals.push($.i18n('edt_conf_grabber_discovered_none'));
|
|
}
|
|
else {
|
|
for (const device of discoveryInfo) {
|
|
enumVals.push(device.device_name);
|
|
}
|
|
conf_editor_video.getEditor('root.grabberV4L2').enable();
|
|
configuredDevice = window.serverConfig.grabberV4L2.available_devices;
|
|
|
|
if ($.inArray(configuredDevice, enumVals) != -1) {
|
|
enumDefaultVal = configuredDevice;
|
|
}
|
|
else {
|
|
addSelect = true;
|
|
}
|
|
}
|
|
|
|
if (enumVals.length > 0) {
|
|
updateJsonEditorSelection(conf_editor_video, 'root.grabberV4L2',
|
|
'available_devices', {}, enumVals, enumTitelVals, enumDefaultVal, addSelect, false);
|
|
}
|
|
}
|
|
|
|
async function discoverInputSources(type, params) {
|
|
const result = await requestInputSourcesDiscovery(type, params);
|
|
|
|
var discoveryResult;
|
|
if (result && !result.error) {
|
|
discoveryResult = result.info;
|
|
}
|
|
else {
|
|
discoveryResult = {
|
|
"video_sources": []
|
|
}
|
|
}
|
|
|
|
switch (type) {
|
|
case "screen":
|
|
discoveredInputSources.screen = discoveryResult.video_sources;
|
|
updateScreenSourcesList(type, discoveredInputSources.screen);
|
|
break;
|
|
case "video":
|
|
discoveredInputSources.video = discoveryResult.video_sources;
|
|
updateVideoSourcesList(type, discoveredInputSources.video);
|
|
break;
|
|
}
|
|
}
|
|
|
|
function getPropertiesOfDevice(type, deviceName) {
|
|
deviceProperties = {};
|
|
for (const deviceRecord of discoveredInputSources[type]) {
|
|
if (deviceRecord.device_name === deviceName) {
|
|
deviceProperties = deviceRecord;
|
|
break;
|
|
}
|
|
}
|
|
return deviceProperties;
|
|
}
|
|
|
|
});
|