mirror of
https://github.com/koush/scrypted.git
synced 2026-06-21 17:10:25 +01:00
rebroadcast: set online/offline state without prebuffer requirement
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"scrypted.debugHost": "127.0.0.1",
|
||||
"scrypted.debugHost": "scrypted-nvr",
|
||||
}
|
||||
4
plugins/prebuffer-mixin/package-lock.json
generated
4
plugins/prebuffer-mixin/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.10.36",
|
||||
"version": "0.10.37",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.10.36",
|
||||
"version": "0.10.37",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.10.36",
|
||||
"version": "0.10.37",
|
||||
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -196,13 +196,33 @@ class PrebufferSession {
|
||||
return;
|
||||
this.console.log(this.streamName, 'prebuffer session started');
|
||||
this.parserSessionPromise = this.startPrebufferSession();
|
||||
this.parserSessionPromise.then(pso => pso.killed.finally(() => {
|
||||
this.console.error(this.streamName, 'prebuffer session ended');
|
||||
this.parserSessionPromise = undefined;
|
||||
}))
|
||||
let active = false;
|
||||
this.parserSessionPromise.then(pso => {
|
||||
pso.once('rtsp', () => {
|
||||
active = true;
|
||||
if (!this.mixin.online)
|
||||
this.mixin.online = true;
|
||||
});
|
||||
|
||||
pso.killed.finally(() => {
|
||||
this.console.error(this.streamName, 'prebuffer session ended');
|
||||
this.parserSessionPromise = undefined;
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
this.console.error(this.streamName, 'prebuffer session ended with error', e);
|
||||
this.parserSessionPromise = undefined;
|
||||
|
||||
if (!active) {
|
||||
// find sessions that arent this one, and check their prebuffers to see if any data has been received.
|
||||
// if there's no data, then consider this camera offline.
|
||||
const others = [...this.mixin.sessions.values()].filter(s => s !== this);
|
||||
if (others.length) {
|
||||
const hasData = others.some(s => s.rtspPrebuffer.length);
|
||||
if (!hasData && this.mixin.online)
|
||||
this.mixin.online = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1415,11 +1435,6 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera> implements Vid
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabledIds.length)
|
||||
this.online = true;
|
||||
|
||||
let active = 0;
|
||||
|
||||
// figure out the default stream and streams that may have been removed due to
|
||||
// a config change.
|
||||
const toRemove = new Set(this.sessions.keys());
|
||||
@@ -1462,23 +1477,13 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera> implements Vid
|
||||
}
|
||||
|
||||
session.ensurePrebufferSession();
|
||||
let wasActive = false;
|
||||
try {
|
||||
this.console.log(name, 'prebuffer session starting');
|
||||
const ps = await session.parserSessionPromise;
|
||||
active++;
|
||||
wasActive = true;
|
||||
this.online = !!active;
|
||||
await ps.killed;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
finally {
|
||||
if (wasActive)
|
||||
active--;
|
||||
wasActive = false;
|
||||
this.online = !!active;
|
||||
}
|
||||
this.console.log(this.name, 'restarting prebuffer session in 5 seconds');
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
}
|
||||
|
||||
2
plugins/ring/.vscode/settings.json
vendored
2
plugins/ring/.vscode/settings.json
vendored
@@ -1,4 +1,4 @@
|
||||
|
||||
{
|
||||
"scrypted.debugHost": "127.0.0.1",
|
||||
"scrypted.debugHost": "scrypted-nvr",
|
||||
}
|
||||
4
server/package-lock.json
generated
4
server/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.121.4",
|
||||
"version": "0.121.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.121.4",
|
||||
"version": "0.121.5",
|
||||
"hasInstallScript": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user