|
@@ -9,11 +9,12 @@ var RTCBrowserType = require("./RTCBrowserType");
|
9
|
9
|
* @param stream original WebRTC stream object to which 'onended' handling
|
10
|
10
|
* will be added.
|
11
|
11
|
*/
|
12
|
|
-function implementOnEndedHandling(stream) {
|
|
12
|
+function implementOnEndedHandling(localStream) {
|
|
13
|
+ var stream = localStream.getOriginalStream();
|
13
|
14
|
var originalStop = stream.stop;
|
14
|
15
|
stream.stop = function () {
|
15
|
16
|
originalStop.apply(stream);
|
16
|
|
- if (!stream.ended) {
|
|
17
|
+ if (localStream.isActive()) {
|
17
|
18
|
stream.ended = true;
|
18
|
19
|
stream.onended();
|
19
|
20
|
}
|
|
@@ -46,7 +47,7 @@ function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
|
46
|
47
|
});
|
47
|
48
|
|
48
|
49
|
if (RTCBrowserType.isFirefox()) {
|
49
|
|
- implementOnEndedHandling(this.stream);
|
|
50
|
+ implementOnEndedHandling(this);
|
50
|
51
|
}
|
51
|
52
|
}
|
52
|
53
|
|
|
@@ -109,7 +110,7 @@ LocalStream.prototype.isMuted = function () {
|
109
|
110
|
if (this.isAudioStream()) {
|
110
|
111
|
tracks = this.stream.getAudioTracks();
|
111
|
112
|
} else {
|
112
|
|
- if (this.stream.ended)
|
|
113
|
+ if (this.isActive())
|
113
|
114
|
return true;
|
114
|
115
|
tracks = this.stream.getVideoTracks();
|
115
|
116
|
}
|
|
@@ -124,4 +125,12 @@ LocalStream.prototype.getId = function () {
|
124
|
125
|
return this.stream.getTracks()[0].id;
|
125
|
126
|
};
|
126
|
127
|
|
|
128
|
+/**
|
|
129
|
+ * Checks whether the MediaStream is avtive/not ended.
|
|
130
|
+ * @returns {boolean} whether MediaStream is active.
|
|
131
|
+ */
|
|
132
|
+LocalStream.prototype.isActive = function () {
|
|
133
|
+ return !this.stream.ended;
|
|
134
|
+};
|
|
135
|
+
|
127
|
136
|
module.exports = LocalStream;
|