Selaa lähdekoodia

fix(frame_api): toggle SS race condition

If toggle SS is executed too early and lib-jitsi-meet is not yet
initialized toggle SS will fail. Now we are storing the whether
SS is on or off and when lib-jitsi-meet is ready we are starting
SS if needed.
j8
hristoterezov 8 vuotta sitten
vanhempi
commit
e7a3ee477d
3 muutettua tiedostoa jossa 56 lisäystä ja 4 poistoa
  1. 7
    0
      ConferenceEvents.js
  2. 3
    0
      conference.js
  3. 46
    4
      modules/API/API.js

+ 7
- 0
ConferenceEvents.js Näytä tiedosto

2
  * Notifies interested parties that hangup procedure will start.
2
  * Notifies interested parties that hangup procedure will start.
3
  */
3
  */
4
 export const BEFORE_HANGUP = "conference.before_hangup";
4
 export const BEFORE_HANGUP = "conference.before_hangup";
5
+
6
+/**
7
+ * Notifies interested parties that desktop sharing enable/disable state is
8
+ * changed.
9
+ */
10
+export const DESKTOP_SHARING_ENABLED_CHANGED
11
+    = "conference.desktop_sharing_enabled_changed";

+ 3
- 0
conference.js Näytä tiedosto

588
                 APP.connection = connection = con;
588
                 APP.connection = connection = con;
589
                 this.isDesktopSharingEnabled =
589
                 this.isDesktopSharingEnabled =
590
                     JitsiMeetJS.isDesktopSharingEnabled();
590
                     JitsiMeetJS.isDesktopSharingEnabled();
591
+                eventEmitter.emit(
592
+                    JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
593
+                    this.isDesktopSharingEnabled);
591
 
594
 
592
                 APP.store.dispatch(showDesktopSharingButton());
595
                 APP.store.dispatch(showDesktopSharingButton());
593
 
596
 

+ 46
- 4
modules/API/API.js Näytä tiedosto

8
 
8
 
9
 import postisInit from 'postis';
9
 import postisInit from 'postis';
10
 
10
 
11
+import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
12
+
11
 /**
13
 /**
12
  * List of the available commands.
14
  * List of the available commands.
13
  * @type {{
15
  * @type {{
43
  */
45
  */
44
 let enabled = false;
46
 let enabled = false;
45
 
47
 
48
+/**
49
+ * The state of screen sharing(started/stopped) before the screen sharing is
50
+ * enabled and initialized.
51
+ * NOTE: This flag help us to cache the state and use it if toggle-share-screen
52
+ * was received before the initialization.
53
+ */
54
+let initialScreenSharingState = false;
55
+
56
+/**
57
+ * Executes on toggle-share-screen command.
58
+ */
59
+function toggleScreenSharing() {
60
+    if(!APP.conference.isDesktopSharingEnabled) {
61
+        initialScreenSharingState = !initialScreenSharingState;
62
+    } else {
63
+        APP.conference.toggleScreenSharing();
64
+    }
65
+}
66
+
46
 function initCommands() {
67
 function initCommands() {
47
     commands = {
68
     commands = {
48
         "display-name":
69
         "display-name":
52
         "toggle-film-strip": APP.UI.toggleFilmstrip,
73
         "toggle-film-strip": APP.UI.toggleFilmstrip,
53
         "toggle-chat": APP.UI.toggleChat,
74
         "toggle-chat": APP.UI.toggleChat,
54
         "toggle-contact-list": APP.UI.toggleContactList,
75
         "toggle-contact-list": APP.UI.toggleContactList,
55
-        "toggle-share-screen":
56
-            APP.conference.toggleScreenSharing.bind(APP.conference),
76
+        "toggle-share-screen": toggleScreenSharing,
57
         "video-hangup": () => APP.conference.hangup(),
77
         "video-hangup": () => APP.conference.hangup(),
58
         "email": APP.conference.changeLocalEmail,
78
         "email": APP.conference.changeLocalEmail,
59
         "avatar-url": APP.conference.changeLocalAvatarUrl,
79
         "avatar-url": APP.conference.changeLocalAvatarUrl,
97
     }
117
     }
98
 }
118
 }
99
 
119
 
120
+/**
121
+ * Listens for screen sharing enabled events and toggles the screen sharing if
122
+ * needed.
123
+ *
124
+ * @param {boolean} enabled - Current screen sharing enabled status.
125
+ * @returns {void}
126
+ */
127
+function onScreenSharingEnable(enabled = false) {
128
+    if(enabled && initialScreenSharingState) {
129
+        toggleScreenSharing();
130
+    }
131
+}
132
+
100
 class API {
133
 class API {
101
     /**
134
     /**
102
      * Constructs new instance
135
      * Constructs new instance
116
         if(!shouldBeEnabled() && !options.forceEnable)
149
         if(!shouldBeEnabled() && !options.forceEnable)
117
             return;
150
             return;
118
 
151
 
119
-        enabled = true;
152
+        if(!enabled) {
153
+            APP.conference.addListener(
154
+                JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
155
+                onScreenSharingEnable);
156
+            enabled = true;
157
+        }
120
 
158
 
121
         if(!postis) {
159
         if(!postis) {
122
             this._initPostis();
160
             this._initPostis();
233
      * Removes the listeners.
271
      * Removes the listeners.
234
      */
272
      */
235
     dispose () {
273
     dispose () {
236
-        if(enabled)
274
+        if(enabled) {
237
             postis.destroy();
275
             postis.destroy();
276
+            APP.conference.removeListener(
277
+                JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
278
+                onScreenSharingEnable);
279
+        }
238
     }
280
     }
239
 }
281
 }
240
 
282
 

Loading…
Peruuta
Tallenna