|
@@ -145,21 +145,21 @@ var VideoLayout = (function (my) {
|
145
|
145
|
}
|
146
|
146
|
};
|
147
|
147
|
|
148
|
|
- my.electLastVisibleVideo = function() {
|
|
148
|
+ my.electLastVisibleVideo = function () {
|
149
|
149
|
// pick the last visible video in the row
|
150
|
150
|
// if nobody else is left, this picks the local video
|
151
|
151
|
var jid;
|
152
|
|
- var videoElem = RTC.getVideoElementName();
|
153
|
|
- var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>' + videoElem);
|
154
|
|
- if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
|
155
|
|
- jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
|
|
152
|
+ var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
|
|
153
|
+ if (pick.length) {
|
|
154
|
+ jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
|
156
|
155
|
} else {
|
157
|
156
|
console.info("Last visible video no longer exists");
|
158
|
|
- pick = $('#remoteVideos>span[id!="mixedstream"]>' + videoElem);
|
159
|
|
- if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
|
160
|
|
- jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
|
161
|
|
- } else {
|
162
|
|
- // Try local video
|
|
157
|
+ pick = $('#remoteVideos>span[id!="mixedstream"]');
|
|
158
|
+ if (pick.length) {
|
|
159
|
+ jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
|
|
160
|
+ }
|
|
161
|
+ if (!jid) {
|
|
162
|
+ // Go with local video
|
163
|
163
|
console.info("Fallback to local video...");
|
164
|
164
|
jid = APP.xmpp.myResource();
|
165
|
165
|
}
|
|
@@ -467,15 +467,14 @@ var VideoLayout = (function (my) {
|
467
|
467
|
* DOM element
|
468
|
468
|
*/
|
469
|
469
|
my.getPeerContainerResourceJid = function (containerElement) {
|
|
470
|
+ if (localVideoThumbnail.container === containerElement) {
|
|
471
|
+ return localVideoThumbnail.getResourceJid();
|
|
472
|
+ }
|
|
473
|
+
|
470
|
474
|
var i = containerElement.id.indexOf('participant_');
|
471
|
475
|
|
472
|
476
|
if (i >= 0)
|
473
|
|
- return containerElement.id.substring(i + 12);
|
474
|
|
- };
|
475
|
|
-
|
476
|
|
- my.getPeerVideoSel = function (peerResourceJid) {
|
477
|
|
- return $('#participant_' + peerResourceJid +
|
478
|
|
- '>' + APP.RTC.getVideoElementName());
|
|
477
|
+ return containerElement.id.substring(i + 12);
|
479
|
478
|
};
|
480
|
479
|
|
481
|
480
|
/**
|
|
@@ -492,9 +491,9 @@ var VideoLayout = (function (my) {
|
492
|
491
|
}
|
493
|
492
|
|
494
|
493
|
var resource = Strophe.getResourceFromJid(jid);
|
495
|
|
- var videoSel = VideoLayout.getPeerVideoSel(resource);
|
496
|
|
- if (videoSel.length > 0) {
|
497
|
|
- var videoThumb = videoSel[0];
|
|
494
|
+ var remoteVideo = remoteVideos[resource];
|
|
495
|
+ if (remoteVideo && remoteVideo.selectVideoElement().length) {
|
|
496
|
+ var videoThumb = remoteVideo.selectVideoElement()[0];
|
498
|
497
|
// It is not always the case that a videoThumb exists (if there is
|
499
|
498
|
// no actual video).
|
500
|
499
|
if (RTC.getVideoSrc(videoThumb)) {
|
|
@@ -553,9 +552,10 @@ var VideoLayout = (function (my) {
|
553
|
552
|
var resource = Strophe.getResourceFromJid(jid);
|
554
|
553
|
|
555
|
554
|
VideoLayout.ensurePeerContainerExists(jid);
|
556
|
|
- remoteVideos[resource].showVideoIndicator(value);
|
|
555
|
+ var remoteVideo = remoteVideos[resource];
|
|
556
|
+ remoteVideo.showVideoIndicator(value);
|
557
|
557
|
|
558
|
|
- var el = VideoLayout.getPeerVideoSel(resource);
|
|
558
|
+ var el = remoteVideo.selectVideoElement();
|
559
|
559
|
if (!value)
|
560
|
560
|
el.show();
|
561
|
561
|
else
|
|
@@ -587,18 +587,19 @@ var VideoLayout = (function (my) {
|
587
|
587
|
if (resourceJid === APP.xmpp.myResource())
|
588
|
588
|
return;
|
589
|
589
|
|
|
590
|
+ var remoteVideo = remoteVideos[resourceJid];
|
590
|
591
|
var members = APP.xmpp.getMembers();
|
591
|
592
|
// Update the current dominant speaker.
|
592
|
593
|
if (resourceJid !== currentDominantSpeaker) {
|
593
|
594
|
var currentJID = APP.xmpp.findJidFromResource(currentDominantSpeaker);
|
594
|
595
|
var newJID = APP.xmpp.findJidFromResource(resourceJid);
|
595
|
|
- if(currentDominantSpeaker && (!members || !members[currentJID] ||
|
596
|
|
- !members[currentJID].displayName) && remoteVideos[resourceJid]) {
|
597
|
|
- remoteVideos[resourceJid].setDisplayName(null);
|
|
596
|
+ if (currentDominantSpeaker && (!members || !members[currentJID] ||
|
|
597
|
+ !members[currentJID].displayName) && remoteVideo) {
|
|
598
|
+ remoteVideo.setDisplayName(null);
|
598
|
599
|
}
|
599
|
|
- if(resourceJid && (!members || !members[newJID] ||
|
600
|
|
- !members[newJID].displayName) && remoteVideos[resourceJid]) {
|
601
|
|
- remoteVideos[resourceJid].setDisplayName(null,
|
|
600
|
+ if (resourceJid && (!members || !members[newJID] ||
|
|
601
|
+ !members[newJID].displayName) && remoteVideo) {
|
|
602
|
+ remoteVideo.setDisplayName(null,
|
602
|
603
|
interfaceConfig.DEFAULT_DOMINANT_SPEAKER_DISPLAY_NAME);
|
603
|
604
|
}
|
604
|
605
|
currentDominantSpeaker = resourceJid;
|
|
@@ -606,8 +607,11 @@ var VideoLayout = (function (my) {
|
606
|
607
|
return;
|
607
|
608
|
}
|
608
|
609
|
|
|
610
|
+ if (!remoteVideo)
|
|
611
|
+ return;
|
|
612
|
+
|
609
|
613
|
// Obtain container for new dominant speaker.
|
610
|
|
- var videoSel = VideoLayout.getPeerVideoSel(resourceJid);
|
|
614
|
+ var videoSel = remoteVideo.selectVideoElement();
|
611
|
615
|
|
612
|
616
|
// Local video will not have container found, but that's ok
|
613
|
617
|
// since we don't want to switch to local video.
|
|
@@ -706,14 +710,15 @@ var VideoLayout = (function (my) {
|
706
|
710
|
endpointsEnteringLastN.forEach(function (resourceJid) {
|
707
|
711
|
|
708
|
712
|
var isVisible = $('#participant_' + resourceJid).is(':visible');
|
709
|
|
- remoteVideos[resourceJid].showPeerContainer('show');
|
|
713
|
+ var remoteVideo = remoteVideos[resourceJid];
|
|
714
|
+ remoteVideo.showPeerContainer('show');
|
710
|
715
|
if (!isVisible) {
|
711
|
716
|
console.log("Add to last N", resourceJid);
|
712
|
717
|
|
713
|
718
|
var jid = APP.xmpp.findJidFromResource(resourceJid);
|
714
|
719
|
var mediaStream =
|
715
|
720
|
APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
|
716
|
|
- var sel = VideoLayout.getPeerVideoSel(resourceJid);
|
|
721
|
+ var sel = remoteVideo.selectVideoElement();
|
717
|
722
|
|
718
|
723
|
APP.RTC.attachMediaStream(sel, mediaStream.stream);
|
719
|
724
|
if (lastNPickupJid == mediaStream.peerjid) {
|