You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. createStartMutedConfigurationEvent,
  5. sendAnalytics
  6. } from '../../analytics';
  7. import { getName } from '../../app/functions';
  8. import { endpointMessageReceived } from '../../subtitles';
  9. import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';
  10. import { JitsiConferenceEvents } from '../lib-jitsi-meet';
  11. import { setAudioMuted, setVideoMuted } from '../media';
  12. import {
  13. dominantSpeakerChanged,
  14. getLocalParticipant,
  15. getNormalizedDisplayName,
  16. participantConnectionStatusChanged,
  17. participantKicked,
  18. participantMutedUs,
  19. participantPresenceChanged,
  20. participantRoleChanged,
  21. participantUpdated
  22. } from '../participants';
  23. import { getLocalTracks, trackAdded, trackRemoved } from '../tracks';
  24. import {
  25. getBackendSafePath,
  26. getBackendSafeRoomName,
  27. getJitsiMeetGlobalNS
  28. } from '../util';
  29. import {
  30. AUTH_STATUS_CHANGED,
  31. CONFERENCE_FAILED,
  32. CONFERENCE_JOINED,
  33. CONFERENCE_LEFT,
  34. CONFERENCE_SUBJECT_CHANGED,
  35. CONFERENCE_TIMESTAMP_CHANGED,
  36. CONFERENCE_WILL_JOIN,
  37. CONFERENCE_WILL_LEAVE,
  38. DATA_CHANNEL_OPENED,
  39. KICKED_OUT,
  40. LOCK_STATE_CHANGED,
  41. P2P_STATUS_CHANGED,
  42. SEND_TONES,
  43. SET_DESKTOP_SHARING_ENABLED,
  44. SET_FOLLOW_ME,
  45. SET_MAX_RECEIVER_VIDEO_QUALITY,
  46. SET_PASSWORD,
  47. SET_PASSWORD_FAILED,
  48. SET_PREFERRED_VIDEO_QUALITY,
  49. SET_ROOM,
  50. SET_PENDING_SUBJECT_CHANGE,
  51. SET_START_MUTED_POLICY
  52. } from './actionTypes';
  53. import {
  54. AVATAR_ID_COMMAND,
  55. AVATAR_URL_COMMAND,
  56. EMAIL_COMMAND,
  57. JITSI_CONFERENCE_URL_KEY
  58. } from './constants';
  59. import {
  60. _addLocalTracksToConference,
  61. commonUserJoinedHandling,
  62. commonUserLeftHandling,
  63. getCurrentConference,
  64. sendLocalParticipant
  65. } from './functions';
  66. import logger from './logger';
  67. declare var APP: Object;
  68. /**
  69. * Adds conference (event) listeners.
  70. *
  71. * @param {JitsiConference} conference - The JitsiConference instance.
  72. * @param {Dispatch} dispatch - The Redux dispatch function.
  73. * @private
  74. * @returns {void}
  75. */
  76. function _addConferenceListeners(conference, dispatch) {
  77. // A simple logger for conference errors received through
  78. // the listener. These errors are not handled now, but logged.
  79. conference.on(JitsiConferenceEvents.CONFERENCE_ERROR,
  80. error => logger.error('Conference error.', error));
  81. // Dispatches into features/base/conference follow:
  82. conference.on(
  83. JitsiConferenceEvents.CONFERENCE_FAILED,
  84. (...args) => dispatch(conferenceFailed(conference, ...args)));
  85. conference.on(
  86. JitsiConferenceEvents.CONFERENCE_JOINED,
  87. (...args) => dispatch(conferenceJoined(conference, ...args)));
  88. conference.on(
  89. JitsiConferenceEvents.CONFERENCE_LEFT,
  90. (...args) => {
  91. dispatch(conferenceTimestampChanged(0));
  92. dispatch(conferenceLeft(conference, ...args));
  93. });
  94. conference.on(JitsiConferenceEvents.SUBJECT_CHANGED,
  95. (...args) => dispatch(conferenceSubjectChanged(...args)));
  96. conference.on(JitsiConferenceEvents.CONFERENCE_CREATED_TIMESTAMP,
  97. (...args) => dispatch(conferenceTimestampChanged(...args)));
  98. conference.on(
  99. JitsiConferenceEvents.KICKED,
  100. (...args) => dispatch(kickedOut(conference, ...args)));
  101. conference.on(
  102. JitsiConferenceEvents.PARTICIPANT_KICKED,
  103. (kicker, kicked) => dispatch(participantKicked(kicker, kicked)));
  104. conference.on(
  105. JitsiConferenceEvents.LOCK_STATE_CHANGED,
  106. (...args) => dispatch(lockStateChanged(conference, ...args)));
  107. // Dispatches into features/base/media follow:
  108. conference.on(
  109. JitsiConferenceEvents.STARTED_MUTED,
  110. () => {
  111. const audioMuted = Boolean(conference.startAudioMuted);
  112. const videoMuted = Boolean(conference.startVideoMuted);
  113. sendAnalytics(createStartMutedConfigurationEvent(
  114. 'remote', audioMuted, videoMuted));
  115. logger.log(`Start muted: ${audioMuted ? 'audio, ' : ''}${
  116. videoMuted ? 'video' : ''}`);
  117. // XXX Jicofo tells lib-jitsi-meet to start with audio and/or video
  118. // muted i.e. Jicofo expresses an intent. Lib-jitsi-meet has turned
  119. // Jicofo's intent into reality by actually muting the respective
  120. // tracks. The reality is expressed in base/tracks already so what
  121. // is left is to express Jicofo's intent in base/media.
  122. // TODO Maybe the app needs to learn about Jicofo's intent and
  123. // transfer that intent to lib-jitsi-meet instead of lib-jitsi-meet
  124. // acting on Jicofo's intent without the app's knowledge.
  125. dispatch(setAudioMuted(audioMuted));
  126. dispatch(setVideoMuted(videoMuted));
  127. });
  128. // Dispatches into features/base/tracks follow:
  129. conference.on(
  130. JitsiConferenceEvents.TRACK_ADDED,
  131. t => t && !t.isLocal() && dispatch(trackAdded(t)));
  132. conference.on(
  133. JitsiConferenceEvents.TRACK_REMOVED,
  134. t => t && !t.isLocal() && dispatch(trackRemoved(t)));
  135. conference.on(
  136. JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  137. (_, participantThatMutedUs) => {
  138. if (participantThatMutedUs) {
  139. dispatch(participantMutedUs(participantThatMutedUs));
  140. }
  141. });
  142. // Dispatches into features/base/participants follow:
  143. conference.on(
  144. JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
  145. (id, displayName) => dispatch(participantUpdated({
  146. conference,
  147. id,
  148. name: getNormalizedDisplayName(displayName)
  149. })));
  150. conference.on(
  151. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
  152. id => dispatch(dominantSpeakerChanged(id, conference)));
  153. conference.on(
  154. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  155. (...args) => dispatch(endpointMessageReceived(...args)));
  156. conference.on(
  157. JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
  158. (...args) => dispatch(participantConnectionStatusChanged(...args)));
  159. conference.on(
  160. JitsiConferenceEvents.USER_JOINED,
  161. (id, user) => commonUserJoinedHandling({ dispatch }, conference, user));
  162. conference.on(
  163. JitsiConferenceEvents.USER_LEFT,
  164. (id, user) => commonUserLeftHandling({ dispatch }, conference, user));
  165. conference.on(
  166. JitsiConferenceEvents.USER_ROLE_CHANGED,
  167. (...args) => dispatch(participantRoleChanged(...args)));
  168. conference.on(
  169. JitsiConferenceEvents.USER_STATUS_CHANGED,
  170. (...args) => dispatch(participantPresenceChanged(...args)));
  171. conference.on(
  172. JitsiConferenceEvents.BOT_TYPE_CHANGED,
  173. (id, botType) => dispatch(participantUpdated({
  174. conference,
  175. id,
  176. botType
  177. })));
  178. conference.addCommandListener(
  179. AVATAR_ID_COMMAND,
  180. (data, id) => dispatch(participantUpdated({
  181. conference,
  182. id,
  183. avatarID: data.value
  184. })));
  185. conference.addCommandListener(
  186. AVATAR_URL_COMMAND,
  187. (data, id) => dispatch(participantUpdated({
  188. conference,
  189. id,
  190. avatarURL: data.value
  191. })));
  192. conference.addCommandListener(
  193. EMAIL_COMMAND,
  194. (data, id) => dispatch(participantUpdated({
  195. conference,
  196. id,
  197. email: data.value
  198. })));
  199. }
  200. /**
  201. * Updates the current known state of server-side authentication.
  202. *
  203. * @param {boolean} authEnabled - Whether or not server authentication is
  204. * enabled.
  205. * @param {string} authLogin - The current name of the logged in user, if any.
  206. * @returns {{
  207. * type: AUTH_STATUS_CHANGED,
  208. * authEnabled: boolean,
  209. * authLogin: string
  210. * }}
  211. */
  212. export function authStatusChanged(authEnabled: boolean, authLogin: string) {
  213. return {
  214. type: AUTH_STATUS_CHANGED,
  215. authEnabled,
  216. authLogin
  217. };
  218. }
  219. /**
  220. * Signals that a specific conference has failed.
  221. *
  222. * @param {JitsiConference} conference - The JitsiConference that has failed.
  223. * @param {string} error - The error describing/detailing the cause of the
  224. * failure.
  225. * @param {any} params - Rest of the params that we receive together with the event.
  226. * @returns {{
  227. * type: CONFERENCE_FAILED,
  228. * conference: JitsiConference,
  229. * error: Error
  230. * }}
  231. * @public
  232. */
  233. export function conferenceFailed(conference: Object, error: string, ...params: any) {
  234. return {
  235. type: CONFERENCE_FAILED,
  236. conference,
  237. // Make the error resemble an Error instance (to the extent that
  238. // jitsi-meet needs it).
  239. error: {
  240. name: error,
  241. params,
  242. recoverable: undefined
  243. }
  244. };
  245. }
  246. /**
  247. * Signals that a specific conference has been joined.
  248. *
  249. * @param {JitsiConference} conference - The JitsiConference instance which was
  250. * joined by the local participant.
  251. * @returns {{
  252. * type: CONFERENCE_JOINED,
  253. * conference: JitsiConference
  254. * }}
  255. */
  256. export function conferenceJoined(conference: Object) {
  257. return {
  258. type: CONFERENCE_JOINED,
  259. conference
  260. };
  261. }
  262. /**
  263. * Signals that a specific conference has been left.
  264. *
  265. * @param {JitsiConference} conference - The JitsiConference instance which was
  266. * left by the local participant.
  267. * @returns {{
  268. * type: CONFERENCE_LEFT,
  269. * conference: JitsiConference
  270. * }}
  271. */
  272. export function conferenceLeft(conference: Object) {
  273. return {
  274. type: CONFERENCE_LEFT,
  275. conference
  276. };
  277. }
  278. /**
  279. * Signals that the conference subject has been changed.
  280. *
  281. * @param {string} subject - The new subject.
  282. * @returns {{
  283. * type: CONFERENCE_SUBJECT_CHANGED,
  284. * subject: string
  285. * }}
  286. */
  287. export function conferenceSubjectChanged(subject: string) {
  288. return {
  289. type: CONFERENCE_SUBJECT_CHANGED,
  290. subject
  291. };
  292. }
  293. /**
  294. * Signals that the conference timestamp has been changed.
  295. *
  296. * @param {number} conferenceTimestamp - The UTC timestamp.
  297. * @returns {{
  298. * type: CONFERENCE_TIMESTAMP_CHANGED,
  299. * conferenceTimestamp
  300. * }}
  301. */
  302. export function conferenceTimestampChanged(conferenceTimestamp: number) {
  303. return {
  304. type: CONFERENCE_TIMESTAMP_CHANGED,
  305. conferenceTimestamp
  306. };
  307. }
  308. /**
  309. * Adds any existing local tracks to a specific conference before the conference
  310. * is joined. Then signals the intention of the application to have the local
  311. * participant join the specified conference.
  312. *
  313. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  314. * the local participant will (try to) join.
  315. * @returns {Function}
  316. */
  317. function _conferenceWillJoin(conference: Object) {
  318. return (dispatch: Dispatch<any>, getState: Function) => {
  319. const localTracks
  320. = getLocalTracks(getState()['features/base/tracks'])
  321. .map(t => t.jitsiTrack);
  322. if (localTracks.length) {
  323. _addLocalTracksToConference(conference, localTracks);
  324. }
  325. dispatch(conferenceWillJoin(conference));
  326. };
  327. }
  328. /**
  329. * Signals the intention of the application to have the local participant
  330. * join the specified conference.
  331. *
  332. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  333. * the local participant will (try to) join.
  334. * @returns {{
  335. * type: CONFERENCE_WILL_JOIN,
  336. * conference: JitsiConference
  337. * }}
  338. */
  339. export function conferenceWillJoin(conference: Object) {
  340. return {
  341. type: CONFERENCE_WILL_JOIN,
  342. conference
  343. };
  344. }
  345. /**
  346. * Signals the intention of the application to have the local participant leave
  347. * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
  348. * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
  349. * lib-jitsi-meet and not the application.
  350. *
  351. * @param {JitsiConference} conference - The JitsiConference instance which will
  352. * be left by the local participant.
  353. * @returns {{
  354. * type: CONFERENCE_LEFT,
  355. * conference: JitsiConference
  356. * }}
  357. */
  358. export function conferenceWillLeave(conference: Object) {
  359. return {
  360. type: CONFERENCE_WILL_LEAVE,
  361. conference
  362. };
  363. }
  364. /**
  365. * Initializes a new conference.
  366. *
  367. * @returns {Function}
  368. */
  369. export function createConference() {
  370. return (dispatch: Function, getState: Function) => {
  371. const state = getState();
  372. const { connection, locationURL } = state['features/base/connection'];
  373. if (!connection) {
  374. throw new Error('Cannot create a conference without a connection!');
  375. }
  376. const { password, room } = state['features/base/conference'];
  377. if (!room) {
  378. throw new Error('Cannot join a conference without a room name!');
  379. }
  380. const config = state['features/base/config'];
  381. const { tenant } = state['features/base/jwt'];
  382. const { email, name: nick } = getLocalParticipant(state);
  383. const conference
  384. = connection.initJitsiConference(
  385. getBackendSafeRoomName(room), {
  386. ...config,
  387. applicationName: getName(),
  388. getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats,
  389. confID: `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`,
  390. siteID: tenant,
  391. statisticsDisplayName: config.enableDisplayNameInStats ? nick : undefined,
  392. statisticsId: config.enableEmailInStats ? email : undefined
  393. });
  394. connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;
  395. conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
  396. dispatch(_conferenceWillJoin(conference));
  397. _addConferenceListeners(conference, dispatch);
  398. sendLocalParticipant(state, conference);
  399. conference.join(password);
  400. };
  401. }
  402. /**
  403. * Will try to join the conference again in case it failed earlier with
  404. * {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
  405. * did not allow to create new room from anonymous domain, but it can be tried
  406. * again later in case authenticated user created it in the meantime.
  407. *
  408. * @returns {Function}
  409. */
  410. export function checkIfCanJoin() {
  411. return (dispatch: Function, getState: Function) => {
  412. const { authRequired, password }
  413. = getState()['features/base/conference'];
  414. authRequired && dispatch(_conferenceWillJoin(authRequired));
  415. authRequired && authRequired.join(password);
  416. };
  417. }
  418. /**
  419. * Signals the data channel with the bridge has successfully opened.
  420. *
  421. * @returns {{
  422. * type: DATA_CHANNEL_OPENED
  423. * }}
  424. */
  425. export function dataChannelOpened() {
  426. return {
  427. type: DATA_CHANNEL_OPENED
  428. };
  429. }
  430. /**
  431. * Signals that we've been kicked out of the conference.
  432. *
  433. * @param {JitsiConference} conference - The {@link JitsiConference} instance
  434. * for which the event is being signaled.
  435. * @param {JitsiParticipant} participant - The {@link JitsiParticipant}
  436. * instance which initiated the kick event.
  437. * @returns {{
  438. * type: KICKED_OUT,
  439. * conference: JitsiConference,
  440. * participant: JitsiParticipant
  441. * }}
  442. */
  443. export function kickedOut(conference: Object, participant: Object) {
  444. return {
  445. type: KICKED_OUT,
  446. conference,
  447. participant
  448. };
  449. }
  450. /**
  451. * Signals that the lock state of a specific JitsiConference changed.
  452. *
  453. * @param {JitsiConference} conference - The JitsiConference which had its lock
  454. * state changed.
  455. * @param {boolean} locked - If the specified conference became locked, true;
  456. * otherwise, false.
  457. * @returns {{
  458. * type: LOCK_STATE_CHANGED,
  459. * conference: JitsiConference,
  460. * locked: boolean
  461. * }}
  462. */
  463. export function lockStateChanged(conference: Object, locked: boolean) {
  464. return {
  465. type: LOCK_STATE_CHANGED,
  466. conference,
  467. locked
  468. };
  469. }
  470. /**
  471. * Updates the known state of start muted policies.
  472. *
  473. * @param {boolean} audioMuted - Whether or not members will join the conference
  474. * as audio muted.
  475. * @param {boolean} videoMuted - Whether or not members will join the conference
  476. * as video muted.
  477. * @returns {{
  478. * type: SET_START_MUTED_POLICY,
  479. * startAudioMutedPolicy: boolean,
  480. * startVideoMutedPolicy: boolean
  481. * }}
  482. */
  483. export function onStartMutedPolicyChanged(
  484. audioMuted: boolean, videoMuted: boolean) {
  485. return {
  486. type: SET_START_MUTED_POLICY,
  487. startAudioMutedPolicy: audioMuted,
  488. startVideoMutedPolicy: videoMuted
  489. };
  490. }
  491. /**
  492. * Sets whether or not peer2peer is currently enabled.
  493. *
  494. * @param {boolean} p2p - Whether or not peer2peer is currently active.
  495. * @returns {{
  496. * type: P2P_STATUS_CHANGED,
  497. * p2p: boolean
  498. * }}
  499. */
  500. export function p2pStatusChanged(p2p: boolean) {
  501. return {
  502. type: P2P_STATUS_CHANGED,
  503. p2p
  504. };
  505. }
  506. /**
  507. * Signals to play touch tones.
  508. *
  509. * @param {string} tones - The tones to play.
  510. * @param {number} [duration] - How long to play each tone.
  511. * @param {number} [pause] - How long to pause between each tone.
  512. * @returns {{
  513. * type: SEND_TONES,
  514. * tones: string,
  515. * duration: number,
  516. * pause: number
  517. * }}
  518. */
  519. export function sendTones(tones: string, duration: number, pause: number) {
  520. return {
  521. type: SEND_TONES,
  522. tones,
  523. duration,
  524. pause
  525. };
  526. }
  527. /**
  528. * Sets the flag for indicating if desktop sharing is enabled.
  529. *
  530. * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled.
  531. * @returns {{
  532. * type: SET_DESKTOP_SHARING_ENABLED,
  533. * desktopSharingEnabled: boolean
  534. * }}
  535. */
  536. export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) {
  537. return {
  538. type: SET_DESKTOP_SHARING_ENABLED,
  539. desktopSharingEnabled
  540. };
  541. }
  542. /**
  543. * Enables or disables the Follow Me feature.
  544. *
  545. * @param {boolean} enabled - Whether or not Follow Me should be enabled.
  546. * @returns {{
  547. * type: SET_FOLLOW_ME,
  548. * enabled: boolean
  549. * }}
  550. */
  551. export function setFollowMe(enabled: boolean) {
  552. return {
  553. type: SET_FOLLOW_ME,
  554. enabled
  555. };
  556. }
  557. /**
  558. * Sets the max frame height that should be received from remote videos.
  559. *
  560. * @param {number} maxReceiverVideoQuality - The max video frame height to
  561. * receive.
  562. * @returns {{
  563. * type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  564. * maxReceiverVideoQuality: number
  565. * }}
  566. */
  567. export function setMaxReceiverVideoQuality(maxReceiverVideoQuality: number) {
  568. return {
  569. type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  570. maxReceiverVideoQuality
  571. };
  572. }
  573. /**
  574. * Sets the password to join or lock a specific JitsiConference.
  575. *
  576. * @param {JitsiConference} conference - The JitsiConference which requires a
  577. * password to join or is to be locked with the specified password.
  578. * @param {Function} method - The JitsiConference method of password protection
  579. * such as join or lock.
  580. * @param {string} password - The password with which the specified conference
  581. * is to be joined or locked.
  582. * @returns {Function}
  583. */
  584. export function setPassword(
  585. conference: Object,
  586. method: Function,
  587. password: string) {
  588. return (dispatch: Dispatch<any>, getState: Function): ?Promise<void> => {
  589. switch (method) {
  590. case conference.join: {
  591. let state = getState()['features/base/conference'];
  592. dispatch({
  593. type: SET_PASSWORD,
  594. conference,
  595. method,
  596. password
  597. });
  598. // Join the conference with the newly-set password.
  599. // Make sure that the action did set the password.
  600. state = getState()['features/base/conference'];
  601. if (state.password === password
  602. // Make sure that the application still wants the
  603. // conference joined.
  604. && !state.conference) {
  605. method.call(conference, password);
  606. }
  607. break;
  608. }
  609. case conference.lock: {
  610. const state = getState()['features/base/conference'];
  611. if (state.conference === conference) {
  612. return (
  613. method.call(conference, password)
  614. .then(() => dispatch({
  615. type: SET_PASSWORD,
  616. conference,
  617. method,
  618. password
  619. }))
  620. .catch(error => dispatch({
  621. type: SET_PASSWORD_FAILED,
  622. error
  623. }))
  624. );
  625. }
  626. return Promise.reject();
  627. }
  628. }
  629. };
  630. }
  631. /**
  632. * Sets the max frame height the user prefers to send and receive from the
  633. * remote participants.
  634. *
  635. * @param {number} preferredVideoQuality - The max video resolution to send and
  636. * receive.
  637. * @returns {{
  638. * type: SET_PREFERRED_VIDEO_QUALITY,
  639. * preferredVideoQuality: number
  640. * }}
  641. */
  642. export function setPreferredVideoQuality(preferredVideoQuality: number) {
  643. return {
  644. type: SET_PREFERRED_VIDEO_QUALITY,
  645. preferredVideoQuality
  646. };
  647. }
  648. /**
  649. * Sets (the name of) the room of the conference to be joined.
  650. *
  651. * @param {(string|undefined)} room - The name of the room of the conference to
  652. * be joined.
  653. * @returns {{
  654. * type: SET_ROOM,
  655. * room: string
  656. * }}
  657. */
  658. export function setRoom(room: ?string) {
  659. return {
  660. type: SET_ROOM,
  661. room
  662. };
  663. }
  664. /**
  665. * Sets whether or not members should join audio and/or video muted.
  666. *
  667. * @param {boolean} startAudioMuted - Whether or not members will join the
  668. * conference as audio muted.
  669. * @param {boolean} startVideoMuted - Whether or not members will join the
  670. * conference as video muted.
  671. * @returns {Function}
  672. */
  673. export function setStartMutedPolicy(
  674. startAudioMuted: boolean, startVideoMuted: boolean) {
  675. return (dispatch: Dispatch<any>, getState: Function) => {
  676. const conference = getCurrentConference(getState());
  677. conference && conference.setStartMutedPolicy({
  678. audio: startAudioMuted,
  679. video: startVideoMuted
  680. });
  681. return dispatch(
  682. onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));
  683. };
  684. }
  685. /**
  686. * Changing conference subject.
  687. *
  688. * @param {string} subject - The new subject.
  689. * @returns {void}
  690. */
  691. export function setSubject(subject: string = '') {
  692. return (dispatch: Dispatch<any>, getState: Function) => {
  693. const { conference } = getState()['features/base/conference'];
  694. if (conference) {
  695. conference.setSubject(subject);
  696. } else {
  697. dispatch({
  698. type: SET_PENDING_SUBJECT_CHANGE,
  699. subject
  700. });
  701. }
  702. };
  703. }