@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
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
4
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
5
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
6
|
+
__proto__: []
|
|
7
|
+
} instanceof Array && function (d, b) {
|
|
8
|
+
d.__proto__ = b;
|
|
9
|
+
} || function (d, b) {
|
|
10
|
+
for (var p in b) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return _extendStatics(d, b);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return function (d, b) {
|
|
19
|
+
_extendStatics(d, b);
|
|
20
|
+
|
|
21
|
+
function __() {
|
|
22
|
+
this.constructor = d;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
26
|
+
};
|
|
27
|
+
}();
|
|
28
|
+
|
|
29
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
30
|
+
__assign = Object.assign || function (t) {
|
|
31
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
32
|
+
s = arguments[i];
|
|
33
|
+
|
|
34
|
+
for (var p in s) {
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return __assign.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
46
|
+
function adopt(value) {
|
|
47
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
48
|
+
resolve(value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
53
|
+
function fulfilled(value) {
|
|
54
|
+
try {
|
|
55
|
+
step(generator.next(value));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
reject(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function rejected(value) {
|
|
62
|
+
try {
|
|
63
|
+
step(generator["throw"](value));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
reject(e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function step(result) {
|
|
70
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
|
|
78
|
+
var _ = {
|
|
79
|
+
label: 0,
|
|
80
|
+
sent: function sent() {
|
|
81
|
+
if (t[0] & 1) throw t[1];
|
|
82
|
+
return t[1];
|
|
83
|
+
},
|
|
84
|
+
trys: [],
|
|
85
|
+
ops: []
|
|
86
|
+
},
|
|
87
|
+
f,
|
|
88
|
+
y,
|
|
89
|
+
t,
|
|
90
|
+
g;
|
|
91
|
+
return g = {
|
|
92
|
+
next: verb(0),
|
|
93
|
+
"throw": verb(1),
|
|
94
|
+
"return": verb(2)
|
|
95
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
96
|
+
return this;
|
|
97
|
+
}), g;
|
|
98
|
+
|
|
99
|
+
function verb(n) {
|
|
100
|
+
return function (v) {
|
|
101
|
+
return step([n, v]);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function step(op) {
|
|
106
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
107
|
+
|
|
108
|
+
while (_) {
|
|
109
|
+
try {
|
|
110
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
111
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
112
|
+
|
|
113
|
+
switch (op[0]) {
|
|
114
|
+
case 0:
|
|
115
|
+
case 1:
|
|
116
|
+
t = op;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 4:
|
|
120
|
+
_.label++;
|
|
121
|
+
return {
|
|
122
|
+
value: op[1],
|
|
123
|
+
done: false
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
case 5:
|
|
127
|
+
_.label++;
|
|
128
|
+
y = op[1];
|
|
129
|
+
op = [0];
|
|
130
|
+
continue;
|
|
131
|
+
|
|
132
|
+
case 7:
|
|
133
|
+
op = _.ops.pop();
|
|
134
|
+
|
|
135
|
+
_.trys.pop();
|
|
136
|
+
|
|
137
|
+
continue;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
141
|
+
_ = 0;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
146
|
+
_.label = op[1];
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
151
|
+
_.label = t[1];
|
|
152
|
+
t = op;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (t && _.label < t[2]) {
|
|
157
|
+
_.label = t[2];
|
|
158
|
+
|
|
159
|
+
_.ops.push(op);
|
|
160
|
+
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (t[2]) _.ops.pop();
|
|
165
|
+
|
|
166
|
+
_.trys.pop();
|
|
167
|
+
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
op = body.call(thisArg, _);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
op = [6, e];
|
|
174
|
+
y = 0;
|
|
175
|
+
} finally {
|
|
176
|
+
f = t = 0;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (op[0] & 5) throw op[1];
|
|
181
|
+
return {
|
|
182
|
+
value: op[0] ? op[1] : void 0,
|
|
183
|
+
done: true
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var __spreadArrays = void 0 && (void 0).__spreadArrays || function () {
|
|
189
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
|
|
190
|
+
s += arguments[i].length;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++) {
|
|
194
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
|
|
195
|
+
r[k] = a[j];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return r;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
Object.defineProperty(exports, "__esModule", {
|
|
203
|
+
value: true
|
|
204
|
+
});
|
|
205
|
+
exports.OpentokMultiPartyService = void 0;
|
|
206
|
+
|
|
207
|
+
var MediaConstants_1 = require("../MediaConstants");
|
|
208
|
+
|
|
209
|
+
var MediaUtils_1 = require("../MediaUtils");
|
|
210
|
+
|
|
211
|
+
var MediaCapabilitiesService_1 = require("./MediaCapabilitiesService");
|
|
212
|
+
|
|
213
|
+
var MediaCapabilitiesUtils_1 = require("./MediaCapabilitiesUtils");
|
|
214
|
+
|
|
215
|
+
var MultiPartyService_1 = require("./MultiPartyService");
|
|
216
|
+
|
|
217
|
+
var trace = MediaUtils_1.getMediaTracer('Multiparty'); // The preferred camera position to use for the video source
|
|
218
|
+
|
|
219
|
+
var OpentokFacingMode;
|
|
220
|
+
|
|
221
|
+
(function (OpentokFacingMode) {
|
|
222
|
+
OpentokFacingMode["USER"] = "user";
|
|
223
|
+
OpentokFacingMode["ENVIRONMENT"] = "environment";
|
|
224
|
+
})(OpentokFacingMode || (OpentokFacingMode = {}));
|
|
225
|
+
|
|
226
|
+
var OpentokMultiPartyService =
|
|
227
|
+
/** @class */
|
|
228
|
+
function (_super) {
|
|
229
|
+
__extends(OpentokMultiPartyService, _super);
|
|
230
|
+
|
|
231
|
+
function OpentokMultiPartyService(settings, getParticipantId) {
|
|
232
|
+
var _this = _super.call(this, settings) || this;
|
|
233
|
+
|
|
234
|
+
_this.getParticipantId = getParticipantId;
|
|
235
|
+
_this.subscriberList = [];
|
|
236
|
+
|
|
237
|
+
_this.connect = function (credentials) {
|
|
238
|
+
try {
|
|
239
|
+
_this.session = OT.initSession(credentials.apiKey, credentials.sessionId);
|
|
240
|
+
|
|
241
|
+
_this.session.on('connectionCreated', _this.connectionCreatedHandler);
|
|
242
|
+
|
|
243
|
+
_this.session.on('connectionDestroyed', _this.connectionDestroyedHandler);
|
|
244
|
+
|
|
245
|
+
_this.session.on('streamCreated', _this.streamCreatedHandler);
|
|
246
|
+
|
|
247
|
+
_this.session.on('streamDestroyed', _this.streamDestroyedHandler);
|
|
248
|
+
|
|
249
|
+
_this.session.on('streamPropertyChanged', _this.streamPropertyChangedHandler);
|
|
250
|
+
|
|
251
|
+
_this.session.on('sessionDisconnected', _this.sessionDisconnectedHandler);
|
|
252
|
+
|
|
253
|
+
_this.session.connect(credentials.token, function (error) {
|
|
254
|
+
var _a;
|
|
255
|
+
|
|
256
|
+
if (error) {
|
|
257
|
+
(_a = _this.session) === null || _a === void 0 ? void 0 : _a.off();
|
|
258
|
+
_this.session = undefined;
|
|
259
|
+
|
|
260
|
+
_this.traceErrorCallback(error);
|
|
261
|
+
|
|
262
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
263
|
+
meta: {
|
|
264
|
+
err: JSON.stringify(error)
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
_this.createPublisher(_this.settings);
|
|
272
|
+
});
|
|
273
|
+
} catch (err) {
|
|
274
|
+
trace.error(JSON.stringify(err));
|
|
275
|
+
|
|
276
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectFailed, {
|
|
277
|
+
meta: {
|
|
278
|
+
err: JSON.stringify(err)
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
_this.disconnect = function () {
|
|
285
|
+
try {
|
|
286
|
+
trace.info('Disconnecting from session');
|
|
287
|
+
|
|
288
|
+
if (_this.session) {
|
|
289
|
+
_this.session.disconnect();
|
|
290
|
+
|
|
291
|
+
trace.info('Disconnection from session completed');
|
|
292
|
+
}
|
|
293
|
+
} catch (err) {
|
|
294
|
+
trace.error(JSON.stringify(err));
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
_this.createPublisher = function (settings) {
|
|
299
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
300
|
+
var canStartWithAudio, canStartWithVideo;
|
|
301
|
+
|
|
302
|
+
var _a;
|
|
303
|
+
|
|
304
|
+
return __generator(this, function (_b) {
|
|
305
|
+
switch (_b.label) {
|
|
306
|
+
case 0:
|
|
307
|
+
return [4
|
|
308
|
+
/*yield*/
|
|
309
|
+
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
310
|
+
|
|
311
|
+
case 1:
|
|
312
|
+
canStartWithAudio = _b.sent();
|
|
313
|
+
return [4
|
|
314
|
+
/*yield*/
|
|
315
|
+
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
316
|
+
|
|
317
|
+
case 2:
|
|
318
|
+
canStartWithVideo = _b.sent();
|
|
319
|
+
|
|
320
|
+
if (!canStartWithAudio && !canStartWithVideo) {
|
|
321
|
+
// FIXME: use emitter
|
|
322
|
+
trace.error('Did not create publisher due to lack of media capabilities.');
|
|
323
|
+
return [2
|
|
324
|
+
/*return*/
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (!!this.currentPublisher) return [3
|
|
329
|
+
/*break*/
|
|
330
|
+
, 4];
|
|
331
|
+
return [4
|
|
332
|
+
/*yield*/
|
|
333
|
+
, this.initPublisher(__assign(__assign({}, settings), {
|
|
334
|
+
cameraEnabled: settings.cameraEnabled && canStartWithVideo,
|
|
335
|
+
startWithAudioMuted: settings.startWithAudioMuted && canStartWithAudio
|
|
336
|
+
}))];
|
|
337
|
+
|
|
338
|
+
case 3:
|
|
339
|
+
_b.sent();
|
|
340
|
+
|
|
341
|
+
if (!this.currentPublisher) {
|
|
342
|
+
throw new Error('Creating session requires initialized publisher');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
this.currentPublisher && ((_a = this.session) === null || _a === void 0 ? void 0 : _a.publish(this.currentPublisher, this.traceErrorCallback));
|
|
346
|
+
_b.label = 4;
|
|
347
|
+
|
|
348
|
+
case 4:
|
|
349
|
+
return [2
|
|
350
|
+
/*return*/
|
|
351
|
+
];
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
_this.publishAudio = function (shouldMute) {
|
|
358
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
359
|
+
var canPublishAudio;
|
|
360
|
+
return __generator(this, function (_a) {
|
|
361
|
+
switch (_a.label) {
|
|
362
|
+
case 0:
|
|
363
|
+
return [4
|
|
364
|
+
/*yield*/
|
|
365
|
+
, MediaCapabilitiesUtils_1.checkAudioCapabilities()];
|
|
366
|
+
|
|
367
|
+
case 1:
|
|
368
|
+
canPublishAudio = _a.sent(); // why do we care about audio if 'shouldMute' is true?
|
|
369
|
+
|
|
370
|
+
if (shouldMute && !canPublishAudio) {
|
|
371
|
+
trace.error('could not publish audio');
|
|
372
|
+
return [2
|
|
373
|
+
/*return*/
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (!!this.currentPublisher) return [3
|
|
378
|
+
/*break*/
|
|
379
|
+
, 3];
|
|
380
|
+
return [4
|
|
381
|
+
/*yield*/
|
|
382
|
+
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
383
|
+
// so if 'shouldMute' is true then we DON't mute?
|
|
384
|
+
startWithAudioMuted: !shouldMute
|
|
385
|
+
}))];
|
|
386
|
+
|
|
387
|
+
case 2:
|
|
388
|
+
_a.sent();
|
|
389
|
+
|
|
390
|
+
return [3
|
|
391
|
+
/*break*/
|
|
392
|
+
, 4];
|
|
393
|
+
|
|
394
|
+
case 3:
|
|
395
|
+
this.currentPublisher.publishAudio(shouldMute);
|
|
396
|
+
_a.label = 4;
|
|
397
|
+
|
|
398
|
+
case 4:
|
|
399
|
+
return [2
|
|
400
|
+
/*return*/
|
|
401
|
+
];
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
_this.publishVideo = function (shouldPublishVideo) {
|
|
408
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
409
|
+
var canPublishVideo;
|
|
410
|
+
return __generator(this, function (_a) {
|
|
411
|
+
switch (_a.label) {
|
|
412
|
+
case 0:
|
|
413
|
+
return [4
|
|
414
|
+
/*yield*/
|
|
415
|
+
, MediaCapabilitiesUtils_1.checkVideoCapabilities()];
|
|
416
|
+
|
|
417
|
+
case 1:
|
|
418
|
+
canPublishVideo = _a.sent();
|
|
419
|
+
|
|
420
|
+
if (shouldPublishVideo && !canPublishVideo) {
|
|
421
|
+
trace.error('could not publish video');
|
|
422
|
+
return [2
|
|
423
|
+
/*return*/
|
|
424
|
+
];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (!!this.currentPublisher) return [3
|
|
428
|
+
/*break*/
|
|
429
|
+
, 3];
|
|
430
|
+
return [4
|
|
431
|
+
/*yield*/
|
|
432
|
+
, this.createPublisher(__assign(__assign({}, this.settings), {
|
|
433
|
+
cameraEnabled: shouldPublishVideo
|
|
434
|
+
}))];
|
|
435
|
+
|
|
436
|
+
case 2:
|
|
437
|
+
_a.sent();
|
|
438
|
+
|
|
439
|
+
return [3
|
|
440
|
+
/*break*/
|
|
441
|
+
, 4];
|
|
442
|
+
|
|
443
|
+
case 3:
|
|
444
|
+
this.currentPublisher.publishVideo(shouldPublishVideo);
|
|
445
|
+
_a.label = 4;
|
|
446
|
+
|
|
447
|
+
case 4:
|
|
448
|
+
return [2
|
|
449
|
+
/*return*/
|
|
450
|
+
];
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
_this.switchCamera = function () {
|
|
457
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
458
|
+
var mediaCapabilitiesService, deviceId, cameraType_1, err_1;
|
|
459
|
+
|
|
460
|
+
var _this = this;
|
|
461
|
+
|
|
462
|
+
var _a;
|
|
463
|
+
|
|
464
|
+
return __generator(this, function (_b) {
|
|
465
|
+
switch (_b.label) {
|
|
466
|
+
case 0:
|
|
467
|
+
_b.trys.push([0, 2,, 3]);
|
|
468
|
+
|
|
469
|
+
return [4
|
|
470
|
+
/*yield*/
|
|
471
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
472
|
+
|
|
473
|
+
case 1:
|
|
474
|
+
mediaCapabilitiesService = _b.sent();
|
|
475
|
+
|
|
476
|
+
if (!mediaCapabilitiesService.supportSwitchCamera) {
|
|
477
|
+
throw new Error('Not Support switch camera');
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
deviceId = '';
|
|
481
|
+
|
|
482
|
+
switch (this.settings.selectedCamera) {
|
|
483
|
+
case MediaConstants_1.MultiPartyCameraTypes.BACK:
|
|
484
|
+
cameraType_1 = MediaConstants_1.MultiPartyCameraTypes.FRONT;
|
|
485
|
+
deviceId = mediaCapabilitiesService.frontCameraDeviceId;
|
|
486
|
+
break;
|
|
487
|
+
|
|
488
|
+
case MediaConstants_1.MultiPartyCameraTypes.FRONT:
|
|
489
|
+
cameraType_1 = MediaConstants_1.MultiPartyCameraTypes.BACK;
|
|
490
|
+
deviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
491
|
+
break;
|
|
492
|
+
|
|
493
|
+
default:
|
|
494
|
+
throw new Error("cameraType not valid: " + this.settings.selectedCamera);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return [2
|
|
498
|
+
/*return*/
|
|
499
|
+
, (_a = this.currentPublisher) === null || _a === void 0 ? void 0 : _a.setVideoSource(deviceId).then(function () {
|
|
500
|
+
_this.settings.selectedCamera = cameraType_1;
|
|
501
|
+
|
|
502
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.cameraSourceChanged, {
|
|
503
|
+
cameraSource: cameraType_1
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
trace.info("Success to switch camera to cameraType: " + cameraType_1);
|
|
507
|
+
})];
|
|
508
|
+
|
|
509
|
+
case 2:
|
|
510
|
+
err_1 = _b.sent();
|
|
511
|
+
trace.error(JSON.stringify(err_1));
|
|
512
|
+
throw err_1;
|
|
513
|
+
|
|
514
|
+
case 3:
|
|
515
|
+
return [2
|
|
516
|
+
/*return*/
|
|
517
|
+
];
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
_this.initPublisher = function (settings) {
|
|
524
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
525
|
+
var selectedCamera, isMobile, mediaCapabilitiesService, frontCameraDeviceId, backCameraDeviceId, videoSourceId, mobileCameraType, err_2;
|
|
526
|
+
|
|
527
|
+
var _this = this;
|
|
528
|
+
|
|
529
|
+
var _a, _b, _c;
|
|
530
|
+
|
|
531
|
+
return __generator(this, function (_d) {
|
|
532
|
+
switch (_d.label) {
|
|
533
|
+
case 0:
|
|
534
|
+
_d.trys.push([0, 2,, 3]);
|
|
535
|
+
|
|
536
|
+
selectedCamera = settings.selectedCamera;
|
|
537
|
+
isMobile = MediaCapabilitiesUtils_1.checkIsMobile();
|
|
538
|
+
return [4
|
|
539
|
+
/*yield*/
|
|
540
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.getInstance()];
|
|
541
|
+
|
|
542
|
+
case 1:
|
|
543
|
+
mediaCapabilitiesService = _d.sent();
|
|
544
|
+
frontCameraDeviceId = mediaCapabilitiesService.frontCameraDeviceId, backCameraDeviceId = mediaCapabilitiesService.backCameraDeviceId;
|
|
545
|
+
videoSourceId = (selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? frontCameraDeviceId : backCameraDeviceId) || undefined;
|
|
546
|
+
mobileCameraType = settings.selectedCamera === MediaConstants_1.MultiPartyCameraTypes.FRONT ? OpentokFacingMode.USER : OpentokFacingMode.ENVIRONMENT;
|
|
547
|
+
this.currentPublisher = OT.initPublisher(this.getParticipantId(((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b.connectionId) || ''), {
|
|
548
|
+
insertMode: 'append',
|
|
549
|
+
fitMode: 'cover',
|
|
550
|
+
width: '100%',
|
|
551
|
+
height: '100%',
|
|
552
|
+
style: {
|
|
553
|
+
buttonDisplayMode: 'off',
|
|
554
|
+
archiveStatusDisplayMode: 'off',
|
|
555
|
+
audioLevelDisplayMode: 'off',
|
|
556
|
+
backgroundImageURI: ((_c = this.branding) === null || _c === void 0 ? void 0 : _c.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
557
|
+
},
|
|
558
|
+
publishAudio: !settings.startWithAudioMuted,
|
|
559
|
+
publishVideo: settings.cameraEnabled,
|
|
560
|
+
videoSource: !isMobile ? videoSourceId : undefined,
|
|
561
|
+
facingMode: isMobile || !videoSourceId ? mobileCameraType : undefined
|
|
562
|
+
}, this.traceErrorCallback);
|
|
563
|
+
|
|
564
|
+
if (!this.currentPublisher) {
|
|
565
|
+
trace.error('failed to init publisher');
|
|
566
|
+
} else {
|
|
567
|
+
this.currentPublisher.on('videoElementCreated', function (event) {
|
|
568
|
+
trace.info('videoElementCreated', event);
|
|
569
|
+
|
|
570
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoElementCreated, event);
|
|
571
|
+
});
|
|
572
|
+
this.currentPublisher.on('streamDestroyed', function (event) {
|
|
573
|
+
var _a;
|
|
574
|
+
|
|
575
|
+
trace.info('Publisher stream destroyed', event);
|
|
576
|
+
|
|
577
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
578
|
+
event: event,
|
|
579
|
+
participantId: _this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId)
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
this.currentPublisher.on('accessDenied', function (event) {
|
|
583
|
+
var _a;
|
|
584
|
+
|
|
585
|
+
trace.info('Publisher denied media permissions', event);
|
|
586
|
+
var connection = (_a = _this.session) === null || _a === void 0 ? void 0 : _a.connection;
|
|
587
|
+
var connectionId = connection === null || connection === void 0 ? void 0 : connection.connectionId;
|
|
588
|
+
|
|
589
|
+
var participantId = _this.getParticipantId(connectionId);
|
|
590
|
+
|
|
591
|
+
var isOwnConnection = _this.ownConnectionId === connectionId;
|
|
592
|
+
|
|
593
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.mediaDeviceAccessDenied, {
|
|
594
|
+
connectionId: connectionId,
|
|
595
|
+
isOwnConnection: isOwnConnection,
|
|
596
|
+
participantId: participantId
|
|
597
|
+
});
|
|
598
|
+
});
|
|
599
|
+
this.currentPublisher.on('streamCreated', function (event) {
|
|
600
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
601
|
+
var participantId;
|
|
602
|
+
|
|
603
|
+
var _a, _b, _c, _d, _e, _f;
|
|
604
|
+
|
|
605
|
+
return __generator(this, function (_g) {
|
|
606
|
+
switch (_g.label) {
|
|
607
|
+
case 0:
|
|
608
|
+
return [4
|
|
609
|
+
/*yield*/
|
|
610
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
611
|
+
|
|
612
|
+
case 1:
|
|
613
|
+
_g.sent();
|
|
614
|
+
|
|
615
|
+
participantId = this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId);
|
|
616
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
617
|
+
event: event,
|
|
618
|
+
participantId: participantId,
|
|
619
|
+
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
620
|
+
hasAudio: (_b = event === null || event === void 0 ? void 0 : event.stream) === null || _b === void 0 ? void 0 : _b.hasAudio,
|
|
621
|
+
hasVideo: (_c = event === null || event === void 0 ? void 0 : event.stream) === null || _c === void 0 ? void 0 : _c.hasVideo,
|
|
622
|
+
isOwnConnection: this.ownConnectionId === ((_e = (_d = event === null || event === void 0 ? void 0 : event.stream) === null || _d === void 0 ? void 0 : _d.connection) === null || _e === void 0 ? void 0 : _e.connectionId)
|
|
623
|
+
});
|
|
624
|
+
trace.info('publisher stream created', {
|
|
625
|
+
event: event,
|
|
626
|
+
hasAudio: (_f = this.currentPublisher) === null || _f === void 0 ? void 0 : _f['stream.hasAudio'],
|
|
627
|
+
participantId: participantId
|
|
628
|
+
});
|
|
629
|
+
return [2
|
|
630
|
+
/*return*/
|
|
631
|
+
];
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return [3
|
|
639
|
+
/*break*/
|
|
640
|
+
, 3];
|
|
641
|
+
|
|
642
|
+
case 2:
|
|
643
|
+
err_2 = _d.sent();
|
|
644
|
+
trace.error(JSON.stringify(err_2));
|
|
645
|
+
throw err_2;
|
|
646
|
+
|
|
647
|
+
case 3:
|
|
648
|
+
return [2
|
|
649
|
+
/*return*/
|
|
650
|
+
];
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
_this.reinitializeStreams = function (settings) {
|
|
657
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
658
|
+
var _this = this;
|
|
659
|
+
|
|
660
|
+
return __generator(this, function (_a) {
|
|
661
|
+
switch (_a.label) {
|
|
662
|
+
case 0:
|
|
663
|
+
if (this.currentPublisher) {
|
|
664
|
+
this.currentPublisher.destroy();
|
|
665
|
+
this.currentPublisher = undefined;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return [4
|
|
669
|
+
/*yield*/
|
|
670
|
+
, this.createPublisher(settings)];
|
|
671
|
+
|
|
672
|
+
case 1:
|
|
673
|
+
_a.sent();
|
|
674
|
+
|
|
675
|
+
this.subscriberList = this.subscriberList.map(function (s) {
|
|
676
|
+
var _a;
|
|
677
|
+
|
|
678
|
+
var connectionId = s.connectionId,
|
|
679
|
+
subscriber = s.subscriber;
|
|
680
|
+
var stream = subscriber.stream;
|
|
681
|
+
(_a = _this.session) === null || _a === void 0 ? void 0 : _a.unsubscribe(subscriber);
|
|
682
|
+
return __assign(__assign({}, s), {
|
|
683
|
+
subscriber: _this.createSubscriber(stream, connectionId)
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
return [2
|
|
687
|
+
/*return*/
|
|
688
|
+
];
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
_this.streamCreatedHandler = function (event) {
|
|
695
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
696
|
+
var stream, connection, connectionId, participantId, subscriber;
|
|
697
|
+
|
|
698
|
+
var _a, _b;
|
|
699
|
+
|
|
700
|
+
return __generator(this, function (_c) {
|
|
701
|
+
switch (_c.label) {
|
|
702
|
+
case 0:
|
|
703
|
+
trace.info('streamCreatedHandler', event.stream);
|
|
704
|
+
stream = event.stream;
|
|
705
|
+
connection = stream.connection;
|
|
706
|
+
connectionId = connection.connectionId;
|
|
707
|
+
participantId = this.getParticipantId(connectionId);
|
|
708
|
+
return [4
|
|
709
|
+
/*yield*/
|
|
710
|
+
, MediaCapabilitiesService_1.MediaCapabilitiesService.setDevicesList()];
|
|
711
|
+
|
|
712
|
+
case 1:
|
|
713
|
+
_c.sent();
|
|
714
|
+
|
|
715
|
+
this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamCreated, {
|
|
716
|
+
event: event,
|
|
717
|
+
participantId: participantId,
|
|
718
|
+
startWithAudioMuted: this.settings.startWithAudioMuted,
|
|
719
|
+
isOwnConnection: this.ownConnectionId === connectionId,
|
|
720
|
+
hasVideo: (_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.hasVideo,
|
|
721
|
+
hasAudio: (_b = event === null || event === void 0 ? void 0 : event.stream) === null || _b === void 0 ? void 0 : _b.hasAudio
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
if (!this.ownConnectionId || !stream || connectionId === this.ownConnectionId) {
|
|
725
|
+
return [2
|
|
726
|
+
/*return*/
|
|
727
|
+
];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (this.subscriberList.length >= MultiPartyService_1.maxParticipantsNumber - 1) {
|
|
731
|
+
trace.info("a new subscriber cannot be added, as the number of participants reached its limit: " + MultiPartyService_1.maxParticipantsNumber);
|
|
732
|
+
return [2
|
|
733
|
+
/*return*/
|
|
734
|
+
];
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
subscriber = this.createSubscriber(stream, connectionId);
|
|
738
|
+
this.subscriberList.push({
|
|
739
|
+
subscriber: subscriber,
|
|
740
|
+
connectionId: connectionId,
|
|
741
|
+
clientRole: this.getClientRole(connection)
|
|
742
|
+
});
|
|
743
|
+
return [2
|
|
744
|
+
/*return*/
|
|
745
|
+
];
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
_this.streamPropertyChangedHandler = function (event) {
|
|
752
|
+
var _a;
|
|
753
|
+
|
|
754
|
+
trace.info('streamPropertyChangedHandler', event);
|
|
755
|
+
var stream = event.stream;
|
|
756
|
+
|
|
757
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.videoAudioStatus, {
|
|
758
|
+
hasVideo: stream === null || stream === void 0 ? void 0 : stream.hasVideo,
|
|
759
|
+
hasAudio: stream === null || stream === void 0 ? void 0 : stream.hasAudio,
|
|
760
|
+
participantId: _this.getParticipantId(stream === null || stream === void 0 ? void 0 : stream.connection.connectionId),
|
|
761
|
+
isOwnConnection: _this.ownConnectionId === ((_a = stream === null || stream === void 0 ? void 0 : stream.connection) === null || _a === void 0 ? void 0 : _a.connectionId),
|
|
762
|
+
stream: stream
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
_this.streamDestroyedHandler = function (event) {
|
|
767
|
+
var _a;
|
|
768
|
+
|
|
769
|
+
trace.info('streamDestroyedHandler', event);
|
|
770
|
+
var stream = event.stream;
|
|
771
|
+
var destroyedConnectionId = stream && stream.connection && stream.connection.connectionId;
|
|
772
|
+
|
|
773
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.streamDestroyed, {
|
|
774
|
+
event: event,
|
|
775
|
+
participantId: _this.getParticipantId((_a = event === null || event === void 0 ? void 0 : event.stream) === null || _a === void 0 ? void 0 : _a.connection.connectionId)
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
_this.subscriberList = _this.subscriberList.filter(function (subscriber) {
|
|
779
|
+
return subscriber.connectionId !== destroyedConnectionId;
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
_this.connectionCreatedHandler = function (event) {
|
|
784
|
+
trace.info('connectionCreatedHandler', event);
|
|
785
|
+
var connection = event.connection;
|
|
786
|
+
|
|
787
|
+
if (!_this.ownConnectionId || !connection) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.subscriberList.length);
|
|
792
|
+
|
|
793
|
+
var clientRole = _this.getClientRole(connection);
|
|
794
|
+
|
|
795
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionCreated, {
|
|
796
|
+
clientRole: clientRole,
|
|
797
|
+
event: event,
|
|
798
|
+
participantId: _this.getParticipantId(connection.connectionId),
|
|
799
|
+
isOwnConnection: _this.ownConnectionId === connection.connectionId
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
_this.connectionDestroyedHandler = function (event) {
|
|
804
|
+
var connection = event.connection;
|
|
805
|
+
|
|
806
|
+
var clientRole = _this.getClientRole(connection);
|
|
807
|
+
|
|
808
|
+
trace.info('connectionDestroyedHandler', event);
|
|
809
|
+
|
|
810
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.connectionDestroyed, {
|
|
811
|
+
clientRole: clientRole,
|
|
812
|
+
event: event,
|
|
813
|
+
participantId: _this.getParticipantId(event === null || event === void 0 ? void 0 : event.connection.connectionId)
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
if (!_this.ownConnectionId || !connection || connection.connectionId !== _this.ownConnectionId) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
_this.emit(MultiPartyService_1.MULTI_PARTY_EVENTS.participantsNumberChanged, _this.subscriberList.length);
|
|
821
|
+
|
|
822
|
+
_this.session = undefined;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
_this.traceErrorCallback = function (error) {
|
|
826
|
+
trace.error(JSON.stringify(error));
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
_this.sessionDisconnectedHandler = function (event) {
|
|
830
|
+
trace.info('sessionDisconnectedHandler', event); // ToDo: Below line makes no sense (according to the OT types). This is not how OT signals work.
|
|
831
|
+
// this?.session?.signal({ retryAfterReconnect: true });
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
_this.createSubscriber = function (stream, connectionId) {
|
|
835
|
+
var _a; // ToDo: OT session can be undefined. This needs to be fixed.
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
var subscriber = _this.session.subscribe(stream, _this.getParticipantId(connectionId), {
|
|
839
|
+
insertMode: 'append',
|
|
840
|
+
fitMode: 'cover',
|
|
841
|
+
width: '100%',
|
|
842
|
+
height: '100%',
|
|
843
|
+
style: {
|
|
844
|
+
buttonDisplayMode: 'off',
|
|
845
|
+
audioLevelDisplayMode: 'off',
|
|
846
|
+
backgroundImageURI: ((_a = _this.branding) === null || _a === void 0 ? void 0 : _a.backgroundImageURI) || MultiPartyService_1.DEFAULT_AVATAR_URI
|
|
847
|
+
}
|
|
848
|
+
}, function (err) {
|
|
849
|
+
_this.traceErrorCallback(err);
|
|
850
|
+
|
|
851
|
+
subscriber === null || subscriber === void 0 ? void 0 : subscriber.on('videoElementCreated', function (event) {
|
|
852
|
+
trace.info('videoElementCreated', event);
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
return subscriber;
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
_this.branding = settings.branding;
|
|
860
|
+
return _this;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
Object.defineProperty(OpentokMultiPartyService.prototype, "ownConnectionId", {
|
|
864
|
+
get: function get() {
|
|
865
|
+
var _a, _b;
|
|
866
|
+
|
|
867
|
+
return ((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b.connectionId) || '';
|
|
868
|
+
},
|
|
869
|
+
enumerable: false,
|
|
870
|
+
configurable: true
|
|
871
|
+
});
|
|
872
|
+
Object.defineProperty(OpentokMultiPartyService.prototype, "subscribers", {
|
|
873
|
+
get: function get() {
|
|
874
|
+
return __spreadArrays(this.subscriberList);
|
|
875
|
+
},
|
|
876
|
+
enumerable: false,
|
|
877
|
+
configurable: true
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
OpentokMultiPartyService.prototype.getClientRole = function (connection) {
|
|
881
|
+
return (connection === null || connection === void 0 ? void 0 : connection.data) && JSON.parse(connection.data).clientRole || MediaConstants_1.SessionClientRole.USER;
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
return OpentokMultiPartyService;
|
|
885
|
+
}(MultiPartyService_1.MultiPartyService);
|
|
886
|
+
|
|
887
|
+
exports.OpentokMultiPartyService = OpentokMultiPartyService;
|
|
888
|
+
//# sourceMappingURL=OpentokMultiPartyService.js.map
|