@@ -21,7 +21,7 @@ import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
2121import dis from 'matrix-react-sdk/lib/dispatcher' ;
2222import { _t } from 'matrix-react-sdk/lib/languageHandler' ;
2323import Promise from 'bluebird' ;
24- import { remote , ipcRenderer } from 'electron' ;
24+ import { remote , ipcRenderer , desktopCapturer } from 'electron' ;
2525import rageshake from '../rageshake' ;
2626
2727remote . autoUpdater . on ( 'update-downloaded' , onUpdateDownloaded ) ;
@@ -207,4 +207,43 @@ export default class ElectronPlatform extends VectorBasePlatform {
207207 reload ( ) {
208208 remote . getCurrentWebContents ( ) . reload ( ) ;
209209 }
210+
211+ /* BEGIN copied and slightly-modified code
212+ * setupScreenSharingForIframe function from:
213+ * https://github.com/jitsi/jitsi-meet-electron-utils
214+ * Copied directly here to avoid the need for a native electron module for
215+ * 'just a bit of JavaScript'
216+ * NOTE: Apache v2.0 licensed
217+ */
218+ setupScreenSharingForIframe ( iframe : Object ) {
219+ iframe . contentWindow . JitsiMeetElectron = {
220+ /**
221+ * Get sources available for screensharing. The callback is invoked
222+ * with an array of DesktopCapturerSources.
223+ *
224+ * @param {Function } callback - The success callback.
225+ * @param {Function } errorCallback - The callback for errors.
226+ * @param {Object } options - Configuration for getting sources.
227+ * @param {Array } options.types - Specify the desktop source types
228+ * to get, with valid sources being "window" and "screen".
229+ * @param {Object } options.thumbnailSize - Specify how big the
230+ * preview images for the sources should be. The valid keys are
231+ * height and width, e.g. { height: number, width: number}. By
232+ * default electron will return images with height and width of
233+ * 150px.
234+ */
235+ obtainDesktopStreams ( callback , errorCallback , options = { } ) {
236+ desktopCapturer . getSources ( options ,
237+ ( error , sources ) => {
238+ if ( error ) {
239+ errorCallback ( error ) ;
240+ return ;
241+ }
242+
243+ callback ( sources ) ;
244+ } ) ;
245+ } ,
246+ } ;
247+ }
248+ /* END of copied and slightly-modified code */
210249}
0 commit comments