From e2fed64b390cf02af3515eb41a5656e2732ad488 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 15 Nov 2020 23:28:00 +0100 Subject: [PATCH] Fixed the video connection for firefox and some minor bugfixes --- ChangeLog.md | 3 + shared/js/ConnectionHandler.ts | 6 +- shared/js/tree/ChannelTree.tsx | 31 +++++---- shared/js/ui/frames/video/Controller.ts | 7 +- shared/js/ui/frames/video/Renderer.tsx | 11 +-- web/app/rtc/Connection.ts | 92 +++++++++++++++++++++++-- web/app/rtc/RemoteTrack.ts | 6 ++ web/app/rtc/SdpUtils.ts | 5 +- web/app/rtc/video/Connection.ts | 27 +++++--- web/app/rtc/voice/Connection.ts | 2 + 10 files changed, 149 insertions(+), 41 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b241800c..68ea38cc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,7 @@ # Changelog: +** 14.11.20** + - Fixed bug where the microphone has been requested when muting it. + * **07.11.20** - Added video broadcasting to the web client - Added various new user interfaces related to video broadcasting diff --git a/shared/js/ConnectionHandler.ts b/shared/js/ConnectionHandler.ts index c012cb1e..219fe63c 100644 --- a/shared/js/ConnectionHandler.ts +++ b/shared/js/ConnectionHandler.ts @@ -826,11 +826,7 @@ export class ConnectionHandler { return; } - if(this.connection_state === ConnectionState.CONNECTED) { - await this.startVoiceRecorder(true); - } else { - this.setInputHardwareState(InputHardwareState.VALID); - } + /* our voice status will be updated automatically due to the notify_recorder_changed event which should be fired when the acquired recorder changed */ } async startVoiceRecorder(notifyError: boolean) : Promise<{ state: "success" | "no-input" } | { state: "error", message: string }> { diff --git a/shared/js/tree/ChannelTree.tsx b/shared/js/tree/ChannelTree.tsx index bc119c73..ab2651a4 100644 --- a/shared/js/tree/ChannelTree.tsx +++ b/shared/js/tree/ChannelTree.tsx @@ -588,7 +588,7 @@ export class ChannelTree { deleteClient(client: ClientEntry, reason: { reason: ViewReasonId, message?: string, serverLeave: boolean }) { const oldChannel = client.currentChannel(); oldChannel?.unregisterClient(client); - this.clients.remove(client); + this.unregisterClient(client); if(oldChannel) { this.events.fire("notify_client_leave_view", { client: client, message: reason.message, reason: reason.reason, isServerLeave: reason.serverLeave, sourceChannel: oldChannel }); @@ -597,30 +597,23 @@ export class ChannelTree { logWarn(LogCategory.CHANNEL, tr("Deleting client %s from channel tree which hasn't a channel."), client.clientId()); } - const voiceConnection = this.client.serverConnection.getVoiceConnection(); - if(client.getVoiceClient()) { - voiceConnection.unregisterVoiceClient(client.getVoiceClient()); - client.setVoiceClient(undefined); - } - - const videoConnection = this.client.serverConnection.getVideoConnection(); - if(client.getVideoClient()) { - videoConnection.unregisterVideoClient(client.getVideoClient()); - client.setVideoClient(undefined); - } client.destroy(); } registerClient(client: ClientEntry) { this.clients.push(client); - if(client instanceof LocalClientEntry) { + const isLocalClient = client instanceof LocalClientEntry; + if(isLocalClient) { if(client.channelTree !== this) { throw tr("client channel tree missmatch"); } } else { client.channelTree = this; + } + /* for debug purposes, the server might send back the own audio/video stream */ + if(!isLocalClient || __build.mode === "debug") { const voiceConnection = this.client.serverConnection.getVoiceConnection(); try { client.setVoiceClient(voiceConnection.registerVoiceClient(client.clientId())); @@ -641,6 +634,18 @@ export class ChannelTree { if(!this.clients.remove(client)) { return; } + + const voiceConnection = this.client.serverConnection.getVoiceConnection(); + if(client.getVoiceClient()) { + voiceConnection.unregisterVoiceClient(client.getVoiceClient()); + client.setVoiceClient(undefined); + } + + const videoConnection = this.client.serverConnection.getVideoConnection(); + if(client.getVideoClient()) { + videoConnection.unregisterVideoClient(client.getVideoClient()); + client.setVideoClient(undefined); + } } insertClient(client: ClientEntry, channel: ChannelEntry, reason: { reason: ViewReasonId, isServerJoin: boolean }) : ClientEntry { diff --git a/shared/js/ui/frames/video/Controller.ts b/shared/js/ui/frames/video/Controller.ts index 3859ffdb..a924563e 100644 --- a/shared/js/ui/frames/video/Controller.ts +++ b/shared/js/ui/frames/video/Controller.ts @@ -351,7 +351,12 @@ class ChannelVideoController { if(localClient.currentChannel()) { this.currentChannelId = localClient.currentChannel().channelId; localClient.currentChannel().channelClientsOrdered().forEach(client => { - if(client instanceof LocalClientEntry || ChannelVideoController.shouldIgnoreClient(client)) { + /* in some instances the server might return our own stream for debug purposes */ + if(client instanceof LocalClientEntry && __build.mode !== "debug") { + return; + } + + if(ChannelVideoController.shouldIgnoreClient(client)) { return; } diff --git a/shared/js/ui/frames/video/Renderer.tsx b/shared/js/ui/frames/video/Renderer.tsx index 84572d75..16988145 100644 --- a/shared/js/ui/frames/video/Renderer.tsx +++ b/shared/js/ui/frames/video/Renderer.tsx @@ -77,16 +77,19 @@ const VideoStreamReplay = React.memo((props: { stream: MediaStream | undefined, const refVideo = useRef(); useEffect(() => { + const video = refVideo.current; if(props.stream) { - refVideo.current.style.opacity = "1"; - refVideo.current.srcObject = props.stream; + video.style.opacity = "1"; + video.srcObject = props.stream; + video.autoplay = true; + video.play().then(undefined); } else { - refVideo.current.style.opacity = "0"; + video.style.opacity = "0"; } }, [ props.stream ]); return ( -