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.

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