소스 검색

More formatting fixes.

j8
Boris Grozev 9 년 전
부모
커밋
2c790f86ad
6개의 변경된 파일81개의 추가작업 그리고 121개의 파일을 삭제
  1. 15
    33
      modules/RTC/DataChannels.js
  2. 13
    26
      modules/RTC/LocalStream.js
  3. 2
    6
      modules/RTC/MediaStream.js
  4. 7
    10
      modules/RTC/RTC.js
  5. 2
    2
      modules/RTC/RTCBrowserType.js
  6. 42
    44
      modules/RTC/RTCUtils.js

+ 15
- 33
modules/RTC/DataChannels.js 파일 보기

@@ -1,4 +1,4 @@
1
-/* global Strophe, focusedVideoSrc*/
1
+/* global config, APP, Strophe */
2 2
 
3 3
 // cache datachannels to avoid garbage collection
4 4
 // https://code.google.com/p/chromium/issues/detail?id=405545
@@ -8,19 +8,13 @@ var _dataChannels = [];
8 8
 var eventEmitter = null;
9 9
 
10 10
 
11
-
12
-
13
-var DataChannels =
14
-{
15
-
11
+var DataChannels = {
16 12
     /**
17 13
      * Callback triggered by PeerConnection when new data channel is opened
18 14
      * on the bridge.
19 15
      * @param event the event info object.
20 16
      */
21
-
22
-    onDataChannel: function (event)
23
-    {
17
+    onDataChannel: function (event) {
24 18
         var dataChannel = event.channel;
25 19
 
26 20
         dataChannel.onopen = function () {
@@ -65,8 +59,7 @@ var DataChannels =
65 59
                         dominantSpeakerEndpoint);
66 60
                     eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
67 61
                 }
68
-                else if ("InLastNChangeEvent" === colibriClass)
69
-                {
62
+                else if ("InLastNChangeEvent" === colibriClass) {
70 63
                     var oldValue = obj.oldValue;
71 64
                     var newValue = obj.newValue;
72 65
                     // Make sure that oldValue and newValue are of type boolean.
@@ -89,15 +82,13 @@ var DataChannels =
89 82
 
90 83
                     eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
91 84
                 }
92
-                else if ("LastNEndpointsChangeEvent" === colibriClass)
93
-                {
85
+                else if ("LastNEndpointsChangeEvent" === colibriClass) {
94 86
                     // The new/latest list of last-n endpoint IDs.
95 87
                     var lastNEndpoints = obj.lastNEndpoints;
96 88
                     // The list of endpoint IDs which are entering the list of
97 89
                     // last-n at this time i.e. were not in the old list of last-n
98 90
                     // endpoint IDs.
99 91
                     var endpointsEnteringLastN = obj.endpointsEnteringLastN;
100
-                    var stream = obj.stream;
101 92
 
102 93
                     console.log(
103 94
                         "Data channel new last-n event: ",
@@ -105,15 +96,13 @@ var DataChannels =
105 96
                     eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
106 97
                         lastNEndpoints, endpointsEnteringLastN, obj);
107 98
                 }
108
-                else
109
-                {
99
+                else {
110 100
                     console.debug("Data channel JSON-formatted message: ", obj);
111 101
                 }
112 102
             }
113 103
         };
114 104
 
115
-        dataChannel.onclose = function ()
116
-        {
105
+        dataChannel.onclose = function () {
117 106
             console.info("The Data Channel closed", dataChannel);
118 107
             var idx = _dataChannels.indexOf(dataChannel);
119 108
             if (idx > -1)
@@ -158,19 +147,15 @@ var DataChannels =
158 147
     },
159 148
     handleSelectedEndpointEvent: onSelectedEndpointChanged,
160 149
     handlePinnedEndpointEvent: onPinnedEndpointChanged
161
-
162 150
 };
163 151
 
164
-function onSelectedEndpointChanged(userResource)
165
-{
152
+function onSelectedEndpointChanged(userResource) {
166 153
     console.log('selected endpoint changed: ', userResource);
167
-    if (_dataChannels && _dataChannels.length != 0)
168
-    {
154
+    if (_dataChannels && _dataChannels.length != 0) {
169 155
         _dataChannels.some(function (dataChannel) {
170
-            if (dataChannel.readyState == 'open')
171
-            {
172
-                console.log('sending selected endpoint changed ' 
173
-                    + 'notification to the bridge: ', userResource);
156
+            if (dataChannel.readyState == 'open') {
157
+                console.log('sending selected endpoint changed ' +
158
+                    'notification to the bridge: ', userResource);
174 159
                 dataChannel.send(JSON.stringify({
175 160
                     'colibriClass': 'SelectedEndpointChangedEvent',
176 161
                     'selectedEndpoint':
@@ -184,14 +169,11 @@ function onSelectedEndpointChanged(userResource)
184 169
     }
185 170
 }
186 171
 
187
-function onPinnedEndpointChanged(userResource)
188
-{
172
+function onPinnedEndpointChanged(userResource) {
189 173
     console.log('pinned endpoint changed: ', userResource);
190
-    if (_dataChannels && _dataChannels.length != 0)
191
-    {
174
+    if (_dataChannels && _dataChannels.length != 0) {
192 175
         _dataChannels.some(function (dataChannel) {
193
-            if (dataChannel.readyState == 'open')
194
-            {
176
+            if (dataChannel.readyState == 'open') {
195 177
                 dataChannel.send(JSON.stringify({
196 178
                     'colibriClass': 'PinnedEndpointChangedEvent',
197 179
                     'pinnedEndpoint':

+ 13
- 26
modules/RTC/LocalStream.js 파일 보기

@@ -1,9 +1,8 @@
1
+/* global APP */
1 2
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
2 3
 var RTCEvents = require("../../service/RTC/RTCEvents");
3 4
 
4
-
5
-function LocalStream(stream, type, eventEmitter, videoType, isGUMStream)
6
-{
5
+function LocalStream(stream, type, eventEmitter, videoType, isGUMStream) {
7 6
     this.stream = stream;
8 7
     this.eventEmitter = eventEmitter;
9 8
     this.type = type;
@@ -12,33 +11,29 @@ function LocalStream(stream, type, eventEmitter, videoType, isGUMStream)
12 11
     if(isGUMStream === false)
13 12
         this.isGUMStream = isGUMStream;
14 13
     var self = this;
15
-    if(type == "audio")
16
-    {
14
+    if(type == "audio") {
17 15
         this.getTracks = function () {
18 16
             return self.stream.getAudioTracks();
19 17
         };
20
-    }
21
-    else
22
-    {
18
+    } else {
23 19
         this.getTracks = function () {
24 20
             return self.stream.getVideoTracks();
25 21
         };
26 22
     }
27 23
 
28
-    this.stream.onended = function()
29
-    {
24
+    this.stream.onended = function() {
30 25
         self.streamEnded();
31 26
     };
32 27
 }
33 28
 
34 29
 LocalStream.prototype.streamEnded = function () {
35 30
     this.eventEmitter.emit(StreamEventTypes.EVENT_TYPE_LOCAL_ENDED, this);
36
-}
31
+};
37 32
 
38 33
 LocalStream.prototype.getOriginalStream = function()
39 34
 {
40 35
     return this.stream;
41
-}
36
+};
42 37
 
43 38
 LocalStream.prototype.isAudioStream = function () {
44 39
     return this.type === "audio";
@@ -50,37 +45,29 @@ LocalStream.prototype.setMute = function (mute)
50 45
     var eventType = isAudio ? RTCEvents.AUDIO_MUTE : RTCEvents.VIDEO_MUTE;
51 46
 
52 47
     if ((window.location.protocol != "https:" && this.isGUMStream) ||
53
-        (isAudio && this.isGUMStream) || this.videoType === "screen")
54
-    {
48
+        (isAudio && this.isGUMStream) || this.videoType === "screen") {
55 49
         var tracks = this.getTracks();
56 50
 
57 51
         for (var idx = 0; idx < tracks.length; idx++) {
58 52
             tracks[idx].enabled = !mute;
59 53
         }
60 54
         this.eventEmitter.emit(eventType, mute);
61
-    }
62
-    else
63
-    {
55
+    } else {
64 56
         if (mute) {
65 57
             APP.xmpp.removeStream(this.stream);
66 58
             this.stream.stop();
67 59
             this.eventEmitter.emit(eventType, true);
68
-        }
69
-        else
70
-        {
60
+        } else {
71 61
             var self = this;
72 62
             APP.RTC.rtcUtils.obtainAudioAndVideoPermissions(
73 63
                 (this.isAudioStream() ? ["audio"] : ["video"]),
74 64
                 function (stream) {
75
-                    if (isAudio)
76
-                    {
65
+                    if (isAudio) {
77 66
                         APP.RTC.changeLocalAudio(stream,
78 67
                             function () {
79 68
                                 self.eventEmitter.emit(eventType, false);
80 69
                             });
81
-                    }
82
-                    else
83
-                    {
70
+                    } else {
84 71
                         APP.RTC.changeLocalVideo(stream, false,
85 72
                             function () {
86 73
                                 self.eventEmitter.emit(eventType, false);
@@ -109,6 +96,6 @@ LocalStream.prototype.isMuted = function () {
109 96
 
110 97
 LocalStream.prototype.getId = function () {
111 98
     return this.stream.getTracks()[0].id;
112
-}
99
+};
113 100
 
114 101
 module.exports = LocalStream;

+ 2
- 6
modules/RTC/MediaStream.js 파일 보기

@@ -1,6 +1,4 @@
1
-////These lines should be uncommented when require works in app.js
2 1
 var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
3
-var StreamEventType = require("../../service/RTC/StreamEventTypes");
4 2
 
5 3
 /**
6 4
  * Creates a MediaStream object for the given data, session id and ssrc.
@@ -37,13 +35,11 @@ function MediaStream(data, sid, ssrc, browser, eventEmitter) {
37 35
 }
38 36
 
39 37
 
40
-MediaStream.prototype.getOriginalStream = function()
41
-{
38
+MediaStream.prototype.getOriginalStream = function() {
42 39
     return this.stream;
43 40
 };
44 41
 
45
-MediaStream.prototype.setMute = function (value)
46
-{
42
+MediaStream.prototype.setMute = function (value) {
47 43
     this.stream.muted = value;
48 44
     this.muted = value;
49 45
 };

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

@@ -1,3 +1,4 @@
1
+/* global APP */
1 2
 var EventEmitter = require("events");
2 3
 var RTCBrowserType = require("./RTCBrowserType");
3 4
 var RTCUtils = require("./RTCUtils.js");
@@ -87,8 +88,7 @@ var RTC = {
87 88
         return localStream;
88 89
     },
89 90
     removeLocalStream: function (stream) {
90
-        for(var i = 0; i < this.localStreams.length; i++)
91
-        {
91
+        for(var i = 0; i < this.localStreams.length; i++) {
92 92
             if(this.localStreams[i].getOriginalStream() === stream) {
93 93
                 delete this.localStreams[i];
94 94
                 return;
@@ -173,8 +173,7 @@ var RTC = {
173 173
         var stream;
174 174
 
175 175
         if(this.remoteStreams[jid] &&
176
-            this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE])
177
-        {
176
+            this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
178 177
             stream = this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
179 178
         }
180 179
 
@@ -201,8 +200,7 @@ var RTC = {
201 200
         var oldStream = this.localVideo.getOriginalStream();
202 201
         var type = (isUsingScreenStream? "screen" : "video");
203 202
         var localCallback = callback;
204
-        if(this.localVideo.isMuted() && this.localVideo.videoType !== type)
205
-        {
203
+        if(this.localVideo.isMuted() && this.localVideo.videoType !== type) {
206 204
             localCallback = function() {
207 205
                 APP.xmpp.setVideoMute(false, function(mute) {
208 206
                     eventEmitter.emit(RTCEvents.VIDEO_MUTE, mute);
@@ -236,10 +234,9 @@ var RTC = {
236 234
         if (jid === APP.xmpp.myJid()) {
237 235
             var localVideo = APP.RTC.localVideo;
238 236
             return (!localVideo || localVideo.isMuted());
239
-        }
240
-        else
241
-        {
242
-            if (!APP.RTC.remoteStreams[jid] || !APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
237
+        } else {
238
+            if (!APP.RTC.remoteStreams[jid] ||
239
+                !APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
243 240
                 return null;
244 241
             }
245 242
             return APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE].muted;

+ 2
- 2
modules/RTC/RTCBrowserType.js 파일 보기

@@ -49,8 +49,8 @@ var RTCBrowserType = {
49 49
     },
50 50
 
51 51
     usesPlanB: function() {
52
-        return RTCBrowserType.isChrome() || RTCBrowserType.isOpera()
53
-            || RTCBrowserType.isTemasysPluginUsed();
52
+        return RTCBrowserType.isChrome() || RTCBrowserType.isOpera() ||
53
+            RTCBrowserType.isTemasysPluginUsed();
54 54
     },
55 55
 
56 56
     usesUnifiedPlan: function() {

+ 42
- 44
modules/RTC/RTCUtils.js 파일 보기

@@ -1,3 +1,4 @@
1
+/* global config, require, attachMediaStream, getUserMedia */
1 2
 var RTCBrowserType = require("./RTCBrowserType");
2 3
 var Resolutions = require("../../service/RTC/Resolutions");
3 4
 var AdapterJS = require("./adapter.screenshare");
@@ -11,11 +12,9 @@ function getPreviousResolution(resolution) {
11 12
     var order = Resolutions[resolution].order;
12 13
     var res = null;
13 14
     var resName = null;
14
-    for(var i in Resolutions)
15
-    {
15
+    for(var i in Resolutions) {
16 16
         var tmp = Resolutions[i];
17
-        if(res == null || (res.order < tmp.order && tmp.order < order))
18
-        {
17
+        if(res == null || (res.order < tmp.order && tmp.order < order)) {
19 18
             resName = i;
20 19
             res = tmp;
21 20
         }
@@ -23,19 +22,17 @@ function getPreviousResolution(resolution) {
23 22
     return resName;
24 23
 }
25 24
 
26
-function setResolutionConstraints(constraints, resolution, isAndroid)
27
-{
25
+function setResolutionConstraints(constraints, resolution, isAndroid) {
28 26
     if (resolution && !constraints.video || isAndroid) {
29
-        constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
27
+        // same behaviour as true
28
+        constraints.video = { mandatory: {}, optional: [] };
30 29
     }
31 30
 
32
-    if(Resolutions[resolution])
33
-    {
31
+    if(Resolutions[resolution]) {
34 32
         constraints.video.mandatory.minWidth = Resolutions[resolution].width;
35 33
         constraints.video.mandatory.minHeight = Resolutions[resolution].height;
36 34
     }
37
-    else
38
-    {
35
+    else {
39 36
         if (isAndroid) {
40 37
             constraints.video.mandatory.minWidth = 320;
41 38
             constraints.video.mandatory.minHeight = 240;
@@ -44,9 +41,11 @@ function setResolutionConstraints(constraints, resolution, isAndroid)
44 41
     }
45 42
 
46 43
     if (constraints.video.mandatory.minWidth)
47
-        constraints.video.mandatory.maxWidth = constraints.video.mandatory.minWidth;
44
+        constraints.video.mandatory.maxWidth =
45
+            constraints.video.mandatory.minWidth;
48 46
     if (constraints.video.mandatory.minHeight)
49
-        constraints.video.mandatory.maxHeight = constraints.video.mandatory.minHeight;
47
+        constraints.video.mandatory.maxHeight =
48
+            constraints.video.mandatory.minHeight;
50 49
 }
51 50
 
52 51
 function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid)
@@ -54,10 +53,12 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
54 53
     var constraints = {audio: false, video: false};
55 54
 
56 55
     if (um.indexOf('video') >= 0) {
57
-        constraints.video = { mandatory: {}, optional: [] };// same behaviour as true
56
+        // same behaviour as true
57
+        constraints.video = { mandatory: {}, optional: [] };
58 58
     }
59 59
     if (um.indexOf('audio') >= 0) {
60
-        constraints.audio = { mandatory: {}, optional: []};// same behaviour as true
60
+        // same behaviour as true
61
+        constraints.audio = { mandatory: {}, optional: []};
61 62
     }
62 63
     if (um.indexOf('screen') >= 0) {
63 64
         if (RTCBrowserType.isChrome()) {
@@ -126,13 +127,20 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
126 127
         setResolutionConstraints(constraints, resolution, isAndroid);
127 128
     }
128 129
 
129
-    if (bandwidth) { // doesn't work currently, see webrtc issue 1846
130
-        if (!constraints.video) constraints.video = {mandatory: {}, optional: []};//same behaviour as true
130
+    if (bandwidth) {
131
+        if (!constraints.video) {
132
+            //same behaviour as true
133
+            constraints.video = {mandatory: {}, optional: []};
134
+        }
131 135
         constraints.video.optional.push({bandwidth: bandwidth});
132 136
     }
133
-    if (fps) { // for some cameras it might be necessary to request 30fps
137
+    if (fps) {
138
+        // for some cameras it might be necessary to request 30fps
134 139
         // so they choose 30fps mjpg over 10fps yuy2
135
-        if (!constraints.video) constraints.video = {mandatory: {}, optional: []};// same behaviour as true;
140
+        if (!constraints.video) {
141
+            // same behaviour as true;
142
+            constraints.video = {mandatory: {}, optional: []};
143
+        }
136 144
         constraints.video.mandatory.minFrameRate = fps;
137 145
     }
138 146
 
@@ -167,8 +175,7 @@ function RTCUtils(RTCService, onTemasysPluginReady)
167 175
                 var id = stream.id;
168 176
                 if (!id) {
169 177
                     var tracks = stream.getVideoTracks();
170
-                    if (!tracks || tracks.length === 0)
171
-                    {
178
+                    if (!tracks || tracks.length === 0) {
172 179
                         tracks = stream.getAudioTracks();
173 180
                     }
174 181
                     id = tracks[0].id;
@@ -258,7 +265,6 @@ function RTCUtils(RTCService, onTemasysPluginReady)
258 265
                     console.warn("Attempt to get video SRC of null element");
259 266
                     return null;
260 267
                 }
261
-                var src = null;
262 268
                 var children = element.children;
263 269
                 for (var i = 0; i !== children.length; ++i) {
264 270
                     if (children[i].name === 'streamId') {
@@ -293,8 +299,7 @@ function RTCUtils(RTCService, onTemasysPluginReady)
293 299
 
294 300
 RTCUtils.prototype.getUserMediaWithConstraints = function(
295 301
     um, success_callback, failure_callback, resolution,bandwidth, fps,
296
-    desktopStream)
297
-{
302
+    desktopStream) {
298 303
     currentResolution = resolution;
299 304
     // Check if we are running on Android device
300 305
     var isAndroid = navigator.userAgent.indexOf('Android') != -1;
@@ -331,16 +336,14 @@ RTCUtils.prototype.getUserMediaWithConstraints = function(
331 336
 
332 337
 RTCUtils.prototype.setAvailableDevices = function (um, available) {
333 338
     var devices = {};
334
-    if(um.indexOf("video") != -1)
335
-    {
339
+    if(um.indexOf("video") != -1) {
336 340
         devices.video = available;
337 341
     }
338
-    if(um.indexOf("audio") != -1)
339
-    {
342
+    if(um.indexOf("audio") != -1) {
340 343
         devices.audio = available;
341 344
     }
342 345
     this.service.setDeviceAvailability(devices);
343
-}
346
+};
344 347
 
345 348
 /**
346 349
  * We ask for audio and video combined stream in order to get permissions and
@@ -366,8 +369,7 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions =
366 369
 
367 370
 
368 371
     if(usageOptions)
369
-        for(var i = 0; i < devices.length; i++)
370
-        {
372
+        for(var i = 0; i < devices.length; i++) {
371 373
             var device = devices[i];
372 374
             if(usageOptions[device] === true)
373 375
                 newDevices.push(device);
@@ -375,8 +377,7 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions =
375 377
     else
376 378
         newDevices = devices;
377 379
 
378
-    if(newDevices.length === 0)
379
-    {
380
+    if(newDevices.length === 0) {
380 381
         successCallback();
381 382
         return;
382 383
     }
@@ -437,7 +438,6 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions =
437 438
         },
438 439
         config.resolution || '360');
439 440
     }
440
-
441 441
 };
442 442
 
443 443
 RTCUtils.prototype.successCallback = function (stream, usageOptions) {
@@ -467,8 +467,7 @@ RTCUtils.prototype.errorCallback = function (error) {
467 467
                 return self.errorCallback(error);
468 468
             }, resolution);
469 469
     }
470
-    else
471
-    {
470
+    else {
472 471
         self.getUserMediaWithConstraints(
473 472
             ['audio'],
474 473
             function (stream) {
@@ -481,11 +480,9 @@ RTCUtils.prototype.errorCallback = function (error) {
481 480
             }
482 481
         );
483 482
     }
483
+};
484 484
 
485
-}
486
-
487
-RTCUtils.prototype.handleLocalStream = function(stream, usageOptions)
488
-{
485
+RTCUtils.prototype.handleLocalStream = function(stream, usageOptions) {
489 486
     // If this is FF, the stream parameter is *not* a MediaStream object, it's
490 487
     // an object with two properties: audioStream, videoStream.
491 488
     var audioStream, videoStream;
@@ -538,8 +535,8 @@ function DummyMediaStream(id) {
538 535
     this.id = id;
539 536
     this.label = id;
540 537
     this.stop = function() { };
541
-    this.getAudioTracks = function() { return []; }
542
-    this.getVideoTracks = function() { return []; }
538
+    this.getAudioTracks = function() { return []; };
539
+    this.getVideoTracks = function() { return []; };
543 540
 }
544 541
 
545 542
 RTCUtils.prototype.createStream = function(stream, isVideo) {
@@ -549,7 +546,7 @@ RTCUtils.prototype.createStream = function(stream, isVideo) {
549 546
         if (newStream) {
550 547
             var tracks = (isVideo ? stream.getVideoTracks() : stream.getAudioTracks());
551 548
 
552
-            for (i = 0; i < tracks.length; i++) {
549
+            for (var i = 0; i < tracks.length; i++) {
553 550
                 newStream.addTrack(tracks[i]);
554 551
             }
555 552
         }
@@ -560,7 +557,8 @@ RTCUtils.prototype.createStream = function(stream, isVideo) {
560 557
         if (stream) {
561 558
             newStream = stream;
562 559
         } else {
563
-            newStream = new DummyMediaStream(isVideo ? "dummyVideo" : "dummyAudio");
560
+            newStream =
561
+                new DummyMediaStream(isVideo ? "dummyVideo" : "dummyAudio");
564 562
         }
565 563
     }
566 564
 

Loading…
취소
저장