Skip to content

Commit

Permalink
[Sigma] Refactor liveview functionality and add getLiveview method
Browse files Browse the repository at this point in the history
  • Loading branch information
baku89 committed Sep 9, 2024
1 parent e0625b9 commit bd4542a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/TethrPTPUSB/TethrSigma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,13 +1256,16 @@ export class TethrSigma extends TethrPTPUSB {
}

#canvasMediaStream = new CanvasMediaStream()
#liveviewStream: MediaStream | null = null

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

this.#liveviewStream = stream

this.emit('liveviewChange', readonlyConfigDesc(stream))

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

async getLiveview(): Promise<MediaStream | null> {
return this.#liveviewStream
}

async stopLiveview(): Promise<OperationResult> {
this.#canvasMediaStream.end()
this.device.off('idle', this.#updateLiveviewFrame)

this.#liveviewStream = null

this.emit('liveviewChange', readonlyConfigDesc(null))

return {status: 'ok'}
Expand Down

0 comments on commit bd4542a

Please sign in to comment.