You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

actions.js 21KB

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