Uses new peer connection statuses to check and show different user msgs. (#1441)

* Uses new peer connection statuses to check and show different user msgs.

Checks for interrupted state of peer connection and shows appropriate messages. In case of inactive or restoring state a message is show to user that video was stopped on purpose. Removes some unused parameters from the event handlers about peer connection status change.

* Removes isParticipantConnectionActive.
This commit is contained in:
Дамян Минков 2017-04-03 11:53:04 -05:00 committed by Paweł Domas
parent 3daae94bca
commit 2248560699
5 changed files with 57 additions and 26 deletions

View File

@ -790,16 +790,17 @@ export default {
return room ? room.getParticipantById(id) : null; return room ? room.getParticipantById(id) : null;
}, },
/** /**
* Checks whether the user identified by given id is currently connected. * Get participant connection status for the participant.
* *
* @param {string} id participant's identifier(MUC nickname) * @param {string} id participant's identifier(MUC nickname)
* *
* @returns {boolean|null} true if participant's connection is ok or false * @returns {ParticipantConnectionStatus|null} the status of the participant
* if the user is having connectivity issues. * or null if no such participant is found or participant is the local user.
*/ */
isParticipantConnectionActive (id) { getParticipantConnectionStatus (id) {
let participant = this.getParticipantById(id); let participant = this.getParticipantById(id);
return participant ? participant.isConnectionActive() : null; return participant
? participant.getConnectionStatus() : null;
}, },
/** /**
* Gets the display name foe the <tt>JitsiParticipant</tt> identified by * Gets the display name foe the <tt>JitsiParticipant</tt> identified by
@ -1306,8 +1307,8 @@ export default {
room.on( room.on(
ConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED, ConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
(id, isActive) => { id => {
APP.UI.participantConnectionStatusChanged(id, isActive); APP.UI.participantConnectionStatusChanged(id);
}); });
room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => { room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
if (this.isLocalId(id)) { if (this.isLocalId(id)) {

View File

@ -849,11 +849,9 @@ UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
* Will handle notification about participant's connectivity status change. * Will handle notification about participant's connectivity status change.
* *
* @param {string} id the id of remote participant(MUC jid) * @param {string} id the id of remote participant(MUC jid)
* @param {boolean} isActive true if the connection is ok or false if the user
* is having connectivity issues.
*/ */
UI.participantConnectionStatusChanged = function (id, isActive) { UI.participantConnectionStatusChanged = function (id) {
VideoLayout.onParticipantConnectionStatusChanged(id, isActive); VideoLayout.onParticipantConnectionStatusChanged(id);
}; };
/** /**

View File

@ -1,4 +1,4 @@
/* global $, APP */ /* global $, APP, JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename); const logger = require("jitsi-meet-logger").getLogger(__filename);
import Avatar from "../avatar/Avatar"; import Avatar from "../avatar/Avatar";
@ -9,6 +9,9 @@ import {VideoContainer, VIDEO_CONTAINER_TYPE} from "./VideoContainer";
import AudioLevels from "../audio_levels/AudioLevels"; import AudioLevels from "../audio_levels/AudioLevels";
const ParticipantConnectionStatus
= JitsiMeetJS.constants.participantConnectionStatus;
/** /**
* Manager for all Large containers. * Manager for all Large containers.
*/ */
@ -114,7 +117,7 @@ export default class LargeVideoManager {
// (camera or desktop) is a completely different thing than // (camera or desktop) is a completely different thing than
// the video container type (Etherpad, SharedVideo, VideoContainer). // the video container type (Etherpad, SharedVideo, VideoContainer).
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// If we the continer is VIDEO_CONTAINER_TYPE, we need to check // If the container is VIDEO_CONTAINER_TYPE, we need to check
// its stream whether exist and is muted to set isVideoMuted // its stream whether exist and is muted to set isVideoMuted
// in rest of the cases it is false // in rest of the cases it is false
let showAvatar let showAvatar
@ -125,11 +128,10 @@ export default class LargeVideoManager {
// displayed in case we have no video image cached. That is if // displayed in case we have no video image cached. That is if
// there was a user switch(image is lost on stream detach) or if // there was a user switch(image is lost on stream detach) or if
// the video was not rendered, before the connection has failed. // the video was not rendered, before the connection has failed.
const isHavingConnectivityIssues const isConnectionActive = this._isConnectionActive(id);
= APP.conference.isParticipantConnectionActive(id) === false;
if (videoType === VIDEO_CONTAINER_TYPE if (videoType === VIDEO_CONTAINER_TYPE
&& isHavingConnectivityIssues && !isConnectionActive
&& (isUserSwitch || !container.wasVideoRendered)) { && (isUserSwitch || !container.wasVideoRendered)) {
showAvatar = true; showAvatar = true;
} }
@ -158,12 +160,19 @@ export default class LargeVideoManager {
// Make sure no notification about remote failure is shown as // Make sure no notification about remote failure is shown as
// its UI conflicts with the one for local connection interrupted. // its UI conflicts with the one for local connection interrupted.
const isConnected = APP.conference.isConnectionInterrupted() const isConnected = APP.conference.isConnectionInterrupted()
|| !isHavingConnectivityIssues; || isConnectionActive;
// when isHavingConnectivityIssues, state can be inactive,
// interrupted or restoring. We show different message for
// interrupted and the rest.
const isConnectionInterrupted =
APP.conference.getParticipantConnectionStatus(id)
=== ParticipantConnectionStatus.INTERRUPTED;
this.updateParticipantConnStatusIndication( this.updateParticipantConnStatusIndication(
id, id,
isConnected, isConnected,
(isHavingConnectivityIssues) (isConnectionInterrupted)
? "connection.USER_CONNECTION_INTERRUPTED" ? "connection.USER_CONNECTION_INTERRUPTED"
: "connection.LOW_BANDWIDTH"); : "connection.LOW_BANDWIDTH");
@ -180,6 +189,22 @@ export default class LargeVideoManager {
}); });
} }
/**
* Checks whether a participant's peer connection status is active.
* There is no JitsiParticipant for local id we skip checking local
* participant and report it as having no connectivity issues.
*
* @param {string} id the id of participant(MUC nickname)
* @returns {boolean} <tt>true</tt> when participant connection status is
* {@link ParticipantConnectionStatus.ACTIVE} and <tt>false</tt> otherwise.
* @private
*/
_isConnectionActive(id) {
return APP.conference.isLocalId(id)
|| APP.conference.getParticipantConnectionStatus(this.id)
=== ParticipantConnectionStatus.ACTIVE;
}
/** /**
* Shows/hides notification about participant's connectivity issues to be * Shows/hides notification about participant's connectivity issues to be
* shown on the large video area. * shown on the large video area.
@ -340,7 +365,7 @@ export default class LargeVideoManager {
*/ */
showRemoteConnectionMessage (show) { showRemoteConnectionMessage (show) {
if (typeof show !== 'boolean') { if (typeof show !== 'boolean') {
show = !APP.conference.isParticipantConnectionActive(this.id); show = !this._isConnectionActive(this.id);
} }
if (show) { if (show) {

View File

@ -1,4 +1,4 @@
/* global $, APP, interfaceConfig */ /* global $, APP, interfaceConfig, JitsiMeetJS */
const logger = require("jitsi-meet-logger").getLogger(__filename); const logger = require("jitsi-meet-logger").getLogger(__filename);
import ConnectionIndicator from './ConnectionIndicator'; import ConnectionIndicator from './ConnectionIndicator';
@ -12,6 +12,8 @@ const MUTED_DIALOG_BUTTON_VALUES = {
cancel: 0, cancel: 0,
muted: 1 muted: 1
}; };
const ParticipantConnectionStatus
= JitsiMeetJS.constants.participantConnectionStatus;
/** /**
* Creates new instance of the <tt>RemoteVideo</tt>. * Creates new instance of the <tt>RemoteVideo</tt>.
@ -447,7 +449,7 @@ RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted, force) {
RemoteVideo.prototype.setMutedView = function(isMuted) { RemoteVideo.prototype.setMutedView = function(isMuted) {
SmallVideo.prototype.setMutedView.call(this, isMuted); SmallVideo.prototype.setMutedView.call(this, isMuted);
// Update 'mutedWhileDisconnected' flag // Update 'mutedWhileDisconnected' flag
this._figureOutMutedWhileDisconnected(this.isConnectionActive() === false); this._figureOutMutedWhileDisconnected(this.isConnectionInterrupted());
}; };
/** /**
@ -534,7 +536,8 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
* <tt>false</tt> otherwise. * <tt>false</tt> otherwise.
*/ */
RemoteVideo.prototype.isConnectionActive = function() { RemoteVideo.prototype.isConnectionActive = function() {
return this.user.isConnectionActive(); return this.user.getConnectionStatus()
=== ParticipantConnectionStatus.ACTIVE;
}; };
/** /**

View File

@ -658,14 +658,18 @@ var VideoLayout = {
* Shows/hides warning about remote user's connectivity issues. * Shows/hides warning about remote user's connectivity issues.
* *
* @param {string} id the ID of the remote participant(MUC nickname) * @param {string} id the ID of the remote participant(MUC nickname)
* @param {boolean} isActive true if the connection is ok or false when
* the user is having connectivity issues.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
onParticipantConnectionStatusChanged (id, isActive) { onParticipantConnectionStatusChanged (id) {
// Show/hide warning on the large video // Show/hide warning on the large video
if (this.isCurrentlyOnLarge(id)) { if (this.isCurrentlyOnLarge(id)) {
if (largeVideo) { // when pinning and we have lastN enabled, we have rapid connection
// status changed between inactive, restoring and active and
// if there was a large video update scheduled already it will
// reflect the current status and no need to schedule new one
// otherwise we end up scheduling updates for endpoints which are
// were on large while checking, but a change was already scheduled
if (largeVideo && !largeVideo.updateInProcess) {
// We have to trigger full large video update to transition from // We have to trigger full large video update to transition from
// avatar to video on connectivity restored. // avatar to video on connectivity restored.
this.updateLargeVideo(id, true /* force update */); this.updateLargeVideo(id, true /* force update */);