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

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