@techsee/techsee-media-service 999.0.2-switch → 999.0.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LocalStreamManager.d.ts +12 -0
- package/lib/LocalStreamManager.d.ts.map +1 -1
- package/lib/LocalStreamManager.js +440 -283
- package/lib/LocalStreamManager.js.map +1 -1
- package/lib/MediaConstants.d.ts +14 -4
- package/lib/MediaConstants.d.ts.map +1 -1
- package/lib/MediaConstants.js +83 -38
- package/lib/MediaConstants.js.map +1 -1
- package/lib/MediaContracts.d.ts +17 -14
- package/lib/MediaContracts.d.ts.map +1 -1
- package/lib/MediaContracts.js +3 -3
- package/lib/MediaContracts.js.map +1 -1
- package/lib/MediaPublisher.d.ts +3 -3
- package/lib/MediaPublisher.d.ts.map +1 -1
- package/lib/MediaPublisher.js +46 -35
- package/lib/MediaPublisher.js.map +1 -1
- package/lib/MediaServiceBase.d.ts +21 -7
- package/lib/MediaServiceBase.d.ts.map +1 -1
- package/lib/MediaServiceBase.js +924 -586
- package/lib/MediaServiceBase.js.map +1 -1
- package/lib/MediaSession/MediaServer.d.ts +45 -0
- package/lib/MediaSession/MediaServer.d.ts.map +1 -0
- package/lib/MediaSession/MediaServer.js +538 -0
- package/lib/MediaSession/MediaServer.js.map +1 -0
- package/lib/MediaSession/MediaSessionBase.d.ts +10 -1
- package/lib/MediaSession/MediaSessionBase.d.ts.map +1 -1
- package/lib/MediaSession/MediaSessionBase.js +128 -66
- package/lib/MediaSession/MediaSessionBase.js.map +1 -1
- package/lib/MediaSession/SessionOpentok.d.ts +11 -9
- package/lib/MediaSession/SessionOpentok.d.ts.map +1 -1
- package/lib/MediaSession/SessionOpentok.js +500 -352
- package/lib/MediaSession/SessionOpentok.js.map +1 -1
- package/lib/MediaSession/SessionTurn.d.ts +4 -1
- package/lib/MediaSession/SessionTurn.d.ts.map +1 -1
- package/lib/MediaSession/SessionTurn.js +611 -422
- package/lib/MediaSession/SessionTurn.js.map +1 -1
- package/lib/MediaSession/TurnConstants.js +31 -30
- package/lib/MediaSession/TurnConstants.js.map +1 -1
- package/lib/MediaSubscriber.d.ts +11 -11
- package/lib/MediaSubscriber.d.ts.map +1 -1
- package/lib/MediaSubscriber.js +236 -192
- package/lib/MediaSubscriber.js.map +1 -1
- package/lib/MediaUtils/Compatibility.d.ts +2 -1
- package/lib/MediaUtils/Compatibility.d.ts.map +1 -1
- package/lib/MediaUtils/Compatibility.js +130 -85
- package/lib/MediaUtils/Compatibility.js.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.d.ts +3 -2
- package/lib/MediaUtils/MediaDomUtils.d.ts.map +1 -1
- package/lib/MediaUtils/MediaDomUtils.js +235 -174
- package/lib/MediaUtils/MediaDomUtils.js.map +1 -1
- package/lib/MediaUtils/MediaTracer.js +9 -4
- package/lib/MediaUtils/MediaTracer.js.map +1 -1
- package/lib/MediaUtils/index.d.ts +1 -0
- package/lib/MediaUtils/index.d.ts.map +1 -0
- package/lib/MediaUtils/index.js +16 -0
- package/lib/MediaUtils/index.js.map +1 -0
- package/lib/MultiParty/Contracts.d.ts +16 -0
- package/lib/MultiParty/Contracts.d.ts.map +1 -0
- package/lib/MultiParty/Contracts.js +6 -0
- package/lib/MultiParty/Contracts.js.map +1 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts +16 -0
- package/lib/MultiParty/DetectWebRtcService.d.ts.map +1 -0
- package/lib/MultiParty/DetectWebRtcService.js +79 -0
- package/lib/MultiParty/DetectWebRtcService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts +23 -0
- package/lib/MultiParty/MediaCapabilitiesService.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesService.js +369 -0
- package/lib/MultiParty/MediaCapabilitiesService.js.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts +5 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.d.ts.map +1 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js +305 -0
- package/lib/MultiParty/MediaCapabilitiesUtils.js.map +1 -0
- package/lib/MultiParty/MultiPartyService.d.ts +41 -0
- package/lib/MultiParty/MultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyService.js +72 -0
- package/lib/MultiParty/MultiPartyService.js.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts +3 -0
- package/lib/MultiParty/MultiPartyServiceFactory.d.ts.map +1 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js +21 -0
- package/lib/MultiParty/MultiPartyServiceFactory.js.map +1 -0
- package/lib/MultiParty/OpentokMultiPartyService.d.ts +29 -0
- package/lib/MultiParty/OpentokMultiPartyService.d.ts.map +1 -0
- package/lib/MultiParty/OpentokMultiPartyService.js +888 -0
- package/lib/MultiParty/OpentokMultiPartyService.js.map +1 -0
- package/lib/MultiParty/VideoLayoutType.d.ts +4 -0
- package/lib/MultiParty/VideoLayoutType.d.ts.map +1 -0
- package/lib/MultiParty/VideoLayoutType.js +13 -0
- package/lib/MultiParty/VideoLayoutType.js.map +1 -0
- package/lib/MultiParty/index.d.ts +4 -0
- package/lib/MultiParty/index.d.ts.map +1 -0
- package/lib/MultiParty/index.js +61 -0
- package/lib/MultiParty/index.js.map +1 -0
- package/lib/MultiParty/opentok.d.ts +503 -0
- package/lib/TechseeMediaStream.d.ts +6 -6
- package/lib/TechseeMediaStream.d.ts.map +1 -1
- package/lib/TechseeMediaStream.js +59 -53
- package/lib/TechseeMediaStream.js.map +1 -1
- package/lib/oldCode/constants.js +20 -15
- package/lib/oldCode/constants.js.map +1 -1
- package/lib/oldCode/event-emitter.js +45 -22
- package/lib/oldCode/event-emitter.js.map +1 -1
- package/lib/oldCode/index.js +48 -52
- package/lib/oldCode/index.js.map +1 -1
- package/lib/oldCode/opentok/session.js +261 -236
- package/lib/oldCode/opentok/session.js.map +1 -1
- package/lib/oldCode/opentok/stream.js +283 -269
- package/lib/oldCode/opentok/stream.js.map +1 -1
- package/lib/oldCode/publisher.js +96 -71
- package/lib/oldCode/publisher.js.map +1 -1
- package/lib/oldCode/service.js +294 -272
- package/lib/oldCode/service.js.map +1 -1
- package/lib/oldCode/session.js +82 -60
- package/lib/oldCode/session.js.map +1 -1
- package/lib/oldCode/stream.js +153 -125
- package/lib/oldCode/stream.js.map +1 -1
- package/lib/oldCode/subscriber.js +60 -35
- package/lib/oldCode/subscriber.js.map +1 -1
- package/lib/oldCode/tracer.d.ts +3 -2
- package/lib/oldCode/tracer.d.ts.map +1 -1
- package/lib/oldCode/tracer.js +181 -130
- package/lib/oldCode/tracer.js.map +1 -1
- package/lib/oldCode/utils/ImageFixer.js +67 -44
- package/lib/oldCode/utils/ImageFixer.js.map +1 -1
- package/lib/oldCode/webrtc/constants.js +102 -110
- package/lib/oldCode/webrtc/constants.js.map +1 -1
- package/lib/oldCode/webrtc/helper.js +176 -124
- package/lib/oldCode/webrtc/helper.js.map +1 -1
- package/lib/oldCode/webrtc/session-kms.js +408 -393
- package/lib/oldCode/webrtc/session-kms.js.map +1 -1
- package/lib/oldCode/webrtc/session-loopback.js +245 -227
- package/lib/oldCode/webrtc/session-loopback.js.map +1 -1
- package/lib/oldCode/webrtc/session-turn.js +705 -658
- package/lib/oldCode/webrtc/session-turn.js.map +1 -1
- package/lib/oldCode/webrtc/session-turn.v2.js +480 -471
- package/lib/oldCode/webrtc/session-turn.v2.js.map +1 -1
- package/lib/oldCode/webrtc/session.js +12 -6
- package/lib/oldCode/webrtc/session.js.map +1 -1
- package/lib/oldCode/webrtc/stream.js +526 -504
- package/lib/oldCode/webrtc/stream.js.map +1 -1
- package/lib/oldCode/webrtc/temasys/adapter-loader.js +5 -6
- package/lib/oldCode/webrtc/temasys/adapter-loader.js.map +1 -1
- package/lib/oldCode/webrtc/temasys/adapter.js +5264 -5192
- package/lib/oldCode/webrtc/temasys/adapter.js.map +1 -1
- package/lib/oldCode/webrtc/webrtc-ie-shim.js +3357 -2927
- package/lib/oldCode/webrtc/webrtc-ie-shim.js.map +1 -1
- package/lib/qos/raw-qos.js +348 -273
- package/lib/qos/raw-qos.js.map +1 -1
- package/lib/webrtc-ie-shim.js +3386 -2985
- package/lib/webrtc-ie-shim.js.map +1 -1
- package/package.json +54 -42
|
@@ -1,317 +1,474 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __assign =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
3
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
|
|
8
|
+
for (var p in s) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
14
17
|
};
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
20
|
+
return mod && mod.__esModule ? mod : {
|
|
21
|
+
"default": mod
|
|
22
|
+
};
|
|
17
23
|
};
|
|
18
|
-
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, "__esModule", {
|
|
26
|
+
value: true
|
|
27
|
+
});
|
|
28
|
+
exports.LocalStreamManager = void 0;
|
|
29
|
+
|
|
19
30
|
var assign_1 = __importDefault(require("lodash/assign"));
|
|
31
|
+
|
|
20
32
|
var get_1 = __importDefault(require("lodash/get"));
|
|
33
|
+
|
|
21
34
|
var last_1 = __importDefault(require("lodash/last"));
|
|
35
|
+
|
|
22
36
|
var first_1 = __importDefault(require("lodash/first"));
|
|
37
|
+
|
|
38
|
+
var cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
39
|
+
|
|
23
40
|
var bluebird_1 = require("bluebird");
|
|
41
|
+
|
|
24
42
|
var MediaConstants_1 = require("./MediaConstants");
|
|
43
|
+
|
|
25
44
|
var MediaTracer_1 = require("./MediaUtils/MediaTracer");
|
|
45
|
+
|
|
26
46
|
window.latestUserMediaStream = null;
|
|
27
47
|
var userMediaPromise = null;
|
|
28
48
|
window.latestDesktopMediaStream = null;
|
|
29
49
|
var desktopMediaPromise = null;
|
|
50
|
+
window.mediaStreamAlreadyReplaced = false;
|
|
51
|
+
window.latestLocalMediaConstraints = null;
|
|
30
52
|
var trace = MediaTracer_1.getMediaTracer('LocalStreamManager');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
trace.info('getUserMediaStream', constraints);
|
|
41
|
-
if (userMediaPromise) {
|
|
42
|
-
return userMediaPromise;
|
|
43
|
-
}
|
|
44
|
-
if (window.latestUserMediaStream) {
|
|
45
|
-
var videoTrack = window.latestUserMediaStream.mediaStream.getVideoTracks();
|
|
46
|
-
if (videoTrack.length > 0 && videoTrack[0].readyState === 'live') {
|
|
47
|
-
return bluebird_1.Promise.resolve(__assign({}, window.latestUserMediaStream, { isNew: false }));
|
|
48
|
-
}
|
|
49
|
-
this.destroyUserMediaStream();
|
|
50
|
-
}
|
|
51
|
-
userMediaPromise = new bluebird_1.Promise(function (resolve, reject) {
|
|
52
|
-
var catchHandler = function catchHandler(err) {
|
|
53
|
-
userMediaPromise = null;
|
|
54
|
-
window.latestUserMediaStream = null;
|
|
55
|
-
trace.error('getUserMedia error', err);
|
|
56
|
-
reject(err);
|
|
57
|
-
};
|
|
58
|
-
try {
|
|
59
|
-
_this.getHighestResolutionStream(false, constraints).then(function (streamResult) {
|
|
60
|
-
userMediaPromise = null;
|
|
61
|
-
window.latestUserMediaStream = streamResult;
|
|
62
|
-
resolve(__assign({}, window.latestUserMediaStream, { isNew: true }));
|
|
63
|
-
}).catch(catchHandler);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
catchHandler(err);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return userMediaPromise;
|
|
69
|
-
};
|
|
70
|
-
LocalStreamManager.prototype.getDesktopMediaStream = function (constraints) {
|
|
71
|
-
var _this = this;
|
|
72
|
-
if (desktopMediaPromise) {
|
|
73
|
-
return desktopMediaPromise;
|
|
74
|
-
}
|
|
75
|
-
trace.info('getDesktopMediaStream', constraints);
|
|
76
|
-
if (window.latestDesktopMediaStream) {
|
|
77
|
-
var track = window.latestDesktopMediaStream.mediaStream.getVideoTracks();
|
|
78
|
-
if (track.length > 0 && track[0].readyState === 'live') {
|
|
79
|
-
//return Promise.resolve();
|
|
80
|
-
return bluebird_1.Promise.resolve(__assign({}, window.latestDesktopMediaStream, { isNew: false }));
|
|
81
|
-
}
|
|
82
|
-
this.destroyDesktopMediaStream().catch(function (error) {
|
|
83
|
-
trace.error('Error destroying desktop media stream', error);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
desktopMediaPromise = new bluebird_1.Promise(function (resolve, reject) {
|
|
87
|
-
var mediaCatchHandler = function mediaCatchHandler(err) {
|
|
88
|
-
desktopMediaPromise = null;
|
|
89
|
-
window.latestDesktopMediaStream = null;
|
|
90
|
-
trace.error('getDisplayMedia error', err);
|
|
91
|
-
reject(err);
|
|
92
|
-
};
|
|
93
|
-
try {
|
|
94
|
-
_this.getHighestResolutionStream(true, { video: constraints, audio: false }).then(function (streamResult) {
|
|
95
|
-
desktopMediaPromise = null;
|
|
96
|
-
window.latestDesktopMediaStream = streamResult;
|
|
97
|
-
resolve(__assign({}, window.latestDesktopMediaStream, { isNew: true }));
|
|
98
|
-
}).catch(mediaCatchHandler);
|
|
99
|
-
} catch (err) {
|
|
100
|
-
mediaCatchHandler(err);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return desktopMediaPromise;
|
|
53
|
+
|
|
54
|
+
var LocalStreamManager =
|
|
55
|
+
/** @class */
|
|
56
|
+
function () {
|
|
57
|
+
function LocalStreamManager(environment) {
|
|
58
|
+
this._groupedDevices = {
|
|
59
|
+
video: null,
|
|
60
|
+
audio: null,
|
|
61
|
+
camerasCount: 0
|
|
104
62
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
63
|
+
this.environment = environment;
|
|
64
|
+
this.parseMediaErrorThenThrow = this.parseMediaErrorThenThrow.bind(this);
|
|
65
|
+
this.clearAllStreams = this.clearAllStreams.bind(this);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Object.defineProperty(LocalStreamManager.prototype, "groupedDevices", {
|
|
69
|
+
get: function get() {
|
|
70
|
+
return this._groupedDevices;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
LocalStreamManager.prototype.getUserMediaStream = function (constraints) {
|
|
77
|
+
var _this = this;
|
|
78
|
+
|
|
79
|
+
trace.info('getUserMediaStream', constraints);
|
|
80
|
+
|
|
81
|
+
if (userMediaPromise) {
|
|
82
|
+
return userMediaPromise;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (window.latestUserMediaStream) {
|
|
86
|
+
var videoTrack = window.latestUserMediaStream.mediaStream.getVideoTracks();
|
|
87
|
+
|
|
88
|
+
if (videoTrack.length > 0 && videoTrack[0].readyState === 'live') {
|
|
89
|
+
return bluebird_1.Promise.resolve(__assign(__assign({}, window.latestUserMediaStream), {
|
|
90
|
+
isNew: false
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.destroyUserMediaStream();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
userMediaPromise = new bluebird_1.Promise(function (resolve, reject) {
|
|
98
|
+
var catchHandler = function catchHandler(err) {
|
|
108
99
|
userMediaPromise = null;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
100
|
+
window.latestUserMediaStream = null;
|
|
101
|
+
trace.error('getUserMedia error', err);
|
|
102
|
+
reject(err);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
_this.getHighestResolutionStream(false, constraints).then(function (streamResult) {
|
|
107
|
+
userMediaPromise = null;
|
|
108
|
+
window.latestUserMediaStream = streamResult;
|
|
109
|
+
window.latestLocalMediaConstraints = cloneDeep_1["default"](constraints);
|
|
110
|
+
window.latestLocalMediaConstraints.audio = streamResult.constraint && streamResult.constraint.audio;
|
|
111
|
+
resolve(__assign(__assign({}, window.latestUserMediaStream), {
|
|
112
|
+
isNew: true
|
|
113
|
+
}));
|
|
114
|
+
})["catch"](catchHandler);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
catchHandler(err);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return userMediaPromise;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
LocalStreamManager.prototype.getDesktopMediaStream = function (constraints) {
|
|
123
|
+
var _this = this;
|
|
124
|
+
|
|
125
|
+
if (desktopMediaPromise) {
|
|
126
|
+
return desktopMediaPromise;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
trace.info('getDesktopMediaStream', constraints);
|
|
130
|
+
|
|
131
|
+
if (window.latestDesktopMediaStream) {
|
|
132
|
+
var track = window.latestDesktopMediaStream.mediaStream.getVideoTracks();
|
|
133
|
+
|
|
134
|
+
if (track.length > 0 && track[0].readyState === 'live') {
|
|
135
|
+
//return Promise.resolve();
|
|
136
|
+
return bluebird_1.Promise.resolve(__assign(__assign({}, window.latestDesktopMediaStream), {
|
|
137
|
+
isNew: false
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.destroyDesktopMediaStream()["catch"](function (error) {
|
|
142
|
+
trace.error('Error destroying desktop media stream', error);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
desktopMediaPromise = new bluebird_1.Promise(function (resolve, reject) {
|
|
147
|
+
var mediaCatchHandler = function mediaCatchHandler(err) {
|
|
119
148
|
desktopMediaPromise = null;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
window.latestDesktopMediaStream = null;
|
|
150
|
+
trace.error('getDisplayMedia error', err);
|
|
151
|
+
reject(err);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
_this.getHighestResolutionStream(true, {
|
|
156
|
+
video: constraints,
|
|
157
|
+
audio: false
|
|
158
|
+
}).then(function (streamResult) {
|
|
159
|
+
desktopMediaPromise = null;
|
|
160
|
+
window.latestDesktopMediaStream = streamResult;
|
|
161
|
+
resolve(__assign(__assign({}, window.latestDesktopMediaStream), {
|
|
162
|
+
isNew: true
|
|
163
|
+
}));
|
|
164
|
+
})["catch"](mediaCatchHandler);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
mediaCatchHandler(err);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return desktopMediaPromise;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
LocalStreamManager.prototype.destroyUserMediaStream = function () {
|
|
173
|
+
var streamResult = window.latestUserMediaStream;
|
|
174
|
+
userMediaPromise = null;
|
|
175
|
+
window.latestUserMediaStream = null;
|
|
176
|
+
window.latestLocalMediaConstraints = null;
|
|
177
|
+
window.mediaStreamAlreadyReplaced = false;
|
|
178
|
+
|
|
179
|
+
if (streamResult && streamResult.mediaStream) {
|
|
180
|
+
try {
|
|
181
|
+
streamResult.mediaStream.getTracks().forEach(function (track) {
|
|
182
|
+
track.stop();
|
|
131
183
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
184
|
+
trace.info('destroyUserMediaStream - stop all tracks');
|
|
185
|
+
} catch (e) {
|
|
186
|
+
trace.info('destroyUserMediaStream - Failed to stop all tracks', e);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return bluebird_1.Promise.resolve();
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
LocalStreamManager.prototype.destroyDesktopMediaStream = function () {
|
|
194
|
+
var streamResult = window.latestDesktopMediaStream;
|
|
195
|
+
window.latestDesktopMediaStream = null;
|
|
196
|
+
desktopMediaPromise = null;
|
|
197
|
+
|
|
198
|
+
if (streamResult && streamResult.mediaStream) {
|
|
199
|
+
try {
|
|
200
|
+
streamResult.mediaStream.getTracks().forEach(function (track) {
|
|
201
|
+
track.stop();
|
|
202
|
+
});
|
|
203
|
+
trace.info('destroyDesktopMediaStream - stop all tracks');
|
|
204
|
+
} catch (e) {
|
|
205
|
+
trace.info('destroyDesktopMediaStream - Failed to stop all tracks', e);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return bluebird_1.Promise.resolve();
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
LocalStreamManager.prototype.clearAllStreams = function () {
|
|
213
|
+
trace.info('LocalStreamManager Clearing all streams');
|
|
214
|
+
return bluebird_1.Promise.all([this.destroyDesktopMediaStream(), this.destroyUserMediaStream()]).then(function () {
|
|
215
|
+
return undefined;
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
LocalStreamManager.prototype.getHighestResolutionStream = function (isDesktopMedia, constraints) {
|
|
220
|
+
var _this = this;
|
|
221
|
+
|
|
222
|
+
var constraintsCandidates = this.getParsedConstraints(isDesktopMedia, constraints);
|
|
223
|
+
trace.info('getHighestResolutionStream - constraintsCandidates:', constraintsCandidates);
|
|
224
|
+
|
|
225
|
+
if (constraintsCandidates.length === 0) {
|
|
226
|
+
return bluebird_1.Promise.reject(new Error('No constraints to retrieve the stream'));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return new bluebird_1.Promise(function (resolve, reject) {
|
|
230
|
+
var lastSuccessfulResult = null;
|
|
231
|
+
var lastFailedResult = null;
|
|
232
|
+
var isStreamRequestFulfilled = false;
|
|
233
|
+
bluebird_1.Promise.reduce(constraintsCandidates, function (total, candidate) {
|
|
234
|
+
if (isStreamRequestFulfilled) {
|
|
235
|
+
return;
|
|
139
236
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}).catch(function (failResult) {
|
|
160
|
-
lastFailedResult = failResult;
|
|
161
|
-
if (lastFailedResult.errorCode === MediaConstants_1.MediaRequestErrorCode.PermissionDenied) {
|
|
162
|
-
isStreamRequestFulfilled = true;
|
|
163
|
-
reject(lastFailedResult);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}, 0).then(function () {
|
|
167
|
-
if (!isStreamRequestFulfilled) {
|
|
168
|
-
if (!lastFailedResult) {
|
|
169
|
-
lastFailedResult = {
|
|
170
|
-
errorCode: MediaConstants_1.MediaRequestErrorCode.GeneralError,
|
|
171
|
-
message: 'Suitable stream cannot be created'
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
reject(lastFailedResult);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
237
|
+
|
|
238
|
+
var constraintType = get_1["default"](constraints, 'video.videoResolution.constraintType') || get_1["default"](constraints, 'video.videoResolution[0].constraintType');
|
|
239
|
+
return _this.getStreamPromiseByParsedConstraints(candidate, isDesktopMedia).then(function (stream) {
|
|
240
|
+
lastSuccessfulResult = {
|
|
241
|
+
mediaStream: stream,
|
|
242
|
+
constraint: candidate,
|
|
243
|
+
constraintType: constraintType,
|
|
244
|
+
isNew: true
|
|
245
|
+
};
|
|
246
|
+
trace.info('getHighestResolutionStream Success', lastSuccessfulResult);
|
|
247
|
+
isStreamRequestFulfilled = true;
|
|
248
|
+
resolve(lastSuccessfulResult);
|
|
249
|
+
})["catch"](function (failResult) {
|
|
250
|
+
lastFailedResult = failResult;
|
|
251
|
+
|
|
252
|
+
if (lastFailedResult.errorCode === MediaConstants_1.MediaRequestErrorCode.PermissionDenied) {
|
|
253
|
+
isStreamRequestFulfilled = true;
|
|
254
|
+
reject(lastFailedResult);
|
|
255
|
+
}
|
|
177
256
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
257
|
+
}, 0).then(function () {
|
|
258
|
+
if (!isStreamRequestFulfilled) {
|
|
259
|
+
if (!lastFailedResult) {
|
|
260
|
+
lastFailedResult = {
|
|
261
|
+
errorCode: MediaConstants_1.MediaRequestErrorCode.GeneralError,
|
|
262
|
+
message: 'Suitable stream cannot be created'
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
reject(lastFailedResult);
|
|
188
267
|
}
|
|
189
|
-
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
LocalStreamManager.prototype.getUserMediaStreamMediaDevice = function (constraints, isDesktopMedia) {
|
|
273
|
+
var streamPromise = null;
|
|
274
|
+
|
|
275
|
+
if (!isDesktopMedia) {
|
|
276
|
+
streamPromise = navigator.mediaDevices.getUserMedia(constraints);
|
|
277
|
+
} else {
|
|
278
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
279
|
+
//@ts-ignore
|
|
280
|
+
streamPromise = navigator.mediaDevices.getDisplayMedia // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
281
|
+
//@ts-ignore
|
|
282
|
+
? navigator.mediaDevices.getDisplayMedia(constraints) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
283
|
+
//@ts-ignore
|
|
284
|
+
: navigator.getDisplayMedia(constraints);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return streamPromise;
|
|
288
|
+
}; // eslint-disable-next-line consistent-return,@typescript-eslint/ban-ts-comment
|
|
289
|
+
// @ts-ignore
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
LocalStreamManager.prototype.getStreamPromiseByParsedConstraints = function (constraints, isDesktopMedia) {
|
|
293
|
+
var _this = this;
|
|
294
|
+
|
|
295
|
+
trace.info('getStreamPromiseByParsedConstraints', constraints);
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
return this.getUserMediaStreamMediaDevice(constraints, isDesktopMedia)["catch"](function (err) {
|
|
299
|
+
var streamPromise = null;
|
|
300
|
+
trace.info('getStreamPromiseByParsedConstraints - get user stream error', err.name); // Android (Galaxy esp.) have a bug that when using facingMode it might cause NotReadableError. So
|
|
301
|
+
// we should try again but without facingMode. The exception to the rule is when we don't have specific
|
|
302
|
+
// device to use (like in IOS13 bug, as can be seen in MediaServiceBase.ts), in that case, we might end
|
|
303
|
+
// up using the front camera, which is a privacy concern and the preference is to fallback from video
|
|
304
|
+
|
|
305
|
+
if (err && err.name === 'NotReadableError' && get_1["default"](constraints, 'video.facingMode') && get_1["default"](constraints, 'video.deviceId')) {
|
|
306
|
+
var newConstraints = constraints;
|
|
307
|
+
trace.info("getStreamPromiseByParsedConstraints - NotReadableError - Failed to get video user media stream with facingMode=" + get_1["default"](constraints, 'video.facingMode'), err.name); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
|
|
310
|
+
delete newConstraints.video.facingMode;
|
|
311
|
+
newConstraints.video.deviceId = {
|
|
312
|
+
exact: constraints.video.deviceId
|
|
313
|
+
};
|
|
314
|
+
streamPromise = _this.getStreamPromiseByParsedConstraints(newConstraints, isDesktopMedia);
|
|
315
|
+
} else if (err && err.name && constraints.audio && !constraints.video) {
|
|
316
|
+
trace.info('getStreamPromiseByParsedConstraints - audioStreamFailed - Failed to get audio user media stream', err.name);
|
|
317
|
+
return _this.parseMediaErrorThenThrow({
|
|
318
|
+
name: 'audioStreamFailed'
|
|
319
|
+
});
|
|
320
|
+
} else if (err && err.name && constraints.audio) {
|
|
321
|
+
var newConstraints = constraints;
|
|
322
|
+
trace.info('getStreamPromiseByParsedConstraints - Failed to get video and audio user media stream, try to get video media stream only', err.name);
|
|
323
|
+
newConstraints.audio = false;
|
|
324
|
+
streamPromise = _this.getStreamPromiseByParsedConstraints(newConstraints, isDesktopMedia);
|
|
325
|
+
} else if (err && !streamPromise) {
|
|
326
|
+
trace.info('getStreamPromiseByParsedConstraints - Failed to get video user media stream', err && err.name);
|
|
327
|
+
streamPromise = bluebird_1.Promise.reject(err);
|
|
225
328
|
}
|
|
329
|
+
|
|
330
|
+
return streamPromise && streamPromise["catch"](_this.parseMediaErrorThenThrow);
|
|
331
|
+
});
|
|
332
|
+
} catch (e) {
|
|
333
|
+
this.parseMediaErrorThenThrow(e);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
LocalStreamManager.prototype.setGroupedDevices = function (groupedDevices) {
|
|
338
|
+
var _a;
|
|
339
|
+
|
|
340
|
+
trace.info('setGroupedDevices', groupedDevices);
|
|
341
|
+
this._groupedDevices = {
|
|
342
|
+
video: groupedDevices.video ? (_a = {}, _a[MediaConstants_1.CameraTypes.BACK] = last_1["default"](groupedDevices.video), _a[MediaConstants_1.CameraTypes.FRONT] = first_1["default"](groupedDevices.video), _a) : null,
|
|
343
|
+
audio: last_1["default"](groupedDevices.audio) || null,
|
|
344
|
+
camerasCount: groupedDevices.video.length
|
|
226
345
|
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
LocalStreamManager.prototype.getParsedConstraints = function (isDesktopMedia, streamConstraints) {
|
|
349
|
+
var constraintCandidates = []; //TODO - Alex: need to understand which constraints not compatible with screen share
|
|
350
|
+
|
|
351
|
+
if (isDesktopMedia) {
|
|
352
|
+
return [{
|
|
353
|
+
video: true
|
|
354
|
+
}];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (!streamConstraints) {
|
|
358
|
+
return constraintCandidates;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var baseConstraints = {};
|
|
362
|
+
baseConstraints.audio = typeof streamConstraints.audio === 'boolean' ? streamConstraints.audio : undefined;
|
|
363
|
+
|
|
364
|
+
if (!streamConstraints.video) {
|
|
365
|
+
return [baseConstraints];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
var cameraType = streamConstraints.video !== 'boolean' && streamConstraints.video.videoSourceType;
|
|
369
|
+
baseConstraints.video = {
|
|
370
|
+
facingMode: cameraType && cameraType === MediaConstants_1.LocalVideoSourceType.CAMERA_FRONT ? 'user' : 'environment',
|
|
371
|
+
frameRate: {
|
|
372
|
+
ideal: 15,
|
|
373
|
+
max: 30
|
|
374
|
+
}
|
|
231
375
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
var baseConstraints = {};
|
|
242
|
-
baseConstraints.audio = typeof streamConstraints.audio === 'boolean' ? streamConstraints.audio : undefined;
|
|
243
|
-
if (!streamConstraints.video) {
|
|
244
|
-
return [baseConstraints];
|
|
245
|
-
}
|
|
246
|
-
var cameraType = streamConstraints.video !== 'boolean' && streamConstraints.video.videoSourceType;
|
|
247
|
-
baseConstraints.video = {
|
|
248
|
-
facingMode: cameraType && cameraType === MediaConstants_1.LocalVideoSourceType.CAMERA_FORNT ? 'user' : 'environment',
|
|
249
|
-
frameRate: { ideal: 15, max: 30 }
|
|
250
|
-
};
|
|
251
|
-
var deviceId = get_1.default(this._groupedDevices, "video." + (cameraType === MediaConstants_1.LocalVideoSourceType.CAMERA_FORNT ? 'front' : 'back') + ".deviceId");
|
|
252
|
-
if (deviceId) {
|
|
253
|
-
baseConstraints.video.deviceId = deviceId;
|
|
254
|
-
}
|
|
255
|
-
var assignConstraint = function assignConstraint(videoResolution) {
|
|
256
|
-
var _a = videoResolution.resolution.split('x'),
|
|
257
|
-
width = _a[0],
|
|
258
|
-
height = _a[1];
|
|
259
|
-
var constraintCandidate = assign_1.default({}, baseConstraints);
|
|
260
|
-
constraintCandidate.video = assign_1.default({}, baseConstraints.video, {
|
|
261
|
-
width: _constraintByType(width, videoResolution.constraintType),
|
|
262
|
-
height: _constraintByType(height, videoResolution.constraintType)
|
|
263
|
-
});
|
|
264
|
-
constraintCandidates.push(constraintCandidate);
|
|
376
|
+
var deviceId = get_1["default"](this._groupedDevices, "video." + (cameraType === MediaConstants_1.LocalVideoSourceType.CAMERA_FRONT ? MediaConstants_1.CameraTypes.FRONT : MediaConstants_1.CameraTypes.BACK) + ".deviceId");
|
|
377
|
+
|
|
378
|
+
if (deviceId) {
|
|
379
|
+
baseConstraints.video.deviceId = deviceId;
|
|
380
|
+
|
|
381
|
+
if (this._groupedDevices.camerasCount > 1) {
|
|
382
|
+
baseConstraints.video.facingMode = {
|
|
383
|
+
exact: baseConstraints.video.facingMode
|
|
265
384
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
var assignConstraint = function assignConstraint(videoResolution) {
|
|
389
|
+
var _a = videoResolution.resolution.split('x'),
|
|
390
|
+
width = _a[0],
|
|
391
|
+
height = _a[1];
|
|
392
|
+
|
|
393
|
+
var constraintCandidate = assign_1["default"]({}, baseConstraints);
|
|
394
|
+
constraintCandidate.video = assign_1["default"]({}, baseConstraints.video, {
|
|
395
|
+
width: _constraintByType(width, videoResolution.constraintType),
|
|
396
|
+
height: _constraintByType(height, videoResolution.constraintType)
|
|
397
|
+
});
|
|
398
|
+
constraintCandidates.push(constraintCandidate);
|
|
276
399
|
};
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
400
|
+
|
|
401
|
+
if (baseConstraints.video && typeof streamConstraints.video === 'boolean' || !(streamConstraints.video.videoResolution instanceof Array)) {
|
|
402
|
+
var defaultResolution = {
|
|
403
|
+
resolution: MediaConstants_1.DEFAULT_VIDEO_RESOLUTION,
|
|
404
|
+
constraintType: MediaConstants_1.DEFAULT_VIDEO_CONSTRAINT_TYPE
|
|
405
|
+
};
|
|
406
|
+
assignConstraint(defaultResolution);
|
|
407
|
+
return constraintCandidates;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
streamConstraints.video.videoResolution.forEach(assignConstraint);
|
|
411
|
+
return constraintCandidates;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
LocalStreamManager.prototype.parseMediaErrorThenThrow = function (error) {
|
|
415
|
+
if (error && error.errorCode) {
|
|
416
|
+
throw error;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
trace.error('Get media stream error.', error);
|
|
420
|
+
var errorName = error && error.name ? error.name : '';
|
|
421
|
+
var permissionErrorNames = ['NotAllowedError', 'PermissionDismissedError', 'PermissionDeniedError']; // const generalError = [
|
|
422
|
+
// 'NotFoundError',
|
|
423
|
+
// 'DevicesNotFoundError',
|
|
424
|
+
// 'NotReadableError',
|
|
425
|
+
// 'TrackStartError'
|
|
426
|
+
// ];
|
|
427
|
+
|
|
428
|
+
var constraintsErrors = ['OverconstrainedError', 'ConstraintNotSatisfiedError'];
|
|
429
|
+
|
|
430
|
+
var isErrorOfType = function isErrorOfType(errorsArr) {
|
|
431
|
+
return errorsArr.filter(function (err) {
|
|
432
|
+
return err === errorName;
|
|
433
|
+
}).length > 0;
|
|
303
434
|
};
|
|
304
|
-
|
|
435
|
+
|
|
436
|
+
if (isErrorOfType(permissionErrorNames)) {
|
|
437
|
+
throw {
|
|
438
|
+
errorCode: MediaConstants_1.MediaRequestErrorCode.PermissionDenied,
|
|
439
|
+
message: errorName
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (isErrorOfType(constraintsErrors)) {
|
|
444
|
+
throw {
|
|
445
|
+
errorCode: MediaConstants_1.MediaRequestErrorCode.Overconstrained,
|
|
446
|
+
message: errorName
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
throw {
|
|
451
|
+
errorCode: MediaConstants_1.MediaRequestErrorCode.GeneralError,
|
|
452
|
+
message: errorName
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
return LocalStreamManager;
|
|
305
457
|
}();
|
|
458
|
+
|
|
306
459
|
exports.LocalStreamManager = LocalStreamManager;
|
|
460
|
+
|
|
307
461
|
function _constraintByType(value, type) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
}
|
|
462
|
+
switch (type) {
|
|
463
|
+
case MediaConstants_1.ConstraintType.MIN:
|
|
464
|
+
return {
|
|
465
|
+
min: value
|
|
466
|
+
};
|
|
315
467
|
|
|
316
|
-
|
|
468
|
+
default:
|
|
469
|
+
return {
|
|
470
|
+
ideal: value
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
}
|
|
317
474
|
//# sourceMappingURL=LocalStreamManager.js.map
|