|
@@ -1,27 +1,29 @@
|
1
|
|
-/*
|
2
|
|
- * Copyright @ 2015 Atlassian Pty Ltd
|
3
|
|
- *
|
4
|
|
- * Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
|
- * you may not use this file except in compliance with the License.
|
6
|
|
- * You may obtain a copy of the License at
|
7
|
|
- *
|
8
|
|
- * http://www.apache.org/licenses/LICENSE-2.0
|
9
|
|
- *
|
10
|
|
- * Unless required by applicable law or agreed to in writing, software
|
11
|
|
- * distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
|
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
|
- * See the License for the specific language governing permissions and
|
14
|
|
- * limitations under the License.
|
|
1
|
+/*
|
|
2
|
+ * Copyright @ 2015 Atlassian Pty Ltd
|
|
3
|
+ *
|
|
4
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+ * you may not use this file except in compliance with the License.
|
|
6
|
+ * You may obtain a copy of the License at
|
|
7
|
+ *
|
|
8
|
+ * http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+ *
|
|
10
|
+ * Unless required by applicable law or agreed to in writing, software
|
|
11
|
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+ * See the License for the specific language governing permissions and
|
|
14
|
+ * limitations under the License.
|
15
|
15
|
*/
|
16
|
16
|
|
17
|
17
|
import UIEvents from '../service/UI/UIEvents';
|
|
18
|
+import VideoLayout from './UI/videolayout/VideoLayout';
|
|
19
|
+import FilmStrip from './UI/videolayout/FilmStrip';
|
18
|
20
|
|
19
|
21
|
/**
|
20
|
22
|
* The (name of the) command which transports the state (represented by
|
21
|
23
|
* {State} for the local state at the time of this writing) of a {FollowMe}
|
22
|
24
|
* (instance) between participants.
|
23
|
25
|
*/
|
24
|
|
-/* private */ const _COMMAND = "follow-me";
|
|
26
|
+const _COMMAND = "follow-me";
|
25
|
27
|
|
26
|
28
|
/**
|
27
|
29
|
* Represents the set of {FollowMe}-related states (properties and their
|
|
@@ -29,7 +31,7 @@ import UIEvents from '../service/UI/UIEvents';
|
29
|
31
|
* will send {_COMMAND} whenever a property of {State} changes (if the local
|
30
|
32
|
* participant is in her right to issue such a command, of course).
|
31
|
33
|
*/
|
32
|
|
-/* private */ class State {
|
|
34
|
+class State {
|
33
|
35
|
/**
|
34
|
36
|
* Initializes a new {State} instance.
|
35
|
37
|
*
|
|
@@ -39,13 +41,13 @@ import UIEvents from '../service/UI/UIEvents';
|
39
|
41
|
* the property, the old value of the property before the change, and the
|
40
|
42
|
* new value of the property after the change.
|
41
|
43
|
*/
|
42
|
|
- /* public */ constructor (propertyChangeCallback) {
|
43
|
|
- /* private*/ this._propertyChangeCallback = propertyChangeCallback;
|
|
44
|
+ constructor (propertyChangeCallback) {
|
|
45
|
+ this._propertyChangeCallback = propertyChangeCallback;
|
44
|
46
|
}
|
45
|
47
|
|
46
|
|
- /* public */ get filmStripVisible () { return this._filmStripVisible; }
|
|
48
|
+ get filmStripVisible () { return this._filmStripVisible; }
|
47
|
49
|
|
48
|
|
- /* public */ set filmStripVisible (b) {
|
|
50
|
+ set filmStripVisible (b) {
|
49
|
51
|
var oldValue = this._filmStripVisible;
|
50
|
52
|
if (oldValue !== b) {
|
51
|
53
|
this._filmStripVisible = b;
|
|
@@ -53,6 +55,26 @@ import UIEvents from '../service/UI/UIEvents';
|
53
|
55
|
}
|
54
|
56
|
}
|
55
|
57
|
|
|
58
|
+ get nextOnStage() { return this._nextOnStage; }
|
|
59
|
+
|
|
60
|
+ set nextOnStage(id) {
|
|
61
|
+ var oldValue = this._nextOnStage;
|
|
62
|
+ if (oldValue !== id) {
|
|
63
|
+ this._nextOnStage = id;
|
|
64
|
+ this._firePropertyChange('nextOnStage', oldValue, id);
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ get sharedDocumentVisible () { return this._sharedDocumentVisible; }
|
|
69
|
+
|
|
70
|
+ set sharedDocumentVisible (b) {
|
|
71
|
+ var oldValue = this._sharedDocumentVisible;
|
|
72
|
+ if (oldValue !== b) {
|
|
73
|
+ this._sharedDocumentVisible = b;
|
|
74
|
+ this._firePropertyChange('sharedDocumentVisible', oldValue, b);
|
|
75
|
+ }
|
|
76
|
+ }
|
|
77
|
+
|
56
|
78
|
/**
|
57
|
79
|
* Invokes {_propertyChangeCallback} to notify it that {property} had its
|
58
|
80
|
* value changed from {oldValue} to {newValue}.
|
|
@@ -62,7 +84,7 @@ import UIEvents from '../service/UI/UIEvents';
|
62
|
84
|
* @param oldValue the value of {property} before the change
|
63
|
85
|
* @param newValue the value of {property} after the change
|
64
|
86
|
*/
|
65
|
|
- /* private */ _firePropertyChange (property, oldValue, newValue) {
|
|
87
|
+ _firePropertyChange (property, oldValue, newValue) {
|
66
|
88
|
var propertyChangeCallback = this._propertyChangeCallback;
|
67
|
89
|
if (propertyChangeCallback)
|
68
|
90
|
propertyChangeCallback(property, oldValue, newValue);
|
|
@@ -74,9 +96,9 @@ import UIEvents from '../service/UI/UIEvents';
|
74
|
96
|
* (partially) control the user experience/interface (e.g. film strip
|
75
|
97
|
* visibility) of (other) non-moderator particiapnts.
|
76
|
98
|
*
|
77
|
|
- * @author Lyubomir Marinov
|
|
99
|
+ * @author Lyubomir Marinov
|
78
|
100
|
*/
|
79
|
|
-/* public */ class FollowMe {
|
|
101
|
+class FollowMe {
|
80
|
102
|
/**
|
81
|
103
|
* Initializes a new {FollowMe} instance.
|
82
|
104
|
*
|
|
@@ -87,15 +109,14 @@ import UIEvents from '../service/UI/UIEvents';
|
87
|
109
|
* destination (model/state) to receive from the remote moderator if the
|
88
|
110
|
* local participant is not the moderator
|
89
|
111
|
*/
|
90
|
|
- /* public */ constructor (conference, UI) {
|
91
|
|
- /* private */ this._conference = conference;
|
92
|
|
- /* private */ this._UI = UI;
|
|
112
|
+ constructor (conference, UI) {
|
|
113
|
+ this._conference = conference;
|
|
114
|
+ this._UI = UI;
|
93
|
115
|
|
94
|
116
|
// The states of the local participant which are to be followed (by the
|
95
|
117
|
// remote participants when the local participant is in her right to
|
96
|
118
|
// issue such commands).
|
97
|
|
- /* private */ this._local
|
98
|
|
- = new State(this._localPropertyChange.bind(this));
|
|
119
|
+ this._local = new State(this._localPropertyChange.bind(this));
|
99
|
120
|
|
100
|
121
|
// Listen to "Follow Me" commands. I'm not sure whether a moderator can
|
101
|
122
|
// (in lib-jitsi-meet and/or Meet) become a non-moderator. If that's
|
|
@@ -104,18 +125,57 @@ import UIEvents from '../service/UI/UIEvents';
|
104
|
125
|
conference.commands.addCommandListener(
|
105
|
126
|
_COMMAND,
|
106
|
127
|
this._onFollowMeCommand.bind(this));
|
107
|
|
- // Listen to (user interface) states of the local participant which are
|
108
|
|
- // to be followed (by the remote participants). A non-moderator (very
|
109
|
|
- // likely) can become a moderator so it may be easiest to always track
|
110
|
|
- // the states of interest.
|
111
|
|
- UI.addListener(
|
112
|
|
- UIEvents.TOGGLED_FILM_STRIP,
|
113
|
|
- this._filmStripToggled.bind(this));
|
114
|
|
- // TODO Listen to changes in the moderator role of the local
|
115
|
|
- // participant. When the local participant is granted the moderator
|
116
|
|
- // role, it may need to start sending "Follow Me" commands. Obviously,
|
117
|
|
- // this depends on how we decide to enable the feature at runtime as
|
118
|
|
- // well.
|
|
128
|
+ }
|
|
129
|
+
|
|
130
|
+ /**
|
|
131
|
+ * Adds listeners for the UI states of the local participant which are
|
|
132
|
+ * to be followed (by the remote participants). A non-moderator (very
|
|
133
|
+ * likely) can become a moderator so it may be easiest to always track
|
|
134
|
+ * the states of interest.
|
|
135
|
+ * @private
|
|
136
|
+ */
|
|
137
|
+ _addFollowMeListeners () {
|
|
138
|
+ this.filmStripEventHandler = this._filmStripToggled.bind(this);
|
|
139
|
+ this._UI.addListener(UIEvents.TOGGLED_FILM_STRIP,
|
|
140
|
+ this.filmStripEventHandler);
|
|
141
|
+
|
|
142
|
+ var self = this;
|
|
143
|
+ this.pinnedEndpointEventHandler = function (smallVideo, isPinned) {
|
|
144
|
+ self._nextOnStage(smallVideo, isPinned);
|
|
145
|
+ };
|
|
146
|
+ this._UI.addListener(UIEvents.PINNED_ENDPOINT,
|
|
147
|
+ this.pinnedEndpointEventHandler);
|
|
148
|
+
|
|
149
|
+ this.sharedDocEventHandler = this._sharedDocumentToggled.bind(this);
|
|
150
|
+ this._UI.addListener( UIEvents.TOGGLED_SHARED_DOCUMENT,
|
|
151
|
+ this.sharedDocEventHandler);
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+ /**
|
|
155
|
+ * Removes all follow me listeners.
|
|
156
|
+ * @private
|
|
157
|
+ */
|
|
158
|
+ _removeFollowMeListeners () {
|
|
159
|
+ this._UI.removeListener(UIEvents.TOGGLED_FILM_STRIP,
|
|
160
|
+ this.filmStripEventHandler);
|
|
161
|
+ this._UI.removeListener(UIEvents.TOGGLED_SHARED_DOCUMENT,
|
|
162
|
+ this.sharedDocEventHandler);
|
|
163
|
+ this._UI.removeListener(UIEvents.PINNED_ENDPOINT,
|
|
164
|
+ this.pinnedEndpointEventHandler);
|
|
165
|
+ }
|
|
166
|
+
|
|
167
|
+ /**
|
|
168
|
+ * Enables or disabled the follow me functionality
|
|
169
|
+ *
|
|
170
|
+ * @param enable {true} to enable the follow me functionality, {false} -
|
|
171
|
+ * to disable it
|
|
172
|
+ */
|
|
173
|
+ enableFollowMe (enable) {
|
|
174
|
+ this.isEnabled = enable;
|
|
175
|
+ if (this.isEnabled)
|
|
176
|
+ this._addFollowMeListeners();
|
|
177
|
+ else
|
|
178
|
+ this._removeFollowMeListeners();
|
119
|
179
|
}
|
120
|
180
|
|
121
|
181
|
/**
|
|
@@ -125,11 +185,49 @@ import UIEvents from '../service/UI/UIEvents';
|
125
|
185
|
* @param filmStripVisible {Boolean} {true} if the film strip was shown (as
|
126
|
186
|
* a result of the toggle) or {false} if the film strip was hidden
|
127
|
187
|
*/
|
128
|
|
- /* private */ _filmStripToggled (filmStripVisible) {
|
|
188
|
+ _filmStripToggled (filmStripVisible) {
|
129
|
189
|
this._local.filmStripVisible = filmStripVisible;
|
130
|
190
|
}
|
131
|
191
|
|
132
|
|
- /* private */ _localPropertyChange (property, oldValue, newValue) {
|
|
192
|
+ /**
|
|
193
|
+ * Notifies this instance that the (visibility of the) shared document was
|
|
194
|
+ * toggled (in the user interface of the local participant).
|
|
195
|
+ *
|
|
196
|
+ * @param sharedDocumentVisible {Boolean} {true} if the shared document was
|
|
197
|
+ * shown (as a result of the toggle) or {false} if it was hidden
|
|
198
|
+ */
|
|
199
|
+ _sharedDocumentToggled (sharedDocumentVisible) {
|
|
200
|
+ this._local.sharedDocumentVisible = sharedDocumentVisible;
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ /**
|
|
204
|
+ * Changes the nextOnPage property value.
|
|
205
|
+ *
|
|
206
|
+ * @param smallVideo the {SmallVideo} that was pinned or unpinned
|
|
207
|
+ * @param isPinned indicates if the given {SmallVideo} was pinned or
|
|
208
|
+ * unpinned
|
|
209
|
+ * @private
|
|
210
|
+ */
|
|
211
|
+ _nextOnStage (smallVideo, isPinned) {
|
|
212
|
+ if (!this._conference.isModerator)
|
|
213
|
+ return;
|
|
214
|
+
|
|
215
|
+ var nextOnStage = null;
|
|
216
|
+ if(isPinned)
|
|
217
|
+ nextOnStage = smallVideo.getId();
|
|
218
|
+
|
|
219
|
+ this._local.nextOnStage = nextOnStage;
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ /**
|
|
223
|
+ * Sends the follow-me command, when a local property change occurs.
|
|
224
|
+ *
|
|
225
|
+ * @param property the property name
|
|
226
|
+ * @param oldValue the old value
|
|
227
|
+ * @param newValue the new value
|
|
228
|
+ * @private
|
|
229
|
+ */
|
|
230
|
+ _localPropertyChange (property, oldValue, newValue) {
|
133
|
231
|
// Only a moderator is allowed to send commands.
|
134
|
232
|
var conference = this._conference;
|
135
|
233
|
if (!conference.isModerator)
|
|
@@ -141,12 +239,14 @@ import UIEvents from '../service/UI/UIEvents';
|
141
|
239
|
// sendCommand!
|
142
|
240
|
commands.removeCommand(_COMMAND);
|
143
|
241
|
var self = this;
|
144
|
|
- commands.sendCommand(
|
|
242
|
+ commands.sendCommandOnce(
|
145
|
243
|
_COMMAND,
|
146
|
244
|
{
|
147
|
245
|
attributes: {
|
148
|
246
|
filmStripVisible: self._local.filmStripVisible,
|
149
|
|
- },
|
|
247
|
+ nextOnStage: self._local.nextOnStage,
|
|
248
|
+ sharedDocumentVisible: self._local.sharedDocumentVisible
|
|
249
|
+ }
|
150
|
250
|
});
|
151
|
251
|
}
|
152
|
252
|
|
|
@@ -159,7 +259,7 @@ import UIEvents from '../service/UI/UIEvents';
|
159
|
259
|
* notable idiosyncrasy of the Command(s) API to be mindful of here is that
|
160
|
260
|
* the command may be issued by the local participant.
|
161
|
261
|
*/
|
162
|
|
- /* private */ _onFollowMeCommand ({ attributes }, id) {
|
|
262
|
+ _onFollowMeCommand ({ attributes }, id) {
|
163
|
263
|
// We require to know who issued the command because (1) only a
|
164
|
264
|
// moderator is allowed to send commands and (2) a command MUST be
|
165
|
265
|
// issued by a defined commander.
|
|
@@ -169,28 +269,60 @@ import UIEvents from '../service/UI/UIEvents';
|
169
|
269
|
// to act upon them.
|
170
|
270
|
if (this._conference.isLocalId(id))
|
171
|
271
|
return;
|
|
272
|
+
|
172
|
273
|
// TODO Don't obey commands issued by non-moderators.
|
173
|
274
|
|
174
|
|
- // Apply the received/remote command to the user experience/interface
|
|
275
|
+ // Applies the received/remote command to the user experience/interface
|
175
|
276
|
// of the local participant.
|
|
277
|
+ this._onFilmStripVisible(attributes.filmStripVisible);
|
|
278
|
+ this._onNextOnStage(attributes.nextOnStage);
|
|
279
|
+ this._onSharedDocumentVisible(attributes.sharedDocumentVisible);
|
|
280
|
+ }
|
176
|
281
|
|
177
|
|
- // filmStripVisible
|
178
|
|
- var filmStripVisible = attributes.filmStripVisible;
|
|
282
|
+ _onFilmStripVisible(filmStripVisible) {
|
179
|
283
|
if (typeof filmStripVisible !== 'undefined') {
|
180
|
284
|
// XXX The Command(s) API doesn't preserve the types (of
|
181
|
285
|
// attributes, at least) at the time of this writing so take into
|
182
|
286
|
// account that what originated as a Boolean may be a String on
|
183
|
287
|
// receipt.
|
184
|
288
|
filmStripVisible = (filmStripVisible == 'true');
|
|
289
|
+
|
185
|
290
|
// FIXME The UI (module) very likely doesn't (want to) expose its
|
186
|
291
|
// eventEmitter as a public field. I'm not sure at the time of this
|
187
|
292
|
// writing whether calling UI.toggleFilmStrip() is acceptable (from
|
188
|
293
|
// a design standpoint) either.
|
189
|
|
- this._UI.eventEmitter.emit(
|
|
294
|
+ if (filmStripVisible !== FilmStrip.isFilmStripVisible())
|
|
295
|
+ this._UI.eventEmitter.emit(
|
190
|
296
|
UIEvents.TOGGLE_FILM_STRIP,
|
191
|
297
|
filmStripVisible);
|
192
|
298
|
}
|
193
|
299
|
}
|
|
300
|
+
|
|
301
|
+ _onNextOnStage(id) {
|
|
302
|
+
|
|
303
|
+ var clickId = null;
|
|
304
|
+ if(typeof id !== 'undefined' && !VideoLayout.isPinned(id))
|
|
305
|
+ clickId = id;
|
|
306
|
+ else if (typeof id == 'undefined')
|
|
307
|
+ clickId = VideoLayout.getPinnedId();
|
|
308
|
+
|
|
309
|
+ if (clickId !== null)
|
|
310
|
+ VideoLayout.handleVideoThumbClicked(clickId);
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ _onSharedDocumentVisible(sharedDocumentVisible) {
|
|
314
|
+ if (typeof sharedDocumentVisible !== 'undefined') {
|
|
315
|
+ // XXX The Command(s) API doesn't preserve the types (of
|
|
316
|
+ // attributes, at least) at the time of this writing so take into
|
|
317
|
+ // account that what originated as a Boolean may be a String on
|
|
318
|
+ // receipt.
|
|
319
|
+ sharedDocumentVisible = (sharedDocumentVisible == 'true');
|
|
320
|
+
|
|
321
|
+ if (sharedDocumentVisible
|
|
322
|
+ !== this._UI.getSharedDocumentManager().isVisible())
|
|
323
|
+ this._UI.getSharedDocumentManager().toggleEtherpad();
|
|
324
|
+ }
|
|
325
|
+ }
|
194
|
326
|
}
|
195
|
327
|
|
196
|
328
|
export default FollowMe;
|