瀏覽代碼

Makes sure we use stream.ended in one place. Replaces deprecated ended call with active check for media streams.

master
damencho 10 年之前
父節點
當前提交
da425c96b5
共有 2 個檔案被更改,包括 21 行新增7 行删除
  1. 1
    1
      modules/RTC/JitsiLocalTrack.js
  2. 20
    6
      modules/RTC/JitsiTrack.js

+ 1
- 1
modules/RTC/JitsiLocalTrack.js 查看文件

@@ -130,7 +130,7 @@ JitsiLocalTrack.prototype.isMuted = function () {
130 130
     if (isAudio) {
131 131
         tracks = this.stream.getAudioTracks();
132 132
     } else {
133
-        if (this.stream.ended)
133
+        if (!this.isActive())
134 134
             return true;
135 135
         tracks = this.stream.getVideoTracks();
136 136
     }

+ 20
- 6
modules/RTC/JitsiTrack.js 查看文件

@@ -3,15 +3,15 @@ var RTCBrowserType = require("./RTCBrowserType");
3 3
 /**
4 4
  * This implements 'onended' callback normally fired by WebRTC after the stream
5 5
  * is stopped. There is no such behaviour yet in FF, so we have to add it.
6
- * @param stream original WebRTC stream object to which 'onended' handling
7
- *               will be added.
6
+ * @param jitsiTrack our track object holding the original WebRTC stream object
7
+ * to which 'onended' handling will be added.
8 8
  */
9
-function implementOnEndedHandling(stream) {
9
+function implementOnEndedHandling(jitsiTrack) {
10
+    var stream = jitsiTrack.getOriginalStream();
10 11
     var originalStop = stream.stop;
11 12
     stream.stop = function () {
12 13
         originalStop.apply(stream);
13
-        if (!stream.ended) {
14
-            stream.ended = true;
14
+        if (jitsiTrack.isActive()) {
15 15
             stream.onended();
16 16
         }
17 17
     };
@@ -66,7 +66,7 @@ function JitsiTrack(rtc, stream, streamInactiveHandler)
66 66
         }.bind(this);
67 67
     }
68 68
     if (RTCBrowserType.isFirefox() && this.stream) {
69
-        implementOnEndedHandling(this.stream);
69
+        implementOnEndedHandling(this);
70 70
     }
71 71
 
72 72
     if(stream)
@@ -171,4 +171,18 @@ JitsiTrack.prototype.getId = function () {
171 171
     return tracks[0].id;
172 172
 };
173 173
 
174
+/**
175
+ * Checks whether the MediaStream is avtive/not ended.
176
+ * When there is no check for active we don't have information and so
177
+ * will return that stream is active (in case of FF).
178
+ * @returns {boolean} whether MediaStream is active.
179
+ */
180
+JitsiTrack.prototype.isActive = function () {
181
+    if((typeof this.stream.active !== "undefined"))
182
+        return this.stream.active;
183
+    else
184
+        return true;
185
+};
186
+
187
+
174 188
 module.exports = JitsiTrack;

Loading…
取消
儲存