Procházet zdrojové kódy

feat(remotecontrol): Make sure the receiver is always sharing entire screen

j8
hristoterezov před 7 roky
rodič
revize
dc8198100b

+ 10
- 3
conference.js Zobrazit soubor

@@ -87,8 +87,8 @@ import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
87 87
  * lib-jitsi-meet to detect and invoke
88 88
  */
89 89
 window.JitsiMeetScreenObtainer = {
90
-    openDesktopPicker(onSourceChoose) {
91
-        APP.store.dispatch(showDesktopPicker(onSourceChoose));
90
+    openDesktopPicker(options, onSourceChoose) {
91
+        APP.store.dispatch(showDesktopPicker(options, onSourceChoose));
92 92
     }
93 93
 };
94 94
 
@@ -341,6 +341,7 @@ function createLocalTracks(options, checkForPermissionPrompt) {
341 341
         .createLocalTracks({
342 342
             // copy array to avoid mutations inside library
343 343
             devices: options.devices.slice(0),
344
+            desktopSharingSources: options.desktopSharingSources,
344 345
             resolution: config.resolution,
345 346
             cameraDeviceId: typeof options.cameraDeviceId === 'undefined' ||
346 347
                     options.cameraDeviceId === null
@@ -1108,9 +1109,14 @@ export default {
1108 1109
     /**
1109 1110
      * Toggles between screensharing and camera video.
1110 1111
      * @param {boolean} [shareScreen]
1112
+     * @param {Object} [options] - Screen sharing options that will be passed to
1113
+     * createLocalTracks.
1114
+     * @param {Array<string>} [options.desktopSharingSources] - Array with the
1115
+     * sources that have to be displayed in the desktop picker window ('screen',
1116
+     * 'window', etc.).
1111 1117
      * @return {Promise.<T>}
1112 1118
      */
1113
-    toggleScreenSharing(shareScreen = !this.isSharingScreen) {
1119
+    toggleScreenSharing(shareScreen = !this.isSharingScreen, options = {}) {
1114 1120
         if (this.videoSwitchInProgress) {
1115 1121
             return Promise.reject('Switch in progress.');
1116 1122
         }
@@ -1130,6 +1136,7 @@ export default {
1130 1136
 
1131 1137
         if (shareScreen) {
1132 1138
             return createLocalTracks({
1139
+                desktopSharingSources: options.desktopSharingSources,
1133 1140
                 devices: ['desktop'],
1134 1141
                 desktopSharingExtensionExternalInstallation: {
1135 1142
                     interval: 500,

+ 1
- 0
lang/main.json Zobrazit soubor

@@ -340,6 +340,7 @@
340 340
         "remoteControlDeniedMessage": "__user__ rejected your remote control request!",
341 341
         "remoteControlAllowedMessage": "__user__ accepted your remote control request!",
342 342
         "remoteControlErrorMessage": "An error occurred while trying to request remote control permissions from __user__!",
343
+        "startRemoteControlErrorMessage": "An error occurred while trying to start the remote control session!",
343 344
         "remoteControlStopMessage": "The remote control session ended!",
344 345
         "close": "Close",
345 346
         "shareYourScreen": "Share your screen",

+ 16
- 5
modules/remotecontrol/Receiver.js Zobrazit soubor

@@ -214,10 +214,15 @@ export default class Receiver extends RemoteControlParticipant {
214 214
 
215 215
         let promise;
216 216
 
217
-        if (APP.conference.isSharingScreen) {
217
+        if (APP.conference.isSharingScreen
218
+                && APP.conference.getDesktopSharingSourceType() === 'screen') {
218 219
             promise = this._sendStartRequest();
219 220
         } else {
220
-            promise = APP.conference.toggleScreenSharing()
221
+            promise = APP.conference.toggleScreenSharing(
222
+                true,
223
+                {
224
+                    desktopSharingSources: [ 'screen' ]
225
+                })
221 226
                 .then(() => this._sendStartRequest());
222 227
         }
223 228
 
@@ -228,14 +233,20 @@ export default class Receiver extends RemoteControlParticipant {
228 233
                     action: PERMISSIONS_ACTIONS.grant
229 234
                 })
230 235
             )
231
-            .catch(() => {
236
+            .catch(error => {
237
+                logger.error(error);
238
+
232 239
                 this.sendRemoteControlEndpointMessage(userId, {
233 240
                     type: EVENTS.permissions,
234 241
                     action: PERMISSIONS_ACTIONS.error
235 242
                 });
236 243
 
237
-                // FIXME: show err msg
238
-                this._stop();
244
+                APP.UI.messageHandler.openMessageDialog(
245
+                    'dialog.remoteControlTitle',
246
+                    'dialog.startRemoteControlErrorMessage'
247
+                );
248
+
249
+                this._stop(true);
239 250
             });
240 251
     }
241 252
 

+ 3
- 1
react/features/desktop-picker/actions.js Zobrazit soubor

@@ -62,12 +62,14 @@ export function resetDesktopSources() {
62 62
 /**
63 63
  * Signals to open a dialog with the DesktopPicker component.
64 64
  *
65
+ * @param {Object} options - Desktop sharing settings.
65 66
  * @param {Function} onSourceChoose - The callback to invoke when
66 67
  * a DesktopCapturerSource has been chosen.
67 68
  * @returns {Object}
68 69
  */
69
-export function showDesktopPicker(onSourceChoose) {
70
+export function showDesktopPicker(options, onSourceChoose) {
70 71
     return openDialog(DesktopPicker, {
72
+        options,
71 73
         onSourceChoose
72 74
     });
73 75
 }

+ 52
- 23
react/features/desktop-picker/components/DesktopPicker.js Zobrazit soubor

@@ -1,5 +1,3 @@
1
-/* global config */
2
-
3 1
 import Tabs from '@atlaskit/tabs';
4 2
 import React, { Component } from 'react';
5 3
 import { connect } from 'react-redux';
@@ -33,12 +31,7 @@ const TAB_CONFIGURATIONS = [
33 31
         type: 'window'
34 32
     }
35 33
 ];
36
-const CONFIGURED_TYPES = config.desktopSharingChromeSources || [];
37 34
 const VALID_TYPES = TAB_CONFIGURATIONS.map(c => c.type);
38
-const TABS_TO_POPULATE
39
-    = TAB_CONFIGURATIONS.filter(
40
-        c => CONFIGURED_TYPES.includes(c.type) && VALID_TYPES.includes(c.type));
41
-const TYPES_TO_FETCH = TABS_TO_POPULATE.map(c => c.type);
42 35
 
43 36
 /**
44 37
  * React component for DesktopPicker.
@@ -63,6 +56,11 @@ class DesktopPicker extends Component {
63 56
          */
64 57
         onSourceChoose: React.PropTypes.func,
65 58
 
59
+        /**
60
+         * An object with options related to desktop sharing.
61
+         */
62
+        options: React.PropTypes.object,
63
+
66 64
         /**
67 65
          * An object with arrays of DesktopCapturerSources. The key should be
68 66
          * the source type.
@@ -85,7 +83,9 @@ class DesktopPicker extends Component {
85 83
         super(props);
86 84
 
87 85
         this.state = {
88
-            selectedSource: {}
86
+            selectedSource: {},
87
+            tabsToPopulate: [],
88
+            typesToFetch: []
89 89
         };
90 90
 
91 91
         this._poller = null;
@@ -102,6 +102,10 @@ class DesktopPicker extends Component {
102 102
      * @inheritdoc
103 103
      */
104 104
     componentWillMount() {
105
+        const options = this.props.options || {};
106
+
107
+        this._onSourceTypesConfigChanged(
108
+            options.desktopSharingSources);
105 109
         this._updateSources();
106 110
         this._startPolling();
107 111
     }
@@ -125,6 +129,11 @@ class DesktopPicker extends Component {
125 129
                 }
126 130
             });
127 131
         }
132
+
133
+        const options = this.props.options || {};
134
+
135
+        this._onSourceTypesConfigChanged(
136
+            options.desktopSharingSources);
128 137
     }
129 138
 
130 139
     /**
@@ -166,7 +175,7 @@ class DesktopPicker extends Component {
166 175
      * the onSourceChoose callback.
167 176
      * @returns {void}
168 177
      */
169
-    _onCloseModal(id, type) {
178
+    _onCloseModal(id = '', type) {
170 179
         this.props.onSourceChoose(id, type);
171 180
         this.props.dispatch(hideDialog());
172 181
     }
@@ -209,19 +218,20 @@ class DesktopPicker extends Component {
209 218
         const { selectedSource } = this.state;
210 219
         const { sources, t } = this.props;
211 220
         const tabs
212
-            = TABS_TO_POPULATE.map(({ defaultSelected, label, type }) => {
213
-                return {
214
-                    content: <DesktopPickerPane
215
-                        key = { type }
216
-                        onClick = { this._onPreviewClick }
217
-                        onDoubleClick = { this._onCloseModal }
218
-                        selectedSourceId = { selectedSource.id }
219
-                        sources = { sources[type] || [] }
220
-                        type = { type } />,
221
-                    defaultSelected,
222
-                    label: t(label)
223
-                };
224
-            });
221
+            = this.state.tabsToPopulate.map(
222
+                ({ defaultSelected, label, type }) => {
223
+                    return {
224
+                        content: <DesktopPickerPane
225
+                            key = { type }
226
+                            onClick = { this._onPreviewClick }
227
+                            onDoubleClick = { this._onCloseModal }
228
+                            selectedSourceId = { selectedSource.id }
229
+                            sources = { sources[type] || [] }
230
+                            type = { type } />,
231
+                        defaultSelected,
232
+                        label: t(label)
233
+                    };
234
+                });
225 235
 
226 236
         return <Tabs tabs = { tabs } />;
227 237
     }
@@ -248,6 +258,25 @@ class DesktopPicker extends Component {
248 258
         this._poller = null;
249 259
     }
250 260
 
261
+    /**
262
+     * Handles changing of allowed desktop sharing source types.
263
+     *
264
+     * @param {Array<string>} desktopSharingSourceTypes - The types that will be
265
+     * fetched and displayed.
266
+     * @returns {void}
267
+     */
268
+    _onSourceTypesConfigChanged(desktopSharingSourceTypes = []) {
269
+        const tabsToPopulate = TAB_CONFIGURATIONS.filter(
270
+            c => desktopSharingSourceTypes.includes(c.type)
271
+                && VALID_TYPES.includes(c.type)
272
+        );
273
+
274
+        this.setState({
275
+            tabsToPopulate,
276
+            typesToFetch: tabsToPopulate.map(c => c.type)
277
+        });
278
+    }
279
+
251 280
     /**
252 281
      * Dispatches an action to get currently available DesktopCapturerSources.
253 282
      *
@@ -256,7 +285,7 @@ class DesktopPicker extends Component {
256 285
      */
257 286
     _updateSources() {
258 287
         this.props.dispatch(obtainDesktopSources(
259
-            TYPES_TO_FETCH,
288
+            this.state.typesToFetch,
260 289
             {
261 290
                 THUMBNAIL_SIZE
262 291
             }

+ 2
- 1
react/features/remote-control/components/RemoteControlAuthorizationDialog.js Zobrazit soubor

@@ -94,7 +94,8 @@ class RemoteControlAuthorizationDialog extends Component {
94 94
     _getAdditionalMessage() {
95 95
         // FIXME: Once we have this information in redux we should
96 96
         // start getting it from there.
97
-        if (APP.conference.isSharingScreen) {
97
+        if (APP.conference.isSharingScreen
98
+                && APP.conference.getDesktopSharingSourceType() === 'screen') {
98 99
             return null;
99 100
         }
100 101
 

Načítá se…
Zrušit
Uložit