[RN] Use participant connection status events instead of last N

They better represent if a participant has video available or not. There are
cases when even a participant in the last N set would not have video because it
disconnected momentarily, for example.
This commit is contained in:
Saúl Ibarra Corretgé 2017-04-03 17:06:39 +02:00 committed by Lyubo Marinov
parent 623b7a8d6f
commit 618dedc58e
5 changed files with 25 additions and 43 deletions

View File

@ -1,6 +1,6 @@
import { JitsiConferenceEvents } from '../lib-jitsi-meet'; import { JitsiConferenceEvents } from '../lib-jitsi-meet';
import { import {
changeParticipantLastNStatus, changeParticipantConnectionStatus,
dominantSpeakerChanged, dominantSpeakerChanged,
getLocalParticipant, getLocalParticipant,
participantJoined, participantJoined,
@ -54,8 +54,8 @@ function _addConferenceListeners(conference, dispatch) {
(...args) => dispatch(dominantSpeakerChanged(...args))); (...args) => dispatch(dominantSpeakerChanged(...args)));
conference.on( conference.on(
JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED, JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
(...args) => _lastNEndpointsChanged(dispatch, ...args)); (...args) => dispatch(changeParticipantConnectionStatus(...args)));
conference.on( conference.on(
JitsiConferenceEvents.LOCK_STATE_CHANGED, JitsiConferenceEvents.LOCK_STATE_CHANGED,
@ -268,30 +268,6 @@ export function createConference() {
}; };
} }
/**
* Handles the lastN status changes for participants in the current conference.
* Signals that a participant's lastN status has changed, for each participant
* who entered or left the last N set.
*
* @param {Dispatch} dispatch - Redux dispatch function.
* @param {Array} leavingIds - Ids of participants who are leaving the last N
* set.
* @param {Array} enteringIds - Ids of participants who are entering the last N
* set.
* @returns {void}
*
* @private
*/
function _lastNEndpointsChanged(dispatch, leavingIds = [], enteringIds = []) {
for (const id of leavingIds) {
dispatch(changeParticipantLastNStatus(id, false));
}
for (const id of enteringIds) {
dispatch(changeParticipantLastNStatus(id, true));
}
}
/** /**
* Signals that the lock state of a specific JitsiConference changed. * Signals that the lock state of a specific JitsiConference changed.
* *

View File

@ -10,6 +10,8 @@ export const JitsiConferenceErrors = JitsiMeetJS.errors.conference;
export const JitsiConferenceEvents = JitsiMeetJS.events.conference; export const JitsiConferenceEvents = JitsiMeetJS.events.conference;
export const JitsiConnectionErrors = JitsiMeetJS.errors.connection; export const JitsiConnectionErrors = JitsiMeetJS.errors.connection;
export const JitsiConnectionEvents = JitsiMeetJS.events.connection; export const JitsiConnectionEvents = JitsiMeetJS.events.connection;
export const JitsiParticipantConnectionStatus
= JitsiMeetJS.constants.participantConnectionStatus;
export const JitsiTrackErrors = JitsiMeetJS.errors.track; export const JitsiTrackErrors = JitsiMeetJS.errors.track;
export const JitsiTrackEvents = JitsiMeetJS.events.track; export const JitsiTrackEvents = JitsiMeetJS.events.track;

View File

@ -9,25 +9,25 @@ import {
import { getLocalParticipant } from './functions'; import { getLocalParticipant } from './functions';
/** /**
* Action to update a participant's lastN status. * Action to update a participant's connection status.
* *
* @param {string} id - Participant's ID. * @param {string} id - Participant's ID.
* @param {boolean} isInLastN - True if the participant is in the lastN * @param {string} connectionStatus - The new connection status for the
* endpoints set, false otherwise. * participant.
* @returns {{ * @returns {{
* type: PARTICIPANT_UPDATED, * type: PARTICIPANT_UPDATED,
* participant: { * participant: {
* id: string, * id: string,
* isInLastN: boolean * connectionStatus: string
* } * }
* }} * }}
*/ */
export function changeParticipantLastNStatus(id, isInLastN) { export function changeParticipantConnectionStatus(id, connectionStatus) {
return { return {
type: PARTICIPANT_UPDATED, type: PARTICIPANT_UPDATED,
participant: { participant: {
id, id,
isInLastN connectionStatus
} }
}; };
} }

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { JitsiParticipantConnectionStatus } from '../../lib-jitsi-meet';
import { import {
MEDIA_TYPE, MEDIA_TYPE,
shouldRenderVideoTrack, shouldRenderVideoTrack,
@ -35,11 +36,12 @@ class ParticipantView extends Component {
_avatar: React.PropTypes.string, _avatar: React.PropTypes.string,
/** /**
* True if the participant is in the last N endpoints set, false if he * The connection status for the participant. Its video will only be
* isn't. If undefined, we have no indication, so the same course of * rendered if the connection status is 'active', otherwise the avatar
* action as true is taken. * will be rendered. If undefined, we have no indication, so the same
* course of action as 'active' is taken.
*/ */
_isInLastN: React.PropTypes.bool, _connectionStatus: React.PropTypes.string,
/** /**
* The video Track of the participant with {@link #participantId}. * The video Track of the participant with {@link #participantId}.
@ -94,7 +96,7 @@ class ParticipantView extends Component {
render() { render() {
const { const {
_avatar: avatar, _avatar: avatar,
_isInLastN: isInLastN, _connectionStatus: connectionStatus,
_videoTrack: videoTrack _videoTrack: videoTrack
} = this.props; } = this.props;
@ -105,7 +107,9 @@ class ParticipantView extends Component {
const waitForVideoStarted = false; const waitForVideoStarted = false;
const renderVideo const renderVideo
= shouldRenderVideoTrack(videoTrack, waitForVideoStarted) = shouldRenderVideoTrack(videoTrack, waitForVideoStarted)
&& (typeof isInLastN === 'undefined' || isInLastN); && (typeof connectionStatus === 'undefined'
|| connectionStatus
=== JitsiParticipantConnectionStatus.ACTIVE);
// Is the avatar to be rendered? // Is the avatar to be rendered?
const renderAvatar = Boolean(!renderVideo && avatar); const renderAvatar = Boolean(!renderVideo && avatar);
@ -168,7 +172,7 @@ function _toBoolean(value, undefinedValue) {
* @private * @private
* @returns {{ * @returns {{
* _avatar: string, * _avatar: string,
* _isInLastN: boolean, * _connectionStatus: string,
* _videoTrack: Track * _videoTrack: Track
* }} * }}
*/ */
@ -181,7 +185,7 @@ function _mapStateToProps(state, ownProps) {
return { return {
_avatar: participant && getAvatarURL(participant), _avatar: participant && getAvatarURL(participant),
_isInLastN: participant && participant.isInLastN, _connectionStatus: participant && participant.connectionStatus,
_videoTrack: _videoTrack:
getTrackByMediaTypeAndParticipant( getTrackByMediaTypeAndParticipant(
state['features/base/tracks'], state['features/base/tracks'],

View File

@ -75,7 +75,7 @@ function _participant(state, action) {
avatarURL, avatarURL,
dominantSpeaker, dominantSpeaker,
email, email,
isInLastN, connectionStatus,
local, local,
pinned, pinned,
role role
@ -110,7 +110,7 @@ function _participant(state, action) {
dominantSpeaker: dominantSpeaker || false, dominantSpeaker: dominantSpeaker || false,
email, email,
id, id,
isInLastN, connectionStatus,
local: local || false, local: local || false,
name, name,
pinned: pinned || false, pinned: pinned || false,