Fixes issues when participant leaves caused by removing src dependancies. Stops the tracks when stream is removed.

This commit is contained in:
hristoterezov 2014-11-24 18:14:35 +02:00
parent 99da618811
commit 03f828ba9a
4 changed files with 30 additions and 7 deletions

4
app.js
View File

@ -1422,10 +1422,10 @@ function disposeConference(onUnload) {
// FIXME: probably removing streams is not required and close() should
// be enough
if (connection.jingle.localAudio) {
handler.peerconnection.removeStream(connection.jingle.localAudio);
handler.peerconnection.removeStream(connection.jingle.localAudio, onUnload);
}
if (connection.jingle.localVideo) {
handler.peerconnection.removeStream(connection.jingle.localVideo);
handler.peerconnection.removeStream(connection.jingle.localVideo, onUnload);
}
handler.peerconnection.close();
}

View File

@ -152,8 +152,16 @@ TraceablePeerConnection.prototype.addStream = function (stream) {
};
TraceablePeerConnection.prototype.removeStream = function (stream) {
TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams) {
this.trace('removeStream', stream.id);
if(stopStreams) {
stream.getAudioTracks().forEach(function (track) {
track.stop();
});
stream.getVideoTracks().forEach(function (track) {
track.stop();
});
}
this.peerconnection.removeStream(stream);
};

View File

@ -82,7 +82,7 @@ SessionBase.prototype.switchStreams = function (new_stream, oldStream, success_c
if(self.peerconnection.localDescription) {
oldSdp = new SDP(self.peerconnection.localDescription.sdp);
}
self.peerconnection.removeStream(oldStream);
self.peerconnection.removeStream(oldStream, true);
self.peerconnection.addStream(new_stream);
}

View File

@ -122,7 +122,17 @@ var VideoLayout = (function (my) {
var container = pick.parentNode;
var jid = null;
if(container)
jid = VideoLayout.getPeerContainerResourceJid(container);
{
if(container.id == "localVideoWrapper")
{
jid = Strophe.getResourceFromJid(connection.emuc.myroomjid);
}
else
{
jid = VideoLayout.getPeerContainerResourceJid(container);
}
}
VideoLayout.updateLargeVideo(RTC.getVideoSrc(pick), pick.volume, jid);
} else {
console.warn("Failed to elect large video");
@ -153,7 +163,13 @@ var VideoLayout = (function (my) {
largeVideoState.newSrc = newSrc;
largeVideoState.isVisible = $('#largeVideo').is(':visible');
largeVideoState.isDesktop = isVideoSrcDesktop(jid);
largeVideoState.oldJid = largeVideoState.userJid;
if(jid2Ssrc[largeVideoState.userJid]) {
largeVideoState.oldJid = largeVideoState.userJid;
}
else
{
largeVideoState.oldJid = null;
}
largeVideoState.userJid = jid;
// Screen stream is already rotated
@ -952,7 +968,6 @@ var VideoLayout = (function (my) {
videoSpan = document.getElementById(videoContainerId);
if (!videoSpan) {
console.error("No video element for jid", resourceJid);
return;
}