2017-10-03 19:24:00 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-10-16 19:58:38 +00:00
|
|
|
import { sendAnalyticsEvent } from '../../analytics';
|
2017-10-13 20:34:27 +00:00
|
|
|
import { getName } from '../../app';
|
2017-02-28 03:21:50 +00:00
|
|
|
import { JitsiConferenceEvents } from '../lib-jitsi-meet';
|
2017-08-02 15:00:51 +00:00
|
|
|
import { setAudioMuted, setVideoMuted } from '../media';
|
2016-10-05 14:36:59 +00:00
|
|
|
import {
|
|
|
|
dominantSpeakerChanged,
|
2017-04-05 09:01:57 +00:00
|
|
|
participantConnectionStatusChanged,
|
2016-10-05 14:36:59 +00:00
|
|
|
participantJoined,
|
|
|
|
participantLeft,
|
2017-03-23 18:01:33 +00:00
|
|
|
participantRoleChanged,
|
|
|
|
participantUpdated
|
2016-10-05 14:36:59 +00:00
|
|
|
} from '../participants';
|
2016-12-05 15:14:50 +00:00
|
|
|
import { trackAdded, trackRemoved } from '../tracks';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
import {
|
2016-12-12 01:02:50 +00:00
|
|
|
CONFERENCE_FAILED,
|
2016-10-05 14:36:59 +00:00
|
|
|
CONFERENCE_JOINED,
|
|
|
|
CONFERENCE_LEFT,
|
2017-01-18 19:28:52 +00:00
|
|
|
CONFERENCE_WILL_JOIN,
|
2016-10-05 14:36:59 +00:00
|
|
|
CONFERENCE_WILL_LEAVE,
|
2017-08-09 19:40:03 +00:00
|
|
|
DATA_CHANNEL_OPENED,
|
2016-12-12 19:49:23 +00:00
|
|
|
LOCK_STATE_CHANGED,
|
2017-08-09 19:40:03 +00:00
|
|
|
P2P_STATUS_CHANGED,
|
2017-03-29 12:07:05 +00:00
|
|
|
SET_AUDIO_ONLY,
|
2017-03-29 10:24:18 +00:00
|
|
|
SET_LASTN,
|
2016-12-12 01:02:50 +00:00
|
|
|
SET_PASSWORD,
|
2017-04-13 00:23:43 +00:00
|
|
|
SET_PASSWORD_FAILED,
|
2017-08-09 19:40:03 +00:00
|
|
|
SET_RECEIVE_VIDEO_QUALITY,
|
2017-05-09 05:15:43 +00:00
|
|
|
SET_ROOM
|
2016-10-05 14:36:59 +00:00
|
|
|
} from './actionTypes';
|
2017-02-28 23:12:02 +00:00
|
|
|
import {
|
|
|
|
AVATAR_ID_COMMAND,
|
|
|
|
AVATAR_URL_COMMAND,
|
2017-08-01 00:40:55 +00:00
|
|
|
EMAIL_COMMAND,
|
|
|
|
JITSI_CONFERENCE_URL_KEY
|
2017-02-28 23:12:02 +00:00
|
|
|
} from './constants';
|
2017-10-06 17:52:23 +00:00
|
|
|
import {
|
|
|
|
_addLocalTracksToConference,
|
2017-10-13 19:31:05 +00:00
|
|
|
sendLocalParticipant
|
2017-10-06 17:52:23 +00:00
|
|
|
} from './functions';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-03-29 10:24:18 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2017-10-09 21:40:38 +00:00
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2016-12-12 00:29:13 +00:00
|
|
|
* Adds conference (event) listeners.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2016-12-12 00:29:13 +00:00
|
|
|
* @param {JitsiConference} conference - The JitsiConference instance.
|
|
|
|
* @param {Dispatch} dispatch - The Redux dispatch function.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2016-12-12 00:29:13 +00:00
|
|
|
function _addConferenceListeners(conference, dispatch) {
|
2017-04-05 09:01:57 +00:00
|
|
|
// Dispatches into features/base/conference follow:
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
|
|
|
(...args) => dispatch(conferenceFailed(conference, ...args)));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.CONFERENCE_JOINED,
|
|
|
|
(...args) => dispatch(conferenceJoined(conference, ...args)));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.CONFERENCE_LEFT,
|
|
|
|
(...args) => dispatch(conferenceLeft(conference, ...args)));
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2016-12-12 19:49:23 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.LOCK_STATE_CHANGED,
|
|
|
|
(...args) => dispatch(lockStateChanged(conference, ...args)));
|
2016-12-12 19:49:23 +00:00
|
|
|
|
2017-08-02 15:00:51 +00:00
|
|
|
// Dispatches into features/base/media follow:
|
|
|
|
|
|
|
|
conference.on(
|
|
|
|
JitsiConferenceEvents.STARTED_MUTED,
|
|
|
|
() => {
|
2017-10-09 21:40:38 +00:00
|
|
|
const audioMuted = Boolean(conference.startAudioMuted);
|
|
|
|
const videoMuted = Boolean(conference.startVideoMuted);
|
|
|
|
|
2017-10-16 19:58:38 +00:00
|
|
|
sendAnalyticsEvent(
|
2017-10-09 21:40:38 +00:00
|
|
|
`startmuted.server.audio.${audioMuted ? 'muted' : 'unmuted'}`);
|
2017-10-16 19:58:38 +00:00
|
|
|
sendAnalyticsEvent(
|
2017-10-09 21:40:38 +00:00
|
|
|
`startmuted.server.video.${videoMuted ? 'muted' : 'unmuted'}`);
|
|
|
|
logger.log(`Start muted: ${audioMuted ? 'audio, ' : ''}${
|
|
|
|
videoMuted ? 'video' : ''}`);
|
|
|
|
|
2017-08-04 21:06:42 +00:00
|
|
|
// XXX Jicofo tells lib-jitsi-meet to start with audio and/or video
|
|
|
|
// muted i.e. Jicofo expresses an intent. Lib-jitsi-meet has turned
|
|
|
|
// Jicofo's intent into reality by actually muting the respective
|
|
|
|
// tracks. The reality is expressed in base/tracks already so what
|
|
|
|
// is left is to express Jicofo's intent in base/media.
|
|
|
|
// TODO Maybe the app needs to learn about Jicofo's intent and
|
|
|
|
// transfer that intent to lib-jitsi-meet instead of lib-jitsi-meet
|
|
|
|
// acting on Jicofo's intent without the app's knowledge.
|
2017-10-09 21:40:38 +00:00
|
|
|
dispatch(setAudioMuted(audioMuted));
|
|
|
|
dispatch(setVideoMuted(videoMuted));
|
2017-08-02 15:00:51 +00:00
|
|
|
});
|
|
|
|
|
2017-04-05 09:01:57 +00:00
|
|
|
// Dispatches into features/base/tracks follow:
|
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.TRACK_ADDED,
|
|
|
|
t => t && !t.isLocal() && dispatch(trackAdded(t)));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.TRACK_REMOVED,
|
|
|
|
t => t && !t.isLocal() && dispatch(trackRemoved(t)));
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-04-05 09:01:57 +00:00
|
|
|
// Dispatches into features/base/participants follow:
|
|
|
|
|
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
|
|
|
|
(...args) => dispatch(dominantSpeakerChanged(...args)));
|
2017-04-05 09:01:57 +00:00
|
|
|
|
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
|
|
|
|
(...args) => dispatch(participantConnectionStatusChanged(...args)));
|
2017-04-05 09:01:57 +00:00
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.USER_JOINED,
|
|
|
|
(id, user) => dispatch(participantJoined({
|
|
|
|
id,
|
|
|
|
name: user.getDisplayName(),
|
|
|
|
role: user.getRole()
|
|
|
|
})));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.USER_LEFT,
|
|
|
|
(...args) => dispatch(participantLeft(...args)));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.on(
|
2017-06-15 00:40:51 +00:00
|
|
|
JitsiConferenceEvents.USER_ROLE_CHANGED,
|
|
|
|
(...args) => dispatch(participantRoleChanged(...args)));
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-02-28 23:12:02 +00:00
|
|
|
conference.addCommandListener(
|
2017-06-15 00:40:51 +00:00
|
|
|
AVATAR_ID_COMMAND,
|
|
|
|
(data, id) => dispatch(participantUpdated({
|
|
|
|
id,
|
|
|
|
avatarID: data.value
|
|
|
|
})));
|
2017-02-28 23:12:02 +00:00
|
|
|
conference.addCommandListener(
|
2017-06-15 00:40:51 +00:00
|
|
|
AVATAR_URL_COMMAND,
|
|
|
|
(data, id) => dispatch(participantUpdated({
|
|
|
|
id,
|
|
|
|
avatarURL: data.value
|
|
|
|
})));
|
2016-12-12 00:29:13 +00:00
|
|
|
conference.addCommandListener(
|
2017-06-15 00:40:51 +00:00
|
|
|
EMAIL_COMMAND,
|
|
|
|
(data, id) => dispatch(participantUpdated({
|
|
|
|
id,
|
|
|
|
email: data.value
|
|
|
|
})));
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* Signals that a specific conference has failed.
|
|
|
|
*
|
|
|
|
* @param {JitsiConference} conference - The JitsiConference that has failed.
|
|
|
|
* @param {string} error - The error describing/detailing the cause of the
|
|
|
|
* failure.
|
|
|
|
* @returns {{
|
|
|
|
* type: CONFERENCE_FAILED,
|
|
|
|
* conference: JitsiConference,
|
2017-10-05 12:41:35 +00:00
|
|
|
* error: Error
|
2016-12-12 01:02:50 +00:00
|
|
|
* }}
|
2017-01-31 20:58:48 +00:00
|
|
|
* @public
|
2016-12-12 01:02:50 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function conferenceFailed(conference: Object, error: string) {
|
2016-12-12 01:02:50 +00:00
|
|
|
return {
|
|
|
|
type: CONFERENCE_FAILED,
|
|
|
|
conference,
|
2017-10-05 12:41:35 +00:00
|
|
|
|
|
|
|
// Make the error resemble an Error instance (to the extent that
|
|
|
|
// jitsi-meet needs it).
|
|
|
|
error: {
|
|
|
|
name: error
|
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2017-08-08 14:27:44 +00:00
|
|
|
* Signals that a specific conference has been joined.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @param {JitsiConference} conference - The JitsiConference instance which was
|
|
|
|
* joined by the local participant.
|
2017-08-08 14:27:44 +00:00
|
|
|
* @returns {{
|
|
|
|
* type: CONFERENCE_JOINED,
|
|
|
|
* conference: JitsiConference
|
|
|
|
* }}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function conferenceJoined(conference: Object) {
|
2017-08-08 14:27:44 +00:00
|
|
|
return {
|
|
|
|
type: CONFERENCE_JOINED,
|
|
|
|
conference
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-18 19:28:52 +00:00
|
|
|
/**
|
2017-01-20 18:11:11 +00:00
|
|
|
* Signals that a specific conference has been left.
|
2017-01-18 19:28:52 +00:00
|
|
|
*
|
2017-01-20 18:11:11 +00:00
|
|
|
* @param {JitsiConference} conference - The JitsiConference instance which was
|
|
|
|
* left by the local participant.
|
2017-01-18 19:28:52 +00:00
|
|
|
* @returns {{
|
2017-04-19 14:52:27 +00:00
|
|
|
* type: CONFERENCE_LEFT,
|
|
|
|
* conference: JitsiConference
|
|
|
|
* }}
|
2017-01-18 19:28:52 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function conferenceLeft(conference: Object) {
|
2017-01-18 19:28:52 +00:00
|
|
|
return {
|
2017-01-20 18:11:11 +00:00
|
|
|
type: CONFERENCE_LEFT,
|
|
|
|
conference
|
2017-01-18 19:28:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2017-08-08 14:27:44 +00:00
|
|
|
* Attaches any pre-existing local media to the conference, before
|
|
|
|
* the conference will be joined. Then signals the intention of the application
|
|
|
|
* to have the local participant join a specific conference.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-07-06 11:51:35 +00:00
|
|
|
* @param {JitsiConference} conference - The JitsiConference instance the
|
|
|
|
* local participant will (try to) join.
|
2017-08-08 14:27:44 +00:00
|
|
|
* @returns {Function}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
function _conferenceWillJoin(conference: Object) {
|
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
2017-08-08 14:27:44 +00:00
|
|
|
const localTracks
|
|
|
|
= getState()['features/base/tracks']
|
|
|
|
.filter(t => t.local)
|
|
|
|
.map(t => t.jitsiTrack);
|
|
|
|
|
|
|
|
if (localTracks.length) {
|
|
|
|
_addLocalTracksToConference(conference, localTracks);
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: CONFERENCE_WILL_JOIN,
|
|
|
|
conference
|
|
|
|
});
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-12-12 00:29:13 +00:00
|
|
|
* Signals the intention of the application to have the local participant leave
|
|
|
|
* a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
|
2016-10-05 14:36:59 +00:00
|
|
|
* though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
|
|
|
|
* lib-jitsi-meet and not the application.
|
|
|
|
*
|
|
|
|
* @param {JitsiConference} conference - The JitsiConference instance which will
|
|
|
|
* be left by the local participant.
|
|
|
|
* @returns {{
|
2017-04-19 14:52:27 +00:00
|
|
|
* type: CONFERENCE_LEFT,
|
|
|
|
* conference: JitsiConference
|
|
|
|
* }}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function conferenceWillLeave(conference: Object) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: CONFERENCE_WILL_LEAVE,
|
2016-12-12 00:29:13 +00:00
|
|
|
conference
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new conference.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function createConference() {
|
2017-10-03 19:24:00 +00:00
|
|
|
return (dispatch: Function, getState: Function) => {
|
2016-12-12 00:29:13 +00:00
|
|
|
const state = getState();
|
2017-08-01 00:40:55 +00:00
|
|
|
const { connection, locationURL } = state['features/base/connection'];
|
2016-12-12 00:29:13 +00:00
|
|
|
|
|
|
|
if (!connection) {
|
2017-07-07 17:21:08 +00:00
|
|
|
throw new Error('Cannot create a conference without a connection!');
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
2016-12-12 00:29:13 +00:00
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
const { password, room } = state['features/base/conference'];
|
2016-12-12 00:29:13 +00:00
|
|
|
|
2017-07-07 17:21:08 +00:00
|
|
|
if (!room) {
|
|
|
|
throw new Error('Cannot join a conference without a room name!');
|
2016-12-12 00:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const conference
|
2017-01-15 19:05:17 +00:00
|
|
|
= connection.initJitsiConference(
|
2017-01-20 18:11:11 +00:00
|
|
|
|
2017-02-24 18:01:10 +00:00
|
|
|
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
2017-10-13 20:34:27 +00:00
|
|
|
room.toLowerCase(), {
|
|
|
|
...state['features/base/config'],
|
|
|
|
applicationName: getName()
|
|
|
|
});
|
2016-12-12 00:29:13 +00:00
|
|
|
|
2017-08-01 00:40:55 +00:00
|
|
|
conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
|
2017-07-07 17:21:08 +00:00
|
|
|
dispatch(_conferenceWillJoin(conference));
|
2017-07-06 11:51:35 +00:00
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
_addConferenceListeners(conference, dispatch);
|
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
sendLocalParticipant(state, conference);
|
2017-02-28 23:12:02 +00:00
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
conference.join(password);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-08 13:36:42 +00:00
|
|
|
/**
|
|
|
|
* Will try to join the conference again in case it failed earlier with
|
|
|
|
* {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
|
|
|
|
* did not allow to create new room from anonymous domain, but it can be tried
|
|
|
|
* again later in case authenticated user created it in the meantime.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function checkIfCanJoin() {
|
2017-10-02 23:08:07 +00:00
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
2017-09-18 07:09:43 +00:00
|
|
|
const { authRequired, password }
|
2017-09-08 13:36:42 +00:00
|
|
|
= getState()['features/base/conference'];
|
|
|
|
|
2017-09-18 07:09:43 +00:00
|
|
|
authRequired && authRequired.join(password);
|
2017-09-08 13:36:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-09 19:40:03 +00:00
|
|
|
/**
|
|
|
|
* Signals the data channel with the bridge has successfully opened.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* type: DATA_CHANNEL_OPENED
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function dataChannelOpened() {
|
|
|
|
return {
|
|
|
|
type: DATA_CHANNEL_OPENED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-12 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Signals that the lock state of a specific JitsiConference changed.
|
|
|
|
*
|
|
|
|
* @param {JitsiConference} conference - The JitsiConference which had its lock
|
|
|
|
* state changed.
|
|
|
|
* @param {boolean} locked - If the specified conference became locked, true;
|
|
|
|
* otherwise, false.
|
|
|
|
* @returns {{
|
|
|
|
* type: LOCK_STATE_CHANGED,
|
|
|
|
* conference: JitsiConference,
|
|
|
|
* locked: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function lockStateChanged(conference: Object, locked: boolean) {
|
2016-12-12 19:49:23 +00:00
|
|
|
return {
|
|
|
|
type: LOCK_STATE_CHANGED,
|
|
|
|
conference,
|
|
|
|
locked
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-03-29 12:07:05 +00:00
|
|
|
/**
|
2017-08-09 19:40:03 +00:00
|
|
|
* Sets whether or not peer2peer is currently enabled.
|
2017-03-29 12:07:05 +00:00
|
|
|
*
|
2017-08-09 19:40:03 +00:00
|
|
|
* @param {boolean} p2p - Whether or not peer2peer is currently active.
|
2017-03-29 12:07:05 +00:00
|
|
|
* @returns {{
|
2017-08-09 19:40:03 +00:00
|
|
|
* type: P2P_STATUS_CHANGED,
|
|
|
|
* p2p: boolean
|
2017-03-29 12:07:05 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function p2pStatusChanged(p2p: boolean) {
|
2017-03-29 12:07:05 +00:00
|
|
|
return {
|
2017-08-09 19:40:03 +00:00
|
|
|
type: P2P_STATUS_CHANGED,
|
|
|
|
p2p
|
2017-03-29 12:07:05 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-21 21:14:14 +00:00
|
|
|
/**
|
2017-08-09 19:40:03 +00:00
|
|
|
* Sets the audio-only flag for the current JitsiConference.
|
2017-04-21 21:14:14 +00:00
|
|
|
*
|
2017-08-09 19:40:03 +00:00
|
|
|
* @param {boolean} audioOnly - True if the conference should be audio only;
|
|
|
|
* false, otherwise.
|
2017-04-21 21:14:14 +00:00
|
|
|
* @returns {{
|
2017-08-09 19:40:03 +00:00
|
|
|
* type: SET_AUDIO_ONLY,
|
|
|
|
* audioOnly: boolean
|
2017-04-21 21:14:14 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function setAudioOnly(audioOnly: boolean) {
|
2017-04-21 21:14:14 +00:00
|
|
|
return {
|
2017-08-09 19:40:03 +00:00
|
|
|
type: SET_AUDIO_ONLY,
|
|
|
|
audioOnly
|
2017-04-21 21:14:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-03-29 10:24:18 +00:00
|
|
|
/**
|
|
|
|
* Sets the video channel's last N (value) of the current conference. A value of
|
|
|
|
* undefined shall be used to reset it to the default value.
|
|
|
|
*
|
|
|
|
* @param {(number|undefined)} lastN - The last N value to be set.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function setLastN(lastN: ?number) {
|
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
|
|
|
if (typeof lastN === 'undefined') {
|
2017-04-23 20:14:02 +00:00
|
|
|
const config = getState()['features/base/config'];
|
2017-03-29 10:24:18 +00:00
|
|
|
|
|
|
|
/* eslint-disable no-param-reassign */
|
|
|
|
|
|
|
|
lastN = config.channelLastN;
|
|
|
|
if (typeof lastN === 'undefined') {
|
|
|
|
lastN = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* eslint-enable no-param-reassign */
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: SET_LASTN,
|
|
|
|
lastN
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* Sets the password to join or lock a specific JitsiConference.
|
|
|
|
*
|
|
|
|
* @param {JitsiConference} conference - The JitsiConference which requires a
|
|
|
|
* password to join or is to be locked with the specified password.
|
|
|
|
* @param {Function} method - The JitsiConference method of password protection
|
|
|
|
* such as join or lock.
|
|
|
|
* @param {string} password - The password with which the specified conference
|
|
|
|
* is to be joined or locked.
|
2016-12-13 09:14:04 +00:00
|
|
|
* @returns {Function}
|
2016-12-12 01:02:50 +00:00
|
|
|
*/
|
2017-10-03 19:24:00 +00:00
|
|
|
export function setPassword(
|
|
|
|
conference: Object,
|
|
|
|
method: Function,
|
|
|
|
password: string) {
|
2017-10-02 23:08:07 +00:00
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
2016-12-13 09:14:04 +00:00
|
|
|
switch (method) {
|
|
|
|
case conference.join: {
|
|
|
|
let state = getState()['features/base/conference'];
|
|
|
|
|
|
|
|
// Make sure that the action will set a password for a conference
|
|
|
|
// that the application wants joined.
|
|
|
|
if (state.passwordRequired === conference) {
|
|
|
|
dispatch({
|
|
|
|
type: SET_PASSWORD,
|
|
|
|
conference,
|
|
|
|
method,
|
|
|
|
password
|
|
|
|
});
|
|
|
|
|
|
|
|
// Join the conference with the newly-set password.
|
|
|
|
|
|
|
|
// Make sure that the action did set the password.
|
|
|
|
state = getState()['features/base/conference'];
|
|
|
|
if (state.password === password
|
|
|
|
&& !state.passwordRequired
|
|
|
|
|
|
|
|
// Make sure that the application still wants the
|
|
|
|
// conference joined.
|
|
|
|
&& !state.conference) {
|
|
|
|
method.call(conference, password);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case conference.lock: {
|
|
|
|
const state = getState()['features/base/conference'];
|
|
|
|
|
|
|
|
if (state.conference === conference) {
|
|
|
|
return (
|
|
|
|
method.call(conference, password)
|
|
|
|
.then(() => dispatch({
|
|
|
|
type: SET_PASSWORD,
|
|
|
|
conference,
|
|
|
|
method,
|
|
|
|
password
|
2017-04-13 00:23:43 +00:00
|
|
|
}))
|
|
|
|
.catch(error => dispatch({
|
|
|
|
type: SET_PASSWORD_FAILED,
|
|
|
|
error
|
|
|
|
}))
|
|
|
|
);
|
2016-12-13 09:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.reject();
|
|
|
|
}
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-09 19:40:03 +00:00
|
|
|
/**
|
|
|
|
* Sets the max frame height to receive from remote participant videos.
|
|
|
|
*
|
|
|
|
* @param {number} receiveVideoQuality - The max video resolution to receive.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_RECEIVE_VIDEO_QUALITY,
|
|
|
|
* receiveVideoQuality: number
|
|
|
|
* }}
|
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
export function setReceiveVideoQuality(receiveVideoQuality: number) {
|
2017-08-09 19:40:03 +00:00
|
|
|
return {
|
|
|
|
type: SET_RECEIVE_VIDEO_QUALITY,
|
|
|
|
receiveVideoQuality
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Sets (the name of) the room of the conference to be joined.
|
|
|
|
*
|
|
|
|
* @param {(string|undefined)} room - The name of the room of the conference to
|
|
|
|
* be joined.
|
|
|
|
* @returns {{
|
2017-04-06 16:45:36 +00:00
|
|
|
* type: SET_ROOM,
|
|
|
|
* room: string
|
|
|
|
* }}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-10-02 23:08:07 +00:00
|
|
|
export function setRoom(room: ?string) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
type: SET_ROOM,
|
|
|
|
room
|
|
|
|
};
|
|
|
|
}
|
2017-03-29 12:07:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the audio-only flag for the current JitsiConference.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function toggleAudioOnly() {
|
|
|
|
return (dispatch: Dispatch<*>, getState: Function) => {
|
|
|
|
const { audioOnly } = getState()['features/base/conference'];
|
|
|
|
|
2017-08-02 15:00:51 +00:00
|
|
|
return dispatch(setAudioOnly(!audioOnly));
|
2017-03-29 12:07:05 +00:00
|
|
|
};
|
|
|
|
}
|