Makes sure we use stream.ended in one place.
This commit is contained in:
parent
8cebbbb347
commit
74227e182a
|
@ -9,11 +9,12 @@ var RTCBrowserType = require("./RTCBrowserType");
|
||||||
* @param stream original WebRTC stream object to which 'onended' handling
|
* @param stream original WebRTC stream object to which 'onended' handling
|
||||||
* will be added.
|
* will be added.
|
||||||
*/
|
*/
|
||||||
function implementOnEndedHandling(stream) {
|
function implementOnEndedHandling(localStream) {
|
||||||
|
var stream = localStream.getOriginalStream();
|
||||||
var originalStop = stream.stop;
|
var originalStop = stream.stop;
|
||||||
stream.stop = function () {
|
stream.stop = function () {
|
||||||
originalStop.apply(stream);
|
originalStop.apply(stream);
|
||||||
if (!stream.ended) {
|
if (localStream.isActive()) {
|
||||||
stream.ended = true;
|
stream.ended = true;
|
||||||
stream.onended();
|
stream.onended();
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (RTCBrowserType.isFirefox()) {
|
if (RTCBrowserType.isFirefox()) {
|
||||||
implementOnEndedHandling(this.stream);
|
implementOnEndedHandling(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ LocalStream.prototype.isMuted = function () {
|
||||||
if (this.isAudioStream()) {
|
if (this.isAudioStream()) {
|
||||||
tracks = this.stream.getAudioTracks();
|
tracks = this.stream.getAudioTracks();
|
||||||
} else {
|
} else {
|
||||||
if (this.stream.ended)
|
if (this.isActive())
|
||||||
return true;
|
return true;
|
||||||
tracks = this.stream.getVideoTracks();
|
tracks = this.stream.getVideoTracks();
|
||||||
}
|
}
|
||||||
|
@ -124,4 +125,12 @@ LocalStream.prototype.getId = function () {
|
||||||
return this.stream.getTracks()[0].id;
|
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;
|
module.exports = LocalStream;
|
||||||
|
|
Loading…
Reference in New Issue