Преглед изворни кода

Merge pull request #552 from damencho/shared-video-fixes

Shared video fixes
j8
yanas пре 9 година
родитељ
комит
1e7cd06555
5 измењених фајлова са 56 додато и 27 уклоњено
  1. 25
    7
      conference.js
  2. 6
    1
      modules/FollowMe.js
  3. 12
    9
      modules/UI/UI.js
  4. 11
    8
      modules/UI/shared_video/SharedVideo.js
  5. 2
    2
      modules/UI/videolayout/VideoLayout.js

+ 25
- 7
conference.js Прегледај датотеку

@@ -402,6 +402,15 @@ export default {
402 402
     listMembersIds () {
403 403
         return room.getParticipants().map(p => p.getId());
404 404
     },
405
+    /**
406
+     * Checks whether the participant identified by id is a moderator.
407
+     * @id id to search for participant
408
+     * @return {boolean} whether the participant is moderator
409
+     */
410
+    isParticipantModerator (id) {
411
+        let user = room.getParticipantById(id);
412
+        return user && user.isModerator();
413
+    },
405 414
     /**
406 415
      * Check if SIP is supported.
407 416
      * @returns {boolean}
@@ -737,7 +746,7 @@ export default {
737 746
             console.log('USER %s LEFT', id, user);
738 747
             APP.API.notifyUserLeft(id);
739 748
             APP.UI.removeUser(id, user.getDisplayName());
740
-            APP.UI.stopSharedVideo({from: id});
749
+            APP.UI.stopSharedVideo(id);
741 750
         });
742 751
 
743 752
 
@@ -1083,7 +1092,6 @@ export default {
1083 1092
                 room.sendCommandOnce(Commands.SHARED_VIDEO, {
1084 1093
                     value: url,
1085 1094
                     attributes: {
1086
-                        from: APP.conference.localId,
1087 1095
                         state: state,
1088 1096
                         time: time,
1089 1097
                         volume: volume
@@ -1096,7 +1104,6 @@ export default {
1096 1104
                 room.sendCommand(Commands.SHARED_VIDEO, {
1097 1105
                     value: url,
1098 1106
                     attributes: {
1099
-                        from: APP.conference.localId,
1100 1107
                         state: state,
1101 1108
                         time: time,
1102 1109
                         volume: volume
@@ -1105,14 +1112,25 @@ export default {
1105 1112
             }
1106 1113
         });
1107 1114
         room.addCommandListener(
1108
-            Commands.SHARED_VIDEO, ({value, attributes}) => {
1115
+            Commands.SHARED_VIDEO, ({value, attributes}, id) => {
1116
+
1117
+                // if we are not the moderator or
1118
+                // the command is coming from a user which is not the moderator
1119
+                if (!(this.isLocalId(id) && room.isModerator())
1120
+                    && !this.isParticipantModerator(id))
1121
+                {
1122
+                    console.warn('Received shared video command ' +
1123
+                        'not from moderator');
1124
+                    return;
1125
+                }
1126
+
1109 1127
                 if (attributes.state === 'stop') {
1110
-                    APP.UI.stopSharedVideo(attributes);
1128
+                    APP.UI.stopSharedVideo(id, attributes);
1111 1129
                 } else if (attributes.state === 'start') {
1112
-                    APP.UI.showSharedVideo(value, attributes);
1130
+                    APP.UI.showSharedVideo(id, value, attributes);
1113 1131
                 } else if (attributes.state === 'playing'
1114 1132
                     || attributes.state === 'pause') {
1115
-                    APP.UI.updateSharedVideo(value, attributes);
1133
+                    APP.UI.updateSharedVideo(id, value, attributes);
1116 1134
                 }
1117 1135
             });
1118 1136
     }

+ 6
- 1
modules/FollowMe.js Прегледај датотеку

@@ -270,7 +270,12 @@ class FollowMe {
270 270
         if (this._conference.isLocalId(id))
271 271
             return;
272 272
 
273
-        // TODO Don't obey commands issued by non-moderators.
273
+        if (!this._conference.isParticipantModerator(id))
274
+        {
275
+            console.warn('Received follow-me command ' +
276
+                'not from moderator');
277
+            return;
278
+        }
274 279
 
275 280
         // Applies the received/remote command to the user experience/interface
276 281
         // of the local participant.

+ 12
- 9
modules/UI/UI.js Прегледај датотеку

@@ -1107,32 +1107,35 @@ UI.updateDevicesAvailability = function (id, devices) {
1107 1107
 };
1108 1108
 
1109 1109
 /**
1110
-* Show shared video.
1111
-* @param {string} url video url
1112
-* @param {string} attributes
1110
+ * Show shared video.
1111
+ * @param {string} id the id of the sender of the command
1112
+ * @param {string} url video url
1113
+ * @param {string} attributes
1113 1114
 */
1114
-UI.showSharedVideo = function (url, attributes) {
1115
+UI.showSharedVideo = function (id, url, attributes) {
1115 1116
     if (sharedVideoManager)
1116
-        sharedVideoManager.showSharedVideo(url, attributes);
1117
+        sharedVideoManager.showSharedVideo(id, url, attributes);
1117 1118
 };
1118 1119
 
1119 1120
 /**
1120 1121
  * Update shared video.
1122
+ * @param {string} id the id of the sender of the command
1121 1123
  * @param {string} url video url
1122 1124
  * @param {string} attributes
1123 1125
  */
1124
-UI.updateSharedVideo = function (url, attributes) {
1126
+UI.updateSharedVideo = function (id, url, attributes) {
1125 1127
     if (sharedVideoManager)
1126
-        sharedVideoManager.updateSharedVideo(url, attributes);
1128
+        sharedVideoManager.updateSharedVideo(id, url, attributes);
1127 1129
 };
1128 1130
 
1129 1131
 /**
1130 1132
  * Stop showing shared video.
1133
+ * @param {string} id the id of the sender of the command
1131 1134
  * @param {string} attributes
1132 1135
  */
1133
-UI.stopSharedVideo = function (attributes) {
1136
+UI.stopSharedVideo = function (id, attributes) {
1134 1137
     if (sharedVideoManager)
1135
-        sharedVideoManager.stopSharedVideo(attributes);
1138
+        sharedVideoManager.stopSharedVideo(id, attributes);
1136 1139
 };
1137 1140
 
1138 1141
 module.exports = UI;

+ 11
- 8
modules/UI/shared_video/SharedVideo.js Прегледај датотеку

@@ -50,10 +50,11 @@ export default class SharedVideoManager {
50 50
     /**
51 51
      * Shows the player component and starts the checking function
52 52
      * that will be sending updates, if we are the one shared the video
53
+     * @param id the id of the sender of the command
53 54
      * @param url the video url
54 55
      * @param attributes
55 56
      */
56
-    showSharedVideo (url, attributes) {
57
+    showSharedVideo (id, url, attributes) {
57 58
         if (this.isSharedVideoShown)
58 59
             return;
59 60
 
@@ -61,7 +62,7 @@ export default class SharedVideoManager {
61 62
         this.url = url;
62 63
 
63 64
         // the owner of the video
64
-        this.from = attributes.from;
65
+        this.from = id;
65 66
 
66 67
         // This code loads the IFrame Player API code asynchronously.
67 68
         var tag = document.createElement('script');
@@ -184,10 +185,11 @@ export default class SharedVideoManager {
184 185
     /**
185 186
      * Updates video, if its not playing and needs starting or
186 187
      * if its playing and needs to be paysed
188
+     * @param id the id of the sender of the command
187 189
      * @param url the video url
188 190
      * @param attributes
189 191
      */
190
-    updateSharedVideo (url, attributes) {
192
+    updateSharedVideo (id, url, attributes) {
191 193
         // if we are sending the event ignore
192 194
         if(APP.conference.isLocalId(this.from)) {
193 195
             return;
@@ -196,7 +198,7 @@ export default class SharedVideoManager {
196 198
         if (attributes.state == 'playing') {
197 199
 
198 200
             if(!this.isSharedVideoShown) {
199
-                this.showSharedVideo(url, attributes);
201
+                this.showSharedVideo(id, url, attributes);
200 202
                 return;
201 203
             }
202 204
 
@@ -239,22 +241,23 @@ export default class SharedVideoManager {
239 241
             else {
240 242
                 // if not shown show it, passing attributes so it can
241 243
                 // be shown paused
242
-                this.showSharedVideo(url, attributes);
244
+                this.showSharedVideo(id, url, attributes);
243 245
             }
244 246
         }
245 247
     }
246 248
 
247 249
     /**
248 250
      * Stop shared video if it is currently showed. If the user started the
249
-     * shared video is the one in the attributes.from (called when user
251
+     * shared video is the one in the id (called when user
250 252
      * left and we want to remove video if the user sharing it left).
253
+     * @param id the id of the sender of the command
251 254
      * @param attributes
252 255
      */
253
-    stopSharedVideo (attributes) {
256
+    stopSharedVideo (id, attributes) {
254 257
         if (!this.isSharedVideoShown)
255 258
             return;
256 259
 
257
-        if(this.from !== attributes.from)
260
+        if(this.from !== id)
258 261
             return;
259 262
 
260 263
         if(this.intervalId) {

+ 2
- 2
modules/UI/videolayout/VideoLayout.js Прегледај датотеку

@@ -922,7 +922,8 @@ var VideoLayout = {
922 922
         let currentId = largeVideo.id;
923 923
 
924 924
         if (!isOnLarge || forceUpdate) {
925
-            if (id !== currentId) {
925
+            let videoType = this.getRemoteVideoType(id);
926
+            if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
926 927
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
927 928
             }
928 929
             if (currentId) {
@@ -931,7 +932,6 @@ var VideoLayout = {
931 932
 
932 933
             let smallVideo = this.getSmallVideo(id);
933 934
 
934
-            let videoType = this.getRemoteVideoType(id);
935 935
             largeVideo.updateLargeVideo(
936 936
                 id,
937 937
                 smallVideo.videoStream,

Loading…
Откажи
Сачувај