diff --git a/web/index.html b/web/index.html
index cd668d80..19b55325 100644
--- a/web/index.html
+++ b/web/index.html
@@ -134,10 +134,10 @@
-
+
-
+
diff --git a/web/js/controller.js b/web/js/controller.js
index 55708867..acf73adf 100644
--- a/web/js/controller.js
+++ b/web/js/controller.js
@@ -449,6 +449,7 @@
event.sub(CONNECTION_CLOSED, () => {
input.poll().disable();
socket.abort();
+ rtcp.stop();
});
event.sub(LATENCY_CHECK_REQUESTED, onLatencyCheck);
event.sub(GAMEPAD_CONNECTED, () => message.show('Gamepad connected'));
@@ -472,4 +473,4 @@
// initial app state
setState(app.state.eden);
-})(document, event, env, gameList, input, KEY, log, message, recording, room, settings, socket, stats, stream, utils);
+})(document, event, env, gameList, input, KEY, log, message, recording, room, rtcp, settings, socket, stats, stream, utils);
diff --git a/web/js/network/rtcp.js b/web/js/network/rtcp.js
index 6dd48274..b785671e 100644
--- a/web/js/network/rtcp.js
+++ b/web/js/network/rtcp.js
@@ -68,6 +68,26 @@ const rtcp = (() => {
}
}
+ const stop = () => {
+ if (mediaStream) {
+ mediaStream.getTracks().forEach(t => {
+ t.stop();
+ mediaStream.removeTrack(t);
+ });
+ mediaStream = null;
+ }
+ if (connection) {
+ connection.close();
+ connection = null;
+ }
+ if (inputChannel) {
+ inputChannel.close();
+ inputChannel = null;
+ }
+ candidates = Array();
+ log.info('[rtcp] WebRTC has been closed');
+ }
+
const ice = (() => {
const ICE_TIMEOUT = 2000;
let timeForIceGathering;
@@ -165,5 +185,6 @@ const rtcp = (() => {
isConnected: () => connected,
isInputReady: () => inputReady,
getConnection: () => connection,
+ stop,
}
})(event, socket, env, log);