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