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

actions.js 21KB

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