Skip to content

Commit

Permalink
Notify active streaming session that the application is about to exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Sep 21, 2020
1 parent 059def9 commit 8ee8888
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/Accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@ export class Accessory extends EventEmitter<Events> {
}

unpublish = () => {
if (this.activeCameraController) {
this.activeCameraController.handleShutdown();
}

if (this._server) {
this._server.stop();
this._server = undefined;
Expand Down
8 changes: 7 additions & 1 deletion src/lib/camera/RTPStreamManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,18 @@ export class RTPStreamManagement {

// Private

handleCloseConnection(connectionID: SessionIdentifier) {
handleCloseConnection(connectionID: SessionIdentifier): void {
if (this.connectionID && this.connectionID === connectionID) {
this._handleStopStream();
}
}

handleShutdown(): void {
if (this.connectionID) {
this._handleStopStream();
}
}

handleFactoryReset() {
this.selectedConfiguration = null;
this.setupEndpointsResponse = RTPStreamManagement.initialSetupEndpointsResponse();
Expand Down
4 changes: 4 additions & 0 deletions src/lib/controller/CameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,8 @@ export class CameraController extends EventEmitter<CameraControllerEventMap> imp
}
}

handleShutdown(): void {
this.streamManagements.forEach(management => management.handleShutdown());
}

}

0 comments on commit 8ee8888

Please sign in to comment.