From bd4542aa588d0774bd9090ef5e45723d77990fd6 Mon Sep 17 00:00:00 2001 From: Baku Hashimoto Date: Mon, 9 Sep 2024 14:09:36 +0900 Subject: [PATCH] [Sigma] Refactor liveview functionality and add getLiveview method --- core/src/TethrPTPUSB/TethrSigma.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/TethrPTPUSB/TethrSigma.ts b/core/src/TethrPTPUSB/TethrSigma.ts index e3dd13e..c86f364 100644 --- a/core/src/TethrPTPUSB/TethrSigma.ts +++ b/core/src/TethrPTPUSB/TethrSigma.ts @@ -1256,6 +1256,7 @@ export class TethrSigma extends TethrPTPUSB { } #canvasMediaStream = new CanvasMediaStream() + #liveviewStream: MediaStream | null = null async startLiveview(): Promise> { const stream = await this.#canvasMediaStream.begin( @@ -1263,6 +1264,8 @@ export class TethrSigma extends TethrPTPUSB { ) this.device.on('idle', this.#updateLiveviewFrame) + this.#liveviewStream = stream + this.emit('liveviewChange', readonlyConfigDesc(stream)) return {status: 'ok', value: stream} @@ -1278,10 +1281,16 @@ export class TethrSigma extends TethrPTPUSB { this.#canvasMediaStream.updateWithImage(bitmap) } + async getLiveview(): Promise { + return this.#liveviewStream + } + async stopLiveview(): Promise { this.#canvasMediaStream.end() this.device.off('idle', this.#updateLiveviewFrame) + this.#liveviewStream = null + this.emit('liveviewChange', readonlyConfigDesc(null)) return {status: 'ok'}