Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. // @flow
  2. import {
  3. createStartMutedConfigurationEvent,
  4. sendAnalytics
  5. } from '../../analytics';
  6. import { getName } from '../../app';
  7. import { JitsiConferenceEvents } from '../lib-jitsi-meet';
  8. import { setAudioMuted, setVideoMuted } from '../media';
  9. import {
  10. dominantSpeakerChanged,
  11. getNormalizedDisplayName,
  12. participantConnectionStatusChanged,
  13. participantPresenceChanged,
  14. participantRoleChanged,
  15. participantUpdated
  16. } from '../participants';
  17. import { endpointMessageReceived } from '../../subtitles';
  18. import { getLocalTracks, trackAdded, trackRemoved } from '../tracks';
  19. import { getJitsiMeetGlobalNS } from '../util';
  20. import {
  21. AUTH_STATUS_CHANGED,
  22. CONFERENCE_FAILED,
  23. CONFERENCE_JOINED,
  24. CONFERENCE_LEFT,
  25. CONFERENCE_SUBJECT_CHANGED,
  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_PENDING_SUBJECT_CHANGE,
  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. * Signals that the conference subject has been changed.
  249. *
  250. * @param {string} subject - The new subject.
  251. * @returns {{
  252. * type: CONFERENCE_SUBJECT_CHANGED,
  253. * subject: string
  254. * }}
  255. */
  256. export function conferenceSubjectChanged(subject: string) {
  257. return {
  258. type: CONFERENCE_SUBJECT_CHANGED,
  259. subject
  260. };
  261. }
  262. /**
  263. * Adds any existing local tracks to a specific conference before the conference
  264. * is joined. Then signals the intention of the application to have the local
  265. * participant join the specified conference.
  266. *
  267. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  268. * the local participant will (try to) join.
  269. * @returns {Function}
  270. */
  271. function _conferenceWillJoin(conference: Object) {
  272. return (dispatch: Dispatch<any>, getState: Function) => {
  273. const localTracks
  274. = getLocalTracks(getState()['features/base/tracks'])
  275. .map(t => t.jitsiTrack);
  276. if (localTracks.length) {
  277. _addLocalTracksToConference(conference, localTracks);
  278. }
  279. dispatch(conferenceWillJoin(conference));
  280. };
  281. }
  282. /**
  283. * Signals the intention of the application to have the local participant
  284. * join the specified conference.
  285. *
  286. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  287. * the local participant will (try to) join.
  288. * @returns {{
  289. * type: CONFERENCE_WILL_JOIN,
  290. * conference: JitsiConference
  291. * }}
  292. */
  293. export function conferenceWillJoin(conference: Object) {
  294. return {
  295. type: CONFERENCE_WILL_JOIN,
  296. conference
  297. };
  298. }
  299. /**
  300. * Signals the intention of the application to have the local participant leave
  301. * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
  302. * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
  303. * lib-jitsi-meet and not the application.
  304. *
  305. * @param {JitsiConference} conference - The JitsiConference instance which will
  306. * be left by the local participant.
  307. * @returns {{
  308. * type: CONFERENCE_LEFT,
  309. * conference: JitsiConference
  310. * }}
  311. */
  312. export function conferenceWillLeave(conference: Object) {
  313. return {
  314. type: CONFERENCE_WILL_LEAVE,
  315. conference
  316. };
  317. }
  318. /**
  319. * Initializes a new conference.
  320. *
  321. * @returns {Function}
  322. */
  323. export function createConference() {
  324. return (dispatch: Function, getState: Function) => {
  325. const state = getState();
  326. const { connection, locationURL } = state['features/base/connection'];
  327. if (!connection) {
  328. throw new Error('Cannot create a conference without a connection!');
  329. }
  330. const { password, room } = state['features/base/conference'];
  331. if (!room) {
  332. throw new Error('Cannot join a conference without a room name!');
  333. }
  334. const conference
  335. = connection.initJitsiConference(
  336. // XXX Lib-jitsi-meet does not accept uppercase letters.
  337. room.toLowerCase(), {
  338. ...state['features/base/config'],
  339. applicationName: getName(),
  340. getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats
  341. });
  342. conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
  343. dispatch(_conferenceWillJoin(conference));
  344. _addConferenceListeners(conference, dispatch);
  345. sendLocalParticipant(state, conference);
  346. conference.join(password);
  347. };
  348. }
  349. /**
  350. * Will try to join the conference again in case it failed earlier with
  351. * {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
  352. * did not allow to create new room from anonymous domain, but it can be tried
  353. * again later in case authenticated user created it in the meantime.
  354. *
  355. * @returns {Function}
  356. */
  357. export function checkIfCanJoin() {
  358. return (dispatch: Function, getState: Function) => {
  359. const { authRequired, password }
  360. = getState()['features/base/conference'];
  361. authRequired && dispatch(_conferenceWillJoin(authRequired));
  362. authRequired && authRequired.join(password);
  363. };
  364. }
  365. /**
  366. * Signals the data channel with the bridge has successfully opened.
  367. *
  368. * @returns {{
  369. * type: DATA_CHANNEL_OPENED
  370. * }}
  371. */
  372. export function dataChannelOpened() {
  373. return {
  374. type: DATA_CHANNEL_OPENED
  375. };
  376. }
  377. /**
  378. * Signals that we've been kicked out of the conference.
  379. *
  380. * @param {JitsiConference} conference - The {@link JitsiConference} instance
  381. * for which the event is being signaled.
  382. * @returns {{
  383. * type: KICKED_OUT,
  384. * conference: JitsiConference
  385. * }}
  386. */
  387. export function kickedOut(conference: Object) {
  388. return {
  389. type: KICKED_OUT,
  390. conference
  391. };
  392. }
  393. /**
  394. * Signals that the lock state of a specific JitsiConference changed.
  395. *
  396. * @param {JitsiConference} conference - The JitsiConference which had its lock
  397. * state changed.
  398. * @param {boolean} locked - If the specified conference became locked, true;
  399. * otherwise, false.
  400. * @returns {{
  401. * type: LOCK_STATE_CHANGED,
  402. * conference: JitsiConference,
  403. * locked: boolean
  404. * }}
  405. */
  406. export function lockStateChanged(conference: Object, locked: boolean) {
  407. return {
  408. type: LOCK_STATE_CHANGED,
  409. conference,
  410. locked
  411. };
  412. }
  413. /**
  414. * Updates the known state of start muted policies.
  415. *
  416. * @param {boolean} audioMuted - Whether or not members will join the conference
  417. * as audio muted.
  418. * @param {boolean} videoMuted - Whether or not members will join the conference
  419. * as video muted.
  420. * @returns {{
  421. * type: SET_START_MUTED_POLICY,
  422. * startAudioMutedPolicy: boolean,
  423. * startVideoMutedPolicy: boolean
  424. * }}
  425. */
  426. export function onStartMutedPolicyChanged(
  427. audioMuted: boolean, videoMuted: boolean) {
  428. return {
  429. type: SET_START_MUTED_POLICY,
  430. startAudioMutedPolicy: audioMuted,
  431. startVideoMutedPolicy: videoMuted
  432. };
  433. }
  434. /**
  435. * Sets whether or not peer2peer is currently enabled.
  436. *
  437. * @param {boolean} p2p - Whether or not peer2peer is currently active.
  438. * @returns {{
  439. * type: P2P_STATUS_CHANGED,
  440. * p2p: boolean
  441. * }}
  442. */
  443. export function p2pStatusChanged(p2p: boolean) {
  444. return {
  445. type: P2P_STATUS_CHANGED,
  446. p2p
  447. };
  448. }
  449. /**
  450. * Sets the audio-only flag for the current JitsiConference.
  451. *
  452. * @param {boolean} audioOnly - True if the conference should be audio only;
  453. * false, otherwise.
  454. * @param {boolean} ensureVideoTrack - Define if conference should ensure
  455. * to create a video track.
  456. * @returns {{
  457. * type: SET_AUDIO_ONLY,
  458. * audioOnly: boolean,
  459. * ensureVideoTrack: boolean
  460. * }}
  461. */
  462. export function setAudioOnly(
  463. audioOnly: boolean,
  464. ensureVideoTrack: boolean = false) {
  465. return {
  466. type: SET_AUDIO_ONLY,
  467. audioOnly,
  468. ensureVideoTrack
  469. };
  470. }
  471. /**
  472. * Sets the flag for indicating if desktop sharing is enabled.
  473. *
  474. * @param {boolean} desktopSharingEnabled - True if desktop sharing is enabled.
  475. * @returns {{
  476. * type: SET_DESKTOP_SHARING_ENABLED,
  477. * desktopSharingEnabled: boolean
  478. * }}
  479. */
  480. export function setDesktopSharingEnabled(desktopSharingEnabled: boolean) {
  481. return {
  482. type: SET_DESKTOP_SHARING_ENABLED,
  483. desktopSharingEnabled
  484. };
  485. }
  486. /**
  487. * Enables or disables the Follow Me feature.
  488. *
  489. * @param {boolean} enabled - Whether or not Follow Me should be enabled.
  490. * @returns {{
  491. * type: SET_FOLLOW_ME,
  492. * enabled: boolean
  493. * }}
  494. */
  495. export function setFollowMe(enabled: boolean) {
  496. return {
  497. type: SET_FOLLOW_ME,
  498. enabled
  499. };
  500. }
  501. /**
  502. * Sets the video channel's last N (value) of the current conference. A value of
  503. * undefined shall be used to reset it to the default value.
  504. *
  505. * @param {(number|undefined)} lastN - The last N value to be set.
  506. * @returns {Function}
  507. */
  508. export function setLastN(lastN: ?number) {
  509. return (dispatch: Dispatch<any>, getState: Function) => {
  510. if (typeof lastN === 'undefined') {
  511. const config = getState()['features/base/config'];
  512. /* eslint-disable no-param-reassign */
  513. lastN = config.channelLastN;
  514. if (typeof lastN === 'undefined') {
  515. lastN = -1;
  516. }
  517. /* eslint-enable no-param-reassign */
  518. }
  519. dispatch({
  520. type: SET_LASTN,
  521. lastN
  522. });
  523. };
  524. }
  525. /**
  526. * Sets the max frame height that should be received from remote videos.
  527. *
  528. * @param {number} maxReceiverVideoQuality - The max video frame height to
  529. * receive.
  530. * @returns {{
  531. * type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  532. * maxReceiverVideoQuality: number
  533. * }}
  534. */
  535. export function setMaxReceiverVideoQuality(maxReceiverVideoQuality: number) {
  536. return {
  537. type: SET_MAX_RECEIVER_VIDEO_QUALITY,
  538. maxReceiverVideoQuality
  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. // Make sure that the action will set a password for a conference
  561. // that the application wants joined.
  562. if (state.passwordRequired === conference) {
  563. dispatch({
  564. type: SET_PASSWORD,
  565. conference,
  566. method,
  567. password
  568. });
  569. // Join the conference with the newly-set password.
  570. // Make sure that the action did set the password.
  571. state = getState()['features/base/conference'];
  572. if (state.password === password
  573. && !state.passwordRequired
  574. // Make sure that the application still wants the
  575. // conference joined.
  576. && !state.conference) {
  577. method.call(conference, password);
  578. }
  579. }
  580. break;
  581. }
  582. case conference.lock: {
  583. const state = getState()['features/base/conference'];
  584. if (state.conference === conference) {
  585. return (
  586. method.call(conference, password)
  587. .then(() => dispatch({
  588. type: SET_PASSWORD,
  589. conference,
  590. method,
  591. password
  592. }))
  593. .catch(error => dispatch({
  594. type: SET_PASSWORD_FAILED,
  595. error
  596. }))
  597. );
  598. }
  599. return Promise.reject();
  600. }
  601. }
  602. };
  603. }
  604. /**
  605. * Sets the max frame height the user prefers to receive from remote participant
  606. * videos.
  607. *
  608. * @param {number} preferredReceiverVideoQuality - The max video resolution to
  609. * receive.
  610. * @returns {{
  611. * type: SET_PREFERRED_RECEIVER_VIDEO_QUALITY,
  612. * preferredReceiverVideoQuality: number
  613. * }}
  614. */
  615. export function setPreferredReceiverVideoQuality(
  616. preferredReceiverVideoQuality: number) {
  617. return {
  618. type: SET_PREFERRED_RECEIVER_VIDEO_QUALITY,
  619. preferredReceiverVideoQuality
  620. };
  621. }
  622. /**
  623. * Sets (the name of) the room of the conference to be joined.
  624. *
  625. * @param {(string|undefined)} room - The name of the room of the conference to
  626. * be joined.
  627. * @returns {{
  628. * type: SET_ROOM,
  629. * room: string
  630. * }}
  631. */
  632. export function setRoom(room: ?string) {
  633. return {
  634. type: SET_ROOM,
  635. room
  636. };
  637. }
  638. /**
  639. * Sets whether or not members should join audio and/or video muted.
  640. *
  641. * @param {boolean} startAudioMuted - Whether or not members will join the
  642. * conference as audio muted.
  643. * @param {boolean} startVideoMuted - Whether or not members will join the
  644. * conference as video muted.
  645. * @returns {Function}
  646. */
  647. export function setStartMutedPolicy(
  648. startAudioMuted: boolean, startVideoMuted: boolean) {
  649. return (dispatch: Dispatch<any>, getState: Function) => {
  650. const conference = getCurrentConference(getState());
  651. conference && conference.setStartMutedPolicy({
  652. audio: startAudioMuted,
  653. video: startVideoMuted
  654. });
  655. return dispatch(
  656. onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));
  657. };
  658. }
  659. /**
  660. * Toggles the audio-only flag for the current JitsiConference.
  661. *
  662. * @returns {Function}
  663. */
  664. export function toggleAudioOnly() {
  665. return (dispatch: Dispatch<any>, getState: Function) => {
  666. const { audioOnly } = getState()['features/base/conference'];
  667. return dispatch(setAudioOnly(!audioOnly, true));
  668. };
  669. }
  670. /**
  671. * Changing conference subject.
  672. *
  673. * @param {string} subject - The new subject.
  674. * @returns {void}
  675. */
  676. export function setSubject(subject: string = '') {
  677. return (dispatch: Dispatch<any>, getState: Function) => {
  678. const { conference } = getState()['features/base/conference'];
  679. if (conference) {
  680. dispatch({
  681. type: SET_PENDING_SUBJECT_CHANGE,
  682. subject: undefined
  683. });
  684. conference.setSubject(subject);
  685. } else {
  686. dispatch({
  687. type: SET_PENDING_SUBJECT_CHANGE,
  688. subject
  689. });
  690. }
  691. };
  692. }