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

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