Skip to content

bug fixing from 16122015 #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions js/modules/webrtc/qbWebRTCClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ WebRTCClient.prototype._onCallListener = function(userID, sessionID, extension)
this.signalingProvider.sendMessage(userID, extension, SignalingConstants.SignalingType.REJECT);
} else {
var session = this.sessions[sessionID];

if(!session){
session = this._createAndStoreSession(sessionID, extension.callerID, extension.opponentsIDs, extension.callType);

Expand All @@ -155,14 +156,18 @@ WebRTCClient.prototype._onAcceptListener = function(userID, sessionID, extension
var session = this.sessions[sessionID];

if(session){
var extensionClone = JSON.parse(JSON.stringify(extension));
this._cleanupExtension(extensionClone);
if(session.state === WebRTCSession.State.ACTIVE ) {
var extensionClone = JSON.parse(JSON.stringify(extension));
this._cleanupExtension(extensionClone);

if (typeof this.onAcceptCallListener === 'function'){
this.onAcceptCallListener(session, userID, extensionClone);
}
if (typeof this.onAcceptCallListener === 'function'){
this.onAcceptCallListener(session, userID, extensionClone);
}

session.processOnAccept(userID, extension);
session.processOnAccept(userID, extension);
} else {
Helpers.traceWarning("Ignore 'onAccept', the session( " + sessionID + " ) has invalid state.");
}
}else{
Helpers.traceError("Ignore 'onAccept', there is no information about session " + sessionID + " by some reason.");
}
Expand Down Expand Up @@ -212,7 +217,11 @@ WebRTCClient.prototype._onIceCandidatesListener = function(userID, sessionID, ex
var session = this.sessions[sessionID];

if(session){
session.processOnIceCandidates(userID, extension);
if(session.state === WebRTCSession.State.ACTIVE) {
session.processOnIceCandidates(userID, extension);
} else {
Helpers.traceWarning('Ignore \'OnIceCandidates\', the session ( ' + sessionID + ' ) has invalid state.');
}
}else{
Helpers.traceError("Ignore 'OnIceCandidates', there is no information about session " + sessionID + " by some reason.");
}
Expand Down
6 changes: 6 additions & 0 deletions js/modules/webrtc/qbWebRTCHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ WebRTCHelpers = {
}
},

traceWarning: function(text) {
if (config.debug) {
console.warn('[QBWebRTC]:', text);
}
},

traceError: function(text) {
if (config.debug) {
console.error('[QBWebRTC]:', text);
Expand Down
19 changes: 9 additions & 10 deletions js/modules/webrtc/qbWebRTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ WebRTCSession.prototype.connectionStateForUser = function(userID){

/**
* Detach media stream from audio/video element
* @param {string} The Id of an ellement to detach a stream
* @param {string} The Id of an element to detach a stream
*/
WebRTCSession.prototype.detachMediaStream = function(id){
var elem = document.getElementById(id);
Expand Down Expand Up @@ -444,17 +444,17 @@ WebRTCSession.filter = function(id, filters) {
//

WebRTCSession.prototype.processOnCall = function(callerID, extension) {
var self = this;
var self = this,
oppIDs = self._uniqueOpponentsIDs();

this._clearWaitingOfferOrAnswerTimer();
self._clearWaitingOfferOrAnswerTimer();

var oppIDs = this._uniqueOpponentsIDs();
oppIDs.forEach(function(opID, i, arr) {

var peerConnection = self.peerConnections[opID];
if(peerConnection){
oppIDs.forEach(function(opID, i, arr) {
var pConn = self.peerConnections[opID];

if(pConn){
if(opID == callerID){
peerConnection.updateRemoteSDP(extension.sdp);
pConn.updateRemoteSDP(extension.sdp);

// The group call logic starts here
if(callerID != self.initiatorID && self.state === WebRTCSession.State.ACTIVE){
Expand All @@ -479,7 +479,6 @@ WebRTCSession.prototype.processOnCall = function(callerID, extension) {
}
}
});

};

WebRTCSession.prototype.processOnAccept = function(userID, extension) {
Expand Down
21 changes: 15 additions & 6 deletions js/qbStrophe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ var Utils = require('./qbUtils');
function Connection() {
var protocol = config.chatProtocol.active === 1 ? config.chatProtocol.bosh : config.chatProtocol.websocket;
var conn = new Strophe.Connection(protocol);

if (config.chatProtocol.active === 1) {
conn.xmlInput = function(data) { if (data.childNodes[0]) {for (var i = 0, len = data.childNodes.length; i < len; i++) {
Utils.QBLog('[QBChat]', 'RECV:', data.childNodes[i]);
}} };
conn.xmlOutput = function(data) { if (data.childNodes[0]) {for (var i = 0, len = data.childNodes.length; i < len; i++) {
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
}} };
conn.xmlInput = function(data) {
if (data.childNodes[0]) {
for (var i = 0, len = data.childNodes.length; i < len; i++) {
Utils.QBLog('[QBChat]', 'RECV:', data.childNodes[i]);
}
}
};
conn.xmlOutput = function(data) {
if (data.childNodes[0]) {
for (var i = 0, len = data.childNodes.length; i < len; i++) {
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
}
}
};
} else {
conn.xmlInput = function(data) {
Utils.QBLog('[QBChat]', 'RECV:', data);
Expand Down
16 changes: 8 additions & 8 deletions quickblox.min.js

Large diffs are not rendered by default.

73 changes: 59 additions & 14 deletions samples/webrtc/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
ui.createUsers(QBUsers, ui.$usersList);
ui.$usersTitle.text(MESSAGES.title_login);

if(!params.withoutUpdMsg) {
ui.updateMsg({msg: 'login'});
if(!params.withoutUpdMsg || params.msg) {
ui.updateMsg({msg: params.msg});
}
}

Expand All @@ -142,15 +142,15 @@
*/
ui.setPositionFooter();

initializeUI();
initializeUI({withoutUpdMsg: false, msg: 'login'});

QB.init(QBApp.appId, QBApp.authKey, QBApp.authSecret, CONFIG);

/**
* EVENTS
*/
/** Choose caller */
$(document).on('click', '.j-user', function() {
/** Choose caller or callees */
$(document).on('click', '.j-user', function(e) {
var $el = $(this),
usersWithoutCaller = [],
user = {},
Expand Down Expand Up @@ -184,9 +184,6 @@
if(err !== null) {
app.caller = {};

ui.updateMsg( {msg: 'connect_error'} );

initializeUI({withoutUpdMsg: true});
ui.setPositionFooter();
ui.togglePreloadMain('hide');
} else {
Expand Down Expand Up @@ -247,8 +244,9 @@
app.currentSession = QB.webrtc.createNewSession(Object.keys(app.callees), QB.webrtc.CallType.VIDEO);

app.currentSession.getUserMedia(mediaParams, function(err, stream) {
if (err) {
if (err || !stream.getAudioTracks().length || !stream.getVideoTracks().length) {
ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}});
app.currentSession.stop({});
} else {
app.currentSession.call({}, function(error) {
if(error) {
Expand Down Expand Up @@ -333,6 +331,7 @@
});

ui.$callees.append(videoElems);
ui.setPositionFooter();
ui.updateMsg( {msg: 'during_call', obj: {name: app.caller.full_name}} );

app.currentSession.accept({});
Expand Down Expand Up @@ -375,7 +374,7 @@
classesName = [],
activeClass = [];

if( app.currentSession.peerConnections[userID].stream ) {
if( app.currentSession.peerConnections[userID].stream && !_.isEmpty( $that.attr('src')) ) {
if( $that.hasClass('active') ) {
$that.removeClass('active');

Expand Down Expand Up @@ -436,8 +435,7 @@
*/
QB.chat.onDisconnectedListener = function() {
console.log('onDisconnectedListener.');

var initUIParams = authorizationing ? {withoutUpdMsg: true} : {};
var initUIParams = authorizationing ? {withoutUpdMsg: false, msg: 'no_internet'} : {withoutUpdMsg: false, msg: 'login'};

app.caller = {};
app.callees = [];
Expand All @@ -452,7 +450,6 @@
$('.j-callee').remove();

ui.setPositionFooter();

authorizationing = false;
};

Expand All @@ -465,7 +462,9 @@

ui.showCallBtn();

ui.updateMsg({msg: 'call_stop', obj: {name: app.caller.full_name}});
if(session.opponentsIDs.length > 1) {
ui.updateMsg({msg: 'call_stop', obj: {name: app.caller.full_name}});
}

/** delete blob from myself video */
document.getElementById('localVideo').src = '';
Expand All @@ -487,6 +486,20 @@
console.log('Session: ' + session);
console.groupEnd();

var userInfo = _.findWhere(QBUsers, {id: +userId});

/** It's for p2p call */
if(session.opponentsIDs.length === 1) {
ui.updateMsg({
msg: 'p2p_call_stop',
obj: {
name: userInfo.full_name,
reason: 'not answered'
}
});
}

/** It's for groups call */
$('.j-callee_status_' + userId).text('No Answer');
};

Expand Down Expand Up @@ -553,6 +566,20 @@
console.log('Extension: ' + JSON.stringify(extension));
console.groupEnd();

var userInfo = _.findWhere(QBUsers, {id: userId});

/** It's for p2p call */
if(session.opponentsIDs.length === 1) {
ui.updateMsg({
msg: 'p2p_call_stop',
obj: {
name: userInfo.full_name,
reason: 'rejected the call'
}
});
}

/** It's for groups call */
$('.j-callee_status_' + userId).text('Rejected');
};

Expand All @@ -563,6 +590,20 @@
console.log('Extension: ' + JSON.stringify(extension));
console.groupEnd();

var userInfo = _.findWhere(QBUsers, {id: userId});

/** It's for p2p call */
if(session.opponentsIDs.length === 1) {
ui.updateMsg({
msg: 'p2p_call_stop',
obj: {
name: userInfo.full_name,
reason: 'hung up the call'
}
});
}

/** It's for groups call */
$('.j-callee_status_' + userId).text('Hung Up');
};

Expand Down Expand Up @@ -624,6 +665,10 @@

if(app.mainVideo === userID) {
$('#remote_video_' + userID).removeClass('active');

ui.changeFilter('#main_video', 'no');
app.currentSession.detachMediaStream('main_video');
app.mainVideo = 0;
}

if( !_.isEmpty(app.currentSession) ) {
Expand Down
6 changes: 6 additions & 0 deletions samples/webrtc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ <h4>Call from <strong class="j-ic_initiator"></strong></h4>
<button class='fw-link j-logout'>Logout</button>
</script>

<script type="text/template" id="p2p_call_stop">
<%=name%> has <%=reason%>. Call is stopped.&emsp;
Login&nbsp;in&nbsp;as&nbsp;<%=name%>
<button class='fw-link j-logout'>Logout</button>
</script>

<!-- SCRIPT -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
Expand Down
15 changes: 13 additions & 2 deletions samples/webrtc/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ body {

.fw-video {
display: block;
width: 100%;
min-height: 100px;
width: 135px;
height: 100px;
max-height: 100px;

background: #bfbfbf;
}
.fw-video-wait {
min-width: 32px;
background: #bfbfbf url('images/loader3.gif') no-repeat center;
}
.fw-video.main_video_vid {
width: 100%;
height: auto;
max-height: none;
}

.fw-inner {
width: 90%;
Expand Down Expand Up @@ -479,6 +485,7 @@ body {
}

.callees__callee_video {
margin: 0 auto;
border: 4px solid transparent;

transition: border-color .3s ease;
Expand All @@ -500,6 +507,10 @@ body {
z-index: 9;
}

.callees__callee_name {
text-align: center;
}

@media all and (min-width: 780px) {
.callees__callee {
width: 20%;
Expand Down