|
@@ -7,7 +7,9 @@ var JitsiTrackErrors = require("../../JitsiTrackErrors");
|
7
|
7
|
var JitsiTrackError = require("../../JitsiTrackError");
|
8
|
8
|
var RTCEvents = require("../../service/RTC/RTCEvents");
|
9
|
9
|
var RTCUtils = require("./RTCUtils");
|
|
10
|
+var MediaType = require('../../service/RTC/MediaType');
|
10
|
11
|
var VideoType = require('../../service/RTC/VideoType');
|
|
12
|
+var CameraFacingMode = require('../../service/RTC/CameraFacingMode');
|
11
|
13
|
|
12
|
14
|
/**
|
13
|
15
|
* Represents a single media track(either audio or video).
|
|
@@ -18,10 +20,11 @@ var VideoType = require('../../service/RTC/VideoType');
|
18
|
20
|
* @param videoType the VideoType of the JitsiRemoteTrack
|
19
|
21
|
* @param resolution the video resoultion if it's a video track
|
20
|
22
|
* @param deviceId the ID of the local device for this track
|
|
23
|
+ * @param facingMode the camera facing mode used in getUserMedia call
|
21
|
24
|
* @constructor
|
22
|
25
|
*/
|
23
|
26
|
function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
|
24
|
|
- deviceId) {
|
|
27
|
+ deviceId, facingMode) {
|
25
|
28
|
var self = this;
|
26
|
29
|
|
27
|
30
|
JitsiTrack.call(this,
|
|
@@ -40,6 +43,9 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
|
40
|
43
|
this.initialMSID = this.getMSID();
|
41
|
44
|
this.inMuteOrUnmuteProgress = false;
|
42
|
45
|
|
|
46
|
+ // Store camera facing mode used during getUserMedia call.
|
|
47
|
+ this.facingMode = facingMode;
|
|
48
|
+
|
43
|
49
|
// Currently there is no way to know the MediaStreamTrack ended due to to
|
44
|
50
|
// device disconnect in Firefox through e.g. "readyState" property. Instead
|
45
|
51
|
// we will compare current track's label with device labels from
|
|
@@ -396,4 +402,41 @@ JitsiLocalTrack.prototype.getDeviceId = function () {
|
396
|
402
|
return this._realDeviceId || this.deviceId;
|
397
|
403
|
};
|
398
|
404
|
|
|
405
|
+/**
|
|
406
|
+ * Returns facing mode for video track from camera. For other cases (e.g. audio
|
|
407
|
+ * track or 'desktop' video track) returns undefined.
|
|
408
|
+ *
|
|
409
|
+ * @returns {CameraFacingMode|undefined}
|
|
410
|
+ */
|
|
411
|
+JitsiLocalTrack.prototype.getCameraFacingMode = function () {
|
|
412
|
+ if (this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
|
|
413
|
+ // MediaStreamTrack#getSettings() is not implemented in many browsers,
|
|
414
|
+ // so we do a feature checking here. Progress on implementation can be
|
|
415
|
+ // tracked at https://bugs.chromium.org/p/webrtc/issues/detail?id=2481
|
|
416
|
+ // for Chromium and https://bugzilla.mozilla.org/show_bug.cgi?id=1213517
|
|
417
|
+ // for Firefox. Even if a browser already implements getSettings()
|
|
418
|
+ // it might still not return anything for 'facingMode' so we need to
|
|
419
|
+ // take into account this.
|
|
420
|
+ var trackSettings;
|
|
421
|
+
|
|
422
|
+ if (this.track &&
|
|
423
|
+ typeof this.track.getSettings === 'function' &&
|
|
424
|
+ (trackSettings = this.track.getSettings()) &&
|
|
425
|
+ 'facingMode' in trackSettings) {
|
|
426
|
+ return trackSettings.facingMode;
|
|
427
|
+ } else if (typeof this.facingMode !== 'undefined') {
|
|
428
|
+ return this.facingMode;
|
|
429
|
+ } else {
|
|
430
|
+ // In most cases we are showing a webcam. So if we failed to satisfy
|
|
431
|
+ // any of the above conditions and got here, that means that we're
|
|
432
|
+ // probably showing the user facing camera.
|
|
433
|
+ return CameraFacingMode.USER;
|
|
434
|
+ }
|
|
435
|
+
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ return undefined;
|
|
439
|
+};
|
|
440
|
+
|
|
441
|
+
|
399
|
442
|
module.exports = JitsiLocalTrack;
|