소스 검색

Implements create local streams.

dev1
hristoterezov 10 년 전
부모
커밋
3416086dc2
7개의 변경된 파일1001개의 추가작업 그리고 526개의 파일을 삭제
  1. 2
    2
      JitsiConference.js
  2. 1
    1
      JitsiMeetJS.js
  3. 901
    426
      lib-jitsi-meet.js
  4. 7
    6
      modules/RTC/LocalStream.js
  5. 11
    10
      modules/RTC/RTC.js
  6. 79
    80
      modules/RTC/RTCUtils.js
  7. 0
    1
      modules/xmpp/JingleSessionPC.js

+ 2
- 2
JitsiConference.js 파일 보기

28
  */
28
  */
29
 JitsiConference.prototype.join = function (password) {
29
 JitsiConference.prototype.join = function (password) {
30
 
30
 
31
-    this.room.joinRoom(password);
31
+    this.room.join(password);
32
 }
32
 }
33
 
33
 
34
 /**
34
 /**
47
  *     or a JitsiConferenceError if rejected.
47
  *     or a JitsiConferenceError if rejected.
48
  */
48
  */
49
 JitsiConference.prototype.createLocalTracks = function (options) {
49
 JitsiConference.prototype.createLocalTracks = function (options) {
50
-    this.rtc.obtainAudioAndVideoPermissions();
50
+    return this.rtc.obtainAudioAndVideoPermissions(options || {});
51
 }
51
 }
52
 
52
 
53
 /**
53
 /**

+ 1
- 1
JitsiMeetJS.js 파일 보기

22
 }
22
 }
23
 
23
 
24
 //Setups the promise object.
24
 //Setups the promise object.
25
-require("es6-promise").polyfill();
25
+window.Promise = window.Promise || require("es6-promise").polyfill();
26
 
26
 
27
 module.exports = LibJitsiMeet;
27
 module.exports = LibJitsiMeet;

+ 901
- 426
lib-jitsi-meet.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 7
- 6
modules/RTC/LocalStream.js 파일 보기

20
     };
20
     };
21
 }
21
 }
22
 
22
 
23
-function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
23
+function LocalStream(RTC, stream, type, eventEmitter, videoType, isGUMStream) {
24
+    this.rtc = RTC;
24
     this.stream = stream;
25
     this.stream = stream;
25
     this.eventEmitter = eventEmitter;
26
     this.eventEmitter = eventEmitter;
26
     this.type = type;
27
     this.type = type;
82
             this.eventEmitter.emit(eventType, true);
83
             this.eventEmitter.emit(eventType, true);
83
         } else {
84
         } else {
84
             var self = this;
85
             var self = this;
85
-            APP.RTC.rtcUtils.obtainAudioAndVideoPermissions(
86
-                (this.isAudioStream() ? ["audio"] : ["video"]),
87
-                function (stream) {
86
+            this.rtcUtils.obtainAudioAndVideoPermissions(
87
+                (this.isAudioStream() ? ["audio"] : ["video"]))
88
+                .then(function (stream) {
88
                     if (isAudio) {
89
                     if (isAudio) {
89
-                        APP.RTC.changeLocalAudio(stream,
90
+                        self.rtc.changeLocalAudio(stream,
90
                             function () {
91
                             function () {
91
                                 self.eventEmitter.emit(eventType, false);
92
                                 self.eventEmitter.emit(eventType, false);
92
                             });
93
                             });
93
                     } else {
94
                     } else {
94
-                        APP.RTC.changeLocalVideo(stream, false,
95
+                        self.rtc.changeLocalVideo(stream, false,
95
                             function () {
96
                             function () {
96
                                 self.eventEmitter.emit(eventType, false);
97
                                 self.eventEmitter.emit(eventType, false);
97
                             });
98
                             });

+ 11
- 10
modules/RTC/RTC.js 파일 보기

42
 }
42
 }
43
 
43
 
44
 
44
 
45
-function RTC()
45
+function RTC(options)
46
 {
46
 {
47
     this.rtcUtils = null;
47
     this.rtcUtils = null;
48
     this.devices = {
48
     this.devices = {
55
     this.localVideo = null;
55
     this.localVideo = null;
56
     this.eventEmitter = new EventEmitter();
56
     this.eventEmitter = new EventEmitter();
57
     var self = this;
57
     var self = this;
58
+    this.options = options || {};
58
     desktopsharing.addListener(
59
     desktopsharing.addListener(
59
         function (stream, isUsingScreenStream, callback) {
60
         function (stream, isUsingScreenStream, callback) {
60
             self.changeLocalVideo(stream, isUsingScreenStream, callback);
61
             self.changeLocalVideo(stream, isUsingScreenStream, callback);
75
     }
76
     }
76
 }
77
 }
77
 
78
 
78
-RTC.prototype.obtainAudioAndVideoPermissions = function () {
79
-    this.rtcUtils.obtainAudioAndVideoPermissions(
80
-        null, null, getMediaStreamUsage());
79
+RTC.prototype.obtainAudioAndVideoPermissions = function (options) {
80
+    return this.rtcUtils.obtainAudioAndVideoPermissions(
81
+        null, getMediaStreamUsage(), options.resolution);
81
 }
82
 }
82
 
83
 
83
 RTC.prototype.onIncommingCall = function(event) {
84
 RTC.prototype.onIncommingCall = function(event) {
109
 
110
 
110
 RTC.prototype.createLocalStreams = function (streams, change) {
111
 RTC.prototype.createLocalStreams = function (streams, change) {
111
     for (var i = 0; i < streams.length; i++) {
112
     for (var i = 0; i < streams.length; i++) {
112
-        var localStream = new LocalStream(streams.stream,
113
-            streams.type, this.eventEmitter, streams.videoType,
114
-            streams.isGUMStream);
113
+        var localStream = new LocalStream(this, streams[i].stream,
114
+            streams[i].type, this.eventEmitter, streams[i].videoType,
115
+            streams[i].isGUMStream);
115
         this.localStreams.push(localStream);
116
         this.localStreams.push(localStream);
116
-        if (streams.isMuted === true)
117
+        if (streams[i].isMuted === true)
117
             localStream.setMute(true);
118
             localStream.setMute(true);
118
 
119
 
119
-        if (streams.type == "audio") {
120
+        if (streams[i].type == "audio") {
120
             this.localAudio = localStream;
121
             this.localAudio = localStream;
121
         } else {
122
         } else {
122
             this.localVideo = localStream;
123
             this.localVideo = localStream;
125
         if (change)
126
         if (change)
126
             eventType = StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED;
127
             eventType = StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED;
127
 
128
 
128
-        this.eventEmitter.emit(eventType, localStream, streams.isMuted);
129
+        this.eventEmitter.emit(eventType, localStream, streams[i].isMuted);
129
     }
130
     }
130
     return this.localStreams;
131
     return this.localStreams;
131
 };
132
 };

+ 79
- 80
modules/RTC/RTCUtils.js 파일 보기

135
 }
135
 }
136
 
136
 
137
 //Options parameter is to pass config options. Currently uses only "useIPv6".
137
 //Options parameter is to pass config options. Currently uses only "useIPv6".
138
-function RTCUtils(RTCService, onTemasysPluginReady, options)
138
+function RTCUtils(RTCService, onTemasysPluginReady)
139
 {
139
 {
140
     var self = this;
140
     var self = this;
141
     this.service = RTCService;
141
     this.service = RTCService;
209
         };
209
         };
210
         // DTLS should now be enabled by default but..
210
         // DTLS should now be enabled by default but..
211
         this.pc_constraints = {'optional': [{'DtlsSrtpKeyAgreement': 'true'}]};
211
         this.pc_constraints = {'optional': [{'DtlsSrtpKeyAgreement': 'true'}]};
212
-        if (options.useIPv6) {
212
+        if (this.service.options.useIPv6) {
213
             // https://code.google.com/p/webrtc/issues/detail?id=2828
213
             // https://code.google.com/p/webrtc/issues/detail?id=2828
214
             this.pc_constraints.optional.push({googIPv6: true});
214
             this.pc_constraints.optional.push({googIPv6: true});
215
         }
215
         }
340
  * not to ask twice.
340
  * not to ask twice.
341
  */
341
  */
342
 RTCUtils.prototype.obtainAudioAndVideoPermissions =
342
 RTCUtils.prototype.obtainAudioAndVideoPermissions =
343
-    function(devices, callback, usageOptions)
343
+    function(devices, usageOptions, resolution)
344
 {
344
 {
345
     var self = this;
345
     var self = this;
346
     // Get AV
346
     // Get AV
347
 
347
 
348
-    var successCallback = function (stream) {
349
-        if(callback)
350
-            callback(stream, usageOptions);
351
-        else
352
-            self.successCallback(stream, usageOptions);
353
-    };
348
+    return new Promise(function(resolve, reject) {
349
+        var successCallback = function (stream) {
350
+            resolve(self.successCallback(stream, usageOptions));
351
+        };
354
 
352
 
355
-    if(!devices)
356
-        devices = ['audio', 'video'];
353
+        if (!devices)
354
+            devices = ['audio', 'video'];
357
 
355
 
358
-    var newDevices = [];
356
+        var newDevices = [];
359
 
357
 
360
 
358
 
361
-    if(usageOptions)
362
-        for(var i = 0; i < devices.length; i++) {
363
-            var device = devices[i];
364
-            if(usageOptions[device] === true)
365
-                newDevices.push(device);
366
-        }
367
-    else
368
-        newDevices = devices;
359
+        if (usageOptions)
360
+            for (var i = 0; i < devices.length; i++) {
361
+                var device = devices[i];
362
+                if (usageOptions[device] === true)
363
+                    newDevices.push(device);
364
+            }
365
+        else
366
+            newDevices = devices;
369
 
367
 
370
-    if(newDevices.length === 0) {
371
-        successCallback();
372
-        return;
373
-    }
368
+        if (newDevices.length === 0) {
369
+            successCallback();
370
+            return;
371
+        }
374
 
372
 
375
-    if (RTCBrowserType.isFirefox() || RTCBrowserType.isTemasysPluginUsed()) {
376
-
377
-        // With FF/IE we can't split the stream into audio and video because FF
378
-        // doesn't support media stream constructors. So, we need to get the
379
-        // audio stream separately from the video stream using two distinct GUM
380
-        // calls. Not very user friendly :-( but we don't have many other
381
-        // options neither.
382
-        //
383
-        // Note that we pack those 2 streams in a single object and pass it to
384
-        // the successCallback method.
385
-        var obtainVideo = function (audioStream) {
386
-            self.getUserMediaWithConstraints(
387
-                ['video'],
388
-                function (videoStream) {
389
-                    return successCallback({
390
-                        audioStream: audioStream,
391
-                        videoStream: videoStream
392
-                    });
373
+        if (RTCBrowserType.isFirefox() || RTCBrowserType.isTemasysPluginUsed()) {
374
+
375
+            // With FF/IE we can't split the stream into audio and video because FF
376
+            // doesn't support media stream constructors. So, we need to get the
377
+            // audio stream separately from the video stream using two distinct GUM
378
+            // calls. Not very user friendly :-( but we don't have many other
379
+            // options neither.
380
+            //
381
+            // Note that we pack those 2 streams in a single object and pass it to
382
+            // the successCallback method.
383
+            var obtainVideo = function (audioStream) {
384
+                self.getUserMediaWithConstraints(
385
+                    ['video'],
386
+                    function (videoStream) {
387
+                        return successCallback({
388
+                            audioStream: audioStream,
389
+                            videoStream: videoStream
390
+                        });
391
+                    },
392
+                    function (error) {
393
+                        console.error(
394
+                            'failed to obtain video stream - stop', error);
395
+                        self.errorCallback(error, resolve);
396
+                    },
397
+                        config.resolution || '360');
398
+            };
399
+            var obtainAudio = function () {
400
+                self.getUserMediaWithConstraints(
401
+                    ['audio'],
402
+                    function (audioStream) {
403
+                        if (newDevices.indexOf('video') !== -1)
404
+                            obtainVideo(audioStream);
405
+                    },
406
+                    function (error) {
407
+                        console.error(
408
+                            'failed to obtain audio stream - stop', error);
409
+                        self.errorCallback(error, resolve);
410
+                    }
411
+                );
412
+            };
413
+            if (newDevices.indexOf('audio') !== -1) {
414
+                obtainAudio();
415
+            } else {
416
+                obtainVideo(null);
417
+            }
418
+        } else {
419
+            this.getUserMediaWithConstraints(
420
+                newDevices,
421
+                function (stream) {
422
+                    successCallback(stream);
393
                 },
423
                 },
394
                 function (error) {
424
                 function (error) {
395
-                    console.error(
396
-                        'failed to obtain video stream - stop', error);
397
-                    self.errorCallback(error);
398
-                },
399
-                config.resolution || '360');
400
-        };
401
-        var obtainAudio = function () {
402
-            self.getUserMediaWithConstraints(
403
-                ['audio'],
404
-                function (audioStream) {
405
-                    if (newDevices.indexOf('video') !== -1)
406
-                        obtainVideo(audioStream);
425
+                    self.errorCallback(error, resolve);
407
                 },
426
                 },
408
-                function (error) {
409
-                    console.error(
410
-                        'failed to obtain audio stream - stop', error);
411
-                    self.errorCallback(error);
412
-                }
413
-            );
414
-        };
415
-        if (newDevices.indexOf('audio') !== -1) {
416
-            obtainAudio();
417
-        } else {
418
-            obtainVideo(null);
427
+                resolution || '360');
419
         }
428
         }
420
-    } else {
421
-        this.getUserMediaWithConstraints(
422
-        newDevices,
423
-        function (stream) {
424
-            successCallback(stream);
425
-        },
426
-        function (error) {
427
-            self.errorCallback(error);
428
-        },
429
-        config.resolution || '360');
430
-    }
429
+    }.bind(this));
431
 };
430
 };
432
 
431
 
433
 RTCUtils.prototype.successCallback = function (stream, usageOptions) {
432
 RTCUtils.prototype.successCallback = function (stream, usageOptions) {
439
     return this.handleLocalStream(stream, usageOptions);
438
     return this.handleLocalStream(stream, usageOptions);
440
 };
439
 };
441
 
440
 
442
-RTCUtils.prototype.errorCallback = function (error) {
441
+RTCUtils.prototype.errorCallback = function (error, resolve) {
443
     var self = this;
442
     var self = this;
444
     console.error('failed to obtain audio/video stream - trying audio only', error);
443
     console.error('failed to obtain audio/video stream - trying audio only', error);
445
     var resolution = getPreviousResolution(currentResolution);
444
     var resolution = getPreviousResolution(currentResolution);
452
     {
451
     {
453
         self.getUserMediaWithConstraints(['audio', 'video'],
452
         self.getUserMediaWithConstraints(['audio', 'video'],
454
             function (stream) {
453
             function (stream) {
455
-                return self.successCallback(stream);
454
+                resolve(self.successCallback(stream));
456
             }, function (error) {
455
             }, function (error) {
457
                 return self.errorCallback(error);
456
                 return self.errorCallback(error);
458
             }, resolution);
457
             }, resolution);
461
         self.getUserMediaWithConstraints(
460
         self.getUserMediaWithConstraints(
462
             ['audio'],
461
             ['audio'],
463
             function (stream) {
462
             function (stream) {
464
-                return self.successCallback(stream);
463
+                resolve(self.successCallback(stream));
465
             },
464
             },
466
             function (error) {
465
             function (error) {
467
                 console.error('failed to obtain audio/video stream - stop',
466
                 console.error('failed to obtain audio/video stream - stop',
468
                     error);
467
                     error);
469
-                return self.successCallback(null);
468
+                resolve(self.successCallback(null));
470
             }
469
             }
471
         );
470
         );
472
     }
471
     }

+ 0
- 1
modules/xmpp/JingleSessionPC.js 파일 보기

9
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
9
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
10
 var RTCBrowserType = require("../RTC/RTCBrowserType");
10
 var RTCBrowserType = require("../RTC/RTCBrowserType");
11
 var SSRCReplacement = require("./LocalSSRCReplacement");
11
 var SSRCReplacement = require("./LocalSSRCReplacement");
12
-var RTC = require("../RTC/RTC");
13
 
12
 
14
 // Jingle stuff
13
 // Jingle stuff
15
 function JingleSessionPC(me, sid, connection, service, eventEmitter) {
14
 function JingleSessionPC(me, sid, connection, service, eventEmitter) {

Loading…
취소
저장