Adds getters for peer video selectors and simplifies the code a little bit.
This commit is contained in:
parent
a1b0677442
commit
879fb9a590
|
@ -119,8 +119,8 @@ var RTC = {
|
||||||
return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
|
return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
|
||||||
failure_callback, resolution, bandwidth, fps, desktopStream);
|
failure_callback, resolution, bandwidth, fps, desktopStream);
|
||||||
},
|
},
|
||||||
attachMediaStream: function (element, stream) {
|
attachMediaStream: function (elSelector, stream) {
|
||||||
this.rtcUtils.attachMediaStream(element, stream);
|
this.rtcUtils.attachMediaStream(elSelector, stream);
|
||||||
},
|
},
|
||||||
getStreamID: function (stream) {
|
getStreamID: function (stream) {
|
||||||
return this.rtcUtils.getStreamID(stream);
|
return this.rtcUtils.getStreamID(stream);
|
||||||
|
|
|
@ -237,13 +237,13 @@ function RTCUtils(RTCService, onTemasysPluginReady)
|
||||||
|
|
||||||
self.peerconnection = RTCPeerConnection;
|
self.peerconnection = RTCPeerConnection;
|
||||||
self.getUserMedia = getUserMedia;
|
self.getUserMedia = getUserMedia;
|
||||||
self.attachMediaStream = function (element, stream) {
|
self.attachMediaStream = function (elSel, stream) {
|
||||||
|
|
||||||
if (stream.id === "dummyAudio" || stream.id === "dummyVideo") {
|
if (stream.id === "dummyAudio" || stream.id === "dummyVideo") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
attachMediaStream(element[0], stream);
|
attachMediaStream(elSel[0], stream);
|
||||||
};
|
};
|
||||||
self.getStreamID = function (stream) {
|
self.getStreamID = function (stream) {
|
||||||
var id = SDPUtil.filter_special_chars(stream.label);
|
var id = SDPUtil.filter_special_chars(stream.label);
|
||||||
|
|
|
@ -456,6 +456,11 @@ var VideoLayout = (function (my) {
|
||||||
return containerElement.id.substring(i + 12);
|
return containerElement.id.substring(i + 12);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my.getPeerVideoSel = function (peerResourceJid) {
|
||||||
|
return $('#participant_' + peerResourceJid +
|
||||||
|
'>' + APP.RTC.getVideoElementName());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On contact list item clicked.
|
* On contact list item clicked.
|
||||||
*/
|
*/
|
||||||
|
@ -464,40 +469,40 @@ var VideoLayout = (function (my) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jid == APP.xmpp.myJid()) {
|
||||||
|
$("#localVideoContainer").click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var resource = Strophe.getResourceFromJid(jid);
|
var resource = Strophe.getResourceFromJid(jid);
|
||||||
var videoContainer = $("#participant_" + resource);
|
var videoSel = VideoLayout.getVideoSelector(resource);
|
||||||
if (videoContainer.length > 0) {
|
if (videoSel.length > 0) {
|
||||||
var videoThumb
|
var videoThumb = videoSel[0];
|
||||||
= $(RTC.getVideoElementName(), videoContainer).get(0);
|
|
||||||
// It is not always the case that a videoThumb exists (if there is
|
// It is not always the case that a videoThumb exists (if there is
|
||||||
// no actual video).
|
// no actual video).
|
||||||
if (videoThumb) {
|
// FIXME: checking on .src will not work with Temasys plugin
|
||||||
if (videoThumb.src && videoThumb.src != '') {
|
if (videoThumb.src && videoThumb.src !== '') {
|
||||||
|
|
||||||
// We have a video src, great! Let's update the large video
|
// We have a video src, great! Let's update the large video
|
||||||
// now.
|
// now.
|
||||||
|
VideoLayout.handleVideoThumbClicked(
|
||||||
|
false,
|
||||||
|
Strophe.getResourceFromJid(jid));
|
||||||
|
} else {
|
||||||
|
|
||||||
VideoLayout.handleVideoThumbClicked(
|
// If we don't have a video src for jid, there's absolutely
|
||||||
false,
|
// no point in calling handleVideoThumbClicked; Quite
|
||||||
Strophe.getResourceFromJid(jid));
|
// simply, it won't work because it needs an src to attach
|
||||||
} else {
|
// to the large video.
|
||||||
|
//
|
||||||
|
// Instead, we trigger the pinned endpoint changed event to
|
||||||
|
// let the bridge adjust its lastN set for myjid and store
|
||||||
|
// the pinned user in the lastNPickupJid variable to be
|
||||||
|
// picked up later by the lastN changed event handler.
|
||||||
|
|
||||||
// If we don't have a video src for jid, there's absolutely
|
lastNPickupJid = jid;
|
||||||
// no point in calling handleVideoThumbClicked; Quite
|
eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
|
||||||
// simply, it won't work because it needs an src to attach
|
Strophe.getResourceFromJid(jid));
|
||||||
// to the large video.
|
|
||||||
//
|
|
||||||
// Instead, we trigger the pinned endpoint changed event to
|
|
||||||
// let the bridge adjust its lastN set for myjid and store
|
|
||||||
// the pinned user in the lastNPickupJid variable to be
|
|
||||||
// picked up later by the lastN changed event handler.
|
|
||||||
|
|
||||||
lastNPickupJid = jid;
|
|
||||||
eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
|
|
||||||
Strophe.getResourceFromJid(jid));
|
|
||||||
}
|
|
||||||
} else if (jid == APP.xmpp.myJid()) {
|
|
||||||
$("#localVideoContainer").click();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -530,11 +535,12 @@ var VideoLayout = (function (my) {
|
||||||
if (jid === APP.xmpp.myJid()) {
|
if (jid === APP.xmpp.myJid()) {
|
||||||
localVideoThumbnail.showVideoIndicator(value);
|
localVideoThumbnail.showVideoIndicator(value);
|
||||||
} else {
|
} else {
|
||||||
VideoLayout.ensurePeerContainerExists(jid);
|
var resource = Strophe.getResourceFromJid(jid);
|
||||||
remoteVideos[Strophe.getResourceFromJid(jid)].showVideoIndicator(value);
|
|
||||||
|
|
||||||
var el = $('#participant_' + Strophe.getResourceFromJid(jid)
|
VideoLayout.ensurePeerContainerExists(jid);
|
||||||
+ '>' + APP.RTC.getVideoElementName());
|
remoteVideos[resource].showVideoIndicator(value);
|
||||||
|
|
||||||
|
var el = VideoLayout.getPeerVideoSel(resource);
|
||||||
if (!value)
|
if (!value)
|
||||||
el.show();
|
el.show();
|
||||||
else
|
else
|
||||||
|
@ -587,19 +593,15 @@ var VideoLayout = (function (my) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtain container for new dominant speaker.
|
// Obtain container for new dominant speaker.
|
||||||
var container = document.getElementById(
|
var videoSel = VideoLayout.getPeerVideoSel(resourceJid);
|
||||||
'participant_' + resourceJid);
|
|
||||||
|
|
||||||
// Local video will not have container found, but that's ok
|
// Local video will not have container found, but that's ok
|
||||||
// since we don't want to switch to local video.
|
// since we don't want to switch to local video.
|
||||||
if (container && !focusedVideoResourceJid)
|
if (!focusedVideoResourceJid && videoSel.length)
|
||||||
{
|
{
|
||||||
var video
|
|
||||||
= container.getElementsByTagName(RTC.getVideoElementName());
|
|
||||||
|
|
||||||
// Update the large video if the video source is already available,
|
// Update the large video if the video source is already available,
|
||||||
// otherwise wait for the "videoactive.jingle" event.
|
// otherwise wait for the "videoactive.jingle" event.
|
||||||
if (video.length && video[0].currentTime > 0) {
|
if (videoSel[0].currentTime > 0) {
|
||||||
LargeVideo.updateLargeVideo(resourceJid);
|
LargeVideo.updateLargeVideo(resourceJid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -697,8 +699,7 @@ var VideoLayout = (function (my) {
|
||||||
|
|
||||||
var jid = APP.xmpp.findJidFromResource(resourceJid);
|
var jid = APP.xmpp.findJidFromResource(resourceJid);
|
||||||
var mediaStream = APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
|
var mediaStream = APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
|
||||||
var sel = $('#participant_' + resourceJid +
|
var sel = VideoLayout.getPeerVideoSel(resourceJid);
|
||||||
'>' + RTC.getVideoElementName());
|
|
||||||
|
|
||||||
APP.RTC.attachMediaStream(sel, mediaStream.stream);
|
APP.RTC.attachMediaStream(sel, mediaStream.stream);
|
||||||
if (lastNPickupJid == mediaStream.peerjid) {
|
if (lastNPickupJid == mediaStream.peerjid) {
|
||||||
|
|
Loading…
Reference in New Issue