Преглед на файлове

Call mucJoined of video layout when the actual joining occurs, as the local id is needed when the presence for the email is received/processed and avatar is set.

master
damencho преди 9 години
родител
ревизия
8249aea796
променени са 4 файла, в които са добавени 130 реда и са изтрити 57 реда
  1. 1
    0
      conference.js
  2. 119
    55
      libs/lib-jitsi-meet.js
  3. 4
    2
      modules/UI/UI.js
  4. 6
    0
      modules/UI/videolayout/VideoLayout.js

+ 1
- 0
conference.js Целия файл

283
             });
283
             });
284
 
284
 
285
             APP.UI.updateAuthInfo(room.isAuthEnabled(), room.getAuthLogin());
285
             APP.UI.updateAuthInfo(room.isAuthEnabled(), room.getAuthLogin());
286
+            APP.UI.mucJoined();
286
         });
287
         });
287
 
288
 
288
 
289
 

+ 119
- 55
libs/lib-jitsi-meet.js Целия файл

413
     this.room.muteParticipant(participant.getJid(), true);
413
     this.room.muteParticipant(participant.getJid(), true);
414
 };
414
 };
415
 
415
 
416
-JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
416
+JitsiConference.prototype.onMemberJoined = function (jid, nick) {
417
     var id = Strophe.getResourceFromJid(jid);
417
     var id = Strophe.getResourceFromJid(jid);
418
     if (id === 'focus' || this.myUserId() === id) {
418
     if (id === 'focus' || this.myUserId() === id) {
419
        return;
419
        return;
1071
 var Logger = require("jitsi-meet-logger");
1071
 var Logger = require("jitsi-meet-logger");
1072
 var RTC = require("./modules/RTC/RTC");
1072
 var RTC = require("./modules/RTC/RTC");
1073
 var Statistics = require("./modules/statistics/statistics");
1073
 var Statistics = require("./modules/statistics/statistics");
1074
+var Resolutions = require("./service/RTC/Resolutions");
1075
+
1076
+function getLowerResolution(resolution) {
1077
+    if(!Resolutions[resolution])
1078
+        return null;
1079
+    var order = Resolutions[resolution].order;
1080
+    var res = null;
1081
+    var resName = null;
1082
+    for(var i in Resolutions) {
1083
+        var tmp = Resolutions[i];
1084
+        if (!res || (res.order < tmp.order && tmp.order < order)) {
1085
+            resName = i;
1086
+            res = tmp;
1087
+        }
1088
+    }
1089
+    return resName;
1090
+}
1074
 
1091
 
1075
 /**
1092
 /**
1076
  * Namespace for the interface of Jitsi Meet Library.
1093
  * Namespace for the interface of Jitsi Meet Library.
1135
                         }
1152
                         }
1136
                     }
1153
                     }
1137
                 return tracks;
1154
                 return tracks;
1155
+            }).catch(function (error) {
1156
+                if(error === JitsiTrackErrors.UNSUPPORTED_RESOLUTION) {
1157
+                    var oldResolution = options.resolution || '360';
1158
+                    var newResolution = getLowerResolution(oldResolution);
1159
+                    if(newResolution === null)
1160
+                        return Promise.reject(error);
1161
+                    options.resolution = newResolution;
1162
+                    return LibJitsiMeet.createLocalTracks(options);
1163
+                }
1164
+                return Promise.reject(error);
1138
             });
1165
             });
1139
     },
1166
     },
1140
     /**
1167
     /**
1163
 
1190
 
1164
 module.exports = LibJitsiMeet;
1191
 module.exports = LibJitsiMeet;
1165
 
1192
 
1166
-},{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiConnection":4,"./JitsiConnectionErrors":5,"./JitsiConnectionEvents":6,"./JitsiTrackErrors":9,"./JitsiTrackEvents":10,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"es6-promise":46,"jitsi-meet-logger":48}],8:[function(require,module,exports){
1193
+},{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiConnection":4,"./JitsiConnectionErrors":5,"./JitsiConnectionEvents":6,"./JitsiTrackErrors":9,"./JitsiTrackEvents":10,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"./service/RTC/Resolutions":81,"es6-promise":46,"jitsi-meet-logger":48}],8:[function(require,module,exports){
1167
 /* global Strophe */
1194
 /* global Strophe */
1168
 
1195
 
1169
 /**
1196
 /**
1326
     /**
1353
     /**
1327
      * Returns JitsiTrackErrors based on the error object passed by GUM
1354
      * Returns JitsiTrackErrors based on the error object passed by GUM
1328
      * @param error the error
1355
      * @param error the error
1329
-     * @param {Object} options the options object given to GUM.
1356
+     * @param {Array} devices Array with the requested devices
1330
      */
1357
      */
1331
-    parseError: function (error, options) {
1332
-        options = options || {};
1358
+    parseError: function (error, devices) {
1359
+        devices = devices || [];
1333
         if (typeof error == "object" && error.constraintName && error.name
1360
         if (typeof error == "object" && error.constraintName && error.name
1334
             && (error.name == "ConstraintNotSatisfiedError" ||
1361
             && (error.name == "ConstraintNotSatisfiedError" ||
1335
             error.name == "OverconstrainedError") &&
1362
             error.name == "OverconstrainedError") &&
1337
             error.constraintName == "maxWidth" ||
1364
             error.constraintName == "maxWidth" ||
1338
             error.constraintName == "minHeight" ||
1365
             error.constraintName == "minHeight" ||
1339
             error.constraintName == "maxHeight") &&
1366
             error.constraintName == "maxHeight") &&
1340
-            options.devices.indexOf("video") !== -1) {
1367
+            devices.indexOf("video") !== -1) {
1341
                 return this.UNSUPPORTED_RESOLUTION;
1368
                 return this.UNSUPPORTED_RESOLUTION;
1342
         } else {
1369
         } else {
1343
             return this.GENERAL;
1370
             return this.GENERAL;
1604
 var JitsiTrack = require("./JitsiTrack");
1631
 var JitsiTrack = require("./JitsiTrack");
1605
 var RTCBrowserType = require("./RTCBrowserType");
1632
 var RTCBrowserType = require("./RTCBrowserType");
1606
 var JitsiTrackEvents = require('../../JitsiTrackEvents');
1633
 var JitsiTrackEvents = require('../../JitsiTrackEvents');
1607
-var RTC = require("./RTCUtils");
1634
+var RTCUtils = require("./RTCUtils");
1608
 
1635
 
1609
 /**
1636
 /**
1610
  * Represents a single media track (either audio or video).
1637
  * Represents a single media track (either audio or video).
1661
         if (mute) {
1688
         if (mute) {
1662
             this.dontFireRemoveEvent = true;
1689
             this.dontFireRemoveEvent = true;
1663
             this.rtc.room.removeStream(this.stream, function () {});
1690
             this.rtc.room.removeStream(this.stream, function () {});
1664
-            RTC.stopMediaStream(this.stream);
1691
+            RTCUtils.stopMediaStream(this.stream);
1665
             if(isAudio)
1692
             if(isAudio)
1666
                 this.rtc.room.setAudioMute(mute);
1693
                 this.rtc.room.setAudioMute(mute);
1667
             else
1694
             else
1671
             //FIXME: Maybe here we should set the SRC for the containers to something
1698
             //FIXME: Maybe here we should set the SRC for the containers to something
1672
         } else {
1699
         } else {
1673
             var self = this;
1700
             var self = this;
1674
-            RTC.obtainAudioAndVideoPermissions({
1701
+            RTCUtils.obtainAudioAndVideoPermissions({
1675
                 devices: (isAudio ? ["audio"] : ["video"]),
1702
                 devices: (isAudio ? ["audio"] : ["video"]),
1676
                 resolution: self.resolution})
1703
                 resolution: self.resolution})
1677
                 .then(function (streams) {
1704
                 .then(function (streams) {
1690
 
1717
 
1691
                     for(var i = 0; i < self.containers.length; i++)
1718
                     for(var i = 0; i < self.containers.length; i++)
1692
                     {
1719
                     {
1693
-                        RTC.attachMediaStream(self.containers[i], self.stream);
1720
+                        RTCUtils.attachMediaStream(
1721
+                            self.containers[i], self.stream);
1694
                     }
1722
                     }
1695
 
1723
 
1696
                     self.rtc.room.addStream(stream.stream,
1724
                     self.rtc.room.addStream(stream.stream,
1716
         return;
1744
         return;
1717
     if(this.rtc)
1745
     if(this.rtc)
1718
         this.rtc.room.removeStream(this.stream, function () {});
1746
         this.rtc.room.removeStream(this.stream, function () {});
1719
-    RTC.stopMediaStream(this.stream);
1747
+    RTCUtils.stopMediaStream(this.stream);
1720
     this.detach();
1748
     this.detach();
1721
 }
1749
 }
1722
 
1750
 
2857
     }
2885
     }
2858
 
2886
 
2859
     var device = options.devices.splice(0, 1);
2887
     var device = options.devices.splice(0, 1);
2888
+    var devices = [];
2889
+    devices.push(device);
2860
     options.deviceGUM[device](function (stream) {
2890
     options.deviceGUM[device](function (stream) {
2861
             options.streams = options.streams || {};
2891
             options.streams = options.streams || {};
2862
             options.streams[device] = stream;
2892
             options.streams[device] = stream;
2865
         function (error) {
2895
         function (error) {
2866
             logger.error(
2896
             logger.error(
2867
                 "failed to obtain " + device + " stream - stop", error);
2897
                 "failed to obtain " + device + " stream - stop", error);
2868
-            options.errorCallback(JitsiTrackErrors.parseError(error));
2898
+            options.errorCallback(JitsiTrackErrors.parseError(error, devices));
2869
         });
2899
         });
2870
 }
2900
 }
2871
 
2901
 
2997
                     this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
3027
                     this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
2998
                 }
3028
                 }
2999
                 this.attachMediaStream = function (element, stream) {
3029
                 this.attachMediaStream = function (element, stream) {
3000
-                    element.attr('src', webkitURL.createObjectURL(stream));
3030
+
3031
+                    // saves the created url for the stream, so we can reuse it
3032
+                    // and not keep creating urls
3033
+                    if (!stream.jitsiObjectURL) {
3034
+                        stream.jitsiObjectURL
3035
+                            = webkitURL.createObjectURL(stream);
3036
+                    }
3037
+
3038
+                    element.attr('src', stream.jitsiObjectURL);
3001
                 };
3039
                 };
3002
                 this.getStreamID = function (stream) {
3040
                 this.getStreamID = function (stream) {
3003
                     // streams from FF endpoints have the characters '{' and '}'
3041
                     // streams from FF endpoints have the characters '{' and '}'
3176
                 var GUM = function (device, s, e) {
3214
                 var GUM = function (device, s, e) {
3177
                     this.getUserMediaWithConstraints(device, s, e, options);
3215
                     this.getUserMediaWithConstraints(device, s, e, options);
3178
                 };
3216
                 };
3217
+
3179
                 var deviceGUM = {
3218
                 var deviceGUM = {
3180
                     "audio": GUM.bind(self, ["audio"]),
3219
                     "audio": GUM.bind(self, ["audio"]),
3181
-                    "video": GUM.bind(self, ["video"]),
3182
-                    "desktop": screenObtainer.obtainStream.bind(screenObtainer)
3220
+                    "video": GUM.bind(self, ["video"])
3183
                 };
3221
                 };
3222
+
3223
+                if(screenObtainer.isSupported()){
3224
+                    deviceGUM["desktop"] = screenObtainer.obtainStream.bind(
3225
+                        screenObtainer);
3226
+                }
3184
                 // With FF/IE we can't split the stream into audio and video because FF
3227
                 // With FF/IE we can't split the stream into audio and video because FF
3185
                 // doesn't support media stream constructors. So, we need to get the
3228
                 // doesn't support media stream constructors. So, we need to get the
3186
                 // audio stream separately from the video stream using two distinct GUM
3229
                 // audio stream separately from the video stream using two distinct GUM
3213
                                             desktopStream: desktopStream});
3256
                                             desktopStream: desktopStream});
3214
                                     }, function (error) {
3257
                                     }, function (error) {
3215
                                         reject(
3258
                                         reject(
3216
-                                            JitsiTrackErrors.parseError(error));
3259
+                                            JitsiTrackErrors.parseError(error,
3260
+                                                options.devices));
3217
                                     });
3261
                                     });
3218
                             } else {
3262
                             } else {
3219
                                 successCallback({audioVideo: stream});
3263
                                 successCallback({audioVideo: stream});
3220
                             }
3264
                             }
3221
                         },
3265
                         },
3222
                         function (error) {
3266
                         function (error) {
3223
-                            reject(JitsiTrackErrors.parseError(error));
3267
+                            reject(JitsiTrackErrors.parseError(error,
3268
+                                options.devices));
3224
                         },
3269
                         },
3225
                         options);
3270
                         options);
3226
                 } else if (hasDesktop) {
3271
                 } else if (hasDesktop) {
3229
                             successCallback({desktopStream: stream});
3274
                             successCallback({desktopStream: stream});
3230
                         }, function (error) {
3275
                         }, function (error) {
3231
                             reject(
3276
                             reject(
3232
-                                JitsiTrackErrors.parseError(error));
3277
+                                JitsiTrackErrors.parseError(error,
3278
+                                    ["desktop"]));
3233
                         });
3279
                         });
3234
                 }
3280
                 }
3235
             }
3281
             }
3285
         if (mediaStream.stop) {
3331
         if (mediaStream.stop) {
3286
             mediaStream.stop();
3332
             mediaStream.stop();
3287
         }
3333
         }
3334
+
3335
+        // if we have done createObjectURL, lets clean it
3336
+        if (mediaStream.jitsiObjectURL) {
3337
+            webkitURL.revokeObjectURL(mediaStream.jitsiObjectURL);
3338
+        }
3288
     },
3339
     },
3289
     /**
3340
     /**
3290
      * Returns whether the desktop sharing is enabled or not.
3341
      * Returns whether the desktop sharing is enabled or not.
6295
     parser.packet2JSON(pres, nodes);
6346
     parser.packet2JSON(pres, nodes);
6296
     this.lastPresences[from] = nodes;
6347
     this.lastPresences[from] = nodes;
6297
     var jibri = null;
6348
     var jibri = null;
6349
+    // process nodes to extract data needed for MUC_JOINED and MUC_MEMBER_JOINED
6350
+    // events
6298
     for(var i = 0; i < nodes.length; i++)
6351
     for(var i = 0; i < nodes.length; i++)
6299
     {
6352
     {
6300
         var node = nodes[i];
6353
         var node = nodes[i];
6302
         {
6355
         {
6303
             case "nick":
6356
             case "nick":
6304
                 member.nick = node.value;
6357
                 member.nick = node.value;
6305
-                if(!member.isFocus) {
6306
-                    var displayName = !this.xmpp.options.displayJids
6307
-                        ? member.nick : Strophe.getResourceFromJid(from);
6308
-
6309
-                    if (displayName && displayName.length > 0) {
6310
-                        this.eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
6311
-                    }
6312
-                }
6313
                 break;
6358
                 break;
6314
             case "userId":
6359
             case "userId":
6315
                 member.id = node.value;
6360
                 member.id = node.value;
6316
                 break;
6361
                 break;
6317
-            case "bridgeIsDown":
6318
-                if(!this.bridgeIsDown) {
6319
-                    this.bridgeIsDown = true;
6320
-                    this.eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
6321
-                }
6322
-                break;
6323
-            case "jibri-recording-status":
6324
-                var jibri = node;
6325
-                break;
6326
-            case "call-control":
6327
-                var att = node.attributes;
6328
-                if(!att)
6329
-                    break;
6330
-                this.phoneNumber = att.phone || null;
6331
-                this.phonePin = att.pin || null;
6332
-                this.eventEmitter.emit(XMPPEvents.PHONE_NUMBER_CHANGED);
6333
-                break;
6334
-            default :
6335
-                this.processNode(node, from);
6336
         }
6362
         }
6337
-
6338
     }
6363
     }
6339
 
6364
 
6340
     if (from == this.myroomjid) {
6365
     if (from == this.myroomjid) {
6341
-        if (member.affiliation == 'owner')
6342
-
6343
-            if (this.role !== member.role) {
6366
+        if (member.affiliation == 'owner'
6367
+            &&  this.role !== member.role) {
6344
                 this.role = member.role;
6368
                 this.role = member.role;
6345
-
6346
-                this.eventEmitter.emit(XMPPEvents.LOCAL_ROLE_CHANGED, this.role);
6347
-            }
6369
+                this.eventEmitter.emit(
6370
+                    XMPPEvents.LOCAL_ROLE_CHANGED, this.role);
6371
+        }
6348
         if (!this.joined) {
6372
         if (!this.joined) {
6349
             this.joined = true;
6373
             this.joined = true;
6350
             console.log("(TIME) MUC joined:\t", window.performance.now());
6374
             console.log("(TIME) MUC joined:\t", window.performance.now());
6351
-            this.eventEmitter.emit(XMPPEvents.MUC_JOINED, from, member);
6375
+            this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
6352
         }
6376
         }
6353
     } else if (this.members[from] === undefined) {
6377
     } else if (this.members[from] === undefined) {
6354
         // new participant
6378
         // new participant
6366
             logger.info("Ignore focus: " + from + ", real JID: " + member.jid);
6390
             logger.info("Ignore focus: " + from + ", real JID: " + member.jid);
6367
         }
6391
         }
6368
         else {
6392
         else {
6369
-            this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_JOINED, from, member.id, member.nick);
6393
+            this.eventEmitter.emit(
6394
+                XMPPEvents.MUC_MEMBER_JOINED, from, member.nick);
6370
         }
6395
         }
6371
     } else {
6396
     } else {
6372
         // Presence update for existing participant
6397
         // Presence update for existing participant
6373
         // Watch role change:
6398
         // Watch role change:
6374
         if (this.members[from].role != member.role) {
6399
         if (this.members[from].role != member.role) {
6375
             this.members[from].role = member.role;
6400
             this.members[from].role = member.role;
6376
-            this.eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED, from, member.role);
6401
+            this.eventEmitter.emit(
6402
+                XMPPEvents.MUC_ROLE_CHANGED, from, member.role);
6377
         }
6403
         }
6378
 
6404
 
6379
         // store the new display name
6405
         // store the new display name
6381
             this.members[from].displayName = member.displayName;
6407
             this.members[from].displayName = member.displayName;
6382
     }
6408
     }
6383
 
6409
 
6410
+    // after we had fired member or room joined events, lets fire events
6411
+    // for the rest info we got in presence
6412
+    for(var i = 0; i < nodes.length; i++)
6413
+    {
6414
+        var node = nodes[i];
6415
+        switch(node.tagName)
6416
+        {
6417
+            case "nick":
6418
+                if(!member.isFocus) {
6419
+                    var displayName = !this.xmpp.options.displayJids
6420
+                        ? member.nick : Strophe.getResourceFromJid(from);
6384
 
6421
 
6422
+                    if (displayName && displayName.length > 0) {
6423
+                        this.eventEmitter.emit(
6424
+                            XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
6425
+                    }
6426
+                }
6427
+                break;
6428
+            case "bridgeIsDown":
6429
+                if(!this.bridgeIsDown) {
6430
+                    this.bridgeIsDown = true;
6431
+                    this.eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
6432
+                }
6433
+                break;
6434
+            case "jibri-recording-status":
6435
+                var jibri = node;
6436
+                break;
6437
+            case "call-control":
6438
+                var att = node.attributes;
6439
+                if(!att)
6440
+                    break;
6441
+                this.phoneNumber = att.phone || null;
6442
+                this.phonePin = att.pin || null;
6443
+                this.eventEmitter.emit(XMPPEvents.PHONE_NUMBER_CHANGED);
6444
+                break;
6445
+            default :
6446
+                this.processNode(node, from);
6447
+        }
6448
+    }
6385
 
6449
 
6386
     if(!member.isFocus)
6450
     if(!member.isFocus)
6387
         this.eventEmitter.emit(XMPPEvents.USER_ID_CHANGED, from, member.id);
6451
         this.eventEmitter.emit(XMPPEvents.USER_ID_CHANGED, from, member.id);

+ 4
- 2
modules/UI/UI.js Целия файл

173
         UI.changeDisplayName('localVideoContainer', displayName);
173
         UI.changeDisplayName('localVideoContainer', displayName);
174
     }
174
     }
175
 
175
 
176
-    VideoLayout.mucJoined();
177
-
178
     // Make sure we configure our avatar id, before creating avatar for us
176
     // Make sure we configure our avatar id, before creating avatar for us
179
     UI.setUserAvatar(id, settings.email || settings.uid);
177
     UI.setUserAvatar(id, settings.email || settings.uid);
180
 
178
 
181
     Toolbar.checkAutoEnableDesktopSharing();
179
     Toolbar.checkAutoEnableDesktopSharing();
182
 };
180
 };
183
 
181
 
182
+UI.mucJoined = function () {
183
+    VideoLayout.mucJoined();
184
+};
185
+
184
 function registerListeners() {
186
 function registerListeners() {
185
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
187
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
186
         UI.setUserAvatar(APP.conference.localId, email);
188
         UI.setUserAvatar(APP.conference.localId, email);

+ 6
- 0
modules/UI/videolayout/VideoLayout.js Целия файл

165
         }
165
         }
166
     },
166
     },
167
 
167
 
168
+    /**
169
+     * Get's the localID of the conference and set it to the local video
170
+     * (small one). This needs to be called as early as possible, when muc is
171
+     * actually joined. Otherwise events can come with information like email
172
+     * and setting them assume the id is already set.
173
+     */
168
     mucJoined () {
174
     mucJoined () {
169
         let id = APP.conference.localId;
175
         let id = APP.conference.localId;
170
         localVideoThumbnail.joined(id);
176
         localVideoThumbnail.joined(id);

Loading…
Отказ
Запис