Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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