ソースを参照

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
     if (isAudio) {
130
     if (isAudio) {
131
         tracks = this.stream.getAudioTracks();
131
         tracks = this.stream.getAudioTracks();
132
     } else {
132
     } else {
133
-        if (this.stream.ended)
133
+        if (!this.isActive())
134
             return true;
134
             return true;
135
         tracks = this.stream.getVideoTracks();
135
         tracks = this.stream.getVideoTracks();
136
     }
136
     }

+ 20
- 6
modules/RTC/JitsiTrack.js ファイルの表示

3
 /**
3
 /**
4
  * This implements 'onended' callback normally fired by WebRTC after the stream
4
  * This implements 'onended' callback normally fired by WebRTC after the stream
5
  * is stopped. There is no such behaviour yet in FF, so we have to add it.
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
     var originalStop = stream.stop;
11
     var originalStop = stream.stop;
11
     stream.stop = function () {
12
     stream.stop = function () {
12
         originalStop.apply(stream);
13
         originalStop.apply(stream);
13
-        if (!stream.ended) {
14
-            stream.ended = true;
14
+        if (jitsiTrack.isActive()) {
15
             stream.onended();
15
             stream.onended();
16
         }
16
         }
17
     };
17
     };
66
         }.bind(this);
66
         }.bind(this);
67
     }
67
     }
68
     if (RTCBrowserType.isFirefox() && this.stream) {
68
     if (RTCBrowserType.isFirefox() && this.stream) {
69
-        implementOnEndedHandling(this.stream);
69
+        implementOnEndedHandling(this);
70
     }
70
     }
71
 
71
 
72
     if(stream)
72
     if(stream)
171
     return tracks[0].id;
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
 module.exports = JitsiTrack;
188
 module.exports = JitsiTrack;

読み込み中…
キャンセル
保存