mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 18:12:04 +00:00
rebroadcast: better stream termination logging
This commit is contained in:
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.1.270",
|
||||
"version": "0.1.272",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.1.270",
|
||||
"version": "0.1.272",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/prebuffer-mixin",
|
||||
"version": "0.1.270",
|
||||
"version": "0.1.272",
|
||||
"description": "Rebroadcast and Prebuffer for VideoCameras.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -742,7 +742,7 @@ class PrebufferSession {
|
||||
return;
|
||||
}
|
||||
this.console.warn('SEI packet detected while operating with Scrypted Parser as default. Restarting rebroadcast.');
|
||||
session.kill();
|
||||
session.kill(new Error('restarting due to SEI packet detection'));
|
||||
this.startPrebufferSession();
|
||||
}
|
||||
}
|
||||
@@ -789,7 +789,7 @@ class PrebufferSession {
|
||||
|
||||
if (probingAudioCodec) {
|
||||
this.console.warn('Audio probe complete, ending rebroadcast session and restarting with detected codecs.');
|
||||
session.kill();
|
||||
session.kill(new Error('audio probe completed, restarting'));
|
||||
return this.startPrebufferSession();
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ class PrebufferSession {
|
||||
return;
|
||||
}
|
||||
this.console.log(this.streamName, 'terminating rebroadcast due to inactivity');
|
||||
session.kill();
|
||||
session.kill(new Error('stream inactivity'));
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
@@ -1278,7 +1278,9 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera & VideoCameraCo
|
||||
session.ensurePrebufferSession();
|
||||
let wasActive = false;
|
||||
try {
|
||||
this.console.log('prebuffer session starting');
|
||||
const ps = await session.parserSessionPromise;
|
||||
this.console.log('prebuffer session started');
|
||||
active++;
|
||||
wasActive = true;
|
||||
this.online = !!active;
|
||||
@@ -1356,7 +1358,7 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera & VideoCameraCo
|
||||
|
||||
// kill and reinitiate the prebuffers.
|
||||
for (const session of sessions.values()) {
|
||||
session?.parserSessionPromise?.then(session => session.kill());
|
||||
session?.parserSessionPromise?.then(session => session.kill(new Error('rebroadcast settings changed')));
|
||||
}
|
||||
this.ensurePrebufferSessions();
|
||||
}
|
||||
@@ -1399,7 +1401,7 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera & VideoCameraCo
|
||||
session.clearPrebuffers();
|
||||
session.parserSessionPromise?.then(parserSession => {
|
||||
this.console.log('prebuffer session released');
|
||||
parserSession.kill();
|
||||
parserSession.kill(new Error('rebroadcast disabled'));
|
||||
session.clearPrebuffers();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ export function startRFC4571Parser(console: Console, socket: Readable, sdp: stri
|
||||
sessionKilled = resolve;
|
||||
});
|
||||
|
||||
const kill = () => {
|
||||
const kill = (error?: Error) => {
|
||||
if (isActive) {
|
||||
events.emit('killed');
|
||||
events.emit('error', new Error('killed'));
|
||||
events.emit('error', error || new Error('killed'));
|
||||
}
|
||||
isActive = false;
|
||||
sessionKilled();
|
||||
@@ -95,10 +95,10 @@ export function startRFC4571Parser(console: Console, socket: Readable, sdp: stri
|
||||
};
|
||||
|
||||
socket.on('close', () => {
|
||||
kill();
|
||||
kill(new Error('rfc4751 socket closed'));
|
||||
});
|
||||
socket.on('error', () => {
|
||||
kill();
|
||||
socket.on('error', e => {
|
||||
kill(e);
|
||||
});
|
||||
|
||||
const { resetActivityTimer } = setupActivityTimer('rtsp', kill, events, options?.timeout);
|
||||
@@ -184,7 +184,7 @@ export function startRFC4571Parser(console: Console, socket: Readable, sdp: stri
|
||||
throw e;
|
||||
})
|
||||
.finally(() => {
|
||||
kill();
|
||||
kill(new Error('parser exited'));
|
||||
});
|
||||
|
||||
|
||||
@@ -196,8 +196,8 @@ export function startRFC4571Parser(console: Console, socket: Readable, sdp: stri
|
||||
return inputVideoResolution;
|
||||
},
|
||||
get isActive() { return isActive },
|
||||
kill() {
|
||||
kill();
|
||||
kill(error?: Error) {
|
||||
kill(error);
|
||||
},
|
||||
killed,
|
||||
resetActivityTimer,
|
||||
|
||||
@@ -39,10 +39,10 @@ export async function startRtspSession(console: Console, url: string, mediaStrea
|
||||
sessionKilled = resolve;
|
||||
});
|
||||
|
||||
const kill = () => {
|
||||
const kill = (error?: Error) => {
|
||||
if (isActive) {
|
||||
events.emit('killed');
|
||||
events.emit('error', new Error('killed'));
|
||||
events.emit('error', error || new Error('killed'));
|
||||
}
|
||||
isActive = false;
|
||||
sessionKilled();
|
||||
@@ -50,10 +50,10 @@ export async function startRtspSession(console: Console, url: string, mediaStrea
|
||||
};
|
||||
|
||||
rtspClient.client.on('close', () => {
|
||||
kill();
|
||||
kill(new Error('rtsp socket closed'));
|
||||
});
|
||||
rtspClient.client.on('error', () => {
|
||||
kill();
|
||||
rtspClient.client.on('error', e => {
|
||||
kill(e);
|
||||
});
|
||||
|
||||
const { resetActivityTimer } = setupActivityTimer('rtsp', kill, events, options?.rtspRequestTimeout);
|
||||
@@ -177,7 +177,9 @@ export async function startRtspSession(console: Console, url: string, mediaStrea
|
||||
|
||||
// don't start parsing until next tick when this function returns to allow
|
||||
// event handlers to be set prior to parsing.
|
||||
process.nextTick(() => rtspClient.readLoop().finally(kill));
|
||||
process.nextTick(() => rtspClient.readLoop()
|
||||
.catch(e => kill(e))
|
||||
.finally(() => kill(new Error('rtsp read loop exited'))));
|
||||
|
||||
// this return block is intentional, to ensure that the remaining code happens sync.
|
||||
return (() => {
|
||||
@@ -217,8 +219,8 @@ export async function startRtspSession(console: Console, url: string, mediaStrea
|
||||
return inputVideoResolution;
|
||||
},
|
||||
get isActive() { return isActive },
|
||||
kill() {
|
||||
kill();
|
||||
kill(error?: Error) {
|
||||
kill(error);
|
||||
},
|
||||
killed,
|
||||
resetActivityTimer,
|
||||
|
||||
Reference in New Issue
Block a user