@vonage/media-processor 1.2.7 → 2.0.1

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.
Files changed (36) hide show
  1. package/dist/docs/assets/highlight.css +13 -27
  2. package/dist/docs/assets/main.js +2 -2
  3. package/dist/docs/assets/search.js +1 -1
  4. package/dist/docs/assets/style.css +3 -2
  5. package/dist/docs/classes/MediaProcessor.html +51 -43
  6. package/dist/docs/classes/MediaProcessorConnector.html +12 -12
  7. package/dist/docs/enums/ErrorFunction.html +9 -0
  8. package/dist/docs/enums/PipelineInfoData.html +19 -0
  9. package/dist/docs/enums/VonageSourceType.html +5 -0
  10. package/dist/docs/enums/WarningType.html +5 -0
  11. package/dist/docs/index.html +2 -2
  12. package/dist/docs/interfaces/MediaProcessorConnectorInterface.html +4 -10
  13. package/dist/docs/interfaces/MediaProcessorInterface.html +17 -7
  14. package/dist/docs/modules.html +42 -35
  15. package/dist/media-processor.es.js +684 -1943
  16. package/dist/media-processor.min.js +1 -0
  17. package/dist/media-processor.static.js +832 -0
  18. package/dist/media-processor.umd.js +2 -3
  19. package/dist/types/lib/main.d.ts +10 -0
  20. package/dist/types/{src → lib/src}/core/InsertableStreamHelper.d.ts +0 -0
  21. package/dist/types/{src → lib/src}/core/MediaProcessor.d.ts +20 -15
  22. package/dist/types/lib/src/core/MediaProcessorConnector.d.ts +39 -0
  23. package/dist/types/{src → lib/src}/core/MediaProcessorConnectorInterface.d.ts +4 -1
  24. package/dist/types/lib/src/core/MediaProcessorInterface.d.ts +23 -0
  25. package/dist/types/lib/src/core/pipeline.d.ts +166 -0
  26. package/dist/types/{src → lib/src}/telemetry/Key.d.ts +0 -0
  27. package/dist/types/lib/src/telemetry/QosReporter.d.ts +22 -0
  28. package/dist/types/{src → lib/src}/utils/Tools.d.ts +0 -0
  29. package/dist/types/{src → lib/src}/utils/package-json.d.ts +0 -0
  30. package/dist/types/{src → lib/src}/utils/utils.d.ts +0 -0
  31. package/package.json +72 -62
  32. package/dist/types/main.d.ts +0 -9
  33. package/dist/types/src/core/MediaProcessorConnector.d.ts +0 -79
  34. package/dist/types/src/core/MediaProcessorInterface.d.ts +0 -16
  35. package/dist/types/src/core/pipeline.d.ts +0 -116
  36. package/dist/types/src/telemetry/Reporter.d.ts +0 -80
@@ -1,2049 +1,783 @@
1
- function isSupported() {
2
- return new Promise((resolve, reject) => {
3
- if (typeof MediaStreamTrackProcessor === "undefined" || typeof MediaStreamTrackGenerator === "undefined") {
4
- reject("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.");
5
- } else {
6
- resolve();
7
- }
8
- });
9
- }
10
- class Key {
11
- }
12
- Key.updates = {
13
- "transformer_new": "New transformer",
14
- "transformer_null": "Null transformer"
15
- };
16
- Key.errors = {
17
- "transformer_none": "No transformers provided",
18
- "transformer_start": "Cannot start transformer",
19
- "transformer_transform": "Cannot transform frame",
20
- "transformer_flush": "Cannot flush transformer",
21
- "readable_null": "Readable is null",
22
- "writable_null": "Writable is null"
23
- };
24
- var axios$2 = { exports: {} };
25
- var bind$2 = function bind(fn, thisArg) {
26
- return function wrap() {
27
- var args = new Array(arguments.length);
28
- for (var i = 0; i < args.length; i++) {
29
- args[i] = arguments[i];
30
- }
31
- return fn.apply(thisArg, args);
32
- };
33
- };
34
- var bind$1 = bind$2;
35
- var toString = Object.prototype.toString;
36
- function isArray(val) {
37
- return Array.isArray(val);
38
- }
39
- function isUndefined(val) {
40
- return typeof val === "undefined";
41
- }
42
- function isBuffer(val) {
43
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
44
- }
45
- function isArrayBuffer(val) {
46
- return toString.call(val) === "[object ArrayBuffer]";
47
- }
48
- function isFormData(val) {
49
- return toString.call(val) === "[object FormData]";
50
- }
51
- function isArrayBufferView(val) {
52
- var result;
53
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
54
- result = ArrayBuffer.isView(val);
55
- } else {
56
- result = val && val.buffer && isArrayBuffer(val.buffer);
57
- }
58
- return result;
59
- }
60
- function isString(val) {
61
- return typeof val === "string";
62
- }
63
- function isNumber(val) {
64
- return typeof val === "number";
65
- }
66
- function isObject(val) {
67
- return val !== null && typeof val === "object";
68
- }
69
- function isPlainObject(val) {
70
- if (toString.call(val) !== "[object Object]") {
71
- return false;
72
- }
73
- var prototype = Object.getPrototypeOf(val);
74
- return prototype === null || prototype === Object.prototype;
75
- }
76
- function isDate(val) {
77
- return toString.call(val) === "[object Date]";
78
- }
79
- function isFile(val) {
80
- return toString.call(val) === "[object File]";
81
- }
82
- function isBlob(val) {
83
- return toString.call(val) === "[object Blob]";
84
- }
85
- function isFunction(val) {
86
- return toString.call(val) === "[object Function]";
87
- }
88
- function isStream(val) {
89
- return isObject(val) && isFunction(val.pipe);
90
- }
91
- function isURLSearchParams(val) {
92
- return toString.call(val) === "[object URLSearchParams]";
93
- }
94
- function trim(str) {
95
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
96
- }
97
- function isStandardBrowserEnv() {
98
- if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
99
- return false;
100
- }
101
- return typeof window !== "undefined" && typeof document !== "undefined";
102
- }
103
- function forEach(obj, fn) {
104
- if (obj === null || typeof obj === "undefined") {
105
- return;
106
- }
107
- if (typeof obj !== "object") {
108
- obj = [obj];
109
- }
110
- if (isArray(obj)) {
111
- for (var i = 0, l = obj.length; i < l; i++) {
112
- fn.call(null, obj[i], i, obj);
113
- }
114
- } else {
115
- for (var key in obj) {
116
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
117
- fn.call(null, obj[key], key, obj);
118
- }
119
- }
120
- }
121
- }
122
- function merge() {
123
- var result = {};
124
- function assignValue(val, key) {
125
- if (isPlainObject(result[key]) && isPlainObject(val)) {
126
- result[key] = merge(result[key], val);
127
- } else if (isPlainObject(val)) {
128
- result[key] = merge({}, val);
129
- } else if (isArray(val)) {
130
- result[key] = val.slice();
131
- } else {
132
- result[key] = val;
133
- }
134
- }
135
- for (var i = 0, l = arguments.length; i < l; i++) {
136
- forEach(arguments[i], assignValue);
137
- }
138
- return result;
139
- }
140
- function extend(a, b, thisArg) {
141
- forEach(b, function assignValue(val, key) {
142
- if (thisArg && typeof val === "function") {
143
- a[key] = bind$1(val, thisArg);
144
- } else {
145
- a[key] = val;
146
- }
147
- });
148
- return a;
149
- }
150
- function stripBOM(content) {
151
- if (content.charCodeAt(0) === 65279) {
152
- content = content.slice(1);
153
- }
154
- return content;
155
- }
156
- var utils$e = {
157
- isArray,
158
- isArrayBuffer,
159
- isBuffer,
160
- isFormData,
161
- isArrayBufferView,
162
- isString,
163
- isNumber,
164
- isObject,
165
- isPlainObject,
166
- isUndefined,
167
- isDate,
168
- isFile,
169
- isBlob,
170
- isFunction,
171
- isStream,
172
- isURLSearchParams,
173
- isStandardBrowserEnv,
174
- forEach,
175
- merge,
176
- extend,
177
- trim,
178
- stripBOM
179
- };
180
- var utils$d = utils$e;
181
- function encode(val) {
182
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
183
- }
184
- var buildURL$2 = function buildURL(url, params, paramsSerializer) {
185
- if (!params) {
186
- return url;
187
- }
188
- var serializedParams;
189
- if (paramsSerializer) {
190
- serializedParams = paramsSerializer(params);
191
- } else if (utils$d.isURLSearchParams(params)) {
192
- serializedParams = params.toString();
193
- } else {
194
- var parts = [];
195
- utils$d.forEach(params, function serialize(val, key) {
196
- if (val === null || typeof val === "undefined") {
197
- return;
198
- }
199
- if (utils$d.isArray(val)) {
200
- key = key + "[]";
201
- } else {
202
- val = [val];
203
- }
204
- utils$d.forEach(val, function parseValue(v) {
205
- if (utils$d.isDate(v)) {
206
- v = v.toISOString();
207
- } else if (utils$d.isObject(v)) {
208
- v = JSON.stringify(v);
209
- }
210
- parts.push(encode(key) + "=" + encode(v));
211
- });
212
- });
213
- serializedParams = parts.join("&");
214
- }
215
- if (serializedParams) {
216
- var hashmarkIndex = url.indexOf("#");
217
- if (hashmarkIndex !== -1) {
218
- url = url.slice(0, hashmarkIndex);
219
- }
220
- url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
221
- }
222
- return url;
223
- };
224
- var utils$c = utils$e;
225
- function InterceptorManager$1() {
226
- this.handlers = [];
227
- }
228
- InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
229
- this.handlers.push({
230
- fulfilled,
231
- rejected,
232
- synchronous: options ? options.synchronous : false,
233
- runWhen: options ? options.runWhen : null
234
- });
235
- return this.handlers.length - 1;
236
- };
237
- InterceptorManager$1.prototype.eject = function eject(id) {
238
- if (this.handlers[id]) {
239
- this.handlers[id] = null;
240
- }
241
- };
242
- InterceptorManager$1.prototype.forEach = function forEach2(fn) {
243
- utils$c.forEach(this.handlers, function forEachHandler(h) {
244
- if (h !== null) {
245
- fn(h);
246
- }
1
+ var B = Object.defineProperty;
2
+ var V = (t, e, r) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var a = (t, e, r) => (V(t, typeof e != "symbol" ? e + "" : e, r), r);
4
+ function Ie() {
5
+ return new Promise((t, e) => {
6
+ typeof MediaStreamTrackProcessor > "u" || typeof MediaStreamTrackGenerator > "u" ? e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.") : t();
247
7
  });
248
- };
249
- var InterceptorManager_1 = InterceptorManager$1;
250
- var utils$b = utils$e;
251
- var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
252
- utils$b.forEach(headers, function processHeader(value, name) {
253
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
254
- headers[normalizedName] = value;
255
- delete headers[name];
256
- }
257
- });
258
- };
259
- var enhanceError$2 = function enhanceError(error, config, code, request2, response) {
260
- error.config = config;
261
- if (code) {
262
- error.code = code;
263
- }
264
- error.request = request2;
265
- error.response = response;
266
- error.isAxiosError = true;
267
- error.toJSON = function toJSON() {
268
- return {
269
- message: this.message,
270
- name: this.name,
271
- description: this.description,
272
- number: this.number,
273
- fileName: this.fileName,
274
- lineNumber: this.lineNumber,
275
- columnNumber: this.columnNumber,
276
- stack: this.stack,
277
- config: this.config,
278
- code: this.code,
279
- status: this.response && this.response.status ? this.response.status : null
280
- };
281
- };
282
- return error;
283
- };
284
- var enhanceError$1 = enhanceError$2;
285
- var createError$2 = function createError(message, config, code, request2, response) {
286
- var error = new Error(message);
287
- return enhanceError$1(error, config, code, request2, response);
288
- };
289
- var createError$1 = createError$2;
290
- var settle$1 = function settle(resolve, reject, response) {
291
- var validateStatus2 = response.config.validateStatus;
292
- if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
293
- resolve(response);
294
- } else {
295
- reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
296
- }
297
- };
298
- var utils$a = utils$e;
299
- var cookies$1 = utils$a.isStandardBrowserEnv() ? function standardBrowserEnv() {
300
- return {
301
- write: function write(name, value, expires, path, domain, secure) {
302
- var cookie = [];
303
- cookie.push(name + "=" + encodeURIComponent(value));
304
- if (utils$a.isNumber(expires)) {
305
- cookie.push("expires=" + new Date(expires).toGMTString());
306
- }
307
- if (utils$a.isString(path)) {
308
- cookie.push("path=" + path);
309
- }
310
- if (utils$a.isString(domain)) {
311
- cookie.push("domain=" + domain);
312
- }
313
- if (secure === true) {
314
- cookie.push("secure");
315
- }
316
- document.cookie = cookie.join("; ");
317
- },
318
- read: function read(name) {
319
- var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
320
- return match ? decodeURIComponent(match[3]) : null;
321
- },
322
- remove: function remove(name) {
323
- this.write(name, "", Date.now() - 864e5);
324
- }
325
- };
326
- }() : function nonStandardBrowserEnv() {
327
- return {
328
- write: function write() {
329
- },
330
- read: function read() {
331
- return null;
332
- },
333
- remove: function remove() {
334
- }
335
- };
336
- }();
337
- var isAbsoluteURL$1 = function isAbsoluteURL(url) {
338
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
339
- };
340
- var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
341
- return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
342
- };
343
- var isAbsoluteURL2 = isAbsoluteURL$1;
344
- var combineURLs2 = combineURLs$1;
345
- var buildFullPath$1 = function buildFullPath(baseURL, requestedURL) {
346
- if (baseURL && !isAbsoluteURL2(requestedURL)) {
347
- return combineURLs2(baseURL, requestedURL);
348
- }
349
- return requestedURL;
350
- };
351
- var utils$9 = utils$e;
352
- var ignoreDuplicateOf = [
353
- "age",
354
- "authorization",
355
- "content-length",
356
- "content-type",
357
- "etag",
358
- "expires",
359
- "from",
360
- "host",
361
- "if-modified-since",
362
- "if-unmodified-since",
363
- "last-modified",
364
- "location",
365
- "max-forwards",
366
- "proxy-authorization",
367
- "referer",
368
- "retry-after",
369
- "user-agent"
370
- ];
371
- var parseHeaders$1 = function parseHeaders(headers) {
372
- var parsed = {};
373
- var key;
374
- var val;
375
- var i;
376
- if (!headers) {
377
- return parsed;
378
- }
379
- utils$9.forEach(headers.split("\n"), function parser(line) {
380
- i = line.indexOf(":");
381
- key = utils$9.trim(line.substr(0, i)).toLowerCase();
382
- val = utils$9.trim(line.substr(i + 1));
383
- if (key) {
384
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
385
- return;
386
- }
387
- if (key === "set-cookie") {
388
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
389
- } else {
390
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
391
- }
392
- }
393
- });
394
- return parsed;
395
- };
396
- var utils$8 = utils$e;
397
- var isURLSameOrigin$1 = utils$8.isStandardBrowserEnv() ? function standardBrowserEnv2() {
398
- var msie = /(msie|trident)/i.test(navigator.userAgent);
399
- var urlParsingNode = document.createElement("a");
400
- var originURL;
401
- function resolveURL(url) {
402
- var href = url;
403
- if (msie) {
404
- urlParsingNode.setAttribute("href", href);
405
- href = urlParsingNode.href;
406
- }
407
- urlParsingNode.setAttribute("href", href);
408
- return {
409
- href: urlParsingNode.href,
410
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
411
- host: urlParsingNode.host,
412
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
413
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
414
- hostname: urlParsingNode.hostname,
415
- port: urlParsingNode.port,
416
- pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
417
- };
418
- }
419
- originURL = resolveURL(window.location.href);
420
- return function isURLSameOrigin2(requestURL) {
421
- var parsed = utils$8.isString(requestURL) ? resolveURL(requestURL) : requestURL;
422
- return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
423
- };
424
- }() : function nonStandardBrowserEnv2() {
425
- return function isURLSameOrigin2() {
426
- return true;
427
- };
428
- }();
429
- function Cancel$3(message) {
430
- this.message = message;
431
8
  }
432
- Cancel$3.prototype.toString = function toString2() {
433
- return "Cancel" + (this.message ? ": " + this.message : "");
434
- };
435
- Cancel$3.prototype.__CANCEL__ = true;
436
- var Cancel_1 = Cancel$3;
437
- var utils$7 = utils$e;
438
- var settle2 = settle$1;
439
- var cookies = cookies$1;
440
- var buildURL$1 = buildURL$2;
441
- var buildFullPath2 = buildFullPath$1;
442
- var parseHeaders2 = parseHeaders$1;
443
- var isURLSameOrigin = isURLSameOrigin$1;
444
- var createError2 = createError$2;
445
- var defaults$4 = defaults_1;
446
- var Cancel$2 = Cancel_1;
447
- var xhr = function xhrAdapter(config) {
448
- return new Promise(function dispatchXhrRequest(resolve, reject) {
449
- var requestData = config.data;
450
- var requestHeaders = config.headers;
451
- var responseType = config.responseType;
452
- var onCanceled;
453
- function done() {
454
- if (config.cancelToken) {
455
- config.cancelToken.unsubscribe(onCanceled);
456
- }
457
- if (config.signal) {
458
- config.signal.removeEventListener("abort", onCanceled);
459
- }
460
- }
461
- if (utils$7.isFormData(requestData)) {
462
- delete requestHeaders["Content-Type"];
463
- }
464
- var request2 = new XMLHttpRequest();
465
- if (config.auth) {
466
- var username = config.auth.username || "";
467
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
468
- requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
469
- }
470
- var fullPath = buildFullPath2(config.baseURL, config.url);
471
- request2.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
472
- request2.timeout = config.timeout;
473
- function onloadend() {
474
- if (!request2) {
475
- return;
476
- }
477
- var responseHeaders = "getAllResponseHeaders" in request2 ? parseHeaders2(request2.getAllResponseHeaders()) : null;
478
- var responseData = !responseType || responseType === "text" || responseType === "json" ? request2.responseText : request2.response;
479
- var response = {
480
- data: responseData,
481
- status: request2.status,
482
- statusText: request2.statusText,
483
- headers: responseHeaders,
484
- config,
485
- request: request2
486
- };
487
- settle2(function _resolve(value) {
488
- resolve(value);
489
- done();
490
- }, function _reject(err) {
491
- reject(err);
492
- done();
493
- }, response);
494
- request2 = null;
495
- }
496
- if ("onloadend" in request2) {
497
- request2.onloadend = onloadend;
498
- } else {
499
- request2.onreadystatechange = function handleLoad() {
500
- if (!request2 || request2.readyState !== 4) {
501
- return;
502
- }
503
- if (request2.status === 0 && !(request2.responseURL && request2.responseURL.indexOf("file:") === 0)) {
504
- return;
505
- }
506
- setTimeout(onloadend);
507
- };
508
- }
509
- request2.onabort = function handleAbort() {
510
- if (!request2) {
511
- return;
512
- }
513
- reject(createError2("Request aborted", config, "ECONNABORTED", request2));
514
- request2 = null;
515
- };
516
- request2.onerror = function handleError() {
517
- reject(createError2("Network Error", config, null, request2));
518
- request2 = null;
519
- };
520
- request2.ontimeout = function handleTimeout() {
521
- var timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
522
- var transitional2 = config.transitional || defaults$4.transitional;
523
- if (config.timeoutErrorMessage) {
524
- timeoutErrorMessage = config.timeoutErrorMessage;
525
- }
526
- reject(createError2(timeoutErrorMessage, config, transitional2.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request2));
527
- request2 = null;
528
- };
529
- if (utils$7.isStandardBrowserEnv()) {
530
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0;
531
- if (xsrfValue) {
532
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
533
- }
534
- }
535
- if ("setRequestHeader" in request2) {
536
- utils$7.forEach(requestHeaders, function setRequestHeader(val, key) {
537
- if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
538
- delete requestHeaders[key];
539
- } else {
540
- request2.setRequestHeader(key, val);
541
- }
542
- });
543
- }
544
- if (!utils$7.isUndefined(config.withCredentials)) {
545
- request2.withCredentials = !!config.withCredentials;
546
- }
547
- if (responseType && responseType !== "json") {
548
- request2.responseType = config.responseType;
549
- }
550
- if (typeof config.onDownloadProgress === "function") {
551
- request2.addEventListener("progress", config.onDownloadProgress);
552
- }
553
- if (typeof config.onUploadProgress === "function" && request2.upload) {
554
- request2.upload.addEventListener("progress", config.onUploadProgress);
555
- }
556
- if (config.cancelToken || config.signal) {
557
- onCanceled = function(cancel) {
558
- if (!request2) {
559
- return;
560
- }
561
- reject(!cancel || cancel && cancel.type ? new Cancel$2("canceled") : cancel);
562
- request2.abort();
563
- request2 = null;
564
- };
565
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
566
- if (config.signal) {
567
- config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
568
- }
569
- }
570
- if (!requestData) {
571
- requestData = null;
572
- }
573
- request2.send(requestData);
574
- });
575
- };
576
- var utils$6 = utils$e;
577
- var normalizeHeaderName2 = normalizeHeaderName$1;
578
- var enhanceError2 = enhanceError$2;
579
- var DEFAULT_CONTENT_TYPE = {
580
- "Content-Type": "application/x-www-form-urlencoded"
581
- };
582
- function setContentTypeIfUnset(headers, value) {
583
- if (!utils$6.isUndefined(headers) && utils$6.isUndefined(headers["Content-Type"])) {
584
- headers["Content-Type"] = value;
585
- }
586
- }
587
- function getDefaultAdapter() {
588
- var adapter;
589
- if (typeof XMLHttpRequest !== "undefined") {
590
- adapter = xhr;
591
- } else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
592
- adapter = xhr;
593
- }
594
- return adapter;
595
- }
596
- function stringifySafely(rawValue, parser, encoder) {
597
- if (utils$6.isString(rawValue)) {
598
- try {
599
- (parser || JSON.parse)(rawValue);
600
- return utils$6.trim(rawValue);
601
- } catch (e) {
602
- if (e.name !== "SyntaxError") {
603
- throw e;
604
- }
605
- }
606
- }
607
- return (encoder || JSON.stringify)(rawValue);
608
- }
609
- var defaults$3 = {
610
- transitional: {
611
- silentJSONParsing: true,
612
- forcedJSONParsing: true,
613
- clarifyTimeoutError: false
614
- },
615
- adapter: getDefaultAdapter(),
616
- transformRequest: [function transformRequest(data2, headers) {
617
- normalizeHeaderName2(headers, "Accept");
618
- normalizeHeaderName2(headers, "Content-Type");
619
- if (utils$6.isFormData(data2) || utils$6.isArrayBuffer(data2) || utils$6.isBuffer(data2) || utils$6.isStream(data2) || utils$6.isFile(data2) || utils$6.isBlob(data2)) {
620
- return data2;
621
- }
622
- if (utils$6.isArrayBufferView(data2)) {
623
- return data2.buffer;
624
- }
625
- if (utils$6.isURLSearchParams(data2)) {
626
- setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
627
- return data2.toString();
628
- }
629
- if (utils$6.isObject(data2) || headers && headers["Content-Type"] === "application/json") {
630
- setContentTypeIfUnset(headers, "application/json");
631
- return stringifySafely(data2);
632
- }
633
- return data2;
634
- }],
635
- transformResponse: [function transformResponse(data2) {
636
- var transitional2 = this.transitional || defaults$3.transitional;
637
- var silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
638
- var forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
639
- var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
640
- if (strictJSONParsing || forcedJSONParsing && utils$6.isString(data2) && data2.length) {
641
- try {
642
- return JSON.parse(data2);
643
- } catch (e) {
644
- if (strictJSONParsing) {
645
- if (e.name === "SyntaxError") {
646
- throw enhanceError2(e, this, "E_JSON_PARSE");
647
- }
648
- throw e;
649
- }
650
- }
651
- }
652
- return data2;
653
- }],
654
- timeout: 0,
655
- xsrfCookieName: "XSRF-TOKEN",
656
- xsrfHeaderName: "X-XSRF-TOKEN",
657
- maxContentLength: -1,
658
- maxBodyLength: -1,
659
- validateStatus: function validateStatus(status) {
660
- return status >= 200 && status < 300;
661
- },
662
- headers: {
663
- common: {
664
- "Accept": "application/json, text/plain, */*"
665
- }
666
- }
667
- };
668
- utils$6.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
669
- defaults$3.headers[method] = {};
9
+ class l {
10
+ }
11
+ a(l, "updates", {
12
+ transformer_new: "New transformer",
13
+ transformer_null: "Null transformer"
14
+ }), a(l, "errors", {
15
+ transformer_none: "No transformers provided",
16
+ transformer_start: "Cannot start transformer",
17
+ transformer_transform: "Cannot transform frame",
18
+ transformer_flush: "Cannot flush transformer",
19
+ readable_null: "Readable is null",
20
+ writable_null: "Writable is null"
670
21
  });
671
- utils$6.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
672
- defaults$3.headers[method] = utils$6.merge(DEFAULT_CONTENT_TYPE);
673
- });
674
- var defaults_1 = defaults$3;
675
- var utils$5 = utils$e;
676
- var defaults$2 = defaults_1;
677
- var transformData$1 = function transformData(data2, headers, fns) {
678
- var context = this || defaults$2;
679
- utils$5.forEach(fns, function transform(fn) {
680
- data2 = fn.call(context, data2, headers);
681
- });
682
- return data2;
683
- };
684
- var isCancel$1 = function isCancel(value) {
685
- return !!(value && value.__CANCEL__);
686
- };
687
- var utils$4 = utils$e;
688
- var transformData2 = transformData$1;
689
- var isCancel2 = isCancel$1;
690
- var defaults$1 = defaults_1;
691
- var Cancel$1 = Cancel_1;
692
- function throwIfCancellationRequested(config) {
693
- if (config.cancelToken) {
694
- config.cancelToken.throwIfRequested();
695
- }
696
- if (config.signal && config.signal.aborted) {
697
- throw new Cancel$1("canceled");
698
- }
699
- }
700
- var dispatchRequest$1 = function dispatchRequest(config) {
701
- throwIfCancellationRequested(config);
702
- config.headers = config.headers || {};
703
- config.data = transformData2.call(config, config.data, config.headers, config.transformRequest);
704
- config.headers = utils$4.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
705
- utils$4.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
706
- delete config.headers[method];
707
- });
708
- var adapter = config.adapter || defaults$1.adapter;
709
- return adapter(config).then(function onAdapterResolution(response) {
710
- throwIfCancellationRequested(config);
711
- response.data = transformData2.call(config, response.data, response.headers, config.transformResponse);
712
- return response;
713
- }, function onAdapterRejection(reason) {
714
- if (!isCancel2(reason)) {
715
- throwIfCancellationRequested(config);
716
- if (reason && reason.response) {
717
- reason.response.data = transformData2.call(config, reason.response.data, reason.response.headers, config.transformResponse);
718
- }
719
- }
720
- return Promise.reject(reason);
721
- });
722
- };
723
- var utils$3 = utils$e;
724
- var mergeConfig$2 = function mergeConfig(config1, config2) {
725
- config2 = config2 || {};
726
- var config = {};
727
- function getMergedValue(target, source2) {
728
- if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source2)) {
729
- return utils$3.merge(target, source2);
730
- } else if (utils$3.isPlainObject(source2)) {
731
- return utils$3.merge({}, source2);
732
- } else if (utils$3.isArray(source2)) {
733
- return source2.slice();
734
- }
735
- return source2;
736
- }
737
- function mergeDeepProperties(prop) {
738
- if (!utils$3.isUndefined(config2[prop])) {
739
- return getMergedValue(config1[prop], config2[prop]);
740
- } else if (!utils$3.isUndefined(config1[prop])) {
741
- return getMergedValue(void 0, config1[prop]);
742
- }
743
- }
744
- function valueFromConfig2(prop) {
745
- if (!utils$3.isUndefined(config2[prop])) {
746
- return getMergedValue(void 0, config2[prop]);
747
- }
748
- }
749
- function defaultToConfig2(prop) {
750
- if (!utils$3.isUndefined(config2[prop])) {
751
- return getMergedValue(void 0, config2[prop]);
752
- } else if (!utils$3.isUndefined(config1[prop])) {
753
- return getMergedValue(void 0, config1[prop]);
754
- }
755
- }
756
- function mergeDirectKeys(prop) {
757
- if (prop in config2) {
758
- return getMergedValue(config1[prop], config2[prop]);
759
- } else if (prop in config1) {
760
- return getMergedValue(void 0, config1[prop]);
761
- }
762
- }
763
- var mergeMap = {
764
- "url": valueFromConfig2,
765
- "method": valueFromConfig2,
766
- "data": valueFromConfig2,
767
- "baseURL": defaultToConfig2,
768
- "transformRequest": defaultToConfig2,
769
- "transformResponse": defaultToConfig2,
770
- "paramsSerializer": defaultToConfig2,
771
- "timeout": defaultToConfig2,
772
- "timeoutMessage": defaultToConfig2,
773
- "withCredentials": defaultToConfig2,
774
- "adapter": defaultToConfig2,
775
- "responseType": defaultToConfig2,
776
- "xsrfCookieName": defaultToConfig2,
777
- "xsrfHeaderName": defaultToConfig2,
778
- "onUploadProgress": defaultToConfig2,
779
- "onDownloadProgress": defaultToConfig2,
780
- "decompress": defaultToConfig2,
781
- "maxContentLength": defaultToConfig2,
782
- "maxBodyLength": defaultToConfig2,
783
- "transport": defaultToConfig2,
784
- "httpAgent": defaultToConfig2,
785
- "httpsAgent": defaultToConfig2,
786
- "cancelToken": defaultToConfig2,
787
- "socketPath": defaultToConfig2,
788
- "responseEncoding": defaultToConfig2,
789
- "validateStatus": mergeDirectKeys
790
- };
791
- utils$3.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
792
- var merge2 = mergeMap[prop] || mergeDeepProperties;
793
- var configValue = merge2(prop);
794
- utils$3.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
795
- });
796
- return config;
797
- };
798
- var data = {
799
- "version": "0.25.0"
800
- };
801
- var VERSION = data.version;
802
- var validators$1 = {};
803
- ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
804
- validators$1[type] = function validator2(thing) {
805
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
806
- };
807
- });
808
- var deprecatedWarnings = {};
809
- validators$1.transitional = function transitional(validator2, version2, message) {
810
- function formatMessage(opt, desc) {
811
- return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
812
- }
813
- return function(value, opt, opts) {
814
- if (validator2 === false) {
815
- throw new Error(formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")));
816
- }
817
- if (version2 && !deprecatedWarnings[opt]) {
818
- deprecatedWarnings[opt] = true;
819
- console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
820
- }
821
- return validator2 ? validator2(value, opt, opts) : true;
822
- };
823
- };
824
- function assertOptions(options, schema, allowUnknown) {
825
- if (typeof options !== "object") {
826
- throw new TypeError("options must be an object");
827
- }
828
- var keys = Object.keys(options);
829
- var i = keys.length;
830
- while (i-- > 0) {
831
- var opt = keys[i];
832
- var validator2 = schema[opt];
833
- if (validator2) {
834
- var value = options[opt];
835
- var result = value === void 0 || validator2(value, opt, options);
836
- if (result !== true) {
837
- throw new TypeError("option " + opt + " must be " + result);
838
- }
839
- continue;
840
- }
841
- if (allowUnknown !== true) {
842
- throw Error("Unknown option " + opt);
843
- }
844
- }
845
- }
846
- var validator$1 = {
847
- assertOptions,
848
- validators: validators$1
849
- };
850
- var utils$2 = utils$e;
851
- var buildURL2 = buildURL$2;
852
- var InterceptorManager = InterceptorManager_1;
853
- var dispatchRequest2 = dispatchRequest$1;
854
- var mergeConfig$1 = mergeConfig$2;
855
- var validator = validator$1;
856
- var validators = validator.validators;
857
- function Axios$1(instanceConfig) {
858
- this.defaults = instanceConfig;
859
- this.interceptors = {
860
- request: new InterceptorManager(),
861
- response: new InterceptorManager()
862
- };
863
- }
864
- Axios$1.prototype.request = function request(configOrUrl, config) {
865
- if (typeof configOrUrl === "string") {
866
- config = config || {};
867
- config.url = configOrUrl;
868
- } else {
869
- config = configOrUrl || {};
870
- }
871
- if (!config.url) {
872
- throw new Error("Provided config url is not valid");
873
- }
874
- config = mergeConfig$1(this.defaults, config);
875
- if (config.method) {
876
- config.method = config.method.toLowerCase();
877
- } else if (this.defaults.method) {
878
- config.method = this.defaults.method.toLowerCase();
879
- } else {
880
- config.method = "get";
881
- }
882
- var transitional2 = config.transitional;
883
- if (transitional2 !== void 0) {
884
- validator.assertOptions(transitional2, {
885
- silentJSONParsing: validators.transitional(validators.boolean),
886
- forcedJSONParsing: validators.transitional(validators.boolean),
887
- clarifyTimeoutError: validators.transitional(validators.boolean)
888
- }, false);
889
- }
890
- var requestInterceptorChain = [];
891
- var synchronousRequestInterceptors = true;
892
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
893
- if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
894
- return;
895
- }
896
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
897
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
898
- });
899
- var responseInterceptorChain = [];
900
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
901
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
902
- });
903
- var promise;
904
- if (!synchronousRequestInterceptors) {
905
- var chain = [dispatchRequest2, void 0];
906
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
907
- chain = chain.concat(responseInterceptorChain);
908
- promise = Promise.resolve(config);
909
- while (chain.length) {
910
- promise = promise.then(chain.shift(), chain.shift());
911
- }
912
- return promise;
913
- }
914
- var newConfig = config;
915
- while (requestInterceptorChain.length) {
916
- var onFulfilled = requestInterceptorChain.shift();
917
- var onRejected = requestInterceptorChain.shift();
918
- try {
919
- newConfig = onFulfilled(newConfig);
920
- } catch (error) {
921
- onRejected(error);
922
- break;
923
- }
924
- }
925
- try {
926
- promise = dispatchRequest2(newConfig);
927
- } catch (error) {
928
- return Promise.reject(error);
929
- }
930
- while (responseInterceptorChain.length) {
931
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
932
- }
933
- return promise;
934
- };
935
- Axios$1.prototype.getUri = function getUri(config) {
936
- if (!config.url) {
937
- throw new Error("Provided config url is not valid");
938
- }
939
- config = mergeConfig$1(this.defaults, config);
940
- return buildURL2(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
941
- };
942
- utils$2.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
943
- Axios$1.prototype[method] = function(url, config) {
944
- return this.request(mergeConfig$1(config || {}, {
945
- method,
946
- url,
947
- data: (config || {}).data
948
- }));
949
- };
950
- });
951
- utils$2.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
952
- Axios$1.prototype[method] = function(url, data2, config) {
953
- return this.request(mergeConfig$1(config || {}, {
954
- method,
955
- url,
956
- data: data2
957
- }));
958
- };
959
- });
960
- var Axios_1 = Axios$1;
961
- var Cancel = Cancel_1;
962
- function CancelToken(executor) {
963
- if (typeof executor !== "function") {
964
- throw new TypeError("executor must be a function.");
965
- }
966
- var resolvePromise;
967
- this.promise = new Promise(function promiseExecutor(resolve) {
968
- resolvePromise = resolve;
969
- });
970
- var token = this;
971
- this.promise.then(function(cancel) {
972
- if (!token._listeners)
973
- return;
974
- var i;
975
- var l = token._listeners.length;
976
- for (i = 0; i < l; i++) {
977
- token._listeners[i](cancel);
978
- }
979
- token._listeners = null;
980
- });
981
- this.promise.then = function(onfulfilled) {
982
- var _resolve;
983
- var promise = new Promise(function(resolve) {
984
- token.subscribe(resolve);
985
- _resolve = resolve;
986
- }).then(onfulfilled);
987
- promise.cancel = function reject() {
988
- token.unsubscribe(_resolve);
989
- };
990
- return promise;
991
- };
992
- executor(function cancel(message) {
993
- if (token.reason) {
994
- return;
995
- }
996
- token.reason = new Cancel(message);
997
- resolvePromise(token.reason);
998
- });
999
- }
1000
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
1001
- if (this.reason) {
1002
- throw this.reason;
1003
- }
1004
- };
1005
- CancelToken.prototype.subscribe = function subscribe(listener) {
1006
- if (this.reason) {
1007
- listener(this.reason);
1008
- return;
1009
- }
1010
- if (this._listeners) {
1011
- this._listeners.push(listener);
1012
- } else {
1013
- this._listeners = [listener];
1014
- }
1015
- };
1016
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
1017
- if (!this._listeners) {
1018
- return;
1019
- }
1020
- var index = this._listeners.indexOf(listener);
1021
- if (index !== -1) {
1022
- this._listeners.splice(index, 1);
1023
- }
1024
- };
1025
- CancelToken.source = function source() {
1026
- var cancel;
1027
- var token = new CancelToken(function executor(c) {
1028
- cancel = c;
1029
- });
1030
- return {
1031
- token,
1032
- cancel
1033
- };
1034
- };
1035
- var CancelToken_1 = CancelToken;
1036
- var spread = function spread2(callback) {
1037
- return function wrap(arr) {
1038
- return callback.apply(null, arr);
1039
- };
1040
- };
1041
- var utils$1 = utils$e;
1042
- var isAxiosError = function isAxiosError2(payload) {
1043
- return utils$1.isObject(payload) && payload.isAxiosError === true;
1044
- };
1045
- var utils = utils$e;
1046
- var bind2 = bind$2;
1047
- var Axios = Axios_1;
1048
- var mergeConfig2 = mergeConfig$2;
1049
- var defaults = defaults_1;
1050
- function createInstance(defaultConfig) {
1051
- var context = new Axios(defaultConfig);
1052
- var instance = bind2(Axios.prototype.request, context);
1053
- utils.extend(instance, Axios.prototype, context);
1054
- utils.extend(instance, context);
1055
- instance.create = function create(instanceConfig) {
1056
- return createInstance(mergeConfig2(defaultConfig, instanceConfig));
1057
- };
1058
- return instance;
1059
- }
1060
- var axios$1 = createInstance(defaults);
1061
- axios$1.Axios = Axios;
1062
- axios$1.Cancel = Cancel_1;
1063
- axios$1.CancelToken = CancelToken_1;
1064
- axios$1.isCancel = isCancel$1;
1065
- axios$1.VERSION = data.version;
1066
- axios$1.all = function all(promises) {
1067
- return Promise.all(promises);
1068
- };
1069
- axios$1.spread = spread;
1070
- axios$1.isAxiosError = isAxiosError;
1071
- axios$2.exports = axios$1;
1072
- axios$2.exports.default = axios$1;
1073
- var axios = axios$2.exports;
1074
- class Optional {
1075
- isEmpty() {
1076
- return !this.isPresent();
1077
- }
1078
- static of(value) {
1079
- if (value !== null && value !== void 0)
1080
- return new PresentOptional(value);
1081
- else
1082
- throw new TypeError("The passed value was null or undefined.");
1083
- }
1084
- static ofNonNull(value) {
1085
- return Optional.of(value);
1086
- }
1087
- static ofNullable(nullable) {
1088
- if (nullable !== null && nullable !== void 0)
1089
- return new PresentOptional(nullable);
1090
- else
1091
- return new EmptyOptional();
1092
- }
1093
- static empty() {
1094
- return new EmptyOptional();
1095
- }
1096
- static from(option) {
1097
- switch (option.kind) {
1098
- case "present":
1099
- return Optional.of(option.value);
1100
- case "empty":
1101
- return Optional.empty();
1102
- default:
1103
- throw new TypeError("The passed value was not an Option type.");
1104
- }
1105
- }
1106
- }
1107
- class PresentOptional extends Optional {
1108
- constructor(value) {
1109
- super();
1110
- this.payload = value;
1111
- }
1112
- isPresent() {
1113
- return true;
1114
- }
1115
- get() {
1116
- return this.payload;
1117
- }
1118
- ifPresent(consumer) {
1119
- consumer(this.payload);
1120
- }
1121
- ifPresentOrElse(consumer, emptyAction) {
1122
- consumer(this.payload);
1123
- }
1124
- filter(predicate) {
1125
- return predicate(this.payload) ? this : Optional.empty();
1126
- }
1127
- map(mapper) {
1128
- const result = mapper(this.payload);
1129
- return Optional.ofNullable(result);
1130
- }
1131
- flatMap(mapper) {
1132
- return mapper(this.payload);
1133
- }
1134
- or(supplier) {
1135
- return this;
1136
- }
1137
- orElse(another) {
1138
- return this.payload;
1139
- }
1140
- orElseGet(another) {
1141
- return this.payload;
1142
- }
1143
- orElseThrow(exception) {
1144
- return this.payload;
1145
- }
1146
- orNull() {
1147
- return this.payload;
1148
- }
1149
- orUndefined() {
1150
- return this.payload;
1151
- }
1152
- toOption() {
1153
- return { kind: "present", value: this.payload };
1154
- }
1155
- matches(cases) {
1156
- return cases.present(this.payload);
1157
- }
1158
- toJSON(key) {
1159
- return this.payload;
1160
- }
1161
- }
1162
- class EmptyOptional extends Optional {
1163
- isPresent() {
1164
- return false;
1165
- }
1166
- constructor() {
1167
- super();
1168
- }
1169
- get() {
1170
- throw new TypeError("The optional is not present.");
1171
- }
1172
- ifPresent(consumer) {
1173
- }
1174
- ifPresentOrElse(consumer, emptyAction) {
1175
- emptyAction();
1176
- }
1177
- filter(predicate) {
1178
- return this;
1179
- }
1180
- map(mapper) {
1181
- return Optional.empty();
1182
- }
1183
- flatMap(mapper) {
1184
- return Optional.empty();
1185
- }
1186
- or(supplier) {
1187
- return supplier();
1188
- }
1189
- orElse(another) {
1190
- return another;
1191
- }
1192
- orElseGet(another) {
1193
- return this.orElse(another());
1194
- }
1195
- orElseThrow(exception) {
1196
- throw exception();
1197
- }
1198
- orNull() {
1199
- return null;
1200
- }
1201
- orUndefined() {
1202
- return void 0;
1203
- }
1204
- toOption() {
1205
- return { kind: "empty" };
1206
- }
1207
- matches(cases) {
1208
- return cases.empty();
1209
- }
1210
- toJSON(key) {
1211
- return null;
1212
- }
1213
- }
1214
- const version = "1.2.7";
1215
- function setVonageMetadata(metadata) {
1216
- globalThis._vonageMediaProcessorMetadata = metadata;
1217
- }
1218
- function getVonageMetadata() {
1219
- return globalThis._vonageMediaProcessorMetadata;
1220
- }
1221
- class ReportBuilder {
1222
- constructor() {
1223
- const metadata = getVonageMetadata();
1224
- this._report = {
1225
- action: Optional.empty(),
1226
- applicationId: Optional.ofNullable(metadata !== void 0 && metadata != null ? metadata.appId : null),
1227
- timestamp: Date.now(),
1228
- fps: Optional.empty(),
1229
- framesTransformed: Optional.empty(),
1230
- guid: Optional.empty(),
1231
- highestFrameTransformCpu: Optional.empty(),
1232
- message: Optional.empty(),
1233
- source: Optional.ofNullable(metadata !== void 0 && metadata != null ? metadata.sourceType : null),
1234
- transformedFps: Optional.empty(),
1235
- transformerType: Optional.empty(),
1236
- variation: Optional.empty(),
1237
- videoHeight: Optional.empty(),
1238
- videoWidth: Optional.empty(),
1239
- version,
1240
- error: Optional.empty(),
1241
- proxyUrl: Optional.ofNullable(metadata !== void 0 && metadata != null ? metadata.proxyUrl : null)
1242
- };
1243
- }
1244
- action(action) {
1245
- this._report.action = Optional.ofNullable(action);
1246
- return this;
1247
- }
1248
- framesTransformed(framesTransformed) {
1249
- this._report.framesTransformed = Optional.ofNullable(framesTransformed);
1250
- return this;
1251
- }
1252
- fps(fps) {
1253
- this._report.fps = Optional.ofNullable(fps);
1254
- return this;
1255
- }
1256
- guid(guid) {
1257
- this._report.guid = Optional.ofNullable(guid);
1258
- return this;
1259
- }
1260
- message(message) {
1261
- this._report.message = Optional.ofNullable(message);
1262
- return this;
1263
- }
1264
- transformedFps(transformedFps) {
1265
- this._report.transformedFps = Optional.ofNullable(transformedFps);
1266
- return this;
1267
- }
1268
- transformerType(transformerType) {
1269
- this._report.transformerType = Optional.ofNullable(transformerType);
1270
- return this;
1271
- }
1272
- variation(variation) {
1273
- this._report.variation = Optional.ofNullable(variation);
1274
- return this;
1275
- }
1276
- videoHeight(videoHeight) {
1277
- this._report.videoHeight = Optional.ofNullable(videoHeight);
1278
- return this;
1279
- }
1280
- videoWidth(videoWidth) {
1281
- this._report.videoWidth = Optional.ofNullable(videoWidth);
1282
- return this;
1283
- }
1284
- error(error) {
1285
- this._report.error = Optional.ofNullable(error);
1286
- return this;
1287
- }
1288
- build() {
1289
- return this._report;
1290
- }
1291
- }
1292
- const serializeReport = (report) => {
1293
- return JSON.stringify(report, (key, value) => {
1294
- if (value !== null)
1295
- return value;
1296
- });
1297
- };
1298
- class Reporter {
1299
- static report(report) {
1300
- return new Promise((resolve, reject) => {
1301
- if (report.applicationId.isEmpty() || report.source.isEmpty()) {
1302
- resolve("success");
1303
- return;
1304
- }
1305
- let axiosInstance = axios.create();
1306
- let config = {
1307
- timeout: 1e4,
1308
- timeoutErrorMessage: "Request timeout",
1309
- headers: {
1310
- "Content-Type": "application/json"
1311
- }
1312
- };
1313
- let telemetryServerUrl = "hlg.tokbox.com/prod/logging/vcp_webrtc";
1314
- if (!report.proxyUrl.isEmpty()) {
1315
- let proxy;
1316
- if (report.proxyUrl.get().slice(report.proxyUrl.get().length - 1) !== "/") {
1317
- proxy = report.proxyUrl.get() + "/";
1318
- } else {
1319
- proxy = report.proxyUrl.get();
1320
- }
1321
- telemetryServerUrl = proxy + telemetryServerUrl;
1322
- } else {
1323
- telemetryServerUrl = "https://" + telemetryServerUrl;
1324
- }
1325
- axiosInstance.post(telemetryServerUrl, serializeReport(report), config).then((res) => {
1326
- console.log(res);
1327
- resolve("success");
1328
- }).catch((e) => {
1329
- console.log(e);
1330
- reject(e);
1331
- });
1332
- });
1333
- }
1334
- }
1335
- var getRandomValues;
1336
- var rnds8 = new Uint8Array(16);
1337
- function rng() {
1338
- if (!getRandomValues) {
1339
- getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
1340
- if (!getRandomValues) {
1341
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1342
- }
1343
- }
1344
- return getRandomValues(rnds8);
1345
- }
1346
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1347
- function validate(uuid) {
1348
- return typeof uuid === "string" && REGEX.test(uuid);
1349
- }
1350
- var byteToHex = [];
1351
- for (var i = 0; i < 256; ++i) {
1352
- byteToHex.push((i + 256).toString(16).substr(1));
1353
- }
1354
- function stringify(arr) {
1355
- var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
1356
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
1357
- if (!validate(uuid)) {
1358
- throw TypeError("Stringified UUID is invalid");
1359
- }
1360
- return uuid;
1361
- }
1362
- function v4(options, buf, offset) {
1363
- options = options || {};
1364
- var rnds = options.random || (options.rng || rng)();
1365
- rnds[6] = rnds[6] & 15 | 64;
1366
- rnds[8] = rnds[8] & 63 | 128;
1367
- if (buf) {
1368
- offset = offset || 0;
1369
- for (var i = 0; i < 16; ++i) {
1370
- buf[offset + i] = rnds[i];
1371
- }
1372
- return buf;
1373
- }
1374
- return stringify(rnds);
1375
- }
1376
- const anyMap = new WeakMap();
1377
- const eventsMap = new WeakMap();
1378
- const producersMap = new WeakMap();
1379
- const anyProducer = Symbol("anyProducer");
1380
- const resolvedPromise = Promise.resolve();
1381
- const listenerAdded = Symbol("listenerAdded");
1382
- const listenerRemoved = Symbol("listenerRemoved");
1383
- let isGlobalDebugEnabled = false;
1384
- function assertEventName(eventName) {
1385
- if (typeof eventName !== "string" && typeof eventName !== "symbol") {
22
+ const h = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), O = Symbol("anyProducer"), D = Promise.resolve(), k = Symbol("listenerAdded"), A = Symbol("listenerRemoved");
23
+ let x = !1;
24
+ function _(t) {
25
+ if (typeof t != "string" && typeof t != "symbol")
1386
26
  throw new TypeError("eventName must be a string or a symbol");
1387
- }
1388
27
  }
1389
- function assertListener(listener) {
1390
- if (typeof listener !== "function") {
28
+ function T(t) {
29
+ if (typeof t != "function")
1391
30
  throw new TypeError("listener must be a function");
1392
- }
1393
- }
1394
- function getListeners(instance, eventName) {
1395
- const events = eventsMap.get(instance);
1396
- if (!events.has(eventName)) {
1397
- events.set(eventName, new Set());
1398
- }
1399
- return events.get(eventName);
1400
31
  }
1401
- function getEventProducers(instance, eventName) {
1402
- const key = typeof eventName === "string" || typeof eventName === "symbol" ? eventName : anyProducer;
1403
- const producers = producersMap.get(instance);
1404
- if (!producers.has(key)) {
1405
- producers.set(key, new Set());
1406
- }
1407
- return producers.get(key);
1408
- }
1409
- function enqueueProducers(instance, eventName, eventData) {
1410
- const producers = producersMap.get(instance);
1411
- if (producers.has(eventName)) {
1412
- for (const producer of producers.get(eventName)) {
1413
- producer.enqueue(eventData);
1414
- }
1415
- }
1416
- if (producers.has(anyProducer)) {
1417
- const item = Promise.all([eventName, eventData]);
1418
- for (const producer of producers.get(anyProducer)) {
1419
- producer.enqueue(item);
1420
- }
1421
- }
1422
- }
1423
- function iterator(instance, eventNames) {
1424
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1425
- let isFinished = false;
1426
- let flush = () => {
1427
- };
1428
- let queue = [];
1429
- const producer = {
1430
- enqueue(item) {
1431
- queue.push(item);
1432
- flush();
32
+ function g(t, e) {
33
+ const r = E.get(t);
34
+ return r.has(e) || r.set(e, /* @__PURE__ */ new Set()), r.get(e);
35
+ }
36
+ function b(t, e) {
37
+ const r = typeof e == "string" || typeof e == "symbol" ? e : O, s = y.get(t);
38
+ return s.has(r) || s.set(r, /* @__PURE__ */ new Set()), s.get(r);
39
+ }
40
+ function Y(t, e, r) {
41
+ const s = y.get(t);
42
+ if (s.has(e))
43
+ for (const o of s.get(e))
44
+ o.enqueue(r);
45
+ if (s.has(O)) {
46
+ const o = Promise.all([e, r]);
47
+ for (const i of s.get(O))
48
+ i.enqueue(o);
49
+ }
50
+ }
51
+ function U(t, e) {
52
+ e = Array.isArray(e) ? e : [e];
53
+ let r = !1, s = () => {
54
+ }, o = [];
55
+ const i = {
56
+ enqueue(n) {
57
+ o.push(n), s();
1433
58
  },
1434
59
  finish() {
1435
- isFinished = true;
1436
- flush();
60
+ r = !0, s();
1437
61
  }
1438
62
  };
1439
- for (const eventName of eventNames) {
1440
- getEventProducers(instance, eventName).add(producer);
1441
- }
63
+ for (const n of e)
64
+ b(t, n).add(i);
1442
65
  return {
1443
66
  async next() {
1444
- if (!queue) {
1445
- return { done: true };
1446
- }
1447
- if (queue.length === 0) {
1448
- if (isFinished) {
1449
- queue = void 0;
1450
- return this.next();
1451
- }
1452
- await new Promise((resolve) => {
1453
- flush = resolve;
1454
- });
1455
- return this.next();
1456
- }
1457
- return {
1458
- done: false,
1459
- value: await queue.shift()
1460
- };
67
+ return o ? o.length === 0 ? r ? (o = void 0, this.next()) : (await new Promise((n) => {
68
+ s = n;
69
+ }), this.next()) : {
70
+ done: !1,
71
+ value: await o.shift()
72
+ } : { done: !0 };
1461
73
  },
1462
- async return(value) {
1463
- queue = void 0;
1464
- for (const eventName of eventNames) {
1465
- getEventProducers(instance, eventName).delete(producer);
1466
- }
1467
- flush();
1468
- return arguments.length > 0 ? { done: true, value: await value } : { done: true };
74
+ async return(n) {
75
+ o = void 0;
76
+ for (const c of e)
77
+ b(t, c).delete(i);
78
+ return s(), arguments.length > 0 ? { done: !0, value: await n } : { done: !0 };
1469
79
  },
1470
80
  [Symbol.asyncIterator]() {
1471
81
  return this;
1472
82
  }
1473
83
  };
1474
84
  }
1475
- function defaultMethodNamesOrAssert(methodNames) {
1476
- if (methodNames === void 0) {
1477
- return allEmitteryMethods;
1478
- }
1479
- if (!Array.isArray(methodNames)) {
85
+ function H(t) {
86
+ if (t === void 0)
87
+ return $;
88
+ if (!Array.isArray(t))
1480
89
  throw new TypeError("`methodNames` must be an array of strings");
1481
- }
1482
- for (const methodName of methodNames) {
1483
- if (!allEmitteryMethods.includes(methodName)) {
1484
- if (typeof methodName !== "string") {
1485
- throw new TypeError("`methodNames` element must be a string");
1486
- }
1487
- throw new Error(`${methodName} is not Emittery method`);
1488
- }
1489
- }
1490
- return methodNames;
1491
- }
1492
- const isListenerSymbol = (symbol) => symbol === listenerAdded || symbol === listenerRemoved;
1493
- class Emittery {
1494
- static mixin(emitteryPropertyName, methodNames) {
1495
- methodNames = defaultMethodNamesOrAssert(methodNames);
1496
- return (target) => {
1497
- if (typeof target !== "function") {
90
+ for (const e of t)
91
+ if (!$.includes(e))
92
+ throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
93
+ return t;
94
+ }
95
+ const I = (t) => t === k || t === A;
96
+ class m {
97
+ static mixin(e, r) {
98
+ return r = H(r), (s) => {
99
+ if (typeof s != "function")
1498
100
  throw new TypeError("`target` must be function");
1499
- }
1500
- for (const methodName of methodNames) {
1501
- if (target.prototype[methodName] !== void 0) {
1502
- throw new Error(`The property \`${methodName}\` already exists on \`target\``);
1503
- }
1504
- }
1505
- function getEmitteryProperty() {
1506
- Object.defineProperty(this, emitteryPropertyName, {
1507
- enumerable: false,
1508
- value: new Emittery()
1509
- });
1510
- return this[emitteryPropertyName];
1511
- }
1512
- Object.defineProperty(target.prototype, emitteryPropertyName, {
1513
- enumerable: false,
1514
- get: getEmitteryProperty
101
+ for (const n of r)
102
+ if (s.prototype[n] !== void 0)
103
+ throw new Error(`The property \`${n}\` already exists on \`target\``);
104
+ function o() {
105
+ return Object.defineProperty(this, e, {
106
+ enumerable: !1,
107
+ value: new m()
108
+ }), this[e];
109
+ }
110
+ Object.defineProperty(s.prototype, e, {
111
+ enumerable: !1,
112
+ get: o
1515
113
  });
1516
- const emitteryMethodCaller = (methodName) => function(...args) {
1517
- return this[emitteryPropertyName][methodName](...args);
114
+ const i = (n) => function(...c) {
115
+ return this[e][n](...c);
1518
116
  };
1519
- for (const methodName of methodNames) {
1520
- Object.defineProperty(target.prototype, methodName, {
1521
- enumerable: false,
1522
- value: emitteryMethodCaller(methodName)
117
+ for (const n of r)
118
+ Object.defineProperty(s.prototype, n, {
119
+ enumerable: !1,
120
+ value: i(n)
1523
121
  });
1524
- }
1525
- return target;
122
+ return s;
1526
123
  };
1527
124
  }
1528
125
  static get isDebugEnabled() {
1529
- if (typeof process !== "object") {
1530
- return isGlobalDebugEnabled;
1531
- }
1532
- const { env } = process || { env: {} };
1533
- return env.DEBUG === "emittery" || env.DEBUG === "*" || isGlobalDebugEnabled;
126
+ if (typeof process != "object")
127
+ return x;
128
+ const { env: e } = process || { env: {} };
129
+ return e.DEBUG === "emittery" || e.DEBUG === "*" || x;
1534
130
  }
1535
- static set isDebugEnabled(newValue) {
1536
- isGlobalDebugEnabled = newValue;
131
+ static set isDebugEnabled(e) {
132
+ x = e;
1537
133
  }
1538
- constructor(options = {}) {
1539
- anyMap.set(this, new Set());
1540
- eventsMap.set(this, new Map());
1541
- producersMap.set(this, new Map());
1542
- this.debug = options.debug || {};
1543
- if (this.debug.enabled === void 0) {
1544
- this.debug.enabled = false;
1545
- }
1546
- if (!this.debug.logger) {
1547
- this.debug.logger = (type, debugName, eventName, eventData) => {
1548
- eventData = JSON.stringify(eventData);
1549
- if (typeof eventName === "symbol") {
1550
- eventName = eventName.toString();
1551
- }
1552
- const currentTime = new Date();
1553
- const logTime = `${currentTime.getHours()}:${currentTime.getMinutes()}:${currentTime.getSeconds()}.${currentTime.getMilliseconds()}`;
1554
- console.log(`[${logTime}][emittery:${type}][${debugName}] Event Name: ${eventName}
1555
- data: ${eventData}`);
1556
- };
1557
- }
134
+ constructor(e = {}) {
135
+ h.set(this, /* @__PURE__ */ new Set()), E.set(this, /* @__PURE__ */ new Map()), y.set(this, /* @__PURE__ */ new Map()), this.debug = e.debug || {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (r, s, o, i) => {
136
+ try {
137
+ i = JSON.stringify(i);
138
+ } catch {
139
+ i = `Object with the following keys failed to stringify: ${Object.keys(i).join(",")}`;
140
+ }
141
+ typeof o == "symbol" && (o = o.toString());
142
+ const n = new Date(), c = `${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}.${n.getMilliseconds()}`;
143
+ console.log(`[${c}][emittery:${r}][${s}] Event Name: ${o}
144
+ data: ${i}`);
145
+ });
1558
146
  }
1559
- logIfDebugEnabled(type, eventName, eventData) {
1560
- if (Emittery.isDebugEnabled || this.debug.enabled) {
1561
- this.debug.logger(type, this.debug.name, eventName, eventData);
1562
- }
147
+ logIfDebugEnabled(e, r, s) {
148
+ (m.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, r, s);
1563
149
  }
1564
- on(eventNames, listener) {
1565
- assertListener(listener);
1566
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1567
- for (const eventName of eventNames) {
1568
- assertEventName(eventName);
1569
- getListeners(this, eventName).add(listener);
1570
- this.logIfDebugEnabled("subscribe", eventName, void 0);
1571
- if (!isListenerSymbol(eventName)) {
1572
- this.emit(listenerAdded, { eventName, listener });
1573
- }
1574
- }
1575
- return this.off.bind(this, eventNames, listener);
150
+ on(e, r) {
151
+ T(r), e = Array.isArray(e) ? e : [e];
152
+ for (const s of e)
153
+ _(s), g(this, s).add(r), this.logIfDebugEnabled("subscribe", s, void 0), I(s) || this.emit(k, { eventName: s, listener: r });
154
+ return this.off.bind(this, e, r);
1576
155
  }
1577
- off(eventNames, listener) {
1578
- assertListener(listener);
1579
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1580
- for (const eventName of eventNames) {
1581
- assertEventName(eventName);
1582
- getListeners(this, eventName).delete(listener);
1583
- this.logIfDebugEnabled("unsubscribe", eventName, void 0);
1584
- if (!isListenerSymbol(eventName)) {
1585
- this.emit(listenerRemoved, { eventName, listener });
1586
- }
1587
- }
156
+ off(e, r) {
157
+ T(r), e = Array.isArray(e) ? e : [e];
158
+ for (const s of e)
159
+ _(s), g(this, s).delete(r), this.logIfDebugEnabled("unsubscribe", s, void 0), I(s) || this.emit(A, { eventName: s, listener: r });
1588
160
  }
1589
- once(eventNames) {
1590
- return new Promise((resolve) => {
1591
- const off = this.on(eventNames, (data2) => {
1592
- off();
1593
- resolve(data2);
161
+ once(e) {
162
+ return new Promise((r) => {
163
+ const s = this.on(e, (o) => {
164
+ s(), r(o);
1594
165
  });
1595
166
  });
1596
167
  }
1597
- events(eventNames) {
1598
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1599
- for (const eventName of eventNames) {
1600
- assertEventName(eventName);
1601
- }
1602
- return iterator(this, eventNames);
1603
- }
1604
- async emit(eventName, eventData) {
1605
- assertEventName(eventName);
1606
- this.logIfDebugEnabled("emit", eventName, eventData);
1607
- enqueueProducers(this, eventName, eventData);
1608
- const listeners = getListeners(this, eventName);
1609
- const anyListeners = anyMap.get(this);
1610
- const staticListeners = [...listeners];
1611
- const staticAnyListeners = isListenerSymbol(eventName) ? [] : [...anyListeners];
1612
- await resolvedPromise;
1613
- await Promise.all([
1614
- ...staticListeners.map(async (listener) => {
1615
- if (listeners.has(listener)) {
1616
- return listener(eventData);
1617
- }
168
+ events(e) {
169
+ e = Array.isArray(e) ? e : [e];
170
+ for (const r of e)
171
+ _(r);
172
+ return U(this, e);
173
+ }
174
+ async emit(e, r) {
175
+ _(e), this.logIfDebugEnabled("emit", e, r), Y(this, e, r);
176
+ const s = g(this, e), o = h.get(this), i = [...s], n = I(e) ? [] : [...o];
177
+ await D, await Promise.all([
178
+ ...i.map(async (c) => {
179
+ if (s.has(c))
180
+ return c(r);
1618
181
  }),
1619
- ...staticAnyListeners.map(async (listener) => {
1620
- if (anyListeners.has(listener)) {
1621
- return listener(eventName, eventData);
1622
- }
182
+ ...n.map(async (c) => {
183
+ if (o.has(c))
184
+ return c(e, r);
1623
185
  })
1624
186
  ]);
1625
187
  }
1626
- async emitSerial(eventName, eventData) {
1627
- assertEventName(eventName);
1628
- this.logIfDebugEnabled("emitSerial", eventName, eventData);
1629
- const listeners = getListeners(this, eventName);
1630
- const anyListeners = anyMap.get(this);
1631
- const staticListeners = [...listeners];
1632
- const staticAnyListeners = [...anyListeners];
1633
- await resolvedPromise;
1634
- for (const listener of staticListeners) {
1635
- if (listeners.has(listener)) {
1636
- await listener(eventData);
1637
- }
1638
- }
1639
- for (const listener of staticAnyListeners) {
1640
- if (anyListeners.has(listener)) {
1641
- await listener(eventName, eventData);
1642
- }
1643
- }
188
+ async emitSerial(e, r) {
189
+ _(e), this.logIfDebugEnabled("emitSerial", e, r);
190
+ const s = g(this, e), o = h.get(this), i = [...s], n = [...o];
191
+ await D;
192
+ for (const c of i)
193
+ s.has(c) && await c(r);
194
+ for (const c of n)
195
+ o.has(c) && await c(e, r);
1644
196
  }
1645
- onAny(listener) {
1646
- assertListener(listener);
1647
- this.logIfDebugEnabled("subscribeAny", void 0, void 0);
1648
- anyMap.get(this).add(listener);
1649
- this.emit(listenerAdded, { listener });
1650
- return this.offAny.bind(this, listener);
197
+ onAny(e) {
198
+ return T(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), h.get(this).add(e), this.emit(k, { listener: e }), this.offAny.bind(this, e);
1651
199
  }
1652
200
  anyEvent() {
1653
- return iterator(this);
1654
- }
1655
- offAny(listener) {
1656
- assertListener(listener);
1657
- this.logIfDebugEnabled("unsubscribeAny", void 0, void 0);
1658
- this.emit(listenerRemoved, { listener });
1659
- anyMap.get(this).delete(listener);
1660
- }
1661
- clearListeners(eventNames) {
1662
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1663
- for (const eventName of eventNames) {
1664
- this.logIfDebugEnabled("clear", eventName, void 0);
1665
- if (typeof eventName === "string" || typeof eventName === "symbol") {
1666
- getListeners(this, eventName).clear();
1667
- const producers = getEventProducers(this, eventName);
1668
- for (const producer of producers) {
1669
- producer.finish();
1670
- }
1671
- producers.clear();
201
+ return U(this);
202
+ }
203
+ offAny(e) {
204
+ T(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), this.emit(A, { listener: e }), h.get(this).delete(e);
205
+ }
206
+ clearListeners(e) {
207
+ e = Array.isArray(e) ? e : [e];
208
+ for (const r of e)
209
+ if (this.logIfDebugEnabled("clear", r, void 0), typeof r == "string" || typeof r == "symbol") {
210
+ g(this, r).clear();
211
+ const s = b(this, r);
212
+ for (const o of s)
213
+ o.finish();
214
+ s.clear();
1672
215
  } else {
1673
- anyMap.get(this).clear();
1674
- for (const listeners of eventsMap.get(this).values()) {
1675
- listeners.clear();
1676
- }
1677
- for (const producers of producersMap.get(this).values()) {
1678
- for (const producer of producers) {
1679
- producer.finish();
1680
- }
1681
- producers.clear();
216
+ h.get(this).clear();
217
+ for (const s of E.get(this).values())
218
+ s.clear();
219
+ for (const s of y.get(this).values()) {
220
+ for (const o of s)
221
+ o.finish();
222
+ s.clear();
1682
223
  }
1683
224
  }
1684
- }
1685
225
  }
1686
- listenerCount(eventNames) {
1687
- eventNames = Array.isArray(eventNames) ? eventNames : [eventNames];
1688
- let count = 0;
1689
- for (const eventName of eventNames) {
1690
- if (typeof eventName === "string") {
1691
- count += anyMap.get(this).size + getListeners(this, eventName).size + getEventProducers(this, eventName).size + getEventProducers(this).size;
226
+ listenerCount(e) {
227
+ e = Array.isArray(e) ? e : [e];
228
+ let r = 0;
229
+ for (const s of e) {
230
+ if (typeof s == "string") {
231
+ r += h.get(this).size + g(this, s).size + b(this, s).size + b(this).size;
1692
232
  continue;
1693
233
  }
1694
- if (typeof eventName !== "undefined") {
1695
- assertEventName(eventName);
1696
- }
1697
- count += anyMap.get(this).size;
1698
- for (const value of eventsMap.get(this).values()) {
1699
- count += value.size;
1700
- }
1701
- for (const value of producersMap.get(this).values()) {
1702
- count += value.size;
1703
- }
234
+ typeof s < "u" && _(s), r += h.get(this).size;
235
+ for (const o of E.get(this).values())
236
+ r += o.size;
237
+ for (const o of y.get(this).values())
238
+ r += o.size;
1704
239
  }
1705
- return count;
240
+ return r;
1706
241
  }
1707
- bindMethods(target, methodNames) {
1708
- if (typeof target !== "object" || target === null) {
242
+ bindMethods(e, r) {
243
+ if (typeof e != "object" || e === null)
1709
244
  throw new TypeError("`target` must be an object");
1710
- }
1711
- methodNames = defaultMethodNamesOrAssert(methodNames);
1712
- for (const methodName of methodNames) {
1713
- if (target[methodName] !== void 0) {
1714
- throw new Error(`The property \`${methodName}\` already exists on \`target\``);
1715
- }
1716
- Object.defineProperty(target, methodName, {
1717
- enumerable: false,
1718
- value: this[methodName].bind(this)
245
+ r = H(r);
246
+ for (const s of r) {
247
+ if (e[s] !== void 0)
248
+ throw new Error(`The property \`${s}\` already exists on \`target\``);
249
+ Object.defineProperty(e, s, {
250
+ enumerable: !1,
251
+ value: this[s].bind(this)
1719
252
  });
1720
253
  }
1721
254
  }
1722
255
  }
1723
- const allEmitteryMethods = Object.getOwnPropertyNames(Emittery.prototype).filter((v) => v !== "constructor");
1724
- Object.defineProperty(Emittery, "listenerAdded", {
1725
- value: listenerAdded,
1726
- writable: false,
1727
- enumerable: true,
1728
- configurable: false
256
+ const $ = Object.getOwnPropertyNames(m.prototype).filter((t) => t !== "constructor");
257
+ Object.defineProperty(m, "listenerAdded", {
258
+ value: k,
259
+ writable: !1,
260
+ enumerable: !0,
261
+ configurable: !1
1729
262
  });
1730
- Object.defineProperty(Emittery, "listenerRemoved", {
1731
- value: listenerRemoved,
1732
- writable: false,
1733
- enumerable: true,
1734
- configurable: false
263
+ Object.defineProperty(m, "listenerRemoved", {
264
+ value: A,
265
+ writable: !1,
266
+ enumerable: !0,
267
+ configurable: !1
1735
268
  });
1736
- var emittery = Emittery;
1737
- function isErrorWithMessage(error) {
1738
- return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
269
+ var L = m;
270
+ function q(t) {
271
+ return typeof t == "object" && t !== null && "message" in t && typeof t.message == "string";
1739
272
  }
1740
- function toErrorWithMessage(maybeError) {
1741
- if (isErrorWithMessage(maybeError))
1742
- return maybeError;
273
+ function J(t) {
274
+ if (q(t))
275
+ return t;
1743
276
  try {
1744
- return new Error(JSON.stringify(maybeError));
277
+ return new Error(JSON.stringify(t));
1745
278
  } catch {
1746
- return new Error(String(maybeError));
1747
- }
279
+ return new Error(String(t));
280
+ }
281
+ }
282
+ function v(t) {
283
+ return J(t).message;
284
+ }
285
+ var X = Object.defineProperty, Z = (t, e, r) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, K = (t, e, r) => (Z(t, typeof e != "symbol" ? e + "" : e, r), r), N = /* @__PURE__ */ ((t) => (t.automation = "automation", t.test = "test", t.vbc = "vbc", t.video = "video", t.voice = "voice", t))(N || {});
286
+ const ee = "hlg.tokbox.com/prod/logging/vcp_webrtc", re = "https://", te = 1e4;
287
+ let S;
288
+ const se = new Uint8Array(16);
289
+ function oe() {
290
+ if (!S && (S = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !S))
291
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
292
+ return S(se);
293
+ }
294
+ const f = [];
295
+ for (let t = 0; t < 256; ++t)
296
+ f.push((t + 256).toString(16).slice(1));
297
+ function ie(t, e = 0) {
298
+ return (f[t[e + 0]] + f[t[e + 1]] + f[t[e + 2]] + f[t[e + 3]] + "-" + f[t[e + 4]] + f[t[e + 5]] + "-" + f[t[e + 6]] + f[t[e + 7]] + "-" + f[t[e + 8]] + f[t[e + 9]] + "-" + f[t[e + 10]] + f[t[e + 11]] + f[t[e + 12]] + f[t[e + 13]] + f[t[e + 14]] + f[t[e + 15]]).toLowerCase();
299
+ }
300
+ const ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Q = {
301
+ randomUUID: ne
302
+ };
303
+ function ae(t, e, r) {
304
+ if (Q.randomUUID && !e && !t)
305
+ return Q.randomUUID();
306
+ t = t || {};
307
+ const s = t.random || (t.rng || oe)();
308
+ if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) {
309
+ r = r || 0;
310
+ for (let o = 0; o < 16; ++o)
311
+ e[r + o] = s[o];
312
+ return e;
313
+ }
314
+ return ie(s);
315
+ }
316
+ const p = {};
317
+ var d = /* @__PURE__ */ ((t) => (t.INIT = "INIT", t.FORWARD = "FORWARD", t.TERMINATE = "TERMINATE", t.GLOBALS_SYNC = "GLOBALS_SYNC", t))(d || {});
318
+ function j(t) {
319
+ return [ImageBitmap, ReadableStream, WritableStream].some((e) => t instanceof e);
320
+ }
321
+ let ce = 0;
322
+ function fe(t, e, r, s, o) {
323
+ const i = ce++;
324
+ return t.postMessage(
325
+ {
326
+ id: i,
327
+ type: e,
328
+ functionName: r,
329
+ args: s
330
+ },
331
+ s.filter((n) => j(n))
332
+ ), new Promise((n) => {
333
+ o == null || o.set(i, n);
334
+ });
1748
335
  }
1749
- function getErrorMessage(error) {
1750
- return toErrorWithMessage(error).message;
336
+ function w(t, e) {
337
+ const { id: r, type: s } = t, o = Array.isArray(e) ? e : [e];
338
+ postMessage(
339
+ {
340
+ id: r,
341
+ type: s,
342
+ result: e
343
+ },
344
+ o.filter((i) => j(i))
345
+ );
346
+ }
347
+ const G = {};
348
+ function z() {
349
+ return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
350
+ }
351
+ async function le() {
352
+ if (z())
353
+ w({ type: d.GLOBALS_SYNC }, p);
354
+ else {
355
+ const t = [];
356
+ for (const e in G) {
357
+ const { worker: r, resolvers: s } = G[e].workerContext;
358
+ r && t.push(
359
+ fe(
360
+ r,
361
+ d.GLOBALS_SYNC,
362
+ "",
363
+ [p],
364
+ s
365
+ )
366
+ );
367
+ }
368
+ await Promise.all(t);
369
+ }
370
+ }
371
+ function P(t, e) {
372
+ if (Array.isArray(e))
373
+ e.splice(0, e.length);
374
+ else if (typeof e == "object")
375
+ for (const r in e)
376
+ delete e[r];
377
+ for (const r in t)
378
+ Array.isArray(t[r]) ? (e[r] = [], P(t[r], e[r])) : typeof t[r] == "object" ? (e[r] = {}, P(t[r], e[r])) : e[r] = t[r];
379
+ }
380
+ async function ue(t, e) {
381
+ const { functionName: r, args: s } = t;
382
+ if (!e.instance)
383
+ throw "instance not initialized";
384
+ if (!r)
385
+ throw "missing function name to call";
386
+ if (!e.instance[r])
387
+ throw `undefined function [${r}] in class ${e.instance.constructor.workerId}`;
388
+ w(t, await e.instance[r](...s != null ? s : []));
389
+ }
390
+ const he = {};
391
+ function pe(t, e) {
392
+ if (!t.args)
393
+ throw "Missing className while initializing worker";
394
+ const [r, s] = t.args, o = he[r];
395
+ if (o)
396
+ e.instance = new o(t.args.slice(1));
397
+ else
398
+ throw `unknown worker class ${r}`;
399
+ P(s, p), w(t, typeof e.instance !== void 0);
400
+ }
401
+ async function de(t, e) {
402
+ const { args: r } = t;
403
+ if (!e.instance)
404
+ throw "instance not initialized";
405
+ let s;
406
+ e.instance.terminate && (s = await e.instance.terminate(...r != null ? r : [])), w(t, s);
407
+ }
408
+ function me(t) {
409
+ if (!t.args)
410
+ throw "Missing globals while syncing";
411
+ P(t.args[0], p), w(t, {});
412
+ }
413
+ function _e() {
414
+ const t = {};
415
+ onmessage = async (e) => {
416
+ const r = e.data;
417
+ switch (r.type) {
418
+ case d.INIT:
419
+ pe(r, t);
420
+ break;
421
+ case d.FORWARD:
422
+ ue(r, t);
423
+ break;
424
+ case d.TERMINATE:
425
+ de(r, t);
426
+ break;
427
+ case d.GLOBALS_SYNC:
428
+ me(r);
429
+ break;
430
+ }
431
+ };
1751
432
  }
1752
- var WarningType;
1753
- (function(WarningType2) {
1754
- WarningType2["FPS_DROP"] = "fps_drop";
1755
- })(WarningType || (WarningType = {}));
1756
- const TELEMETRY_MEDIA_TRANSFORMER_QOS_REPORT_INTERVAL = 500;
1757
- const RATE_DROP_TO_PRECENT = 0.8;
1758
- class InternalTransformer extends emittery {
1759
- constructor(transformer, index) {
433
+ z() && _e();
434
+ function ge(t, e) {
435
+ return p[t] || (p[t] = e), [
436
+ () => p[t],
437
+ async (r) => {
438
+ p[t] = r, await le();
439
+ }
440
+ ];
441
+ }
442
+ function ye(t, e) {
443
+ return ge(t, e);
444
+ }
445
+ const [be, we] = ye("metadata");
446
+ function ve(t) {
447
+ we(t);
448
+ }
449
+ function C() {
450
+ return be();
451
+ }
452
+ class W {
453
+ constructor(e) {
454
+ K(this, "uuid", ae()), this.config = e;
455
+ }
456
+ async send(e) {
457
+ var r, s, o;
458
+ const { appId: i, sourceType: n } = (r = C()) != null ? r : {};
459
+ if (!i || !n)
460
+ return "metadata missing";
461
+ const c = new AbortController(), u = setTimeout(() => c.abort(), te);
462
+ return await ((o = (s = this.config) == null ? void 0 : s.fetch) != null ? o : fetch)(this.getUrl(), {
463
+ method: "POST",
464
+ headers: this.getHeaders(),
465
+ body: JSON.stringify(this.buildReport(e)),
466
+ signal: c.signal
467
+ }), clearTimeout(u), "success";
468
+ }
469
+ getUrl() {
470
+ var e;
471
+ let r = (e = C().proxyUrl) != null ? e : re;
472
+ return r += (r.at(-1) === "/" ? "" : "/") + ee, r;
473
+ }
474
+ getHeaders() {
475
+ return {
476
+ "Content-Type": "application/json"
477
+ };
478
+ }
479
+ buildReport(e) {
480
+ const r = C();
481
+ return {
482
+ guid: this.uuid,
483
+ ...e,
484
+ applicationId: r.appId,
485
+ timestamp: Date.now(),
486
+ proxyUrl: r.proxyUrl,
487
+ source: r.sourceType
488
+ };
489
+ }
490
+ }
491
+ const R = "2.0.1";
492
+ class Te {
493
+ constructor(e) {
494
+ a(this, "frameTransformedCount", 0);
495
+ a(this, "frameFromSourceCount", 0);
496
+ a(this, "startAt", 0);
497
+ a(this, "reporter");
498
+ this.config = e, this.reporter = new W(e);
499
+ }
500
+ async onFrameFromSource() {
501
+ this.frameFromSourceCount++;
502
+ }
503
+ get fps() {
504
+ const { startAt: e, frameFromSourceCount: r } = this, o = (Date.now() - e) / 1e3;
505
+ return r / o;
506
+ }
507
+ async onFrameTransformed(e = {}, r = !1) {
508
+ this.startAt === 0 && (this.startAt = Date.now()), this.frameTransformedCount++;
509
+ const { startAt: s, frameTransformedCount: o, frameFromSourceCount: i } = this, n = Date.now(), c = (n - s) / 1e3, u = o / c, M = i / c;
510
+ return r || this.frameTransformedCount >= this.config.loggingIntervalFrameCount ? (this.frameFromSourceCount = 0, this.frameTransformedCount = 0, this.startAt = n, this.reporter.config = this.config, this.reporter.send({
511
+ ...this.config.report,
512
+ variation: "QoS",
513
+ fps: M,
514
+ transformedFps: u,
515
+ framesTransformed: o,
516
+ ...e
517
+ })) : "success";
518
+ }
519
+ }
520
+ var Se = /* @__PURE__ */ ((t) => (t.FPS_DROP = "fps_drop", t))(Se || {}), Ee = /* @__PURE__ */ ((t) => (t.start = "start", t.transform = "transform", t.flush = "flush", t))(Ee || {}), F = /* @__PURE__ */ ((t) => (t.pipeline_ended = "pipeline_ended", t.pipeline_ended_with_error = "pipeline_ended_with_error", t.pipeline_started = "pipeline_started", t.pipeline_started_with_error = "pipeline_started_with_error", t.pipeline_restarted = "pipeline_restarted", t.pipeline_restarted_with_error = "pipeline_restarted_with_error", t))(F || {});
521
+ const Re = 500, ke = 0.8;
522
+ class Ae extends L {
523
+ constructor(r, s) {
1760
524
  super();
1761
- this.index_ = index;
1762
- this.uuid_ = v4();
1763
- this.framesTransformed_ = 0;
1764
- this.transformer_ = transformer;
1765
- this.shouldStop_ = false;
1766
- this.isFlashed_ = false;
1767
- this.framesFromSource_ = 0;
1768
- this.fps_ = 0;
1769
- this.mediaTransformerQosReportStartTimestamp_ = 0;
1770
- this.videoHeight_ = 0;
1771
- this.videoWidth_ = 0;
1772
- this.trackExpectedRate_ = -1;
1773
- this.transformerType_ = "Custom";
1774
- if ("getTransformerType" in transformer) {
1775
- this.transformerType_ = transformer.getTransformerType();
1776
- }
1777
- const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Create").build();
1778
- Reporter.report(report);
525
+ a(this, "reporter_", new W());
526
+ a(this, "reporterQos_", new Te({
527
+ loggingIntervalFrameCount: Re,
528
+ report: {
529
+ version: R
530
+ }
531
+ }));
532
+ a(this, "transformerType_");
533
+ a(this, "transformer_");
534
+ a(this, "shouldStop_");
535
+ a(this, "isFlashed_");
536
+ a(this, "mediaTransformerQosReportStartTimestamp_");
537
+ a(this, "videoHeight_");
538
+ a(this, "videoWidth_");
539
+ a(this, "trackExpectedRate_");
540
+ a(this, "index_");
541
+ a(this, "controller_");
542
+ this.index_ = s, this.transformer_ = r, this.shouldStop_ = !1, this.isFlashed_ = !1, this.mediaTransformerQosReportStartTimestamp_ = 0, this.videoHeight_ = 0, this.videoWidth_ = 0, this.trackExpectedRate_ = -1, this.transformerType_ = "Custom", "getTransformerType" in r && (this.transformerType_ = r.getTransformerType()), this.report({
543
+ variation: "Create"
544
+ });
1779
545
  }
1780
- setTrackExpectedRate(trackExpectedRate) {
1781
- this.trackExpectedRate_ = trackExpectedRate;
546
+ setTrackExpectedRate(r) {
547
+ this.trackExpectedRate_ = r;
1782
548
  }
1783
- async start(controller) {
1784
- this.controller_ = controller;
1785
- if (this.transformer_ && typeof this.transformer_.start === "function") {
549
+ async start(r) {
550
+ if (this.controller_ = r, this.transformer_ && typeof this.transformer_.start == "function")
1786
551
  try {
1787
- await this.transformer_.start(controller);
1788
- } catch (e) {
1789
- const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_start"]).transformerType(this.transformerType_).variation("Error").error(getErrorMessage(e)).build();
1790
- Reporter.report(report);
1791
- const msg = { eventMetaData: { transformerIndex: this.index_ }, error: e, function: "start" };
1792
- this.emit("error", msg);
552
+ await this.transformer_.start(r);
553
+ } catch (s) {
554
+ this.report({
555
+ message: l.errors.transformer_start,
556
+ variation: "Error",
557
+ error: v(s)
558
+ });
559
+ const o = { eventMetaData: { transformerIndex: this.index_ }, error: s, function: "start" };
560
+ this.emit("error", o);
1793
561
  }
1794
- }
1795
562
  }
1796
- async transform(data2, controller) {
1797
- var _a, _b, _c, _d;
1798
- if (this.mediaTransformerQosReportStartTimestamp_ === 0) {
1799
- this.mediaTransformerQosReportStartTimestamp_ = Date.now();
1800
- }
1801
- if (data2 instanceof VideoFrame) {
1802
- this.videoHeight_ = (_a = data2 == null ? void 0 : data2.displayHeight) != null ? _a : 0;
1803
- this.videoWidth_ = (_b = data2 == null ? void 0 : data2.displayWidth) != null ? _b : 0;
1804
- }
1805
- ++this.framesFromSource_;
1806
- if (this.transformer_) {
1807
- if (!this.shouldStop_) {
563
+ async transform(r, s) {
564
+ var o, i, n, c;
565
+ if (this.mediaTransformerQosReportStartTimestamp_ === 0 && (this.mediaTransformerQosReportStartTimestamp_ = Date.now()), r instanceof VideoFrame && (this.videoHeight_ = (o = r == null ? void 0 : r.displayHeight) != null ? o : 0, this.videoWidth_ = (i = r == null ? void 0 : r.displayWidth) != null ? i : 0), this.reporterQos_.onFrameFromSource(), this.transformer_)
566
+ if (this.shouldStop_)
567
+ console.warn("[Pipeline] flush from transform"), r.close(), this.flush(s), s.terminate();
568
+ else {
1808
569
  try {
1809
- await ((_d = (_c = this.transformer_).transform) == null ? void 0 : _d.call(_c, data2, controller));
1810
- ++this.framesTransformed_;
1811
- if (this.framesTransformed_ === TELEMETRY_MEDIA_TRANSFORMER_QOS_REPORT_INTERVAL) {
1812
- this.mediaTransformerQosReport();
1813
- }
1814
- } catch (e) {
1815
- const report = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_transform"]).transformerType(this.transformerType_).variation("Error").error(getErrorMessage(e)).build();
1816
- Reporter.report(report);
1817
- const msg = { eventMetaData: { transformerIndex: this.index_ }, error: e, function: "transform" };
1818
- this.emit("error", msg);
570
+ await ((c = (n = this.transformer_).transform) == null ? void 0 : c.call(n, r, s)), this.reportQos();
571
+ } catch (u) {
572
+ this.report({
573
+ message: l.errors.transformer_transform,
574
+ variation: "Error",
575
+ error: v(u)
576
+ });
577
+ const M = { eventMetaData: { transformerIndex: this.index_ }, error: u, function: "transform" };
578
+ this.emit("error", M);
579
+ }
580
+ if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * ke > this.reporterQos_.fps) {
581
+ const u = {
582
+ eventMetaData: {
583
+ transformerIndex: this.index_
584
+ },
585
+ warningType: "fps_drop",
586
+ dropInfo: {
587
+ requested: this.trackExpectedRate_,
588
+ current: this.reporterQos_.fps
589
+ }
590
+ };
591
+ this.emit("warn", u);
1819
592
  }
1820
- } else {
1821
- console.warn("[Pipeline] flush from transform");
1822
- data2.close();
1823
- this.flush(controller);
1824
- controller.terminate();
1825
593
  }
1826
- }
1827
594
  }
1828
- async flush(controller) {
1829
- if (this.transformer_ && typeof this.transformer_.flush === "function" && !this.isFlashed_) {
1830
- this.isFlashed_ = true;
595
+ async flush(r) {
596
+ if (this.transformer_ && typeof this.transformer_.flush == "function" && !this.isFlashed_) {
597
+ this.isFlashed_ = !0;
1831
598
  try {
1832
- await this.transformer_.flush(controller);
1833
- } catch (e) {
1834
- const error = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).message(Key.errors["transformer_flush"]).transformerType(this.transformerType_).variation("Error").error(getErrorMessage(e)).build();
1835
- Reporter.report(error);
1836
- const msg = { eventMetaData: { transformerIndex: this.index_ }, error: e, function: "flush" };
1837
- this.emit("error", msg);
599
+ await this.transformer_.flush(r);
600
+ } catch (s) {
601
+ this.report({
602
+ message: l.errors.transformer_flush,
603
+ variation: "Error",
604
+ error: v(s)
605
+ });
606
+ const o = { eventMetaData: { transformerIndex: this.index_ }, error: s, function: "flush" };
607
+ this.emit("error", o);
1838
608
  }
1839
609
  }
1840
- this.mediaTransformerQosReport();
1841
- const deleteReport = new ReportBuilder().action("MediaTransformer").guid(this.uuid_).transformerType(this.transformerType_).variation("Delete").build();
1842
- Reporter.report(deleteReport);
610
+ this.reportQos(!0), this.report({
611
+ variation: "Delete"
612
+ });
1843
613
  }
1844
614
  stop() {
1845
- console.log("[Pipeline] Stop stream.");
1846
- if (this.controller_) {
1847
- this.flush(this.controller_);
1848
- this.controller_.terminate();
1849
- }
1850
- this.shouldStop_ = true;
615
+ console.log("[Pipeline] Stop stream."), this.controller_ && (this.flush(this.controller_), this.controller_.terminate()), this.shouldStop_ = !0;
616
+ }
617
+ report(r) {
618
+ this.reporter_.send({
619
+ version: R,
620
+ action: "MediaTransformer",
621
+ transformerType: this.transformerType_,
622
+ ...r
623
+ });
1851
624
  }
1852
- mediaTransformerQosReport() {
1853
- let timeElapsed_s = (Date.now() - this.mediaTransformerQosReportStartTimestamp_) / 1e3;
1854
- let fps = this.framesFromSource_ / timeElapsed_s;
1855
- let transformedFps = this.framesTransformed_ / timeElapsed_s;
1856
- if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * RATE_DROP_TO_PRECENT > fps) {
1857
- const msg = { eventMetaData: { transformerIndex: this.index_ }, warningType: WarningType.FPS_DROP, dropInfo: { requested: this.trackExpectedRate_, current: fps } };
1858
- this.emit("warn", msg);
1859
- }
1860
- const qos = new ReportBuilder().action("MediaTransformer").fps(fps).transformedFps(transformedFps).framesTransformed(this.framesTransformed_).guid(this.uuid_).transformerType(this.transformerType_).videoHeight(this.videoHeight_).videoWidth(this.videoWidth_).variation("QoS").build();
1861
- Reporter.report(qos);
1862
- this.mediaTransformerQosReportStartTimestamp_ = 0;
1863
- this.framesFromSource_ = 0;
1864
- this.framesTransformed_ = 0;
625
+ reportQos(r = !1) {
626
+ this.reporterQos_.config = {
627
+ ...this.reporterQos_.config
628
+ }, this.reporterQos_.onFrameTransformed({
629
+ version: R,
630
+ action: "MediaTransformer",
631
+ transformerType: this.transformerType_,
632
+ videoWidth: this.videoWidth_,
633
+ videoHeight: this.videoHeight_
634
+ }, r);
1865
635
  }
1866
636
  }
1867
- class Pipeline extends emittery {
1868
- constructor(transformers) {
637
+ class Pe extends L {
638
+ constructor(r) {
1869
639
  super();
1870
- this.transformers_ = [];
1871
- this.trackExpectedRate_ = -1;
1872
- for (let index = 0; index < transformers.length; index++) {
1873
- let internalTransformer = new InternalTransformer(transformers[index], index);
1874
- internalTransformer.on("error", (eventData) => {
1875
- this.emit("error", eventData);
1876
- });
1877
- internalTransformer.on("warn", (eventData) => {
1878
- this.emit("warn", eventData);
1879
- });
1880
- this.transformers_.push(internalTransformer);
1881
- }
1882
- }
1883
- setTrackExpectedRate(trackExpectedRate) {
1884
- this.trackExpectedRate_ = trackExpectedRate;
1885
- for (let transformer of this.transformers_) {
1886
- transformer.setTrackExpectedRate(this.trackExpectedRate_);
1887
- }
1888
- }
1889
- async start(readable, writeable) {
640
+ a(this, "transformers_");
641
+ a(this, "trackExpectedRate_");
642
+ this.transformers_ = [], this.trackExpectedRate_ = -1;
643
+ for (let s = 0; s < r.length; s++) {
644
+ let o = new Ae(r[s], s);
645
+ o.on("error", (i) => {
646
+ this.emit("error", i);
647
+ }), o.on("warn", (i) => {
648
+ this.emit("warn", i);
649
+ }), this.transformers_.push(o);
650
+ }
651
+ }
652
+ setTrackExpectedRate(r) {
653
+ this.trackExpectedRate_ = r;
654
+ for (let s of this.transformers_)
655
+ s.setTrackExpectedRate(this.trackExpectedRate_);
656
+ }
657
+ async start(r, s) {
1890
658
  if (!this.transformers_ || this.transformers_.length === 0) {
1891
659
  console.log("[Pipeline] No transformers.");
1892
660
  return;
1893
661
  }
1894
662
  try {
1895
- let orgReader = readable;
1896
- for (let transformer of this.transformers_) {
1897
- readable = readable.pipeThrough(new TransformStream(transformer));
1898
- }
1899
- readable.pipeTo(writeable).then(async () => {
1900
- console.log("[Pipeline] Setup.");
1901
- await writeable.abort();
1902
- await orgReader.cancel();
1903
- this.emit("pipelineInfo", { message: "pipeline_ended" });
1904
- }).catch(async (e) => {
1905
- readable.cancel().then(() => {
663
+ let o = r;
664
+ for (let i of this.transformers_)
665
+ r = r.pipeThrough(new TransformStream(i));
666
+ r.pipeTo(s).then(async () => {
667
+ console.log("[Pipeline] Setup."), await s.abort(), await o.cancel(), this.emit("pipelineInfo", "pipeline_ended");
668
+ }).catch(async (i) => {
669
+ r.cancel().then(() => {
1906
670
  console.log("[Pipeline] Shutting down streams after abort.");
1907
- }).catch((e2) => {
1908
- console.error("[Pipeline] Error from stream transform:", e2);
1909
- });
1910
- await writeable.abort(e);
1911
- await orgReader.cancel(e);
1912
- this.emit("pipelineInfo", { message: "pipeline_ended_with_error" });
671
+ }).catch((n) => {
672
+ console.error("[Pipeline] Error from stream transform:", n);
673
+ }), await s.abort(i), await o.cancel(i), this.emit("pipelineInfo", "pipeline_ended_with_error");
1913
674
  });
1914
- } catch (e) {
1915
- this.emit("pipelineInfo", { message: "pipeline_started_with_error" });
1916
- this.destroy();
675
+ } catch {
676
+ this.emit("pipelineInfo", "pipeline_started_with_error"), this.destroy();
1917
677
  return;
1918
678
  }
1919
- this.emit("pipelineInfo", { message: "pipeline_started" });
1920
- console.log("[Pipeline] Pipeline started.");
679
+ this.emit("pipelineInfo", "pipeline_started"), console.log("[Pipeline] Pipeline started.");
1921
680
  }
1922
681
  async destroy() {
1923
682
  console.log("[Pipeline] Destroying Pipeline.");
1924
- for (let transformer of this.transformers_) {
1925
- transformer.stop();
1926
- }
683
+ for (let r of this.transformers_)
684
+ r.stop();
1927
685
  }
1928
686
  }
1929
- class MediaProcessor extends emittery {
687
+ class Ce extends L {
1930
688
  constructor() {
1931
689
  super();
1932
- this.uuid_ = v4();
1933
- this.trackExpectedRate_ = -1;
1934
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).variation("Create").build();
1935
- Reporter.report(report);
690
+ a(this, "reporter_");
691
+ a(this, "pipeline_");
692
+ a(this, "transformers_");
693
+ a(this, "readable_");
694
+ a(this, "writable_");
695
+ a(this, "trackExpectedRate_");
696
+ this.reporter_ = new W(), this.trackExpectedRate_ = -1, this.report({
697
+ variation: "Create"
698
+ });
1936
699
  }
1937
- setTrackExpectedRate(trackExpectedRate) {
1938
- this.trackExpectedRate_ = trackExpectedRate;
1939
- if (this.pipeline_) {
1940
- this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
1941
- }
700
+ setTrackExpectedRate(r) {
701
+ this.trackExpectedRate_ = r, this.pipeline_ && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
1942
702
  }
1943
- transform(readable, writable) {
1944
- this.readable_ = readable;
1945
- this.writable_ = writable;
1946
- return this.transformInternal();
703
+ transform(r, s) {
704
+ return this.readable_ = r, this.writable_ = s, this.transformInternal();
1947
705
  }
1948
706
  transformInternal() {
1949
- return new Promise((resolve, reject) => {
707
+ return new Promise(async (r, s) => {
1950
708
  if (!this.transformers_ || this.transformers_.length === 0) {
1951
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.errors["transformer_none"]).variation("Error").build();
1952
- Reporter.report(report);
1953
- reject("[MediaProcessor] Need to set transformers.");
709
+ this.report({
710
+ message: l.errors.transformer_none,
711
+ variation: "Error"
712
+ }), s("[MediaProcessor] Need to set transformers.");
1954
713
  return;
1955
714
  }
1956
715
  if (!this.readable_) {
1957
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.errors["readable_null"]).variation("Error").build();
1958
- Reporter.report(report);
1959
- reject("[MediaProcessor] Readable is null.");
716
+ this.report({
717
+ variation: "Error",
718
+ message: l.errors.readable_null
719
+ }), s("[MediaProcessor] Readable is null.");
1960
720
  return;
1961
721
  }
1962
722
  if (!this.writable_) {
1963
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.errors["writable_null"]).variation("Error").build();
1964
- Reporter.report(report);
1965
- reject("[MediaProcessor] Writable is null.");
723
+ this.report({
724
+ variation: "Error",
725
+ message: l.errors.writable_null
726
+ }), s("[MediaProcessor] Writable is null.");
1966
727
  return;
1967
728
  }
1968
- let isPipelineReset = false;
1969
- if (this.pipeline_) {
1970
- isPipelineReset = true;
1971
- this.pipeline_.clearListeners();
1972
- this.pipeline_.destroy();
1973
- }
1974
- this.pipeline_ = new Pipeline(this.transformers_);
1975
- this.pipeline_.on("warn", (eventData) => {
1976
- this.emit("warn", eventData);
1977
- });
1978
- this.pipeline_.on("error", (eventData) => {
1979
- this.emit("error", eventData);
1980
- });
1981
- this.pipeline_.on("pipelineInfo", (eventData) => {
1982
- if (isPipelineReset) {
1983
- if (eventData.message === "pipeline_started") {
1984
- eventData.message = "pipeline_restarted";
1985
- } else if (eventData.message === "pipeline_started_with_error") {
1986
- eventData.message = "pipeline_restarted_with_error";
1987
- }
1988
- }
1989
- this.emit("pipelineInfo", eventData);
1990
- });
1991
- if (this.trackExpectedRate_ != -1) {
1992
- this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
1993
- }
1994
- this.pipeline_.start(this.readable_, this.writable_).then(() => {
1995
- resolve();
1996
- }).catch((e) => {
1997
- reject(e);
729
+ let o = !1;
730
+ this.pipeline_ && (o = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new Pe(this.transformers_), this.pipeline_.on("warn", (i) => {
731
+ this.emit("warn", i);
732
+ }), this.pipeline_.on("error", (i) => {
733
+ this.emit("error", i);
734
+ }), this.pipeline_.on("pipelineInfo", (i) => {
735
+ o && (i === "pipeline_started" ? i = F.pipeline_restarted : i === "pipeline_started_with_error" && (i = F.pipeline_restarted_with_error)), this.emit("pipelineInfo", i);
736
+ }), this.trackExpectedRate_ != -1 && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_), this.pipeline_.start(this.readable_, this.writable_).then(() => {
737
+ r();
738
+ }).catch((i) => {
739
+ s(i);
1998
740
  });
1999
741
  });
2000
742
  }
2001
- setTransformers(transformers) {
2002
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).message(Key.updates["transformer_new"]).variation("Update").build();
2003
- Reporter.report(report);
2004
- this.transformers_ = transformers;
2005
- if (this.readable_ && this.writable_) {
2006
- return this.transformInternal();
2007
- }
2008
- return Promise.resolve();
743
+ setTransformers(r) {
744
+ return this.report({
745
+ variation: "Update",
746
+ message: l.updates.transformer_new
747
+ }), this.transformers_ = r, this.readable_ && this.writable_ ? this.transformInternal() : Promise.resolve();
2009
748
  }
2010
749
  destroy() {
2011
- return new Promise((resolve) => {
2012
- if (this.pipeline_) {
2013
- this.pipeline_.destroy();
2014
- }
2015
- const report = new ReportBuilder().action("MediaProcessor").guid(this.uuid_).variation("Delete").build();
2016
- Reporter.report(report);
2017
- resolve();
750
+ return new Promise(async (r) => {
751
+ this.pipeline_ && this.pipeline_.destroy(), this.report({ variation: "Delete" }), r();
752
+ });
753
+ }
754
+ report(r) {
755
+ this.reporter_.send({
756
+ version: R,
757
+ action: "MediaProcessor",
758
+ ...r
2018
759
  });
2019
760
  }
2020
761
  }
2021
- class InsertableStreamHelper {
762
+ class Me {
2022
763
  constructor() {
2023
- this.processor_ = null;
2024
- this.generator_ = null;
764
+ a(this, "processor_");
765
+ a(this, "generator_");
766
+ this.processor_ = null, this.generator_ = null;
2025
767
  }
2026
- init(track) {
2027
- return new Promise((resolve, reject) => {
768
+ init(e) {
769
+ return new Promise((r, s) => {
2028
770
  try {
2029
- this.processor_ = new MediaStreamTrackProcessor(track);
2030
- } catch (e) {
2031
- console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${e}`);
2032
- reject(e);
771
+ this.processor_ = new MediaStreamTrackProcessor(e);
772
+ } catch (o) {
773
+ console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${o}`), s(o);
2033
774
  }
2034
775
  try {
2035
- if (track.kind === "audio") {
2036
- this.generator_ = new MediaStreamTrackGenerator({ kind: "audio" });
2037
- } else if (track.kind === "video") {
2038
- this.generator_ = new MediaStreamTrackGenerator({ kind: "video" });
2039
- } else {
2040
- reject("kind not supported");
2041
- }
2042
- } catch (e) {
2043
- console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${e}`);
2044
- reject(e);
776
+ e.kind === "audio" ? this.generator_ = new MediaStreamTrackGenerator({ kind: "audio" }) : e.kind === "video" ? this.generator_ = new MediaStreamTrackGenerator({ kind: "video" }) : s("kind not supported");
777
+ } catch (o) {
778
+ console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${o}`), s(o);
2045
779
  }
2046
- resolve();
780
+ r();
2047
781
  });
2048
782
  }
2049
783
  getReadable() {
@@ -2056,36 +790,43 @@ class InsertableStreamHelper {
2056
790
  return this.generator_;
2057
791
  }
2058
792
  }
2059
- class MediaProcessorConnector {
2060
- constructor(vonageMediaProcessor) {
2061
- this.insertableStreamHelper_ = new InsertableStreamHelper();
2062
- this.mediaProcessor_ = vonageMediaProcessor;
793
+ class Oe {
794
+ constructor(e) {
795
+ a(this, "insertableStreamHelper_");
796
+ a(this, "mediaProcessor_");
797
+ this.insertableStreamHelper_ = new Me(), this.mediaProcessor_ = e;
2063
798
  }
2064
- setTrack(track) {
2065
- return new Promise((resolve, reject) => {
2066
- this.insertableStreamHelper_.init(track).then(() => {
799
+ setTrack(e) {
800
+ return new Promise((r, s) => {
801
+ this.insertableStreamHelper_.init(e).then(() => {
2067
802
  this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(), this.insertableStreamHelper_.getWriteable()).then(() => {
2068
- resolve(this.insertableStreamHelper_.getProccesorTrack());
2069
- }).catch((e) => {
2070
- reject(e);
803
+ r(this.insertableStreamHelper_.getProccesorTrack());
804
+ }).catch((o) => {
805
+ s(o);
2071
806
  });
2072
- }).catch((e) => {
2073
- reject(e);
807
+ }).catch((o) => {
808
+ s(o);
2074
809
  });
2075
810
  });
2076
811
  }
2077
812
  destroy() {
2078
- return new Promise((resolve, reject) => {
2079
- if (this.mediaProcessor_) {
2080
- this.mediaProcessor_.destroy().then(() => {
2081
- resolve();
2082
- }).catch((e) => {
2083
- reject(e);
2084
- });
2085
- } else {
2086
- reject("no processor");
2087
- }
813
+ return new Promise((e, r) => {
814
+ this.mediaProcessor_ ? this.mediaProcessor_.destroy().then(() => {
815
+ e();
816
+ }).catch((s) => {
817
+ r(s);
818
+ }) : r("no processor");
2088
819
  });
2089
820
  }
2090
821
  }
2091
- export { MediaProcessor, MediaProcessorConnector, getVonageMetadata, isSupported, setVonageMetadata };
822
+ export {
823
+ Ee as ErrorFunction,
824
+ Ce as MediaProcessor,
825
+ Oe as MediaProcessorConnector,
826
+ F as PipelineInfoData,
827
+ N as VonageSourceType,
828
+ Se as WarningType,
829
+ C as getVonageMetadata,
830
+ Ie as isSupported,
831
+ ve as setVonageMetadata
832
+ };