Skip to content

Commit 61a41e7

Browse files
committed
Fix inactive timeout.
1 parent 22a92ca commit 61a41e7

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## v3.0.1 (2020-08-25)
6+
7+
### Bug Fixes
8+
9+
- Fixed an issue with inactive camera timeouts that could cause zombie FFmpeg processes.
10+
511
## v3.0.0 (2020-08-24)
612

713
### Changes

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"displayName": "Homebridge Camera FFmpeg",
33
"name": "homebridge-camera-ffmpeg",
4-
"version": "3.0.0",
4+
"version": "3.0.1",
55
"description": "Homebridge Plugin Providing FFmpeg-based Camera Support",
66
"main": "dist/index.js",
77
"license": "ISC",

src/streamingDelegate.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ export class StreamingDelegate implements CameraStreamingDelegate {
367367
clearTimeout(activeSession.timeout);
368368
}
369369
activeSession.timeout = setTimeout(() => {
370-
activeSession.socket?.close();
371370
this.log.info('Device appears to be inactive. Stopping stream.', this.cameraName);
372371
this.controller.forceStopStreamingSession(request.sessionID);
373372
this.stopStream(request.sessionID);
@@ -434,20 +433,28 @@ export class StreamingDelegate implements CameraStreamingDelegate {
434433
}
435434

436435
public stopStream(sessionId: string): void {
437-
try {
438-
const session = this.ongoingSessions[sessionId];
439-
if (session) {
440-
if (session.timeout) {
441-
clearTimeout(session.timeout);
442-
}
436+
const session = this.ongoingSessions[sessionId];
437+
if (session) {
438+
if (session.timeout) {
439+
clearTimeout(session.timeout);
440+
}
441+
try {
443442
session.socket?.close();
443+
} catch (err) {
444+
this.log.error('Error occurred closing socket: ' + err, this.cameraName);
445+
}
446+
try {
444447
session.mainProcess?.stop();
448+
} catch (err) {
449+
this.log.error('Error occurred terminating main FFmpeg process: ' + err, this.cameraName);
450+
}
451+
try {
445452
session.returnProcess?.stop();
453+
} catch (err) {
454+
this.log.error('Error occurred terminating two-way FFmpeg process: ' + err, this.cameraName);
446455
}
447-
delete this.ongoingSessions[sessionId];
448-
this.log.info('Stopped video stream.', this.cameraName);
449-
} catch (err) {
450-
this.log.error('Error occurred terminating FFmpeg process: ' + err, this.cameraName);
451456
}
457+
delete this.ongoingSessions[sessionId];
458+
this.log.info('Stopped video stream.', this.cameraName);
452459
}
453460
}

0 commit comments

Comments
 (0)