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

actions.js 21KB

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