Skip to content

Commit bd4542a

Browse files
committed
[Sigma] Refactor liveview functionality and add getLiveview method
1 parent e0625b9 commit bd4542a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/TethrPTPUSB/TethrSigma.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,13 +1256,16 @@ export class TethrSigma extends TethrPTPUSB {
12561256
}
12571257

12581258
#canvasMediaStream = new CanvasMediaStream()
1259+
#liveviewStream: MediaStream | null = null
12591260

12601261
async startLiveview(): Promise<OperationResult<MediaStream>> {
12611262
const stream = await this.#canvasMediaStream.begin(
12621263
this.#updateLiveviewFrame
12631264
)
12641265
this.device.on('idle', this.#updateLiveviewFrame)
12651266

1267+
this.#liveviewStream = stream
1268+
12661269
this.emit('liveviewChange', readonlyConfigDesc(stream))
12671270

12681271
return {status: 'ok', value: stream}
@@ -1278,10 +1281,16 @@ export class TethrSigma extends TethrPTPUSB {
12781281
this.#canvasMediaStream.updateWithImage(bitmap)
12791282
}
12801283

1284+
async getLiveview(): Promise<MediaStream | null> {
1285+
return this.#liveviewStream
1286+
}
1287+
12811288
async stopLiveview(): Promise<OperationResult> {
12821289
this.#canvasMediaStream.end()
12831290
this.device.off('idle', this.#updateLiveviewFrame)
12841291

1292+
this.#liveviewStream = null
1293+
12851294
this.emit('liveviewChange', readonlyConfigDesc(null))
12861295

12871296
return {status: 'ok'}

0 commit comments

Comments
 (0)