您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 22KB

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