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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. createStartMutedConfigurationEvent,
  5. sendAnalytics
  6. } from '../../analytics';
  7. import { getName } from '../../app';
  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. * @returns {{
  226. * type: CONFERENCE_FAILED,
  227. * conference: JitsiConference,
  228. * error: Error
  229. * }}
  230. * @public
  231. */
  232. export function conferenceFailed(conference: Object, error: string, ...params: any) {
  233. return {
  234. type: CONFERENCE_FAILED,
  235. conference,
  236. // Make the error resemble an Error instance (to the extent that
  237. // jitsi-meet needs it).
  238. error: {
  239. name: error,
  240. params,
  241. recoverable: undefined
  242. }
  243. };
  244. }
  245. /**
  246. * Signals that a specific conference has been joined.
  247. *
  248. * @param {JitsiConference} conference - The JitsiConference instance which was
  249. * joined by the local participant.
  250. * @returns {{
  251. * type: CONFERENCE_JOINED,
  252. * conference: JitsiConference
  253. * }}
  254. */
  255. export function conferenceJoined(conference: Object) {
  256. return {
  257. type: CONFERENCE_JOINED,
  258. conference
  259. };
  260. }
  261. /**
  262. * Signals that a specific conference has been left.
  263. *
  264. * @param {JitsiConference} conference - The JitsiConference instance which was
  265. * left by the local participant.
  266. * @returns {{
  267. * type: CONFERENCE_LEFT,
  268. * conference: JitsiConference
  269. * }}
  270. */
  271. export function conferenceLeft(conference: Object) {
  272. return {
  273. type: CONFERENCE_LEFT,
  274. conference
  275. };
  276. }
  277. /**
  278. * Signals that the conference subject has been changed.
  279. *
  280. * @param {string} subject - The new subject.
  281. * @returns {{
  282. * type: CONFERENCE_SUBJECT_CHANGED,
  283. * subject: string
  284. * }}
  285. */
  286. export function conferenceSubjectChanged(subject: string) {
  287. return {
  288. type: CONFERENCE_SUBJECT_CHANGED,
  289. subject
  290. };
  291. }
  292. /**
  293. * Signals that the conference timestamp has been changed.
  294. *
  295. * @param {number} conferenceTimestamp - The UTC timestamp.
  296. * @returns {{
  297. * type: CONFERENCE_TIMESTAMP_CHANGED,
  298. * conferenceTimestamp
  299. * }}
  300. */
  301. export function conferenceTimestampChanged(conferenceTimestamp: number) {
  302. return {
  303. type: CONFERENCE_TIMESTAMP_CHANGED,
  304. conferenceTimestamp
  305. };
  306. }
  307. /**
  308. * Adds any existing local tracks to a specific conference before the conference
  309. * is joined. Then signals the intention of the application to have the local
  310. * participant join the specified conference.
  311. *
  312. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  313. * the local participant will (try to) join.
  314. * @returns {Function}
  315. */
  316. function _conferenceWillJoin(conference: Object) {
  317. return (dispatch: Dispatch<any>, getState: Function) => {
  318. const localTracks
  319. = getLocalTracks(getState()['features/base/tracks'])
  320. .map(t => t.jitsiTrack);
  321. if (localTracks.length) {
  322. _addLocalTracksToConference(conference, localTracks);
  323. }
  324. dispatch(conferenceWillJoin(conference));
  325. };
  326. }
  327. /**
  328. * Signals the intention of the application to have the local participant
  329. * join the specified conference.
  330. *
  331. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  332. * the local participant will (try to) join.
  333. * @returns {{
  334. * type: CONFERENCE_WILL_JOIN,
  335. * conference: JitsiConference
  336. * }}
  337. */
  338. export function conferenceWillJoin(conference: Object) {
  339. return {
  340. type: CONFERENCE_WILL_JOIN,
  341. conference
  342. };
  343. }
  344. /**
  345. * Signals the intention of the application to have the local participant leave
  346. * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
  347. * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
  348. * lib-jitsi-meet and not the application.
  349. *
  350. * @param {JitsiConference} conference - The JitsiConference instance which will
  351. * be left by the local participant.
  352. * @returns {{
  353. * type: CONFERENCE_LEFT,
  354. * conference: JitsiConference
  355. * }}
  356. */
  357. export function conferenceWillLeave(conference: Object) {
  358. return {
  359. type: CONFERENCE_WILL_LEAVE,
  360. conference
  361. };
  362. }
  363. /**
  364. * Initializes a new conference.
  365. *
  366. * @returns {Function}
  367. */
  368. export function createConference() {
  369. return (dispatch: Function, getState: Function) => {
  370. const state = getState();
  371. const { connection, locationURL } = state['features/base/connection'];
  372. if (!connection) {
  373. throw new Error('Cannot create a conference without a connection!');
  374. }
  375. const { password, room } = state['features/base/conference'];
  376. if (!room) {
  377. throw new Error('Cannot join a conference without a room name!');
  378. }
  379. const config = state['features/base/config'];
  380. const { tenant } = state['features/base/jwt'];
  381. const { email, name: nick } = getLocalParticipant(state);
  382. const conference
  383. = connection.initJitsiConference(
  384. getBackendSafeRoomName(room), {
  385. ...config,
  386. applicationName: getName(),
  387. getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats,
  388. confID: `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`,
  389. siteID: tenant,
  390. statisticsDisplayName: config.enableDisplayNameInStats ? nick : undefined,
  391. statisticsId: config.enableEmailInStats ? email : undefined
  392. });
  393. connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;
  394. conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
  395. dispatch(_conferenceWillJoin(conference));
  396. _addConferenceListeners(conference, dispatch);
  397. sendLocalParticipant(state, conference);
  398. conference.join(password);
  399. };
  400. }
  401. /**
  402. * Will try to join the conference again in case it failed earlier with
  403. * {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
  404. * did not allow to create new room from anonymous domain, but it can be tried
  405. * again later in case authenticated user created it in the meantime.
  406. *
  407. * @returns {Function}
  408. */
  409. export function checkIfCanJoin() {
  410. return (dispatch: Function, getState: Function) => {
  411. const { authRequired, password }
  412. = getState()['features/base/conference'];
  413. authRequired && dispatch(_conferenceWillJoin(authRequired));
  414. authRequired && authRequired.join(password);
  415. };
  416. }
  417. /**
  418. * Signals the data channel with the bridge has successfully opened.
  419. *
  420. * @returns {{
  421. * type: DATA_CHANNEL_OPENED
  422. * }}
  423. */
  424. export function dataChannelOpened() {
  425. return {
  426. type: DATA_CHANNEL_OPENED
  427. };
  428. }
  429. /**
  430. * Signals that we've been kicked out of the conference.
  431. *
  432. * @param {JitsiConference} conference - The {@link JitsiConference} instance
  433. * for which the event is being signaled.
  434. * @param {JitsiParticipant} participant - The {@link JitsiParticipant}
  435. * instance which initiated the kick event.
  436. * @returns {{
  437. * type: KICKED_OUT,
  438. * conference: JitsiConference,
  439. * participant: JitsiParticipant
  440. * }}
  441. */
  442. export function kickedOut(conference: Object, participant: Object) {
  443. return {
  444. type: KICKED_OUT,
  445. conference,
  446. participant
  447. };
  448. }
  449. /**
  450. * Signals that the lock state of a specific JitsiConference changed.
  451. *
  452. * @param {JitsiConference} conference - The JitsiConference which had its lock
  453. * state changed.
  454. * @param {boolean} locked - If the specified conference became locked, true;
  455. * otherwise, false.
  456. * @returns {{
  457. * type: LOCK_STATE_CHANGED,
  458. * conference: JitsiConference,
  459. * locked: boolean
  460. * }}
  461. */
  462. export function lockStateChanged(conference: Object, locked: boolean) {
  463. return {
  464. type: LOCK_STATE_CHANGED,
  465. conference,
  466. locked
  467. };
  468. }
  469. /**
  470. * Updates the known state of start muted policies.
  471. *
  472. * @param {boolean} audioMuted - Whether or not members will join the conference
  473. * as audio muted.
  474. * @param {boolean} videoMuted - Whether or not members will join the conference
  475. * as video muted.
  476. * @returns {{
  477. * type: SET_START_MUTED_POLICY,
  478. * startAudioMutedPolicy: boolean,
  479. * startVideoMutedPolicy: boolean
  480. * }}
  481. */
  482. export function onStartMutedPolicyChanged(
  483. audioMuted: boolean, videoMuted: boolean) {
  484. return {
  485. type: SET_START_MUTED_POLICY,
  486. startAudioMutedPolicy: audioMuted,
  487. startVideoMutedPolicy: videoMuted
  488. };
  489. }
  490. /**
  491. * Sets whether or not peer2peer is currently enabled.
  492. *
  493. * @param {boolean} p2p - Whether or not peer2peer is currently active.
  494. * @returns {{
  495. * type: P2P_STATUS_CHANGED,
  496. * p2p: boolean
  497. * }}
  498. */
  499. export function p2pStatusChanged(p2p: boolean) {
  500. return {
  501. type: P2P_STATUS_CHANGED,
  502. p2p
  503. };
  504. }
  505. /**
  506. * Signals to play touch tones.
  507. *
  508. * @param {string} tones - The tones to play.
  509. * @param {number} [duration] - How long to play each tone.
  510. * @param {number} [pause] - How long to pause between each tone.
  511. * @returns {{
  512. * type: SEND_TONES,
  513. * tones: string,
  514. * duration: number,
  515. * pause: number
  516. * }}
  517. */
  518. export function sendTones(tones: string, duration: number, pause: number) {
  519. return {
  520. type: SEND_TONES,
  521. tones,
  522. duration,
  523. pause
  524. };
  525. }
  526. /**
  527. * Sets the flag for indicating if desktop sharing is enabled.
  528. *
  529. * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled.
  530. * @returns {{
  531. * type: SET_DESKTOP_SHARING_ENABLED,
  532. * desktopSharingEnabled: boolean
  533. * }}
  534. */
  535. export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) {
  536. return {
  537. type: SET_DESKTOP_SHARING_ENABLED,
  538. desktopSharingEnabled
  539. };
  540. }
  541. /**
  542. * Enables or disables the Follow Me feature.
  543. *
  544. * @param {boolean} enabled - Whether or not Follow Me should be enabled.
  545. * @returns {{
  546. * type: SET_FOLLOW_ME,
  547. * enabled: boolean
  548. * }}
  549. */
  550. export function setFollowMe(enabled: boolean) {
  551. return {
  552. type: SET_FOLLOW_ME,
  553. enabled
  554. };
  555. }
  556. /**
  557. * Sets the max frame height that should be received from remote videos.
  558. *
  559. * @param {number} maxReceiverVideoQuality - The max video frame height to
  560. * receive.
  561. * @returns {{
  562. * type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  563. * maxReceiverVideoQuality: number
  564. * }}
  565. */
  566. export function setMaxReceiverVideoQuality(maxReceiverVideoQuality: number) {
  567. return {
  568. type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  569. maxReceiverVideoQuality
  570. };
  571. }
  572. /**
  573. * Sets the password to join or lock a specific JitsiConference.
  574. *
  575. * @param {JitsiConference} conference - The JitsiConference which requires a
  576. * password to join or is to be locked with the specified password.
  577. * @param {Function} method - The JitsiConference method of password protection
  578. * such as join or lock.
  579. * @param {string} password - The password with which the specified conference
  580. * is to be joined or locked.
  581. * @returns {Function}
  582. */
  583. export function setPassword(
  584. conference: Object,
  585. method: Function,
  586. password: string) {
  587. return (dispatch: Dispatch<any>, getState: Function): ?Promise<void> => {
  588. switch (method) {
  589. case conference.join: {
  590. let state = getState()['features/base/conference'];
  591. // Make sure that the action will set a password for a conference
  592. // that the application wants joined.
  593. if (state.passwordRequired === conference) {
  594. dispatch({
  595. type: SET_PASSWORD,
  596. conference,
  597. method,
  598. password
  599. });
  600. // Join the conference with the newly-set password.
  601. // Make sure that the action did set the password.
  602. state = getState()['features/base/conference'];
  603. if (state.password === password
  604. && !state.passwordRequired
  605. // Make sure that the application still wants the
  606. // conference joined.
  607. && !state.conference) {
  608. method.call(conference, password);
  609. }
  610. }
  611. break;
  612. }
  613. case conference.lock: {
  614. const state = getState()['features/base/conference'];
  615. if (state.conference === conference) {
  616. return (
  617. method.call(conference, password)
  618. .then(() => dispatch({
  619. type: SET_PASSWORD,
  620. conference,
  621. method,
  622. password
  623. }))
  624. .catch(error => dispatch({
  625. type: SET_PASSWORD_FAILED,
  626. error
  627. }))
  628. );
  629. }
  630. return Promise.reject();
  631. }
  632. }
  633. };
  634. }
  635. /**
  636. * Sets the max frame height the user prefers to send and receive from the
  637. * remote participants.
  638. *
  639. * @param {number} preferredVideoQuality - The max video resolution to send and
  640. * receive.
  641. * @returns {{
  642. * type: SET_PREFERRED_VIDEO_QUALITY,
  643. * preferredVideoQuality: number
  644. * }}
  645. */
  646. export function setPreferredVideoQuality(preferredVideoQuality: number) {
  647. return {
  648. type: SET_PREFERRED_VIDEO_QUALITY,
  649. preferredVideoQuality
  650. };
  651. }
  652. /**
  653. * Sets (the name of) the room of the conference to be joined.
  654. *
  655. * @param {(string|undefined)} room - The name of the room of the conference to
  656. * be joined.
  657. * @returns {{
  658. * type: SET_ROOM,
  659. * room: string
  660. * }}
  661. */
  662. export function setRoom(room: ?string) {
  663. return {
  664. type: SET_ROOM,
  665. room
  666. };
  667. }
  668. /**
  669. * Sets whether or not members should join audio and/or video muted.
  670. *
  671. * @param {boolean} startAudioMuted - Whether or not members will join the
  672. * conference as audio muted.
  673. * @param {boolean} startVideoMuted - Whether or not members will join the
  674. * conference as video muted.
  675. * @returns {Function}
  676. */
  677. export function setStartMutedPolicy(
  678. startAudioMuted: boolean, startVideoMuted: boolean) {
  679. return (dispatch: Dispatch<any>, getState: Function) => {
  680. const conference = getCurrentConference(getState());
  681. conference && conference.setStartMutedPolicy({
  682. audio: startAudioMuted,
  683. video: startVideoMuted
  684. });
  685. return dispatch(
  686. onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));
  687. };
  688. }
  689. /**
  690. * Changing conference subject.
  691. *
  692. * @param {string} subject - The new subject.
  693. * @returns {void}
  694. */
  695. export function setSubject(subject: string = '') {
  696. return (dispatch: Dispatch<any>, getState: Function) => {
  697. const { conference } = getState()['features/base/conference'];
  698. if (conference) {
  699. conference.setSubject(subject);
  700. } else {
  701. dispatch({
  702. type: SET_PENDING_SUBJECT_CHANGE,
  703. subject
  704. });
  705. }
  706. };
  707. }