change(tracker): send signal to disable/enable camera feed

This commit is contained in:
sylenien 2022-10-03 14:58:35 +02:00 committed by Delirium
parent d48a580d62
commit 3b60b6d5f3
3 changed files with 9 additions and 1 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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<typeof setInterval>
private readonly load: Promise<void>
@ -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)