Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Jan 13, 2022
1 parent 60cc3ad commit 8536391
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 195 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file.
# Next

## Other Changes
- Reduced default videoanalysis sensitivity to 25
- Removed session control
- Videoanalysis improvements
- Refactored web stream
- Improved camera pinging
- Moved ENOENT messages to debug (eg. if recording not found)
- Minor UI improvements

## Bugfixes
- Fixed an issue where resetting motion via MQTT didnt work
- Fixed an issue where the video analysis sensitivity does not work as desired
- Fixed an issue where mapping video/audio stream didnt work (ffmpeg)
- Minor Bugfixes

# [1.0.4] - 2022-01-11

Expand Down
29 changes: 20 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camera.ui",
"version": "1.0.5-beta.0",
"version": "1.0.5",
"description": "User Interface for RTSP capable cameras.",
"author": "SeydX (https://github.com/SeydX/camera.ui)",
"scripts": {
Expand Down Expand Up @@ -39,7 +39,8 @@
"morgan": "^1.10.0",
"mqtt": "^4.3.4",
"multer": "^1.4.4",
"nanoid": "^3.1.31",
"nanoid": "^3.1.32",
"nodejs-tcp-ping": "^1.0.3",
"os": "^0.1.2",
"pam-diff": "^1.1.0",
"piexifjs": "^1.0.6",
Expand Down
17 changes: 14 additions & 3 deletions src/api/components/files/files.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

const path = require('path');

const SettingsModel = require('../settings/settings.model');

const { ConfigService } = require('../../../services/config/config.service');
const { LoggerService } = require('../../../services/logger/logger.service');

const SettingsModel = require('../settings/settings.model');
const { log } = LoggerService;

exports.serve = async (req, res) => {
exports.serve = async (req, res, next) => {
try {
const recordingSettings = await SettingsModel.getByTarget(false, 'recordings');

Expand All @@ -23,7 +26,15 @@ exports.serve = async (req, res) => {
root: path.join(recPath),
};

res.sendFile(file, options);
res.sendFile(file, options, (err) => {
if (err) {
if (err?.status === 404 || err?.statusCode === 404) {
log.debug(err.message);
}

next();
}
});
} catch (error) {
res.status(500).send({
statusCode: 500,
Expand Down
29 changes: 0 additions & 29 deletions src/api/components/settings/settings.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,10 @@ exports.patchTarget = async (req, res) => {
await SettingsModel.patchByTarget(req.query.all, req.params.target, req.body);

if (req.params.target === 'cameras') {
/*if (req.query.stopStream === 'true') {
for (const controller of cameras.values()) {
controller.stream?.stop();
}
}*/

//log.debug('Camera settings changed. The changes take effect when the camera stream is restarted.');

const cameraSettings = req.body;

for (const camera of cameraSettings) {
const controller = cameras.get(camera.name);

let setting = {
'-s': camera.resolution,
};

if (camera.audio) {
controller?.stream?.delStreamOptions(['-an']);

setting = {
...setting,
'-codec:a': 'mp2',
'-ar': '44100',
'-ac': '1',
'-b:a': '128k',
};
} else {
controller?.stream?.delStreamOptions(['-codec:a', '-ar', '-ac', '-b:a']);
setting['-an'] = '';
}

controller?.stream.setStreamOptions(setting);
controller?.videoanalysis.changeZone(camera.videoanalysis.regions, camera.videoanalysis.sensitivity);
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/api/components/system/system.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ exports.clearLog = async (req, res) => {
}
};

exports.downloadDb = async (req, res) => {
exports.downloadDb = async (req, res, next) => {
try {
const dbPath = ConfigService.databaseFilePath;
//const dbJson = JSON.stringify((await fs.readJSON(dbPath, { throws: false })) || {});

res.header('Content-Type', 'application/json');
res.sendFile(dbPath);
res.sendFile(dbPath, (err) => {
if (err) {
if (err?.status === 404 || err?.statusCode === 404) {
log.debug(err.message);
}

next();
}
});
} catch (error) {
res.status(500).send({
statusCode: 500,
Expand Down
2 changes: 1 addition & 1 deletion src/api/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const defaultCameraSettingsEntry = {
labels: [],
},
videoanalysis: {
sensitivity: 50,
sensitivity: 25,
regions: [],
},
};
Expand Down
32 changes: 25 additions & 7 deletions src/common/ping.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use-strict';

const nodejsTcpPing = require('nodejs-tcp-ping');
const ping = require('ping');
const { URL } = require('url');

Expand All @@ -26,16 +27,33 @@ class Ping {

const url = new URL(cameraSource);

log.debug(`Pinging ${url.hostname}`, camera.name);
log.debug(`Pinging ${url.hostname}:${url.port || 80}`, camera.name);

const response = await ping.promise.probe(url.hostname, {
timeout: timeout || 1,
extra: ['-i', '2'],
});
let available = false;

let available = response && response.alive;
try {
const response = await nodejsTcpPing.tcpPing({
attempts: 5,
host: url.hostname,
port: Number.parseInt(url.port) || 80,
timeout: (timeout || 1) * 1000,
});

log.debug(`Pinging ${url.hostname} - ${available ? 'successful' : 'failed'}`, camera.name);
available = response.filter((result) => result.ping).length > 2;
} catch {
//ignore
}

if (!available) {
const response = await ping.promise.probe(url.hostname, {
timeout: timeout || 1,
extra: ['-i', '2'],
});

available = response && response.alive;
}

log.debug(`Pinging ${url.hostname}:${url.port || 80} - ${available ? 'successful' : 'failed'}`, camera.name);

return available;
}
Expand Down
Loading

0 comments on commit 8536391

Please sign in to comment.