From 4ad41bc8c5f25d40ef8ab829e83f0fe4e90e1880 Mon Sep 17 00:00:00 2001
From: Mario Jr <mariogasparoni@gmail.com>
Date: Wed, 31 Mar 2021 15:34:52 -0300
Subject: [PATCH] Improvements in muted banner

We now stop the MediaStream (cloned/dummy input stream) when this is not
needed anymore.
We don't create/clone a new MediaStream when it already exists.
Fixed eslint warning in muted-alert/component.jsx
---
 .../imports/ui/components/muted-alert/component.jsx         | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bigbluebutton-html5/imports/ui/components/muted-alert/component.jsx b/bigbluebutton-html5/imports/ui/components/muted-alert/component.jsx
index 582aac49fa..8c67ce721f 100644
--- a/bigbluebutton-html5/imports/ui/components/muted-alert/component.jsx
+++ b/bigbluebutton-html5/imports/ui/components/muted-alert/component.jsx
@@ -9,7 +9,7 @@ import { styles } from './styles';
 const MUTE_ALERT_CONFIG = Meteor.settings.public.app.mutedAlert;
 
 const propTypes = {
-  inputStream: PropTypes.object.isRequired,
+  inputStream: PropTypes.objectOf(PropTypes.object).isRequired,
   isPresenter: PropTypes.bool.isRequired,
   isViewer: PropTypes.bool.isRequired,
   muted: PropTypes.bool.isRequired,
@@ -58,10 +58,14 @@ class MutedAlert extends Component {
   componentWillUnmount() {
     this._isMounted = false;
     if (this.speechEvents) this.speechEvents.stop();
+    if (this.inputStream) {
+      this.inputStream.getTracks().forEach(t => t.stop());
+    }
     this.resetTimer();
   }
 
   cloneMediaStream() {
+    if (this.inputStream) return;
     const { inputStream, muted } = this.props;
     if (inputStream && !muted) this.inputStream = inputStream.clone();
   }
-- 
GitLab