Selaa lähdekoodia

Implements partly multi conference support for rtc module.

dev1
hristoterezov 10 vuotta sitten
vanhempi
commit
9ea31b1ef4
4 muutettua tiedostoa jossa 268 lisäystä ja 228 poistoa
  1. 17
    3
      JitsiConference.js
  2. 8
    7
      JitsiTrack.js
  3. 238
    210
      modules/RTC/RTC.js
  4. 5
    8
      modules/RTC/RTCUtils.js

+ 17
- 3
JitsiConference.js Näytä tiedosto

@@ -1,3 +1,5 @@
1
+var RTC = require("./modules/RTC/RTC");
2
+var XMPPEvents = require("./service/xmpp/XMPPEvents");
1 3
 
2 4
 /**
3 5
  * Creates a JitsiConference object with the given name and properties.
@@ -14,6 +16,10 @@ function JitsiConference(options) {
14 16
     this.connection = this.options.connection;
15 17
     this.xmpp = this.connection.xmpp;
16 18
     this.room = this.xmpp.createRoom(this.options.name, null, null);
19
+    this.rtc = new RTC();
20
+    this.xmpp.addListener(XMPPEvents.CALL_INCOMING,
21
+        this.rtc.onIncommingCall.bind(this.rtc));
22
+
17 23
 }
18 24
 
19 25
 /**
@@ -41,14 +47,14 @@ JitsiConference.prototype.leave = function () {
41 47
  *     or a JitsiConferenceError if rejected.
42 48
  */
43 49
 JitsiConference.prototype.createLocalTracks = function (options) {
44
-
50
+    this.rtc.obtainAudioAndVideoPermissions();
45 51
 }
46 52
 
47 53
 /**
48 54
  * Returns the local tracks.
49 55
  */
50 56
 JitsiConference.prototype.getLocalTracks = function () {
51
-
57
+    return this.rtc.localStreams;
52 58
 };
53 59
 
54 60
 
@@ -61,7 +67,7 @@ JitsiConference.prototype.getLocalTracks = function () {
61 67
  * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
62 68
  */
63 69
 JitsiConference.prototype.on = function (eventId, handler) {
64
-    this.add.addListener(eventId, handler);
70
+    this.room.addListener(eventId, handler);
65 71
 }
66 72
 
67 73
 /**
@@ -147,7 +153,15 @@ JitsiConference.prototype.setDisplayName = function(name) {
147 153
  * @param id the identifier of the participant
148 154
  */
149 155
 JitsiConference.prototype.selectParticipant = function(participantId) {
156
+    this.rtc.selectedEndpoint(participantId);
157
+}
150 158
 
159
+/**
160
+ *
161
+ * @param id the identifier of the participant
162
+ */
163
+JitsiConference.prototype.pinParticipant = function(participantId) {
164
+    this.rtc.pinEndpoint(participantId);
151 165
 }
152 166
 
153 167
 /**

+ 8
- 7
JitsiTrack.js Näytä tiedosto

@@ -2,9 +2,9 @@
2 2
  * Represents a single media track (either audio or video).
3 3
  * @constructor
4 4
  */
5
-function JitsiTrack()
5
+function JitsiTrack(stream)
6 6
 {
7
-
7
+    this.stream = stream;
8 8
 }
9 9
 
10 10
 /**
@@ -23,34 +23,35 @@ JitsiTrack.AUDIO = "audio";
23 23
  * Returns the type (audio or video) of this track.
24 24
  */
25 25
 JitsiTrack.prototype.getType = function() {
26
+    return this.stream.type;
26 27
 };
27 28
 
28 29
 /**
29 30
  * @returns {JitsiParticipant} to which this track belongs, or null if it is a local track.
30 31
  */
31
-JitsiTrack.prototype.getParitcipant() = function() {
32
+JitsiTrack.prototype.getParitcipant = function() {
32 33
 
33 34
 };
34 35
 
35 36
 /**
36 37
  * Returns the RTCMediaStream from the browser (?).
37 38
  */
38
-JitsiTrack.prototype.getOriginalStream() {
39
-
39
+JitsiTrack.prototype.getOriginalStream = function() {
40
+    return this.stream.getOriginalStream();
40 41
 }
41 42
 
42 43
 /**
43 44
  * Mutes the track.
44 45
  */
45 46
 JitsiTrack.prototype.mute = function () {
46
-
47
+    this.stream.setMute(true);
47 48
 }
48 49
 
49 50
 /**
50 51
  * Unmutes the stream.
51 52
  */
52 53
 JitsiTrack.prototype.unmute = function () {
53
-
54
+    this.stream.setMute(false);
54 55
 }
55 56
 
56 57
 /**

+ 238
- 210
modules/RTC/RTC.js Näytä tiedosto

@@ -12,9 +12,7 @@ var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
12 12
 var RTCEvents = require("../../service/RTC/RTCEvents.js");
13 13
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
14 14
 var UIEvents = require("../../service/UI/UIEvents");
15
-
16
-var eventEmitter = new EventEmitter();
17
-
15
+var desktopsharing = require("../desktopsharing/desktopsharing");
18 16
 
19 17
 function getMediaStreamUsage()
20 18
 {
@@ -43,233 +41,263 @@ function getMediaStreamUsage()
43 41
     return result;
44 42
 }
45 43
 
46
-var RTC = {
47
-    rtcUtils: null,
48
-    devices: {
44
+
45
+function RTC()
46
+{
47
+    this.rtcUtils = null;
48
+    this.devices = {
49 49
         audio: true,
50 50
         video: true
51
-    },
52
-    localStreams: [],
53
-    remoteStreams: {},
54
-    localAudio: null,
55
-    localVideo: null,
56
-    addStreamListener: function (listener, eventType) {
57
-        eventEmitter.on(eventType, listener);
58
-    },
59
-    addListener: function (type, listener) {
60
-        eventEmitter.on(type, listener);
61
-    },
62
-    removeStreamListener: function (listener, eventType) {
63
-        if(!(eventType instanceof StreamEventTypes))
64
-            throw "Illegal argument";
65
-
66
-        eventEmitter.removeListener(eventType, listener);
67
-    },
68
-    createLocalStream: function (stream, type, change, videoType, isMuted, isGUMStream) {
69
-
70
-        var localStream =  new LocalStream(stream, type, eventEmitter, videoType, isGUMStream);
71
-        //in firefox we have only one stream object
72
-        if(this.localStreams.length == 0 ||
73
-            this.localStreams[0].getOriginalStream() != stream)
74
-            this.localStreams.push(localStream);
75
-        if(isMuted === true)
51
+    };
52
+    this.localStreams = [];
53
+    this.remoteStreams = {};
54
+    this.localAudio = null;
55
+    this.localVideo = null;
56
+    this.eventEmitter = new EventEmitter();
57
+    var self = this;
58
+    desktopsharing.addListener(
59
+        function (stream, isUsingScreenStream, callback) {
60
+            self.changeLocalVideo(stream, isUsingScreenStream, callback);
61
+        }, DesktopSharingEventTypes.NEW_STREAM_CREATED);
62
+
63
+    // In case of IE we continue from 'onReady' callback
64
+    // passed to RTCUtils constructor. It will be invoked by Temasys plugin
65
+    // once it is initialized.
66
+    var onReady = function () {
67
+        self.eventEmitter.emit(RTCEvents.RTC_READY, true);
68
+    };
69
+
70
+    this.rtcUtils = new RTCUtils(this, onReady);
71
+
72
+    // Call onReady() if Temasys plugin is not used
73
+    if (!RTCBrowserType.isTemasysPluginUsed()) {
74
+        onReady();
75
+    }
76
+}
77
+
78
+RTC.prototype.obtainAudioAndVideoPermissions = function () {
79
+    this.rtcUtils.obtainAudioAndVideoPermissions(
80
+        null, null, getMediaStreamUsage());
81
+}
82
+
83
+RTC.prototype.onIncommingCall = function(event) {
84
+    DataChannels.init(event.peerconnection, self.eventEmitter);
85
+}
86
+
87
+RTC.prototype.selectedEndpoint = function (id) {
88
+    DataChannels.handleSelectedEndpointEvent(id);
89
+}
90
+
91
+RTC.prototype.pinEndpoint = function (id) {
92
+    DataChannels.handlePinnedEndpointEvent(id);
93
+}
94
+
95
+RTC.prototype.addStreamListener = function (listener, eventType) {
96
+    this.eventEmitter.on(eventType, listener);
97
+};
98
+
99
+RTC.prototype.addListener = function (type, listener) {
100
+    this.eventEmitter.on(type, listener);
101
+};
102
+
103
+RTC.prototype.removeStreamListener = function (listener, eventType) {
104
+    if(!(eventType instanceof StreamEventTypes))
105
+        throw "Illegal argument";
106
+
107
+    this.removeListener(eventType, listener);
108
+};
109
+
110
+RTC.prototype.createLocalStreams = function (streams, change) {
111
+    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);
115
+        this.localStreams.push(localStream);
116
+        if (streams.isMuted === true)
76 117
             localStream.setMute(true);
77 118
 
78
-        if(type == "audio") {
119
+        if (streams.type == "audio") {
79 120
             this.localAudio = localStream;
80 121
         } else {
81 122
             this.localVideo = localStream;
82 123
         }
83 124
         var eventType = StreamEventTypes.EVENT_TYPE_LOCAL_CREATED;
84
-        if(change)
125
+        if (change)
85 126
             eventType = StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED;
86 127
 
87
-        eventEmitter.emit(eventType, localStream, isMuted);
88
-        return localStream;
89
-    },
90
-    removeLocalStream: function (stream) {
91
-        for(var i = 0; i < this.localStreams.length; i++) {
92
-            if(this.localStreams[i].getOriginalStream() === stream) {
93
-                delete this.localStreams[i];
94
-                return;
95
-            }
96
-        }
97
-    },
98
-    createRemoteStream: function (data, sid, thessrc) {
99
-        var remoteStream = new MediaStream(data, sid, thessrc,
100
-            RTCBrowserType.getBrowserType(), eventEmitter);
101
-        var jid = data.peerjid || APP.xmpp.myJid();
102
-        if(!this.remoteStreams[jid]) {
103
-            this.remoteStreams[jid] = {};
104
-        }
105
-        this.remoteStreams[jid][remoteStream.type]= remoteStream;
106
-        eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
107
-        return remoteStream;
108
-    },
109
-    getPCConstraints: function () {
110
-        return this.rtcUtils.pc_constraints;
111
-    },
112
-    getUserMediaWithConstraints:function(um, success_callback,
113
-                                         failure_callback, resolution,
114
-                                         bandwidth, fps, desktopStream)
115
-    {
116
-        return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
117
-            failure_callback, resolution, bandwidth, fps, desktopStream);
118
-    },
119
-    attachMediaStream:  function (elSelector, stream) {
120
-        this.rtcUtils.attachMediaStream(elSelector, stream);
121
-    },
122
-    getStreamID:  function (stream) {
123
-        return this.rtcUtils.getStreamID(stream);
124
-    },
125
-    getVideoSrc: function (element) {
126
-        return this.rtcUtils.getVideoSrc(element);
127
-    },
128
-    setVideoSrc: function (element, src) {
129
-        this.rtcUtils.setVideoSrc(element, src);
130
-    },
131
-    getVideoElementName: function () {
132
-        return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
133
-    },
134
-    dispose: function() {
135
-        if (this.rtcUtils) {
136
-            this.rtcUtils = null;
128
+        this.eventEmitter.emit(eventType, localStream, streams.isMuted);
129
+    }
130
+    return this.localStreams;
131
+};
132
+
133
+RTC.prototype.removeLocalStream = function (stream) {
134
+    for(var i = 0; i < this.localStreams.length; i++) {
135
+        if(this.localStreams[i].getOriginalStream() === stream) {
136
+            delete this.localStreams[i];
137
+            return;
137 138
         }
138
-    },
139
-    stop:  function () {
140
-        this.dispose();
141
-    },
142
-    start: function () {
143
-        var self = this;
144
-        APP.desktopsharing.addListener(
145
-            function (stream, isUsingScreenStream, callback) {
146
-                self.changeLocalVideo(stream, isUsingScreenStream, callback);
147
-            }, DesktopSharingEventTypes.NEW_STREAM_CREATED);
148
-        APP.xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
149
-            DataChannels.init(event.peerconnection, eventEmitter);
150
-        });
151
-        APP.UI.addListener(UIEvents.SELECTED_ENDPOINT,
152
-            DataChannels.handleSelectedEndpointEvent);
153
-        APP.UI.addListener(UIEvents.PINNED_ENDPOINT,
154
-            DataChannels.handlePinnedEndpointEvent);
155
-
156
-        // In case of IE we continue from 'onReady' callback
157
-        // passed to RTCUtils constructor. It will be invoked by Temasys plugin
158
-        // once it is initialized.
159
-        var onReady = function () {
160
-            eventEmitter.emit(RTCEvents.RTC_READY, true);
161
-            self.rtcUtils.obtainAudioAndVideoPermissions(
162
-                null, null, getMediaStreamUsage());
163
-        };
139
+    }
140
+};
164 141
 
165
-        this.rtcUtils = new RTCUtils(this, onReady);
142
+RTC.prototype.createRemoteStream = function (data, sid, thessrc) {
143
+    var remoteStream = new MediaStream(data, sid, thessrc,
144
+        RTCBrowserType.getBrowserType(), this.eventEmitter);
145
+    if(data.peerjid)
146
+        return;
147
+    var jid = data.peerjid;
148
+    if(!this.remoteStreams[jid]) {
149
+        this.remoteStreams[jid] = {};
150
+    }
151
+    this.remoteStreams[jid][remoteStream.type]= remoteStream;
152
+    this.eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
153
+    return remoteStream;
154
+};
166 155
 
167
-        // Call onReady() if Temasys plugin is not used
168
-        if (!RTCBrowserType.isTemasysPluginUsed()) {
169
-            onReady();
170
-        }
171
-    },
172
-    muteRemoteVideoStream: function (jid, value) {
173
-        var stream;
156
+RTC.prototype.getPCConstraints = function () {
157
+    return this.rtcUtils.pc_constraints;
158
+};
174 159
 
175
-        if(this.remoteStreams[jid] &&
176
-            this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
177
-            stream = this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
178
-        }
160
+RTC.prototype.getUserMediaWithConstraints = function(um, success_callback,
161
+                                     failure_callback, resolution,
162
+                                     bandwidth, fps, desktopStream)
163
+{
164
+    return this.rtcUtils.getUserMediaWithConstraints(um, success_callback,
165
+        failure_callback, resolution, bandwidth, fps, desktopStream);
166
+};
179 167
 
180
-        if(!stream)
181
-            return true;
168
+RTC.prototype.attachMediaStream =  function (elSelector, stream) {
169
+    this.rtcUtils.attachMediaStream(elSelector, stream);
170
+};
182 171
 
183
-        if (value != stream.muted) {
184
-            stream.setMute(value);
185
-            return true;
186
-        }
187
-        return false;
188
-    },
189
-    switchVideoStreams: function (new_stream) {
190
-        this.localVideo.stream = new_stream;
191
-
192
-        this.localStreams = [];
193
-
194
-        //in firefox we have only one stream object
195
-        if (this.localAudio.getOriginalStream() != new_stream)
196
-            this.localStreams.push(this.localAudio);
197
-        this.localStreams.push(this.localVideo);
198
-    },
199
-    changeLocalVideo: function (stream, isUsingScreenStream, callback) {
200
-        var oldStream = this.localVideo.getOriginalStream();
201
-        var type = (isUsingScreenStream ? "screen" : "camera");
202
-        var localCallback = callback;
203
-        if(this.localVideo.isMuted() && this.localVideo.videoType !== type) {
204
-            localCallback = function() {
205
-                APP.xmpp.setVideoMute(false, function(mute) {
206
-                    eventEmitter.emit(RTCEvents.VIDEO_MUTE, mute);
207
-                });
208
-                
209
-                callback();
210
-            };
211
-        }
212
-        // FIXME: Workaround for FF/IE/Safari
213
-        if (stream && stream.videoStream) {
214
-            stream = stream.videoStream;
215
-        }
216
-        var videoStream = this.rtcUtils.createStream(stream, true);
217
-        this.localVideo = this.createLocalStream(videoStream, "video", true, type);
218
-        // Stop the stream to trigger onended event for old stream
219
-        oldStream.stop();
220
-
221
-        this.switchVideoStreams(videoStream, oldStream);
222
-
223
-        APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
224
-    },
225
-    changeLocalAudio: function (stream, callback) {
226
-        var oldStream = this.localAudio.getOriginalStream();
227
-        var newStream = this.rtcUtils.createStream(stream);
228
-        this.localAudio = this.createLocalStream(newStream, "audio", true);
229
-        // Stop the stream to trigger onended event for old stream
230
-        oldStream.stop();
231
-        APP.xmpp.switchStreams(newStream, oldStream, callback, true);
232
-    },
233
-    isVideoMuted: function (jid) {
234
-        if (jid === APP.xmpp.myJid()) {
235
-            var localVideo = APP.RTC.localVideo;
236
-            return (!localVideo || localVideo.isMuted());
237
-        } else {
238
-            if (!APP.RTC.remoteStreams[jid] ||
239
-                !APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
240
-                return null;
241
-            }
242
-            return APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE].muted;
243
-        }
244
-    },
245
-    setVideoMute: function (mute, callback, options) {
246
-        if (!this.localVideo)
247
-            return;
172
+RTC.prototype.getStreamID = function (stream) {
173
+    return this.rtcUtils.getStreamID(stream);
174
+};
248 175
 
249
-        if (mute == APP.RTC.localVideo.isMuted())
250
-        {
251
-            APP.xmpp.sendVideoInfoPresence(mute);
252
-            if (callback)
253
-                callback(mute);
254
-        }
255
-        else
256
-        {
257
-            APP.RTC.localVideo.setMute(mute);
258
-            APP.xmpp.setVideoMute(
259
-                mute,
260
-                callback,
261
-                options);
176
+RTC.prototype.getVideoSrc = function (element) {
177
+    return this.rtcUtils.getVideoSrc(element);
178
+};
179
+
180
+RTC.prototype.setVideoSrc = function (element, src) {
181
+    this.rtcUtils.setVideoSrc(element, src);
182
+};
183
+
184
+RTC.prototype.getVideoElementName = function () {
185
+    return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
186
+};
187
+
188
+RTC.prototype.dispose = function() {
189
+    if (this.rtcUtils) {
190
+        this.rtcUtils = null;
191
+    }
192
+};
193
+
194
+RTC.prototype.muteRemoteVideoStream = function (jid, value) {
195
+    var stream;
196
+
197
+    if(this.remoteStreams[jid] &&
198
+        this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
199
+        stream = this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
200
+    }
201
+
202
+    if(!stream)
203
+        return true;
204
+
205
+    if (value != stream.muted) {
206
+        stream.setMute(value);
207
+        return true;
208
+    }
209
+    return false;
210
+};
211
+
212
+RTC.prototype.switchVideoStreams = function (new_stream) {
213
+    this.localVideo.stream = new_stream;
214
+
215
+    this.localStreams = [];
216
+
217
+    //in firefox we have only one stream object
218
+    if (this.localAudio.getOriginalStream() != new_stream)
219
+        this.localStreams.push(this.localAudio);
220
+    this.localStreams.push(this.localVideo);
221
+};
222
+
223
+RTC.prototype.changeLocalVideo = function (stream, isUsingScreenStream, callback) {
224
+    var oldStream = this.localVideo.getOriginalStream();
225
+    var type = (isUsingScreenStream ? "screen" : "camera");
226
+    var localCallback = callback;
227
+
228
+    if(this.localVideo.isMuted() && this.localVideo.videoType !== type) {
229
+        localCallback = function() {
230
+            APP.xmpp.setVideoMute(false, function(mute) {
231
+                self.eventEmitter.emit(RTCEvents.VIDEO_MUTE, mute);
232
+            });
233
+            
234
+            callback();
235
+        };
236
+    }
237
+    // FIXME: Workaround for FF/IE/Safari
238
+    if (stream && stream.videoStream) {
239
+        stream = stream.videoStream;
240
+    }
241
+    var videoStream = this.rtcUtils.createStream(stream, true);
242
+    this.localVideo = this.createLocalStream(videoStream, "video", true, type);
243
+    // Stop the stream to trigger onended event for old stream
244
+    oldStream.stop();
245
+
246
+    this.switchVideoStreams(videoStream, oldStream);
247
+
248
+    APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
249
+};
250
+
251
+RTC.prototype.changeLocalAudio = function (stream, callback) {
252
+    var oldStream = this.localAudio.getOriginalStream();
253
+    var newStream = this.rtcUtils.createStream(stream);
254
+    this.localAudio = this.createLocalStream(newStream, "audio", true);
255
+    // Stop the stream to trigger onended event for old stream
256
+    oldStream.stop();
257
+    APP.xmpp.switchStreams(newStream, oldStream, callback, true);
258
+};
259
+
260
+RTC.prototype.isVideoMuted = function (jid) {
261
+    if (jid === APP.xmpp.myJid()) {
262
+        var localVideo = APP.RTC.localVideo;
263
+        return (!localVideo || localVideo.isMuted());
264
+    } else {
265
+        if (!this.remoteStreams[jid] ||
266
+            !this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]) {
267
+            return null;
262 268
         }
263
-    },
264
-    setDeviceAvailability: function (devices) {
265
-        if(!devices)
266
-            return;
267
-        if(devices.audio === true || devices.audio === false)
268
-            this.devices.audio = devices.audio;
269
-        if(devices.video === true || devices.video === false)
270
-            this.devices.video = devices.video;
271
-        eventEmitter.emit(RTCEvents.AVAILABLE_DEVICES_CHANGED, this.devices);
269
+        return this.remoteStreams[jid][MediaStreamType.VIDEO_TYPE].muted;
272 270
     }
273 271
 };
274 272
 
273
+RTC.prototype.setVideoMute = function (mute, callback, options) {
274
+    if (!this.localVideo)
275
+        return;
276
+
277
+    if (mute == this.localVideo.isMuted())
278
+    {
279
+        APP.xmpp.sendVideoInfoPresence(mute);
280
+        if (callback)
281
+            callback(mute);
282
+    }
283
+    else
284
+    {
285
+        this.localVideo.setMute(mute);
286
+        APP.xmpp.setVideoMute(
287
+            mute,
288
+            callback,
289
+            options);
290
+    }
291
+};
292
+
293
+RTC.prototype.setDeviceAvailability = function (devices) {
294
+    if(!devices)
295
+        return;
296
+    if(devices.audio === true || devices.audio === false)
297
+        this.devices.audio = devices.audio;
298
+    if(devices.video === true || devices.video === false)
299
+        this.devices.video = devices.video;
300
+    this.eventEmitter.emit(RTCEvents.AVAILABLE_DEVICES_CHANGED, this.devices);
301
+};
302
+
275 303
 module.exports = RTC;

+ 5
- 8
modules/RTC/RTCUtils.js Näytä tiedosto

@@ -436,7 +436,7 @@ RTCUtils.prototype.successCallback = function (stream, usageOptions) {
436 436
     if (stream && stream.getAudioTracks && stream.getVideoTracks)
437 437
         console.log('got', stream, stream.getAudioTracks().length,
438 438
             stream.getVideoTracks().length);
439
-    this.handleLocalStream(stream, usageOptions);
439
+    return this.handleLocalStream(stream, usageOptions);
440 440
 };
441 441
 
442 442
 RTCUtils.prototype.errorCallback = function (error) {
@@ -475,7 +475,6 @@ RTCUtils.prototype.errorCallback = function (error) {
475 475
 RTCUtils.prototype.handleLocalStream = function(stream, usageOptions) {
476 476
     // If this is FF, the stream parameter is *not* a MediaStream object, it's
477 477
     // an object with two properties: audioStream, videoStream.
478
-    var audioStream, videoStream;
479 478
     if(window.webkitMediaStream)
480 479
     {
481 480
         audioStream = new webkitMediaStream();
@@ -493,6 +492,7 @@ RTCUtils.prototype.handleLocalStream = function(stream, usageOptions) {
493 492
                 videoStream.addTrack(videoTracks[i]);
494 493
             }
495 494
         }
495
+
496 496
     }
497 497
     else if (RTCBrowserType.isFirefox() || RTCBrowserType.isTemasysPluginUsed())
498 498
     {   // Firefox and Temasys plugin
@@ -513,12 +513,9 @@ RTCUtils.prototype.handleLocalStream = function(stream, usageOptions) {
513 513
     var audioGUM = (!usageOptions || usageOptions.audio !== false),
514 514
         videoGUM = (!usageOptions || usageOptions.video !== false);
515 515
 
516
-
517
-    this.service.createLocalStream(audioStream, "audio", null, null,
518
-        audioMuted, audioGUM);
519
-
520
-    this.service.createLocalStream(videoStream, "video", null, 'camera',
521
-        videoMuted, videoGUM);
516
+    return this.service.createLocalStreams(
517
+        [{stream: audioStream, type: "audio", isMuted: audioMuted, isGUMStream: audioGUM, videoType: null},
518
+        {stream: videoStream, type: "video", isMuted: videoMuted, isGUMStream: videoGUM, videoType: "camera"}]);
522 519
 };
523 520
 
524 521
 function DummyMediaStream(id) {

Loading…
Peruuta
Tallenna