|
@@ -26,9 +26,9 @@ const JitsiTrackEvents = JitsiMeetJS.events.track;
|
26
|
26
|
export function createLocalTracks(options = {}) {
|
27
|
27
|
return dispatch =>
|
28
|
28
|
JitsiMeetJS.createLocalTracks({
|
|
29
|
+ cameraDeviceId: options.cameraDeviceId,
|
29
|
30
|
devices: options.devices || [ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ],
|
30
|
31
|
facingMode: options.facingMode || CAMERA_FACING_MODE.USER,
|
31
|
|
- cameraDeviceId: options.cameraDeviceId,
|
32
|
32
|
micDeviceId: options.micDeviceId
|
33
|
33
|
})
|
34
|
34
|
.then(localTracks => dispatch(_updateLocalTracks(localTracks)))
|
|
@@ -233,10 +233,31 @@ function _disposeAndRemoveTracks(tracks) {
|
233
|
233
|
}
|
234
|
234
|
|
235
|
235
|
/**
|
236
|
|
- * Determines which local media tracks should be added, and which - removed.
|
|
236
|
+ * Finds the first <tt>JitsiLocalTrack</tt> in a specific array/list of
|
|
237
|
+ * <tt>JitsiTrack</tt>s which is of a specific <tt>MEDIA_TYPE</tt>.
|
|
238
|
+ *
|
|
239
|
+ * @param {JitsiTrack[]} tracks - The array/list of <tt>JitsiTrack</tt>s to look
|
|
240
|
+ * through.
|
|
241
|
+ * @param {MEDIA_TYPE} mediaType - The <tt>MEDIA_TYPE</tt> of the first
|
|
242
|
+ * <tt>JitsiLocalTrack</tt> to be returned.
|
|
243
|
+ * @returns {JitsiLocalTrack} The first <tt>JitsiLocalTrack</tt>, if any, in the
|
|
244
|
+ * specified <tt>tracks</tt> of the specified <tt>mediaType</tt>.
|
|
245
|
+ */
|
|
246
|
+function _getLocalTrack(tracks, mediaType) {
|
|
247
|
+ return tracks.find(track =>
|
|
248
|
+ track.isLocal()
|
|
249
|
+
|
|
250
|
+ // XXX JitsiTrack#getType() returns a MEDIA_TYPE value in the terms
|
|
251
|
+ // of lib-jitsi-meet while mediaType is in the terms of
|
|
252
|
+ // jitsi-meet-react.
|
|
253
|
+ && track.getType() === mediaType);
|
|
254
|
+}
|
|
255
|
+
|
|
256
|
+/**
|
|
257
|
+ * Determines which local media tracks should be added and which removed.
|
237
|
258
|
*
|
238
|
259
|
* @param {(JitsiLocalTrack|JitsiRemoteTrack)[]} currentTracks - List of
|
239
|
|
- * existing media tracks.
|
|
260
|
+ * current/existing media tracks.
|
240
|
261
|
* @param {(JitsiLocalTrack|JitsiRemoteTrack)[]} newTracks - List of new media
|
241
|
262
|
* tracks.
|
242
|
263
|
* @private
|
|
@@ -246,22 +267,18 @@ function _disposeAndRemoveTracks(tracks) {
|
246
|
267
|
* }}
|
247
|
268
|
*/
|
248
|
269
|
function _getLocalTracksToChange(currentTracks, newTracks) {
|
249
|
|
- const currentLocalAudio
|
250
|
|
- = currentTracks.find(t => t.isLocal() && t.isAudioTrack());
|
251
|
|
- const currentLocalVideo
|
252
|
|
- = currentTracks.find(t => t.isLocal() && t.isVideoTrack());
|
253
|
|
- const newLocalAudio = newTracks.find(t => t.isLocal() && t.isAudioTrack());
|
254
|
|
- const newLocalVideo = newTracks.find(t => t.isLocal() && t.isVideoTrack());
|
255
|
|
- const tracksToRemove = [];
|
256
|
270
|
const tracksToAdd = [];
|
|
271
|
+ const tracksToRemove = [];
|
257
|
272
|
|
258
|
|
- if (newLocalAudio) {
|
259
|
|
- tracksToAdd.push(newLocalAudio);
|
260
|
|
- currentLocalAudio && tracksToRemove.push(currentLocalAudio);
|
261
|
|
- }
|
262
|
|
- if (newLocalVideo) {
|
263
|
|
- tracksToAdd.push(newLocalVideo);
|
264
|
|
- currentLocalVideo && tracksToRemove.push(currentLocalVideo);
|
|
273
|
+ for (const mediaType of [ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ]) {
|
|
274
|
+ const newTrack = _getLocalTrack(newTracks, mediaType);
|
|
275
|
+
|
|
276
|
+ if (newTrack) {
|
|
277
|
+ const currentTrack = _getLocalTrack(currentTracks, mediaType);
|
|
278
|
+
|
|
279
|
+ tracksToAdd.push(newTrack);
|
|
280
|
+ currentTrack && tracksToRemove.push(currentTrack);
|
|
281
|
+ }
|
265
|
282
|
}
|
266
|
283
|
|
267
|
284
|
return {
|