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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { openDialog } from '../base/dialog';
  2. import {
  3. RESET_DESKTOP_SOURCES,
  4. UPDATE_DESKTOP_SOURCES
  5. } from './actionTypes';
  6. import { DesktopPicker } from './components';
  7. const logger = require('jitsi-meet-logger').getLogger(__filename);
  8. /**
  9. * Begins a request to get available DesktopCapturerSources.
  10. *
  11. * @param {Array} types - An array with DesktopCapturerSource type strings.
  12. * @param {Object} options - Additional configuration for getting a list of
  13. * sources.
  14. * @param {Object} options.thumbnailSize - The desired height and width of the
  15. * return native image object used for the preview image of the source.
  16. * @returns {Function}
  17. */
  18. export function obtainDesktopSources(types, options = {}) {
  19. const capturerOptions = {
  20. types
  21. };
  22. if (options.thumbnailSize) {
  23. capturerOptions.thumbnailSize = options.thumbnailSize;
  24. }
  25. return dispatch => {
  26. const { JitsiMeetElectron } = window;
  27. if (JitsiMeetElectron && JitsiMeetElectron.obtainDesktopStreams) {
  28. JitsiMeetElectron.obtainDesktopStreams(
  29. sources => dispatch(updateDesktopSources(sources)),
  30. error =>
  31. logger.error(
  32. `Error while obtaining desktop sources: ${error}`),
  33. capturerOptions
  34. );
  35. } else {
  36. logger.error(
  37. 'Called JitsiMeetElectron.obtainDesktopStreams'
  38. + ' but it is not defined');
  39. }
  40. };
  41. }
  42. /**
  43. * Signals to remove all stored DesktopCapturerSources.
  44. *
  45. * @returns {{
  46. * type: RESET_DESKTOP_SOURCES
  47. * }}
  48. */
  49. export function resetDesktopSources() {
  50. return {
  51. type: RESET_DESKTOP_SOURCES
  52. };
  53. }
  54. /**
  55. * Signals to open a dialog with the DesktopPicker component.
  56. *
  57. * @param {Object} options - Desktop sharing settings.
  58. * @param {Function} onSourceChoose - The callback to invoke when
  59. * a DesktopCapturerSource has been chosen.
  60. * @returns {Object}
  61. */
  62. export function showDesktopPicker(options, onSourceChoose) {
  63. return openDialog(DesktopPicker, {
  64. options,
  65. onSourceChoose
  66. });
  67. }
  68. /**
  69. * Signals new DesktopCapturerSources have been received.
  70. *
  71. * @param {Object} sources - Arrays with DesktopCapturerSources.
  72. * @returns {{
  73. * type: UPDATE_DESKTOP_SOURCES,
  74. * sources: Array
  75. * }}
  76. */
  77. export function updateDesktopSources(sources) {
  78. return {
  79. type: UPDATE_DESKTOP_SOURCES,
  80. sources
  81. };
  82. }