Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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