@vonage/media-processor 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/enums/VonageSourceType.html +3 -5
- package/dist/docs/index.html +1 -1
- package/dist/docs/modules.html +4 -4
- package/dist/media-processor.es.js +690 -2004
- package/dist/media-processor.min.js +1 -0
- package/dist/media-processor.static.js +838 -0
- package/dist/media-processor.umd.js +2 -3
- package/dist/types/lib/main.d.ts +10 -0
- package/dist/types/{src → lib/src}/core/InsertableStreamHelper.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessor.d.ts +3 -1
- package/dist/types/{src → lib/src}/core/MediaProcessorConnector.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessorConnectorInterface.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/MediaProcessorInterface.d.ts +0 -0
- package/dist/types/{src → lib/src}/core/pipeline.d.ts +4 -5
- package/dist/types/{src → lib/src}/telemetry/Key.d.ts +0 -0
- package/dist/types/lib/src/telemetry/QosReporter.d.ts +22 -0
- package/dist/types/{src → lib/src}/utils/Tools.d.ts +0 -0
- package/dist/types/{src → lib/src}/utils/package-json.d.ts +0 -0
- package/dist/types/{src → lib/src}/utils/utils.d.ts +0 -0
- package/package.json +72 -62
- package/dist/types/main.d.ts +0 -11
- package/dist/types/src/telemetry/Reporter.d.ts +0 -97
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var Y = (t, e, r) => e in t ? V(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var a = (t, e, r) => (Y(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
function ve() {
|
|
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();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
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"
|
|
21
|
+
});
|
|
22
|
+
const h = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), O = Symbol("anyProducer"), U = Promise.resolve(), k = Symbol("listenerAdded"), P = Symbol("listenerRemoved");
|
|
23
|
+
let x = !1;
|
|
24
|
+
function _(t) {
|
|
25
|
+
if (typeof t != "string" && typeof t != "symbol")
|
|
26
|
+
throw new TypeError("eventName must be a string or a symbol");
|
|
27
|
+
}
|
|
28
|
+
function T(t) {
|
|
29
|
+
if (typeof t != "function")
|
|
30
|
+
throw new TypeError("listener must be a function");
|
|
31
|
+
}
|
|
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 q(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 $(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();
|
|
58
|
+
},
|
|
59
|
+
finish() {
|
|
60
|
+
r = !0, s();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
for (const n of e)
|
|
64
|
+
b(t, n).add(i);
|
|
65
|
+
return {
|
|
66
|
+
async next() {
|
|
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 };
|
|
73
|
+
},
|
|
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 };
|
|
79
|
+
},
|
|
80
|
+
[Symbol.asyncIterator]() {
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function H(t) {
|
|
86
|
+
if (t === void 0)
|
|
87
|
+
return Q;
|
|
88
|
+
if (!Array.isArray(t))
|
|
89
|
+
throw new TypeError("`methodNames` must be an array of strings");
|
|
90
|
+
for (const e of t)
|
|
91
|
+
if (!Q.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 === P;
|
|
96
|
+
class m {
|
|
97
|
+
static mixin(e, r) {
|
|
98
|
+
return r = H(r), (s) => {
|
|
99
|
+
if (typeof s != "function")
|
|
100
|
+
throw new TypeError("`target` must be function");
|
|
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
|
|
113
|
+
});
|
|
114
|
+
const i = (n) => function(...c) {
|
|
115
|
+
return this[e][n](...c);
|
|
116
|
+
};
|
|
117
|
+
for (const n of r)
|
|
118
|
+
Object.defineProperty(s.prototype, n, {
|
|
119
|
+
enumerable: !1,
|
|
120
|
+
value: i(n)
|
|
121
|
+
});
|
|
122
|
+
return s;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
static get isDebugEnabled() {
|
|
126
|
+
if (typeof process != "object")
|
|
127
|
+
return x;
|
|
128
|
+
const { env: e } = process || { env: {} };
|
|
129
|
+
return e.DEBUG === "emittery" || e.DEBUG === "*" || x;
|
|
130
|
+
}
|
|
131
|
+
static set isDebugEnabled(e) {
|
|
132
|
+
x = e;
|
|
133
|
+
}
|
|
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
|
+
});
|
|
146
|
+
}
|
|
147
|
+
logIfDebugEnabled(e, r, s) {
|
|
148
|
+
(m.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, r, s);
|
|
149
|
+
}
|
|
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);
|
|
155
|
+
}
|
|
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(P, { eventName: s, listener: r });
|
|
160
|
+
}
|
|
161
|
+
once(e) {
|
|
162
|
+
return new Promise((r) => {
|
|
163
|
+
const s = this.on(e, (o) => {
|
|
164
|
+
s(), r(o);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
events(e) {
|
|
169
|
+
e = Array.isArray(e) ? e : [e];
|
|
170
|
+
for (const r of e)
|
|
171
|
+
_(r);
|
|
172
|
+
return $(this, e);
|
|
173
|
+
}
|
|
174
|
+
async emit(e, r) {
|
|
175
|
+
_(e), this.logIfDebugEnabled("emit", e, r), q(this, e, r);
|
|
176
|
+
const s = g(this, e), o = h.get(this), i = [...s], n = I(e) ? [] : [...o];
|
|
177
|
+
await U, await Promise.all([
|
|
178
|
+
...i.map(async (c) => {
|
|
179
|
+
if (s.has(c))
|
|
180
|
+
return c(r);
|
|
181
|
+
}),
|
|
182
|
+
...n.map(async (c) => {
|
|
183
|
+
if (o.has(c))
|
|
184
|
+
return c(e, r);
|
|
185
|
+
})
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
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 U;
|
|
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);
|
|
196
|
+
}
|
|
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);
|
|
199
|
+
}
|
|
200
|
+
anyEvent() {
|
|
201
|
+
return $(this);
|
|
202
|
+
}
|
|
203
|
+
offAny(e) {
|
|
204
|
+
T(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), this.emit(P, { 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();
|
|
215
|
+
} else {
|
|
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();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
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;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
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;
|
|
239
|
+
}
|
|
240
|
+
return r;
|
|
241
|
+
}
|
|
242
|
+
bindMethods(e, r) {
|
|
243
|
+
if (typeof e != "object" || e === null)
|
|
244
|
+
throw new TypeError("`target` must be an object");
|
|
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)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const Q = 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
|
|
262
|
+
});
|
|
263
|
+
Object.defineProperty(m, "listenerRemoved", {
|
|
264
|
+
value: P,
|
|
265
|
+
writable: !1,
|
|
266
|
+
enumerable: !0,
|
|
267
|
+
configurable: !1
|
|
268
|
+
});
|
|
269
|
+
var L = m;
|
|
270
|
+
function J(t) {
|
|
271
|
+
return typeof t == "object" && t !== null && "message" in t && typeof t.message == "string";
|
|
272
|
+
}
|
|
273
|
+
function X(t) {
|
|
274
|
+
if (J(t))
|
|
275
|
+
return t;
|
|
276
|
+
try {
|
|
277
|
+
return new Error(JSON.stringify(t));
|
|
278
|
+
} catch {
|
|
279
|
+
return new Error(String(t));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function v(t) {
|
|
283
|
+
return X(t).message;
|
|
284
|
+
}
|
|
285
|
+
var Z = Object.defineProperty, K = (t, e, r) => e in t ? Z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, N = (t, e, r) => (K(t, typeof e != "symbol" ? e + "" : e, r), r), ee = /* @__PURE__ */ ((t) => (t.automation = "automation", t.test = "test", t.vbc = "vbc", t.video = "video", t.voice = "voice", t))(ee || {});
|
|
286
|
+
const re = "hlg.tokbox.com/prod/logging/vcp_webrtc", te = "https://", se = 1e4;
|
|
287
|
+
let S;
|
|
288
|
+
const oe = new Uint8Array(16);
|
|
289
|
+
function ie() {
|
|
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(oe);
|
|
293
|
+
}
|
|
294
|
+
const f = [];
|
|
295
|
+
for (let t = 0; t < 256; ++t)
|
|
296
|
+
f.push((t + 256).toString(16).slice(1));
|
|
297
|
+
function ne(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 ae = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), G = {
|
|
301
|
+
randomUUID: ae
|
|
302
|
+
};
|
|
303
|
+
function ce(t, e, r) {
|
|
304
|
+
if (G.randomUUID && !e && !t)
|
|
305
|
+
return G.randomUUID();
|
|
306
|
+
t = t || {};
|
|
307
|
+
const s = t.random || (t.rng || ie)();
|
|
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 ne(s);
|
|
315
|
+
}
|
|
316
|
+
function W(t, e) {
|
|
317
|
+
return globalThis[t] || (globalThis[t] = e), globalThis[t];
|
|
318
|
+
}
|
|
319
|
+
const p = W(
|
|
320
|
+
"globals",
|
|
321
|
+
{}
|
|
322
|
+
);
|
|
323
|
+
var d = /* @__PURE__ */ ((t) => (t.INIT = "INIT", t.FORWARD = "FORWARD", t.TERMINATE = "TERMINATE", t.GLOBALS_SYNC = "GLOBALS_SYNC", t))(d || {});
|
|
324
|
+
function z(t) {
|
|
325
|
+
return [ImageBitmap, ReadableStream, WritableStream].some((e) => t instanceof e);
|
|
326
|
+
}
|
|
327
|
+
let fe = 0;
|
|
328
|
+
function le(t, e, r, s, o) {
|
|
329
|
+
const i = fe++;
|
|
330
|
+
return t.postMessage(
|
|
331
|
+
{
|
|
332
|
+
id: i,
|
|
333
|
+
type: e,
|
|
334
|
+
functionName: r,
|
|
335
|
+
args: s
|
|
336
|
+
},
|
|
337
|
+
s.filter((n) => z(n))
|
|
338
|
+
), new Promise((n) => {
|
|
339
|
+
o == null || o.set(i, n);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function w(t, e) {
|
|
343
|
+
const { id: r, type: s } = t, o = Array.isArray(e) ? e : [e];
|
|
344
|
+
postMessage(
|
|
345
|
+
{
|
|
346
|
+
id: r,
|
|
347
|
+
type: s,
|
|
348
|
+
result: e
|
|
349
|
+
},
|
|
350
|
+
o.filter((i) => z(i))
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const j = W("workerized", {});
|
|
354
|
+
function B() {
|
|
355
|
+
return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
|
|
356
|
+
}
|
|
357
|
+
async function ue() {
|
|
358
|
+
if (B())
|
|
359
|
+
w({ type: d.GLOBALS_SYNC }, p);
|
|
360
|
+
else {
|
|
361
|
+
const t = [];
|
|
362
|
+
for (const e in j) {
|
|
363
|
+
const { worker: r, resolvers: s } = j[e].workerContext;
|
|
364
|
+
r && t.push(
|
|
365
|
+
le(
|
|
366
|
+
r,
|
|
367
|
+
d.GLOBALS_SYNC,
|
|
368
|
+
"",
|
|
369
|
+
[p],
|
|
370
|
+
s
|
|
371
|
+
)
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
await Promise.all(t);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function A(t, e) {
|
|
378
|
+
if (Array.isArray(e))
|
|
379
|
+
e.splice(0, e.length);
|
|
380
|
+
else if (typeof e == "object")
|
|
381
|
+
for (const r in e)
|
|
382
|
+
delete e[r];
|
|
383
|
+
for (const r in t)
|
|
384
|
+
Array.isArray(t[r]) ? (e[r] = [], A(t[r], e[r])) : typeof t[r] == "object" ? (e[r] = {}, A(t[r], e[r])) : e[r] = t[r];
|
|
385
|
+
}
|
|
386
|
+
async function he(t, e) {
|
|
387
|
+
const { functionName: r, args: s } = t;
|
|
388
|
+
if (!e.instance)
|
|
389
|
+
throw "instance not initialized";
|
|
390
|
+
if (!r)
|
|
391
|
+
throw "missing function name to call";
|
|
392
|
+
if (!e.instance[r])
|
|
393
|
+
throw `undefined function [${r}] in class ${e.instance.constructor.workerId}`;
|
|
394
|
+
w(t, await e.instance[r](...s != null ? s : []));
|
|
395
|
+
}
|
|
396
|
+
const pe = W("registeredWorkers", {});
|
|
397
|
+
function de(t, e) {
|
|
398
|
+
if (!t.args)
|
|
399
|
+
throw "Missing className while initializing worker";
|
|
400
|
+
const [r, s] = t.args, o = pe[r];
|
|
401
|
+
if (o)
|
|
402
|
+
e.instance = new o(t.args.slice(1));
|
|
403
|
+
else
|
|
404
|
+
throw `unknown worker class ${r}`;
|
|
405
|
+
A(s, p), w(t, typeof e.instance !== void 0);
|
|
406
|
+
}
|
|
407
|
+
async function me(t, e) {
|
|
408
|
+
const { args: r } = t;
|
|
409
|
+
if (!e.instance)
|
|
410
|
+
throw "instance not initialized";
|
|
411
|
+
let s;
|
|
412
|
+
e.instance.terminate && (s = await e.instance.terminate(...r != null ? r : [])), w(t, s);
|
|
413
|
+
}
|
|
414
|
+
function _e(t) {
|
|
415
|
+
if (!t.args)
|
|
416
|
+
throw "Missing globals while syncing";
|
|
417
|
+
A(t.args[0], p), w(t, {});
|
|
418
|
+
}
|
|
419
|
+
function ge() {
|
|
420
|
+
const t = {};
|
|
421
|
+
onmessage = async (e) => {
|
|
422
|
+
const r = e.data;
|
|
423
|
+
switch (r.type) {
|
|
424
|
+
case d.INIT:
|
|
425
|
+
de(r, t);
|
|
426
|
+
break;
|
|
427
|
+
case d.FORWARD:
|
|
428
|
+
he(r, t);
|
|
429
|
+
break;
|
|
430
|
+
case d.TERMINATE:
|
|
431
|
+
me(r, t);
|
|
432
|
+
break;
|
|
433
|
+
case d.GLOBALS_SYNC:
|
|
434
|
+
_e(r);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
B() && ge();
|
|
440
|
+
function ye(t, e) {
|
|
441
|
+
return p[t] || (p[t] = e), [
|
|
442
|
+
() => p[t],
|
|
443
|
+
async (r) => {
|
|
444
|
+
p[t] = r, await ue();
|
|
445
|
+
}
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
function be(t, e) {
|
|
449
|
+
return ye(t, e);
|
|
450
|
+
}
|
|
451
|
+
const [we, Te] = be("metadata");
|
|
452
|
+
function Ce(t) {
|
|
453
|
+
Te(t);
|
|
454
|
+
}
|
|
455
|
+
function C() {
|
|
456
|
+
return we();
|
|
457
|
+
}
|
|
458
|
+
class D {
|
|
459
|
+
constructor(e) {
|
|
460
|
+
N(this, "uuid", ce()), this.config = e;
|
|
461
|
+
}
|
|
462
|
+
async send(e) {
|
|
463
|
+
var r, s, o;
|
|
464
|
+
const { appId: i, sourceType: n } = (r = C()) != null ? r : {};
|
|
465
|
+
if (!i || !n)
|
|
466
|
+
return "metadata missing";
|
|
467
|
+
const c = new AbortController(), u = setTimeout(() => c.abort(), se);
|
|
468
|
+
return await ((o = (s = this.config) == null ? void 0 : s.fetch) != null ? o : fetch)(this.getUrl(), {
|
|
469
|
+
method: "POST",
|
|
470
|
+
headers: this.getHeaders(),
|
|
471
|
+
body: JSON.stringify(this.buildReport(e)),
|
|
472
|
+
signal: c.signal
|
|
473
|
+
}), clearTimeout(u), "success";
|
|
474
|
+
}
|
|
475
|
+
getUrl() {
|
|
476
|
+
var e;
|
|
477
|
+
let r = (e = C().proxyUrl) != null ? e : te;
|
|
478
|
+
return r += (r.at(-1) === "/" ? "" : "/") + re, r;
|
|
479
|
+
}
|
|
480
|
+
getHeaders() {
|
|
481
|
+
return {
|
|
482
|
+
"Content-Type": "application/json"
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
buildReport(e) {
|
|
486
|
+
const r = C();
|
|
487
|
+
return {
|
|
488
|
+
guid: this.uuid,
|
|
489
|
+
...e,
|
|
490
|
+
applicationId: r.appId,
|
|
491
|
+
timestamp: Date.now(),
|
|
492
|
+
proxyUrl: r.proxyUrl,
|
|
493
|
+
source: r.sourceType
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const R = "2.0.2";
|
|
498
|
+
class Se {
|
|
499
|
+
constructor(e) {
|
|
500
|
+
a(this, "frameTransformedCount", 0);
|
|
501
|
+
a(this, "frameFromSourceCount", 0);
|
|
502
|
+
a(this, "startAt", 0);
|
|
503
|
+
a(this, "reporter");
|
|
504
|
+
this.config = e, this.reporter = new D(e);
|
|
505
|
+
}
|
|
506
|
+
async onFrameFromSource() {
|
|
507
|
+
this.frameFromSourceCount++;
|
|
508
|
+
}
|
|
509
|
+
get fps() {
|
|
510
|
+
const { startAt: e, frameFromSourceCount: r } = this, o = (Date.now() - e) / 1e3;
|
|
511
|
+
return r / o;
|
|
512
|
+
}
|
|
513
|
+
async onFrameTransformed(e = {}, r = !1) {
|
|
514
|
+
this.startAt === 0 && (this.startAt = Date.now()), this.frameTransformedCount++;
|
|
515
|
+
const { startAt: s, frameTransformedCount: o, frameFromSourceCount: i } = this, n = Date.now(), c = (n - s) / 1e3, u = o / c, M = i / c;
|
|
516
|
+
return r || this.frameTransformedCount >= this.config.loggingIntervalFrameCount ? (this.frameFromSourceCount = 0, this.frameTransformedCount = 0, this.startAt = n, this.reporter.config = this.config, this.reporter.send({
|
|
517
|
+
...this.config.report,
|
|
518
|
+
variation: "QoS",
|
|
519
|
+
fps: M,
|
|
520
|
+
transformedFps: u,
|
|
521
|
+
framesTransformed: o,
|
|
522
|
+
...e
|
|
523
|
+
})) : "success";
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
var Ee = /* @__PURE__ */ ((t) => (t.FPS_DROP = "fps_drop", t))(Ee || {}), Re = /* @__PURE__ */ ((t) => (t.start = "start", t.transform = "transform", t.flush = "flush", t))(Re || {}), 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 || {});
|
|
527
|
+
const ke = 500, Pe = 0.8;
|
|
528
|
+
class Ae extends L {
|
|
529
|
+
constructor(r, s) {
|
|
530
|
+
super();
|
|
531
|
+
a(this, "reporter_", new D());
|
|
532
|
+
a(this, "reporterQos_", new Se({
|
|
533
|
+
loggingIntervalFrameCount: ke,
|
|
534
|
+
report: {
|
|
535
|
+
version: R
|
|
536
|
+
}
|
|
537
|
+
}));
|
|
538
|
+
a(this, "transformerType_");
|
|
539
|
+
a(this, "transformer_");
|
|
540
|
+
a(this, "shouldStop_");
|
|
541
|
+
a(this, "isFlashed_");
|
|
542
|
+
a(this, "mediaTransformerQosReportStartTimestamp_");
|
|
543
|
+
a(this, "videoHeight_");
|
|
544
|
+
a(this, "videoWidth_");
|
|
545
|
+
a(this, "trackExpectedRate_");
|
|
546
|
+
a(this, "index_");
|
|
547
|
+
a(this, "controller_");
|
|
548
|
+
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({
|
|
549
|
+
variation: "Create"
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
setTrackExpectedRate(r) {
|
|
553
|
+
this.trackExpectedRate_ = r;
|
|
554
|
+
}
|
|
555
|
+
async start(r) {
|
|
556
|
+
if (this.controller_ = r, this.transformer_ && typeof this.transformer_.start == "function")
|
|
557
|
+
try {
|
|
558
|
+
await this.transformer_.start(r);
|
|
559
|
+
} catch (s) {
|
|
560
|
+
this.report({
|
|
561
|
+
message: l.errors.transformer_start,
|
|
562
|
+
variation: "Error",
|
|
563
|
+
error: v(s)
|
|
564
|
+
});
|
|
565
|
+
const o = { eventMetaData: { transformerIndex: this.index_ }, error: s, function: "start" };
|
|
566
|
+
this.emit("error", o);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
async transform(r, s) {
|
|
570
|
+
var o, i, n, c;
|
|
571
|
+
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_)
|
|
572
|
+
if (this.shouldStop_)
|
|
573
|
+
console.warn("[Pipeline] flush from transform"), r.close(), this.flush(s), s.terminate();
|
|
574
|
+
else {
|
|
575
|
+
try {
|
|
576
|
+
await ((c = (n = this.transformer_).transform) == null ? void 0 : c.call(n, r, s)), this.reportQos();
|
|
577
|
+
} catch (u) {
|
|
578
|
+
this.report({
|
|
579
|
+
message: l.errors.transformer_transform,
|
|
580
|
+
variation: "Error",
|
|
581
|
+
error: v(u)
|
|
582
|
+
});
|
|
583
|
+
const M = { eventMetaData: { transformerIndex: this.index_ }, error: u, function: "transform" };
|
|
584
|
+
this.emit("error", M);
|
|
585
|
+
}
|
|
586
|
+
if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * Pe > this.reporterQos_.fps) {
|
|
587
|
+
const u = {
|
|
588
|
+
eventMetaData: {
|
|
589
|
+
transformerIndex: this.index_
|
|
590
|
+
},
|
|
591
|
+
warningType: "fps_drop",
|
|
592
|
+
dropInfo: {
|
|
593
|
+
requested: this.trackExpectedRate_,
|
|
594
|
+
current: this.reporterQos_.fps
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
this.emit("warn", u);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async flush(r) {
|
|
602
|
+
if (this.transformer_ && typeof this.transformer_.flush == "function" && !this.isFlashed_) {
|
|
603
|
+
this.isFlashed_ = !0;
|
|
604
|
+
try {
|
|
605
|
+
await this.transformer_.flush(r);
|
|
606
|
+
} catch (s) {
|
|
607
|
+
this.report({
|
|
608
|
+
message: l.errors.transformer_flush,
|
|
609
|
+
variation: "Error",
|
|
610
|
+
error: v(s)
|
|
611
|
+
});
|
|
612
|
+
const o = { eventMetaData: { transformerIndex: this.index_ }, error: s, function: "flush" };
|
|
613
|
+
this.emit("error", o);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
this.reportQos(!0), this.report({
|
|
617
|
+
variation: "Delete"
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
stop() {
|
|
621
|
+
console.log("[Pipeline] Stop stream."), this.controller_ && (this.flush(this.controller_), this.controller_.terminate()), this.shouldStop_ = !0;
|
|
622
|
+
}
|
|
623
|
+
report(r) {
|
|
624
|
+
this.reporter_.send({
|
|
625
|
+
version: R,
|
|
626
|
+
action: "MediaTransformer",
|
|
627
|
+
transformerType: this.transformerType_,
|
|
628
|
+
...r
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
reportQos(r = !1) {
|
|
632
|
+
this.reporterQos_.config = {
|
|
633
|
+
...this.reporterQos_.config
|
|
634
|
+
}, this.reporterQos_.onFrameTransformed({
|
|
635
|
+
version: R,
|
|
636
|
+
action: "MediaTransformer",
|
|
637
|
+
transformerType: this.transformerType_,
|
|
638
|
+
videoWidth: this.videoWidth_,
|
|
639
|
+
videoHeight: this.videoHeight_
|
|
640
|
+
}, r);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
class Me extends L {
|
|
644
|
+
constructor(r) {
|
|
645
|
+
super();
|
|
646
|
+
a(this, "transformers_");
|
|
647
|
+
a(this, "trackExpectedRate_");
|
|
648
|
+
this.transformers_ = [], this.trackExpectedRate_ = -1;
|
|
649
|
+
for (let s = 0; s < r.length; s++) {
|
|
650
|
+
let o = new Ae(r[s], s);
|
|
651
|
+
o.on("error", (i) => {
|
|
652
|
+
this.emit("error", i);
|
|
653
|
+
}), o.on("warn", (i) => {
|
|
654
|
+
this.emit("warn", i);
|
|
655
|
+
}), this.transformers_.push(o);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
setTrackExpectedRate(r) {
|
|
659
|
+
this.trackExpectedRate_ = r;
|
|
660
|
+
for (let s of this.transformers_)
|
|
661
|
+
s.setTrackExpectedRate(this.trackExpectedRate_);
|
|
662
|
+
}
|
|
663
|
+
async start(r, s) {
|
|
664
|
+
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
665
|
+
console.log("[Pipeline] No transformers.");
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
try {
|
|
669
|
+
let o = r;
|
|
670
|
+
for (let i of this.transformers_)
|
|
671
|
+
r = r.pipeThrough(new TransformStream(i));
|
|
672
|
+
r.pipeTo(s).then(async () => {
|
|
673
|
+
console.log("[Pipeline] Setup."), await s.abort(), await o.cancel(), this.emit("pipelineInfo", "pipeline_ended");
|
|
674
|
+
}).catch(async (i) => {
|
|
675
|
+
r.cancel().then(() => {
|
|
676
|
+
console.log("[Pipeline] Shutting down streams after abort.");
|
|
677
|
+
}).catch((n) => {
|
|
678
|
+
console.error("[Pipeline] Error from stream transform:", n);
|
|
679
|
+
}), await s.abort(i), await o.cancel(i), this.emit("pipelineInfo", "pipeline_ended_with_error");
|
|
680
|
+
});
|
|
681
|
+
} catch {
|
|
682
|
+
this.emit("pipelineInfo", "pipeline_started_with_error"), this.destroy();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
this.emit("pipelineInfo", "pipeline_started"), console.log("[Pipeline] Pipeline started.");
|
|
686
|
+
}
|
|
687
|
+
async destroy() {
|
|
688
|
+
console.log("[Pipeline] Destroying Pipeline.");
|
|
689
|
+
for (let r of this.transformers_)
|
|
690
|
+
r.stop();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
class Oe extends L {
|
|
694
|
+
constructor() {
|
|
695
|
+
super();
|
|
696
|
+
a(this, "reporter_");
|
|
697
|
+
a(this, "pipeline_");
|
|
698
|
+
a(this, "transformers_");
|
|
699
|
+
a(this, "readable_");
|
|
700
|
+
a(this, "writable_");
|
|
701
|
+
a(this, "trackExpectedRate_");
|
|
702
|
+
this.reporter_ = new D(), this.trackExpectedRate_ = -1, this.report({
|
|
703
|
+
variation: "Create"
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
setTrackExpectedRate(r) {
|
|
707
|
+
this.trackExpectedRate_ = r, this.pipeline_ && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
|
|
708
|
+
}
|
|
709
|
+
transform(r, s) {
|
|
710
|
+
return this.readable_ = r, this.writable_ = s, this.transformInternal();
|
|
711
|
+
}
|
|
712
|
+
transformInternal() {
|
|
713
|
+
return new Promise(async (r, s) => {
|
|
714
|
+
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
715
|
+
this.report({
|
|
716
|
+
message: l.errors.transformer_none,
|
|
717
|
+
variation: "Error"
|
|
718
|
+
}), s("[MediaProcessor] Need to set transformers.");
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (!this.readable_) {
|
|
722
|
+
this.report({
|
|
723
|
+
variation: "Error",
|
|
724
|
+
message: l.errors.readable_null
|
|
725
|
+
}), s("[MediaProcessor] Readable is null.");
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (!this.writable_) {
|
|
729
|
+
this.report({
|
|
730
|
+
variation: "Error",
|
|
731
|
+
message: l.errors.writable_null
|
|
732
|
+
}), s("[MediaProcessor] Writable is null.");
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
let o = !1;
|
|
736
|
+
this.pipeline_ && (o = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new Me(this.transformers_), this.pipeline_.on("warn", (i) => {
|
|
737
|
+
this.emit("warn", i);
|
|
738
|
+
}), this.pipeline_.on("error", (i) => {
|
|
739
|
+
this.emit("error", i);
|
|
740
|
+
}), this.pipeline_.on("pipelineInfo", (i) => {
|
|
741
|
+
o && (i === "pipeline_started" ? i = F.pipeline_restarted : i === "pipeline_started_with_error" && (i = F.pipeline_restarted_with_error)), this.emit("pipelineInfo", i);
|
|
742
|
+
}), this.trackExpectedRate_ != -1 && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_), this.pipeline_.start(this.readable_, this.writable_).then(() => {
|
|
743
|
+
r();
|
|
744
|
+
}).catch((i) => {
|
|
745
|
+
s(i);
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
setTransformers(r) {
|
|
750
|
+
return this.report({
|
|
751
|
+
variation: "Update",
|
|
752
|
+
message: l.updates.transformer_new
|
|
753
|
+
}), this.transformers_ = r, this.readable_ && this.writable_ ? this.transformInternal() : Promise.resolve();
|
|
754
|
+
}
|
|
755
|
+
destroy() {
|
|
756
|
+
return new Promise(async (r) => {
|
|
757
|
+
this.pipeline_ && this.pipeline_.destroy(), this.report({ variation: "Delete" }), r();
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
report(r) {
|
|
761
|
+
this.reporter_.send({
|
|
762
|
+
version: R,
|
|
763
|
+
action: "MediaProcessor",
|
|
764
|
+
...r
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
class xe {
|
|
769
|
+
constructor() {
|
|
770
|
+
a(this, "processor_");
|
|
771
|
+
a(this, "generator_");
|
|
772
|
+
this.processor_ = null, this.generator_ = null;
|
|
773
|
+
}
|
|
774
|
+
init(e) {
|
|
775
|
+
return new Promise((r, s) => {
|
|
776
|
+
try {
|
|
777
|
+
this.processor_ = new MediaStreamTrackProcessor(e);
|
|
778
|
+
} catch (o) {
|
|
779
|
+
console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${o}`), s(o);
|
|
780
|
+
}
|
|
781
|
+
try {
|
|
782
|
+
e.kind === "audio" ? this.generator_ = new MediaStreamTrackGenerator({ kind: "audio" }) : e.kind === "video" ? this.generator_ = new MediaStreamTrackGenerator({ kind: "video" }) : s("kind not supported");
|
|
783
|
+
} catch (o) {
|
|
784
|
+
console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${o}`), s(o);
|
|
785
|
+
}
|
|
786
|
+
r();
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
getReadable() {
|
|
790
|
+
return this.processor_.readable;
|
|
791
|
+
}
|
|
792
|
+
getWriteable() {
|
|
793
|
+
return this.generator_.writable;
|
|
794
|
+
}
|
|
795
|
+
getProccesorTrack() {
|
|
796
|
+
return this.generator_;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
class Fe {
|
|
800
|
+
constructor(e) {
|
|
801
|
+
a(this, "insertableStreamHelper_");
|
|
802
|
+
a(this, "mediaProcessor_");
|
|
803
|
+
this.insertableStreamHelper_ = new xe(), this.mediaProcessor_ = e;
|
|
804
|
+
}
|
|
805
|
+
setTrack(e) {
|
|
806
|
+
return new Promise((r, s) => {
|
|
807
|
+
this.insertableStreamHelper_.init(e).then(() => {
|
|
808
|
+
this.mediaProcessor_.transform(this.insertableStreamHelper_.getReadable(), this.insertableStreamHelper_.getWriteable()).then(() => {
|
|
809
|
+
r(this.insertableStreamHelper_.getProccesorTrack());
|
|
810
|
+
}).catch((o) => {
|
|
811
|
+
s(o);
|
|
812
|
+
});
|
|
813
|
+
}).catch((o) => {
|
|
814
|
+
s(o);
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
destroy() {
|
|
819
|
+
return new Promise((e, r) => {
|
|
820
|
+
this.mediaProcessor_ ? this.mediaProcessor_.destroy().then(() => {
|
|
821
|
+
e();
|
|
822
|
+
}).catch((s) => {
|
|
823
|
+
r(s);
|
|
824
|
+
}) : r("no processor");
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
export {
|
|
829
|
+
Re as ErrorFunction,
|
|
830
|
+
Oe as MediaProcessor,
|
|
831
|
+
Fe as MediaProcessorConnector,
|
|
832
|
+
F as PipelineInfoData,
|
|
833
|
+
ee as VonageSourceType,
|
|
834
|
+
Ee as WarningType,
|
|
835
|
+
C as getVonageMetadata,
|
|
836
|
+
ve as isSupported,
|
|
837
|
+
Ce as setVonageMetadata
|
|
838
|
+
};
|