Skip to content

Commit

Permalink
SAK-29127
Browse files Browse the repository at this point in the history
Hand-merge PR#326 from sinmsinm
  • Loading branch information
sinmsinm authored and jonespm committed Mar 22, 2015
1 parent bb594e3 commit 3469596
Show file tree
Hide file tree
Showing 32 changed files with 1,106 additions and 645 deletions.
393 changes: 265 additions & 128 deletions portal/portal-charon/charon/src/webapp/scripts/chat.js

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions portal/portal-charon/charon/src/webapp/scripts/videocall.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
this.changeCallStatus(peerUUID, portal.chat.video.statuses.CANCELLING);
}
this.webrtc.hangUp(peerUUID, skipBye);
var chatDiv = $("#pc_chat_with_" + peerUUID);
var chatDiv = $(portal.chat.domSelectors.pcChatWithPre + peerUUID);
chatDiv.removeClass("video_active");
portal.chat.video.hideMyVideo();
};
Expand All @@ -103,7 +103,7 @@
if (debug) console.debug('video.startCall(' + peerUUID + ')');

this.showMyVideo();
this.webrtc.attachMediaStream(document.getElementById("pc_chat_local_video"), localMediaStream);
this.webrtc.attachMediaStream(document.getElementById(portal.chat.domNames.pcChatVideoLocalVideo), localMediaStream);
};

portal.chat.video.maximizeVideo = function (videoElement) {
Expand All @@ -126,7 +126,7 @@
var fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled;

if (fullscreenEnabled) {
var remoteVideo = document.getElementById("pc_chat_" + peerUUID + "_remote_video");
var remoteVideo = document.getElementById(portal.chat.domNames.pcChatRemoteVideoPre + peerUUID );
var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement;

if (fullscreenElement === remoteVideo){
Expand Down Expand Up @@ -154,7 +154,7 @@

if (debug) console.debug('video.successCall(' + peerUUID + ')');

this.webrtc.attachMediaStream(document.getElementById("pc_chat_" + peerUUID + "_remote_video"), remoteMediaStream);
this.webrtc.attachMediaStream(document.getElementById(portal.chat.domNames.pcChatRemoteVideoPre + peerUUID), remoteMediaStream);
this.setVideoStatus (peerUUID, this.messages.pc_video_status_connection_established, "video");

};
Expand Down Expand Up @@ -189,7 +189,7 @@

if (debug) console.debug('video.maximizeVideoCall(' + peerUUID + ')');

var remoteVideo = document.getElementById("pc_chat_" + peerUUID + "_remote_video");
var remoteVideo = document.getElementById(portal.chat.domNames.pcChatRemoteVideoPre + peerUUID);
this.maximizeVideo (remoteVideo);
};

Expand All @@ -199,7 +199,7 @@

this.webrtc.disableLocalVideo();
$('#enable_local_video').show();
$('#pc_chat_local_video').hide();
$('#'+portal.chat.domNames.pcChatVideoLocalVideo).hide();
$('#disable_local_video').hide();
};

Expand All @@ -209,7 +209,7 @@

this.webrtc.enableLocalVideo();
$('#disable_local_video').show();
$('#pc_chat_local_video').show();
$('#'+portal.chat.domNames.pcChatVideoLocalVideo).show();
$('#enable_local_video').hide();
};

Expand Down Expand Up @@ -274,16 +274,16 @@
if (this.getCurrentCallStatus(peerUUID) === this.statuses.ESTABLISHING && this.getCurrentCallTime(peerUUID) === timeLimit) {
this.setVideoStatus(peerUUID, this.messages.pc_video_status_call_timeout, "failed");
this.doClose(peerUUID);
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').hide();
}
};

portal.chat.video.doAnswerTimeout = function (peerUUID, timeLimit) {

if (debug) console.debug('video.doAnswerTimeout(' + peerUUID + ', ' + timeLimit + ')');

if ($('#pc_connection_' + peerUUID + '_videoin').is(":visible")
if ($(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).is(":visible")
&& (!this.webrtc.currentPeerConnectionsMap[peerUUID] || this.getCurrentCallStatus(peerUUID) === this.statuses.CANCELLING)
&& this.getCurrentCallTime (peerUUID) == timeLimit) {

Expand All @@ -308,16 +308,16 @@
}

// If a chat window is already open for this sender, show video.
var messagePanel = $("#pc_chat_with_" + peerUUID);
var messagePanel = $(portal.chat.domSelectors.pcChatWithPre+ peerUUID);
if (!messagePanel.length) {
// No current chat window for this sender. Create one.
portal.chat.setupChatWindow(peerUUID, true);
}

if (incoming) {
this.showVideoCall(peerUUID);
$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').hide();
$('#pc_connection_' + peerUUID + '_videoin').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).hide();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).show();
} else {
if (!this.getCurrentCall(peerUUID)) {
this.setVideoStatus(peerUUID, portal.chat.video.messages.pc_video_status_setup, "waiting");
Expand Down Expand Up @@ -364,9 +364,9 @@

if (self.debug) console.debug('webrtc: doCall onFailedCallback');

$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').hide();
self.setVideoStatus(peerUUID, self.messages.pc_video_status_call_not_accepted, "failed");
self.doClose(peerUUID);
}
Expand All @@ -392,22 +392,22 @@

this.changeCallStatus(peerUUID, this.statuses.ACCEPTED);
if (!this.webrtc.currentPeerConnectionsMap[peerUUID]) {
$('#pc_connection_' + peerUUID + '_videoin').hide();
$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
this.setVideoStatus(peerUUID, this.messages.pc_video_status_answer_timeout, "failed");
return;
}
this.setVideoStatus(peerUUID, this.messages.pc_video_status_setup, "waiting");
$('#pc_connection_' + peerUUID + '_videoin').hide();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).hide();

var self = this;

this.webrtc.answerCall(peerUUID, function (peerUUID, localMediaStream) {

self.showMyVideo();
self.webrtc.attachMediaStream(document.getElementById("pc_chat_local_video"), localMediaStream);
self.webrtc.attachMediaStream(document.getElementById(portal.chat.domNames.pcChatVideoLocalVideo), localMediaStream);

$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID +' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
self.setVideoStatus(peerUUID, self.messages.pc_video_status_setup, "waiting");
}, function (peerUUID, localMediaStream) {

Expand All @@ -417,9 +417,9 @@
self.successCall(peerUUID, localMediaStream);
}, function () {

$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').hide();
self.setVideoStatus(peerUUID, self.messages.pc_video_status_call_failed, "failed");
self.closeVideoCall(peerUUID);
});
Expand All @@ -429,29 +429,29 @@

if (debug) console.debug('video.receiveVideoCall(' + peerUUID + ')');

$('#pc_connection_' + peerUUID + '_videoin').show();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).show();
};

portal.chat.video.ignoreVideoCall = function (peerUUID) {

if (debug) console.debug('video.ignoreVideoCall(' + peerUUID + ')');

this.changeCallStatus(peerUUID, this.statuses.CANCELLED);
$('#pc_connection_' + peerUUID + '_videoin').hide();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).hide();
this.setVideoStatus(peerUUID, this.messages.pc_video_status_you_ignored, "finished");
this.webrtc.signal(peerUUID, JSON.stringify({"bye": "ignore"}));
this.closeVideoCall(peerUUID);
$('#pc_connection_' + peerUUID+ '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
};

portal.chat.video.showVideoCall = function (peerUUID) {

if (debug) console.debug('video.showVideoCall(' + peerUUID + ')');

var chatDiv = $("#pc_chat_with_" + peerUUID);
$("#pc_chat_" + peerUUID + "_video_content").show();
var chatDiv = $(portal.chat.domSelectors.pcChatWithPre+ peerUUID);
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID).show();

if (!chatDiv.hasClass('pc_minimised')) {
if (!chatDiv.hasClass(portal.chat.domNames.pcMinimised)) {
chatDiv.css('height', '512px');
chatDiv.css('margin-top', '-212px');
} else {
Expand All @@ -461,10 +461,10 @@
chatDiv.addClass('video_active');
chatDiv.attr('data-height', '512');

$('#pc_connection_' + peerUUID + '_videochat_bar').show();
$('#pc_connection_' + peerUUID + '_videoin').hide();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').hide();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID).show();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').show();
};

portal.chat.video.closeVideoCall = function (peerUUID, ui) {
Expand All @@ -475,17 +475,17 @@
this.setVideoStatus(peerUUID, this.messages.pc_video_status_hangup, "finished");
}
this.doClose(peerUUID);
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').hide();
};

portal.chat.video.showMyVideo = function () {

if (debug) console.debug('video.showMyVideo');

$('#pc_chat_local_video_content').show();
$(portal.chat.domSelectors.pcChatLocalVideoContent).show();
if (!portal.chat.expanded) {
$('#pc_content').hide();
$(portal.chat.domSelectors.pcChatContent).hide();
portal.chat.toggleChat();
}
};
Expand All @@ -496,10 +496,10 @@

if ($('.video_active').length < 1) {
if (portal.chat.expanded) {
$('#pc_content').show();
$(portal.chat.domSelectors.pcChatContent).show();
portal.chat.toggleChat();
}
$('#pc_chat_local_video_content').hide();
$(portal.chat.domSelectors.pcChatLocalVideoContent).hide();
}
};

Expand All @@ -508,28 +508,28 @@
if (debug) console.debug('video.setVideoStatus(' + peerUUID + ', ' + text + ', ' + state + ')');

if (state != null) {
$("#pc_chat_" + peerUUID + "_video_content > .statusElement").hide();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > '+ portal.chat.domSelectors.pcChatVideoStatusElement).hide();

if (state === 'video') {
$("#pc_chat_" + peerUUID + "_video_content > .pc_chat_video_remote").fadeIn();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > ' +portal.chat.domSelectors.pcChatVideoRemote).fadeIn();
} else if (state === 'waiting') {
$("#pc_chat_"+ peerUUID + "_video_content > .bubblingG").show();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > '+ portal.chat.domSelectors.pcChatBubbling).show();
} else if (state === 'failed') {
$("#pc_chat_"+ peerUUID + "_video_content > .pc_chat_video_failed").show();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > ' + portal.chat.domSelectors.pcChatVideoFailed).show();
setTimeout('portal.chat.setupVideoChatBar("' + peerUUID + '",' + !this.hasRemoteVideoAgent(peerUUID) + ');', 5000);
} else if (state === 'finished') {
$("#pc_chat_" + peerUUID + "_video_content > .pc_chat_video_finished").show();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > ' + portal.chat.domSelectors.pcChatVideoFinished).show();
setTimeout('portal.chat.setupVideoChatBar("' + peerUUID + '",' + !this.hasRemoteVideoAgent(peerUUID) + ');', 5000);
}
}

$("#pc_chat_" + peerUUID + "_video_content > .pc_chat_video_statusbar > span").text(text);
$("#pc_chat_" + peerUUID + "_video_content > .pc_chat_video_statusbar").show();
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > ' + portal.chat.domSelectors.pcChatVideoStatusBar +' > span').text(text);
$(portal.chat.domSelectors.pcChatVideoContentPre + peerUUID +' > ' + portal.chat.domSelectors.pcChatVideoStatusBar).show();
};

$(document).ready(function () {

$('#pc_video_off_checkbox').click( function () {
$(portal.chat.domSelectors.pcVideoOffCheckOff).click( function () {

if ($(this).prop('checked')) {
portal.chat.setSetting('videoOff', true, /* localStorage */ true);
Expand Down
12 changes: 6 additions & 6 deletions portal/portal-charon/charon/src/webapp/scripts/webrtc-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
if (secs < 10) secs = '0' + secs;

var formattedDuration = hours + ":" + mins + ":" + secs;
$('#pc_connection_' + peerUUID + '_time').html(formattedDuration);
$(portal.chat.domSelectors.pcChatVideoTimePre + peerUUID).html(formattedDuration);
});
}, 1000);
}; // init
Expand Down Expand Up @@ -361,7 +361,7 @@
};

/**
* Use this helper function to hook the media stream to a especified element
* Use this helper function to hook the media stream to a specified element
*/
portal.chat.video.webrtc.attachMediaStream = function (element, stream) {

Expand Down Expand Up @@ -653,10 +653,10 @@

video.setVideoStatus(peerUUID, video.messages.pc_video_status_user_hung, "finished");
video.doClose(peerUUID);
$('#pc_connection_' + peerUUID + '_videochat_bar > .pc_connection_videochat_bar_left ').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_off').show();
$('#pc_connection_' + peerUUID + '_videochat_bar .video_on').hide();
$('#pc_connection_' + peerUUID + '_videoin').hide();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' > ' + portal.chat.domSelectors.pcChatVideoBarLeft).show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_off').show();
$(portal.chat.domSelectors.pcChatVideoVideoChatBarPre + peerUUID + ' .video_on').hide();
$(portal.chat.domSelectors.pcChatVideoVideoInPre + peerUUID).hide();
};

/**
Expand Down
Loading

0 comments on commit 3469596

Please sign in to comment.