import { printErrorDetail } from '../Utils'; export class WeCameraSession { constructor(p19, q19, r19, s19) { this.configCommitted = false; this.device = p19; this.session = q19; this.preview = r19; this.output = s19; } registerErrorListener(i19) { this.session?.on('error', async (o19) => { await i19(o19); }); this.device?.onInputError(i19); this.preview?.on('error', async (n19) => { await i19(n19); }); this.output?.on('error', async (m19) => { await i19(m19); }); } async registerCameraFrameConsumer(h19) { if (this.session == undefined) { throw Error("registerCameraFrameConsumer fail: cameraInput is undefined"); } if (this.session.canAddOutput(h19)) { this.session.addOutput(h19); } } async registerCameraFrameProvider(g19) { if (this.session == undefined) { throw Error("registerCameraFrameConsumer fail: cameraInput is undefined"); } if (this.session.canAddInput(g19)) { this.session.addInput(g19); } } isInvalid() { return this.session == undefined || this.device.isInvalid() || this.preview == undefined; } async stop() { try { await this.session?.stop(); } catch (f19) { } } async config() { try { if (!this.isInvalid() && !this.configCommitted) { this.session?.beginConfig(); let e19 = this.device.getSysCameraInput(); if (e19 !== undefined) { this.registerCameraFrameProvider(e19); } if (this.preview !== undefined) { this.registerCameraFrameConsumer(this.preview); } if (this.output !== undefined) { this.registerCameraFrameConsumer(this.output); } await this.session?.commitConfig(); this.configCommitted = true; } } catch (d19) { printErrorDetail(d19); } } async start() { try { await this.session?.start(); } catch (c19) { } } async releaseSession() { try { await this.session?.stop(); await this.device?.close(); this.preview?.release(); this.output?.release(); await this.session?.release(); } catch (b19) { } finally { this.configCommitted = false; this.session = undefined; this.output = undefined; this.preview = undefined; } } } 