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