@vonage/media-processor 2.0.3 → 2.0.4
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/media-processor.es.js +444 -363
- package/dist/media-processor.min.js +1 -1
- package/dist/media-processor.static.js +444 -363
- package/dist/media-processor.umd.js +2 -2
- package/dist/types/lib/src/core/MediaProcessor.d.ts +14 -14
- package/dist/types/lib/src/core/MediaProcessorConnector.d.ts +3 -3
- package/dist/types/lib/src/core/pipeline.d.ts +1 -1
- package/dist/types/lib/src/telemetry/QosReporter.d.ts +1 -1
- package/package.json +11 -8
|
@@ -1,224 +1,227 @@
|
|
|
1
|
-
|
|
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() {
|
|
1
|
+
function Ie() {
|
|
5
2
|
return new Promise((t, e) => {
|
|
6
|
-
typeof MediaStreamTrackProcessor > "u" || typeof MediaStreamTrackGenerator > "u" ? e(
|
|
3
|
+
typeof MediaStreamTrackProcessor > "u" || typeof MediaStreamTrackGenerator > "u" ? e(
|
|
4
|
+
"Your browser does not support the MediaStreamTrack API for Insertable Streams of Media."
|
|
5
|
+
) : t();
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
8
|
class l {
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
l.updates = {
|
|
12
11
|
transformer_new: "New transformer",
|
|
13
12
|
transformer_null: "Null transformer"
|
|
14
|
-
}
|
|
13
|
+
};
|
|
14
|
+
l.errors = {
|
|
15
15
|
transformer_none: "No transformers provided",
|
|
16
16
|
transformer_start: "Cannot start transformer",
|
|
17
17
|
transformer_transform: "Cannot transform frame",
|
|
18
18
|
transformer_flush: "Cannot flush transformer",
|
|
19
19
|
readable_null: "Readable is null",
|
|
20
20
|
writable_null: "Writable is null"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
};
|
|
22
|
+
function j(t) {
|
|
23
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
24
|
+
}
|
|
25
|
+
const f = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), C = Symbol("anyProducer"), U = Promise.resolve(), S = Symbol("listenerAdded"), R = Symbol("listenerRemoved");
|
|
26
|
+
let A = !1;
|
|
27
|
+
function p(t) {
|
|
25
28
|
if (typeof t != "string" && typeof t != "symbol")
|
|
26
29
|
throw new TypeError("eventName must be a string or a symbol");
|
|
27
30
|
}
|
|
28
|
-
function
|
|
31
|
+
function b(t) {
|
|
29
32
|
if (typeof t != "function")
|
|
30
33
|
throw new TypeError("listener must be a function");
|
|
31
34
|
}
|
|
32
|
-
function
|
|
33
|
-
const r =
|
|
35
|
+
function m(t, e) {
|
|
36
|
+
const r = T.get(t);
|
|
34
37
|
return r.has(e) || r.set(e, /* @__PURE__ */ new Set()), r.get(e);
|
|
35
38
|
}
|
|
36
|
-
function
|
|
37
|
-
const r = typeof e == "string" || typeof e == "symbol" ? e :
|
|
39
|
+
function _(t, e) {
|
|
40
|
+
const r = typeof e == "string" || typeof e == "symbol" ? e : C, s = g.get(t);
|
|
38
41
|
return s.has(r) || s.set(r, /* @__PURE__ */ new Set()), s.get(r);
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
const s =
|
|
43
|
+
function B(t, e, r) {
|
|
44
|
+
const s = g.get(t);
|
|
42
45
|
if (s.has(e))
|
|
43
|
-
for (const
|
|
44
|
-
|
|
45
|
-
if (s.has(
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
|
|
46
|
+
for (const i of s.get(e))
|
|
47
|
+
i.enqueue(r);
|
|
48
|
+
if (s.has(C)) {
|
|
49
|
+
const i = Promise.all([e, r]);
|
|
50
|
+
for (const n of s.get(C))
|
|
51
|
+
n.enqueue(i);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
function
|
|
54
|
+
function D(t, e) {
|
|
52
55
|
e = Array.isArray(e) ? e : [e];
|
|
53
56
|
let r = !1, s = () => {
|
|
54
|
-
},
|
|
55
|
-
const
|
|
56
|
-
enqueue(
|
|
57
|
-
|
|
57
|
+
}, i = [];
|
|
58
|
+
const n = {
|
|
59
|
+
enqueue(o) {
|
|
60
|
+
i.push(o), s();
|
|
58
61
|
},
|
|
59
62
|
finish() {
|
|
60
63
|
r = !0, s();
|
|
61
64
|
}
|
|
62
65
|
};
|
|
63
|
-
for (const
|
|
64
|
-
|
|
66
|
+
for (const o of e)
|
|
67
|
+
_(t, o).add(n);
|
|
65
68
|
return {
|
|
66
69
|
async next() {
|
|
67
|
-
return
|
|
68
|
-
s =
|
|
70
|
+
return i ? i.length === 0 ? r ? (i = void 0, this.next()) : (await new Promise((o) => {
|
|
71
|
+
s = o;
|
|
69
72
|
}), this.next()) : {
|
|
70
73
|
done: !1,
|
|
71
|
-
value: await
|
|
74
|
+
value: await i.shift()
|
|
72
75
|
} : { done: !0 };
|
|
73
76
|
},
|
|
74
|
-
async return(
|
|
75
|
-
|
|
76
|
-
for (const
|
|
77
|
-
|
|
78
|
-
return s(), arguments.length > 0 ? { done: !0, value: await
|
|
77
|
+
async return(o) {
|
|
78
|
+
i = void 0;
|
|
79
|
+
for (const a of e)
|
|
80
|
+
_(t, a).delete(n);
|
|
81
|
+
return s(), arguments.length > 0 ? { done: !0, value: await o } : { done: !0 };
|
|
79
82
|
},
|
|
80
83
|
[Symbol.asyncIterator]() {
|
|
81
84
|
return this;
|
|
82
85
|
}
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
|
-
function
|
|
88
|
+
function $(t) {
|
|
86
89
|
if (t === void 0)
|
|
87
|
-
return
|
|
90
|
+
return G;
|
|
88
91
|
if (!Array.isArray(t))
|
|
89
92
|
throw new TypeError("`methodNames` must be an array of strings");
|
|
90
93
|
for (const e of t)
|
|
91
|
-
if (!
|
|
94
|
+
if (!G.includes(e))
|
|
92
95
|
throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
|
|
93
96
|
return t;
|
|
94
97
|
}
|
|
95
|
-
const
|
|
96
|
-
class
|
|
98
|
+
const M = (t) => t === S || t === R;
|
|
99
|
+
class d {
|
|
97
100
|
static mixin(e, r) {
|
|
98
|
-
return r =
|
|
101
|
+
return r = $(r), (s) => {
|
|
99
102
|
if (typeof s != "function")
|
|
100
103
|
throw new TypeError("`target` must be function");
|
|
101
|
-
for (const
|
|
102
|
-
if (s.prototype[
|
|
103
|
-
throw new Error(`The property \`${
|
|
104
|
-
function
|
|
104
|
+
for (const o of r)
|
|
105
|
+
if (s.prototype[o] !== void 0)
|
|
106
|
+
throw new Error(`The property \`${o}\` already exists on \`target\``);
|
|
107
|
+
function i() {
|
|
105
108
|
return Object.defineProperty(this, e, {
|
|
106
109
|
enumerable: !1,
|
|
107
|
-
value: new
|
|
110
|
+
value: new d()
|
|
108
111
|
}), this[e];
|
|
109
112
|
}
|
|
110
113
|
Object.defineProperty(s.prototype, e, {
|
|
111
114
|
enumerable: !1,
|
|
112
|
-
get:
|
|
115
|
+
get: i
|
|
113
116
|
});
|
|
114
|
-
const
|
|
115
|
-
return this[e][
|
|
117
|
+
const n = (o) => function(...a) {
|
|
118
|
+
return this[e][o](...a);
|
|
116
119
|
};
|
|
117
|
-
for (const
|
|
118
|
-
Object.defineProperty(s.prototype,
|
|
120
|
+
for (const o of r)
|
|
121
|
+
Object.defineProperty(s.prototype, o, {
|
|
119
122
|
enumerable: !1,
|
|
120
|
-
value:
|
|
123
|
+
value: n(o)
|
|
121
124
|
});
|
|
122
125
|
return s;
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
static get isDebugEnabled() {
|
|
126
129
|
if (typeof process != "object")
|
|
127
|
-
return
|
|
130
|
+
return A;
|
|
128
131
|
const { env: e } = process || { env: {} };
|
|
129
|
-
return e.DEBUG === "emittery" || e.DEBUG === "*" ||
|
|
132
|
+
return e.DEBUG === "emittery" || e.DEBUG === "*" || A;
|
|
130
133
|
}
|
|
131
134
|
static set isDebugEnabled(e) {
|
|
132
|
-
|
|
135
|
+
A = e;
|
|
133
136
|
}
|
|
134
137
|
constructor(e = {}) {
|
|
135
|
-
|
|
138
|
+
f.set(this, /* @__PURE__ */ new Set()), T.set(this, /* @__PURE__ */ new Map()), g.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, i, n) => {
|
|
136
139
|
try {
|
|
137
|
-
|
|
140
|
+
n = JSON.stringify(n);
|
|
138
141
|
} catch {
|
|
139
|
-
|
|
142
|
+
n = `Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`;
|
|
140
143
|
}
|
|
141
|
-
typeof
|
|
142
|
-
const
|
|
143
|
-
console.log(`[${
|
|
144
|
-
data: ${
|
|
144
|
+
typeof i == "symbol" && (i = i.toString());
|
|
145
|
+
const o = /* @__PURE__ */ new Date(), a = `${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;
|
|
146
|
+
console.log(`[${a}][emittery:${r}][${s}] Event Name: ${i}
|
|
147
|
+
data: ${n}`);
|
|
145
148
|
});
|
|
146
149
|
}
|
|
147
150
|
logIfDebugEnabled(e, r, s) {
|
|
148
|
-
(
|
|
151
|
+
(d.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, r, s);
|
|
149
152
|
}
|
|
150
153
|
on(e, r) {
|
|
151
|
-
|
|
154
|
+
b(r), e = Array.isArray(e) ? e : [e];
|
|
152
155
|
for (const s of e)
|
|
153
|
-
|
|
156
|
+
p(s), m(this, s).add(r), this.logIfDebugEnabled("subscribe", s, void 0), M(s) || this.emit(S, { eventName: s, listener: r });
|
|
154
157
|
return this.off.bind(this, e, r);
|
|
155
158
|
}
|
|
156
159
|
off(e, r) {
|
|
157
|
-
|
|
160
|
+
b(r), e = Array.isArray(e) ? e : [e];
|
|
158
161
|
for (const s of e)
|
|
159
|
-
|
|
162
|
+
p(s), m(this, s).delete(r), this.logIfDebugEnabled("unsubscribe", s, void 0), M(s) || this.emit(R, { eventName: s, listener: r });
|
|
160
163
|
}
|
|
161
164
|
once(e) {
|
|
162
165
|
return new Promise((r) => {
|
|
163
|
-
const s = this.on(e, (
|
|
164
|
-
s(), r(
|
|
166
|
+
const s = this.on(e, (i) => {
|
|
167
|
+
s(), r(i);
|
|
165
168
|
});
|
|
166
169
|
});
|
|
167
170
|
}
|
|
168
171
|
events(e) {
|
|
169
172
|
e = Array.isArray(e) ? e : [e];
|
|
170
173
|
for (const r of e)
|
|
171
|
-
|
|
172
|
-
return
|
|
174
|
+
p(r);
|
|
175
|
+
return D(this, e);
|
|
173
176
|
}
|
|
174
177
|
async emit(e, r) {
|
|
175
|
-
|
|
176
|
-
const s =
|
|
178
|
+
p(e), this.logIfDebugEnabled("emit", e, r), B(this, e, r);
|
|
179
|
+
const s = m(this, e), i = f.get(this), n = [...s], o = M(e) ? [] : [...i];
|
|
177
180
|
await U, await Promise.all([
|
|
178
|
-
...
|
|
179
|
-
if (s.has(
|
|
180
|
-
return
|
|
181
|
+
...n.map(async (a) => {
|
|
182
|
+
if (s.has(a))
|
|
183
|
+
return a(r);
|
|
181
184
|
}),
|
|
182
|
-
...
|
|
183
|
-
if (
|
|
184
|
-
return
|
|
185
|
+
...o.map(async (a) => {
|
|
186
|
+
if (i.has(a))
|
|
187
|
+
return a(e, r);
|
|
185
188
|
})
|
|
186
189
|
]);
|
|
187
190
|
}
|
|
188
191
|
async emitSerial(e, r) {
|
|
189
|
-
|
|
190
|
-
const s =
|
|
192
|
+
p(e), this.logIfDebugEnabled("emitSerial", e, r);
|
|
193
|
+
const s = m(this, e), i = f.get(this), n = [...s], o = [...i];
|
|
191
194
|
await U;
|
|
192
|
-
for (const
|
|
193
|
-
s.has(
|
|
194
|
-
for (const
|
|
195
|
-
|
|
195
|
+
for (const a of n)
|
|
196
|
+
s.has(a) && await a(r);
|
|
197
|
+
for (const a of o)
|
|
198
|
+
i.has(a) && await a(e, r);
|
|
196
199
|
}
|
|
197
200
|
onAny(e) {
|
|
198
|
-
return
|
|
201
|
+
return b(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), f.get(this).add(e), this.emit(S, { listener: e }), this.offAny.bind(this, e);
|
|
199
202
|
}
|
|
200
203
|
anyEvent() {
|
|
201
|
-
return
|
|
204
|
+
return D(this);
|
|
202
205
|
}
|
|
203
206
|
offAny(e) {
|
|
204
|
-
|
|
207
|
+
b(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), this.emit(R, { listener: e }), f.get(this).delete(e);
|
|
205
208
|
}
|
|
206
209
|
clearListeners(e) {
|
|
207
210
|
e = Array.isArray(e) ? e : [e];
|
|
208
211
|
for (const r of e)
|
|
209
212
|
if (this.logIfDebugEnabled("clear", r, void 0), typeof r == "string" || typeof r == "symbol") {
|
|
210
|
-
|
|
211
|
-
const s =
|
|
212
|
-
for (const
|
|
213
|
-
|
|
213
|
+
m(this, r).clear();
|
|
214
|
+
const s = _(this, r);
|
|
215
|
+
for (const i of s)
|
|
216
|
+
i.finish();
|
|
214
217
|
s.clear();
|
|
215
218
|
} else {
|
|
216
|
-
|
|
217
|
-
for (const s of
|
|
219
|
+
f.get(this).clear();
|
|
220
|
+
for (const s of T.get(this).values())
|
|
218
221
|
s.clear();
|
|
219
|
-
for (const s of
|
|
220
|
-
for (const
|
|
221
|
-
|
|
222
|
+
for (const s of g.get(this).values()) {
|
|
223
|
+
for (const i of s)
|
|
224
|
+
i.finish();
|
|
222
225
|
s.clear();
|
|
223
226
|
}
|
|
224
227
|
}
|
|
@@ -228,21 +231,21 @@ class m {
|
|
|
228
231
|
let r = 0;
|
|
229
232
|
for (const s of e) {
|
|
230
233
|
if (typeof s == "string") {
|
|
231
|
-
r +=
|
|
234
|
+
r += f.get(this).size + m(this, s).size + _(this, s).size + _(this).size;
|
|
232
235
|
continue;
|
|
233
236
|
}
|
|
234
|
-
typeof s < "u" &&
|
|
235
|
-
for (const
|
|
236
|
-
r +=
|
|
237
|
-
for (const
|
|
238
|
-
r +=
|
|
237
|
+
typeof s < "u" && p(s), r += f.get(this).size;
|
|
238
|
+
for (const i of T.get(this).values())
|
|
239
|
+
r += i.size;
|
|
240
|
+
for (const i of g.get(this).values())
|
|
241
|
+
r += i.size;
|
|
239
242
|
}
|
|
240
243
|
return r;
|
|
241
244
|
}
|
|
242
245
|
bindMethods(e, r) {
|
|
243
246
|
if (typeof e != "object" || e === null)
|
|
244
247
|
throw new TypeError("`target` must be an object");
|
|
245
|
-
r =
|
|
248
|
+
r = $(r);
|
|
246
249
|
for (const s of r) {
|
|
247
250
|
if (e[s] !== void 0)
|
|
248
251
|
throw new Error(`The property \`${s}\` already exists on \`target\``);
|
|
@@ -253,25 +256,26 @@ class m {
|
|
|
253
256
|
}
|
|
254
257
|
}
|
|
255
258
|
}
|
|
256
|
-
const
|
|
257
|
-
Object.defineProperty(
|
|
258
|
-
value:
|
|
259
|
+
const G = Object.getOwnPropertyNames(d.prototype).filter((t) => t !== "constructor");
|
|
260
|
+
Object.defineProperty(d, "listenerAdded", {
|
|
261
|
+
value: S,
|
|
259
262
|
writable: !1,
|
|
260
263
|
enumerable: !0,
|
|
261
264
|
configurable: !1
|
|
262
265
|
});
|
|
263
|
-
Object.defineProperty(
|
|
264
|
-
value:
|
|
266
|
+
Object.defineProperty(d, "listenerRemoved", {
|
|
267
|
+
value: R,
|
|
265
268
|
writable: !1,
|
|
266
269
|
enumerable: !0,
|
|
267
270
|
configurable: !1
|
|
268
271
|
});
|
|
269
|
-
var
|
|
270
|
-
|
|
272
|
+
var Y = d;
|
|
273
|
+
const v = /* @__PURE__ */ j(Y);
|
|
274
|
+
function q(t) {
|
|
271
275
|
return typeof t == "object" && t !== null && "message" in t && typeof t.message == "string";
|
|
272
276
|
}
|
|
273
|
-
function
|
|
274
|
-
if (
|
|
277
|
+
function J(t) {
|
|
278
|
+
if (q(t))
|
|
275
279
|
return t;
|
|
276
280
|
try {
|
|
277
281
|
return new Error(JSON.stringify(t));
|
|
@@ -279,96 +283,96 @@ function X(t) {
|
|
|
279
283
|
return new Error(String(t));
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
286
|
+
function I(t) {
|
|
287
|
+
return J(t).message;
|
|
284
288
|
}
|
|
285
|
-
var
|
|
286
|
-
const
|
|
287
|
-
let
|
|
288
|
-
const
|
|
289
|
+
var K = Object.defineProperty, X = (t, e, r) => e in t ? K(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Z = (t, e, r) => (X(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 || {});
|
|
290
|
+
const ee = "hlg.tokbox.com/prod/logging/vcp_webrtc", re = "https://", te = 1e4;
|
|
291
|
+
let w;
|
|
292
|
+
const se = new Uint8Array(16);
|
|
289
293
|
function ie() {
|
|
290
|
-
if (!
|
|
294
|
+
if (!w && (w = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !w))
|
|
291
295
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
292
|
-
return
|
|
296
|
+
return w(se);
|
|
293
297
|
}
|
|
294
|
-
const
|
|
298
|
+
const c = [];
|
|
295
299
|
for (let t = 0; t < 256; ++t)
|
|
296
|
-
|
|
300
|
+
c.push((t + 256).toString(16).slice(1));
|
|
297
301
|
function ne(t, e = 0) {
|
|
298
|
-
return (
|
|
302
|
+
return (c[t[e + 0]] + c[t[e + 1]] + c[t[e + 2]] + c[t[e + 3]] + "-" + c[t[e + 4]] + c[t[e + 5]] + "-" + c[t[e + 6]] + c[t[e + 7]] + "-" + c[t[e + 8]] + c[t[e + 9]] + "-" + c[t[e + 10]] + c[t[e + 11]] + c[t[e + 12]] + c[t[e + 13]] + c[t[e + 14]] + c[t[e + 15]]).toLowerCase();
|
|
299
303
|
}
|
|
300
|
-
const
|
|
301
|
-
randomUUID:
|
|
304
|
+
const oe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), H = {
|
|
305
|
+
randomUUID: oe
|
|
302
306
|
};
|
|
303
|
-
function
|
|
304
|
-
if (
|
|
305
|
-
return
|
|
307
|
+
function ae(t, e, r) {
|
|
308
|
+
if (H.randomUUID && !e && !t)
|
|
309
|
+
return H.randomUUID();
|
|
306
310
|
t = t || {};
|
|
307
311
|
const s = t.random || (t.rng || ie)();
|
|
308
312
|
if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) {
|
|
309
313
|
r = r || 0;
|
|
310
|
-
for (let
|
|
311
|
-
e[r +
|
|
314
|
+
for (let i = 0; i < 16; ++i)
|
|
315
|
+
e[r + i] = s[i];
|
|
312
316
|
return e;
|
|
313
317
|
}
|
|
314
318
|
return ne(s);
|
|
315
319
|
}
|
|
316
|
-
function
|
|
320
|
+
function F(t, e) {
|
|
317
321
|
globalThis.vonage || (globalThis.vonage = {}), globalThis.vonage.workerizer || (globalThis.vonage.workerizer = {});
|
|
318
322
|
let r = globalThis.vonage.workerizer;
|
|
319
323
|
return r[t] || (r[t] = e), r[t];
|
|
320
324
|
}
|
|
321
|
-
const
|
|
325
|
+
const h = F(
|
|
322
326
|
"globals",
|
|
323
327
|
{}
|
|
324
328
|
);
|
|
325
|
-
var
|
|
326
|
-
function
|
|
327
|
-
return [ImageBitmap, ReadableStream, WritableStream].some((
|
|
329
|
+
var u = /* @__PURE__ */ ((t) => (t.INIT = "INIT", t.FORWARD = "FORWARD", t.TERMINATE = "TERMINATE", t.GLOBALS_SYNC = "GLOBALS_SYNC", t))(u || {});
|
|
330
|
+
function z(t) {
|
|
331
|
+
return [ImageBitmap, ReadableStream, WritableStream].some((r) => t instanceof r);
|
|
328
332
|
}
|
|
329
|
-
let
|
|
330
|
-
function le(t, e, r, s,
|
|
331
|
-
const
|
|
333
|
+
let ce = 0;
|
|
334
|
+
function le(t, e, r, s, i) {
|
|
335
|
+
const n = ce++;
|
|
332
336
|
return t.postMessage(
|
|
333
337
|
{
|
|
334
|
-
id:
|
|
338
|
+
id: n,
|
|
335
339
|
type: e,
|
|
336
340
|
functionName: r,
|
|
337
341
|
args: s
|
|
338
342
|
},
|
|
339
|
-
s.filter((
|
|
340
|
-
), new Promise((
|
|
341
|
-
|
|
343
|
+
s.filter((a) => z(a))
|
|
344
|
+
), new Promise((a) => {
|
|
345
|
+
i == null || i.set(n, a);
|
|
342
346
|
});
|
|
343
347
|
}
|
|
344
|
-
function
|
|
345
|
-
const { id: r, type: s } = t,
|
|
348
|
+
function y(t, e) {
|
|
349
|
+
const { id: r, type: s } = t, i = Array.isArray(e) ? e : [e];
|
|
346
350
|
postMessage(
|
|
347
351
|
{
|
|
348
352
|
id: r,
|
|
349
353
|
type: s,
|
|
350
354
|
result: e
|
|
351
355
|
},
|
|
352
|
-
|
|
356
|
+
i.filter((n) => z(n))
|
|
353
357
|
);
|
|
354
358
|
}
|
|
355
|
-
const
|
|
356
|
-
function
|
|
359
|
+
const Q = F("workerized", {});
|
|
360
|
+
function V() {
|
|
357
361
|
return typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope;
|
|
358
362
|
}
|
|
359
|
-
async function
|
|
360
|
-
if (
|
|
361
|
-
|
|
363
|
+
async function fe() {
|
|
364
|
+
if (V())
|
|
365
|
+
y({ type: u.GLOBALS_SYNC }, h);
|
|
362
366
|
else {
|
|
363
367
|
const t = [];
|
|
364
|
-
for (const e in
|
|
365
|
-
const { worker: r, resolvers: s } =
|
|
368
|
+
for (const e in Q) {
|
|
369
|
+
const { worker: r, resolvers: s } = Q[e].workerContext;
|
|
366
370
|
r && t.push(
|
|
367
371
|
le(
|
|
368
372
|
r,
|
|
369
|
-
|
|
373
|
+
u.GLOBALS_SYNC,
|
|
370
374
|
"",
|
|
371
|
-
[
|
|
375
|
+
[h],
|
|
372
376
|
s
|
|
373
377
|
)
|
|
374
378
|
);
|
|
@@ -393,91 +397,91 @@ async function he(t, e) {
|
|
|
393
397
|
throw "missing function name to call";
|
|
394
398
|
if (!e.instance[r])
|
|
395
399
|
throw `undefined function [${r}] in class ${e.instance.constructor.workerId}`;
|
|
396
|
-
|
|
400
|
+
y(t, await e.instance[r](...s ?? []));
|
|
397
401
|
}
|
|
398
|
-
const
|
|
402
|
+
const ue = F("registeredWorkers", {});
|
|
399
403
|
function de(t, e) {
|
|
400
404
|
if (!t.args)
|
|
401
405
|
throw "Missing className while initializing worker";
|
|
402
|
-
const [r, s] = t.args,
|
|
403
|
-
if (
|
|
404
|
-
e.instance = new
|
|
406
|
+
const [r, s] = t.args, i = ue[r];
|
|
407
|
+
if (i)
|
|
408
|
+
e.instance = new i(t.args.slice(1));
|
|
405
409
|
else
|
|
406
410
|
throw `unknown worker class ${r}`;
|
|
407
|
-
P(s,
|
|
411
|
+
P(s, h), y(t, typeof e.instance !== void 0);
|
|
408
412
|
}
|
|
409
|
-
async function
|
|
413
|
+
async function pe(t, e) {
|
|
410
414
|
const { args: r } = t;
|
|
411
415
|
if (!e.instance)
|
|
412
416
|
throw "instance not initialized";
|
|
413
417
|
let s;
|
|
414
|
-
e.instance.terminate && (s = await e.instance.terminate(...r
|
|
418
|
+
e.instance.terminate && (s = await e.instance.terminate(...r ?? [])), y(t, s);
|
|
415
419
|
}
|
|
416
|
-
function
|
|
420
|
+
function me(t) {
|
|
417
421
|
if (!t.args)
|
|
418
422
|
throw "Missing globals while syncing";
|
|
419
|
-
P(t.args[0],
|
|
423
|
+
P(t.args[0], h), y(t, {});
|
|
420
424
|
}
|
|
421
|
-
function
|
|
425
|
+
function ge() {
|
|
422
426
|
const t = {};
|
|
423
427
|
onmessage = async (e) => {
|
|
424
428
|
const r = e.data;
|
|
425
429
|
switch (r.type) {
|
|
426
|
-
case
|
|
430
|
+
case u.INIT:
|
|
427
431
|
de(r, t);
|
|
428
432
|
break;
|
|
429
|
-
case
|
|
433
|
+
case u.FORWARD:
|
|
430
434
|
he(r, t);
|
|
431
435
|
break;
|
|
432
|
-
case
|
|
433
|
-
|
|
436
|
+
case u.TERMINATE:
|
|
437
|
+
pe(r, t);
|
|
434
438
|
break;
|
|
435
|
-
case
|
|
436
|
-
|
|
439
|
+
case u.GLOBALS_SYNC:
|
|
440
|
+
me(r);
|
|
437
441
|
break;
|
|
438
442
|
}
|
|
439
443
|
};
|
|
440
444
|
}
|
|
441
|
-
|
|
442
|
-
function
|
|
443
|
-
return
|
|
444
|
-
() =>
|
|
445
|
+
V() && ge();
|
|
446
|
+
function _e(t, e) {
|
|
447
|
+
return h[t] || (h[t] = e), [
|
|
448
|
+
() => h[t],
|
|
445
449
|
async (r) => {
|
|
446
|
-
|
|
450
|
+
h[t] = r, await fe();
|
|
447
451
|
}
|
|
448
452
|
];
|
|
449
453
|
}
|
|
450
|
-
function
|
|
451
|
-
return
|
|
454
|
+
function ye(t, e) {
|
|
455
|
+
return _e(t, e);
|
|
452
456
|
}
|
|
453
|
-
const [
|
|
454
|
-
function
|
|
455
|
-
|
|
457
|
+
const [be, we] = ye("metadata");
|
|
458
|
+
function xe(t) {
|
|
459
|
+
we(t);
|
|
456
460
|
}
|
|
457
|
-
function
|
|
458
|
-
return
|
|
461
|
+
function x() {
|
|
462
|
+
return be();
|
|
459
463
|
}
|
|
460
|
-
class
|
|
461
|
-
constructor(e) {
|
|
462
|
-
|
|
464
|
+
class L {
|
|
465
|
+
constructor(e, r) {
|
|
466
|
+
Z(this, "uuid"), this.config = e, this.uuid = r ?? ae();
|
|
463
467
|
}
|
|
464
468
|
async send(e) {
|
|
465
|
-
var r, s,
|
|
466
|
-
const { appId:
|
|
467
|
-
if (!
|
|
469
|
+
var r, s, i;
|
|
470
|
+
const { appId: n, sourceType: o } = (r = x()) != null ? r : {};
|
|
471
|
+
if (!n || !o)
|
|
468
472
|
return "metadata missing";
|
|
469
|
-
const
|
|
470
|
-
return await ((
|
|
473
|
+
const a = new AbortController(), k = setTimeout(() => a.abort(), te);
|
|
474
|
+
return await ((i = (s = this.config) == null ? void 0 : s.fetch) != null ? i : fetch)(this.getUrl(), {
|
|
471
475
|
method: "POST",
|
|
472
476
|
headers: this.getHeaders(),
|
|
473
477
|
body: JSON.stringify(this.buildReport(e)),
|
|
474
|
-
signal:
|
|
475
|
-
}), clearTimeout(
|
|
478
|
+
signal: a.signal
|
|
479
|
+
}), clearTimeout(k), "success";
|
|
476
480
|
}
|
|
477
481
|
getUrl() {
|
|
478
482
|
var e;
|
|
479
|
-
let r = (e =
|
|
480
|
-
return r += (r.at(-1) === "/" ? "" : "/") +
|
|
483
|
+
let r = (e = x().proxyUrl) != null ? e : re;
|
|
484
|
+
return r += (r.at(-1) === "/" ? "" : "/") + ee, r;
|
|
481
485
|
}
|
|
482
486
|
getHeaders() {
|
|
483
487
|
return {
|
|
@@ -485,7 +489,7 @@ class D {
|
|
|
485
489
|
};
|
|
486
490
|
}
|
|
487
491
|
buildReport(e) {
|
|
488
|
-
const r =
|
|
492
|
+
const r = x();
|
|
489
493
|
return {
|
|
490
494
|
guid: this.uuid,
|
|
491
495
|
...e,
|
|
@@ -496,97 +500,90 @@ class D {
|
|
|
496
500
|
};
|
|
497
501
|
}
|
|
498
502
|
}
|
|
499
|
-
const
|
|
500
|
-
class
|
|
501
|
-
constructor(e) {
|
|
502
|
-
|
|
503
|
-
a(this, "frameFromSourceCount", 0);
|
|
504
|
-
a(this, "startAt", 0);
|
|
505
|
-
a(this, "reporter");
|
|
506
|
-
this.config = e, this.reporter = new D(e);
|
|
503
|
+
const E = "2.0.4";
|
|
504
|
+
class Te {
|
|
505
|
+
constructor(e, r) {
|
|
506
|
+
this.config = e, this.frameTransformedCount = 0, this.frameFromSourceCount = 0, this.startAt = 0, this.reporter = new L(e, r);
|
|
507
507
|
}
|
|
508
508
|
async onFrameFromSource() {
|
|
509
509
|
this.frameFromSourceCount++;
|
|
510
510
|
}
|
|
511
511
|
get fps() {
|
|
512
|
-
const { startAt: e, frameFromSourceCount: r } = this,
|
|
513
|
-
return r /
|
|
512
|
+
const { startAt: e, frameFromSourceCount: r } = this, i = (Date.now() - e) / 1e3;
|
|
513
|
+
return r / i;
|
|
514
514
|
}
|
|
515
515
|
async onFrameTransformed(e = {}, r = !1) {
|
|
516
516
|
this.startAt === 0 && (this.startAt = Date.now()), this.frameTransformedCount++;
|
|
517
|
-
const { startAt: s, frameTransformedCount:
|
|
518
|
-
return r || this.frameTransformedCount >= this.config.loggingIntervalFrameCount ? (this.frameFromSourceCount = 0, this.frameTransformedCount = 0, this.startAt =
|
|
517
|
+
const { startAt: s, frameTransformedCount: i, frameFromSourceCount: n } = this, o = Date.now(), a = (o - s) / 1e3, k = i / a, W = n / a;
|
|
518
|
+
return r || this.frameTransformedCount >= this.config.loggingIntervalFrameCount ? (this.frameFromSourceCount = 0, this.frameTransformedCount = 0, this.startAt = o, this.reporter.config = this.config, this.reporter.send({
|
|
519
519
|
...this.config.report,
|
|
520
520
|
variation: "QoS",
|
|
521
|
-
fps:
|
|
522
|
-
transformedFps:
|
|
523
|
-
framesTransformed:
|
|
521
|
+
fps: W,
|
|
522
|
+
transformedFps: k,
|
|
523
|
+
framesTransformed: i,
|
|
524
524
|
...e
|
|
525
525
|
})) : "success";
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
var Ee = /* @__PURE__ */ ((t) => (t.FPS_DROP = "fps_drop", t))(Ee || {}),
|
|
529
|
-
const
|
|
530
|
-
class
|
|
531
|
-
constructor(
|
|
532
|
-
super()
|
|
533
|
-
|
|
534
|
-
a(this, "reporterQos_", new Se({
|
|
535
|
-
loggingIntervalFrameCount: ke,
|
|
528
|
+
var Ee = /* @__PURE__ */ ((t) => (t.FPS_DROP = "fps_drop", t))(Ee || {}), Se = /* @__PURE__ */ ((t) => (t.start = "start", t.transform = "transform", t.flush = "flush", t))(Se || {}), O = /* @__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))(O || {});
|
|
529
|
+
const Re = 500, Pe = 0.8;
|
|
530
|
+
class ke extends v {
|
|
531
|
+
constructor(e, r) {
|
|
532
|
+
super(), this.reporter_ = new L(), this.reporterQos_ = new Te({
|
|
533
|
+
loggingIntervalFrameCount: Re,
|
|
536
534
|
report: {
|
|
537
|
-
version:
|
|
535
|
+
version: E
|
|
538
536
|
}
|
|
539
|
-
}))
|
|
540
|
-
a(this, "transformerType_");
|
|
541
|
-
a(this, "transformer_");
|
|
542
|
-
a(this, "shouldStop_");
|
|
543
|
-
a(this, "isFlashed_");
|
|
544
|
-
a(this, "mediaTransformerQosReportStartTimestamp_");
|
|
545
|
-
a(this, "videoHeight_");
|
|
546
|
-
a(this, "videoWidth_");
|
|
547
|
-
a(this, "trackExpectedRate_");
|
|
548
|
-
a(this, "index_");
|
|
549
|
-
a(this, "controller_");
|
|
550
|
-
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({
|
|
537
|
+
}), this.index_ = r, this.transformer_ = e, this.shouldStop_ = !1, this.isFlashed_ = !1, this.mediaTransformerQosReportStartTimestamp_ = 0, this.videoHeight_ = 0, this.videoWidth_ = 0, this.trackExpectedRate_ = -1, this.transformerType_ = "Custom", "getTransformerType" in e && (this.transformerType_ = e.getTransformerType()), this.report({
|
|
551
538
|
variation: "Create"
|
|
552
539
|
});
|
|
553
540
|
}
|
|
554
|
-
setTrackExpectedRate(
|
|
555
|
-
this.trackExpectedRate_ =
|
|
541
|
+
setTrackExpectedRate(e) {
|
|
542
|
+
this.trackExpectedRate_ = e;
|
|
556
543
|
}
|
|
557
|
-
async start(
|
|
558
|
-
if (this.controller_ =
|
|
544
|
+
async start(e) {
|
|
545
|
+
if (this.controller_ = e, this.transformer_ && typeof this.transformer_.start == "function")
|
|
559
546
|
try {
|
|
560
|
-
await this.transformer_.start(
|
|
561
|
-
} catch (
|
|
547
|
+
await this.transformer_.start(e);
|
|
548
|
+
} catch (r) {
|
|
562
549
|
this.report({
|
|
563
550
|
message: l.errors.transformer_start,
|
|
564
551
|
variation: "Error",
|
|
565
|
-
error:
|
|
552
|
+
error: I(r)
|
|
566
553
|
});
|
|
567
|
-
const
|
|
568
|
-
|
|
554
|
+
const s = {
|
|
555
|
+
eventMetaData: { transformerIndex: this.index_ },
|
|
556
|
+
error: r,
|
|
557
|
+
function: "start"
|
|
558
|
+
/* start */
|
|
559
|
+
};
|
|
560
|
+
this.emit("error", s);
|
|
569
561
|
}
|
|
570
562
|
}
|
|
571
|
-
async transform(
|
|
572
|
-
var
|
|
573
|
-
if (this.mediaTransformerQosReportStartTimestamp_ === 0 && (this.mediaTransformerQosReportStartTimestamp_ = Date.now()),
|
|
563
|
+
async transform(e, r) {
|
|
564
|
+
var s, i;
|
|
565
|
+
if (this.mediaTransformerQosReportStartTimestamp_ === 0 && (this.mediaTransformerQosReportStartTimestamp_ = Date.now()), e instanceof VideoFrame && (this.videoHeight_ = (e == null ? void 0 : e.displayHeight) ?? 0, this.videoWidth_ = (e == null ? void 0 : e.displayWidth) ?? 0), this.reporterQos_.onFrameFromSource(), this.transformer_)
|
|
574
566
|
if (this.shouldStop_)
|
|
575
|
-
console.warn("[Pipeline] flush from transform"),
|
|
567
|
+
console.warn("[Pipeline] flush from transform"), e.close(), this.flush(r), r.terminate();
|
|
576
568
|
else {
|
|
577
569
|
try {
|
|
578
|
-
await ((
|
|
579
|
-
} catch (
|
|
570
|
+
await ((i = (s = this.transformer_).transform) == null ? void 0 : i.call(s, e, r)), this.reportQos();
|
|
571
|
+
} catch (n) {
|
|
580
572
|
this.report({
|
|
581
573
|
message: l.errors.transformer_transform,
|
|
582
574
|
variation: "Error",
|
|
583
|
-
error:
|
|
575
|
+
error: I(n)
|
|
584
576
|
});
|
|
585
|
-
const
|
|
586
|
-
|
|
577
|
+
const o = {
|
|
578
|
+
eventMetaData: { transformerIndex: this.index_ },
|
|
579
|
+
error: n,
|
|
580
|
+
function: "transform"
|
|
581
|
+
/* transform */
|
|
582
|
+
};
|
|
583
|
+
this.emit("error", o);
|
|
587
584
|
}
|
|
588
|
-
if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ *
|
|
589
|
-
const
|
|
585
|
+
if (this.trackExpectedRate_ != -1 && this.trackExpectedRate_ * Pe > this.reporterQos_.fps) {
|
|
586
|
+
const n = {
|
|
590
587
|
eventMetaData: {
|
|
591
588
|
transformerIndex: this.index_
|
|
592
589
|
},
|
|
@@ -596,23 +593,28 @@ class Pe extends L {
|
|
|
596
593
|
current: this.reporterQos_.fps
|
|
597
594
|
}
|
|
598
595
|
};
|
|
599
|
-
this.emit("warn",
|
|
596
|
+
this.emit("warn", n);
|
|
600
597
|
}
|
|
601
598
|
}
|
|
602
599
|
}
|
|
603
|
-
async flush(
|
|
600
|
+
async flush(e) {
|
|
604
601
|
if (this.transformer_ && typeof this.transformer_.flush == "function" && !this.isFlashed_) {
|
|
605
602
|
this.isFlashed_ = !0;
|
|
606
603
|
try {
|
|
607
|
-
await this.transformer_.flush(
|
|
608
|
-
} catch (
|
|
604
|
+
await this.transformer_.flush(e);
|
|
605
|
+
} catch (r) {
|
|
609
606
|
this.report({
|
|
610
607
|
message: l.errors.transformer_flush,
|
|
611
608
|
variation: "Error",
|
|
612
|
-
error:
|
|
609
|
+
error: I(r)
|
|
613
610
|
});
|
|
614
|
-
const
|
|
615
|
-
|
|
611
|
+
const s = {
|
|
612
|
+
eventMetaData: { transformerIndex: this.index_ },
|
|
613
|
+
error: r,
|
|
614
|
+
function: "flush"
|
|
615
|
+
/* flush */
|
|
616
|
+
};
|
|
617
|
+
this.emit("error", s);
|
|
616
618
|
}
|
|
617
619
|
}
|
|
618
620
|
this.reportQos(!0), this.report({
|
|
@@ -622,168 +624,227 @@ class Pe extends L {
|
|
|
622
624
|
stop() {
|
|
623
625
|
console.log("[Pipeline] Stop stream."), this.controller_ && (this.flush(this.controller_), this.controller_.terminate()), this.shouldStop_ = !0;
|
|
624
626
|
}
|
|
625
|
-
report(
|
|
627
|
+
report(e) {
|
|
626
628
|
this.reporter_.send({
|
|
627
|
-
version:
|
|
629
|
+
version: E,
|
|
628
630
|
action: "MediaTransformer",
|
|
629
631
|
transformerType: this.transformerType_,
|
|
630
|
-
...
|
|
632
|
+
...e
|
|
631
633
|
});
|
|
632
634
|
}
|
|
633
|
-
reportQos(
|
|
635
|
+
reportQos(e = !1) {
|
|
634
636
|
this.reporterQos_.config = {
|
|
635
637
|
...this.reporterQos_.config
|
|
636
|
-
}, this.reporterQos_.onFrameTransformed(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.transformers_ = [], this.trackExpectedRate_ = -1;
|
|
651
|
-
for (let
|
|
652
|
-
let
|
|
653
|
-
|
|
638
|
+
}, this.reporterQos_.onFrameTransformed(
|
|
639
|
+
{
|
|
640
|
+
version: E,
|
|
641
|
+
action: "MediaTransformer",
|
|
642
|
+
transformerType: this.transformerType_,
|
|
643
|
+
videoWidth: this.videoWidth_,
|
|
644
|
+
videoHeight: this.videoHeight_
|
|
645
|
+
},
|
|
646
|
+
e
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
class Ae extends v {
|
|
651
|
+
constructor(e) {
|
|
652
|
+
super(), this.transformers_ = [], this.trackExpectedRate_ = -1;
|
|
653
|
+
for (let r = 0; r < e.length; r++) {
|
|
654
|
+
let s = new ke(e[r], r);
|
|
655
|
+
s.on("error", (i) => {
|
|
654
656
|
this.emit("error", i);
|
|
655
|
-
}),
|
|
657
|
+
}), s.on("warn", (i) => {
|
|
656
658
|
this.emit("warn", i);
|
|
657
|
-
}), this.transformers_.push(
|
|
659
|
+
}), this.transformers_.push(s);
|
|
658
660
|
}
|
|
659
661
|
}
|
|
660
|
-
setTrackExpectedRate(
|
|
661
|
-
this.trackExpectedRate_ =
|
|
662
|
-
for (let
|
|
663
|
-
|
|
662
|
+
setTrackExpectedRate(e) {
|
|
663
|
+
this.trackExpectedRate_ = e;
|
|
664
|
+
for (let r of this.transformers_)
|
|
665
|
+
r.setTrackExpectedRate(this.trackExpectedRate_);
|
|
664
666
|
}
|
|
665
|
-
async start(
|
|
667
|
+
async start(e, r) {
|
|
666
668
|
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
667
669
|
console.log("[Pipeline] No transformers.");
|
|
668
670
|
return;
|
|
669
671
|
}
|
|
670
672
|
try {
|
|
671
|
-
let
|
|
673
|
+
let s = e;
|
|
672
674
|
for (let i of this.transformers_)
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
675
|
+
e = e.pipeThrough(
|
|
676
|
+
new TransformStream(i)
|
|
677
|
+
);
|
|
678
|
+
e.pipeTo(r).then(async () => {
|
|
679
|
+
console.log("[Pipeline] Setup."), await r.abort(), await s.cancel(), this.emit(
|
|
680
|
+
"pipelineInfo",
|
|
681
|
+
"pipeline_ended"
|
|
682
|
+
/* pipeline_ended */
|
|
683
|
+
);
|
|
676
684
|
}).catch(async (i) => {
|
|
677
|
-
|
|
678
|
-
console.log(
|
|
685
|
+
e.cancel().then(() => {
|
|
686
|
+
console.log(
|
|
687
|
+
"[Pipeline] Shutting down streams after abort."
|
|
688
|
+
);
|
|
679
689
|
}).catch((n) => {
|
|
680
|
-
console.error(
|
|
681
|
-
|
|
690
|
+
console.error(
|
|
691
|
+
"[Pipeline] Error from stream transform:",
|
|
692
|
+
n
|
|
693
|
+
);
|
|
694
|
+
}), await r.abort(i), await s.cancel(i), this.emit(
|
|
695
|
+
"pipelineInfo",
|
|
696
|
+
"pipeline_ended_with_error"
|
|
697
|
+
/* pipeline_ended_with_error */
|
|
698
|
+
);
|
|
682
699
|
});
|
|
683
700
|
} catch {
|
|
684
|
-
this.emit(
|
|
701
|
+
this.emit(
|
|
702
|
+
"pipelineInfo",
|
|
703
|
+
"pipeline_started_with_error"
|
|
704
|
+
/* pipeline_started_with_error */
|
|
705
|
+
), this.destroy();
|
|
685
706
|
return;
|
|
686
707
|
}
|
|
687
|
-
this.emit(
|
|
708
|
+
this.emit(
|
|
709
|
+
"pipelineInfo",
|
|
710
|
+
"pipeline_started"
|
|
711
|
+
/* pipeline_started */
|
|
712
|
+
), console.log("[Pipeline] Pipeline started.");
|
|
688
713
|
}
|
|
689
714
|
async destroy() {
|
|
690
715
|
console.log("[Pipeline] Destroying Pipeline.");
|
|
691
|
-
for (let
|
|
692
|
-
|
|
716
|
+
for (let e of this.transformers_)
|
|
717
|
+
e.stop();
|
|
693
718
|
}
|
|
694
719
|
}
|
|
695
|
-
class
|
|
720
|
+
class Ce extends v {
|
|
696
721
|
constructor() {
|
|
697
|
-
super()
|
|
698
|
-
a(this, "reporter_");
|
|
699
|
-
a(this, "pipeline_");
|
|
700
|
-
a(this, "transformers_");
|
|
701
|
-
a(this, "readable_");
|
|
702
|
-
a(this, "writable_");
|
|
703
|
-
a(this, "trackExpectedRate_");
|
|
704
|
-
this.reporter_ = new D(), this.trackExpectedRate_ = -1, this.report({
|
|
722
|
+
super(), this.reporter_ = new L(), this.trackExpectedRate_ = -1, this.report({
|
|
705
723
|
variation: "Create"
|
|
706
724
|
});
|
|
707
725
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Sets the expected rate of the track per second.
|
|
728
|
+
* The media processor will use this number for calculating drops in the rate.
|
|
729
|
+
* This could happen when the transformation will take more time than expected.
|
|
730
|
+
* This will not cause an error, just warning to the client.
|
|
731
|
+
* Mostly:
|
|
732
|
+
* Video: 30 frames per second
|
|
733
|
+
* Audio: 50 audio data per second for OPUS
|
|
734
|
+
* In case of increased frame dropping rate a warning will be emitted according to info [here](/docs/intro#errors-and-warnings-listener).
|
|
735
|
+
* ***This is an optional method.***
|
|
736
|
+
* @param trackExpectedRate - number holds the predicted track rate.
|
|
737
|
+
*/
|
|
738
|
+
setTrackExpectedRate(e) {
|
|
739
|
+
this.trackExpectedRate_ = e, this.pipeline_ && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_);
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Starts running the tranformation logic performed by the media processor instance.
|
|
743
|
+
* When running an instance of this class on a Web worker thread the call for this function should be made by the user. See example [here](/docs/intro#webworker-code).
|
|
744
|
+
* When running an instance of this class on the application main thread there is no need to call this method given it will be called by the `MediaProcessorConnector` instance.
|
|
745
|
+
*
|
|
746
|
+
* @param readable Readable stream associated to the media source being processed.
|
|
747
|
+
* @param writable Writable stream associated to the resulting media once processed.
|
|
748
|
+
*
|
|
749
|
+
* @returns
|
|
750
|
+
*/
|
|
751
|
+
transform(e, r) {
|
|
752
|
+
return this.readable_ = e, this.writable_ = r, this.transformInternal();
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* @private
|
|
756
|
+
*/
|
|
714
757
|
transformInternal() {
|
|
715
|
-
return new Promise(async (
|
|
758
|
+
return new Promise(async (e, r) => {
|
|
716
759
|
if (!this.transformers_ || this.transformers_.length === 0) {
|
|
717
760
|
this.report({
|
|
718
761
|
message: l.errors.transformer_none,
|
|
719
762
|
variation: "Error"
|
|
720
|
-
}),
|
|
763
|
+
}), r("[MediaProcessor] Need to set transformers.");
|
|
721
764
|
return;
|
|
722
765
|
}
|
|
723
766
|
if (!this.readable_) {
|
|
724
767
|
this.report({
|
|
725
768
|
variation: "Error",
|
|
726
769
|
message: l.errors.readable_null
|
|
727
|
-
}),
|
|
770
|
+
}), r("[MediaProcessor] Readable is null.");
|
|
728
771
|
return;
|
|
729
772
|
}
|
|
730
773
|
if (!this.writable_) {
|
|
731
774
|
this.report({
|
|
732
775
|
variation: "Error",
|
|
733
776
|
message: l.errors.writable_null
|
|
734
|
-
}),
|
|
777
|
+
}), r("[MediaProcessor] Writable is null.");
|
|
735
778
|
return;
|
|
736
779
|
}
|
|
737
|
-
let
|
|
738
|
-
this.pipeline_ && (
|
|
780
|
+
let s = !1;
|
|
781
|
+
this.pipeline_ && (s = !0, this.pipeline_.clearListeners(), this.pipeline_.destroy()), this.pipeline_ = new Ae(this.transformers_), this.pipeline_.on("warn", (i) => {
|
|
739
782
|
this.emit("warn", i);
|
|
740
783
|
}), this.pipeline_.on("error", (i) => {
|
|
741
784
|
this.emit("error", i);
|
|
742
785
|
}), this.pipeline_.on("pipelineInfo", (i) => {
|
|
743
|
-
|
|
786
|
+
s && (i === "pipeline_started" ? i = O.pipeline_restarted : i === "pipeline_started_with_error" && (i = O.pipeline_restarted_with_error)), this.emit("pipelineInfo", i);
|
|
744
787
|
}), this.trackExpectedRate_ != -1 && this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_), this.pipeline_.start(this.readable_, this.writable_).then(() => {
|
|
745
|
-
|
|
788
|
+
e();
|
|
746
789
|
}).catch((i) => {
|
|
747
|
-
|
|
790
|
+
r(i);
|
|
748
791
|
});
|
|
749
792
|
});
|
|
750
793
|
}
|
|
751
|
-
|
|
794
|
+
/**
|
|
795
|
+
* Sets an array of transfromer instances that will be hold and ran by the media processor instance.
|
|
796
|
+
* See example [here](/docs/intro#main-code)
|
|
797
|
+
*
|
|
798
|
+
* @param transformers An array of transformer instances.
|
|
799
|
+
*
|
|
800
|
+
* @returns
|
|
801
|
+
*/
|
|
802
|
+
setTransformers(e) {
|
|
752
803
|
return this.report({
|
|
753
804
|
variation: "Update",
|
|
754
805
|
message: l.updates.transformer_new
|
|
755
|
-
}), this.transformers_ =
|
|
806
|
+
}), this.transformers_ = e, this.readable_ && this.writable_ ? this.transformInternal() : Promise.resolve();
|
|
756
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Stops running the tranformation logic performed by the media processor instance.
|
|
810
|
+
* @returns
|
|
811
|
+
*/
|
|
757
812
|
destroy() {
|
|
758
|
-
return new Promise(async (
|
|
759
|
-
this.pipeline_ && this.pipeline_.destroy(), this.report({ variation: "Delete" }),
|
|
813
|
+
return new Promise(async (e) => {
|
|
814
|
+
this.pipeline_ && this.pipeline_.destroy(), this.report({ variation: "Delete" }), e();
|
|
760
815
|
});
|
|
761
816
|
}
|
|
762
|
-
report(
|
|
817
|
+
report(e) {
|
|
763
818
|
this.reporter_.send({
|
|
764
|
-
version:
|
|
819
|
+
version: E,
|
|
765
820
|
action: "MediaProcessor",
|
|
766
|
-
...
|
|
821
|
+
...e
|
|
767
822
|
});
|
|
768
823
|
}
|
|
769
824
|
}
|
|
770
|
-
class
|
|
825
|
+
class Me {
|
|
771
826
|
constructor() {
|
|
772
|
-
a(this, "processor_");
|
|
773
|
-
a(this, "generator_");
|
|
774
827
|
this.processor_ = null, this.generator_ = null;
|
|
775
828
|
}
|
|
776
829
|
init(e) {
|
|
777
830
|
return new Promise((r, s) => {
|
|
778
831
|
try {
|
|
779
832
|
this.processor_ = new MediaStreamTrackProcessor(e);
|
|
780
|
-
} catch (
|
|
781
|
-
console.log(
|
|
833
|
+
} catch (i) {
|
|
834
|
+
console.log(
|
|
835
|
+
`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`
|
|
836
|
+
), s(i);
|
|
782
837
|
}
|
|
783
838
|
try {
|
|
784
|
-
e.kind === "audio" ? this.generator_ = new MediaStreamTrackGenerator({
|
|
785
|
-
|
|
786
|
-
|
|
839
|
+
e.kind === "audio" ? this.generator_ = new MediaStreamTrackGenerator({
|
|
840
|
+
kind: "audio"
|
|
841
|
+
}) : e.kind === "video" ? this.generator_ = new MediaStreamTrackGenerator({
|
|
842
|
+
kind: "video"
|
|
843
|
+
}) : s("kind not supported");
|
|
844
|
+
} catch (i) {
|
|
845
|
+
console.log(
|
|
846
|
+
`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`
|
|
847
|
+
), s(i);
|
|
787
848
|
}
|
|
788
849
|
r();
|
|
789
850
|
});
|
|
@@ -798,25 +859,45 @@ class xe {
|
|
|
798
859
|
return this.generator_;
|
|
799
860
|
}
|
|
800
861
|
}
|
|
801
|
-
class
|
|
862
|
+
class Oe {
|
|
863
|
+
/**
|
|
864
|
+
* - When running insertable streams on the main `MediaProcessorInterface` should be instance of `MediaProcessor` class.
|
|
865
|
+
* - When running insertable streams on WebWorker `MediaProcessorInterface` should be instance of bridge calss created by the user. Example can be found [here](/docs/intro.md#using-the-transformer-on-webworker)
|
|
866
|
+
* @param vonageMediaProcessor - MediaProcessorInterface.
|
|
867
|
+
*/
|
|
802
868
|
constructor(e) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
869
|
+
this.insertableStreamHelper_ = new Me(), this.mediaProcessor_ = e;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* @private
|
|
873
|
+
* Sets the media stream track instance to be processed.
|
|
874
|
+
*
|
|
875
|
+
* @param track MediaStreamTrack (audio or video) to be processed.
|
|
876
|
+
*
|
|
877
|
+
* @returns New track to be used.
|
|
878
|
+
*/
|
|
807
879
|
setTrack(e) {
|
|
808
880
|
return new Promise((r, s) => {
|
|
809
881
|
this.insertableStreamHelper_.init(e).then(() => {
|
|
810
|
-
this.mediaProcessor_.transform(
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
882
|
+
this.mediaProcessor_.transform(
|
|
883
|
+
this.insertableStreamHelper_.getReadable(),
|
|
884
|
+
this.insertableStreamHelper_.getWriteable()
|
|
885
|
+
).then(() => {
|
|
886
|
+
r(
|
|
887
|
+
this.insertableStreamHelper_.getProccesorTrack()
|
|
888
|
+
);
|
|
889
|
+
}).catch((i) => {
|
|
890
|
+
s(i);
|
|
814
891
|
});
|
|
815
|
-
}).catch((
|
|
816
|
-
s(
|
|
892
|
+
}).catch((i) => {
|
|
893
|
+
s(i);
|
|
817
894
|
});
|
|
818
895
|
});
|
|
819
896
|
}
|
|
897
|
+
/**
|
|
898
|
+
* @private
|
|
899
|
+
* Stops the media processing being performed.
|
|
900
|
+
*/
|
|
820
901
|
destroy() {
|
|
821
902
|
return new Promise((e, r) => {
|
|
822
903
|
this.mediaProcessor_ ? this.mediaProcessor_.destroy().then(() => {
|
|
@@ -828,13 +909,13 @@ class Fe {
|
|
|
828
909
|
}
|
|
829
910
|
}
|
|
830
911
|
export {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
912
|
+
Se as ErrorFunction,
|
|
913
|
+
Ce as MediaProcessor,
|
|
914
|
+
Oe as MediaProcessorConnector,
|
|
915
|
+
O as PipelineInfoData,
|
|
916
|
+
N as VonageSourceType,
|
|
836
917
|
Ee as WarningType,
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
918
|
+
x as getVonageMetadata,
|
|
919
|
+
Ie as isSupported,
|
|
920
|
+
xe as setVonageMetadata
|
|
840
921
|
};
|