|
|
@@ -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;
|