Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

actions.js 22KB

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