Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  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. participantPresenceChanged,
  16. participantRoleChanged,
  17. participantUpdated
  18. } from '../participants';
  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(JitsiConferenceEvents.SUBJECT_CHANGED,
  81. (...args) => dispatch(conferenceSubjectChanged(...args)));
  82. conference.on(
  83. JitsiConferenceEvents.KICKED,
  84. () => dispatch(kickedOut(conference)));
  85. conference.on(
  86. JitsiConferenceEvents.LOCK_STATE_CHANGED,
  87. (...args) => dispatch(lockStateChanged(conference, ...args)));
  88. // Dispatches into features/base/media follow:
  89. conference.on(
  90. JitsiConferenceEvents.STARTED_MUTED,
  91. () => {
  92. const audioMuted = Boolean(conference.startAudioMuted);
  93. const videoMuted = Boolean(conference.startVideoMuted);
  94. sendAnalytics(createStartMutedConfigurationEvent(
  95. 'remote', audioMuted, videoMuted));
  96. logger.log(`Start muted: ${audioMuted ? 'audio, ' : ''}${
  97. videoMuted ? 'video' : ''}`);
  98. // XXX Jicofo tells lib-jitsi-meet to start with audio and/or video
  99. // muted i.e. Jicofo expresses an intent. Lib-jitsi-meet has turned
  100. // Jicofo's intent into reality by actually muting the respective
  101. // tracks. The reality is expressed in base/tracks already so what
  102. // is left is to express Jicofo's intent in base/media.
  103. // TODO Maybe the app needs to learn about Jicofo's intent and
  104. // transfer that intent to lib-jitsi-meet instead of lib-jitsi-meet
  105. // acting on Jicofo's intent without the app's knowledge.
  106. dispatch(setAudioMuted(audioMuted));
  107. dispatch(setVideoMuted(videoMuted));
  108. });
  109. // Dispatches into features/base/tracks follow:
  110. conference.on(
  111. JitsiConferenceEvents.TRACK_ADDED,
  112. t => t && !t.isLocal() && dispatch(trackAdded(t)));
  113. conference.on(
  114. JitsiConferenceEvents.TRACK_REMOVED,
  115. t => t && !t.isLocal() && dispatch(trackRemoved(t)));
  116. // Dispatches into features/base/participants follow:
  117. conference.on(
  118. JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
  119. (id, displayName) => dispatch(participantUpdated({
  120. conference,
  121. id,
  122. name: getNormalizedDisplayName(displayName)
  123. })));
  124. conference.on(
  125. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
  126. id => dispatch(dominantSpeakerChanged(id, conference)));
  127. conference.on(
  128. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  129. (...args) => dispatch(endpointMessageReceived(...args)));
  130. conference.on(
  131. JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
  132. (...args) => dispatch(participantConnectionStatusChanged(...args)));
  133. conference.on(
  134. JitsiConferenceEvents.USER_JOINED,
  135. (id, user) => commonUserJoinedHandling({ dispatch }, conference, user));
  136. conference.on(
  137. JitsiConferenceEvents.USER_LEFT,
  138. (id, user) => commonUserLeftHandling({ dispatch }, conference, user));
  139. conference.on(
  140. JitsiConferenceEvents.USER_ROLE_CHANGED,
  141. (...args) => dispatch(participantRoleChanged(...args)));
  142. conference.on(
  143. JitsiConferenceEvents.USER_STATUS_CHANGED,
  144. (...args) => dispatch(participantPresenceChanged(...args)));
  145. conference.on(
  146. JitsiConferenceEvents.BOT_TYPE_CHANGED,
  147. (id, botType) => dispatch(participantUpdated({
  148. conference,
  149. id,
  150. botType
  151. })));
  152. conference.addCommandListener(
  153. AVATAR_ID_COMMAND,
  154. (data, id) => dispatch(participantUpdated({
  155. conference,
  156. id,
  157. avatarID: data.value
  158. })));
  159. conference.addCommandListener(
  160. AVATAR_URL_COMMAND,
  161. (data, id) => dispatch(participantUpdated({
  162. conference,
  163. id,
  164. avatarURL: data.value
  165. })));
  166. conference.addCommandListener(
  167. EMAIL_COMMAND,
  168. (data, id) => dispatch(participantUpdated({
  169. conference,
  170. id,
  171. email: data.value
  172. })));
  173. }
  174. /**
  175. * Updates the current known state of server-side authentication.
  176. *
  177. * @param {boolean} authEnabled - Whether or not server authentication is
  178. * enabled.
  179. * @param {string} authLogin - The current name of the logged in user, if any.
  180. * @returns {{
  181. * type: AUTH_STATUS_CHANGED,
  182. * authEnabled: boolean,
  183. * authLogin: string
  184. * }}
  185. */
  186. export function authStatusChanged(authEnabled: boolean, authLogin: string) {
  187. return {
  188. type: AUTH_STATUS_CHANGED,
  189. authEnabled,
  190. authLogin
  191. };
  192. }
  193. /**
  194. * Signals that a specific conference has failed.
  195. *
  196. * @param {JitsiConference} conference - The JitsiConference that has failed.
  197. * @param {string} error - The error describing/detailing the cause of the
  198. * failure.
  199. * @returns {{
  200. * type: CONFERENCE_FAILED,
  201. * conference: JitsiConference,
  202. * error: Error
  203. * }}
  204. * @public
  205. */
  206. export function conferenceFailed(conference: Object, error: string) {
  207. return {
  208. type: CONFERENCE_FAILED,
  209. conference,
  210. // Make the error resemble an Error instance (to the extent that
  211. // jitsi-meet needs it).
  212. error: {
  213. name: error,
  214. recoverable: undefined
  215. }
  216. };
  217. }
  218. /**
  219. * Signals that a specific conference has been joined.
  220. *
  221. * @param {JitsiConference} conference - The JitsiConference instance which was
  222. * joined by the local participant.
  223. * @returns {{
  224. * type: CONFERENCE_JOINED,
  225. * conference: JitsiConference
  226. * }}
  227. */
  228. export function conferenceJoined(conference: Object) {
  229. return {
  230. type: CONFERENCE_JOINED,
  231. conference
  232. };
  233. }
  234. /**
  235. * Signals that a specific conference has been left.
  236. *
  237. * @param {JitsiConference} conference - The JitsiConference instance which was
  238. * left by the local participant.
  239. * @returns {{
  240. * type: CONFERENCE_LEFT,
  241. * conference: JitsiConference
  242. * }}
  243. */
  244. export function conferenceLeft(conference: Object) {
  245. return {
  246. type: CONFERENCE_LEFT,
  247. conference
  248. };
  249. }
  250. /**
  251. * Signals that the conference subject has been changed.
  252. *
  253. * @param {string} subject - The new subject.
  254. * @returns {{
  255. * type: CONFERENCE_SUBJECT_CHANGED,
  256. * subject: string
  257. * }}
  258. */
  259. export function conferenceSubjectChanged(subject: string) {
  260. return {
  261. type: CONFERENCE_SUBJECT_CHANGED,
  262. subject
  263. };
  264. }
  265. /**
  266. * Adds any existing local tracks to a specific conference before the conference
  267. * is joined. Then signals the intention of the application to have the local
  268. * participant join the specified conference.
  269. *
  270. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  271. * the local participant will (try to) join.
  272. * @returns {Function}
  273. */
  274. function _conferenceWillJoin(conference: Object) {
  275. return (dispatch: Dispatch<any>, getState: Function) => {
  276. const localTracks
  277. = getLocalTracks(getState()['features/base/tracks'])
  278. .map(t => t.jitsiTrack);
  279. if (localTracks.length) {
  280. _addLocalTracksToConference(conference, localTracks);
  281. }
  282. dispatch(conferenceWillJoin(conference));
  283. };
  284. }
  285. /**
  286. * Signals the intention of the application to have the local participant
  287. * join the specified conference.
  288. *
  289. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  290. * the local participant will (try to) join.
  291. * @returns {{
  292. * type: CONFERENCE_WILL_JOIN,
  293. * conference: JitsiConference
  294. * }}
  295. */
  296. export function conferenceWillJoin(conference: Object) {
  297. return {
  298. type: CONFERENCE_WILL_JOIN,
  299. conference
  300. };
  301. }
  302. /**
  303. * Signals the intention of the application to have the local participant leave
  304. * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
  305. * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
  306. * lib-jitsi-meet and not the application.
  307. *
  308. * @param {JitsiConference} conference - The JitsiConference instance which will
  309. * be left by the local participant.
  310. * @returns {{
  311. * type: CONFERENCE_LEFT,
  312. * conference: JitsiConference
  313. * }}
  314. */
  315. export function conferenceWillLeave(conference: Object) {
  316. return {
  317. type: CONFERENCE_WILL_LEAVE,
  318. conference
  319. };
  320. }
  321. /**
  322. * Initializes a new conference.
  323. *
  324. * @returns {Function}
  325. */
  326. export function createConference() {
  327. return (dispatch: Function, getState: Function) => {
  328. const state = getState();
  329. const { connection, locationURL } = state['features/base/connection'];
  330. if (!connection) {
  331. throw new Error('Cannot create a conference without a connection!');
  332. }
  333. const { password, room } = state['features/base/conference'];
  334. if (!room) {
  335. throw new Error('Cannot join a conference without a room name!');
  336. }
  337. const conference
  338. = connection.initJitsiConference(
  339. // XXX Lib-jitsi-meet does not accept uppercase letters.
  340. room.toLowerCase(), {
  341. ...state['features/base/config'],
  342. applicationName: getName(),
  343. getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats
  344. });
  345. connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;
  346. conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
  347. dispatch(_conferenceWillJoin(conference));
  348. _addConferenceListeners(conference, dispatch);
  349. sendLocalParticipant(state, conference);
  350. conference.join(password);
  351. };
  352. }
  353. /**
  354. * Will try to join the conference again in case it failed earlier with
  355. * {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
  356. * did not allow to create new room from anonymous domain, but it can be tried
  357. * again later in case authenticated user created it in the meantime.
  358. *
  359. * @returns {Function}
  360. */
  361. export function checkIfCanJoin() {
  362. return (dispatch: Function, getState: Function) => {
  363. const { authRequired, password }
  364. = getState()['features/base/conference'];
  365. authRequired && dispatch(_conferenceWillJoin(authRequired));
  366. authRequired && authRequired.join(password);
  367. };
  368. }
  369. /**
  370. * Signals the data channel with the bridge has successfully opened.
  371. *
  372. * @returns {{
  373. * type: DATA_CHANNEL_OPENED
  374. * }}
  375. */
  376. export function dataChannelOpened() {
  377. return {
  378. type: DATA_CHANNEL_OPENED
  379. };
  380. }
  381. /**
  382. * Signals that we've been kicked out of the conference.
  383. *
  384. * @param {JitsiConference} conference - The {@link JitsiConference} instance
  385. * for which the event is being signaled.
  386. * @returns {{
  387. * type: KICKED_OUT,
  388. * conference: JitsiConference
  389. * }}
  390. */
  391. export function kickedOut(conference: Object) {
  392. return {
  393. type: KICKED_OUT,
  394. conference
  395. };
  396. }
  397. /**
  398. * Signals that the lock state of a specific JitsiConference changed.
  399. *
  400. * @param {JitsiConference} conference - The JitsiConference which had its lock
  401. * state changed.
  402. * @param {boolean} locked - If the specified conference became locked, true;
  403. * otherwise, false.
  404. * @returns {{
  405. * type: LOCK_STATE_CHANGED,
  406. * conference: JitsiConference,
  407. * locked: boolean
  408. * }}
  409. */
  410. export function lockStateChanged(conference: Object, locked: boolean) {
  411. return {
  412. type: LOCK_STATE_CHANGED,
  413. conference,
  414. locked
  415. };
  416. }
  417. /**
  418. * Updates the known state of start muted policies.
  419. *
  420. * @param {boolean} audioMuted - Whether or not members will join the conference
  421. * as audio muted.
  422. * @param {boolean} videoMuted - Whether or not members will join the conference
  423. * as video muted.
  424. * @returns {{
  425. * type: SET_START_MUTED_POLICY,
  426. * startAudioMutedPolicy: boolean,
  427. * startVideoMutedPolicy: boolean
  428. * }}
  429. */
  430. export function onStartMutedPolicyChanged(
  431. audioMuted: boolean, videoMuted: boolean) {
  432. return {
  433. type: SET_START_MUTED_POLICY,
  434. startAudioMutedPolicy: audioMuted,
  435. startVideoMutedPolicy: videoMuted
  436. };
  437. }
  438. /**
  439. * Sets whether or not peer2peer is currently enabled.
  440. *
  441. * @param {boolean} p2p - Whether or not peer2peer is currently active.
  442. * @returns {{
  443. * type: P2P_STATUS_CHANGED,
  444. * p2p: boolean
  445. * }}
  446. */
  447. export function p2pStatusChanged(p2p: boolean) {
  448. return {
  449. type: P2P_STATUS_CHANGED,
  450. p2p
  451. };
  452. }
  453. /**
  454. * Sets the audio-only flag for the current JitsiConference.
  455. *
  456. * @param {boolean} audioOnly - True if the conference should be audio only;
  457. * false, otherwise.
  458. * @param {boolean} ensureVideoTrack - Define if conference should ensure
  459. * to create a video track.
  460. * @returns {{
  461. * type: SET_AUDIO_ONLY,
  462. * audioOnly: boolean,
  463. * ensureVideoTrack: boolean
  464. * }}
  465. */
  466. export function setAudioOnly(
  467. audioOnly: boolean,
  468. ensureVideoTrack: boolean = false) {
  469. return {
  470. type: SET_AUDIO_ONLY,
  471. audioOnly,
  472. ensureVideoTrack
  473. };
  474. }
  475. /**
  476. * Sets the flag for indicating if desktop sharing is enabled.
  477. *
  478. * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled.
  479. * @returns {{
  480. * type: SET_DESKTOP_SHARING_ENABLED,
  481. * desktopSharingEnabled: boolean
  482. * }}
  483. */
  484. export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) {
  485. return {
  486. type: SET_DESKTOP_SHARING_ENABLED,
  487. desktopSharingEnabled
  488. };
  489. }
  490. /**
  491. * Enables or disables the Follow Me feature.
  492. *
  493. * @param {boolean} enabled - Whether or not Follow Me should be enabled.
  494. * @returns {{
  495. * type: SET_FOLLOW_ME,
  496. * enabled: boolean
  497. * }}
  498. */
  499. export function setFollowMe(enabled: boolean) {
  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. }