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 22KB

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