Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Makes sure we use stream.ended in one place.

damencho74227e182abb
diff --git a/modules/RTC/LocalStream.js b/modules/RTC/LocalStream.js
index 4f13cce3cb..a20a219d0d 100644
--- a/modules/RTC/LocalStream.js
+++ b/modules/RTC/LocalStream.js
@@ -9,11 +9,12 @@ var RTCBrowserType = require("./RTCBrowserType");
* @param stream original WebRTC stream object to which 'onended' handling
* will be added.
*/
-function implementOnEndedHandling(stream) {
+function implementOnEndedHandling(localStream) {
+ var stream = localStream.getOriginalStream();
var originalStop = stream.stop;
stream.stop = function () {
originalStop.apply(stream);
- if (!stream.ended) {
+ if (localStream.isActive()) {
stream.ended = true;
stream.onended();
}
@@ -46,7 +47,7 @@ function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
});
if (RTCBrowserType.isFirefox()) {
- implementOnEndedHandling(this.stream);
+ implementOnEndedHandling(this);
}
}
@@ -109,7 +110,7 @@ LocalStream.prototype.isMuted = function () {
if (this.isAudioStream()) {
tracks = this.stream.getAudioTracks();
} else {
- if (this.stream.ended)
+ if (this.isActive())
return true;
tracks = this.stream.getVideoTracks();
}
@@ -124,4 +125,12 @@ LocalStream.prototype.getId = function () {
return this.stream.getTracks()[0].id;
};
+/**
+ * Checks whether the MediaStream is avtive/not ended.
+ * @returns {boolean} whether MediaStream is active.
+ */
+LocalStream.prototype.isActive = function () {
+ return !this.stream.ended;
+};
+
module.exports = LocalStream;