Uses one method from RTC to stop media streams.
This commit is contained in:
parent
932af962b2
commit
11e1197901
|
@ -210,8 +210,8 @@ var RTC = {
|
||||||
var videoStream = this.rtcUtils.createStream(stream, true);
|
var videoStream = this.rtcUtils.createStream(stream, true);
|
||||||
this.localVideo =
|
this.localVideo =
|
||||||
this.createLocalStream(videoStream, "video", true, type);
|
this.createLocalStream(videoStream, "video", true, type);
|
||||||
// Stop the stream to trigger onended event for old stream
|
// Stop the stream
|
||||||
oldStream.stop();
|
this.stopMediaStream(oldStream);
|
||||||
|
|
||||||
APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
|
APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
|
||||||
},
|
},
|
||||||
|
@ -219,8 +219,8 @@ var RTC = {
|
||||||
var oldStream = this.localAudio.getOriginalStream();
|
var oldStream = this.localAudio.getOriginalStream();
|
||||||
var newStream = this.rtcUtils.createStream(stream);
|
var newStream = this.rtcUtils.createStream(stream);
|
||||||
this.localAudio = this.createLocalStream(newStream, "audio", true);
|
this.localAudio = this.createLocalStream(newStream, "audio", true);
|
||||||
// Stop the stream to trigger onended event for old stream
|
// Stop the stream
|
||||||
oldStream.stop();
|
this.stopMediaStream(oldStream);
|
||||||
APP.xmpp.switchStreams(newStream, oldStream, callback, true);
|
APP.xmpp.switchStreams(newStream, oldStream, callback, true);
|
||||||
},
|
},
|
||||||
isVideoMuted: function (jid) {
|
isVideoMuted: function (jid) {
|
||||||
|
@ -262,6 +262,29 @@ var RTC = {
|
||||||
if(devices.video === true || devices.video === false)
|
if(devices.video === true || devices.video === false)
|
||||||
this.devices.video = devices.video;
|
this.devices.video = devices.video;
|
||||||
eventEmitter.emit(RTCEvents.AVAILABLE_DEVICES_CHANGED, this.devices);
|
eventEmitter.emit(RTCEvents.AVAILABLE_DEVICES_CHANGED, this.devices);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* A method to handle stopping of the stream.
|
||||||
|
* One point to handle the differences in various implementations.
|
||||||
|
*/
|
||||||
|
stopMediaStream: function (mediaStream) {
|
||||||
|
mediaStream.getAudioTracks().forEach(function (track) {
|
||||||
|
// stop() not supported with IE
|
||||||
|
if (track.stop) {
|
||||||
|
track.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mediaStream.getVideoTracks().forEach(function (track) {
|
||||||
|
// stop() not supported with IE
|
||||||
|
if (track.stop) {
|
||||||
|
track.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
if (mediaStream.stop) {
|
||||||
|
mediaStream.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -258,21 +258,7 @@ TraceablePeerConnection.prototype.addStream = function (stream) {
|
||||||
TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams) {
|
TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams) {
|
||||||
this.trace('removeStream', stream.id);
|
this.trace('removeStream', stream.id);
|
||||||
if(stopStreams) {
|
if(stopStreams) {
|
||||||
stream.getAudioTracks().forEach(function (track) {
|
RTC.stopMediaStream(stream);
|
||||||
// stop() not supported with IE
|
|
||||||
if (track.stop) {
|
|
||||||
track.stop();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
stream.getVideoTracks().forEach(function (track) {
|
|
||||||
// stop() not supported with IE
|
|
||||||
if (track.stop) {
|
|
||||||
track.stop();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (stream.stop) {
|
|
||||||
stream.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue