From 3b60b6d5f31f35fa02bb6de272e9ebd1e81e3a54 Mon Sep 17 00:00:00 2001 From: sylenien Date: Mon, 3 Oct 2022 14:58:35 +0200 Subject: [PATCH] change(tracker): send signal to disable/enable camera feed --- .../Assist/components/VideoContainer/VideoContainer.tsx | 1 + tracker/tracker-assist/src/Assist.ts | 2 ++ tracker/tracker-assist/src/CallWindow.ts | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx index 08adc74c5..fc8fb8e29 100644 --- a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx +++ b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx @@ -23,6 +23,7 @@ function VideoContainer({ stream, muted = false, height = 280, setRemoteEnabled const settings = stream.getVideoTracks()[0]?.getSettings() const isDummyVideoTrack = settings ? (settings.width === 2 || settings.frameRate === 0 || !settings.frameRate && !settings.width) : true const shouldBeEnabled = !isDummyVideoTrack + console.log(stream.getVideoTracks()) if (isEnabled !== shouldBeEnabled) { setEnabled(shouldBeEnabled) setRemoteEnabled?.(shouldBeEnabled) diff --git a/tracker/tracker-assist/src/Assist.ts b/tracker/tracker-assist/src/Assist.ts index d79e008f3..828ccfd79 100644 --- a/tracker/tracker-assist/src/Assist.ts +++ b/tracker/tracker-assist/src/Assist.ts @@ -338,6 +338,7 @@ export default class Assist { this.emit('call_end') handleCallEnd() } + const updateVideoFeed = ({ streamId, enabled, }) => this.emit('videofeed', { streamId, enabled, }) peer.on('call', (call) => { app.debug.log('Incoming call: ', call) @@ -379,6 +380,7 @@ export default class Assist { // UI if (!callUI) { callUI = new CallWindow(app.debug.error, this.options.callUITemplate) + callUI.setVideoCallback(updateVideoFeed) } callUI.showControls(initiateCallEnd) diff --git a/tracker/tracker-assist/src/CallWindow.ts b/tracker/tracker-assist/src/CallWindow.ts index 13b2565a6..bcaa25197 100644 --- a/tracker/tracker-assist/src/CallWindow.ts +++ b/tracker/tracker-assist/src/CallWindow.ts @@ -18,7 +18,7 @@ export default class CallWindow { private controlsContainer: HTMLElement | null = null private remoteVideoOn = false private localVideoOn = false - + private onToggleVideo: (args: any) => void private tsInterval: ReturnType private readonly load: Promise @@ -245,6 +245,7 @@ export default class CallWindow { stream .toggleVideo() .then((enabled) => { + this.onToggleVideo?.({ streamId: stream.stream.id, enabled, }) this.toggleVideoUI(enabled) this.load .then(() => { @@ -300,6 +301,10 @@ export default class CallWindow { this.adjustIframeSize() } + public setVideoCallback(cb) { + this.onToggleVideo = cb + } + remove() { clearInterval(this.tsInterval) clearInterval(this.checkRemoteVideoInterval)