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

actions.js 21KB

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