Pārlūkot izejas kodu

fixes after rebase

master
isymchych 9 gadus atpakaļ
vecāks
revīzija
6ee6b6e9e5

+ 50
- 63
app.js Parādīt failu

36
 const ConferenceEvents = JitsiMeetJS.events.conference;
36
 const ConferenceEvents = JitsiMeetJS.events.conference;
37
 const ConferenceErrors = JitsiMeetJS.errors.conference;
37
 const ConferenceErrors = JitsiMeetJS.errors.conference;
38
 
38
 
39
-const TrackEvents = JitsiMeetJS.events.track;
40
-const TrackErrors = JitsiMeetJS.errors.track;
41
-
42
 let localVideo, localAudio;
39
 let localVideo, localAudio;
43
 
40
 
44
 const Commands = {
41
 const Commands = {
45
     CONNECTION_QUALITY: "connectionQuality",
42
     CONNECTION_QUALITY: "connectionQuality",
46
     EMAIL: "email",
43
     EMAIL: "email",
47
-    VIDEO_TYPE: "videoType"
44
+    VIDEO_TYPE: "videoType",
48
     ETHERPAD: "etherpad",
45
     ETHERPAD: "etherpad",
49
     PREZI: "prezi",
46
     PREZI: "prezi",
50
     STOP_PREZI: "stop-prezi"
47
     STOP_PREZI: "stop-prezi"
88
     statistics,
85
     statistics,
89
     settings,
86
     settings,
90
 
87
 
88
+    createLocalTracks (...devices) {
89
+        return JitsiMeetJS.createLocalTracks({
90
+            // copy array to avoid mutations inside library
91
+            devices: devices.slice(0),
92
+            resolution: config.resolution
93
+        }).catch(function (err) {
94
+            console.error('failed to create local tracks', ...devices, err);
95
+            APP.statistics.onGetUserMediaFailed(err);
96
+            return [];
97
+        });
98
+    },
99
+
91
     init () {
100
     init () {
92
         let roomName = buildRoomName();
101
         let roomName = buildRoomName();
93
         this.conference = {
102
         this.conference = {
137
 
146
 
138
     const addTrack = (track) => {
147
     const addTrack = (track) => {
139
         room.addTrack(track);
148
         room.addTrack(track);
140
-        if(track.getType() === "audio")
149
+        if (track.isAudioTrack()) {
141
             return;
150
             return;
151
+        }
152
+
142
         room.removeCommand(Commands.VIDEO_TYPE);
153
         room.removeCommand(Commands.VIDEO_TYPE);
143
         room.sendCommand(Commands.VIDEO_TYPE, {
154
         room.sendCommand(Commands.VIDEO_TYPE, {
144
             value: track.videoType,
155
             value: track.videoType,
161
     APP.conference.listMembersIds = function () {
172
     APP.conference.listMembersIds = function () {
162
         return room.getParticipants().map(p => p.getId());
173
         return room.getParticipants().map(p => p.getId());
163
     };
174
     };
164
-    /**
165
-     * Creates video track (desktop or camera).
166
-     * @param type "camera" or "video"
167
-     * @param endedHandler onended function
168
-     * @returns Promise
169
-     */
170
-    APP.conference.createVideoTrack = (type, endedHandler) => {
171
-        return JitsiMeetJS.createLocalTracks({
172
-            devices: [type], resolution: config.resolution
173
-        }).then((tracks) => {
174
-            tracks[0].on(TrackEvents.TRACK_STOPPED, endedHandler);
175
-            return tracks;
176
-        });
177
-    };
178
-
179
-    APP.conference.changeLocalVideo = (track, callback) => {
180
-        const localCallback = (newTrack) => {
181
-            if (newTrack.isLocal() && newTrack === localVideo) {
182
-                if(localVideo.isMuted() &&
183
-                    localVideo.videoType !== track.videoType) {
184
-                        localVideo.mute();
185
-                }
186
-                callback();
187
-                room.off(ConferenceEvents.TRACK_ADDED, localCallback);
188
-            }
189
-        };
190
-
191
-        room.on(ConferenceEvents.TRACK_ADDED, localCallback);
192
-
193
-        localVideo.stop();
194
-        localVideo = track;
195
-        addTrack(track);
196
-        APP.UI.addLocalStream(track);
197
-    };
198
 
175
 
199
     APP.conference.sipGatewayEnabled = () => {
176
     APP.conference.sipGatewayEnabled = () => {
200
         return room.isSIPCallingSupported();
177
         return room.isSIPCallingSupported();
205
             return APP.settings.getDisplayName();
182
             return APP.settings.getDisplayName();
206
         }
183
         }
207
 
184
 
208
-        var participant = room.getParticipantById(id);
185
+        let participant = room.getParticipantById(id);
209
         if (participant && participant.getDisplayName()) {
186
         if (participant && participant.getDisplayName()) {
210
             return participant.getDisplayName();
187
             return participant.getDisplayName();
211
         }
188
         }
214
     // add local streams when joined to the conference
191
     // add local streams when joined to the conference
215
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
192
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
216
         localTracks.forEach(function (track) {
193
         localTracks.forEach(function (track) {
217
-            if(track.getType() === "audio") {
194
+            if(track.isAudioTrack()) {
218
                 localAudio = track;
195
                 localAudio = track;
219
             }
196
             }
220
-            else if (track.getType() === "video") {
197
+            else if (track.isVideoTrack()) {
221
                 localVideo = track;
198
                 localVideo = track;
222
             }
199
             }
223
             addTrack(track);
200
             addTrack(track);
246
             APP.conference.isModerator = room.isModerator();
223
             APP.conference.isModerator = room.isModerator();
247
             APP.UI.updateLocalRole(room.isModerator());
224
             APP.UI.updateLocalRole(room.isModerator());
248
         } else {
225
         } else {
249
-            var user = room.getParticipantById(id);
226
+            let user = room.getParticipantById(id);
250
             if (user) {
227
             if (user) {
251
                 APP.UI.updateUserRole(user);
228
                 APP.UI.updateUserRole(user);
252
             }
229
             }
401
         });
378
         });
402
     });
379
     });
403
 
380
 
404
-    room.addCommandListener(Commands.VIDEO_TYPE, (data, from) => {
405
-        APP.UI.onPeerVideoTypeChanged(from, data.value);
381
+    room.addCommandListener(Commands.VIDEO_TYPE, ({value}, from) => {
382
+        APP.UI.onPeerVideoTypeChanged(from, value);
406
     });
383
     });
407
 
384
 
408
 
385
 
416
         });
393
         });
417
     }
394
     }
418
 
395
 
419
-    var email = APP.settings.getEmail();
396
+    let email = APP.settings.getEmail();
420
     email && sendEmail(email);
397
     email && sendEmail(email);
421
     APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
398
     APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
422
         APP.settings.setEmail(email);
399
         APP.settings.setEmail(email);
534
         APP.UI.updateDTMFSupport(isDTMFSupported);
511
         APP.UI.updateDTMFSupport(isDTMFSupported);
535
     });
512
     });
536
 
513
 
514
+    APP.desktopsharing.addListener(
515
+        DesktopSharingEventTypes.NEW_STREAM_CREATED,
516
+        (track, callback) => {
517
+            const localCallback = (newTrack) => {
518
+                if (newTrack.isLocal() && newTrack === localVideo) {
519
+                    if(localVideo.isMuted() &&
520
+                       localVideo.videoType !== track.videoType) {
521
+                        localVideo.mute();
522
+                    }
523
+                    callback();
524
+                    room.off(ConferenceEvents.TRACK_ADDED, localCallback);
525
+                }
526
+            };
527
+
528
+            room.on(ConferenceEvents.TRACK_ADDED, localCallback);
529
+
530
+            localVideo.stop();
531
+            localVideo = track;
532
+            addTrack(track);
533
+            APP.UI.addLocalStream(track);
534
+        }
535
+    );
536
+
537
     $(window).bind('beforeunload', function () {
537
     $(window).bind('beforeunload', function () {
538
         room.leave();
538
         room.leave();
539
     });
539
     });
603
     });
603
     });
604
 }
604
 }
605
 
605
 
606
-function createLocalTracks () {
607
-    return JitsiMeetJS.createLocalTracks({
608
-        devices: ['audio', 'video']
609
-    }).catch(function (err) {
610
-        console.error('failed to create local tracks', err);
611
-        APP.statistics.onGetUserMediaFailed(err);
612
-        return [];
613
-    });
614
-}
615
-
616
 function connect() {
606
 function connect() {
617
     return openConnection({retry: true}).catch(function (err) {
607
     return openConnection({retry: true}).catch(function (err) {
618
         if (err === ConnectionErrors.PASSWORD_REQUIRED) {
608
         if (err === ConnectionErrors.PASSWORD_REQUIRED) {
630
     JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
620
     JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
631
 
621
 
632
     JitsiMeetJS.init(config).then(function () {
622
     JitsiMeetJS.init(config).then(function () {
633
-        return Promise.all([createLocalTracks(), connect()]);
623
+        return Promise.all([
624
+            APP.createLocalTracks('audio', 'video'),
625
+            connect()
626
+        ]);
634
     }).then(function ([tracks, connection]) {
627
     }).then(function ([tracks, connection]) {
635
         console.log('initialized with %s local tracks', tracks.length);
628
         console.log('initialized with %s local tracks', tracks.length);
636
         return initConference(tracks, connection);
629
         return initConference(tracks, connection);
642
             APP.settings.setLanguage(language);
635
             APP.settings.setLanguage(language);
643
         });
636
         });
644
 
637
 
645
-        APP.desktopsharing.addListener(
646
-            DesktopSharingEventTypes.NEW_STREAM_CREATED,
647
-            (stream, callback) => {
648
-                APP.conference.changeLocalVideo(stream,
649
-                    callback);
650
-            });
651
         APP.desktopsharing.init(JitsiMeetJS.isDesktopSharingEnabled());
638
         APP.desktopsharing.init(JitsiMeetJS.isDesktopSharingEnabled());
652
         APP.statistics.start();
639
         APP.statistics.start();
653
         APP.connectionquality.init();
640
         APP.connectionquality.init();

+ 55
- 7
libs/lib-jitsi-meet.js Parādīt failu

579
         reject(new Error("The conference is not created yet!"))});
579
         reject(new Error("The conference is not created yet!"))});
580
 }
580
 }
581
 
581
 
582
+/**
583
+ * Returns true if the SIP calls are supported and false otherwise
584
+ */
585
+JitsiConference.prototype.isSIPCallingSupported = function () {
586
+    if(this.room)
587
+        return this.room.isSIPCallingSupported();
588
+    return false;
589
+}
590
+
582
 /**
591
 /**
583
  * Dials a number.
592
  * Dials a number.
584
  * @param number the number
593
  * @param number the number
1059
     init: function (options) {
1068
     init: function (options) {
1060
         return RTC.init(options || {});
1069
         return RTC.init(options || {});
1061
     },
1070
     },
1071
+    /**
1072
+     * Returns whether the desktop sharing is enabled or not.
1073
+     * @returns {boolean}
1074
+     */
1075
+    isDesktopSharingEnabled: function () {
1076
+        return RTC.isDesktopSharingEnabled();
1077
+    },
1062
     setLogLevel: function (level) {
1078
     setLogLevel: function (level) {
1063
         Logger.setLogLevel(level);
1079
         Logger.setLogLevel(level);
1064
     },
1080
     },
1799
 var RTCBrowserType = require("./RTCBrowserType");
1815
 var RTCBrowserType = require("./RTCBrowserType");
1800
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
1816
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
1801
 var EventEmitter = require("events");
1817
 var EventEmitter = require("events");
1818
+var RTC = require("./RTCUtils");
1802
 
1819
 
1803
 /**
1820
 /**
1804
  * This implements 'onended' callback normally fired by WebRTC after the stream
1821
  * This implements 'onended' callback normally fired by WebRTC after the stream
1989
  * Returns id of the track.
2006
  * Returns id of the track.
1990
  * @returns {string} id of the track or null if this is fake track.
2007
  * @returns {string} id of the track or null if this is fake track.
1991
  */
2008
  */
1992
-JitsiTrack.prototype.getId = function () {
2009
+JitsiTrack.prototype._getId = function () {
1993
     var tracks = this.stream.getTracks();
2010
     var tracks = this.stream.getTracks();
1994
     if(!tracks || tracks.length === 0)
2011
     if(!tracks || tracks.length === 0)
1995
         return null;
2012
         return null;
1996
     return tracks[0].id;
2013
     return tracks[0].id;
1997
 };
2014
 };
1998
 
2015
 
2016
+/**
2017
+ * Returns id of the track.
2018
+ * @returns {string} id of the track or null if this is fake track.
2019
+ */
2020
+JitsiTrack.prototype.getId = function () {
2021
+    return RTC.getStreamID(this.stream);
2022
+};
2023
+
1999
 /**
2024
 /**
2000
  * Checks whether the MediaStream is avtive/not ended.
2025
  * Checks whether the MediaStream is avtive/not ended.
2001
  * When there is no check for active we don't have information and so
2026
  * When there is no check for active we don't have information and so
2247
     RTCUtils.stopMediaStream(mediaStream);
2272
     RTCUtils.stopMediaStream(mediaStream);
2248
 };
2273
 };
2249
 
2274
 
2275
+/**
2276
+ * Returns whether the desktop sharing is enabled or not.
2277
+ * @returns {boolean}
2278
+ */
2279
+RTC.isDesktopSharingEnabled = function () {
2280
+    return RTCUtils.isDesktopSharingEnabled();
2281
+}
2282
+
2250
 RTC.prototype.getVideoElementName = function () {
2283
 RTC.prototype.getVideoElementName = function () {
2251
     return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
2284
     return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
2252
 };
2285
 };
3105
                 var deviceGUM = {
3138
                 var deviceGUM = {
3106
                     "audio": GUM.bind(self, ["audio"]),
3139
                     "audio": GUM.bind(self, ["audio"]),
3107
                     "video": GUM.bind(self, ["video"]),
3140
                     "video": GUM.bind(self, ["video"]),
3108
-                    "desktop": screenObtainer.obtainStream
3141
+                    "desktop": screenObtainer.obtainStream.bind(screenObtainer)
3109
                 };
3142
                 };
3110
                 // With FF/IE we can't split the stream into audio and video because FF
3143
                 // With FF/IE we can't split the stream into audio and video because FF
3111
                 // doesn't support media stream constructors. So, we need to get the
3144
                 // doesn't support media stream constructors. So, we need to get the
3211
         if (mediaStream.stop) {
3244
         if (mediaStream.stop) {
3212
             mediaStream.stop();
3245
             mediaStream.stop();
3213
         }
3246
         }
3247
+    },
3248
+    /**
3249
+     * Returns whether the desktop sharing is enabled or not.
3250
+     * @returns {boolean}
3251
+     */
3252
+    isDesktopSharingEnabled: function () {
3253
+        return screenObtainer.isSupported();
3214
     }
3254
     }
3215
 
3255
 
3216
 };
3256
 };
6344
 
6384
 
6345
 ChatRoom.prototype.processNode = function (node, from) {
6385
 ChatRoom.prototype.processNode = function (node, from) {
6346
     if(this.presHandlers[node.tagName])
6386
     if(this.presHandlers[node.tagName])
6347
-        this.presHandlers[node.tagName](node, from);
6387
+        this.presHandlers[node.tagName](node, Strophe.getResourceFromJid(from));
6348
 };
6388
 };
6349
 
6389
 
6350
 ChatRoom.prototype.sendMessage = function (body, nickname) {
6390
 ChatRoom.prototype.sendMessage = function (body, nickname) {
6722
         reject(new Error("The conference is not created yet!"))});
6762
         reject(new Error("The conference is not created yet!"))});
6723
 }
6763
 }
6724
 
6764
 
6765
+/**
6766
+ * Returns true if the SIP calls are supported and false otherwise
6767
+ */
6768
+ChatRoom.prototype.isSIPCallingSupported = function () {
6769
+    if(this.moderator)
6770
+        return this.moderator.isSipGatewayEnabled();
6771
+    return false;
6772
+}
6773
+
6725
 /**
6774
 /**
6726
  * Dials a number.
6775
  * Dials a number.
6727
  * @param number the number
6776
  * @param number the number
9088
                     var msid = null;
9137
                     var msid = null;
9089
                     if(mline.media == "audio")
9138
                     if(mline.media == "audio")
9090
                     {
9139
                     {
9091
-                        msid = APP.RTC.localAudio.getId();
9140
+                        msid = APP.RTC.localAudio._getId();
9092
                     }
9141
                     }
9093
                     else
9142
                     else
9094
                     {
9143
                     {
9095
-                        msid = APP.RTC.localVideo.getId();
9144
+                        msid = APP.RTC.localVideo._getId();
9096
                     }
9145
                     }
9097
                     if(msid != null)
9146
                     if(msid != null)
9098
                     {
9147
                     {
9488
 
9537
 
9489
 module.exports = SDP;
9538
 module.exports = SDP;
9490
 
9539
 
9491
-
9492
 }).call(this,"/modules/xmpp/SDP.js")
9540
 }).call(this,"/modules/xmpp/SDP.js")
9493
 },{"./SDPUtil":32,"jitsi-meet-logger":48}],31:[function(require,module,exports){
9541
 },{"./SDPUtil":32,"jitsi-meet-logger":48}],31:[function(require,module,exports){
9494
 var SDPUtil = require("./SDPUtil");
9542
 var SDPUtil = require("./SDPUtil");
10521
     // Sip gateway can be enabled by configuring Jigasi host in config.js or
10569
     // Sip gateway can be enabled by configuring Jigasi host in config.js or
10522
     // it will be enabled automatically if focus detects the component through
10570
     // it will be enabled automatically if focus detects the component through
10523
     // service discovery.
10571
     // service discovery.
10524
-    this.sipGatewayEnabled =
10572
+    this.sipGatewayEnabled = this.xmppService.options.hosts &&
10525
         this.xmppService.options.hosts.call_control !== undefined;
10573
         this.xmppService.options.hosts.call_control !== undefined;
10526
 
10574
 
10527
     this.eventEmitter = emitter;
10575
     this.eventEmitter = emitter;

+ 2
- 2
modules/UI/UI.js Parādīt failu

396
 //     VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
396
 //     VideoLayout.setPresenceStatus(Strophe.getResourceFromJid(jid), info.status);
397
 // }
397
 // }
398
 
398
 
399
-UI.onPeerVideoTypeChanged = (resourceJid, newVideoType) => {
400
-    VideoLayout.onVideoTypeChanged(resourceJid, newVideoType);
399
+UI.onPeerVideoTypeChanged = (id, newVideoType) => {
400
+    VideoLayout.onVideoTypeChanged(id, newVideoType);
401
 };
401
 };
402
 
402
 
403
 UI.updateLocalRole = function (isModerator) {
403
 UI.updateLocalRole = function (isModerator) {

+ 12
- 6
modules/UI/videolayout/LargeVideo.js Parādīt failu

159
     constructor (onPlay) {
159
     constructor (onPlay) {
160
         super();
160
         super();
161
         this.stream = null;
161
         this.stream = null;
162
+        this.videoType = null;
162
 
163
 
163
         this.$avatar = $('#activeSpeaker');
164
         this.$avatar = $('#activeSpeaker');
164
         this.$wrapper = $('#largeVideoWrapper');
165
         this.$wrapper = $('#largeVideoWrapper');
180
 
181
 
181
     getVideoSize (containerWidth, containerHeight) {
182
     getVideoSize (containerWidth, containerHeight) {
182
         let { width, height } = this.getStreamSize();
183
         let { width, height } = this.getStreamSize();
183
-        if (this.stream && this.stream.isScreenSharing()) {
184
+        if (this.stream && this.isScreenSharing()) {
184
             return getDesktopVideoSize(width, height, containerWidth, containerHeight);
185
             return getDesktopVideoSize(width, height, containerWidth, containerHeight);
185
         } else {
186
         } else {
186
             return getCameraVideoSize(width, height, containerWidth, containerHeight);
187
             return getCameraVideoSize(width, height, containerWidth, containerHeight);
188
     }
189
     }
189
 
190
 
190
     getVideoPosition (width, height, containerWidth, containerHeight) {
191
     getVideoPosition (width, height, containerWidth, containerHeight) {
191
-        if (this.stream && this.stream.isScreenSharing()) {
192
+        if (this.stream && this.isScreenSharing()) {
192
             return getDesktopVideoPosition(width, height, containerWidth, containerHeight);
193
             return getDesktopVideoPosition(width, height, containerWidth, containerHeight);
193
         } else {
194
         } else {
194
             return getCameraVideoPosition(width, height, containerWidth, containerHeight);
195
             return getCameraVideoPosition(width, height, containerWidth, containerHeight);
218
         });
219
         });
219
     }
220
     }
220
 
221
 
221
-    setStream (stream) {
222
+    setStream (stream, videoType) {
222
         this.stream = stream;
223
         this.stream = stream;
224
+        this.videoType = videoType;
223
 
225
 
224
         stream.attach(this.$video);
226
         stream.attach(this.$video);
225
 
227
 
226
-        let flipX = stream.isLocal() && !stream.isScreenSharing();
228
+        let flipX = stream.isLocal() && !this.isScreenSharing();
227
         this.$video.css({
229
         this.$video.css({
228
             transform: flipX ? 'scaleX(-1)' : 'none'
230
             transform: flipX ? 'scaleX(-1)' : 'none'
229
         });
231
         });
230
     }
232
     }
231
 
233
 
234
+    isScreenSharing () {
235
+        return this.videoType === 'desktop';
236
+    }
237
+
232
     showAvatar (show) {
238
     showAvatar (show) {
233
         this.$avatar.css("visibility", show ? "visible" : "hidden");
239
         this.$avatar.css("visibility", show ? "visible" : "hidden");
234
     }
240
     }
332
         return this.videoContainer.id;
338
         return this.videoContainer.id;
333
     }
339
     }
334
 
340
 
335
-    updateLargeVideo (stream) {
341
+    updateLargeVideo (stream, videoType) {
336
         let id = getStreamId(stream);
342
         let id = getStreamId(stream);
337
 
343
 
338
         let container = this.getContainer(this.state);
344
         let container = this.getContainer(this.state);
340
         container.hide().then(() => {
346
         container.hide().then(() => {
341
             console.info("hover in %s", id);
347
             console.info("hover in %s", id);
342
             this.state = VideoContainerType;
348
             this.state = VideoContainerType;
343
-            this.videoContainer.setStream(stream);
349
+            this.videoContainer.setStream(stream, videoType);
344
             this.videoContainer.show();
350
             this.videoContainer.show();
345
         });
351
         });
346
     }
352
     }

+ 4
- 3
modules/UI/videolayout/VideoLayout.js Parādīt failu

153
         localVideoThumbnail.createConnectionIndicator();
153
         localVideoThumbnail.createConnectionIndicator();
154
 
154
 
155
         let localId = APP.conference.localId;
155
         let localId = APP.conference.localId;
156
-        this.onVideoTypeChanged(localId, stream.getType());
156
+        this.onVideoTypeChanged(localId, stream.videoType);
157
 
157
 
158
         let {thumbWidth, thumbHeight} = this.calculateThumbnailSize();
158
         let {thumbWidth, thumbHeight} = this.calculateThumbnailSize();
159
         AudioLevels.updateAudioLevelCanvas(null, thumbWidth, thumbHeight);
159
         AudioLevels.updateAudioLevelCanvas(null, thumbWidth, thumbHeight);
218
     electLastVisibleVideo () {
218
     electLastVisibleVideo () {
219
         // pick the last visible video in the row
219
         // pick the last visible video in the row
220
         // if nobody else is left, this picks the local video
220
         // if nobody else is left, this picks the local video
221
-        let thumbs = BottomToolbar.getThumbs(true).filter('id!="mixedstream"');
221
+        let thumbs = BottomToolbar.getThumbs(true).filter('[id!="mixedstream"]');
222
 
222
 
223
         let lastVisible = thumbs.filter(':visible:last');
223
         let lastVisible = thumbs.filter(':visible:last');
224
         if (lastVisible.length) {
224
         if (lastVisible.length) {
973
 
973
 
974
             let smallVideo = this.getSmallVideo(id);
974
             let smallVideo = this.getSmallVideo(id);
975
 
975
 
976
-            largeVideo.updateLargeVideo(smallVideo.stream);
976
+            let videoType = this.getRemoteVideoType(id);
977
+            largeVideo.updateLargeVideo(smallVideo.stream, videoType);
977
 
978
 
978
             smallVideo.enableDominantSpeaker(true);
979
             smallVideo.enableDominantSpeaker(true);
979
         } else if (currentId) {
980
         } else if (currentId) {

+ 29
- 14
modules/desktopsharing/desktopsharing.js Parādīt failu

1
-/* global APP, config */
1
+/* global APP, JitsiMeetJS, config */
2
 var EventEmitter = require("events");
2
 var EventEmitter = require("events");
3
 var DesktopSharingEventTypes
3
 var DesktopSharingEventTypes
4
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
4
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
5
 
5
 
6
+const TrackEvents = JitsiMeetJS.events.track;
7
+
6
 /**
8
 /**
7
  * Indicates that desktop stream is currently in use (for toggle purpose).
9
  * Indicates that desktop stream is currently in use (for toggle purpose).
8
  * @type {boolean}
10
  * @type {boolean}
35
         track, streamSwitchDone);
37
         track, streamSwitchDone);
36
 }
38
 }
37
 
39
 
38
-function getVideoStreamFailed(error) {
39
-    console.error("Failed to obtain the stream to switch to", error);
40
+function getVideoStreamFailed() {
41
+    console.error("Failed to obtain the stream to switch to");
40
     switchInProgress = false;
42
     switchInProgress = false;
41
     isUsingScreenStream = false;
43
     isUsingScreenStream = false;
42
     newStreamCreated(null);
44
     newStreamCreated(null);
43
 }
45
 }
44
 
46
 
45
-function getDesktopStreamFailed(error) {
46
-    console.error("Failed to obtain the stream to switch to", error);
47
+function getDesktopStreamFailed() {
48
+    console.error("Failed to obtain the stream to switch to");
47
     switchInProgress = false;
49
     switchInProgress = false;
48
 }
50
 }
49
 
51
 
92
             return;
94
             return;
93
         }
95
         }
94
         switchInProgress = true;
96
         switchInProgress = true;
95
-        let type, handler;
97
+        let type;
96
         if (!isUsingScreenStream) {
98
         if (!isUsingScreenStream) {
97
             // Switch to desktop stream
99
             // Switch to desktop stream
98
-            handler = onEndedHandler;
99
             type = "desktop";
100
             type = "desktop";
100
         } else {
101
         } else {
101
-            handler = () => {};
102
             type = "video";
102
             type = "video";
103
         }
103
         }
104
-        APP.conference.createVideoTrack(type, handler).then(
105
-            (tracks) => {
106
-                // We now use screen stream
107
-                isUsingScreenStream = type === "desktop";
108
-                newStreamCreated(tracks[0]);
109
-            }).catch(getDesktopStreamFailed);
104
+        APP.createLocalTracks(type).then(function (tracks) {
105
+            if (!tracks.length) {
106
+                if (type === 'desktop') {
107
+                    getDesktopStreamFailed();
108
+                } else {
109
+                    getVideoStreamFailed();
110
+                }
111
+
112
+                return;
113
+            }
114
+
115
+            let stream = tracks[0];
116
+
117
+            // We now use screen stream
118
+            isUsingScreenStream = type === "desktop";
119
+            if (isUsingScreenStream) {
120
+                stream.on(TrackEvents.TRACK_STOPPED, onEndedHandler);
121
+            }
122
+
123
+            newStreamCreated(stream);
124
+        });
110
     },
125
     },
111
     /*
126
     /*
112
      * Exports the event emitter to allow use by ScreenObtainer. Not for outside
127
      * Exports the event emitter to allow use by ScreenObtainer. Not for outside

Notiek ielāde…
Atcelt
Saglabāt