Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Merge branch 'master' into firefox

hristoterezov5213583af25a
diff --cc app.js
index c9ff1b40ae,928c904360..08128a0820
--- a/app.js
+++ b/app.js
@@@ -253,7 -237,26 +253,25 @@@ function doJoin()
connection.emuc.doJoin(roomjid);
}
-function waitForRemoteVideo(selector, ssrc, stream) {
-
+function waitForRemoteVideo(selector, ssrc, stream, jid) {
+ // XXX(gp) so, every call to this function is *always* preceded by a call
+ // to the RTC.attachMediaStream() function but that call is *not* followed
+ // by an update to the videoSrcToSsrc map!
+ //
+ // The above way of doing things results in video SRCs that don't correspond
+ // to any SSRC for a short period of time (to be more precise, for as long
+ // the waitForRemoteVideo takes to complete). This causes problems (see
+ // bellow).
+ //
+ // I'm wondering why we need to do that; i.e. why call RTC.attachMediaStream()
+ // a second time in here and only then update the videoSrcToSsrc map? Why
+ // not simply update the videoSrcToSsrc map when the RTC.attachMediaStream()
+ // is called the first time? I actually do that in the lastN changed event
+ // handler because the "orphan" video SRC is causing troubles there. The
+ // purpose of this method would then be to fire the "videoactive.jingle".
+ //
+ // Food for though I guess :-)
+
if (selector.removed || !selector.parent().is(":visible")) {
console.warn("Media removed before had started", selector);
return;
diff --cc libs/strophe/strophe.jingle.adapter.js
index 44c9ae2cc5,d0f4847f6c..43f3ca6ceb
--- a/libs/strophe/strophe.jingle.adapter.js
+++ b/libs/strophe/strophe.jingle.adapter.js
@@@ -140,28 -140,13 +140,29 @@@ if (TraceablePeerConnection.prototype._
TraceablePeerConnection.prototype.addStream = function (stream) {
this.trace('addStream', stream.id);
+ simulcast.resetSender();
- this.peerconnection.addStream(stream);
+ try
+ {
+ this.peerconnection.addStream(stream);
+ }
+ catch (e)
+ {
+ console.error(e);
+ return;
+ }
-
};
-TraceablePeerConnection.prototype.removeStream = function (stream) {
+TraceablePeerConnection.prototype.removeStream = function (stream, stopStreams) {
this.trace('removeStream', stream.id);
+ simulcast.resetSender();
+ if(stopStreams) {
+ stream.getAudioTracks().forEach(function (track) {
+ track.stop();
+ });
+ stream.getVideoTracks().forEach(function (track) {
+ track.stop();
+ });
+ }
this.peerconnection.removeStream(stream);
};
diff --cc videolayout.js
index 6b5e890d9f,2d1ae1989b..4cb96aba85
--- a/videolayout.js
+++ b/videolayout.js
@@@ -271,20 -239,17 +274,20 @@@ var VideoLayout = (function (my)
}
};
- my.handleVideoThumbClicked = function(videoSrc, jid) {
- my.handleVideoThumbClicked = function(videoSrc, noPinnedEndpointChangedEvent) {
++ my.handleVideoThumbClicked = function(videoSrc, noPinnedEndpointChangedEvent, jid) {
// Restore style for previously focused video
- var focusJid = getJidFromVideoSrc(focusedVideoSrc);
- var oldContainer = getParticipantContainer(focusJid);
+ var oldContainer = null;
+ if(focusedVideoSrc) {
+ var focusJid = focusedVideoSrc.jid;
+ oldContainer = getParticipantContainer(focusJid);
+ }
if (oldContainer) {
oldContainer.removeClass("videoContainerFocused");
}
- // Unlock current focused.
+ // Unlock current focused.
- if (focusedVideoSrc === videoSrc)
+ if (focusedVideoSrc && focusedVideoSrc.src === videoSrc)
{
focusedVideoSrc = null;
var dominantSpeakerVideo = null;
@@@ -303,16 -271,22 +309,24 @@@
}
// Lock new video
- focusedVideoSrc = videoSrc;
+ focusedVideoSrc = {
+ src: videoSrc,
+ jid: jid
+ };
// Update focused/pinned interface.
- var userJid = getJidFromVideoSrc(videoSrc);
- if (userJid)
+ if (jid)
{
- var container = getParticipantContainer(userJid);
+ var container = getParticipantContainer(jid);
container.addClass("videoContainerFocused");
+
+ if (!noPinnedEndpointChangedEvent) {
+ $(document).trigger("pinnedendpointchanged", [userJid]);
+ }
+ }
+
+ if ($('#largeVideo').attr('src') == videoSrc) {
+ return;
}
// Triggers a "video.selected" event. The "false" parameter indicates
@@@ -1519,10 -1694,16 +1723,10 @@@
var msidParts = msid.split(' ');
var selRemoteVideo = $(['#', 'remoteVideo_', session.sid, '_', msidParts[0]].join(''));
- // FIXME(gp) here we should use the VideoLayout.getPeerContainerResource
- // and VideoLayout.getLargeVideoResource methods.
- var updateLargeVideo = (ssrc2jid[videoSrcToSsrc[selRemoteVideo.attr('src')]]
- == ssrc2jid[videoSrcToSsrc[largeVideoState.newSrc]]);
-
- // We should only update the focused video src if it's not a
- // falsy value.
- var updateFocusedVideoSrc
- = focusedVideoSrc && focusedVideoSrc !== ''
- && (selRemoteVideo.attr('src') == focusedVideoSrc);
+ var updateLargeVideo = (Strophe.getResourceFromJid(ssrc2jid[primarySSRC])
+ == largeVideoState.userJid);
- var updateFocusedVideoSrc = (focusedVideoSrc &&
++ var updateFocusedVideoSrc = (focusedVideoSrc && focusVideoSrc.src && focusVideoSrc.src != '' &&
+ (RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoSrc.src));
var electedStreamUrl;
if (largeVideoState.preload_ssrc == primarySSRC)
@@@ -1538,25 -1719,22 +1742,23 @@@
largeVideoState.preload_ssrc = 0;
- electedStreamUrl = webkitURL.createObjectURL(electedStream);
+ RTC.attachMediaStream(selRemoteVideo, electedStream);
}
-
- selRemoteVideo.attr('src', electedStreamUrl);
- videoSrcToSsrc[selRemoteVideo.attr('src')] = primarySSRC + ''; // what we store there is typeof string.
+ var jid = ssrc2jid[primarySSRC];
+ jid2Ssrc[jid] = primarySSRC;
if (updateLargeVideo) {
- VideoLayout.updateLargeVideo(electedStreamUrl);
+ VideoLayout.updateLargeVideo(RTC.getVideoSrc(selRemoteVideo[0]), null,
+ Strophe.getResourceFromJid(jid));
}
if (updateFocusedVideoSrc) {
- focusedVideoSrc = electedStreamUrl;
+ focusedVideoSrc.src = RTC.getVideoSrc(selRemoteVideo[0]);
}
-
var videoId;
- if(jid == connection.emuc.myroomjid)
+ if(resource == Strophe.getResourceFromJid(connection.emuc.myroomjid))
{
videoId = "localVideoContainer";
}