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

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