瀏覽代碼

More formatting fixes.

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

+ 13
- 26
modules/RTC/LocalStream.js 查看文件

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

+ 2
- 6
modules/RTC/MediaStream.js 查看文件

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

+ 7
- 10
modules/RTC/RTC.js 查看文件

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

+ 2
- 2
modules/RTC/RTCBrowserType.js 查看文件

49
     },
49
     },
50
 
50
 
51
     usesPlanB: function() {
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
     usesUnifiedPlan: function() {
56
     usesUnifiedPlan: function() {

+ 42
- 44
modules/RTC/RTCUtils.js 查看文件

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

Loading…
取消
儲存