@gyeonghokim/vega 0.0.0
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/LICENSE +21 -0
- package/README.md +301 -0
- package/dist/assets/media-worker-DqCztg6H.js +3363 -0
- package/dist/assets/media-worker-DqCztg6H.js.map +1 -0
- package/dist/audio/audio-renderer.d.ts +76 -0
- package/dist/audio/audio-renderer.d.ts.map +1 -0
- package/dist/audio/audio-worklet-processor.d.ts +14 -0
- package/dist/audio/audio-worklet-processor.d.ts.map +1 -0
- package/dist/audio/ring-buffer.d.ts +71 -0
- package/dist/audio/ring-buffer.d.ts.map +1 -0
- package/dist/convert.d.ts +27 -0
- package/dist/convert.d.ts.map +1 -0
- package/dist/demuxer/mp4-demuxer.d.ts +133 -0
- package/dist/demuxer/mp4-demuxer.d.ts.map +1 -0
- package/dist/demuxer/mp4box-types.d.ts +149 -0
- package/dist/demuxer/mp4box-types.d.ts.map +1 -0
- package/dist/factory.d.ts +16 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/renderers/renderer-2d.d.ts +12 -0
- package/dist/renderers/renderer-2d.d.ts.map +1 -0
- package/dist/renderers/renderer-webgl.d.ts +11 -0
- package/dist/renderers/renderer-webgl.d.ts.map +1 -0
- package/dist/renderers/renderer-webgpu.d.ts +11 -0
- package/dist/renderers/renderer-webgpu.d.ts.map +1 -0
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/vega.d.ts +189 -0
- package/dist/types/vega.d.ts.map +1 -0
- package/dist/types/worker-messages.d.ts +179 -0
- package/dist/types/worker-messages.d.ts.map +1 -0
- package/dist/vega.d.ts +13 -0
- package/dist/vega.d.ts.map +1 -0
- package/dist/vega.js +488 -0
- package/dist/vega.js.map +1 -0
- package/dist/vega.umd.cjs +42 -0
- package/dist/vega.umd.cjs.map +1 -0
- package/dist/worker/media-worker.d.ts +6 -0
- package/dist/worker/media-worker.d.ts.map +1 -0
- package/dist/worker/video-renderer.d.ts +63 -0
- package/dist/worker/video-renderer.d.ts.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,3363 @@
|
|
|
1
|
+
function ht(v, l) {
|
|
2
|
+
return l.forEach(function(_) {
|
|
3
|
+
_ && typeof _ != "string" && !Array.isArray(_) && Object.keys(_).forEach(function(d) {
|
|
4
|
+
if (d !== "default" && !(d in v)) {
|
|
5
|
+
var b = Object.getOwnPropertyDescriptor(_, d);
|
|
6
|
+
Object.defineProperty(v, d, b.get ? b : {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _[d];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}), Object.freeze(v);
|
|
15
|
+
}
|
|
16
|
+
var X = {}, tt;
|
|
17
|
+
function lt() {
|
|
18
|
+
return tt || (tt = 1, (function(v) {
|
|
19
|
+
var l = /* @__PURE__ */ (function() {
|
|
20
|
+
var t = /* @__PURE__ */ new Date(), e = 4, r = 3, n = 2, o = 1, a = e, h = {
|
|
21
|
+
setLogLevel: function(f) {
|
|
22
|
+
f == this.debug ? a = o : f == this.info ? a = n : f == this.warn ? a = r : (f == this.error, a = e);
|
|
23
|
+
},
|
|
24
|
+
debug: function(f, p) {
|
|
25
|
+
console.debug === void 0 && (console.debug = console.log), o >= a && console.debug("[" + l.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + f + "]", p);
|
|
26
|
+
},
|
|
27
|
+
log: function(f, p) {
|
|
28
|
+
this.debug(f.msg);
|
|
29
|
+
},
|
|
30
|
+
info: function(f, p) {
|
|
31
|
+
n >= a && console.info("[" + l.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + f + "]", p);
|
|
32
|
+
},
|
|
33
|
+
warn: function(f, p) {
|
|
34
|
+
r >= a && console.warn("[" + l.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + f + "]", p);
|
|
35
|
+
},
|
|
36
|
+
error: function(f, p) {
|
|
37
|
+
e >= a && console.error("[" + l.getDurationString(/* @__PURE__ */ new Date() - t, 1e3) + "]", "[" + f + "]", p);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return h;
|
|
41
|
+
})();
|
|
42
|
+
l.getDurationString = function(t, e) {
|
|
43
|
+
var r;
|
|
44
|
+
function n(u, c) {
|
|
45
|
+
for (var g = "" + u, x = g.split("."); x[0].length < c; )
|
|
46
|
+
x[0] = "0" + x[0];
|
|
47
|
+
return x.join(".");
|
|
48
|
+
}
|
|
49
|
+
t < 0 ? (r = !0, t = -t) : r = !1;
|
|
50
|
+
var o = e || 1, a = t / o, h = Math.floor(a / 3600);
|
|
51
|
+
a -= h * 3600;
|
|
52
|
+
var f = Math.floor(a / 60);
|
|
53
|
+
a -= f * 60;
|
|
54
|
+
var p = a * 1e3;
|
|
55
|
+
return a = Math.floor(a), p -= a * 1e3, p = Math.floor(p), (r ? "-" : "") + h + ":" + n(f, 2) + ":" + n(a, 2) + "." + n(p, 3);
|
|
56
|
+
}, l.printRanges = function(t) {
|
|
57
|
+
var e = t.length;
|
|
58
|
+
if (e > 0) {
|
|
59
|
+
for (var r = "", n = 0; n < e; n++)
|
|
60
|
+
n > 0 && (r += ","), r += "[" + l.getDurationString(t.start(n)) + "," + l.getDurationString(t.end(n)) + "]";
|
|
61
|
+
return r;
|
|
62
|
+
} else
|
|
63
|
+
return "(empty)";
|
|
64
|
+
}, v.Log = l;
|
|
65
|
+
var _ = function(t) {
|
|
66
|
+
if (t instanceof ArrayBuffer)
|
|
67
|
+
this.buffer = t, this.dataview = new DataView(t);
|
|
68
|
+
else
|
|
69
|
+
throw "Needs an array buffer";
|
|
70
|
+
this.position = 0;
|
|
71
|
+
};
|
|
72
|
+
_.prototype.getPosition = function() {
|
|
73
|
+
return this.position;
|
|
74
|
+
}, _.prototype.getEndPosition = function() {
|
|
75
|
+
return this.buffer.byteLength;
|
|
76
|
+
}, _.prototype.getLength = function() {
|
|
77
|
+
return this.buffer.byteLength;
|
|
78
|
+
}, _.prototype.seek = function(t) {
|
|
79
|
+
var e = Math.max(0, Math.min(this.buffer.byteLength, t));
|
|
80
|
+
return this.position = isNaN(e) || !isFinite(e) ? 0 : e, !0;
|
|
81
|
+
}, _.prototype.isEos = function() {
|
|
82
|
+
return this.getPosition() >= this.getEndPosition();
|
|
83
|
+
}, _.prototype.readAnyInt = function(t, e) {
|
|
84
|
+
var r = 0;
|
|
85
|
+
if (this.position + t <= this.buffer.byteLength) {
|
|
86
|
+
switch (t) {
|
|
87
|
+
case 1:
|
|
88
|
+
e ? r = this.dataview.getInt8(this.position) : r = this.dataview.getUint8(this.position);
|
|
89
|
+
break;
|
|
90
|
+
case 2:
|
|
91
|
+
e ? r = this.dataview.getInt16(this.position) : r = this.dataview.getUint16(this.position);
|
|
92
|
+
break;
|
|
93
|
+
case 3:
|
|
94
|
+
if (e)
|
|
95
|
+
throw "No method for reading signed 24 bits values";
|
|
96
|
+
r = this.dataview.getUint8(this.position) << 16, r |= this.dataview.getUint8(this.position + 1) << 8, r |= this.dataview.getUint8(this.position + 2);
|
|
97
|
+
break;
|
|
98
|
+
case 4:
|
|
99
|
+
e ? r = this.dataview.getInt32(this.position) : r = this.dataview.getUint32(this.position);
|
|
100
|
+
break;
|
|
101
|
+
case 8:
|
|
102
|
+
if (e)
|
|
103
|
+
throw "No method for reading signed 64 bits values";
|
|
104
|
+
r = this.dataview.getUint32(this.position) << 32, r |= this.dataview.getUint32(this.position + 4);
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
throw "readInt method not implemented for size: " + t;
|
|
108
|
+
}
|
|
109
|
+
return this.position += t, r;
|
|
110
|
+
} else
|
|
111
|
+
throw "Not enough bytes in buffer";
|
|
112
|
+
}, _.prototype.readUint8 = function() {
|
|
113
|
+
return this.readAnyInt(1, !1);
|
|
114
|
+
}, _.prototype.readUint16 = function() {
|
|
115
|
+
return this.readAnyInt(2, !1);
|
|
116
|
+
}, _.prototype.readUint24 = function() {
|
|
117
|
+
return this.readAnyInt(3, !1);
|
|
118
|
+
}, _.prototype.readUint32 = function() {
|
|
119
|
+
return this.readAnyInt(4, !1);
|
|
120
|
+
}, _.prototype.readUint64 = function() {
|
|
121
|
+
return this.readAnyInt(8, !1);
|
|
122
|
+
}, _.prototype.readString = function(t) {
|
|
123
|
+
if (this.position + t <= this.buffer.byteLength) {
|
|
124
|
+
for (var e = "", r = 0; r < t; r++)
|
|
125
|
+
e += String.fromCharCode(this.readUint8());
|
|
126
|
+
return e;
|
|
127
|
+
} else
|
|
128
|
+
throw "Not enough bytes in buffer";
|
|
129
|
+
}, _.prototype.readCString = function() {
|
|
130
|
+
for (var t = []; ; ) {
|
|
131
|
+
var e = this.readUint8();
|
|
132
|
+
if (e !== 0)
|
|
133
|
+
t.push(e);
|
|
134
|
+
else
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return String.fromCharCode.apply(null, t);
|
|
138
|
+
}, _.prototype.readInt8 = function() {
|
|
139
|
+
return this.readAnyInt(1, !0);
|
|
140
|
+
}, _.prototype.readInt16 = function() {
|
|
141
|
+
return this.readAnyInt(2, !0);
|
|
142
|
+
}, _.prototype.readInt32 = function() {
|
|
143
|
+
return this.readAnyInt(4, !0);
|
|
144
|
+
}, _.prototype.readInt64 = function() {
|
|
145
|
+
return this.readAnyInt(8, !1);
|
|
146
|
+
}, _.prototype.readUint8Array = function(t) {
|
|
147
|
+
for (var e = new Uint8Array(t), r = 0; r < t; r++)
|
|
148
|
+
e[r] = this.readUint8();
|
|
149
|
+
return e;
|
|
150
|
+
}, _.prototype.readInt16Array = function(t) {
|
|
151
|
+
for (var e = new Int16Array(t), r = 0; r < t; r++)
|
|
152
|
+
e[r] = this.readInt16();
|
|
153
|
+
return e;
|
|
154
|
+
}, _.prototype.readUint16Array = function(t) {
|
|
155
|
+
for (var e = new Int16Array(t), r = 0; r < t; r++)
|
|
156
|
+
e[r] = this.readUint16();
|
|
157
|
+
return e;
|
|
158
|
+
}, _.prototype.readUint32Array = function(t) {
|
|
159
|
+
for (var e = new Uint32Array(t), r = 0; r < t; r++)
|
|
160
|
+
e[r] = this.readUint32();
|
|
161
|
+
return e;
|
|
162
|
+
}, _.prototype.readInt32Array = function(t) {
|
|
163
|
+
for (var e = new Int32Array(t), r = 0; r < t; r++)
|
|
164
|
+
e[r] = this.readInt32();
|
|
165
|
+
return e;
|
|
166
|
+
}, v.MP4BoxStream = _;
|
|
167
|
+
var d = function(t, e, r) {
|
|
168
|
+
this._byteOffset = e || 0, t instanceof ArrayBuffer ? this.buffer = t : typeof t == "object" ? (this.dataView = t, e && (this._byteOffset += e)) : this.buffer = new ArrayBuffer(t || 0), this.position = 0, this.endianness = r ?? d.LITTLE_ENDIAN;
|
|
169
|
+
};
|
|
170
|
+
d.prototype = {}, d.prototype.getPosition = function() {
|
|
171
|
+
return this.position;
|
|
172
|
+
}, d.prototype._realloc = function(t) {
|
|
173
|
+
if (this._dynamicSize) {
|
|
174
|
+
var e = this._byteOffset + this.position + t, r = this._buffer.byteLength;
|
|
175
|
+
if (e <= r) {
|
|
176
|
+
e > this._byteLength && (this._byteLength = e);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (r < 1 && (r = 1); e > r; )
|
|
180
|
+
r *= 2;
|
|
181
|
+
var n = new ArrayBuffer(r), o = new Uint8Array(this._buffer), a = new Uint8Array(n, 0, o.length);
|
|
182
|
+
a.set(o), this.buffer = n, this._byteLength = e;
|
|
183
|
+
}
|
|
184
|
+
}, d.prototype._trimAlloc = function() {
|
|
185
|
+
if (this._byteLength != this._buffer.byteLength) {
|
|
186
|
+
var t = new ArrayBuffer(this._byteLength), e = new Uint8Array(t), r = new Uint8Array(this._buffer, 0, e.length);
|
|
187
|
+
e.set(r), this.buffer = t;
|
|
188
|
+
}
|
|
189
|
+
}, d.BIG_ENDIAN = !1, d.LITTLE_ENDIAN = !0, d.prototype._byteLength = 0, Object.defineProperty(
|
|
190
|
+
d.prototype,
|
|
191
|
+
"byteLength",
|
|
192
|
+
{ get: function() {
|
|
193
|
+
return this._byteLength - this._byteOffset;
|
|
194
|
+
} }
|
|
195
|
+
), Object.defineProperty(
|
|
196
|
+
d.prototype,
|
|
197
|
+
"buffer",
|
|
198
|
+
{
|
|
199
|
+
get: function() {
|
|
200
|
+
return this._trimAlloc(), this._buffer;
|
|
201
|
+
},
|
|
202
|
+
set: function(t) {
|
|
203
|
+
this._buffer = t, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._buffer.byteLength;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
), Object.defineProperty(
|
|
207
|
+
d.prototype,
|
|
208
|
+
"byteOffset",
|
|
209
|
+
{
|
|
210
|
+
get: function() {
|
|
211
|
+
return this._byteOffset;
|
|
212
|
+
},
|
|
213
|
+
set: function(t) {
|
|
214
|
+
this._byteOffset = t, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._buffer.byteLength;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
), Object.defineProperty(
|
|
218
|
+
d.prototype,
|
|
219
|
+
"dataView",
|
|
220
|
+
{
|
|
221
|
+
get: function() {
|
|
222
|
+
return this._dataView;
|
|
223
|
+
},
|
|
224
|
+
set: function(t) {
|
|
225
|
+
this._byteOffset = t.byteOffset, this._buffer = t.buffer, this._dataView = new DataView(this._buffer, this._byteOffset), this._byteLength = this._byteOffset + t.byteLength;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
), d.prototype.seek = function(t) {
|
|
229
|
+
var e = Math.max(0, Math.min(this.byteLength, t));
|
|
230
|
+
this.position = isNaN(e) || !isFinite(e) ? 0 : e;
|
|
231
|
+
}, d.prototype.isEof = function() {
|
|
232
|
+
return this.position >= this._byteLength;
|
|
233
|
+
}, d.prototype.mapUint8Array = function(t) {
|
|
234
|
+
this._realloc(t * 1);
|
|
235
|
+
var e = new Uint8Array(this._buffer, this.byteOffset + this.position, t);
|
|
236
|
+
return this.position += t * 1, e;
|
|
237
|
+
}, d.prototype.readInt32Array = function(t, e) {
|
|
238
|
+
t = t ?? this.byteLength - this.position / 4;
|
|
239
|
+
var r = new Int32Array(t);
|
|
240
|
+
return d.memcpy(
|
|
241
|
+
r.buffer,
|
|
242
|
+
0,
|
|
243
|
+
this.buffer,
|
|
244
|
+
this.byteOffset + this.position,
|
|
245
|
+
t * r.BYTES_PER_ELEMENT
|
|
246
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
247
|
+
}, d.prototype.readInt16Array = function(t, e) {
|
|
248
|
+
t = t ?? this.byteLength - this.position / 2;
|
|
249
|
+
var r = new Int16Array(t);
|
|
250
|
+
return d.memcpy(
|
|
251
|
+
r.buffer,
|
|
252
|
+
0,
|
|
253
|
+
this.buffer,
|
|
254
|
+
this.byteOffset + this.position,
|
|
255
|
+
t * r.BYTES_PER_ELEMENT
|
|
256
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
257
|
+
}, d.prototype.readInt8Array = function(t) {
|
|
258
|
+
t = t ?? this.byteLength - this.position;
|
|
259
|
+
var e = new Int8Array(t);
|
|
260
|
+
return d.memcpy(
|
|
261
|
+
e.buffer,
|
|
262
|
+
0,
|
|
263
|
+
this.buffer,
|
|
264
|
+
this.byteOffset + this.position,
|
|
265
|
+
t * e.BYTES_PER_ELEMENT
|
|
266
|
+
), this.position += e.byteLength, e;
|
|
267
|
+
}, d.prototype.readUint32Array = function(t, e) {
|
|
268
|
+
t = t ?? this.byteLength - this.position / 4;
|
|
269
|
+
var r = new Uint32Array(t);
|
|
270
|
+
return d.memcpy(
|
|
271
|
+
r.buffer,
|
|
272
|
+
0,
|
|
273
|
+
this.buffer,
|
|
274
|
+
this.byteOffset + this.position,
|
|
275
|
+
t * r.BYTES_PER_ELEMENT
|
|
276
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
277
|
+
}, d.prototype.readUint16Array = function(t, e) {
|
|
278
|
+
t = t ?? this.byteLength - this.position / 2;
|
|
279
|
+
var r = new Uint16Array(t);
|
|
280
|
+
return d.memcpy(
|
|
281
|
+
r.buffer,
|
|
282
|
+
0,
|
|
283
|
+
this.buffer,
|
|
284
|
+
this.byteOffset + this.position,
|
|
285
|
+
t * r.BYTES_PER_ELEMENT
|
|
286
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
287
|
+
}, d.prototype.readUint8Array = function(t) {
|
|
288
|
+
t = t ?? this.byteLength - this.position;
|
|
289
|
+
var e = new Uint8Array(t);
|
|
290
|
+
return d.memcpy(
|
|
291
|
+
e.buffer,
|
|
292
|
+
0,
|
|
293
|
+
this.buffer,
|
|
294
|
+
this.byteOffset + this.position,
|
|
295
|
+
t * e.BYTES_PER_ELEMENT
|
|
296
|
+
), this.position += e.byteLength, e;
|
|
297
|
+
}, d.prototype.readFloat64Array = function(t, e) {
|
|
298
|
+
t = t ?? this.byteLength - this.position / 8;
|
|
299
|
+
var r = new Float64Array(t);
|
|
300
|
+
return d.memcpy(
|
|
301
|
+
r.buffer,
|
|
302
|
+
0,
|
|
303
|
+
this.buffer,
|
|
304
|
+
this.byteOffset + this.position,
|
|
305
|
+
t * r.BYTES_PER_ELEMENT
|
|
306
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
307
|
+
}, d.prototype.readFloat32Array = function(t, e) {
|
|
308
|
+
t = t ?? this.byteLength - this.position / 4;
|
|
309
|
+
var r = new Float32Array(t);
|
|
310
|
+
return d.memcpy(
|
|
311
|
+
r.buffer,
|
|
312
|
+
0,
|
|
313
|
+
this.buffer,
|
|
314
|
+
this.byteOffset + this.position,
|
|
315
|
+
t * r.BYTES_PER_ELEMENT
|
|
316
|
+
), d.arrayToNative(r, e ?? this.endianness), this.position += r.byteLength, r;
|
|
317
|
+
}, d.prototype.readInt32 = function(t) {
|
|
318
|
+
var e = this._dataView.getInt32(this.position, t ?? this.endianness);
|
|
319
|
+
return this.position += 4, e;
|
|
320
|
+
}, d.prototype.readInt16 = function(t) {
|
|
321
|
+
var e = this._dataView.getInt16(this.position, t ?? this.endianness);
|
|
322
|
+
return this.position += 2, e;
|
|
323
|
+
}, d.prototype.readInt8 = function() {
|
|
324
|
+
var t = this._dataView.getInt8(this.position);
|
|
325
|
+
return this.position += 1, t;
|
|
326
|
+
}, d.prototype.readUint32 = function(t) {
|
|
327
|
+
var e = this._dataView.getUint32(this.position, t ?? this.endianness);
|
|
328
|
+
return this.position += 4, e;
|
|
329
|
+
}, d.prototype.readUint16 = function(t) {
|
|
330
|
+
var e = this._dataView.getUint16(this.position, t ?? this.endianness);
|
|
331
|
+
return this.position += 2, e;
|
|
332
|
+
}, d.prototype.readUint8 = function() {
|
|
333
|
+
var t = this._dataView.getUint8(this.position);
|
|
334
|
+
return this.position += 1, t;
|
|
335
|
+
}, d.prototype.readFloat32 = function(t) {
|
|
336
|
+
var e = this._dataView.getFloat32(this.position, t ?? this.endianness);
|
|
337
|
+
return this.position += 4, e;
|
|
338
|
+
}, d.prototype.readFloat64 = function(t) {
|
|
339
|
+
var e = this._dataView.getFloat64(this.position, t ?? this.endianness);
|
|
340
|
+
return this.position += 8, e;
|
|
341
|
+
}, d.endianness = new Int8Array(new Int16Array([1]).buffer)[0] > 0, d.memcpy = function(t, e, r, n, o) {
|
|
342
|
+
var a = new Uint8Array(t, e, o), h = new Uint8Array(r, n, o);
|
|
343
|
+
a.set(h);
|
|
344
|
+
}, d.arrayToNative = function(t, e) {
|
|
345
|
+
return e == this.endianness ? t : this.flipArrayEndianness(t);
|
|
346
|
+
}, d.nativeToEndian = function(t, e) {
|
|
347
|
+
return this.endianness == e ? t : this.flipArrayEndianness(t);
|
|
348
|
+
}, d.flipArrayEndianness = function(t) {
|
|
349
|
+
for (var e = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), r = 0; r < t.byteLength; r += t.BYTES_PER_ELEMENT)
|
|
350
|
+
for (var n = r + t.BYTES_PER_ELEMENT - 1, o = r; n > o; n--, o++) {
|
|
351
|
+
var a = e[o];
|
|
352
|
+
e[o] = e[n], e[n] = a;
|
|
353
|
+
}
|
|
354
|
+
return t;
|
|
355
|
+
}, d.prototype.failurePosition = 0, String.fromCharCodeUint8 = function(t) {
|
|
356
|
+
for (var e = [], r = 0; r < t.length; r++)
|
|
357
|
+
e[r] = t[r];
|
|
358
|
+
return String.fromCharCode.apply(null, e);
|
|
359
|
+
}, d.prototype.readString = function(t, e) {
|
|
360
|
+
return e == null || e == "ASCII" ? String.fromCharCodeUint8.apply(null, [this.mapUint8Array(t ?? this.byteLength - this.position)]) : new TextDecoder(e).decode(this.mapUint8Array(t));
|
|
361
|
+
}, d.prototype.readCString = function(t) {
|
|
362
|
+
var e = this.byteLength - this.position, r = new Uint8Array(this._buffer, this._byteOffset + this.position), n = e;
|
|
363
|
+
t != null && (n = Math.min(t, e));
|
|
364
|
+
for (var o = 0; o < n && r[o] !== 0; o++) ;
|
|
365
|
+
var a = String.fromCharCodeUint8.apply(null, [this.mapUint8Array(o)]);
|
|
366
|
+
return t != null ? this.position += n - o : o != e && (this.position += 1), a;
|
|
367
|
+
};
|
|
368
|
+
var b = Math.pow(2, 32);
|
|
369
|
+
d.prototype.readInt64 = function() {
|
|
370
|
+
return this.readInt32() * b + this.readUint32();
|
|
371
|
+
}, d.prototype.readUint64 = function() {
|
|
372
|
+
return this.readUint32() * b + this.readUint32();
|
|
373
|
+
}, d.prototype.readInt64 = function() {
|
|
374
|
+
return this.readUint32() * b + this.readUint32();
|
|
375
|
+
}, d.prototype.readUint24 = function() {
|
|
376
|
+
return (this.readUint8() << 16) + (this.readUint8() << 8) + this.readUint8();
|
|
377
|
+
}, v.DataStream = d, d.prototype.save = function(t) {
|
|
378
|
+
var e = new Blob([this.buffer]);
|
|
379
|
+
if (window.URL && URL.createObjectURL) {
|
|
380
|
+
var r = window.URL.createObjectURL(e), n = document.createElement("a");
|
|
381
|
+
document.body.appendChild(n), n.setAttribute("href", r), n.setAttribute("download", t), n.setAttribute("target", "_self"), n.click(), window.URL.revokeObjectURL(r);
|
|
382
|
+
} else
|
|
383
|
+
throw "DataStream.save: Can't create object URL.";
|
|
384
|
+
}, d.prototype._dynamicSize = !0, Object.defineProperty(
|
|
385
|
+
d.prototype,
|
|
386
|
+
"dynamicSize",
|
|
387
|
+
{
|
|
388
|
+
get: function() {
|
|
389
|
+
return this._dynamicSize;
|
|
390
|
+
},
|
|
391
|
+
set: function(t) {
|
|
392
|
+
t || this._trimAlloc(), this._dynamicSize = t;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
), d.prototype.shift = function(t) {
|
|
396
|
+
var e = new ArrayBuffer(this._byteLength - t), r = new Uint8Array(e), n = new Uint8Array(this._buffer, t, r.length);
|
|
397
|
+
r.set(n), this.buffer = e, this.position -= t;
|
|
398
|
+
}, d.prototype.writeInt32Array = function(t, e) {
|
|
399
|
+
if (this._realloc(t.length * 4), t instanceof Int32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
400
|
+
d.memcpy(
|
|
401
|
+
this._buffer,
|
|
402
|
+
this.byteOffset + this.position,
|
|
403
|
+
t.buffer,
|
|
404
|
+
0,
|
|
405
|
+
t.byteLength
|
|
406
|
+
), this.mapInt32Array(t.length, e);
|
|
407
|
+
else
|
|
408
|
+
for (var r = 0; r < t.length; r++)
|
|
409
|
+
this.writeInt32(t[r], e);
|
|
410
|
+
}, d.prototype.writeInt16Array = function(t, e) {
|
|
411
|
+
if (this._realloc(t.length * 2), t instanceof Int16Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
412
|
+
d.memcpy(
|
|
413
|
+
this._buffer,
|
|
414
|
+
this.byteOffset + this.position,
|
|
415
|
+
t.buffer,
|
|
416
|
+
0,
|
|
417
|
+
t.byteLength
|
|
418
|
+
), this.mapInt16Array(t.length, e);
|
|
419
|
+
else
|
|
420
|
+
for (var r = 0; r < t.length; r++)
|
|
421
|
+
this.writeInt16(t[r], e);
|
|
422
|
+
}, d.prototype.writeInt8Array = function(t) {
|
|
423
|
+
if (this._realloc(t.length * 1), t instanceof Int8Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
424
|
+
d.memcpy(
|
|
425
|
+
this._buffer,
|
|
426
|
+
this.byteOffset + this.position,
|
|
427
|
+
t.buffer,
|
|
428
|
+
0,
|
|
429
|
+
t.byteLength
|
|
430
|
+
), this.mapInt8Array(t.length);
|
|
431
|
+
else
|
|
432
|
+
for (var e = 0; e < t.length; e++)
|
|
433
|
+
this.writeInt8(t[e]);
|
|
434
|
+
}, d.prototype.writeUint32Array = function(t, e) {
|
|
435
|
+
if (this._realloc(t.length * 4), t instanceof Uint32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
436
|
+
d.memcpy(
|
|
437
|
+
this._buffer,
|
|
438
|
+
this.byteOffset + this.position,
|
|
439
|
+
t.buffer,
|
|
440
|
+
0,
|
|
441
|
+
t.byteLength
|
|
442
|
+
), this.mapUint32Array(t.length, e);
|
|
443
|
+
else
|
|
444
|
+
for (var r = 0; r < t.length; r++)
|
|
445
|
+
this.writeUint32(t[r], e);
|
|
446
|
+
}, d.prototype.writeUint16Array = function(t, e) {
|
|
447
|
+
if (this._realloc(t.length * 2), t instanceof Uint16Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
448
|
+
d.memcpy(
|
|
449
|
+
this._buffer,
|
|
450
|
+
this.byteOffset + this.position,
|
|
451
|
+
t.buffer,
|
|
452
|
+
0,
|
|
453
|
+
t.byteLength
|
|
454
|
+
), this.mapUint16Array(t.length, e);
|
|
455
|
+
else
|
|
456
|
+
for (var r = 0; r < t.length; r++)
|
|
457
|
+
this.writeUint16(t[r], e);
|
|
458
|
+
}, d.prototype.writeUint8Array = function(t) {
|
|
459
|
+
if (this._realloc(t.length * 1), t instanceof Uint8Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
460
|
+
d.memcpy(
|
|
461
|
+
this._buffer,
|
|
462
|
+
this.byteOffset + this.position,
|
|
463
|
+
t.buffer,
|
|
464
|
+
0,
|
|
465
|
+
t.byteLength
|
|
466
|
+
), this.mapUint8Array(t.length);
|
|
467
|
+
else
|
|
468
|
+
for (var e = 0; e < t.length; e++)
|
|
469
|
+
this.writeUint8(t[e]);
|
|
470
|
+
}, d.prototype.writeFloat64Array = function(t, e) {
|
|
471
|
+
if (this._realloc(t.length * 8), t instanceof Float64Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
472
|
+
d.memcpy(
|
|
473
|
+
this._buffer,
|
|
474
|
+
this.byteOffset + this.position,
|
|
475
|
+
t.buffer,
|
|
476
|
+
0,
|
|
477
|
+
t.byteLength
|
|
478
|
+
), this.mapFloat64Array(t.length, e);
|
|
479
|
+
else
|
|
480
|
+
for (var r = 0; r < t.length; r++)
|
|
481
|
+
this.writeFloat64(t[r], e);
|
|
482
|
+
}, d.prototype.writeFloat32Array = function(t, e) {
|
|
483
|
+
if (this._realloc(t.length * 4), t instanceof Float32Array && this.byteOffset + this.position % t.BYTES_PER_ELEMENT === 0)
|
|
484
|
+
d.memcpy(
|
|
485
|
+
this._buffer,
|
|
486
|
+
this.byteOffset + this.position,
|
|
487
|
+
t.buffer,
|
|
488
|
+
0,
|
|
489
|
+
t.byteLength
|
|
490
|
+
), this.mapFloat32Array(t.length, e);
|
|
491
|
+
else
|
|
492
|
+
for (var r = 0; r < t.length; r++)
|
|
493
|
+
this.writeFloat32(t[r], e);
|
|
494
|
+
}, d.prototype.writeInt32 = function(t, e) {
|
|
495
|
+
this._realloc(4), this._dataView.setInt32(this.position, t, e ?? this.endianness), this.position += 4;
|
|
496
|
+
}, d.prototype.writeInt16 = function(t, e) {
|
|
497
|
+
this._realloc(2), this._dataView.setInt16(this.position, t, e ?? this.endianness), this.position += 2;
|
|
498
|
+
}, d.prototype.writeInt8 = function(t) {
|
|
499
|
+
this._realloc(1), this._dataView.setInt8(this.position, t), this.position += 1;
|
|
500
|
+
}, d.prototype.writeUint32 = function(t, e) {
|
|
501
|
+
this._realloc(4), this._dataView.setUint32(this.position, t, e ?? this.endianness), this.position += 4;
|
|
502
|
+
}, d.prototype.writeUint16 = function(t, e) {
|
|
503
|
+
this._realloc(2), this._dataView.setUint16(this.position, t, e ?? this.endianness), this.position += 2;
|
|
504
|
+
}, d.prototype.writeUint8 = function(t) {
|
|
505
|
+
this._realloc(1), this._dataView.setUint8(this.position, t), this.position += 1;
|
|
506
|
+
}, d.prototype.writeFloat32 = function(t, e) {
|
|
507
|
+
this._realloc(4), this._dataView.setFloat32(this.position, t, e ?? this.endianness), this.position += 4;
|
|
508
|
+
}, d.prototype.writeFloat64 = function(t, e) {
|
|
509
|
+
this._realloc(8), this._dataView.setFloat64(this.position, t, e ?? this.endianness), this.position += 8;
|
|
510
|
+
}, d.prototype.writeUCS2String = function(t, e, r) {
|
|
511
|
+
r == null && (r = t.length);
|
|
512
|
+
for (var n = 0; n < t.length && n < r; n++)
|
|
513
|
+
this.writeUint16(t.charCodeAt(n), e);
|
|
514
|
+
for (; n < r; n++)
|
|
515
|
+
this.writeUint16(0);
|
|
516
|
+
}, d.prototype.writeString = function(t, e, r) {
|
|
517
|
+
var n = 0;
|
|
518
|
+
if (e == null || e == "ASCII")
|
|
519
|
+
if (r != null) {
|
|
520
|
+
var o = Math.min(t.length, r);
|
|
521
|
+
for (n = 0; n < o; n++)
|
|
522
|
+
this.writeUint8(t.charCodeAt(n));
|
|
523
|
+
for (; n < r; n++)
|
|
524
|
+
this.writeUint8(0);
|
|
525
|
+
} else
|
|
526
|
+
for (n = 0; n < t.length; n++)
|
|
527
|
+
this.writeUint8(t.charCodeAt(n));
|
|
528
|
+
else
|
|
529
|
+
this.writeUint8Array(new TextEncoder(e).encode(t.substring(0, r)));
|
|
530
|
+
}, d.prototype.writeCString = function(t, e) {
|
|
531
|
+
var r = 0;
|
|
532
|
+
if (e != null) {
|
|
533
|
+
var n = Math.min(t.length, e);
|
|
534
|
+
for (r = 0; r < n; r++)
|
|
535
|
+
this.writeUint8(t.charCodeAt(r));
|
|
536
|
+
for (; r < e; r++)
|
|
537
|
+
this.writeUint8(0);
|
|
538
|
+
} else {
|
|
539
|
+
for (r = 0; r < t.length; r++)
|
|
540
|
+
this.writeUint8(t.charCodeAt(r));
|
|
541
|
+
this.writeUint8(0);
|
|
542
|
+
}
|
|
543
|
+
}, d.prototype.writeStruct = function(t, e) {
|
|
544
|
+
for (var r = 0; r < t.length; r += 2) {
|
|
545
|
+
var n = t[r + 1];
|
|
546
|
+
this.writeType(n, e[t[r]], e);
|
|
547
|
+
}
|
|
548
|
+
}, d.prototype.writeType = function(t, e, r) {
|
|
549
|
+
var n;
|
|
550
|
+
if (typeof t == "function")
|
|
551
|
+
return t(this, e);
|
|
552
|
+
if (typeof t == "object" && !(t instanceof Array))
|
|
553
|
+
return t.set(this, e, r);
|
|
554
|
+
var o = null, a = "ASCII", h = this.position;
|
|
555
|
+
switch (typeof t == "string" && /:/.test(t) && (n = t.split(":"), t = n[0], o = parseInt(n[1])), typeof t == "string" && /,/.test(t) && (n = t.split(","), t = n[0], a = parseInt(n[1])), t) {
|
|
556
|
+
case "uint8":
|
|
557
|
+
this.writeUint8(e);
|
|
558
|
+
break;
|
|
559
|
+
case "int8":
|
|
560
|
+
this.writeInt8(e);
|
|
561
|
+
break;
|
|
562
|
+
case "uint16":
|
|
563
|
+
this.writeUint16(e, this.endianness);
|
|
564
|
+
break;
|
|
565
|
+
case "int16":
|
|
566
|
+
this.writeInt16(e, this.endianness);
|
|
567
|
+
break;
|
|
568
|
+
case "uint32":
|
|
569
|
+
this.writeUint32(e, this.endianness);
|
|
570
|
+
break;
|
|
571
|
+
case "int32":
|
|
572
|
+
this.writeInt32(e, this.endianness);
|
|
573
|
+
break;
|
|
574
|
+
case "float32":
|
|
575
|
+
this.writeFloat32(e, this.endianness);
|
|
576
|
+
break;
|
|
577
|
+
case "float64":
|
|
578
|
+
this.writeFloat64(e, this.endianness);
|
|
579
|
+
break;
|
|
580
|
+
case "uint16be":
|
|
581
|
+
this.writeUint16(e, d.BIG_ENDIAN);
|
|
582
|
+
break;
|
|
583
|
+
case "int16be":
|
|
584
|
+
this.writeInt16(e, d.BIG_ENDIAN);
|
|
585
|
+
break;
|
|
586
|
+
case "uint32be":
|
|
587
|
+
this.writeUint32(e, d.BIG_ENDIAN);
|
|
588
|
+
break;
|
|
589
|
+
case "int32be":
|
|
590
|
+
this.writeInt32(e, d.BIG_ENDIAN);
|
|
591
|
+
break;
|
|
592
|
+
case "float32be":
|
|
593
|
+
this.writeFloat32(e, d.BIG_ENDIAN);
|
|
594
|
+
break;
|
|
595
|
+
case "float64be":
|
|
596
|
+
this.writeFloat64(e, d.BIG_ENDIAN);
|
|
597
|
+
break;
|
|
598
|
+
case "uint16le":
|
|
599
|
+
this.writeUint16(e, d.LITTLE_ENDIAN);
|
|
600
|
+
break;
|
|
601
|
+
case "int16le":
|
|
602
|
+
this.writeInt16(e, d.LITTLE_ENDIAN);
|
|
603
|
+
break;
|
|
604
|
+
case "uint32le":
|
|
605
|
+
this.writeUint32(e, d.LITTLE_ENDIAN);
|
|
606
|
+
break;
|
|
607
|
+
case "int32le":
|
|
608
|
+
this.writeInt32(e, d.LITTLE_ENDIAN);
|
|
609
|
+
break;
|
|
610
|
+
case "float32le":
|
|
611
|
+
this.writeFloat32(e, d.LITTLE_ENDIAN);
|
|
612
|
+
break;
|
|
613
|
+
case "float64le":
|
|
614
|
+
this.writeFloat64(e, d.LITTLE_ENDIAN);
|
|
615
|
+
break;
|
|
616
|
+
case "cstring":
|
|
617
|
+
this.writeCString(e, o);
|
|
618
|
+
break;
|
|
619
|
+
case "string":
|
|
620
|
+
this.writeString(e, a, o);
|
|
621
|
+
break;
|
|
622
|
+
case "u16string":
|
|
623
|
+
this.writeUCS2String(e, this.endianness, o);
|
|
624
|
+
break;
|
|
625
|
+
case "u16stringle":
|
|
626
|
+
this.writeUCS2String(e, d.LITTLE_ENDIAN, o);
|
|
627
|
+
break;
|
|
628
|
+
case "u16stringbe":
|
|
629
|
+
this.writeUCS2String(e, d.BIG_ENDIAN, o);
|
|
630
|
+
break;
|
|
631
|
+
default:
|
|
632
|
+
if (t.length == 3) {
|
|
633
|
+
for (var f = t[1], p = 0; p < e.length; p++)
|
|
634
|
+
this.writeType(f, e[p]);
|
|
635
|
+
break;
|
|
636
|
+
} else {
|
|
637
|
+
this.writeStruct(t, e);
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
o != null && (this.position = h, this._realloc(o), this.position = h + o);
|
|
642
|
+
}, d.prototype.writeUint64 = function(t) {
|
|
643
|
+
var e = Math.floor(t / b);
|
|
644
|
+
this.writeUint32(e), this.writeUint32(t & 4294967295);
|
|
645
|
+
}, d.prototype.writeUint24 = function(t) {
|
|
646
|
+
this.writeUint8((t & 16711680) >> 16), this.writeUint8((t & 65280) >> 8), this.writeUint8(t & 255);
|
|
647
|
+
}, d.prototype.adjustUint32 = function(t, e) {
|
|
648
|
+
var r = this.position;
|
|
649
|
+
this.seek(t), this.writeUint32(e), this.seek(r);
|
|
650
|
+
}, d.prototype.mapInt32Array = function(t, e) {
|
|
651
|
+
this._realloc(t * 4);
|
|
652
|
+
var r = new Int32Array(this._buffer, this.byteOffset + this.position, t);
|
|
653
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 4, r;
|
|
654
|
+
}, d.prototype.mapInt16Array = function(t, e) {
|
|
655
|
+
this._realloc(t * 2);
|
|
656
|
+
var r = new Int16Array(this._buffer, this.byteOffset + this.position, t);
|
|
657
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 2, r;
|
|
658
|
+
}, d.prototype.mapInt8Array = function(t) {
|
|
659
|
+
this._realloc(t * 1);
|
|
660
|
+
var e = new Int8Array(this._buffer, this.byteOffset + this.position, t);
|
|
661
|
+
return this.position += t * 1, e;
|
|
662
|
+
}, d.prototype.mapUint32Array = function(t, e) {
|
|
663
|
+
this._realloc(t * 4);
|
|
664
|
+
var r = new Uint32Array(this._buffer, this.byteOffset + this.position, t);
|
|
665
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 4, r;
|
|
666
|
+
}, d.prototype.mapUint16Array = function(t, e) {
|
|
667
|
+
this._realloc(t * 2);
|
|
668
|
+
var r = new Uint16Array(this._buffer, this.byteOffset + this.position, t);
|
|
669
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 2, r;
|
|
670
|
+
}, d.prototype.mapFloat64Array = function(t, e) {
|
|
671
|
+
this._realloc(t * 8);
|
|
672
|
+
var r = new Float64Array(this._buffer, this.byteOffset + this.position, t);
|
|
673
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 8, r;
|
|
674
|
+
}, d.prototype.mapFloat32Array = function(t, e) {
|
|
675
|
+
this._realloc(t * 4);
|
|
676
|
+
var r = new Float32Array(this._buffer, this.byteOffset + this.position, t);
|
|
677
|
+
return d.arrayToNative(r, e ?? this.endianness), this.position += t * 4, r;
|
|
678
|
+
};
|
|
679
|
+
var S = function(t) {
|
|
680
|
+
this.buffers = [], this.bufferIndex = -1, t && (this.insertBuffer(t), this.bufferIndex = 0);
|
|
681
|
+
};
|
|
682
|
+
S.prototype = new d(new ArrayBuffer(), 0, d.BIG_ENDIAN), S.prototype.initialized = function() {
|
|
683
|
+
var t;
|
|
684
|
+
return this.bufferIndex > -1 ? !0 : this.buffers.length > 0 ? (t = this.buffers[0], t.fileStart === 0 ? (this.buffer = t, this.bufferIndex = 0, l.debug("MultiBufferStream", "Stream ready for parsing"), !0) : (l.warn("MultiBufferStream", "The first buffer should have a fileStart of 0"), this.logBufferLevel(), !1)) : (l.warn("MultiBufferStream", "No buffer to start parsing from"), this.logBufferLevel(), !1);
|
|
685
|
+
}, ArrayBuffer.concat = function(t, e) {
|
|
686
|
+
l.debug("ArrayBuffer", "Trying to create a new buffer of size: " + (t.byteLength + e.byteLength));
|
|
687
|
+
var r = new Uint8Array(t.byteLength + e.byteLength);
|
|
688
|
+
return r.set(new Uint8Array(t), 0), r.set(new Uint8Array(e), t.byteLength), r.buffer;
|
|
689
|
+
}, S.prototype.reduceBuffer = function(t, e, r) {
|
|
690
|
+
var n;
|
|
691
|
+
return n = new Uint8Array(r), n.set(new Uint8Array(t, e, r)), n.buffer.fileStart = t.fileStart + e, n.buffer.usedBytes = 0, n.buffer;
|
|
692
|
+
}, S.prototype.insertBuffer = function(t) {
|
|
693
|
+
for (var e = !0, r = 0; r < this.buffers.length; r++) {
|
|
694
|
+
var n = this.buffers[r];
|
|
695
|
+
if (t.fileStart <= n.fileStart) {
|
|
696
|
+
if (t.fileStart === n.fileStart)
|
|
697
|
+
if (t.byteLength > n.byteLength) {
|
|
698
|
+
this.buffers.splice(r, 1), r--;
|
|
699
|
+
continue;
|
|
700
|
+
} else
|
|
701
|
+
l.warn("MultiBufferStream", "Buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ") already appended, ignoring");
|
|
702
|
+
else
|
|
703
|
+
t.fileStart + t.byteLength <= n.fileStart || (t = this.reduceBuffer(t, 0, n.fileStart - t.fileStart)), l.debug("MultiBufferStream", "Appending new buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ")"), this.buffers.splice(r, 0, t), r === 0 && (this.buffer = t);
|
|
704
|
+
e = !1;
|
|
705
|
+
break;
|
|
706
|
+
} else if (t.fileStart < n.fileStart + n.byteLength) {
|
|
707
|
+
var o = n.fileStart + n.byteLength - t.fileStart, a = t.byteLength - o;
|
|
708
|
+
if (a > 0)
|
|
709
|
+
t = this.reduceBuffer(t, o, a);
|
|
710
|
+
else {
|
|
711
|
+
e = !1;
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
e && (l.debug("MultiBufferStream", "Appending new buffer (fileStart: " + t.fileStart + " - Length: " + t.byteLength + ")"), this.buffers.push(t), r === 0 && (this.buffer = t));
|
|
717
|
+
}, S.prototype.logBufferLevel = function(t) {
|
|
718
|
+
var e, r, n, o, a = [], h, f = "";
|
|
719
|
+
for (n = 0, o = 0, e = 0; e < this.buffers.length; e++)
|
|
720
|
+
r = this.buffers[e], e === 0 ? (h = {}, a.push(h), h.start = r.fileStart, h.end = r.fileStart + r.byteLength, f += "[" + h.start + "-") : h.end === r.fileStart ? h.end = r.fileStart + r.byteLength : (h = {}, h.start = r.fileStart, f += a[a.length - 1].end - 1 + "], [" + h.start + "-", h.end = r.fileStart + r.byteLength, a.push(h)), n += r.usedBytes, o += r.byteLength;
|
|
721
|
+
a.length > 0 && (f += h.end - 1 + "]");
|
|
722
|
+
var p = t ? l.info : l.debug;
|
|
723
|
+
this.buffers.length === 0 ? p("MultiBufferStream", "No more buffer in memory") : p("MultiBufferStream", "" + this.buffers.length + " stored buffer(s) (" + n + "/" + o + " bytes), continuous ranges: " + f);
|
|
724
|
+
}, S.prototype.cleanBuffers = function() {
|
|
725
|
+
var t, e;
|
|
726
|
+
for (t = 0; t < this.buffers.length; t++)
|
|
727
|
+
e = this.buffers[t], e.usedBytes === e.byteLength && (l.debug("MultiBufferStream", "Removing buffer #" + t), this.buffers.splice(t, 1), t--);
|
|
728
|
+
}, S.prototype.mergeNextBuffer = function() {
|
|
729
|
+
var t;
|
|
730
|
+
if (this.bufferIndex + 1 < this.buffers.length)
|
|
731
|
+
if (t = this.buffers[this.bufferIndex + 1], t.fileStart === this.buffer.fileStart + this.buffer.byteLength) {
|
|
732
|
+
var e = this.buffer.byteLength, r = this.buffer.usedBytes, n = this.buffer.fileStart;
|
|
733
|
+
return this.buffers[this.bufferIndex] = ArrayBuffer.concat(this.buffer, t), this.buffer = this.buffers[this.bufferIndex], this.buffers.splice(this.bufferIndex + 1, 1), this.buffer.usedBytes = r, this.buffer.fileStart = n, l.debug("ISOFile", "Concatenating buffer for box parsing (length: " + e + "->" + this.buffer.byteLength + ")"), !0;
|
|
734
|
+
} else
|
|
735
|
+
return !1;
|
|
736
|
+
else
|
|
737
|
+
return !1;
|
|
738
|
+
}, S.prototype.findPosition = function(t, e, r) {
|
|
739
|
+
var n, o = null, a = -1;
|
|
740
|
+
for (t === !0 ? n = 0 : n = this.bufferIndex; n < this.buffers.length && (o = this.buffers[n], o.fileStart <= e); ) {
|
|
741
|
+
a = n, r && (o.fileStart + o.byteLength <= e ? o.usedBytes = o.byteLength : o.usedBytes = e - o.fileStart, this.logBufferLevel());
|
|
742
|
+
n++;
|
|
743
|
+
}
|
|
744
|
+
return a !== -1 ? (o = this.buffers[a], o.fileStart + o.byteLength >= e ? (l.debug("MultiBufferStream", "Found position in existing buffer #" + a), a) : -1) : -1;
|
|
745
|
+
}, S.prototype.findEndContiguousBuf = function(t) {
|
|
746
|
+
var e, r, n, o = t !== void 0 ? t : this.bufferIndex;
|
|
747
|
+
if (r = this.buffers[o], this.buffers.length > o + 1)
|
|
748
|
+
for (e = o + 1; e < this.buffers.length && (n = this.buffers[e], n.fileStart === r.fileStart + r.byteLength); e++)
|
|
749
|
+
r = n;
|
|
750
|
+
return r.fileStart + r.byteLength;
|
|
751
|
+
}, S.prototype.getEndFilePositionAfter = function(t) {
|
|
752
|
+
var e = this.findPosition(!0, t, !1);
|
|
753
|
+
return e !== -1 ? this.findEndContiguousBuf(e) : t;
|
|
754
|
+
}, S.prototype.addUsedBytes = function(t) {
|
|
755
|
+
this.buffer.usedBytes += t, this.logBufferLevel();
|
|
756
|
+
}, S.prototype.setAllUsedBytes = function() {
|
|
757
|
+
this.buffer.usedBytes = this.buffer.byteLength, this.logBufferLevel();
|
|
758
|
+
}, S.prototype.seek = function(t, e, r) {
|
|
759
|
+
var n;
|
|
760
|
+
return n = this.findPosition(e, t, r), n !== -1 ? (this.buffer = this.buffers[n], this.bufferIndex = n, this.position = t - this.buffer.fileStart, l.debug("MultiBufferStream", "Repositioning parser at buffer position: " + this.position), !0) : (l.debug("MultiBufferStream", "Position " + t + " not found in buffered data"), !1);
|
|
761
|
+
}, S.prototype.getPosition = function() {
|
|
762
|
+
if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null)
|
|
763
|
+
throw "Error accessing position in the MultiBufferStream";
|
|
764
|
+
return this.buffers[this.bufferIndex].fileStart + this.position;
|
|
765
|
+
}, S.prototype.getLength = function() {
|
|
766
|
+
return this.byteLength;
|
|
767
|
+
}, S.prototype.getEndPosition = function() {
|
|
768
|
+
if (this.bufferIndex === -1 || this.buffers[this.bufferIndex] === null)
|
|
769
|
+
throw "Error accessing position in the MultiBufferStream";
|
|
770
|
+
return this.buffers[this.bufferIndex].fileStart + this.byteLength;
|
|
771
|
+
}, v.MultiBufferStream = S;
|
|
772
|
+
var B = function() {
|
|
773
|
+
var t = 3, e = 4, r = 5, n = 6, o = [];
|
|
774
|
+
o[t] = "ES_Descriptor", o[e] = "DecoderConfigDescriptor", o[r] = "DecoderSpecificInfo", o[n] = "SLConfigDescriptor", this.getDescriptorName = function(f) {
|
|
775
|
+
return o[f];
|
|
776
|
+
};
|
|
777
|
+
var a = this, h = {};
|
|
778
|
+
return this.parseOneDescriptor = function(f) {
|
|
779
|
+
var p = 0, u, c, g;
|
|
780
|
+
for (u = f.readUint8(), g = f.readUint8(); g & 128; )
|
|
781
|
+
p = (p << 7) + (g & 127), g = f.readUint8();
|
|
782
|
+
return p = (p << 7) + (g & 127), l.debug("MPEG4DescriptorParser", "Found " + (o[u] || "Descriptor " + u) + ", size " + p + " at position " + f.getPosition()), o[u] ? c = new h[o[u]](p) : c = new h.Descriptor(p), c.parse(f), c;
|
|
783
|
+
}, h.Descriptor = function(f, p) {
|
|
784
|
+
this.tag = f, this.size = p, this.descs = [];
|
|
785
|
+
}, h.Descriptor.prototype.parse = function(f) {
|
|
786
|
+
this.data = f.readUint8Array(this.size);
|
|
787
|
+
}, h.Descriptor.prototype.findDescriptor = function(f) {
|
|
788
|
+
for (var p = 0; p < this.descs.length; p++)
|
|
789
|
+
if (this.descs[p].tag == f)
|
|
790
|
+
return this.descs[p];
|
|
791
|
+
return null;
|
|
792
|
+
}, h.Descriptor.prototype.parseRemainingDescriptors = function(f) {
|
|
793
|
+
for (var p = f.position; f.position < p + this.size; ) {
|
|
794
|
+
var u = a.parseOneDescriptor(f);
|
|
795
|
+
this.descs.push(u);
|
|
796
|
+
}
|
|
797
|
+
}, h.ES_Descriptor = function(f) {
|
|
798
|
+
h.Descriptor.call(this, t, f);
|
|
799
|
+
}, h.ES_Descriptor.prototype = new h.Descriptor(), h.ES_Descriptor.prototype.parse = function(f) {
|
|
800
|
+
if (this.ES_ID = f.readUint16(), this.flags = f.readUint8(), this.size -= 3, this.flags & 128 ? (this.dependsOn_ES_ID = f.readUint16(), this.size -= 2) : this.dependsOn_ES_ID = 0, this.flags & 64) {
|
|
801
|
+
var p = f.readUint8();
|
|
802
|
+
this.URL = f.readString(p), this.size -= p + 1;
|
|
803
|
+
} else
|
|
804
|
+
this.URL = "";
|
|
805
|
+
this.flags & 32 ? (this.OCR_ES_ID = f.readUint16(), this.size -= 2) : this.OCR_ES_ID = 0, this.parseRemainingDescriptors(f);
|
|
806
|
+
}, h.ES_Descriptor.prototype.getOTI = function(f) {
|
|
807
|
+
var p = this.findDescriptor(e);
|
|
808
|
+
return p ? p.oti : 0;
|
|
809
|
+
}, h.ES_Descriptor.prototype.getAudioConfig = function(f) {
|
|
810
|
+
var p = this.findDescriptor(e);
|
|
811
|
+
if (!p) return null;
|
|
812
|
+
var u = p.findDescriptor(r);
|
|
813
|
+
if (u && u.data) {
|
|
814
|
+
var c = (u.data[0] & 248) >> 3;
|
|
815
|
+
return c === 31 && u.data.length >= 2 && (c = 32 + ((u.data[0] & 7) << 3) + ((u.data[1] & 224) >> 5)), c;
|
|
816
|
+
} else
|
|
817
|
+
return null;
|
|
818
|
+
}, h.DecoderConfigDescriptor = function(f) {
|
|
819
|
+
h.Descriptor.call(this, e, f);
|
|
820
|
+
}, h.DecoderConfigDescriptor.prototype = new h.Descriptor(), h.DecoderConfigDescriptor.prototype.parse = function(f) {
|
|
821
|
+
this.oti = f.readUint8(), this.streamType = f.readUint8(), this.upStream = (this.streamType >> 1 & 1) !== 0, this.streamType = this.streamType >>> 2, this.bufferSize = f.readUint24(), this.maxBitrate = f.readUint32(), this.avgBitrate = f.readUint32(), this.size -= 13, this.parseRemainingDescriptors(f);
|
|
822
|
+
}, h.DecoderSpecificInfo = function(f) {
|
|
823
|
+
h.Descriptor.call(this, r, f);
|
|
824
|
+
}, h.DecoderSpecificInfo.prototype = new h.Descriptor(), h.SLConfigDescriptor = function(f) {
|
|
825
|
+
h.Descriptor.call(this, n, f);
|
|
826
|
+
}, h.SLConfigDescriptor.prototype = new h.Descriptor(), this;
|
|
827
|
+
};
|
|
828
|
+
v.MPEG4DescriptorParser = B;
|
|
829
|
+
var s = {
|
|
830
|
+
ERR_INVALID_DATA: -1,
|
|
831
|
+
ERR_NOT_ENOUGH_DATA: 0,
|
|
832
|
+
OK: 1,
|
|
833
|
+
// Boxes to be created with default parsing
|
|
834
|
+
BASIC_BOXES: [
|
|
835
|
+
{ type: "mdat", name: "MediaDataBox" },
|
|
836
|
+
{ type: "idat", name: "ItemDataBox" },
|
|
837
|
+
{ type: "free", name: "FreeSpaceBox" },
|
|
838
|
+
{ type: "skip", name: "FreeSpaceBox" },
|
|
839
|
+
{ type: "meco", name: "AdditionalMetadataContainerBox" },
|
|
840
|
+
{ type: "strk", name: "SubTrackBox" }
|
|
841
|
+
],
|
|
842
|
+
FULL_BOXES: [
|
|
843
|
+
{ type: "hmhd", name: "HintMediaHeaderBox" },
|
|
844
|
+
{ type: "nmhd", name: "NullMediaHeaderBox" },
|
|
845
|
+
{ type: "iods", name: "ObjectDescriptorBox" },
|
|
846
|
+
{ type: "xml ", name: "XMLBox" },
|
|
847
|
+
{ type: "bxml", name: "BinaryXMLBox" },
|
|
848
|
+
{ type: "ipro", name: "ItemProtectionBox" },
|
|
849
|
+
{ type: "mere", name: "MetaboxRelationBox" }
|
|
850
|
+
],
|
|
851
|
+
CONTAINER_BOXES: [
|
|
852
|
+
[{ type: "moov", name: "CompressedMovieBox" }, ["trak", "pssh"]],
|
|
853
|
+
[{ type: "trak", name: "TrackBox" }],
|
|
854
|
+
[{ type: "edts", name: "EditBox" }],
|
|
855
|
+
[{ type: "mdia", name: "MediaBox" }],
|
|
856
|
+
[{ type: "minf", name: "MediaInformationBox" }],
|
|
857
|
+
[{ type: "dinf", name: "DataInformationBox" }],
|
|
858
|
+
[{ type: "stbl", name: "SampleTableBox" }, ["sgpd", "sbgp"]],
|
|
859
|
+
[{ type: "mvex", name: "MovieExtendsBox" }, ["trex"]],
|
|
860
|
+
[{ type: "moof", name: "CompressedMovieFragmentBox" }, ["traf"]],
|
|
861
|
+
[{ type: "traf", name: "TrackFragmentBox" }, ["trun", "sgpd", "sbgp"]],
|
|
862
|
+
[{ type: "vttc", name: "VTTCueBox" }],
|
|
863
|
+
[{ type: "tref", name: "TrackReferenceBox" }],
|
|
864
|
+
[{ type: "iref", name: "ItemReferenceBox" }],
|
|
865
|
+
[{ type: "mfra", name: "MovieFragmentRandomAccessBox" }, ["tfra"]],
|
|
866
|
+
[{ type: "meco", name: "AdditionalMetadataContainerBox" }],
|
|
867
|
+
[{ type: "hnti", name: "trackhintinformation" }],
|
|
868
|
+
[{ type: "hinf", name: "hintstatisticsbox" }],
|
|
869
|
+
[{ type: "strk", name: "SubTrackBox" }],
|
|
870
|
+
[{ type: "strd", name: "SubTrackDefinitionBox" }],
|
|
871
|
+
[{ type: "sinf", name: "ProtectionSchemeInfoBox" }],
|
|
872
|
+
[{ type: "rinf", name: "RestrictedSchemeInfoBox" }],
|
|
873
|
+
[{ type: "schi", name: "SchemeInformationBox" }],
|
|
874
|
+
[{ type: "trgr", name: "TrackGroupBox" }],
|
|
875
|
+
[{ type: "udta", name: "UserDataBox" }, ["kind"]],
|
|
876
|
+
[{ type: "iprp", name: "ItemPropertiesBox" }, ["ipma"]],
|
|
877
|
+
[{ type: "ipco", name: "ItemPropertyContainerBox" }],
|
|
878
|
+
[{ type: "grpl", name: "GroupsListBox" }],
|
|
879
|
+
[{ type: "j2kH", name: "J2KHeaderInfoBox" }],
|
|
880
|
+
[{ type: "etyp", name: "ExtendedTypeBox" }, ["tyco"]]
|
|
881
|
+
],
|
|
882
|
+
// Boxes effectively created
|
|
883
|
+
boxCodes: [],
|
|
884
|
+
fullBoxCodes: [],
|
|
885
|
+
containerBoxCodes: [],
|
|
886
|
+
sampleEntryCodes: {},
|
|
887
|
+
sampleGroupEntryCodes: [],
|
|
888
|
+
trackGroupTypes: [],
|
|
889
|
+
UUIDBoxes: {},
|
|
890
|
+
UUIDs: [],
|
|
891
|
+
initialize: function() {
|
|
892
|
+
s.FullBox.prototype = new s.Box(), s.ContainerBox.prototype = new s.Box(), s.SampleEntry.prototype = new s.Box(), s.TrackGroupTypeBox.prototype = new s.FullBox(), s.BASIC_BOXES.forEach(function(t) {
|
|
893
|
+
s.createBoxCtor(t.type, t.name);
|
|
894
|
+
}), s.FULL_BOXES.forEach(function(t) {
|
|
895
|
+
s.createFullBoxCtor(t.type, t.name);
|
|
896
|
+
}), s.CONTAINER_BOXES.forEach(function(t) {
|
|
897
|
+
s.createContainerBoxCtor(t[0].type, t[0].name, null, t[1]);
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
Box: function(t, e, r, n) {
|
|
901
|
+
this.type = t, this.box_name = r, this.size = e, this.uuid = n;
|
|
902
|
+
},
|
|
903
|
+
FullBox: function(t, e, r, n) {
|
|
904
|
+
s.Box.call(this, t, e, r, n), this.flags = 0, this.version = 0;
|
|
905
|
+
},
|
|
906
|
+
ContainerBox: function(t, e, r, n) {
|
|
907
|
+
s.Box.call(this, t, e, r, n), this.boxes = [];
|
|
908
|
+
},
|
|
909
|
+
SampleEntry: function(t, e, r, n) {
|
|
910
|
+
s.ContainerBox.call(this, t, e), this.hdr_size = r, this.start = n;
|
|
911
|
+
},
|
|
912
|
+
SampleGroupEntry: function(t) {
|
|
913
|
+
this.grouping_type = t;
|
|
914
|
+
},
|
|
915
|
+
TrackGroupTypeBox: function(t, e) {
|
|
916
|
+
s.FullBox.call(this, t, e);
|
|
917
|
+
},
|
|
918
|
+
createBoxCtor: function(t, e, r) {
|
|
919
|
+
s.boxCodes.push(t), s[t + "Box"] = function(n) {
|
|
920
|
+
s.Box.call(this, t, n, e);
|
|
921
|
+
}, s[t + "Box"].prototype = new s.Box(), r && (s[t + "Box"].prototype.parse = r);
|
|
922
|
+
},
|
|
923
|
+
createFullBoxCtor: function(t, e, r) {
|
|
924
|
+
s[t + "Box"] = function(n) {
|
|
925
|
+
s.FullBox.call(this, t, n, e);
|
|
926
|
+
}, s[t + "Box"].prototype = new s.FullBox(), s[t + "Box"].prototype.parse = function(n) {
|
|
927
|
+
this.parseFullHeader(n), r && r.call(this, n);
|
|
928
|
+
};
|
|
929
|
+
},
|
|
930
|
+
addSubBoxArrays: function(t) {
|
|
931
|
+
if (t) {
|
|
932
|
+
this.subBoxNames = t;
|
|
933
|
+
for (var e = t.length, r = 0; r < e; r++)
|
|
934
|
+
this[t[r] + "s"] = [];
|
|
935
|
+
}
|
|
936
|
+
},
|
|
937
|
+
createContainerBoxCtor: function(t, e, r, n) {
|
|
938
|
+
s[t + "Box"] = function(o) {
|
|
939
|
+
s.ContainerBox.call(this, t, o, e), s.addSubBoxArrays.call(this, n);
|
|
940
|
+
}, s[t + "Box"].prototype = new s.ContainerBox(), r && (s[t + "Box"].prototype.parse = r);
|
|
941
|
+
},
|
|
942
|
+
createMediaSampleEntryCtor: function(t, e, r) {
|
|
943
|
+
s.sampleEntryCodes[t] = [], s[t + "SampleEntry"] = function(n, o) {
|
|
944
|
+
s.SampleEntry.call(this, n, o), s.addSubBoxArrays.call(this, r);
|
|
945
|
+
}, s[t + "SampleEntry"].prototype = new s.SampleEntry(), e && (s[t + "SampleEntry"].prototype.parse = e);
|
|
946
|
+
},
|
|
947
|
+
createSampleEntryCtor: function(t, e, r, n) {
|
|
948
|
+
s.sampleEntryCodes[t].push(e), s[e + "SampleEntry"] = function(o) {
|
|
949
|
+
s[t + "SampleEntry"].call(this, e, o), s.addSubBoxArrays.call(this, n);
|
|
950
|
+
}, s[e + "SampleEntry"].prototype = new s[t + "SampleEntry"](), r && (s[e + "SampleEntry"].prototype.parse = r);
|
|
951
|
+
},
|
|
952
|
+
createEncryptedSampleEntryCtor: function(t, e, r) {
|
|
953
|
+
s.createSampleEntryCtor.call(this, t, e, r, ["sinf"]);
|
|
954
|
+
},
|
|
955
|
+
createSampleGroupCtor: function(t, e) {
|
|
956
|
+
s[t + "SampleGroupEntry"] = function(r) {
|
|
957
|
+
s.SampleGroupEntry.call(this, t, r);
|
|
958
|
+
}, s[t + "SampleGroupEntry"].prototype = new s.SampleGroupEntry(), e && (s[t + "SampleGroupEntry"].prototype.parse = e);
|
|
959
|
+
},
|
|
960
|
+
createTrackGroupCtor: function(t, e) {
|
|
961
|
+
s[t + "TrackGroupTypeBox"] = function(r) {
|
|
962
|
+
s.TrackGroupTypeBox.call(this, t, r);
|
|
963
|
+
}, s[t + "TrackGroupTypeBox"].prototype = new s.TrackGroupTypeBox(), e && (s[t + "TrackGroupTypeBox"].prototype.parse = e);
|
|
964
|
+
},
|
|
965
|
+
createUUIDBox: function(t, e, r, n, o) {
|
|
966
|
+
s.UUIDs.push(t), s.UUIDBoxes[t] = function(a) {
|
|
967
|
+
r ? s.FullBox.call(this, "uuid", a, e, t) : n ? s.ContainerBox.call(this, "uuid", a, e, t) : s.Box.call(this, "uuid", a, e, t);
|
|
968
|
+
}, s.UUIDBoxes[t].prototype = r ? new s.FullBox() : n ? new s.ContainerBox() : new s.Box(), o && (r ? s.UUIDBoxes[t].prototype.parse = function(a) {
|
|
969
|
+
this.parseFullHeader(a), o && o.call(this, a);
|
|
970
|
+
} : s.UUIDBoxes[t].prototype.parse = o);
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
s.initialize(), s.TKHD_FLAG_ENABLED = 1, s.TKHD_FLAG_IN_MOVIE = 2, s.TKHD_FLAG_IN_PREVIEW = 4, s.TFHD_FLAG_BASE_DATA_OFFSET = 1, s.TFHD_FLAG_SAMPLE_DESC = 2, s.TFHD_FLAG_SAMPLE_DUR = 8, s.TFHD_FLAG_SAMPLE_SIZE = 16, s.TFHD_FLAG_SAMPLE_FLAGS = 32, s.TFHD_FLAG_DUR_EMPTY = 65536, s.TFHD_FLAG_DEFAULT_BASE_IS_MOOF = 131072, s.TRUN_FLAGS_DATA_OFFSET = 1, s.TRUN_FLAGS_FIRST_FLAG = 4, s.TRUN_FLAGS_DURATION = 256, s.TRUN_FLAGS_SIZE = 512, s.TRUN_FLAGS_FLAGS = 1024, s.TRUN_FLAGS_CTS_OFFSET = 2048, s.Box.prototype.add = function(t) {
|
|
974
|
+
return this.addBox(new s[t + "Box"]());
|
|
975
|
+
}, s.Box.prototype.addBox = function(t) {
|
|
976
|
+
return this.boxes.push(t), this[t.type + "s"] ? this[t.type + "s"].push(t) : this[t.type] = t, t;
|
|
977
|
+
}, s.Box.prototype.set = function(t, e) {
|
|
978
|
+
return this[t] = e, this;
|
|
979
|
+
}, s.Box.prototype.addEntry = function(t, e) {
|
|
980
|
+
var r = e || "entries";
|
|
981
|
+
return this[r] || (this[r] = []), this[r].push(t), this;
|
|
982
|
+
}, v.BoxParser = s, s.parseUUID = function(t) {
|
|
983
|
+
return s.parseHex16(t);
|
|
984
|
+
}, s.parseHex16 = function(t) {
|
|
985
|
+
for (var e = "", r = 0; r < 16; r++) {
|
|
986
|
+
var n = t.readUint8().toString(16);
|
|
987
|
+
e += n.length === 1 ? "0" + n : n;
|
|
988
|
+
}
|
|
989
|
+
return e;
|
|
990
|
+
}, s.parseOneBox = function(t, e, r) {
|
|
991
|
+
var n, o = t.getPosition(), a = 0, h, f;
|
|
992
|
+
if (t.getEndPosition() - o < 8)
|
|
993
|
+
return l.debug("BoxParser", "Not enough data in stream to parse the type and size of the box"), { code: s.ERR_NOT_ENOUGH_DATA };
|
|
994
|
+
if (r && r < 8)
|
|
995
|
+
return l.debug("BoxParser", "Not enough bytes left in the parent box to parse a new box"), { code: s.ERR_NOT_ENOUGH_DATA };
|
|
996
|
+
var p = t.readUint32(), u = t.readString(4), c = u;
|
|
997
|
+
if (l.debug("BoxParser", "Found box of type '" + u + "' and size " + p + " at position " + o), a = 8, u == "uuid") {
|
|
998
|
+
if (t.getEndPosition() - t.getPosition() < 16 || r - a < 16)
|
|
999
|
+
return t.seek(o), l.debug("BoxParser", "Not enough bytes left in the parent box to parse a UUID box"), { code: s.ERR_NOT_ENOUGH_DATA };
|
|
1000
|
+
f = s.parseUUID(t), a += 16, c = f;
|
|
1001
|
+
}
|
|
1002
|
+
if (p == 1) {
|
|
1003
|
+
if (t.getEndPosition() - t.getPosition() < 8 || r && r - a < 8)
|
|
1004
|
+
return t.seek(o), l.warn("BoxParser", 'Not enough data in stream to parse the extended size of the "' + u + '" box'), { code: s.ERR_NOT_ENOUGH_DATA };
|
|
1005
|
+
p = t.readUint64(), a += 8;
|
|
1006
|
+
} else if (p === 0) {
|
|
1007
|
+
if (r)
|
|
1008
|
+
p = r;
|
|
1009
|
+
else if (u !== "mdat")
|
|
1010
|
+
return l.error("BoxParser", "Unlimited box size not supported for type: '" + u + "'"), n = new s.Box(u, p), { code: s.OK, box: n, size: n.size };
|
|
1011
|
+
}
|
|
1012
|
+
return p !== 0 && p < a ? (l.error("BoxParser", "Box of type " + u + " has an invalid size " + p + " (too small to be a box)"), { code: s.ERR_NOT_ENOUGH_DATA, type: u, size: p, hdr_size: a, start: o }) : p !== 0 && r && p > r ? (l.error("BoxParser", "Box of type '" + u + "' has a size " + p + " greater than its container size " + r), { code: s.ERR_NOT_ENOUGH_DATA, type: u, size: p, hdr_size: a, start: o }) : p !== 0 && o + p > t.getEndPosition() ? (t.seek(o), l.info("BoxParser", "Not enough data in stream to parse the entire '" + u + "' box"), { code: s.ERR_NOT_ENOUGH_DATA, type: u, size: p, hdr_size: a, start: o }) : e ? { code: s.OK, type: u, size: p, hdr_size: a, start: o } : (s[u + "Box"] ? n = new s[u + "Box"](p) : u !== "uuid" ? (l.warn("BoxParser", "Unknown box type: '" + u + "'"), n = new s.Box(u, p), n.has_unparsed_data = !0) : s.UUIDBoxes[f] ? n = new s.UUIDBoxes[f](p) : (l.warn("BoxParser", "Unknown uuid type: '" + f + "'"), n = new s.Box(u, p), n.uuid = f, n.has_unparsed_data = !0), n.hdr_size = a, n.start = o, n.write === s.Box.prototype.write && n.type !== "mdat" && (l.info("BoxParser", "'" + c + "' box writing not yet implemented, keeping unparsed data in memory for later write"), n.parseDataAndRewind(t)), n.parse(t), h = t.getPosition() - (n.start + n.size), h < 0 ? (l.warn("BoxParser", "Parsing of box '" + c + "' did not read the entire indicated box data size (missing " + -h + " bytes), seeking forward"), t.seek(n.start + n.size)) : h > 0 && (l.error("BoxParser", "Parsing of box '" + c + "' read " + h + " more bytes than the indicated box data size, seeking backwards"), n.size !== 0 && t.seek(n.start + n.size)), { code: s.OK, box: n, size: n.size });
|
|
1013
|
+
}, s.Box.prototype.parse = function(t) {
|
|
1014
|
+
this.type != "mdat" ? this.data = t.readUint8Array(this.size - this.hdr_size) : this.size === 0 ? t.seek(t.getEndPosition()) : t.seek(this.start + this.size);
|
|
1015
|
+
}, s.Box.prototype.parseDataAndRewind = function(t) {
|
|
1016
|
+
this.data = t.readUint8Array(this.size - this.hdr_size), t.position -= this.size - this.hdr_size;
|
|
1017
|
+
}, s.FullBox.prototype.parseDataAndRewind = function(t) {
|
|
1018
|
+
this.parseFullHeader(t), this.data = t.readUint8Array(this.size - this.hdr_size), this.hdr_size -= 4, t.position -= this.size - this.hdr_size;
|
|
1019
|
+
}, s.FullBox.prototype.parseFullHeader = function(t) {
|
|
1020
|
+
this.version = t.readUint8(), this.flags = t.readUint24(), this.hdr_size += 4;
|
|
1021
|
+
}, s.FullBox.prototype.parse = function(t) {
|
|
1022
|
+
this.parseFullHeader(t), this.data = t.readUint8Array(this.size - this.hdr_size);
|
|
1023
|
+
}, s.ContainerBox.prototype.parse = function(t) {
|
|
1024
|
+
for (var e, r; t.getPosition() < this.start + this.size; )
|
|
1025
|
+
if (e = s.parseOneBox(t, !1, this.size - (t.getPosition() - this.start)), e.code === s.OK)
|
|
1026
|
+
if (r = e.box, this.boxes.push(r), this.subBoxNames && this.subBoxNames.indexOf(r.type) != -1)
|
|
1027
|
+
this[this.subBoxNames[this.subBoxNames.indexOf(r.type)] + "s"].push(r);
|
|
1028
|
+
else {
|
|
1029
|
+
var n = r.type !== "uuid" ? r.type : r.uuid;
|
|
1030
|
+
this[n] ? l.warn("Box of type " + n + " already stored in field of this type") : this[n] = r;
|
|
1031
|
+
}
|
|
1032
|
+
else
|
|
1033
|
+
return;
|
|
1034
|
+
}, s.Box.prototype.parseLanguage = function(t) {
|
|
1035
|
+
this.language = t.readUint16();
|
|
1036
|
+
var e = [];
|
|
1037
|
+
e[0] = this.language >> 10 & 31, e[1] = this.language >> 5 & 31, e[2] = this.language & 31, this.languageString = String.fromCharCode(e[0] + 96, e[1] + 96, e[2] + 96);
|
|
1038
|
+
}, s.SAMPLE_ENTRY_TYPE_VISUAL = "Visual", s.SAMPLE_ENTRY_TYPE_AUDIO = "Audio", s.SAMPLE_ENTRY_TYPE_HINT = "Hint", s.SAMPLE_ENTRY_TYPE_METADATA = "Metadata", s.SAMPLE_ENTRY_TYPE_SUBTITLE = "Subtitle", s.SAMPLE_ENTRY_TYPE_SYSTEM = "System", s.SAMPLE_ENTRY_TYPE_TEXT = "Text", s.SampleEntry.prototype.parseHeader = function(t) {
|
|
1039
|
+
t.readUint8Array(6), this.data_reference_index = t.readUint16(), this.hdr_size += 8;
|
|
1040
|
+
}, s.SampleEntry.prototype.parse = function(t) {
|
|
1041
|
+
this.parseHeader(t), this.data = t.readUint8Array(this.size - this.hdr_size);
|
|
1042
|
+
}, s.SampleEntry.prototype.parseDataAndRewind = function(t) {
|
|
1043
|
+
this.parseHeader(t), this.data = t.readUint8Array(this.size - this.hdr_size), this.hdr_size -= 8, t.position -= this.size - this.hdr_size;
|
|
1044
|
+
}, s.SampleEntry.prototype.parseFooter = function(t) {
|
|
1045
|
+
s.ContainerBox.prototype.parse.call(this, t);
|
|
1046
|
+
}, s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_HINT), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_METADATA), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SYSTEM), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_TEXT), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, function(t) {
|
|
1047
|
+
var e;
|
|
1048
|
+
this.parseHeader(t), t.readUint16(), t.readUint16(), t.readUint32Array(3), this.width = t.readUint16(), this.height = t.readUint16(), this.horizresolution = t.readUint32(), this.vertresolution = t.readUint32(), t.readUint32(), this.frame_count = t.readUint16(), e = Math.min(31, t.readUint8()), this.compressorname = t.readString(e), e < 31 && t.readString(31 - e), this.depth = t.readUint16(), t.readUint16(), this.parseFooter(t);
|
|
1049
|
+
}), s.createMediaSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, function(t) {
|
|
1050
|
+
this.parseHeader(t), t.readUint32Array(2), this.channel_count = t.readUint16(), this.samplesize = t.readUint16(), t.readUint16(), t.readUint16(), this.samplerate = t.readUint32() / 65536, this.parseFooter(t);
|
|
1051
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "avc1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "avc2"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "avc3"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "avc4"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "av01"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "dav1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "hvc1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "hev1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "hvt1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "lhe1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "dvh1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "dvhe"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vvc1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vvi1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vvs1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vvcN"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vp08"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "vp09"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "avs3"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "j2ki"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "mjp2"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "mjpg"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "uncv"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "mp4a"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "ac-3"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "ac-4"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "ec-3"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "Opus"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "mha1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "mha2"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "mhm1"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "mhm2"), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "fLaC"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_VISUAL, "encv"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_AUDIO, "enca"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE, "encu"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SYSTEM, "encs"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_TEXT, "enct"), s.createEncryptedSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_METADATA, "encm"), s.createBoxCtor("a1lx", "AV1LayeredImageIndexingProperty", function(t) {
|
|
1052
|
+
var e = t.readUint8() & 1, r = ((e & 1) + 1) * 16;
|
|
1053
|
+
this.layer_size = [];
|
|
1054
|
+
for (var n = 0; n < 3; n++)
|
|
1055
|
+
r == 16 ? this.layer_size[n] = t.readUint16() : this.layer_size[n] = t.readUint32();
|
|
1056
|
+
}), s.createBoxCtor("a1op", "OperatingPointSelectorProperty", function(t) {
|
|
1057
|
+
this.op_index = t.readUint8();
|
|
1058
|
+
}), s.createFullBoxCtor("auxC", "AuxiliaryTypeProperty", function(t) {
|
|
1059
|
+
this.aux_type = t.readCString();
|
|
1060
|
+
var e = this.size - this.hdr_size - (this.aux_type.length + 1);
|
|
1061
|
+
this.aux_subtype = t.readUint8Array(e);
|
|
1062
|
+
}), s.createBoxCtor("av1C", "AV1CodecConfigurationBox", function(t) {
|
|
1063
|
+
var e = t.readUint8();
|
|
1064
|
+
if ((e >> 7 & 1) !== 1) {
|
|
1065
|
+
l.error("av1C marker problem");
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
if (this.version = e & 127, this.version !== 1) {
|
|
1069
|
+
l.error("av1C version " + this.version + " not supported");
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (e = t.readUint8(), this.seq_profile = e >> 5 & 7, this.seq_level_idx_0 = e & 31, e = t.readUint8(), this.seq_tier_0 = e >> 7 & 1, this.high_bitdepth = e >> 6 & 1, this.twelve_bit = e >> 5 & 1, this.monochrome = e >> 4 & 1, this.chroma_subsampling_x = e >> 3 & 1, this.chroma_subsampling_y = e >> 2 & 1, this.chroma_sample_position = e & 3, e = t.readUint8(), this.reserved_1 = e >> 5 & 7, this.reserved_1 !== 0) {
|
|
1073
|
+
l.error("av1C reserved_1 parsing problem");
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
if (this.initial_presentation_delay_present = e >> 4 & 1, this.initial_presentation_delay_present === 1)
|
|
1077
|
+
this.initial_presentation_delay_minus_one = e & 15;
|
|
1078
|
+
else if (this.reserved_2 = e & 15, this.reserved_2 !== 0) {
|
|
1079
|
+
l.error("av1C reserved_2 parsing problem");
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
var r = this.size - this.hdr_size - 4;
|
|
1083
|
+
this.configOBUs = t.readUint8Array(r);
|
|
1084
|
+
});
|
|
1085
|
+
function R(t) {
|
|
1086
|
+
var e = "<table class='inner-table'>";
|
|
1087
|
+
e += "<thead><tr><th>length</th><th>nalu_data</th></tr></thead>", e += "<tbody>";
|
|
1088
|
+
for (var r = 0; r < t.length; r++) {
|
|
1089
|
+
var n = t[r];
|
|
1090
|
+
e += "<tr>", e += "<td>" + n.length + "</td>", e += "<td>", e += n.nalu.reduce(function(o, a) {
|
|
1091
|
+
return o + a.toString(16).padStart(2, "0");
|
|
1092
|
+
}, "0x"), e += "</td></tr>";
|
|
1093
|
+
}
|
|
1094
|
+
return e += "</tbody></table>", e;
|
|
1095
|
+
}
|
|
1096
|
+
s.createBoxCtor("avcC", "AVCConfigurationBox", function(t) {
|
|
1097
|
+
var e, r;
|
|
1098
|
+
for (this.configurationVersion = t.readUint8(), this.AVCProfileIndication = t.readUint8(), this.profile_compatibility = t.readUint8(), this.AVCLevelIndication = t.readUint8(), this.lengthSizeMinusOne = t.readUint8() & 3, this.nb_SPS_nalus = t.readUint8() & 31, r = this.size - this.hdr_size - 6, this.SPS = [], this.SPS.toString = function() {
|
|
1099
|
+
return R(this);
|
|
1100
|
+
}, e = 0; e < this.nb_SPS_nalus; e++)
|
|
1101
|
+
this.SPS[e] = {}, this.SPS[e].length = t.readUint16(), this.SPS[e].nalu = t.readUint8Array(this.SPS[e].length), r -= 2 + this.SPS[e].length;
|
|
1102
|
+
for (this.nb_PPS_nalus = t.readUint8(), r--, this.PPS = [], this.PPS.toString = function() {
|
|
1103
|
+
return R(this);
|
|
1104
|
+
}, e = 0; e < this.nb_PPS_nalus; e++)
|
|
1105
|
+
this.PPS[e] = {}, this.PPS[e].length = t.readUint16(), this.PPS[e].nalu = t.readUint8Array(this.PPS[e].length), r -= 2 + this.PPS[e].length;
|
|
1106
|
+
r > 0 && (this.ext = t.readUint8Array(r));
|
|
1107
|
+
}), s.createBoxCtor("btrt", "BitRateBox", function(t) {
|
|
1108
|
+
this.bufferSizeDB = t.readUint32(), this.maxBitrate = t.readUint32(), this.avgBitrate = t.readUint32();
|
|
1109
|
+
}), s.createFullBoxCtor("ccst", "CodingConstraintsBox", function(t) {
|
|
1110
|
+
var e = t.readUint8();
|
|
1111
|
+
this.all_ref_pics_intra = (e & 128) == 128, this.intra_pred_used = (e & 64) == 64, this.max_ref_per_pic = (e & 63) >> 2, t.readUint24();
|
|
1112
|
+
}), s.createBoxCtor("cdef", "ComponentDefinitionBox", function(t) {
|
|
1113
|
+
var e;
|
|
1114
|
+
for (this.channel_count = t.readUint16(), this.channel_indexes = [], this.channel_types = [], this.channel_associations = [], e = 0; e < this.channel_count; e++)
|
|
1115
|
+
this.channel_indexes.push(t.readUint16()), this.channel_types.push(t.readUint16()), this.channel_associations.push(t.readUint16());
|
|
1116
|
+
}), s.createBoxCtor("clap", "CleanApertureBox", function(t) {
|
|
1117
|
+
this.cleanApertureWidthN = t.readUint32(), this.cleanApertureWidthD = t.readUint32(), this.cleanApertureHeightN = t.readUint32(), this.cleanApertureHeightD = t.readUint32(), this.horizOffN = t.readUint32(), this.horizOffD = t.readUint32(), this.vertOffN = t.readUint32(), this.vertOffD = t.readUint32();
|
|
1118
|
+
}), s.createBoxCtor("clli", "ContentLightLevelBox", function(t) {
|
|
1119
|
+
this.max_content_light_level = t.readUint16(), this.max_pic_average_light_level = t.readUint16();
|
|
1120
|
+
}), s.createFullBoxCtor("cmex", "CameraExtrinsicMatrixProperty", function(t) {
|
|
1121
|
+
this.flags & 1 && (this.pos_x = t.readInt32()), this.flags & 2 && (this.pos_y = t.readInt32()), this.flags & 4 && (this.pos_z = t.readInt32()), this.flags & 8 && (this.version == 0 ? this.flags & 16 ? (this.quat_x = t.readInt32(), this.quat_y = t.readInt32(), this.quat_z = t.readInt32()) : (this.quat_x = t.readInt16(), this.quat_y = t.readInt16(), this.quat_z = t.readInt16()) : this.version == 1), this.flags & 32 && (this.id = t.readUint32());
|
|
1122
|
+
}), s.createFullBoxCtor("cmin", "CameraIntrinsicMatrixProperty", function(t) {
|
|
1123
|
+
this.focal_length_x = t.readInt32(), this.principal_point_x = t.readInt32(), this.principal_point_y = t.readInt32(), this.flags & 1 && (this.focal_length_y = t.readInt32(), this.skew_factor = t.readInt32());
|
|
1124
|
+
}), s.createBoxCtor("cmpd", "ComponentDefinitionBox", function(t) {
|
|
1125
|
+
for (this.component_count = t.readUint32(), this.component_types = [], this.component_type_urls = [], i = 0; i < this.component_count; i++) {
|
|
1126
|
+
var e = t.readUint16();
|
|
1127
|
+
this.component_types.push(e), e >= 32768 && this.component_type_urls.push(t.readCString());
|
|
1128
|
+
}
|
|
1129
|
+
}), s.createFullBoxCtor("co64", "ChunkLargeOffsetBox", function(t) {
|
|
1130
|
+
var e, r;
|
|
1131
|
+
if (e = t.readUint32(), this.chunk_offsets = [], this.version === 0)
|
|
1132
|
+
for (r = 0; r < e; r++)
|
|
1133
|
+
this.chunk_offsets.push(t.readUint64());
|
|
1134
|
+
}), s.createFullBoxCtor("CoLL", "ContentLightLevelBox", function(t) {
|
|
1135
|
+
this.maxCLL = t.readUint16(), this.maxFALL = t.readUint16();
|
|
1136
|
+
}), s.createBoxCtor("colr", "ColourInformationBox", function(t) {
|
|
1137
|
+
if (this.colour_type = t.readString(4), this.colour_type === "nclx") {
|
|
1138
|
+
this.colour_primaries = t.readUint16(), this.transfer_characteristics = t.readUint16(), this.matrix_coefficients = t.readUint16();
|
|
1139
|
+
var e = t.readUint8();
|
|
1140
|
+
this.full_range_flag = e >> 7;
|
|
1141
|
+
} else this.colour_type === "rICC" ? this.ICC_profile = t.readUint8Array(this.size - 4) : this.colour_type === "prof" && (this.ICC_profile = t.readUint8Array(this.size - 4));
|
|
1142
|
+
}), s.createFullBoxCtor("cprt", "CopyrightBox", function(t) {
|
|
1143
|
+
this.parseLanguage(t), this.notice = t.readCString();
|
|
1144
|
+
}), s.createFullBoxCtor("cslg", "CompositionToDecodeBox", function(t) {
|
|
1145
|
+
this.version === 0 && (this.compositionToDTSShift = t.readInt32(), this.leastDecodeToDisplayDelta = t.readInt32(), this.greatestDecodeToDisplayDelta = t.readInt32(), this.compositionStartTime = t.readInt32(), this.compositionEndTime = t.readInt32());
|
|
1146
|
+
}), s.createFullBoxCtor("ctts", "CompositionOffsetBox", function(t) {
|
|
1147
|
+
var e, r;
|
|
1148
|
+
if (e = t.readUint32(), this.sample_counts = [], this.sample_offsets = [], this.version === 0)
|
|
1149
|
+
for (r = 0; r < e; r++) {
|
|
1150
|
+
this.sample_counts.push(t.readUint32());
|
|
1151
|
+
var n = t.readInt32();
|
|
1152
|
+
n < 0 && l.warn("BoxParser", "ctts box uses negative values without using version 1"), this.sample_offsets.push(n);
|
|
1153
|
+
}
|
|
1154
|
+
else if (this.version == 1)
|
|
1155
|
+
for (r = 0; r < e; r++)
|
|
1156
|
+
this.sample_counts.push(t.readUint32()), this.sample_offsets.push(t.readInt32());
|
|
1157
|
+
}), s.createBoxCtor("dac3", "AC3SpecificBox", function(t) {
|
|
1158
|
+
var e = t.readUint8(), r = t.readUint8(), n = t.readUint8();
|
|
1159
|
+
this.fscod = e >> 6, this.bsid = e >> 1 & 31, this.bsmod = (e & 1) << 2 | r >> 6 & 3, this.acmod = r >> 3 & 7, this.lfeon = r >> 2 & 1, this.bit_rate_code = r & 3 | n >> 5 & 7;
|
|
1160
|
+
}), s.createBoxCtor("dec3", "EC3SpecificBox", function(t) {
|
|
1161
|
+
var e = t.readUint16();
|
|
1162
|
+
this.data_rate = e >> 3, this.num_ind_sub = e & 7, this.ind_subs = [];
|
|
1163
|
+
for (var r = 0; r < this.num_ind_sub + 1; r++) {
|
|
1164
|
+
var n = {};
|
|
1165
|
+
this.ind_subs.push(n);
|
|
1166
|
+
var o = t.readUint8(), a = t.readUint8(), h = t.readUint8();
|
|
1167
|
+
n.fscod = o >> 6, n.bsid = o >> 1 & 31, n.bsmod = (o & 1) << 4 | a >> 4 & 15, n.acmod = a >> 1 & 7, n.lfeon = a & 1, n.num_dep_sub = h >> 1 & 15, n.num_dep_sub > 0 && (n.chan_loc = (h & 1) << 8 | t.readUint8());
|
|
1168
|
+
}
|
|
1169
|
+
}), s.createFullBoxCtor("dfLa", "FLACSpecificBox", function(t) {
|
|
1170
|
+
var e = 127, r = 128, n = [], o = [
|
|
1171
|
+
"STREAMINFO",
|
|
1172
|
+
"PADDING",
|
|
1173
|
+
"APPLICATION",
|
|
1174
|
+
"SEEKTABLE",
|
|
1175
|
+
"VORBIS_COMMENT",
|
|
1176
|
+
"CUESHEET",
|
|
1177
|
+
"PICTURE",
|
|
1178
|
+
"RESERVED"
|
|
1179
|
+
];
|
|
1180
|
+
do {
|
|
1181
|
+
var a = t.readUint8(), h = Math.min(
|
|
1182
|
+
a & e,
|
|
1183
|
+
o.length - 1
|
|
1184
|
+
);
|
|
1185
|
+
if (h ? t.readUint8Array(t.readUint24()) : (t.readUint8Array(13), this.samplerate = t.readUint32() >> 12, t.readUint8Array(20)), n.push(o[h]), a & r)
|
|
1186
|
+
break;
|
|
1187
|
+
} while (!0);
|
|
1188
|
+
this.numMetadataBlocks = n.length + " (" + n.join(", ") + ")";
|
|
1189
|
+
}), s.createBoxCtor("dimm", "hintimmediateBytesSent", function(t) {
|
|
1190
|
+
this.bytessent = t.readUint64();
|
|
1191
|
+
}), s.createBoxCtor("dmax", "hintlongestpacket", function(t) {
|
|
1192
|
+
this.time = t.readUint32();
|
|
1193
|
+
}), s.createBoxCtor("dmed", "hintmediaBytesSent", function(t) {
|
|
1194
|
+
this.bytessent = t.readUint64();
|
|
1195
|
+
}), s.createBoxCtor("dOps", "OpusSpecificBox", function(t) {
|
|
1196
|
+
if (this.Version = t.readUint8(), this.OutputChannelCount = t.readUint8(), this.PreSkip = t.readUint16(), this.InputSampleRate = t.readUint32(), this.OutputGain = t.readInt16(), this.ChannelMappingFamily = t.readUint8(), this.ChannelMappingFamily !== 0) {
|
|
1197
|
+
this.StreamCount = t.readUint8(), this.CoupledCount = t.readUint8(), this.ChannelMapping = [];
|
|
1198
|
+
for (var e = 0; e < this.OutputChannelCount; e++)
|
|
1199
|
+
this.ChannelMapping[e] = t.readUint8();
|
|
1200
|
+
}
|
|
1201
|
+
}), s.createFullBoxCtor("dref", "DataReferenceBox", function(t) {
|
|
1202
|
+
var e, r;
|
|
1203
|
+
this.entries = [];
|
|
1204
|
+
for (var n = t.readUint32(), o = 0; o < n; o++)
|
|
1205
|
+
if (e = s.parseOneBox(t, !1, this.size - (t.getPosition() - this.start)), e.code === s.OK)
|
|
1206
|
+
r = e.box, this.entries.push(r);
|
|
1207
|
+
else
|
|
1208
|
+
return;
|
|
1209
|
+
}), s.createBoxCtor("drep", "hintrepeatedBytesSent", function(t) {
|
|
1210
|
+
this.bytessent = t.readUint64();
|
|
1211
|
+
}), s.createFullBoxCtor("elng", "ExtendedLanguageBox", function(t) {
|
|
1212
|
+
this.extended_language = t.readString(this.size - this.hdr_size);
|
|
1213
|
+
}), s.createFullBoxCtor("elst", "EditListBox", function(t) {
|
|
1214
|
+
this.entries = [];
|
|
1215
|
+
for (var e = t.readUint32(), r = 0; r < e; r++) {
|
|
1216
|
+
var n = {};
|
|
1217
|
+
this.entries.push(n), this.version === 1 ? (n.segment_duration = t.readUint64(), n.media_time = t.readInt64()) : (n.segment_duration = t.readUint32(), n.media_time = t.readInt32()), n.media_rate_integer = t.readInt16(), n.media_rate_fraction = t.readInt16();
|
|
1218
|
+
}
|
|
1219
|
+
}), s.createFullBoxCtor("emsg", "EventMessageBox", function(t) {
|
|
1220
|
+
this.version == 1 ? (this.timescale = t.readUint32(), this.presentation_time = t.readUint64(), this.event_duration = t.readUint32(), this.id = t.readUint32(), this.scheme_id_uri = t.readCString(), this.value = t.readCString()) : (this.scheme_id_uri = t.readCString(), this.value = t.readCString(), this.timescale = t.readUint32(), this.presentation_time_delta = t.readUint32(), this.event_duration = t.readUint32(), this.id = t.readUint32());
|
|
1221
|
+
var e = this.size - this.hdr_size - (16 + (this.scheme_id_uri.length + 1) + (this.value.length + 1));
|
|
1222
|
+
this.version == 1 && (e -= 4), this.message_data = t.readUint8Array(e);
|
|
1223
|
+
}), s.createEntityToGroupCtor = function(t, e) {
|
|
1224
|
+
s[t + "Box"] = function(r) {
|
|
1225
|
+
s.FullBox.call(this, t, r);
|
|
1226
|
+
}, s[t + "Box"].prototype = new s.FullBox(), s[t + "Box"].prototype.parse = function(r) {
|
|
1227
|
+
if (this.parseFullHeader(r), e)
|
|
1228
|
+
e.call(this, r);
|
|
1229
|
+
else
|
|
1230
|
+
for (this.group_id = r.readUint32(), this.num_entities_in_group = r.readUint32(), this.entity_ids = [], i = 0; i < this.num_entities_in_group; i++) {
|
|
1231
|
+
var n = r.readUint32();
|
|
1232
|
+
this.entity_ids.push(n);
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
}, s.createEntityToGroupCtor("aebr"), s.createEntityToGroupCtor("afbr"), s.createEntityToGroupCtor("albc"), s.createEntityToGroupCtor("altr"), s.createEntityToGroupCtor("brst"), s.createEntityToGroupCtor("dobr"), s.createEntityToGroupCtor("eqiv"), s.createEntityToGroupCtor("favc"), s.createEntityToGroupCtor("fobr"), s.createEntityToGroupCtor("iaug"), s.createEntityToGroupCtor("pano"), s.createEntityToGroupCtor("slid"), s.createEntityToGroupCtor("ster"), s.createEntityToGroupCtor("tsyn"), s.createEntityToGroupCtor("wbbr"), s.createEntityToGroupCtor("prgr"), s.createEntityToGroupCtor("pymd", function(t) {
|
|
1236
|
+
this.group_id = t.readUint32(), this.num_entities_in_group = t.readUint32(), this.entity_ids = [];
|
|
1237
|
+
for (var e = 0; e < this.num_entities_in_group; e++) {
|
|
1238
|
+
var r = t.readUint32();
|
|
1239
|
+
this.entity_ids.push(r);
|
|
1240
|
+
}
|
|
1241
|
+
for (this.tile_size_x = t.readUint16(), this.tile_size_y = t.readUint16(), this.layer_binning = [], this.tiles_in_layer_column_minus1 = [], this.tiles_in_layer_row_minus1 = [], e = 0; e < this.num_entities_in_group; e++)
|
|
1242
|
+
this.layer_binning[e] = t.readUint16(), this.tiles_in_layer_row_minus1[e] = t.readUint16(), this.tiles_in_layer_column_minus1[e] = t.readUint16();
|
|
1243
|
+
}), s.createFullBoxCtor("esds", "ElementaryStreamDescriptorBox", function(t) {
|
|
1244
|
+
var e = t.readUint8Array(this.size - this.hdr_size);
|
|
1245
|
+
if (typeof B < "u") {
|
|
1246
|
+
var r = new B();
|
|
1247
|
+
this.esd = r.parseOneDescriptor(new d(e.buffer, 0, d.BIG_ENDIAN));
|
|
1248
|
+
}
|
|
1249
|
+
}), s.createBoxCtor("fiel", "FieldHandlingBox", function(t) {
|
|
1250
|
+
this.fieldCount = t.readUint8(), this.fieldOrdering = t.readUint8();
|
|
1251
|
+
}), s.createBoxCtor("frma", "OriginalFormatBox", function(t) {
|
|
1252
|
+
this.data_format = t.readString(4);
|
|
1253
|
+
}), s.createBoxCtor("ftyp", "FileTypeBox", function(t) {
|
|
1254
|
+
var e = this.size - this.hdr_size;
|
|
1255
|
+
this.major_brand = t.readString(4), this.minor_version = t.readUint32(), e -= 8, this.compatible_brands = [];
|
|
1256
|
+
for (var r = 0; e >= 4; )
|
|
1257
|
+
this.compatible_brands[r] = t.readString(4), e -= 4, r++;
|
|
1258
|
+
}), s.createFullBoxCtor("hdlr", "HandlerBox", function(t) {
|
|
1259
|
+
this.version === 0 && (t.readUint32(), this.handler = t.readString(4), t.readUint32Array(3), this.name = t.readString(this.size - this.hdr_size - 20), this.name[this.name.length - 1] === "\0" && (this.name = this.name.slice(0, -1)));
|
|
1260
|
+
}), s.createBoxCtor("hvcC", "HEVCConfigurationBox", function(t) {
|
|
1261
|
+
var e, r, n, o;
|
|
1262
|
+
this.configurationVersion = t.readUint8(), o = t.readUint8(), this.general_profile_space = o >> 6, this.general_tier_flag = (o & 32) >> 5, this.general_profile_idc = o & 31, this.general_profile_compatibility = t.readUint32(), this.general_constraint_indicator = t.readUint8Array(6), this.general_level_idc = t.readUint8(), this.min_spatial_segmentation_idc = t.readUint16() & 4095, this.parallelismType = t.readUint8() & 3, this.chroma_format_idc = t.readUint8() & 3, this.bit_depth_luma_minus8 = t.readUint8() & 7, this.bit_depth_chroma_minus8 = t.readUint8() & 7, this.avgFrameRate = t.readUint16(), o = t.readUint8(), this.constantFrameRate = o >> 6, this.numTemporalLayers = (o & 13) >> 3, this.temporalIdNested = (o & 4) >> 2, this.lengthSizeMinusOne = o & 3, this.nalu_arrays = [], this.nalu_arrays.toString = function() {
|
|
1263
|
+
var u = "<table class='inner-table'>";
|
|
1264
|
+
u += "<thead><tr><th>completeness</th><th>nalu_type</th><th>nalu_data</th></tr></thead>", u += "<tbody>";
|
|
1265
|
+
for (var c = 0; c < this.length; c++) {
|
|
1266
|
+
var g = this[c];
|
|
1267
|
+
u += "<tr>", u += "<td rowspan='" + g.length + "'>" + g.completeness + "</td>", u += "<td rowspan='" + g.length + "'>" + g.nalu_type + "</td>";
|
|
1268
|
+
for (var x = 0; x < g.length; x++) {
|
|
1269
|
+
var m = g[x];
|
|
1270
|
+
x !== 0 && (u += "<tr>"), u += "<td>", u += m.data.reduce(function(E, w) {
|
|
1271
|
+
return E + w.toString(16).padStart(2, "0");
|
|
1272
|
+
}, "0x"), u += "</td></tr>";
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return u += "</tbody></table>", u;
|
|
1276
|
+
};
|
|
1277
|
+
var a = t.readUint8();
|
|
1278
|
+
for (e = 0; e < a; e++) {
|
|
1279
|
+
var h = [];
|
|
1280
|
+
this.nalu_arrays.push(h), o = t.readUint8(), h.completeness = (o & 128) >> 7, h.nalu_type = o & 63;
|
|
1281
|
+
var f = t.readUint16();
|
|
1282
|
+
for (r = 0; r < f; r++) {
|
|
1283
|
+
var p = {};
|
|
1284
|
+
h.push(p), n = t.readUint16(), p.data = t.readUint8Array(n);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}), s.createFullBoxCtor("iinf", "ItemInfoBox", function(t) {
|
|
1288
|
+
var e;
|
|
1289
|
+
this.version === 0 ? this.entry_count = t.readUint16() : this.entry_count = t.readUint32(), this.item_infos = [];
|
|
1290
|
+
for (var r = 0; r < this.entry_count; r++)
|
|
1291
|
+
if (e = s.parseOneBox(t, !1, this.size - (t.getPosition() - this.start)), e.code === s.OK)
|
|
1292
|
+
e.box.type !== "infe" && l.error("BoxParser", "Expected 'infe' box, got " + e.box.type), this.item_infos[r] = e.box;
|
|
1293
|
+
else
|
|
1294
|
+
return;
|
|
1295
|
+
}), s.createFullBoxCtor("iloc", "ItemLocationBox", function(t) {
|
|
1296
|
+
var e;
|
|
1297
|
+
e = t.readUint8(), this.offset_size = e >> 4 & 15, this.length_size = e & 15, e = t.readUint8(), this.base_offset_size = e >> 4 & 15, this.version === 1 || this.version === 2 ? this.index_size = e & 15 : this.index_size = 0, this.items = [];
|
|
1298
|
+
var r = 0;
|
|
1299
|
+
if (this.version < 2)
|
|
1300
|
+
r = t.readUint16();
|
|
1301
|
+
else if (this.version === 2)
|
|
1302
|
+
r = t.readUint32();
|
|
1303
|
+
else
|
|
1304
|
+
throw "version of iloc box not supported";
|
|
1305
|
+
for (var n = 0; n < r; n++) {
|
|
1306
|
+
var o = {};
|
|
1307
|
+
if (this.items.push(o), this.version < 2)
|
|
1308
|
+
o.item_ID = t.readUint16();
|
|
1309
|
+
else if (this.version === 2)
|
|
1310
|
+
o.item_ID = t.readUint32();
|
|
1311
|
+
else
|
|
1312
|
+
throw "version of iloc box not supported";
|
|
1313
|
+
switch (this.version === 1 || this.version === 2 ? o.construction_method = t.readUint16() & 15 : o.construction_method = 0, o.data_reference_index = t.readUint16(), this.base_offset_size) {
|
|
1314
|
+
case 0:
|
|
1315
|
+
o.base_offset = 0;
|
|
1316
|
+
break;
|
|
1317
|
+
case 4:
|
|
1318
|
+
o.base_offset = t.readUint32();
|
|
1319
|
+
break;
|
|
1320
|
+
case 8:
|
|
1321
|
+
o.base_offset = t.readUint64();
|
|
1322
|
+
break;
|
|
1323
|
+
default:
|
|
1324
|
+
throw "Error reading base offset size";
|
|
1325
|
+
}
|
|
1326
|
+
var a = t.readUint16();
|
|
1327
|
+
o.extents = [];
|
|
1328
|
+
for (var h = 0; h < a; h++) {
|
|
1329
|
+
var f = {};
|
|
1330
|
+
if (o.extents.push(f), this.version === 1 || this.version === 2)
|
|
1331
|
+
switch (this.index_size) {
|
|
1332
|
+
case 0:
|
|
1333
|
+
f.extent_index = 0;
|
|
1334
|
+
break;
|
|
1335
|
+
case 4:
|
|
1336
|
+
f.extent_index = t.readUint32();
|
|
1337
|
+
break;
|
|
1338
|
+
case 8:
|
|
1339
|
+
f.extent_index = t.readUint64();
|
|
1340
|
+
break;
|
|
1341
|
+
default:
|
|
1342
|
+
throw "Error reading extent index";
|
|
1343
|
+
}
|
|
1344
|
+
switch (this.offset_size) {
|
|
1345
|
+
case 0:
|
|
1346
|
+
f.extent_offset = 0;
|
|
1347
|
+
break;
|
|
1348
|
+
case 4:
|
|
1349
|
+
f.extent_offset = t.readUint32();
|
|
1350
|
+
break;
|
|
1351
|
+
case 8:
|
|
1352
|
+
f.extent_offset = t.readUint64();
|
|
1353
|
+
break;
|
|
1354
|
+
default:
|
|
1355
|
+
throw "Error reading extent index";
|
|
1356
|
+
}
|
|
1357
|
+
switch (this.length_size) {
|
|
1358
|
+
case 0:
|
|
1359
|
+
f.extent_length = 0;
|
|
1360
|
+
break;
|
|
1361
|
+
case 4:
|
|
1362
|
+
f.extent_length = t.readUint32();
|
|
1363
|
+
break;
|
|
1364
|
+
case 8:
|
|
1365
|
+
f.extent_length = t.readUint64();
|
|
1366
|
+
break;
|
|
1367
|
+
default:
|
|
1368
|
+
throw "Error reading extent index";
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}), s.createBoxCtor("imir", "ImageMirror", function(t) {
|
|
1373
|
+
var e = t.readUint8();
|
|
1374
|
+
this.reserved = e >> 7, this.axis = e & 1;
|
|
1375
|
+
}), s.createFullBoxCtor("infe", "ItemInfoEntry", function(t) {
|
|
1376
|
+
if ((this.version === 0 || this.version === 1) && (this.item_ID = t.readUint16(), this.item_protection_index = t.readUint16(), this.item_name = t.readCString(), this.content_type = t.readCString(), this.content_encoding = t.readCString()), this.version === 1) {
|
|
1377
|
+
this.extension_type = t.readString(4), l.warn("BoxParser", "Cannot parse extension type"), t.seek(this.start + this.size);
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
this.version >= 2 && (this.version === 2 ? this.item_ID = t.readUint16() : this.version === 3 && (this.item_ID = t.readUint32()), this.item_protection_index = t.readUint16(), this.item_type = t.readString(4), this.item_name = t.readCString(), this.item_type === "mime" ? (this.content_type = t.readCString(), this.content_encoding = t.readCString()) : this.item_type === "uri " && (this.item_uri_type = t.readCString()));
|
|
1381
|
+
}), s.createFullBoxCtor("ipma", "ItemPropertyAssociationBox", function(t) {
|
|
1382
|
+
var e, r;
|
|
1383
|
+
for (entry_count = t.readUint32(), this.associations = [], e = 0; e < entry_count; e++) {
|
|
1384
|
+
var n = {};
|
|
1385
|
+
this.associations.push(n), this.version < 1 ? n.id = t.readUint16() : n.id = t.readUint32();
|
|
1386
|
+
var o = t.readUint8();
|
|
1387
|
+
for (n.props = [], r = 0; r < o; r++) {
|
|
1388
|
+
var a = t.readUint8(), h = {};
|
|
1389
|
+
n.props.push(h), h.essential = (a & 128) >> 7 === 1, this.flags & 1 ? h.property_index = (a & 127) << 8 | t.readUint8() : h.property_index = a & 127;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}), s.createFullBoxCtor("iref", "ItemReferenceBox", function(t) {
|
|
1393
|
+
var e, r;
|
|
1394
|
+
for (this.references = []; t.getPosition() < this.start + this.size; )
|
|
1395
|
+
if (e = s.parseOneBox(t, !0, this.size - (t.getPosition() - this.start)), e.code === s.OK)
|
|
1396
|
+
this.version === 0 ? r = new s.SingleItemTypeReferenceBox(e.type, e.size, e.hdr_size, e.start) : r = new s.SingleItemTypeReferenceBoxLarge(e.type, e.size, e.hdr_size, e.start), r.write === s.Box.prototype.write && r.type !== "mdat" && (l.warn("BoxParser", r.type + " box writing not yet implemented, keeping unparsed data in memory for later write"), r.parseDataAndRewind(t)), r.parse(t), this.references.push(r);
|
|
1397
|
+
else
|
|
1398
|
+
return;
|
|
1399
|
+
}), s.createBoxCtor("irot", "ImageRotation", function(t) {
|
|
1400
|
+
this.angle = t.readUint8() & 3;
|
|
1401
|
+
}), s.createFullBoxCtor("ispe", "ImageSpatialExtentsProperty", function(t) {
|
|
1402
|
+
this.image_width = t.readUint32(), this.image_height = t.readUint32();
|
|
1403
|
+
}), s.createFullBoxCtor("kind", "KindBox", function(t) {
|
|
1404
|
+
this.schemeURI = t.readCString(), this.value = t.readCString();
|
|
1405
|
+
}), s.createFullBoxCtor("leva", "LevelAssignmentBox", function(t) {
|
|
1406
|
+
var e = t.readUint8();
|
|
1407
|
+
this.levels = [];
|
|
1408
|
+
for (var r = 0; r < e; r++) {
|
|
1409
|
+
var n = {};
|
|
1410
|
+
this.levels[r] = n, n.track_ID = t.readUint32();
|
|
1411
|
+
var o = t.readUint8();
|
|
1412
|
+
switch (n.padding_flag = o >> 7, n.assignment_type = o & 127, n.assignment_type) {
|
|
1413
|
+
case 0:
|
|
1414
|
+
n.grouping_type = t.readString(4);
|
|
1415
|
+
break;
|
|
1416
|
+
case 1:
|
|
1417
|
+
n.grouping_type = t.readString(4), n.grouping_type_parameter = t.readUint32();
|
|
1418
|
+
break;
|
|
1419
|
+
case 2:
|
|
1420
|
+
break;
|
|
1421
|
+
case 3:
|
|
1422
|
+
break;
|
|
1423
|
+
case 4:
|
|
1424
|
+
n.sub_track_id = t.readUint32();
|
|
1425
|
+
break;
|
|
1426
|
+
default:
|
|
1427
|
+
l.warn("BoxParser", "Unknown leva assignement type");
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}), s.createBoxCtor("lhvC", "LHEVCConfigurationBox", function(t) {
|
|
1431
|
+
var e, r, n;
|
|
1432
|
+
this.configurationVersion = t.readUint8(), this.min_spatial_segmentation_idc = t.readUint16() & 4095, this.parallelismType = t.readUint8() & 3, n = t.readUint8(), this.numTemporalLayers = (n & 13) >> 3, this.temporalIdNested = (n & 4) >> 2, this.lengthSizeMinusOne = n & 3, this.nalu_arrays = [], this.nalu_arrays.toString = function() {
|
|
1433
|
+
var u = "<table class='inner-table'>";
|
|
1434
|
+
u += "<thead><tr><th>completeness</th><th>nalu_type</th><th>nalu_data</th></tr></thead>", u += "<tbody>";
|
|
1435
|
+
for (var c = 0; c < this.length; c++) {
|
|
1436
|
+
var g = this[c];
|
|
1437
|
+
u += "<tr>", u += "<td rowspan='" + g.length + "'>" + g.completeness + "</td>", u += "<td rowspan='" + g.length + "'>" + g.nalu_type + "</td>";
|
|
1438
|
+
for (var x = 0; x < g.length; x++) {
|
|
1439
|
+
var m = g[x];
|
|
1440
|
+
x !== 0 && (u += "<tr>"), u += "<td>", u += m.data.reduce(function(E, w) {
|
|
1441
|
+
return E + w.toString(16).padStart(2, "0");
|
|
1442
|
+
}, "0x"), u += "</td></tr>";
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
return u += "</tbody></table>", u;
|
|
1446
|
+
};
|
|
1447
|
+
var o = t.readUint8();
|
|
1448
|
+
for (e = 0; e < o; e++) {
|
|
1449
|
+
var a = [];
|
|
1450
|
+
this.nalu_arrays.push(a), n = t.readUint8(), a.completeness = (n & 128) >> 7, a.nalu_type = n & 63;
|
|
1451
|
+
var h = t.readUint16();
|
|
1452
|
+
for (r = 0; r < h; r++) {
|
|
1453
|
+
var f = {};
|
|
1454
|
+
a.push(f);
|
|
1455
|
+
var p = t.readUint16();
|
|
1456
|
+
f.data = t.readUint8Array(p);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}), s.createBoxCtor("lsel", "LayerSelectorProperty", function(t) {
|
|
1460
|
+
this.layer_id = t.readUint16();
|
|
1461
|
+
}), s.createBoxCtor("maxr", "hintmaxrate", function(t) {
|
|
1462
|
+
this.period = t.readUint32(), this.bytes = t.readUint32();
|
|
1463
|
+
});
|
|
1464
|
+
function M(t, e) {
|
|
1465
|
+
this.x = t, this.y = e;
|
|
1466
|
+
}
|
|
1467
|
+
M.prototype.toString = function() {
|
|
1468
|
+
return "(" + this.x + "," + this.y + ")";
|
|
1469
|
+
}, s.createBoxCtor("mdcv", "MasteringDisplayColourVolumeBox", function(t) {
|
|
1470
|
+
this.display_primaries = [], this.display_primaries[0] = new M(t.readUint16(), t.readUint16()), this.display_primaries[1] = new M(t.readUint16(), t.readUint16()), this.display_primaries[2] = new M(t.readUint16(), t.readUint16()), this.white_point = new M(t.readUint16(), t.readUint16()), this.max_display_mastering_luminance = t.readUint32(), this.min_display_mastering_luminance = t.readUint32();
|
|
1471
|
+
}), s.createFullBoxCtor("mdhd", "MediaHeaderBox", function(t) {
|
|
1472
|
+
this.version == 1 ? (this.creation_time = t.readUint64(), this.modification_time = t.readUint64(), this.timescale = t.readUint32(), this.duration = t.readUint64()) : (this.creation_time = t.readUint32(), this.modification_time = t.readUint32(), this.timescale = t.readUint32(), this.duration = t.readUint32()), this.parseLanguage(t), t.readUint16();
|
|
1473
|
+
}), s.createFullBoxCtor("mehd", "MovieExtendsHeaderBox", function(t) {
|
|
1474
|
+
this.flags & 1 && (l.warn("BoxParser", "mehd box incorrectly uses flags set to 1, converting version to 1"), this.version = 1), this.version == 1 ? this.fragment_duration = t.readUint64() : this.fragment_duration = t.readUint32();
|
|
1475
|
+
}), s.createFullBoxCtor("meta", "MetaBox", function(t) {
|
|
1476
|
+
this.boxes = [], s.ContainerBox.prototype.parse.call(this, t);
|
|
1477
|
+
}), s.createFullBoxCtor("mfhd", "MovieFragmentHeaderBox", function(t) {
|
|
1478
|
+
this.sequence_number = t.readUint32();
|
|
1479
|
+
}), s.createFullBoxCtor("mfro", "MovieFragmentRandomAccessOffsetBox", function(t) {
|
|
1480
|
+
this._size = t.readUint32();
|
|
1481
|
+
}), s.createFullBoxCtor("mskC", "MaskConfigurationProperty", function(t) {
|
|
1482
|
+
this.bits_per_pixel = t.readUint8();
|
|
1483
|
+
}), s.createFullBoxCtor("mvhd", "MovieHeaderBox", function(t) {
|
|
1484
|
+
this.version == 1 ? (this.creation_time = t.readUint64(), this.modification_time = t.readUint64(), this.timescale = t.readUint32(), this.duration = t.readUint64()) : (this.creation_time = t.readUint32(), this.modification_time = t.readUint32(), this.timescale = t.readUint32(), this.duration = t.readUint32()), this.rate = t.readUint32(), this.volume = t.readUint16() >> 8, t.readUint16(), t.readUint32Array(2), this.matrix = t.readUint32Array(9), t.readUint32Array(6), this.next_track_id = t.readUint32();
|
|
1485
|
+
}), s.createBoxCtor("npck", "hintPacketsSent", function(t) {
|
|
1486
|
+
this.packetssent = t.readUint32();
|
|
1487
|
+
}), s.createBoxCtor("nump", "hintPacketsSent", function(t) {
|
|
1488
|
+
this.packetssent = t.readUint64();
|
|
1489
|
+
}), s.createFullBoxCtor("padb", "PaddingBitsBox", function(t) {
|
|
1490
|
+
var e = t.readUint32();
|
|
1491
|
+
this.padbits = [];
|
|
1492
|
+
for (var r = 0; r < Math.floor((e + 1) / 2); r++)
|
|
1493
|
+
this.padbits = t.readUint8();
|
|
1494
|
+
}), s.createBoxCtor("pasp", "PixelAspectRatioBox", function(t) {
|
|
1495
|
+
this.hSpacing = t.readUint32(), this.vSpacing = t.readUint32();
|
|
1496
|
+
}), s.createBoxCtor("payl", "CuePayloadBox", function(t) {
|
|
1497
|
+
this.text = t.readString(this.size - this.hdr_size);
|
|
1498
|
+
}), s.createBoxCtor("payt", "hintpayloadID", function(t) {
|
|
1499
|
+
this.payloadID = t.readUint32();
|
|
1500
|
+
var e = t.readUint8();
|
|
1501
|
+
this.rtpmap_string = t.readString(e);
|
|
1502
|
+
}), s.createFullBoxCtor("pdin", "ProgressiveDownloadInfoBox", function(t) {
|
|
1503
|
+
var e = (this.size - this.hdr_size) / 8;
|
|
1504
|
+
this.rate = [], this.initial_delay = [];
|
|
1505
|
+
for (var r = 0; r < e; r++)
|
|
1506
|
+
this.rate[r] = t.readUint32(), this.initial_delay[r] = t.readUint32();
|
|
1507
|
+
}), s.createFullBoxCtor("pitm", "PrimaryItemBox", function(t) {
|
|
1508
|
+
this.version === 0 ? this.item_id = t.readUint16() : this.item_id = t.readUint32();
|
|
1509
|
+
}), s.createFullBoxCtor("pixi", "PixelInformationProperty", function(t) {
|
|
1510
|
+
var e;
|
|
1511
|
+
for (this.num_channels = t.readUint8(), this.bits_per_channels = [], e = 0; e < this.num_channels; e++)
|
|
1512
|
+
this.bits_per_channels[e] = t.readUint8();
|
|
1513
|
+
}), s.createBoxCtor("pmax", "hintlargestpacket", function(t) {
|
|
1514
|
+
this.bytes = t.readUint32();
|
|
1515
|
+
}), s.createFullBoxCtor("prdi", "ProgressiveDerivedImageItemInformationProperty", function(t) {
|
|
1516
|
+
if (this.step_count = t.readUint16(), this.item_count = [], this.flags & 2)
|
|
1517
|
+
for (var e = 0; e < this.step_count; e++)
|
|
1518
|
+
this.item_count[e] = t.readUint16();
|
|
1519
|
+
}), s.createFullBoxCtor("prft", "ProducerReferenceTimeBox", function(t) {
|
|
1520
|
+
this.ref_track_id = t.readUint32(), this.ntp_timestamp = t.readUint64(), this.version === 0 ? this.media_time = t.readUint32() : this.media_time = t.readUint64();
|
|
1521
|
+
}), s.createFullBoxCtor("pssh", "ProtectionSystemSpecificHeaderBox", function(t) {
|
|
1522
|
+
if (this.system_id = s.parseHex16(t), this.version > 0) {
|
|
1523
|
+
var e = t.readUint32();
|
|
1524
|
+
this.kid = [];
|
|
1525
|
+
for (var r = 0; r < e; r++)
|
|
1526
|
+
this.kid[r] = s.parseHex16(t);
|
|
1527
|
+
}
|
|
1528
|
+
var n = t.readUint32();
|
|
1529
|
+
n > 0 && (this.data = t.readUint8Array(n));
|
|
1530
|
+
}), s.createFullBoxCtor("clef", "TrackCleanApertureDimensionsBox", function(t) {
|
|
1531
|
+
this.width = t.readUint32(), this.height = t.readUint32();
|
|
1532
|
+
}), s.createFullBoxCtor("enof", "TrackEncodedPixelsDimensionsBox", function(t) {
|
|
1533
|
+
this.width = t.readUint32(), this.height = t.readUint32();
|
|
1534
|
+
}), s.createFullBoxCtor("prof", "TrackProductionApertureDimensionsBox", function(t) {
|
|
1535
|
+
this.width = t.readUint32(), this.height = t.readUint32();
|
|
1536
|
+
}), s.createContainerBoxCtor("tapt", "TrackApertureModeDimensionsBox", null, ["clef", "prof", "enof"]), s.createBoxCtor("rtp ", "rtpmoviehintinformation", function(t) {
|
|
1537
|
+
this.descriptionformat = t.readString(4), this.sdptext = t.readString(this.size - this.hdr_size - 4);
|
|
1538
|
+
}), s.createFullBoxCtor("saio", "SampleAuxiliaryInformationOffsetsBox", function(t) {
|
|
1539
|
+
this.flags & 1 && (this.aux_info_type = t.readString(4), this.aux_info_type_parameter = t.readUint32());
|
|
1540
|
+
var e = t.readUint32();
|
|
1541
|
+
this.offset = [];
|
|
1542
|
+
for (var r = 0; r < e; r++)
|
|
1543
|
+
this.version === 0 ? this.offset[r] = t.readUint32() : this.offset[r] = t.readUint64();
|
|
1544
|
+
}), s.createFullBoxCtor("saiz", "SampleAuxiliaryInformationSizesBox", function(t) {
|
|
1545
|
+
if (this.flags & 1 && (this.aux_info_type = t.readString(4), this.aux_info_type_parameter = t.readUint32()), this.default_sample_info_size = t.readUint8(), this.sample_count = t.readUint32(), this.sample_info_size = [], this.default_sample_info_size === 0)
|
|
1546
|
+
for (var e = 0; e < this.sample_count; e++)
|
|
1547
|
+
this.sample_info_size[e] = t.readUint8();
|
|
1548
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_METADATA, "mett", function(t) {
|
|
1549
|
+
this.parseHeader(t), this.content_encoding = t.readCString(), this.mime_format = t.readCString(), this.parseFooter(t);
|
|
1550
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_METADATA, "metx", function(t) {
|
|
1551
|
+
this.parseHeader(t), this.content_encoding = t.readCString(), this.namespace = t.readCString(), this.schema_location = t.readCString(), this.parseFooter(t);
|
|
1552
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE, "sbtt", function(t) {
|
|
1553
|
+
this.parseHeader(t), this.content_encoding = t.readCString(), this.mime_format = t.readCString(), this.parseFooter(t);
|
|
1554
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE, "stpp", function(t) {
|
|
1555
|
+
this.parseHeader(t), this.namespace = t.readCString(), this.schema_location = t.readCString(), this.auxiliary_mime_types = t.readCString(), this.parseFooter(t);
|
|
1556
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE, "stxt", function(t) {
|
|
1557
|
+
this.parseHeader(t), this.content_encoding = t.readCString(), this.mime_format = t.readCString(), this.parseFooter(t);
|
|
1558
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_SUBTITLE, "tx3g", function(t) {
|
|
1559
|
+
this.parseHeader(t), this.displayFlags = t.readUint32(), this.horizontal_justification = t.readInt8(), this.vertical_justification = t.readInt8(), this.bg_color_rgba = t.readUint8Array(4), this.box_record = t.readInt16Array(4), this.style_record = t.readUint8Array(12), this.parseFooter(t);
|
|
1560
|
+
}), s.createSampleEntryCtor(s.SAMPLE_ENTRY_TYPE_METADATA, "wvtt", function(t) {
|
|
1561
|
+
this.parseHeader(t), this.parseFooter(t);
|
|
1562
|
+
}), s.createSampleGroupCtor("alst", function(t) {
|
|
1563
|
+
var e, r = t.readUint16();
|
|
1564
|
+
for (this.first_output_sample = t.readUint16(), this.sample_offset = [], e = 0; e < r; e++)
|
|
1565
|
+
this.sample_offset[e] = t.readUint32();
|
|
1566
|
+
var n = this.description_length - 4 - 4 * r;
|
|
1567
|
+
for (this.num_output_samples = [], this.num_total_samples = [], e = 0; e < n / 4; e++)
|
|
1568
|
+
this.num_output_samples[e] = t.readUint16(), this.num_total_samples[e] = t.readUint16();
|
|
1569
|
+
}), s.createSampleGroupCtor("avll", function(t) {
|
|
1570
|
+
this.layerNumber = t.readUint8(), this.accurateStatisticsFlag = t.readUint8(), this.avgBitRate = t.readUint16(), this.avgFrameRate = t.readUint16();
|
|
1571
|
+
}), s.createSampleGroupCtor("avss", function(t) {
|
|
1572
|
+
this.subSequenceIdentifier = t.readUint16(), this.layerNumber = t.readUint8();
|
|
1573
|
+
var e = t.readUint8();
|
|
1574
|
+
this.durationFlag = e >> 7, this.avgRateFlag = e >> 6 & 1, this.durationFlag && (this.duration = t.readUint32()), this.avgRateFlag && (this.accurateStatisticsFlag = t.readUint8(), this.avgBitRate = t.readUint16(), this.avgFrameRate = t.readUint16()), this.dependency = [];
|
|
1575
|
+
for (var r = t.readUint8(), n = 0; n < r; n++) {
|
|
1576
|
+
var o = {};
|
|
1577
|
+
this.dependency.push(o), o.subSeqDirectionFlag = t.readUint8(), o.layerNumber = t.readUint8(), o.subSequenceIdentifier = t.readUint16();
|
|
1578
|
+
}
|
|
1579
|
+
}), s.createSampleGroupCtor("dtrt", function(t) {
|
|
1580
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1581
|
+
}), s.createSampleGroupCtor("mvif", function(t) {
|
|
1582
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1583
|
+
}), s.createSampleGroupCtor("prol", function(t) {
|
|
1584
|
+
this.roll_distance = t.readInt16();
|
|
1585
|
+
}), s.createSampleGroupCtor("rap ", function(t) {
|
|
1586
|
+
var e = t.readUint8();
|
|
1587
|
+
this.num_leading_samples_known = e >> 7, this.num_leading_samples = e & 127;
|
|
1588
|
+
}), s.createSampleGroupCtor("rash", function(t) {
|
|
1589
|
+
if (this.operation_point_count = t.readUint16(), this.description_length !== 2 + (this.operation_point_count === 1 ? 2 : this.operation_point_count * 6) + 9)
|
|
1590
|
+
l.warn("BoxParser", "Mismatch in " + this.grouping_type + " sample group length"), this.data = t.readUint8Array(this.description_length - 2);
|
|
1591
|
+
else {
|
|
1592
|
+
if (this.operation_point_count === 1)
|
|
1593
|
+
this.target_rate_share = t.readUint16();
|
|
1594
|
+
else {
|
|
1595
|
+
this.target_rate_share = [], this.available_bitrate = [];
|
|
1596
|
+
for (var e = 0; e < this.operation_point_count; e++)
|
|
1597
|
+
this.available_bitrate[e] = t.readUint32(), this.target_rate_share[e] = t.readUint16();
|
|
1598
|
+
}
|
|
1599
|
+
this.maximum_bitrate = t.readUint32(), this.minimum_bitrate = t.readUint32(), this.discard_priority = t.readUint8();
|
|
1600
|
+
}
|
|
1601
|
+
}), s.createSampleGroupCtor("roll", function(t) {
|
|
1602
|
+
this.roll_distance = t.readInt16();
|
|
1603
|
+
}), s.SampleGroupEntry.prototype.parse = function(t) {
|
|
1604
|
+
l.warn("BoxParser", "Unknown Sample Group type: " + this.grouping_type), this.data = t.readUint8Array(this.description_length);
|
|
1605
|
+
}, s.createSampleGroupCtor("scif", function(t) {
|
|
1606
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1607
|
+
}), s.createSampleGroupCtor("scnm", function(t) {
|
|
1608
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1609
|
+
}), s.createSampleGroupCtor("seig", function(t) {
|
|
1610
|
+
this.reserved = t.readUint8();
|
|
1611
|
+
var e = t.readUint8();
|
|
1612
|
+
this.crypt_byte_block = e >> 4, this.skip_byte_block = e & 15, this.isProtected = t.readUint8(), this.Per_Sample_IV_Size = t.readUint8(), this.KID = s.parseHex16(t), this.constant_IV_size = 0, this.constant_IV = 0, this.isProtected === 1 && this.Per_Sample_IV_Size === 0 && (this.constant_IV_size = t.readUint8(), this.constant_IV = t.readUint8Array(this.constant_IV_size));
|
|
1613
|
+
}), s.createSampleGroupCtor("stsa", function(t) {
|
|
1614
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1615
|
+
}), s.createSampleGroupCtor("sync", function(t) {
|
|
1616
|
+
var e = t.readUint8();
|
|
1617
|
+
this.NAL_unit_type = e & 63;
|
|
1618
|
+
}), s.createSampleGroupCtor("tele", function(t) {
|
|
1619
|
+
var e = t.readUint8();
|
|
1620
|
+
this.level_independently_decodable = e >> 7;
|
|
1621
|
+
}), s.createSampleGroupCtor("tsas", function(t) {
|
|
1622
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1623
|
+
}), s.createSampleGroupCtor("tscl", function(t) {
|
|
1624
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1625
|
+
}), s.createSampleGroupCtor("vipr", function(t) {
|
|
1626
|
+
l.warn("BoxParser", "Sample Group type: " + this.grouping_type + " not fully parsed");
|
|
1627
|
+
}), s.createFullBoxCtor("sbgp", "SampleToGroupBox", function(t) {
|
|
1628
|
+
this.grouping_type = t.readString(4), this.version === 1 ? this.grouping_type_parameter = t.readUint32() : this.grouping_type_parameter = 0, this.entries = [];
|
|
1629
|
+
for (var e = t.readUint32(), r = 0; r < e; r++) {
|
|
1630
|
+
var n = {};
|
|
1631
|
+
this.entries.push(n), n.sample_count = t.readInt32(), n.group_description_index = t.readInt32();
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
function J(t, e) {
|
|
1635
|
+
this.bad_pixel_row = t, this.bad_pixel_column = e;
|
|
1636
|
+
}
|
|
1637
|
+
J.prototype.toString = function() {
|
|
1638
|
+
return "[row: " + this.bad_pixel_row + ", column: " + this.bad_pixel_column + "]";
|
|
1639
|
+
}, s.createFullBoxCtor("sbpm", "SensorBadPixelsMapBox", function(t) {
|
|
1640
|
+
var e;
|
|
1641
|
+
for (this.component_count = t.readUint16(), this.component_index = [], e = 0; e < this.component_count; e++)
|
|
1642
|
+
this.component_index.push(t.readUint16());
|
|
1643
|
+
var r = t.readUint8();
|
|
1644
|
+
for (this.correction_applied = (r & 128) == 128, this.num_bad_rows = t.readUint32(), this.num_bad_cols = t.readUint32(), this.num_bad_pixels = t.readUint32(), this.bad_rows = [], this.bad_columns = [], this.bad_pixels = [], e = 0; e < this.num_bad_rows; e++)
|
|
1645
|
+
this.bad_rows.push(t.readUint32());
|
|
1646
|
+
for (e = 0; e < this.num_bad_cols; e++)
|
|
1647
|
+
this.bad_columns.push(t.readUint32());
|
|
1648
|
+
for (e = 0; e < this.num_bad_pixels; e++) {
|
|
1649
|
+
var n = t.readUint32(), o = t.readUint32();
|
|
1650
|
+
this.bad_pixels.push(new J(n, o));
|
|
1651
|
+
}
|
|
1652
|
+
}), s.createFullBoxCtor("schm", "SchemeTypeBox", function(t) {
|
|
1653
|
+
this.scheme_type = t.readString(4), this.scheme_version = t.readUint32(), this.flags & 1 && (this.scheme_uri = t.readString(this.size - this.hdr_size - 8));
|
|
1654
|
+
}), s.createBoxCtor("sdp ", "rtptracksdphintinformation", function(t) {
|
|
1655
|
+
this.sdptext = t.readString(this.size - this.hdr_size);
|
|
1656
|
+
}), s.createFullBoxCtor("sdtp", "SampleDependencyTypeBox", function(t) {
|
|
1657
|
+
var e, r = this.size - this.hdr_size;
|
|
1658
|
+
this.is_leading = [], this.sample_depends_on = [], this.sample_is_depended_on = [], this.sample_has_redundancy = [];
|
|
1659
|
+
for (var n = 0; n < r; n++)
|
|
1660
|
+
e = t.readUint8(), this.is_leading[n] = e >> 6, this.sample_depends_on[n] = e >> 4 & 3, this.sample_is_depended_on[n] = e >> 2 & 3, this.sample_has_redundancy[n] = e & 3;
|
|
1661
|
+
}), s.createFullBoxCtor(
|
|
1662
|
+
"senc",
|
|
1663
|
+
"SampleEncryptionBox"
|
|
1664
|
+
/*, function(stream) {
|
|
1665
|
+
this.parseFullHeader(stream);
|
|
1666
|
+
var sample_count = stream.readUint32();
|
|
1667
|
+
this.samples = [];
|
|
1668
|
+
for (var i = 0; i < sample_count; i++) {
|
|
1669
|
+
var sample = {};
|
|
1670
|
+
// tenc.default_Per_Sample_IV_Size or seig.Per_Sample_IV_Size
|
|
1671
|
+
sample.InitializationVector = this.readUint8Array(Per_Sample_IV_Size*8);
|
|
1672
|
+
if (this.flags & 0x2) {
|
|
1673
|
+
sample.subsamples = [];
|
|
1674
|
+
subsample_count = stream.readUint16();
|
|
1675
|
+
for (var j = 0; j < subsample_count; j++) {
|
|
1676
|
+
var subsample = {};
|
|
1677
|
+
subsample.BytesOfClearData = stream.readUint16();
|
|
1678
|
+
subsample.BytesOfProtectedData = stream.readUint32();
|
|
1679
|
+
sample.subsamples.push(subsample);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
// TODO
|
|
1683
|
+
this.samples.push(sample);
|
|
1684
|
+
}
|
|
1685
|
+
}*/
|
|
1686
|
+
), s.createFullBoxCtor("sgpd", "SampleGroupDescriptionBox", function(t) {
|
|
1687
|
+
this.grouping_type = t.readString(4), l.debug("BoxParser", "Found Sample Groups of type " + this.grouping_type), this.version === 1 ? this.default_length = t.readUint32() : this.default_length = 0, this.version >= 2 && (this.default_group_description_index = t.readUint32()), this.entries = [];
|
|
1688
|
+
for (var e = t.readUint32(), r = 0; r < e; r++) {
|
|
1689
|
+
var n;
|
|
1690
|
+
s[this.grouping_type + "SampleGroupEntry"] ? n = new s[this.grouping_type + "SampleGroupEntry"](this.grouping_type) : n = new s.SampleGroupEntry(this.grouping_type), this.entries.push(n), this.version === 1 ? this.default_length === 0 ? n.description_length = t.readUint32() : n.description_length = this.default_length : n.description_length = this.default_length, n.write === s.SampleGroupEntry.prototype.write && (l.info("BoxParser", "SampleGroup for type " + this.grouping_type + " writing not yet implemented, keeping unparsed data in memory for later write"), n.data = t.readUint8Array(n.description_length), t.position -= n.description_length), n.parse(t);
|
|
1691
|
+
}
|
|
1692
|
+
}), s.createFullBoxCtor("sidx", "CompressedSegmentIndexBox", function(t) {
|
|
1693
|
+
this.reference_ID = t.readUint32(), this.timescale = t.readUint32(), this.version === 0 ? (this.earliest_presentation_time = t.readUint32(), this.first_offset = t.readUint32()) : (this.earliest_presentation_time = t.readUint64(), this.first_offset = t.readUint64()), t.readUint16(), this.references = [];
|
|
1694
|
+
for (var e = t.readUint16(), r = 0; r < e; r++) {
|
|
1695
|
+
var n = {};
|
|
1696
|
+
this.references.push(n);
|
|
1697
|
+
var o = t.readUint32();
|
|
1698
|
+
n.reference_type = o >> 31 & 1, n.referenced_size = o & 2147483647, n.subsegment_duration = t.readUint32(), o = t.readUint32(), n.starts_with_SAP = o >> 31 & 1, n.SAP_type = o >> 28 & 7, n.SAP_delta_time = o & 268435455;
|
|
1699
|
+
}
|
|
1700
|
+
}), s.SingleItemTypeReferenceBox = function(t, e, r, n) {
|
|
1701
|
+
s.Box.call(this, t, e), this.hdr_size = r, this.start = n;
|
|
1702
|
+
}, s.SingleItemTypeReferenceBox.prototype = new s.Box(), s.SingleItemTypeReferenceBox.prototype.parse = function(t) {
|
|
1703
|
+
this.from_item_ID = t.readUint16();
|
|
1704
|
+
var e = t.readUint16();
|
|
1705
|
+
this.references = [];
|
|
1706
|
+
for (var r = 0; r < e; r++)
|
|
1707
|
+
this.references[r] = {}, this.references[r].to_item_ID = t.readUint16();
|
|
1708
|
+
}, s.SingleItemTypeReferenceBoxLarge = function(t, e, r, n) {
|
|
1709
|
+
s.Box.call(this, t, e), this.hdr_size = r, this.start = n;
|
|
1710
|
+
}, s.SingleItemTypeReferenceBoxLarge.prototype = new s.Box(), s.SingleItemTypeReferenceBoxLarge.prototype.parse = function(t) {
|
|
1711
|
+
this.from_item_ID = t.readUint32();
|
|
1712
|
+
var e = t.readUint16();
|
|
1713
|
+
this.references = [];
|
|
1714
|
+
for (var r = 0; r < e; r++)
|
|
1715
|
+
this.references[r] = {}, this.references[r].to_item_ID = t.readUint32();
|
|
1716
|
+
}, s.createFullBoxCtor("SmDm", "SMPTE2086MasteringDisplayMetadataBox", function(t) {
|
|
1717
|
+
this.primaryRChromaticity_x = t.readUint16(), this.primaryRChromaticity_y = t.readUint16(), this.primaryGChromaticity_x = t.readUint16(), this.primaryGChromaticity_y = t.readUint16(), this.primaryBChromaticity_x = t.readUint16(), this.primaryBChromaticity_y = t.readUint16(), this.whitePointChromaticity_x = t.readUint16(), this.whitePointChromaticity_y = t.readUint16(), this.luminanceMax = t.readUint32(), this.luminanceMin = t.readUint32();
|
|
1718
|
+
}), s.createFullBoxCtor("smhd", "SoundMediaHeaderBox", function(t) {
|
|
1719
|
+
this.balance = t.readUint16(), t.readUint16();
|
|
1720
|
+
}), s.createFullBoxCtor("ssix", "CompressedSubsegmentIndexBox", function(t) {
|
|
1721
|
+
this.subsegments = [];
|
|
1722
|
+
for (var e = t.readUint32(), r = 0; r < e; r++) {
|
|
1723
|
+
var n = {};
|
|
1724
|
+
this.subsegments.push(n), n.ranges = [];
|
|
1725
|
+
for (var o = t.readUint32(), a = 0; a < o; a++) {
|
|
1726
|
+
var h = {};
|
|
1727
|
+
n.ranges.push(h), h.level = t.readUint8(), h.range_size = t.readUint24();
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}), s.createFullBoxCtor("stco", "ChunkOffsetBox", function(t) {
|
|
1731
|
+
var e;
|
|
1732
|
+
if (e = t.readUint32(), this.chunk_offsets = [], this.version === 0)
|
|
1733
|
+
for (var r = 0; r < e; r++)
|
|
1734
|
+
this.chunk_offsets.push(t.readUint32());
|
|
1735
|
+
}), s.createFullBoxCtor("stdp", "DegradationPriorityBox", function(t) {
|
|
1736
|
+
var e = (this.size - this.hdr_size) / 2;
|
|
1737
|
+
this.priority = [];
|
|
1738
|
+
for (var r = 0; r < e; r++)
|
|
1739
|
+
this.priority[r] = t.readUint16();
|
|
1740
|
+
}), s.createFullBoxCtor("sthd", "SubtitleMediaHeaderBox"), s.createFullBoxCtor("stri", "SubTrackInformationBox", function(t) {
|
|
1741
|
+
this.switch_group = t.readUint16(), this.alternate_group = t.readUint16(), this.sub_track_id = t.readUint32();
|
|
1742
|
+
var e = (this.size - this.hdr_size - 8) / 4;
|
|
1743
|
+
this.attribute_list = [];
|
|
1744
|
+
for (var r = 0; r < e; r++)
|
|
1745
|
+
this.attribute_list[r] = t.readUint32();
|
|
1746
|
+
}), s.createFullBoxCtor("stsc", "SampleToChunkBox", function(t) {
|
|
1747
|
+
var e, r;
|
|
1748
|
+
if (e = t.readUint32(), this.first_chunk = [], this.samples_per_chunk = [], this.sample_description_index = [], this.version === 0)
|
|
1749
|
+
for (r = 0; r < e; r++)
|
|
1750
|
+
this.first_chunk.push(t.readUint32()), this.samples_per_chunk.push(t.readUint32()), this.sample_description_index.push(t.readUint32());
|
|
1751
|
+
}), s.createFullBoxCtor("stsd", "SampleDescriptionBox", function(t) {
|
|
1752
|
+
var e, r, n, o;
|
|
1753
|
+
for (this.entries = [], n = t.readUint32(), e = 1; e <= n; e++)
|
|
1754
|
+
if (r = s.parseOneBox(t, !0, this.size - (t.getPosition() - this.start)), r.code === s.OK)
|
|
1755
|
+
s[r.type + "SampleEntry"] ? (o = new s[r.type + "SampleEntry"](r.size), o.hdr_size = r.hdr_size, o.start = r.start) : (l.warn("BoxParser", "Unknown sample entry type: " + r.type), o = new s.SampleEntry(r.type, r.size, r.hdr_size, r.start)), o.write === s.SampleEntry.prototype.write && (l.info("BoxParser", "SampleEntry " + o.type + " box writing not yet implemented, keeping unparsed data in memory for later write"), o.parseDataAndRewind(t)), o.parse(t), this.entries.push(o);
|
|
1756
|
+
else
|
|
1757
|
+
return;
|
|
1758
|
+
}), s.createFullBoxCtor("stsg", "SubTrackSampleGroupBox", function(t) {
|
|
1759
|
+
this.grouping_type = t.readUint32();
|
|
1760
|
+
var e = t.readUint16();
|
|
1761
|
+
this.group_description_index = [];
|
|
1762
|
+
for (var r = 0; r < e; r++)
|
|
1763
|
+
this.group_description_index[r] = t.readUint32();
|
|
1764
|
+
}), s.createFullBoxCtor("stsh", "ShadowSyncSampleBox", function(t) {
|
|
1765
|
+
var e, r;
|
|
1766
|
+
if (e = t.readUint32(), this.shadowed_sample_numbers = [], this.sync_sample_numbers = [], this.version === 0)
|
|
1767
|
+
for (r = 0; r < e; r++)
|
|
1768
|
+
this.shadowed_sample_numbers.push(t.readUint32()), this.sync_sample_numbers.push(t.readUint32());
|
|
1769
|
+
}), s.createFullBoxCtor("stss", "SyncSampleBox", function(t) {
|
|
1770
|
+
var e, r;
|
|
1771
|
+
if (r = t.readUint32(), this.version === 0)
|
|
1772
|
+
for (this.sample_numbers = [], e = 0; e < r; e++)
|
|
1773
|
+
this.sample_numbers.push(t.readUint32());
|
|
1774
|
+
}), s.createFullBoxCtor("stsz", "SampleSizeBox", function(t) {
|
|
1775
|
+
var e;
|
|
1776
|
+
if (this.sample_sizes = [], this.version === 0)
|
|
1777
|
+
for (this.sample_size = t.readUint32(), this.sample_count = t.readUint32(), e = 0; e < this.sample_count; e++)
|
|
1778
|
+
this.sample_size === 0 ? this.sample_sizes.push(t.readUint32()) : this.sample_sizes[e] = this.sample_size;
|
|
1779
|
+
}), s.createFullBoxCtor("stts", "TimeToSampleBox", function(t) {
|
|
1780
|
+
var e, r, n;
|
|
1781
|
+
if (e = t.readUint32(), this.sample_counts = [], this.sample_deltas = [], this.version === 0)
|
|
1782
|
+
for (r = 0; r < e; r++)
|
|
1783
|
+
this.sample_counts.push(t.readUint32()), n = t.readInt32(), n < 0 && (l.warn("BoxParser", "File uses negative stts sample delta, using value 1 instead, sync may be lost!"), n = 1), this.sample_deltas.push(n);
|
|
1784
|
+
}), s.createFullBoxCtor("stvi", "StereoVideoBox", function(t) {
|
|
1785
|
+
var e = t.readUint32();
|
|
1786
|
+
this.single_view_allowed = e & 3, this.stereo_scheme = t.readUint32();
|
|
1787
|
+
var r = t.readUint32();
|
|
1788
|
+
this.stereo_indication_type = t.readString(r);
|
|
1789
|
+
var n, o;
|
|
1790
|
+
for (this.boxes = []; t.getPosition() < this.start + this.size; )
|
|
1791
|
+
if (n = s.parseOneBox(t, !1, this.size - (t.getPosition() - this.start)), n.code === s.OK)
|
|
1792
|
+
o = n.box, this.boxes.push(o), this[o.type] = o;
|
|
1793
|
+
else
|
|
1794
|
+
return;
|
|
1795
|
+
}), s.createBoxCtor("styp", "SegmentTypeBox", function(t) {
|
|
1796
|
+
s.ftypBox.prototype.parse.call(this, t);
|
|
1797
|
+
}), s.createFullBoxCtor("stz2", "CompactSampleSizeBox", function(t) {
|
|
1798
|
+
var e, r;
|
|
1799
|
+
if (this.sample_sizes = [], this.version === 0)
|
|
1800
|
+
if (this.reserved = t.readUint24(), this.field_size = t.readUint8(), r = t.readUint32(), this.field_size === 4)
|
|
1801
|
+
for (e = 0; e < r; e += 2) {
|
|
1802
|
+
var n = t.readUint8();
|
|
1803
|
+
this.sample_sizes[e] = n >> 4 & 15, this.sample_sizes[e + 1] = n & 15;
|
|
1804
|
+
}
|
|
1805
|
+
else if (this.field_size === 8)
|
|
1806
|
+
for (e = 0; e < r; e++)
|
|
1807
|
+
this.sample_sizes[e] = t.readUint8();
|
|
1808
|
+
else if (this.field_size === 16)
|
|
1809
|
+
for (e = 0; e < r; e++)
|
|
1810
|
+
this.sample_sizes[e] = t.readUint16();
|
|
1811
|
+
else
|
|
1812
|
+
l.error("BoxParser", "Error in length field in stz2 box");
|
|
1813
|
+
}), s.createFullBoxCtor("subs", "SubSampleInformationBox", function(t) {
|
|
1814
|
+
var e, r, n, o;
|
|
1815
|
+
for (n = t.readUint32(), this.entries = [], e = 0; e < n; e++) {
|
|
1816
|
+
var a = {};
|
|
1817
|
+
if (this.entries[e] = a, a.sample_delta = t.readUint32(), a.subsamples = [], o = t.readUint16(), o > 0)
|
|
1818
|
+
for (r = 0; r < o; r++) {
|
|
1819
|
+
var h = {};
|
|
1820
|
+
a.subsamples.push(h), this.version == 1 ? h.size = t.readUint32() : h.size = t.readUint16(), h.priority = t.readUint8(), h.discardable = t.readUint8(), h.codec_specific_parameters = t.readUint32();
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}), s.createFullBoxCtor("tenc", "TrackEncryptionBox", function(t) {
|
|
1824
|
+
if (t.readUint8(), this.version === 0)
|
|
1825
|
+
t.readUint8();
|
|
1826
|
+
else {
|
|
1827
|
+
var e = t.readUint8();
|
|
1828
|
+
this.default_crypt_byte_block = e >> 4 & 15, this.default_skip_byte_block = e & 15;
|
|
1829
|
+
}
|
|
1830
|
+
this.default_isProtected = t.readUint8(), this.default_Per_Sample_IV_Size = t.readUint8(), this.default_KID = s.parseHex16(t), this.default_isProtected === 1 && this.default_Per_Sample_IV_Size === 0 && (this.default_constant_IV_size = t.readUint8(), this.default_constant_IV = t.readUint8Array(this.default_constant_IV_size));
|
|
1831
|
+
}), s.createFullBoxCtor("tfdt", "TrackFragmentBaseMediaDecodeTimeBox", function(t) {
|
|
1832
|
+
this.version == 1 ? this.baseMediaDecodeTime = t.readUint64() : this.baseMediaDecodeTime = t.readUint32();
|
|
1833
|
+
}), s.createFullBoxCtor("tfhd", "TrackFragmentHeaderBox", function(t) {
|
|
1834
|
+
var e = 0;
|
|
1835
|
+
this.track_id = t.readUint32(), this.size - this.hdr_size > e && this.flags & s.TFHD_FLAG_BASE_DATA_OFFSET ? (this.base_data_offset = t.readUint64(), e += 8) : this.base_data_offset = 0, this.size - this.hdr_size > e && this.flags & s.TFHD_FLAG_SAMPLE_DESC ? (this.default_sample_description_index = t.readUint32(), e += 4) : this.default_sample_description_index = 0, this.size - this.hdr_size > e && this.flags & s.TFHD_FLAG_SAMPLE_DUR ? (this.default_sample_duration = t.readUint32(), e += 4) : this.default_sample_duration = 0, this.size - this.hdr_size > e && this.flags & s.TFHD_FLAG_SAMPLE_SIZE ? (this.default_sample_size = t.readUint32(), e += 4) : this.default_sample_size = 0, this.size - this.hdr_size > e && this.flags & s.TFHD_FLAG_SAMPLE_FLAGS ? (this.default_sample_flags = t.readUint32(), e += 4) : this.default_sample_flags = 0;
|
|
1836
|
+
}), s.createFullBoxCtor("tfra", "TrackFragmentRandomAccessBox", function(t) {
|
|
1837
|
+
this.track_ID = t.readUint32(), t.readUint24();
|
|
1838
|
+
var e = t.readUint8();
|
|
1839
|
+
this.length_size_of_traf_num = e >> 4 & 3, this.length_size_of_trun_num = e >> 2 & 3, this.length_size_of_sample_num = e & 3, this.entries = [];
|
|
1840
|
+
for (var r = t.readUint32(), n = 0; n < r; n++)
|
|
1841
|
+
this.version === 1 ? (this.time = t.readUint64(), this.moof_offset = t.readUint64()) : (this.time = t.readUint32(), this.moof_offset = t.readUint32()), this.traf_number = t["readUint" + 8 * (this.length_size_of_traf_num + 1)](), this.trun_number = t["readUint" + 8 * (this.length_size_of_trun_num + 1)](), this.sample_number = t["readUint" + 8 * (this.length_size_of_sample_num + 1)]();
|
|
1842
|
+
}), s.createFullBoxCtor("tkhd", "TrackHeaderBox", function(t) {
|
|
1843
|
+
this.version == 1 ? (this.creation_time = t.readUint64(), this.modification_time = t.readUint64(), this.track_id = t.readUint32(), t.readUint32(), this.duration = t.readUint64()) : (this.creation_time = t.readUint32(), this.modification_time = t.readUint32(), this.track_id = t.readUint32(), t.readUint32(), this.duration = t.readUint32()), t.readUint32Array(2), this.layer = t.readInt16(), this.alternate_group = t.readInt16(), this.volume = t.readInt16() >> 8, t.readUint16(), this.matrix = t.readInt32Array(9), this.width = t.readUint32(), this.height = t.readUint32();
|
|
1844
|
+
}), s.createBoxCtor("tmax", "hintmaxrelativetime", function(t) {
|
|
1845
|
+
this.time = t.readUint32();
|
|
1846
|
+
}), s.createBoxCtor("tmin", "hintminrelativetime", function(t) {
|
|
1847
|
+
this.time = t.readUint32();
|
|
1848
|
+
}), s.createBoxCtor("totl", "hintBytesSent", function(t) {
|
|
1849
|
+
this.bytessent = t.readUint32();
|
|
1850
|
+
}), s.createBoxCtor("tpay", "hintBytesSent", function(t) {
|
|
1851
|
+
this.bytessent = t.readUint32();
|
|
1852
|
+
}), s.createBoxCtor("tpyl", "hintBytesSent", function(t) {
|
|
1853
|
+
this.bytessent = t.readUint64();
|
|
1854
|
+
}), s.TrackGroupTypeBox.prototype.parse = function(t) {
|
|
1855
|
+
this.parseFullHeader(t), this.track_group_id = t.readUint32();
|
|
1856
|
+
}, s.createTrackGroupCtor("msrc"), s.TrackReferenceTypeBox = function(t, e, r, n) {
|
|
1857
|
+
s.Box.call(this, t, e), this.hdr_size = r, this.start = n;
|
|
1858
|
+
}, s.TrackReferenceTypeBox.prototype = new s.Box(), s.TrackReferenceTypeBox.prototype.parse = function(t) {
|
|
1859
|
+
this.track_ids = t.readUint32Array((this.size - this.hdr_size) / 4);
|
|
1860
|
+
}, s.trefBox.prototype.parse = function(t) {
|
|
1861
|
+
for (var e, r; t.getPosition() < this.start + this.size; )
|
|
1862
|
+
if (e = s.parseOneBox(t, !0, this.size - (t.getPosition() - this.start)), e.code === s.OK)
|
|
1863
|
+
r = new s.TrackReferenceTypeBox(e.type, e.size, e.hdr_size, e.start), r.write === s.Box.prototype.write && r.type !== "mdat" && (l.info("BoxParser", "TrackReference " + r.type + " box writing not yet implemented, keeping unparsed data in memory for later write"), r.parseDataAndRewind(t)), r.parse(t), this.boxes.push(r);
|
|
1864
|
+
else
|
|
1865
|
+
return;
|
|
1866
|
+
}, s.createFullBoxCtor("trep", "TrackExtensionPropertiesBox", function(t) {
|
|
1867
|
+
for (this.track_ID = t.readUint32(), this.boxes = []; t.getPosition() < this.start + this.size; )
|
|
1868
|
+
if (ret = s.parseOneBox(t, !1, this.size - (t.getPosition() - this.start)), ret.code === s.OK)
|
|
1869
|
+
box = ret.box, this.boxes.push(box);
|
|
1870
|
+
else
|
|
1871
|
+
return;
|
|
1872
|
+
}), s.createFullBoxCtor("trex", "TrackExtendsBox", function(t) {
|
|
1873
|
+
this.track_id = t.readUint32(), this.default_sample_description_index = t.readUint32(), this.default_sample_duration = t.readUint32(), this.default_sample_size = t.readUint32(), this.default_sample_flags = t.readUint32();
|
|
1874
|
+
}), s.createBoxCtor("trpy", "hintBytesSent", function(t) {
|
|
1875
|
+
this.bytessent = t.readUint64();
|
|
1876
|
+
}), s.createFullBoxCtor("trun", "TrackRunBox", function(t) {
|
|
1877
|
+
var e = 0;
|
|
1878
|
+
if (this.sample_count = t.readUint32(), e += 4, this.size - this.hdr_size > e && this.flags & s.TRUN_FLAGS_DATA_OFFSET ? (this.data_offset = t.readInt32(), e += 4) : this.data_offset = 0, this.size - this.hdr_size > e && this.flags & s.TRUN_FLAGS_FIRST_FLAG ? (this.first_sample_flags = t.readUint32(), e += 4) : this.first_sample_flags = 0, this.sample_duration = [], this.sample_size = [], this.sample_flags = [], this.sample_composition_time_offset = [], this.size - this.hdr_size > e)
|
|
1879
|
+
for (var r = 0; r < this.sample_count; r++)
|
|
1880
|
+
this.flags & s.TRUN_FLAGS_DURATION && (this.sample_duration[r] = t.readUint32()), this.flags & s.TRUN_FLAGS_SIZE && (this.sample_size[r] = t.readUint32()), this.flags & s.TRUN_FLAGS_FLAGS && (this.sample_flags[r] = t.readUint32()), this.flags & s.TRUN_FLAGS_CTS_OFFSET && (this.version === 0 ? this.sample_composition_time_offset[r] = t.readUint32() : this.sample_composition_time_offset[r] = t.readInt32());
|
|
1881
|
+
}), s.createFullBoxCtor("tsel", "TrackSelectionBox", function(t) {
|
|
1882
|
+
this.switch_group = t.readUint32();
|
|
1883
|
+
var e = (this.size - this.hdr_size - 4) / 4;
|
|
1884
|
+
this.attribute_list = [];
|
|
1885
|
+
for (var r = 0; r < e; r++)
|
|
1886
|
+
this.attribute_list[r] = t.readUint32();
|
|
1887
|
+
}), s.createFullBoxCtor("txtC", "TextConfigBox", function(t) {
|
|
1888
|
+
this.config = t.readCString();
|
|
1889
|
+
}), s.createBoxCtor("tyco", "TypeCombinationBox", function(t) {
|
|
1890
|
+
var e = (this.size - this.hdr_size) / 4;
|
|
1891
|
+
this.compatible_brands = [];
|
|
1892
|
+
for (var r = 0; r < e; r++)
|
|
1893
|
+
this.compatible_brands[r] = t.readString(4);
|
|
1894
|
+
}), s.createFullBoxCtor("udes", "UserDescriptionProperty", function(t) {
|
|
1895
|
+
this.lang = t.readCString(), this.name = t.readCString(), this.description = t.readCString(), this.tags = t.readCString();
|
|
1896
|
+
}), s.createFullBoxCtor("uncC", "UncompressedFrameConfigBox", function(t) {
|
|
1897
|
+
var e;
|
|
1898
|
+
if (this.profile = t.readString(4), this.version != 1) {
|
|
1899
|
+
if (this.version == 0) {
|
|
1900
|
+
for (this.component_count = t.readUint32(), this.component_index = [], this.component_bit_depth_minus_one = [], this.component_format = [], this.component_align_size = [], e = 0; e < this.component_count; e++)
|
|
1901
|
+
this.component_index.push(t.readUint16()), this.component_bit_depth_minus_one.push(t.readUint8()), this.component_format.push(t.readUint8()), this.component_align_size.push(t.readUint8());
|
|
1902
|
+
this.sampling_type = t.readUint8(), this.interleave_type = t.readUint8(), this.block_size = t.readUint8();
|
|
1903
|
+
var r = t.readUint8();
|
|
1904
|
+
this.component_little_endian = r >> 7 & 1, this.block_pad_lsb = r >> 6 & 1, this.block_little_endian = r >> 5 & 1, this.block_reversed = r >> 4 & 1, this.pad_unknown = r >> 3 & 1, this.pixel_size = t.readUint32(), this.row_align_size = t.readUint32(), this.tile_align_size = t.readUint32(), this.num_tile_cols_minus_one = t.readUint32(), this.num_tile_rows_minus_one = t.readUint32();
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
}), s.createFullBoxCtor("url ", "DataEntryUrlBox", function(t) {
|
|
1908
|
+
this.flags !== 1 && (this.location = t.readCString());
|
|
1909
|
+
}), s.createFullBoxCtor("urn ", "DataEntryUrnBox", function(t) {
|
|
1910
|
+
this.name = t.readCString(), this.size - this.hdr_size - this.name.length - 1 > 0 && (this.location = t.readCString());
|
|
1911
|
+
}), s.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66", "LiveServerManifestBox", !0, !1, function(t) {
|
|
1912
|
+
this.LiveServerManifest = t.readString(this.size - this.hdr_size).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1913
|
+
}), s.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3", "PiffProtectionSystemSpecificHeaderBox", !0, !1, function(t) {
|
|
1914
|
+
this.system_id = s.parseHex16(t);
|
|
1915
|
+
var e = t.readUint32();
|
|
1916
|
+
e > 0 && (this.data = t.readUint8Array(e));
|
|
1917
|
+
}), s.createUUIDBox(
|
|
1918
|
+
"a2394f525a9b4f14a2446c427c648df4",
|
|
1919
|
+
"PiffSampleEncryptionBox",
|
|
1920
|
+
!0,
|
|
1921
|
+
!1
|
|
1922
|
+
/*, function(stream) {
|
|
1923
|
+
if (this.flags & 0x1) {
|
|
1924
|
+
this.AlgorithmID = stream.readUint24();
|
|
1925
|
+
this.IV_size = stream.readUint8();
|
|
1926
|
+
this.KID = BoxParser.parseHex16(stream);
|
|
1927
|
+
}
|
|
1928
|
+
var sample_count = stream.readUint32();
|
|
1929
|
+
this.samples = [];
|
|
1930
|
+
for (var i = 0; i < sample_count; i++) {
|
|
1931
|
+
var sample = {};
|
|
1932
|
+
sample.InitializationVector = this.readUint8Array(this.IV_size*8);
|
|
1933
|
+
if (this.flags & 0x2) {
|
|
1934
|
+
sample.subsamples = [];
|
|
1935
|
+
sample.NumberOfEntries = stream.readUint16();
|
|
1936
|
+
for (var j = 0; j < sample.NumberOfEntries; j++) {
|
|
1937
|
+
var subsample = {};
|
|
1938
|
+
subsample.BytesOfClearData = stream.readUint16();
|
|
1939
|
+
subsample.BytesOfProtectedData = stream.readUint32();
|
|
1940
|
+
sample.subsamples.push(subsample);
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
this.samples.push(sample);
|
|
1944
|
+
}
|
|
1945
|
+
}*/
|
|
1946
|
+
), s.createUUIDBox("8974dbce7be74c5184f97148f9882554", "PiffTrackEncryptionBox", !0, !1, function(t) {
|
|
1947
|
+
this.default_AlgorithmID = t.readUint24(), this.default_IV_size = t.readUint8(), this.default_KID = s.parseHex16(t);
|
|
1948
|
+
}), s.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f", "TfrfBox", !0, !1, function(t) {
|
|
1949
|
+
this.fragment_count = t.readUint8(), this.entries = [];
|
|
1950
|
+
for (var e = 0; e < this.fragment_count; e++) {
|
|
1951
|
+
var r = {}, n = 0, o = 0;
|
|
1952
|
+
this.version === 1 ? (n = t.readUint64(), o = t.readUint64()) : (n = t.readUint32(), o = t.readUint32()), r.absolute_time = n, r.absolute_duration = o, this.entries.push(r);
|
|
1953
|
+
}
|
|
1954
|
+
}), s.createUUIDBox("6d1d9b0542d544e680e2141daff757b2", "TfxdBox", !0, !1, function(t) {
|
|
1955
|
+
this.version === 1 ? (this.absolute_time = t.readUint64(), this.duration = t.readUint64()) : (this.absolute_time = t.readUint32(), this.duration = t.readUint32());
|
|
1956
|
+
}), s.createFullBoxCtor("vmhd", "VideoMediaHeaderBox", function(t) {
|
|
1957
|
+
this.graphicsmode = t.readUint16(), this.opcolor = t.readUint16Array(3);
|
|
1958
|
+
}), s.createFullBoxCtor("vpcC", "VPCodecConfigurationRecord", function(t) {
|
|
1959
|
+
var e;
|
|
1960
|
+
this.version === 1 ? (this.profile = t.readUint8(), this.level = t.readUint8(), e = t.readUint8(), this.bitDepth = e >> 4, this.chromaSubsampling = e >> 1 & 7, this.videoFullRangeFlag = e & 1, this.colourPrimaries = t.readUint8(), this.transferCharacteristics = t.readUint8(), this.matrixCoefficients = t.readUint8(), this.codecIntializationDataSize = t.readUint16(), this.codecIntializationData = t.readUint8Array(this.codecIntializationDataSize)) : (this.profile = t.readUint8(), this.level = t.readUint8(), e = t.readUint8(), this.bitDepth = e >> 4 & 15, this.colorSpace = e & 15, e = t.readUint8(), this.chromaSubsampling = e >> 4 & 15, this.transferFunction = e >> 1 & 7, this.videoFullRangeFlag = e & 1, this.codecIntializationDataSize = t.readUint16(), this.codecIntializationData = t.readUint8Array(this.codecIntializationDataSize));
|
|
1961
|
+
}), s.createBoxCtor("vttC", "WebVTTConfigurationBox", function(t) {
|
|
1962
|
+
this.text = t.readString(this.size - this.hdr_size);
|
|
1963
|
+
}), s.createFullBoxCtor("vvcC", "VvcConfigurationBox", function(t) {
|
|
1964
|
+
var e, r, n = {
|
|
1965
|
+
held_bits: void 0,
|
|
1966
|
+
num_held_bits: 0,
|
|
1967
|
+
stream_read_1_bytes: function(m) {
|
|
1968
|
+
this.held_bits = m.readUint8(), this.num_held_bits = 8;
|
|
1969
|
+
},
|
|
1970
|
+
stream_read_2_bytes: function(m) {
|
|
1971
|
+
this.held_bits = m.readUint16(), this.num_held_bits = 16;
|
|
1972
|
+
},
|
|
1973
|
+
extract_bits: function(m) {
|
|
1974
|
+
var E = this.held_bits >> this.num_held_bits - m & (1 << m) - 1;
|
|
1975
|
+
return this.num_held_bits -= m, E;
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
if (n.stream_read_1_bytes(t), n.extract_bits(5), this.lengthSizeMinusOne = n.extract_bits(2), this.ptl_present_flag = n.extract_bits(1), this.ptl_present_flag) {
|
|
1979
|
+
n.stream_read_2_bytes(t), this.ols_idx = n.extract_bits(9), this.num_sublayers = n.extract_bits(3), this.constant_frame_rate = n.extract_bits(2), this.chroma_format_idc = n.extract_bits(2), n.stream_read_1_bytes(t), this.bit_depth_minus8 = n.extract_bits(3), n.extract_bits(5);
|
|
1980
|
+
{
|
|
1981
|
+
if (n.stream_read_2_bytes(t), n.extract_bits(2), this.num_bytes_constraint_info = n.extract_bits(6), this.general_profile_idc = n.extract_bits(7), this.general_tier_flag = n.extract_bits(1), this.general_level_idc = t.readUint8(), n.stream_read_1_bytes(t), this.ptl_frame_only_constraint_flag = n.extract_bits(1), this.ptl_multilayer_enabled_flag = n.extract_bits(1), this.general_constraint_info = new Uint8Array(this.num_bytes_constraint_info), this.num_bytes_constraint_info) {
|
|
1982
|
+
for (e = 0; e < this.num_bytes_constraint_info - 1; e++) {
|
|
1983
|
+
var o = n.extract_bits(6);
|
|
1984
|
+
n.stream_read_1_bytes(t);
|
|
1985
|
+
var a = n.extract_bits(2);
|
|
1986
|
+
this.general_constraint_info[e] = o << 2 | a;
|
|
1987
|
+
}
|
|
1988
|
+
this.general_constraint_info[this.num_bytes_constraint_info - 1] = n.extract_bits(6);
|
|
1989
|
+
} else
|
|
1990
|
+
n.extract_bits(6);
|
|
1991
|
+
if (this.num_sublayers > 1) {
|
|
1992
|
+
for (n.stream_read_1_bytes(t), this.ptl_sublayer_present_mask = 0, r = this.num_sublayers - 2; r >= 0; --r) {
|
|
1993
|
+
var h = n.extract_bits(1);
|
|
1994
|
+
this.ptl_sublayer_present_mask |= h << r;
|
|
1995
|
+
}
|
|
1996
|
+
for (r = this.num_sublayers; r <= 8 && this.num_sublayers > 1; ++r)
|
|
1997
|
+
n.extract_bits(1);
|
|
1998
|
+
for (this.sublayer_level_idc = [], r = this.num_sublayers - 2; r >= 0; --r)
|
|
1999
|
+
this.ptl_sublayer_present_mask & 1 << r && (this.sublayer_level_idc[r] = t.readUint8());
|
|
2000
|
+
}
|
|
2001
|
+
if (this.ptl_num_sub_profiles = t.readUint8(), this.general_sub_profile_idc = [], this.ptl_num_sub_profiles)
|
|
2002
|
+
for (e = 0; e < this.ptl_num_sub_profiles; e++)
|
|
2003
|
+
this.general_sub_profile_idc.push(t.readUint32());
|
|
2004
|
+
}
|
|
2005
|
+
this.max_picture_width = t.readUint16(), this.max_picture_height = t.readUint16(), this.avg_frame_rate = t.readUint16();
|
|
2006
|
+
}
|
|
2007
|
+
var f = 12, p = 13;
|
|
2008
|
+
this.nalu_arrays = [];
|
|
2009
|
+
var u = t.readUint8();
|
|
2010
|
+
for (e = 0; e < u; e++) {
|
|
2011
|
+
var c = [];
|
|
2012
|
+
this.nalu_arrays.push(c), n.stream_read_1_bytes(t), c.completeness = n.extract_bits(1), n.extract_bits(2), c.nalu_type = n.extract_bits(5);
|
|
2013
|
+
var g = 1;
|
|
2014
|
+
for (c.nalu_type != p && c.nalu_type != f && (g = t.readUint16()), r = 0; r < g; r++) {
|
|
2015
|
+
var x = t.readUint16();
|
|
2016
|
+
c.push({
|
|
2017
|
+
data: t.readUint8Array(x),
|
|
2018
|
+
length: x
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
}), s.createFullBoxCtor("vvnC", "VvcNALUConfigBox", function(t) {
|
|
2023
|
+
var e = strm.readUint8();
|
|
2024
|
+
this.lengthSizeMinusOne = e & 3;
|
|
2025
|
+
}), s.SampleEntry.prototype.isVideo = function() {
|
|
2026
|
+
return !1;
|
|
2027
|
+
}, s.SampleEntry.prototype.isAudio = function() {
|
|
2028
|
+
return !1;
|
|
2029
|
+
}, s.SampleEntry.prototype.isSubtitle = function() {
|
|
2030
|
+
return !1;
|
|
2031
|
+
}, s.SampleEntry.prototype.isMetadata = function() {
|
|
2032
|
+
return !1;
|
|
2033
|
+
}, s.SampleEntry.prototype.isHint = function() {
|
|
2034
|
+
return !1;
|
|
2035
|
+
}, s.SampleEntry.prototype.getCodec = function() {
|
|
2036
|
+
return this.type.replace(".", "");
|
|
2037
|
+
}, s.SampleEntry.prototype.getWidth = function() {
|
|
2038
|
+
return "";
|
|
2039
|
+
}, s.SampleEntry.prototype.getHeight = function() {
|
|
2040
|
+
return "";
|
|
2041
|
+
}, s.SampleEntry.prototype.getChannelCount = function() {
|
|
2042
|
+
return "";
|
|
2043
|
+
}, s.SampleEntry.prototype.getSampleRate = function() {
|
|
2044
|
+
return "";
|
|
2045
|
+
}, s.SampleEntry.prototype.getSampleSize = function() {
|
|
2046
|
+
return "";
|
|
2047
|
+
}, s.VisualSampleEntry.prototype.isVideo = function() {
|
|
2048
|
+
return !0;
|
|
2049
|
+
}, s.VisualSampleEntry.prototype.getWidth = function() {
|
|
2050
|
+
return this.width;
|
|
2051
|
+
}, s.VisualSampleEntry.prototype.getHeight = function() {
|
|
2052
|
+
return this.height;
|
|
2053
|
+
}, s.AudioSampleEntry.prototype.isAudio = function() {
|
|
2054
|
+
return !0;
|
|
2055
|
+
}, s.AudioSampleEntry.prototype.getChannelCount = function() {
|
|
2056
|
+
return this.channel_count;
|
|
2057
|
+
}, s.AudioSampleEntry.prototype.getSampleRate = function() {
|
|
2058
|
+
return this.samplerate;
|
|
2059
|
+
}, s.AudioSampleEntry.prototype.getSampleSize = function() {
|
|
2060
|
+
return this.samplesize;
|
|
2061
|
+
}, s.SubtitleSampleEntry.prototype.isSubtitle = function() {
|
|
2062
|
+
return !0;
|
|
2063
|
+
}, s.MetadataSampleEntry.prototype.isMetadata = function() {
|
|
2064
|
+
return !0;
|
|
2065
|
+
}, s.decimalToHex = function(t, e) {
|
|
2066
|
+
var r = Number(t).toString(16);
|
|
2067
|
+
for (e = typeof e > "u" || e === null ? e = 2 : e; r.length < e; )
|
|
2068
|
+
r = "0" + r;
|
|
2069
|
+
return r;
|
|
2070
|
+
}, s.avc1SampleEntry.prototype.getCodec = s.avc2SampleEntry.prototype.getCodec = s.avc3SampleEntry.prototype.getCodec = s.avc4SampleEntry.prototype.getCodec = function() {
|
|
2071
|
+
var t = s.SampleEntry.prototype.getCodec.call(this);
|
|
2072
|
+
return this.avcC ? t + "." + s.decimalToHex(this.avcC.AVCProfileIndication) + s.decimalToHex(this.avcC.profile_compatibility) + s.decimalToHex(this.avcC.AVCLevelIndication) : t;
|
|
2073
|
+
}, s.hev1SampleEntry.prototype.getCodec = s.hvc1SampleEntry.prototype.getCodec = function() {
|
|
2074
|
+
var t, e = s.SampleEntry.prototype.getCodec.call(this);
|
|
2075
|
+
if (this.hvcC) {
|
|
2076
|
+
switch (e += ".", this.hvcC.general_profile_space) {
|
|
2077
|
+
case 0:
|
|
2078
|
+
e += "";
|
|
2079
|
+
break;
|
|
2080
|
+
case 1:
|
|
2081
|
+
e += "A";
|
|
2082
|
+
break;
|
|
2083
|
+
case 2:
|
|
2084
|
+
e += "B";
|
|
2085
|
+
break;
|
|
2086
|
+
case 3:
|
|
2087
|
+
e += "C";
|
|
2088
|
+
break;
|
|
2089
|
+
}
|
|
2090
|
+
e += this.hvcC.general_profile_idc, e += ".";
|
|
2091
|
+
var r = this.hvcC.general_profile_compatibility, n = 0;
|
|
2092
|
+
for (t = 0; t < 32 && (n |= r & 1, t != 31); t++)
|
|
2093
|
+
n <<= 1, r >>= 1;
|
|
2094
|
+
e += s.decimalToHex(n, 0), e += ".", this.hvcC.general_tier_flag === 0 ? e += "L" : e += "H", e += this.hvcC.general_level_idc;
|
|
2095
|
+
var o = !1, a = "";
|
|
2096
|
+
for (t = 5; t >= 0; t--)
|
|
2097
|
+
(this.hvcC.general_constraint_indicator[t] || o) && (a = "." + s.decimalToHex(this.hvcC.general_constraint_indicator[t], 0) + a, o = !0);
|
|
2098
|
+
e += a;
|
|
2099
|
+
}
|
|
2100
|
+
return e;
|
|
2101
|
+
}, s.vvc1SampleEntry.prototype.getCodec = s.vvi1SampleEntry.prototype.getCodec = function() {
|
|
2102
|
+
var t, e = s.SampleEntry.prototype.getCodec.call(this);
|
|
2103
|
+
if (this.vvcC) {
|
|
2104
|
+
e += "." + this.vvcC.general_profile_idc, this.vvcC.general_tier_flag ? e += ".H" : e += ".L", e += this.vvcC.general_level_idc;
|
|
2105
|
+
var r = "";
|
|
2106
|
+
if (this.vvcC.general_constraint_info) {
|
|
2107
|
+
var n = [], o = 0;
|
|
2108
|
+
o |= this.vvcC.ptl_frame_only_constraint << 7, o |= this.vvcC.ptl_multilayer_enabled << 6;
|
|
2109
|
+
var a;
|
|
2110
|
+
for (t = 0; t < this.vvcC.general_constraint_info.length; ++t)
|
|
2111
|
+
o |= this.vvcC.general_constraint_info[t] >> 2 & 63, n.push(o), o && (a = t), o = this.vvcC.general_constraint_info[t] >> 2 & 3;
|
|
2112
|
+
if (a === void 0)
|
|
2113
|
+
r = ".CA";
|
|
2114
|
+
else {
|
|
2115
|
+
r = ".C";
|
|
2116
|
+
var h = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", f = 0, p = 0;
|
|
2117
|
+
for (t = 0; t <= a; ++t)
|
|
2118
|
+
for (f = f << 8 | n[t], p += 8; p >= 5; ) {
|
|
2119
|
+
var u = f >> p - 5 & 31;
|
|
2120
|
+
r += h[u], p -= 5, f &= (1 << p) - 1;
|
|
2121
|
+
}
|
|
2122
|
+
p && (f <<= 5 - p, r += h[f & 31]);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
e += r;
|
|
2126
|
+
}
|
|
2127
|
+
return e;
|
|
2128
|
+
}, s.mp4aSampleEntry.prototype.getCodec = function() {
|
|
2129
|
+
var t = s.SampleEntry.prototype.getCodec.call(this);
|
|
2130
|
+
if (this.esds && this.esds.esd) {
|
|
2131
|
+
var e = this.esds.esd.getOTI(), r = this.esds.esd.getAudioConfig();
|
|
2132
|
+
return t + "." + s.decimalToHex(e) + (r ? "." + r : "");
|
|
2133
|
+
} else
|
|
2134
|
+
return t;
|
|
2135
|
+
}, s.stxtSampleEntry.prototype.getCodec = function() {
|
|
2136
|
+
var t = s.SampleEntry.prototype.getCodec.call(this);
|
|
2137
|
+
return this.mime_format ? t + "." + this.mime_format : t;
|
|
2138
|
+
}, s.vp08SampleEntry.prototype.getCodec = s.vp09SampleEntry.prototype.getCodec = function() {
|
|
2139
|
+
var t = s.SampleEntry.prototype.getCodec.call(this), e = this.vpcC.level;
|
|
2140
|
+
e == 0 && (e = "00");
|
|
2141
|
+
var r = this.vpcC.bitDepth;
|
|
2142
|
+
return r == 8 && (r = "08"), t + ".0" + this.vpcC.profile + "." + e + "." + r;
|
|
2143
|
+
}, s.av01SampleEntry.prototype.getCodec = function() {
|
|
2144
|
+
var t = s.SampleEntry.prototype.getCodec.call(this), e = this.av1C.seq_level_idx_0;
|
|
2145
|
+
e < 10 && (e = "0" + e);
|
|
2146
|
+
var r;
|
|
2147
|
+
return this.av1C.seq_profile === 2 && this.av1C.high_bitdepth === 1 ? r = this.av1C.twelve_bit === 1 ? "12" : "10" : this.av1C.seq_profile <= 2 && (r = this.av1C.high_bitdepth === 1 ? "10" : "08"), t + "." + this.av1C.seq_profile + "." + e + (this.av1C.seq_tier_0 ? "H" : "M") + "." + r;
|
|
2148
|
+
}, s.Box.prototype.writeHeader = function(t, e) {
|
|
2149
|
+
this.size += 8, this.size > b && (this.size += 8), this.type === "uuid" && (this.size += 16), l.debug("BoxWriter", "Writing box " + this.type + " of size: " + this.size + " at position " + t.getPosition() + (e || "")), this.size > b ? t.writeUint32(1) : (this.sizePosition = t.getPosition(), t.writeUint32(this.size)), t.writeString(this.type, null, 4), this.type === "uuid" && t.writeUint8Array(this.uuid), this.size > b && t.writeUint64(this.size);
|
|
2150
|
+
}, s.FullBox.prototype.writeHeader = function(t) {
|
|
2151
|
+
this.size += 4, s.Box.prototype.writeHeader.call(this, t, " v=" + this.version + " f=" + this.flags), t.writeUint8(this.version), t.writeUint24(this.flags);
|
|
2152
|
+
}, s.Box.prototype.write = function(t) {
|
|
2153
|
+
this.type === "mdat" ? this.data && (this.size = this.data.length, this.writeHeader(t), t.writeUint8Array(this.data)) : (this.size = this.data ? this.data.length : 0, this.writeHeader(t), this.data && t.writeUint8Array(this.data));
|
|
2154
|
+
}, s.ContainerBox.prototype.write = function(t) {
|
|
2155
|
+
this.size = 0, this.writeHeader(t);
|
|
2156
|
+
for (var e = 0; e < this.boxes.length; e++)
|
|
2157
|
+
this.boxes[e] && (this.boxes[e].write(t), this.size += this.boxes[e].size);
|
|
2158
|
+
l.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size);
|
|
2159
|
+
}, s.TrackReferenceTypeBox.prototype.write = function(t) {
|
|
2160
|
+
this.size = this.track_ids.length * 4, this.writeHeader(t), t.writeUint32Array(this.track_ids);
|
|
2161
|
+
}, s.avcCBox.prototype.write = function(t) {
|
|
2162
|
+
var e;
|
|
2163
|
+
for (this.size = 7, e = 0; e < this.SPS.length; e++)
|
|
2164
|
+
this.size += 2 + this.SPS[e].length;
|
|
2165
|
+
for (e = 0; e < this.PPS.length; e++)
|
|
2166
|
+
this.size += 2 + this.PPS[e].length;
|
|
2167
|
+
for (this.ext && (this.size += this.ext.length), this.writeHeader(t), t.writeUint8(this.configurationVersion), t.writeUint8(this.AVCProfileIndication), t.writeUint8(this.profile_compatibility), t.writeUint8(this.AVCLevelIndication), t.writeUint8(this.lengthSizeMinusOne + 252), t.writeUint8(this.SPS.length + 224), e = 0; e < this.SPS.length; e++)
|
|
2168
|
+
t.writeUint16(this.SPS[e].length), t.writeUint8Array(this.SPS[e].nalu);
|
|
2169
|
+
for (t.writeUint8(this.PPS.length), e = 0; e < this.PPS.length; e++)
|
|
2170
|
+
t.writeUint16(this.PPS[e].length), t.writeUint8Array(this.PPS[e].nalu);
|
|
2171
|
+
this.ext && t.writeUint8Array(this.ext);
|
|
2172
|
+
}, s.co64Box.prototype.write = function(t) {
|
|
2173
|
+
var e;
|
|
2174
|
+
for (this.version = 0, this.flags = 0, this.size = 4 + 8 * this.chunk_offsets.length, this.writeHeader(t), t.writeUint32(this.chunk_offsets.length), e = 0; e < this.chunk_offsets.length; e++)
|
|
2175
|
+
t.writeUint64(this.chunk_offsets[e]);
|
|
2176
|
+
}, s.cslgBox.prototype.write = function(t) {
|
|
2177
|
+
this.version = 0, this.flags = 0, this.size = 20, this.writeHeader(t), t.writeInt32(this.compositionToDTSShift), t.writeInt32(this.leastDecodeToDisplayDelta), t.writeInt32(this.greatestDecodeToDisplayDelta), t.writeInt32(this.compositionStartTime), t.writeInt32(this.compositionEndTime);
|
|
2178
|
+
}, s.cttsBox.prototype.write = function(t) {
|
|
2179
|
+
var e;
|
|
2180
|
+
for (this.version = 0, this.flags = 0, this.size = 4 + 8 * this.sample_counts.length, this.writeHeader(t), t.writeUint32(this.sample_counts.length), e = 0; e < this.sample_counts.length; e++)
|
|
2181
|
+
t.writeUint32(this.sample_counts[e]), this.version === 1 ? t.writeInt32(this.sample_offsets[e]) : t.writeUint32(this.sample_offsets[e]);
|
|
2182
|
+
}, s.drefBox.prototype.write = function(t) {
|
|
2183
|
+
this.version = 0, this.flags = 0, this.size = 4, this.writeHeader(t), t.writeUint32(this.entries.length);
|
|
2184
|
+
for (var e = 0; e < this.entries.length; e++)
|
|
2185
|
+
this.entries[e].write(t), this.size += this.entries[e].size;
|
|
2186
|
+
l.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size);
|
|
2187
|
+
}, s.elngBox.prototype.write = function(t) {
|
|
2188
|
+
this.version = 0, this.flags = 0, this.size = this.extended_language.length, this.writeHeader(t), t.writeString(this.extended_language);
|
|
2189
|
+
}, s.elstBox.prototype.write = function(t) {
|
|
2190
|
+
this.version = 0, this.flags = 0, this.size = 4 + 12 * this.entries.length, this.writeHeader(t), t.writeUint32(this.entries.length);
|
|
2191
|
+
for (var e = 0; e < this.entries.length; e++) {
|
|
2192
|
+
var r = this.entries[e];
|
|
2193
|
+
t.writeUint32(r.segment_duration), t.writeInt32(r.media_time), t.writeInt16(r.media_rate_integer), t.writeInt16(r.media_rate_fraction);
|
|
2194
|
+
}
|
|
2195
|
+
}, s.emsgBox.prototype.write = function(t) {
|
|
2196
|
+
this.version = 0, this.flags = 0, this.size = 16 + this.message_data.length + (this.scheme_id_uri.length + 1) + (this.value.length + 1), this.writeHeader(t), t.writeCString(this.scheme_id_uri), t.writeCString(this.value), t.writeUint32(this.timescale), t.writeUint32(this.presentation_time_delta), t.writeUint32(this.event_duration), t.writeUint32(this.id), t.writeUint8Array(this.message_data);
|
|
2197
|
+
}, s.ftypBox.prototype.write = function(t) {
|
|
2198
|
+
this.size = 8 + 4 * this.compatible_brands.length, this.writeHeader(t), t.writeString(this.major_brand, null, 4), t.writeUint32(this.minor_version);
|
|
2199
|
+
for (var e = 0; e < this.compatible_brands.length; e++)
|
|
2200
|
+
t.writeString(this.compatible_brands[e], null, 4);
|
|
2201
|
+
}, s.hdlrBox.prototype.write = function(t) {
|
|
2202
|
+
this.size = 20 + this.name.length + 1, this.version = 0, this.flags = 0, this.writeHeader(t), t.writeUint32(0), t.writeString(this.handler, null, 4), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeCString(this.name);
|
|
2203
|
+
}, s.hvcCBox.prototype.write = function(t) {
|
|
2204
|
+
var e, r;
|
|
2205
|
+
for (this.size = 23, e = 0; e < this.nalu_arrays.length; e++)
|
|
2206
|
+
for (this.size += 3, r = 0; r < this.nalu_arrays[e].length; r++)
|
|
2207
|
+
this.size += 2 + this.nalu_arrays[e][r].data.length;
|
|
2208
|
+
for (this.writeHeader(t), t.writeUint8(this.configurationVersion), t.writeUint8((this.general_profile_space << 6) + (this.general_tier_flag << 5) + this.general_profile_idc), t.writeUint32(this.general_profile_compatibility), t.writeUint8Array(this.general_constraint_indicator), t.writeUint8(this.general_level_idc), t.writeUint16(this.min_spatial_segmentation_idc + (15 << 24)), t.writeUint8(this.parallelismType + 252), t.writeUint8(this.chroma_format_idc + 252), t.writeUint8(this.bit_depth_luma_minus8 + 248), t.writeUint8(this.bit_depth_chroma_minus8 + 248), t.writeUint16(this.avgFrameRate), t.writeUint8((this.constantFrameRate << 6) + (this.numTemporalLayers << 3) + (this.temporalIdNested << 2) + this.lengthSizeMinusOne), t.writeUint8(this.nalu_arrays.length), e = 0; e < this.nalu_arrays.length; e++)
|
|
2209
|
+
for (t.writeUint8((this.nalu_arrays[e].completeness << 7) + this.nalu_arrays[e].nalu_type), t.writeUint16(this.nalu_arrays[e].length), r = 0; r < this.nalu_arrays[e].length; r++)
|
|
2210
|
+
t.writeUint16(this.nalu_arrays[e][r].data.length), t.writeUint8Array(this.nalu_arrays[e][r].data);
|
|
2211
|
+
}, s.kindBox.prototype.write = function(t) {
|
|
2212
|
+
this.version = 0, this.flags = 0, this.size = this.schemeURI.length + 1 + (this.value.length + 1), this.writeHeader(t), t.writeCString(this.schemeURI), t.writeCString(this.value);
|
|
2213
|
+
}, s.mdhdBox.prototype.write = function(t) {
|
|
2214
|
+
this.size = 20, this.flags = 0, this.version = 0, this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.timescale), t.writeUint32(this.duration), t.writeUint16(this.language), t.writeUint16(0);
|
|
2215
|
+
}, s.mehdBox.prototype.write = function(t) {
|
|
2216
|
+
this.version = 0, this.flags = 0, this.size = 4, this.writeHeader(t), t.writeUint32(this.fragment_duration);
|
|
2217
|
+
}, s.mfhdBox.prototype.write = function(t) {
|
|
2218
|
+
this.version = 0, this.flags = 0, this.size = 4, this.writeHeader(t), t.writeUint32(this.sequence_number);
|
|
2219
|
+
}, s.mvhdBox.prototype.write = function(t) {
|
|
2220
|
+
this.version = 0, this.flags = 0, this.size = 96, this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.timescale), t.writeUint32(this.duration), t.writeUint32(this.rate), t.writeUint16(this.volume << 8), t.writeUint16(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32Array(this.matrix), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(this.next_track_id);
|
|
2221
|
+
}, s.SampleEntry.prototype.writeHeader = function(t) {
|
|
2222
|
+
this.size = 8, s.Box.prototype.writeHeader.call(this, t), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint8(0), t.writeUint16(this.data_reference_index);
|
|
2223
|
+
}, s.SampleEntry.prototype.writeFooter = function(t) {
|
|
2224
|
+
for (var e = 0; e < this.boxes.length; e++)
|
|
2225
|
+
this.boxes[e].write(t), this.size += this.boxes[e].size;
|
|
2226
|
+
l.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size);
|
|
2227
|
+
}, s.SampleEntry.prototype.write = function(t) {
|
|
2228
|
+
this.writeHeader(t), t.writeUint8Array(this.data), this.size += this.data.length, l.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size);
|
|
2229
|
+
}, s.VisualSampleEntry.prototype.write = function(t) {
|
|
2230
|
+
this.writeHeader(t), this.size += 70, t.writeUint16(0), t.writeUint16(0), t.writeUint32(0), t.writeUint32(0), t.writeUint32(0), t.writeUint16(this.width), t.writeUint16(this.height), t.writeUint32(this.horizresolution), t.writeUint32(this.vertresolution), t.writeUint32(0), t.writeUint16(this.frame_count), t.writeUint8(Math.min(31, this.compressorname.length)), t.writeString(this.compressorname, null, 31), t.writeUint16(this.depth), t.writeInt16(-1), this.writeFooter(t);
|
|
2231
|
+
}, s.AudioSampleEntry.prototype.write = function(t) {
|
|
2232
|
+
this.writeHeader(t), this.size += 20, t.writeUint32(0), t.writeUint32(0), t.writeUint16(this.channel_count), t.writeUint16(this.samplesize), t.writeUint16(0), t.writeUint16(0), t.writeUint32(this.samplerate << 16), this.writeFooter(t);
|
|
2233
|
+
}, s.stppSampleEntry.prototype.write = function(t) {
|
|
2234
|
+
this.writeHeader(t), this.size += this.namespace.length + 1 + this.schema_location.length + 1 + this.auxiliary_mime_types.length + 1, t.writeCString(this.namespace), t.writeCString(this.schema_location), t.writeCString(this.auxiliary_mime_types), this.writeFooter(t);
|
|
2235
|
+
}, s.SampleGroupEntry.prototype.write = function(t) {
|
|
2236
|
+
t.writeUint8Array(this.data);
|
|
2237
|
+
}, s.sbgpBox.prototype.write = function(t) {
|
|
2238
|
+
this.version = 1, this.flags = 0, this.size = 12 + 8 * this.entries.length, this.writeHeader(t), t.writeString(this.grouping_type, null, 4), t.writeUint32(this.grouping_type_parameter), t.writeUint32(this.entries.length);
|
|
2239
|
+
for (var e = 0; e < this.entries.length; e++) {
|
|
2240
|
+
var r = this.entries[e];
|
|
2241
|
+
t.writeInt32(r.sample_count), t.writeInt32(r.group_description_index);
|
|
2242
|
+
}
|
|
2243
|
+
}, s.sgpdBox.prototype.write = function(t) {
|
|
2244
|
+
var e, r;
|
|
2245
|
+
for (this.flags = 0, this.size = 12, e = 0; e < this.entries.length; e++)
|
|
2246
|
+
r = this.entries[e], this.version === 1 && (this.default_length === 0 && (this.size += 4), this.size += r.data.length);
|
|
2247
|
+
for (this.writeHeader(t), t.writeString(this.grouping_type, null, 4), this.version === 1 && t.writeUint32(this.default_length), this.version >= 2 && t.writeUint32(this.default_sample_description_index), t.writeUint32(this.entries.length), e = 0; e < this.entries.length; e++)
|
|
2248
|
+
r = this.entries[e], this.version === 1 && this.default_length === 0 && t.writeUint32(r.description_length), r.write(t);
|
|
2249
|
+
}, s.sidxBox.prototype.write = function(t) {
|
|
2250
|
+
this.version = 0, this.flags = 0, this.size = 20 + 12 * this.references.length, this.writeHeader(t), t.writeUint32(this.reference_ID), t.writeUint32(this.timescale), t.writeUint32(this.earliest_presentation_time), t.writeUint32(this.first_offset), t.writeUint16(0), t.writeUint16(this.references.length);
|
|
2251
|
+
for (var e = 0; e < this.references.length; e++) {
|
|
2252
|
+
var r = this.references[e];
|
|
2253
|
+
t.writeUint32(r.reference_type << 31 | r.referenced_size), t.writeUint32(r.subsegment_duration), t.writeUint32(r.starts_with_SAP << 31 | r.SAP_type << 28 | r.SAP_delta_time);
|
|
2254
|
+
}
|
|
2255
|
+
}, s.smhdBox.prototype.write = function(t) {
|
|
2256
|
+
this.version = 0, this.flags = 1, this.size = 4, this.writeHeader(t), t.writeUint16(this.balance), t.writeUint16(0);
|
|
2257
|
+
}, s.stcoBox.prototype.write = function(t) {
|
|
2258
|
+
this.version = 0, this.flags = 0, this.size = 4 + 4 * this.chunk_offsets.length, this.writeHeader(t), t.writeUint32(this.chunk_offsets.length), t.writeUint32Array(this.chunk_offsets);
|
|
2259
|
+
}, s.stscBox.prototype.write = function(t) {
|
|
2260
|
+
var e;
|
|
2261
|
+
for (this.version = 0, this.flags = 0, this.size = 4 + 12 * this.first_chunk.length, this.writeHeader(t), t.writeUint32(this.first_chunk.length), e = 0; e < this.first_chunk.length; e++)
|
|
2262
|
+
t.writeUint32(this.first_chunk[e]), t.writeUint32(this.samples_per_chunk[e]), t.writeUint32(this.sample_description_index[e]);
|
|
2263
|
+
}, s.stsdBox.prototype.write = function(t) {
|
|
2264
|
+
var e;
|
|
2265
|
+
for (this.version = 0, this.flags = 0, this.size = 0, this.writeHeader(t), t.writeUint32(this.entries.length), this.size += 4, e = 0; e < this.entries.length; e++)
|
|
2266
|
+
this.entries[e].write(t), this.size += this.entries[e].size;
|
|
2267
|
+
l.debug("BoxWriter", "Adjusting box " + this.type + " with new size " + this.size), t.adjustUint32(this.sizePosition, this.size);
|
|
2268
|
+
}, s.stshBox.prototype.write = function(t) {
|
|
2269
|
+
var e;
|
|
2270
|
+
for (this.version = 0, this.flags = 0, this.size = 4 + 8 * this.shadowed_sample_numbers.length, this.writeHeader(t), t.writeUint32(this.shadowed_sample_numbers.length), e = 0; e < this.shadowed_sample_numbers.length; e++)
|
|
2271
|
+
t.writeUint32(this.shadowed_sample_numbers[e]), t.writeUint32(this.sync_sample_numbers[e]);
|
|
2272
|
+
}, s.stssBox.prototype.write = function(t) {
|
|
2273
|
+
this.version = 0, this.flags = 0, this.size = 4 + 4 * this.sample_numbers.length, this.writeHeader(t), t.writeUint32(this.sample_numbers.length), t.writeUint32Array(this.sample_numbers);
|
|
2274
|
+
}, s.stszBox.prototype.write = function(t) {
|
|
2275
|
+
var e, r = !0;
|
|
2276
|
+
if (this.version = 0, this.flags = 0, this.sample_sizes.length > 0)
|
|
2277
|
+
for (e = 0; e + 1 < this.sample_sizes.length; )
|
|
2278
|
+
if (this.sample_sizes[e + 1] !== this.sample_sizes[0]) {
|
|
2279
|
+
r = !1;
|
|
2280
|
+
break;
|
|
2281
|
+
} else
|
|
2282
|
+
e++;
|
|
2283
|
+
else
|
|
2284
|
+
r = !1;
|
|
2285
|
+
this.size = 8, r || (this.size += 4 * this.sample_sizes.length), this.writeHeader(t), r ? t.writeUint32(this.sample_sizes[0]) : t.writeUint32(0), t.writeUint32(this.sample_sizes.length), r || t.writeUint32Array(this.sample_sizes);
|
|
2286
|
+
}, s.sttsBox.prototype.write = function(t) {
|
|
2287
|
+
var e;
|
|
2288
|
+
for (this.version = 0, this.flags = 0, this.size = 4 + 8 * this.sample_counts.length, this.writeHeader(t), t.writeUint32(this.sample_counts.length), e = 0; e < this.sample_counts.length; e++)
|
|
2289
|
+
t.writeUint32(this.sample_counts[e]), t.writeUint32(this.sample_deltas[e]);
|
|
2290
|
+
}, s.tfdtBox.prototype.write = function(t) {
|
|
2291
|
+
var e = Math.pow(2, 32) - 1;
|
|
2292
|
+
this.version = this.baseMediaDecodeTime > e ? 1 : 0, this.flags = 0, this.size = 4, this.version === 1 && (this.size += 4), this.writeHeader(t), this.version === 1 ? t.writeUint64(this.baseMediaDecodeTime) : t.writeUint32(this.baseMediaDecodeTime);
|
|
2293
|
+
}, s.tfhdBox.prototype.write = function(t) {
|
|
2294
|
+
this.version = 0, this.size = 4, this.flags & s.TFHD_FLAG_BASE_DATA_OFFSET && (this.size += 8), this.flags & s.TFHD_FLAG_SAMPLE_DESC && (this.size += 4), this.flags & s.TFHD_FLAG_SAMPLE_DUR && (this.size += 4), this.flags & s.TFHD_FLAG_SAMPLE_SIZE && (this.size += 4), this.flags & s.TFHD_FLAG_SAMPLE_FLAGS && (this.size += 4), this.writeHeader(t), t.writeUint32(this.track_id), this.flags & s.TFHD_FLAG_BASE_DATA_OFFSET && t.writeUint64(this.base_data_offset), this.flags & s.TFHD_FLAG_SAMPLE_DESC && t.writeUint32(this.default_sample_description_index), this.flags & s.TFHD_FLAG_SAMPLE_DUR && t.writeUint32(this.default_sample_duration), this.flags & s.TFHD_FLAG_SAMPLE_SIZE && t.writeUint32(this.default_sample_size), this.flags & s.TFHD_FLAG_SAMPLE_FLAGS && t.writeUint32(this.default_sample_flags);
|
|
2295
|
+
}, s.tkhdBox.prototype.write = function(t) {
|
|
2296
|
+
this.version = 0, this.size = 80, this.writeHeader(t), t.writeUint32(this.creation_time), t.writeUint32(this.modification_time), t.writeUint32(this.track_id), t.writeUint32(0), t.writeUint32(this.duration), t.writeUint32(0), t.writeUint32(0), t.writeInt16(this.layer), t.writeInt16(this.alternate_group), t.writeInt16(this.volume << 8), t.writeUint16(0), t.writeInt32Array(this.matrix), t.writeUint32(this.width), t.writeUint32(this.height);
|
|
2297
|
+
}, s.trexBox.prototype.write = function(t) {
|
|
2298
|
+
this.version = 0, this.flags = 0, this.size = 20, this.writeHeader(t), t.writeUint32(this.track_id), t.writeUint32(this.default_sample_description_index), t.writeUint32(this.default_sample_duration), t.writeUint32(this.default_sample_size), t.writeUint32(this.default_sample_flags);
|
|
2299
|
+
}, s.trunBox.prototype.write = function(t) {
|
|
2300
|
+
this.version = 0, this.size = 4, this.flags & s.TRUN_FLAGS_DATA_OFFSET && (this.size += 4), this.flags & s.TRUN_FLAGS_FIRST_FLAG && (this.size += 4), this.flags & s.TRUN_FLAGS_DURATION && (this.size += 4 * this.sample_duration.length), this.flags & s.TRUN_FLAGS_SIZE && (this.size += 4 * this.sample_size.length), this.flags & s.TRUN_FLAGS_FLAGS && (this.size += 4 * this.sample_flags.length), this.flags & s.TRUN_FLAGS_CTS_OFFSET && (this.size += 4 * this.sample_composition_time_offset.length), this.writeHeader(t), t.writeUint32(this.sample_count), this.flags & s.TRUN_FLAGS_DATA_OFFSET && (this.data_offset_position = t.getPosition(), t.writeInt32(this.data_offset)), this.flags & s.TRUN_FLAGS_FIRST_FLAG && t.writeUint32(this.first_sample_flags);
|
|
2301
|
+
for (var e = 0; e < this.sample_count; e++)
|
|
2302
|
+
this.flags & s.TRUN_FLAGS_DURATION && t.writeUint32(this.sample_duration[e]), this.flags & s.TRUN_FLAGS_SIZE && t.writeUint32(this.sample_size[e]), this.flags & s.TRUN_FLAGS_FLAGS && t.writeUint32(this.sample_flags[e]), this.flags & s.TRUN_FLAGS_CTS_OFFSET && (this.version === 0 ? t.writeUint32(this.sample_composition_time_offset[e]) : t.writeInt32(this.sample_composition_time_offset[e]));
|
|
2303
|
+
}, s["url Box"].prototype.write = function(t) {
|
|
2304
|
+
this.version = 0, this.location ? (this.flags = 0, this.size = this.location.length + 1) : (this.flags = 1, this.size = 0), this.writeHeader(t), this.location && t.writeCString(this.location);
|
|
2305
|
+
}, s["urn Box"].prototype.write = function(t) {
|
|
2306
|
+
this.version = 0, this.flags = 0, this.size = this.name.length + 1 + (this.location ? this.location.length + 1 : 0), this.writeHeader(t), t.writeCString(this.name), this.location && t.writeCString(this.location);
|
|
2307
|
+
}, s.vmhdBox.prototype.write = function(t) {
|
|
2308
|
+
this.version = 0, this.flags = 1, this.size = 8, this.writeHeader(t), t.writeUint16(this.graphicsmode), t.writeUint16Array(this.opcolor);
|
|
2309
|
+
}, s.cttsBox.prototype.unpack = function(t) {
|
|
2310
|
+
var e, r, n;
|
|
2311
|
+
for (n = 0, e = 0; e < this.sample_counts.length; e++)
|
|
2312
|
+
for (r = 0; r < this.sample_counts[e]; r++)
|
|
2313
|
+
t[n].pts = t[n].dts + this.sample_offsets[e], n++;
|
|
2314
|
+
}, s.sttsBox.prototype.unpack = function(t) {
|
|
2315
|
+
var e, r, n;
|
|
2316
|
+
for (n = 0, e = 0; e < this.sample_counts.length; e++)
|
|
2317
|
+
for (r = 0; r < this.sample_counts[e]; r++)
|
|
2318
|
+
n === 0 ? t[n].dts = 0 : t[n].dts = t[n - 1].dts + this.sample_deltas[e], n++;
|
|
2319
|
+
}, s.stcoBox.prototype.unpack = function(t) {
|
|
2320
|
+
var e;
|
|
2321
|
+
for (e = 0; e < this.chunk_offsets.length; e++)
|
|
2322
|
+
t[e].offset = this.chunk_offsets[e];
|
|
2323
|
+
}, s.stscBox.prototype.unpack = function(t) {
|
|
2324
|
+
var e, r, n, o, a;
|
|
2325
|
+
for (o = 0, a = 0, e = 0; e < this.first_chunk.length; e++)
|
|
2326
|
+
for (r = 0; r < (e + 1 < this.first_chunk.length ? this.first_chunk[e + 1] : 1 / 0); r++)
|
|
2327
|
+
for (a++, n = 0; n < this.samples_per_chunk[e]; n++) {
|
|
2328
|
+
if (t[o])
|
|
2329
|
+
t[o].description_index = this.sample_description_index[e], t[o].chunk_index = a;
|
|
2330
|
+
else
|
|
2331
|
+
return;
|
|
2332
|
+
o++;
|
|
2333
|
+
}
|
|
2334
|
+
}, s.stszBox.prototype.unpack = function(t) {
|
|
2335
|
+
var e;
|
|
2336
|
+
for (e = 0; e < this.sample_sizes.length; e++)
|
|
2337
|
+
t[e].size = this.sample_sizes[e];
|
|
2338
|
+
}, s.DIFF_BOXES_PROP_NAMES = [
|
|
2339
|
+
"boxes",
|
|
2340
|
+
"entries",
|
|
2341
|
+
"references",
|
|
2342
|
+
"subsamples",
|
|
2343
|
+
"items",
|
|
2344
|
+
"item_infos",
|
|
2345
|
+
"extents",
|
|
2346
|
+
"associations",
|
|
2347
|
+
"subsegments",
|
|
2348
|
+
"ranges",
|
|
2349
|
+
"seekLists",
|
|
2350
|
+
"seekPoints",
|
|
2351
|
+
"esd",
|
|
2352
|
+
"levels"
|
|
2353
|
+
], s.DIFF_PRIMITIVE_ARRAY_PROP_NAMES = [
|
|
2354
|
+
"compatible_brands",
|
|
2355
|
+
"matrix",
|
|
2356
|
+
"opcolor",
|
|
2357
|
+
"sample_counts",
|
|
2358
|
+
"sample_deltas",
|
|
2359
|
+
"first_chunk",
|
|
2360
|
+
"samples_per_chunk",
|
|
2361
|
+
"sample_sizes",
|
|
2362
|
+
"chunk_offsets",
|
|
2363
|
+
"sample_offsets",
|
|
2364
|
+
"sample_description_index",
|
|
2365
|
+
"sample_duration"
|
|
2366
|
+
], s.boxEqualFields = function(t, e) {
|
|
2367
|
+
if (t && !e) return !1;
|
|
2368
|
+
var r;
|
|
2369
|
+
for (r in t)
|
|
2370
|
+
if (!(s.DIFF_BOXES_PROP_NAMES.indexOf(r) > -1)) {
|
|
2371
|
+
if (t[r] instanceof s.Box || e[r] instanceof s.Box)
|
|
2372
|
+
continue;
|
|
2373
|
+
if (typeof t[r] > "u" || typeof e[r] > "u")
|
|
2374
|
+
continue;
|
|
2375
|
+
if (typeof t[r] == "function" || typeof e[r] == "function")
|
|
2376
|
+
continue;
|
|
2377
|
+
if (t.subBoxNames && t.subBoxNames.indexOf(r.slice(0, 4)) > -1 || e.subBoxNames && e.subBoxNames.indexOf(r.slice(0, 4)) > -1)
|
|
2378
|
+
continue;
|
|
2379
|
+
if (r === "data" || r === "start" || r === "size" || r === "creation_time" || r === "modification_time")
|
|
2380
|
+
continue;
|
|
2381
|
+
if (s.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(r) > -1)
|
|
2382
|
+
continue;
|
|
2383
|
+
if (t[r] !== e[r])
|
|
2384
|
+
return !1;
|
|
2385
|
+
}
|
|
2386
|
+
return !0;
|
|
2387
|
+
}, s.boxEqual = function(t, e) {
|
|
2388
|
+
if (!s.boxEqualFields(t, e))
|
|
2389
|
+
return !1;
|
|
2390
|
+
for (var r = 0; r < s.DIFF_BOXES_PROP_NAMES.length; r++) {
|
|
2391
|
+
var n = s.DIFF_BOXES_PROP_NAMES[r];
|
|
2392
|
+
if (t[n] && e[n] && !s.boxEqual(t[n], e[n]))
|
|
2393
|
+
return !1;
|
|
2394
|
+
}
|
|
2395
|
+
return !0;
|
|
2396
|
+
};
|
|
2397
|
+
var j = function() {
|
|
2398
|
+
};
|
|
2399
|
+
j.prototype.parseSample = function(t) {
|
|
2400
|
+
var e, r, n = new _(t.buffer);
|
|
2401
|
+
for (e = []; !n.isEos(); )
|
|
2402
|
+
r = s.parseOneBox(n, !1), r.code === s.OK && r.box.type === "vttc" && e.push(r.box);
|
|
2403
|
+
return e;
|
|
2404
|
+
}, j.prototype.getText = function(t, e, r) {
|
|
2405
|
+
function n(u, c, g) {
|
|
2406
|
+
return g = g || "0", u = u + "", u.length >= c ? u : new Array(c - u.length + 1).join(g) + u;
|
|
2407
|
+
}
|
|
2408
|
+
function o(u) {
|
|
2409
|
+
var c = Math.floor(u / 3600), g = Math.floor((u - c * 3600) / 60), x = Math.floor(u - c * 3600 - g * 60), m = Math.floor((u - c * 3600 - g * 60 - x) * 1e3);
|
|
2410
|
+
return "" + n(c, 2) + ":" + n(g, 2) + ":" + n(x, 2) + "." + n(m, 3);
|
|
2411
|
+
}
|
|
2412
|
+
for (var a = this.parseSample(r), h = "", f = 0; f < a.length; f++) {
|
|
2413
|
+
var p = a[f];
|
|
2414
|
+
h += o(t) + " --> " + o(e) + `\r
|
|
2415
|
+
`, h += p.payl.text;
|
|
2416
|
+
}
|
|
2417
|
+
return h;
|
|
2418
|
+
};
|
|
2419
|
+
var Q = function() {
|
|
2420
|
+
};
|
|
2421
|
+
Q.prototype.parseSample = function(t) {
|
|
2422
|
+
var e = {}, r;
|
|
2423
|
+
e.resources = [];
|
|
2424
|
+
var n = new _(t.data.buffer);
|
|
2425
|
+
if (!t.subsamples || t.subsamples.length === 0)
|
|
2426
|
+
e.documentString = n.readString(t.data.length);
|
|
2427
|
+
else if (e.documentString = n.readString(t.subsamples[0].size), t.subsamples.length > 1)
|
|
2428
|
+
for (r = 1; r < t.subsamples.length; r++)
|
|
2429
|
+
e.resources[r] = n.readUint8Array(t.subsamples[r].size);
|
|
2430
|
+
return typeof DOMParser < "u" && (e.document = new DOMParser().parseFromString(e.documentString, "application/xml")), e;
|
|
2431
|
+
};
|
|
2432
|
+
var q = function() {
|
|
2433
|
+
};
|
|
2434
|
+
q.prototype.parseSample = function(t) {
|
|
2435
|
+
var e, r = new _(t.data.buffer);
|
|
2436
|
+
return e = r.readString(t.data.length), e;
|
|
2437
|
+
}, q.prototype.parseConfig = function(t) {
|
|
2438
|
+
var e, r = new _(t.buffer);
|
|
2439
|
+
return r.readUint32(), e = r.readCString(), e;
|
|
2440
|
+
}, v.VTTin4Parser = j, v.XMLSubtitlein4Parser = Q, v.Textin4Parser = q;
|
|
2441
|
+
var y = function(t) {
|
|
2442
|
+
this.stream = t || new S(), this.boxes = [], this.mdats = [], this.moofs = [], this.isProgressive = !1, this.moovStartFound = !1, this.onMoovStart = null, this.moovStartSent = !1, this.onReady = null, this.readySent = !1, this.onSegment = null, this.onSamples = null, this.onError = null, this.sampleListBuilt = !1, this.fragmentedTracks = [], this.extractedTracks = [], this.isFragmentationInitialized = !1, this.sampleProcessingStarted = !1, this.nextMoofNumber = 0, this.itemListBuilt = !1, this.items = [], this.entity_groups = [], this.onSidx = null, this.sidxSent = !1;
|
|
2443
|
+
};
|
|
2444
|
+
y.prototype.setSegmentOptions = function(t, e, r) {
|
|
2445
|
+
var n = this.getTrackById(t);
|
|
2446
|
+
if (n) {
|
|
2447
|
+
var o = {};
|
|
2448
|
+
this.fragmentedTracks.push(o), o.id = t, o.user = e, o.trak = n, n.nextSample = 0, o.segmentStream = null, o.nb_samples = 1e3, o.rapAlignement = !0, r && (r.nbSamples && (o.nb_samples = r.nbSamples), r.rapAlignement && (o.rapAlignement = r.rapAlignement));
|
|
2449
|
+
}
|
|
2450
|
+
}, y.prototype.unsetSegmentOptions = function(t) {
|
|
2451
|
+
for (var e = -1, r = 0; r < this.fragmentedTracks.length; r++) {
|
|
2452
|
+
var n = this.fragmentedTracks[r];
|
|
2453
|
+
n.id == t && (e = r);
|
|
2454
|
+
}
|
|
2455
|
+
e > -1 && this.fragmentedTracks.splice(e, 1);
|
|
2456
|
+
}, y.prototype.setExtractionOptions = function(t, e, r) {
|
|
2457
|
+
var n = this.getTrackById(t);
|
|
2458
|
+
if (n) {
|
|
2459
|
+
var o = {};
|
|
2460
|
+
this.extractedTracks.push(o), o.id = t, o.user = e, o.trak = n, n.nextSample = 0, o.nb_samples = 1e3, o.samples = [], r && r.nbSamples && (o.nb_samples = r.nbSamples);
|
|
2461
|
+
}
|
|
2462
|
+
}, y.prototype.unsetExtractionOptions = function(t) {
|
|
2463
|
+
for (var e = -1, r = 0; r < this.extractedTracks.length; r++) {
|
|
2464
|
+
var n = this.extractedTracks[r];
|
|
2465
|
+
n.id == t && (e = r);
|
|
2466
|
+
}
|
|
2467
|
+
e > -1 && this.extractedTracks.splice(e, 1);
|
|
2468
|
+
}, y.prototype.parse = function() {
|
|
2469
|
+
var t, e, r = !1;
|
|
2470
|
+
if (!(this.restoreParsePosition && !this.restoreParsePosition()))
|
|
2471
|
+
for (; ; )
|
|
2472
|
+
if (this.hasIncompleteMdat && this.hasIncompleteMdat()) {
|
|
2473
|
+
if (this.processIncompleteMdat())
|
|
2474
|
+
continue;
|
|
2475
|
+
return;
|
|
2476
|
+
} else if (this.saveParsePosition && this.saveParsePosition(), t = s.parseOneBox(this.stream, r), t.code === s.ERR_NOT_ENOUGH_DATA)
|
|
2477
|
+
if (this.processIncompleteBox) {
|
|
2478
|
+
if (this.processIncompleteBox(t))
|
|
2479
|
+
continue;
|
|
2480
|
+
return;
|
|
2481
|
+
} else
|
|
2482
|
+
return;
|
|
2483
|
+
else {
|
|
2484
|
+
var n;
|
|
2485
|
+
switch (e = t.box, n = e.type !== "uuid" ? e.type : e.uuid, this.boxes.push(e), n) {
|
|
2486
|
+
case "mdat":
|
|
2487
|
+
this.mdats.push(e);
|
|
2488
|
+
break;
|
|
2489
|
+
case "moof":
|
|
2490
|
+
this.moofs.push(e);
|
|
2491
|
+
break;
|
|
2492
|
+
case "moov":
|
|
2493
|
+
this.moovStartFound = !0, this.mdats.length === 0 && (this.isProgressive = !0);
|
|
2494
|
+
/* no break */
|
|
2495
|
+
/* falls through */
|
|
2496
|
+
default:
|
|
2497
|
+
this[n] !== void 0 && l.warn("ISOFile", "Duplicate Box of type: " + n + ", overriding previous occurrence"), this[n] = e;
|
|
2498
|
+
break;
|
|
2499
|
+
}
|
|
2500
|
+
this.updateUsedBytes && this.updateUsedBytes(e, t);
|
|
2501
|
+
}
|
|
2502
|
+
}, y.prototype.checkBuffer = function(t) {
|
|
2503
|
+
if (t == null)
|
|
2504
|
+
throw "Buffer must be defined and non empty";
|
|
2505
|
+
if (t.fileStart === void 0)
|
|
2506
|
+
throw "Buffer must have a fileStart property";
|
|
2507
|
+
return t.byteLength === 0 ? (l.warn("ISOFile", "Ignoring empty buffer (fileStart: " + t.fileStart + ")"), this.stream.logBufferLevel(), !1) : (l.info("ISOFile", "Processing buffer (fileStart: " + t.fileStart + ")"), t.usedBytes = 0, this.stream.insertBuffer(t), this.stream.logBufferLevel(), this.stream.initialized() ? !0 : (l.warn("ISOFile", "Not ready to start parsing"), !1));
|
|
2508
|
+
}, y.prototype.appendBuffer = function(t, e) {
|
|
2509
|
+
var r;
|
|
2510
|
+
if (this.checkBuffer(t))
|
|
2511
|
+
return this.parse(), this.moovStartFound && !this.moovStartSent && (this.moovStartSent = !0, this.onMoovStart && this.onMoovStart()), this.moov ? (this.sampleListBuilt || (this.buildSampleLists(), this.sampleListBuilt = !0), this.updateSampleLists(), this.onReady && !this.readySent && (this.readySent = !0, this.onReady(this.getInfo())), this.processSamples(e), this.nextSeekPosition ? (r = this.nextSeekPosition, this.nextSeekPosition = void 0) : r = this.nextParsePosition, this.stream.getEndFilePositionAfter && (r = this.stream.getEndFilePositionAfter(r))) : this.nextParsePosition ? r = this.nextParsePosition : r = 0, this.sidx && this.onSidx && !this.sidxSent && (this.onSidx(this.sidx), this.sidxSent = !0), this.meta && (this.flattenItemInfo && !this.itemListBuilt && (this.flattenItemInfo(), this.itemListBuilt = !0), this.processItems && this.processItems(this.onItem)), this.stream.cleanBuffers && (l.info("ISOFile", "Done processing buffer (fileStart: " + t.fileStart + ") - next buffer to fetch should have a fileStart position of " + r), this.stream.logBufferLevel(), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0), l.info("ISOFile", "Sample data size in memory: " + this.getAllocatedSampleDataSize())), r;
|
|
2512
|
+
}, y.prototype.getInfo = function() {
|
|
2513
|
+
var t, e, r = {}, n, o, a, h, f = (/* @__PURE__ */ new Date("1904-01-01T00:00:00Z")).getTime();
|
|
2514
|
+
if (this.moov)
|
|
2515
|
+
for (r.hasMoov = !0, r.duration = this.moov.mvhd.duration, r.timescale = this.moov.mvhd.timescale, r.isFragmented = this.moov.mvex != null, r.isFragmented && this.moov.mvex.mehd && (r.fragment_duration = this.moov.mvex.mehd.fragment_duration), r.isProgressive = this.isProgressive, r.hasIOD = this.moov.iods != null, r.brands = [], r.brands.push(this.ftyp.major_brand), r.brands = r.brands.concat(this.ftyp.compatible_brands), r.created = new Date(f + this.moov.mvhd.creation_time * 1e3), r.modified = new Date(f + this.moov.mvhd.modification_time * 1e3), r.tracks = [], r.audioTracks = [], r.videoTracks = [], r.subtitleTracks = [], r.metadataTracks = [], r.hintTracks = [], r.otherTracks = [], t = 0; t < this.moov.traks.length; t++) {
|
|
2516
|
+
if (n = this.moov.traks[t], h = n.mdia.minf.stbl.stsd.entries[0], o = {}, r.tracks.push(o), o.id = n.tkhd.track_id, o.name = n.mdia.hdlr.name, o.references = [], n.tref)
|
|
2517
|
+
for (e = 0; e < n.tref.boxes.length; e++)
|
|
2518
|
+
a = {}, o.references.push(a), a.type = n.tref.boxes[e].type, a.track_ids = n.tref.boxes[e].track_ids;
|
|
2519
|
+
n.edts && (o.edits = n.edts.elst.entries), o.created = new Date(f + n.tkhd.creation_time * 1e3), o.modified = new Date(f + n.tkhd.modification_time * 1e3), o.movie_duration = n.tkhd.duration, o.movie_timescale = r.timescale, o.layer = n.tkhd.layer, o.alternate_group = n.tkhd.alternate_group, o.volume = n.tkhd.volume, o.matrix = n.tkhd.matrix, o.track_width = n.tkhd.width / 65536, o.track_height = n.tkhd.height / 65536, o.timescale = n.mdia.mdhd.timescale, o.cts_shift = n.mdia.minf.stbl.cslg, o.duration = n.mdia.mdhd.duration, o.samples_duration = n.samples_duration, o.codec = h.getCodec(), o.kind = n.udta && n.udta.kinds.length ? n.udta.kinds[0] : { schemeURI: "", value: "" }, o.language = n.mdia.elng ? n.mdia.elng.extended_language : n.mdia.mdhd.languageString, o.nb_samples = n.samples.length, o.size = n.samples_size, o.bitrate = o.size * 8 * o.timescale / o.samples_duration, h.isAudio() ? (o.type = "audio", r.audioTracks.push(o), o.audio = {}, o.audio.sample_rate = h.getSampleRate(), o.audio.channel_count = h.getChannelCount(), o.audio.sample_size = h.getSampleSize()) : h.isVideo() ? (o.type = "video", r.videoTracks.push(o), o.video = {}, o.video.width = h.getWidth(), o.video.height = h.getHeight()) : h.isSubtitle() ? (o.type = "subtitles", r.subtitleTracks.push(o)) : h.isHint() ? (o.type = "metadata", r.hintTracks.push(o)) : h.isMetadata() ? (o.type = "metadata", r.metadataTracks.push(o)) : (o.type = "metadata", r.otherTracks.push(o));
|
|
2520
|
+
}
|
|
2521
|
+
else
|
|
2522
|
+
r.hasMoov = !1;
|
|
2523
|
+
if (r.mime = "", r.hasMoov && r.tracks) {
|
|
2524
|
+
for (r.videoTracks && r.videoTracks.length > 0 ? r.mime += 'video/mp4; codecs="' : r.audioTracks && r.audioTracks.length > 0 ? r.mime += 'audio/mp4; codecs="' : r.mime += 'application/mp4; codecs="', t = 0; t < r.tracks.length; t++)
|
|
2525
|
+
t !== 0 && (r.mime += ","), r.mime += r.tracks[t].codec;
|
|
2526
|
+
r.mime += '"; profiles="', r.mime += this.ftyp.compatible_brands.join(), r.mime += '"';
|
|
2527
|
+
}
|
|
2528
|
+
return r;
|
|
2529
|
+
}, y.prototype.setNextSeekPositionFromSample = function(t) {
|
|
2530
|
+
t && (this.nextSeekPosition ? this.nextSeekPosition = Math.min(t.offset + t.alreadyRead, this.nextSeekPosition) : this.nextSeekPosition = t.offset + t.alreadyRead);
|
|
2531
|
+
}, y.prototype.processSamples = function(t) {
|
|
2532
|
+
var e, r;
|
|
2533
|
+
if (this.sampleProcessingStarted) {
|
|
2534
|
+
if (this.isFragmentationInitialized && this.onSegment !== null)
|
|
2535
|
+
for (e = 0; e < this.fragmentedTracks.length; e++) {
|
|
2536
|
+
var n = this.fragmentedTracks[e];
|
|
2537
|
+
for (r = n.trak; r.nextSample < r.samples.length && this.sampleProcessingStarted; ) {
|
|
2538
|
+
l.debug("ISOFile", "Creating media fragment on track #" + n.id + " for sample " + r.nextSample);
|
|
2539
|
+
var o = this.createFragment(n.id, r.nextSample, n.segmentStream);
|
|
2540
|
+
if (o)
|
|
2541
|
+
n.segmentStream = o, r.nextSample++;
|
|
2542
|
+
else
|
|
2543
|
+
break;
|
|
2544
|
+
if ((r.nextSample % n.nb_samples === 0 || t || r.nextSample >= r.samples.length) && (l.info("ISOFile", "Sending fragmented data on track #" + n.id + " for samples [" + Math.max(0, r.nextSample - n.nb_samples) + "," + (r.nextSample - 1) + "]"), l.info("ISOFile", "Sample data size in memory: " + this.getAllocatedSampleDataSize()), this.onSegment && this.onSegment(n.id, n.user, n.segmentStream.buffer, r.nextSample, t || r.nextSample >= r.samples.length), n.segmentStream = null, n !== this.fragmentedTracks[e]))
|
|
2545
|
+
break;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
if (this.onSamples !== null)
|
|
2549
|
+
for (e = 0; e < this.extractedTracks.length; e++) {
|
|
2550
|
+
var a = this.extractedTracks[e];
|
|
2551
|
+
for (r = a.trak; r.nextSample < r.samples.length && this.sampleProcessingStarted; ) {
|
|
2552
|
+
l.debug("ISOFile", "Exporting on track #" + a.id + " sample #" + r.nextSample);
|
|
2553
|
+
var h = this.getSample(r, r.nextSample);
|
|
2554
|
+
if (h)
|
|
2555
|
+
r.nextSample++, a.samples.push(h);
|
|
2556
|
+
else {
|
|
2557
|
+
this.setNextSeekPositionFromSample(r.samples[r.nextSample]);
|
|
2558
|
+
break;
|
|
2559
|
+
}
|
|
2560
|
+
if ((r.nextSample % a.nb_samples === 0 || r.nextSample >= r.samples.length) && (l.debug("ISOFile", "Sending samples on track #" + a.id + " for sample " + r.nextSample), this.onSamples && this.onSamples(a.id, a.user, a.samples), a.samples = [], a !== this.extractedTracks[e]))
|
|
2561
|
+
break;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
}, y.prototype.getBox = function(t) {
|
|
2566
|
+
var e = this.getBoxes(t, !0);
|
|
2567
|
+
return e.length ? e[0] : null;
|
|
2568
|
+
}, y.prototype.getBoxes = function(t, e) {
|
|
2569
|
+
var r = [];
|
|
2570
|
+
return y._sweep.call(this, t, r, e), r;
|
|
2571
|
+
}, y._sweep = function(t, e, r) {
|
|
2572
|
+
this.type && this.type == t && e.push(this);
|
|
2573
|
+
for (var n in this.boxes) {
|
|
2574
|
+
if (e.length && r) return;
|
|
2575
|
+
y._sweep.call(this.boxes[n], t, e, r);
|
|
2576
|
+
}
|
|
2577
|
+
}, y.prototype.getTrackSamplesInfo = function(t) {
|
|
2578
|
+
var e = this.getTrackById(t);
|
|
2579
|
+
if (e)
|
|
2580
|
+
return e.samples;
|
|
2581
|
+
}, y.prototype.getTrackSample = function(t, e) {
|
|
2582
|
+
var r = this.getTrackById(t), n = this.getSample(r, e);
|
|
2583
|
+
return n;
|
|
2584
|
+
}, y.prototype.releaseUsedSamples = function(t, e) {
|
|
2585
|
+
var r = 0, n = this.getTrackById(t);
|
|
2586
|
+
n.lastValidSample || (n.lastValidSample = 0);
|
|
2587
|
+
for (var o = n.lastValidSample; o < e; o++)
|
|
2588
|
+
r += this.releaseSample(n, o);
|
|
2589
|
+
l.info("ISOFile", "Track #" + t + " released samples up to " + e + " (released size: " + r + ", remaining: " + this.samplesDataSize + ")"), n.lastValidSample = e;
|
|
2590
|
+
}, y.prototype.start = function() {
|
|
2591
|
+
this.sampleProcessingStarted = !0, this.processSamples(!1);
|
|
2592
|
+
}, y.prototype.stop = function() {
|
|
2593
|
+
this.sampleProcessingStarted = !1;
|
|
2594
|
+
}, y.prototype.flush = function() {
|
|
2595
|
+
l.info("ISOFile", "Flushing remaining samples"), this.updateSampleLists(), this.processSamples(!0), this.stream.cleanBuffers(), this.stream.logBufferLevel(!0);
|
|
2596
|
+
}, y.prototype.seekTrack = function(t, e, r) {
|
|
2597
|
+
var n, o, a = 1 / 0, h = 0, f = 0, p;
|
|
2598
|
+
if (r.samples.length === 0)
|
|
2599
|
+
return l.info("ISOFile", "No sample in track, cannot seek! Using time " + l.getDurationString(0, 1) + " and offset: 0"), { offset: 0, time: 0 };
|
|
2600
|
+
for (n = 0; n < r.samples.length; n++) {
|
|
2601
|
+
if (o = r.samples[n], n === 0)
|
|
2602
|
+
f = 0, p = o.timescale;
|
|
2603
|
+
else if (o.cts > t * o.timescale) {
|
|
2604
|
+
f = n - 1;
|
|
2605
|
+
break;
|
|
2606
|
+
}
|
|
2607
|
+
e && o.is_sync && (h = n);
|
|
2608
|
+
}
|
|
2609
|
+
for (e && (f = h), t = r.samples[f].cts, r.nextSample = f; r.samples[f].alreadyRead === r.samples[f].size && r.samples[f + 1]; )
|
|
2610
|
+
f++;
|
|
2611
|
+
return a = r.samples[f].offset + r.samples[f].alreadyRead, l.info("ISOFile", "Seeking to " + (e ? "RAP" : "") + " sample #" + r.nextSample + " on track " + r.tkhd.track_id + ", time " + l.getDurationString(t, p) + " and offset: " + a), { offset: a, time: t / p };
|
|
2612
|
+
}, y.prototype.getTrackDuration = function(t) {
|
|
2613
|
+
var e;
|
|
2614
|
+
return t.samples ? (e = t.samples[t.samples.length - 1], (e.cts + e.duration) / e.timescale) : 1 / 0;
|
|
2615
|
+
}, y.prototype.seek = function(t, e) {
|
|
2616
|
+
var r = this.moov, n, o, a, h = { offset: 1 / 0, time: 1 / 0 };
|
|
2617
|
+
if (this.moov) {
|
|
2618
|
+
for (a = 0; a < r.traks.length; a++)
|
|
2619
|
+
n = r.traks[a], !(t > this.getTrackDuration(n)) && (o = this.seekTrack(t, e, n), o.offset < h.offset && (h.offset = o.offset), o.time < h.time && (h.time = o.time));
|
|
2620
|
+
return l.info("ISOFile", "Seeking at time " + l.getDurationString(h.time, 1) + " needs a buffer with a fileStart position of " + h.offset), h.offset === 1 / 0 ? h = { offset: this.nextParsePosition, time: 0 } : h.offset = this.stream.getEndFilePositionAfter(h.offset), l.info("ISOFile", "Adjusted seek position (after checking data already in buffer): " + h.offset), h;
|
|
2621
|
+
} else
|
|
2622
|
+
throw "Cannot seek: moov not received!";
|
|
2623
|
+
}, y.prototype.equal = function(t) {
|
|
2624
|
+
for (var e = 0; e < this.boxes.length && e < t.boxes.length; ) {
|
|
2625
|
+
var r = this.boxes[e], n = t.boxes[e];
|
|
2626
|
+
if (!s.boxEqual(r, n))
|
|
2627
|
+
return !1;
|
|
2628
|
+
e++;
|
|
2629
|
+
}
|
|
2630
|
+
return !0;
|
|
2631
|
+
}, v.ISOFile = y, y.prototype.lastBoxStartPosition = 0, y.prototype.parsingMdat = null, y.prototype.nextParsePosition = 0, y.prototype.discardMdatData = !1, y.prototype.processIncompleteBox = function(t) {
|
|
2632
|
+
var e, r, n;
|
|
2633
|
+
return t.type === "mdat" ? (e = new s[t.type + "Box"](t.size), this.parsingMdat = e, this.boxes.push(e), this.mdats.push(e), e.start = t.start, e.hdr_size = t.hdr_size, this.stream.addUsedBytes(e.hdr_size), this.lastBoxStartPosition = e.start + e.size, n = this.stream.seek(e.start + e.size, !1, this.discardMdatData), n ? (this.parsingMdat = null, !0) : (this.moovStartFound ? this.nextParsePosition = this.stream.findEndContiguousBuf() : this.nextParsePosition = e.start + e.size, !1)) : (t.type === "moov" && (this.moovStartFound = !0, this.mdats.length === 0 && (this.isProgressive = !0)), r = this.stream.mergeNextBuffer ? this.stream.mergeNextBuffer() : !1, r ? (this.nextParsePosition = this.stream.getEndPosition(), !0) : (t.type ? this.moovStartFound ? this.nextParsePosition = this.stream.getEndPosition() : this.nextParsePosition = this.stream.getPosition() + t.size : this.nextParsePosition = this.stream.getEndPosition(), !1));
|
|
2634
|
+
}, y.prototype.hasIncompleteMdat = function() {
|
|
2635
|
+
return this.parsingMdat !== null;
|
|
2636
|
+
}, y.prototype.processIncompleteMdat = function() {
|
|
2637
|
+
var t, e;
|
|
2638
|
+
return t = this.parsingMdat, e = this.stream.seek(t.start + t.size, !1, this.discardMdatData), e ? (l.debug("ISOFile", "Found 'mdat' end in buffered data"), this.parsingMdat = null, !0) : (this.nextParsePosition = this.stream.findEndContiguousBuf(), !1);
|
|
2639
|
+
}, y.prototype.restoreParsePosition = function() {
|
|
2640
|
+
return this.stream.seek(this.lastBoxStartPosition, !0, this.discardMdatData);
|
|
2641
|
+
}, y.prototype.saveParsePosition = function() {
|
|
2642
|
+
this.lastBoxStartPosition = this.stream.getPosition();
|
|
2643
|
+
}, y.prototype.updateUsedBytes = function(t, e) {
|
|
2644
|
+
this.stream.addUsedBytes && (t.type === "mdat" ? (this.stream.addUsedBytes(t.hdr_size), this.discardMdatData && this.stream.addUsedBytes(t.size - t.hdr_size)) : this.stream.addUsedBytes(t.size));
|
|
2645
|
+
}, y.prototype.add = s.Box.prototype.add, y.prototype.addBox = s.Box.prototype.addBox, y.prototype.init = function(t) {
|
|
2646
|
+
var e = t || {};
|
|
2647
|
+
this.add("ftyp").set("major_brand", e.brands && e.brands[0] || "iso4").set("minor_version", 0).set("compatible_brands", e.brands || ["iso4"]);
|
|
2648
|
+
var r = this.add("moov");
|
|
2649
|
+
return r.add("mvhd").set("timescale", e.timescale || 600).set("rate", e.rate || 65536).set("creation_time", 0).set("modification_time", 0).set("duration", e.duration || 0).set("volume", e.width ? 0 : 256).set("matrix", [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824]).set("next_track_id", 1), r.add("mvex"), this;
|
|
2650
|
+
}, y.prototype.addTrack = function(t) {
|
|
2651
|
+
this.moov || this.init(t);
|
|
2652
|
+
var e = t || {};
|
|
2653
|
+
e.width = e.width || 320, e.height = e.height || 320, e.id = e.id || this.moov.mvhd.next_track_id, e.type = e.type || "avc1";
|
|
2654
|
+
var r = this.moov.add("trak");
|
|
2655
|
+
this.moov.mvhd.next_track_id = e.id + 1, r.add("tkhd").set("flags", s.TKHD_FLAG_ENABLED | s.TKHD_FLAG_IN_MOVIE | s.TKHD_FLAG_IN_PREVIEW).set("creation_time", 0).set("modification_time", 0).set("track_id", e.id).set("duration", e.duration || 0).set("layer", e.layer || 0).set("alternate_group", 0).set("volume", 1).set("matrix", [65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824]).set("width", e.width << 16).set("height", e.height << 16);
|
|
2656
|
+
var n = r.add("mdia");
|
|
2657
|
+
n.add("mdhd").set("creation_time", 0).set("modification_time", 0).set("timescale", e.timescale || 1).set("duration", e.media_duration || 0).set("language", e.language || "und"), n.add("hdlr").set("handler", e.hdlr || "vide").set("name", e.name || "Track created with MP4Box.js"), n.add("elng").set("extended_language", e.language || "fr-FR");
|
|
2658
|
+
var o = n.add("minf");
|
|
2659
|
+
if (s[e.type + "SampleEntry"] !== void 0) {
|
|
2660
|
+
var a = new s[e.type + "SampleEntry"]();
|
|
2661
|
+
a.data_reference_index = 1;
|
|
2662
|
+
var h = "";
|
|
2663
|
+
for (var f in s.sampleEntryCodes)
|
|
2664
|
+
for (var p = s.sampleEntryCodes[f], u = 0; u < p.length; u++)
|
|
2665
|
+
if (p.indexOf(e.type) > -1) {
|
|
2666
|
+
h = f;
|
|
2667
|
+
break;
|
|
2668
|
+
}
|
|
2669
|
+
switch (h) {
|
|
2670
|
+
case "Visual":
|
|
2671
|
+
if (o.add("vmhd").set("graphicsmode", 0).set("opcolor", [0, 0, 0]), a.set("width", e.width).set("height", e.height).set("horizresolution", 72 << 16).set("vertresolution", 72 << 16).set("frame_count", 1).set("compressorname", e.type + " Compressor").set("depth", 24), e.avcDecoderConfigRecord) {
|
|
2672
|
+
var c = new s.avcCBox();
|
|
2673
|
+
c.parse(new _(e.avcDecoderConfigRecord)), a.addBox(c);
|
|
2674
|
+
} else if (e.hevcDecoderConfigRecord) {
|
|
2675
|
+
var g = new s.hvcCBox();
|
|
2676
|
+
g.parse(new _(e.hevcDecoderConfigRecord)), a.addBox(g);
|
|
2677
|
+
}
|
|
2678
|
+
break;
|
|
2679
|
+
case "Audio":
|
|
2680
|
+
o.add("smhd").set("balance", e.balance || 0), a.set("channel_count", e.channel_count || 2).set("samplesize", e.samplesize || 16).set("samplerate", e.samplerate || 65536);
|
|
2681
|
+
break;
|
|
2682
|
+
case "Hint":
|
|
2683
|
+
o.add("hmhd");
|
|
2684
|
+
break;
|
|
2685
|
+
case "Subtitle":
|
|
2686
|
+
o.add("sthd"), e.type === "stpp" && a.set("namespace", e.namespace || "nonamespace").set("schema_location", e.schema_location || "").set("auxiliary_mime_types", e.auxiliary_mime_types || "");
|
|
2687
|
+
break;
|
|
2688
|
+
case "Metadata":
|
|
2689
|
+
o.add("nmhd");
|
|
2690
|
+
break;
|
|
2691
|
+
case "System":
|
|
2692
|
+
o.add("nmhd");
|
|
2693
|
+
break;
|
|
2694
|
+
default:
|
|
2695
|
+
o.add("nmhd");
|
|
2696
|
+
break;
|
|
2697
|
+
}
|
|
2698
|
+
e.description && a.addBox(e.description), e.description_boxes && e.description_boxes.forEach(function(m) {
|
|
2699
|
+
a.addBox(m);
|
|
2700
|
+
}), o.add("dinf").add("dref").addEntry(new s["url Box"]().set("flags", 1));
|
|
2701
|
+
var x = o.add("stbl");
|
|
2702
|
+
return x.add("stsd").addEntry(a), x.add("stts").set("sample_counts", []).set("sample_deltas", []), x.add("stsc").set("first_chunk", []).set("samples_per_chunk", []).set("sample_description_index", []), x.add("stco").set("chunk_offsets", []), x.add("stsz").set("sample_sizes", []), this.moov.mvex.add("trex").set("track_id", e.id).set("default_sample_description_index", e.default_sample_description_index || 1).set("default_sample_duration", e.default_sample_duration || 0).set("default_sample_size", e.default_sample_size || 0).set("default_sample_flags", e.default_sample_flags || 0), this.buildTrakSampleLists(r), e.id;
|
|
2703
|
+
}
|
|
2704
|
+
}, s.Box.prototype.computeSize = function(t) {
|
|
2705
|
+
var e = t || new d();
|
|
2706
|
+
e.endianness = d.BIG_ENDIAN, this.write(e);
|
|
2707
|
+
}, y.prototype.addSample = function(t, e, r) {
|
|
2708
|
+
var n = r || {}, o = {}, a = this.getTrackById(t);
|
|
2709
|
+
if (a !== null) {
|
|
2710
|
+
o.number = a.samples.length, o.track_id = a.tkhd.track_id, o.timescale = a.mdia.mdhd.timescale, o.description_index = n.sample_description_index ? n.sample_description_index - 1 : 0, o.description = a.mdia.minf.stbl.stsd.entries[o.description_index], o.data = e, o.size = e.byteLength, o.alreadyRead = o.size, o.duration = n.duration || 1, o.cts = n.cts || 0, o.dts = n.dts || 0, o.is_sync = n.is_sync || !1, o.is_leading = n.is_leading || 0, o.depends_on = n.depends_on || 0, o.is_depended_on = n.is_depended_on || 0, o.has_redundancy = n.has_redundancy || 0, o.degradation_priority = n.degradation_priority || 0, o.offset = 0, o.subsamples = n.subsamples, a.samples.push(o), a.samples_size += o.size, a.samples_duration += o.duration, a.first_dts === void 0 && (a.first_dts = n.dts), this.processSamples();
|
|
2711
|
+
var h = this.createSingleSampleMoof(o);
|
|
2712
|
+
return this.addBox(h), h.computeSize(), h.trafs[0].truns[0].data_offset = h.size + 8, this.add("mdat").data = new Uint8Array(e), o;
|
|
2713
|
+
}
|
|
2714
|
+
}, y.prototype.createSingleSampleMoof = function(t) {
|
|
2715
|
+
var e = 0;
|
|
2716
|
+
t.is_sync ? e = 1 << 25 : e = 65536;
|
|
2717
|
+
var r = new s.moofBox();
|
|
2718
|
+
r.add("mfhd").set("sequence_number", this.nextMoofNumber), this.nextMoofNumber++;
|
|
2719
|
+
var n = r.add("traf"), o = this.getTrackById(t.track_id);
|
|
2720
|
+
return n.add("tfhd").set("track_id", t.track_id).set("flags", s.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), n.add("tfdt").set("baseMediaDecodeTime", t.dts - (o.first_dts || 0)), n.add("trun").set("flags", s.TRUN_FLAGS_DATA_OFFSET | s.TRUN_FLAGS_DURATION | s.TRUN_FLAGS_SIZE | s.TRUN_FLAGS_FLAGS | s.TRUN_FLAGS_CTS_OFFSET).set("data_offset", 0).set("first_sample_flags", 0).set("sample_count", 1).set("sample_duration", [t.duration]).set("sample_size", [t.size]).set("sample_flags", [e]).set("sample_composition_time_offset", [t.cts - t.dts]), r;
|
|
2721
|
+
}, y.prototype.lastMoofIndex = 0, y.prototype.samplesDataSize = 0, y.prototype.resetTables = function() {
|
|
2722
|
+
var t, e, r, n, o, a, h, f;
|
|
2723
|
+
for (this.initial_duration = this.moov.mvhd.duration, this.moov.mvhd.duration = 0, t = 0; t < this.moov.traks.length; t++) {
|
|
2724
|
+
e = this.moov.traks[t], e.tkhd.duration = 0, e.mdia.mdhd.duration = 0, r = e.mdia.minf.stbl.stco || e.mdia.minf.stbl.co64, r.chunk_offsets = [], n = e.mdia.minf.stbl.stsc, n.first_chunk = [], n.samples_per_chunk = [], n.sample_description_index = [], o = e.mdia.minf.stbl.stsz || e.mdia.minf.stbl.stz2, o.sample_sizes = [], a = e.mdia.minf.stbl.stts, a.sample_counts = [], a.sample_deltas = [], h = e.mdia.minf.stbl.ctts, h && (h.sample_counts = [], h.sample_offsets = []), f = e.mdia.minf.stbl.stss;
|
|
2725
|
+
var p = e.mdia.minf.stbl.boxes.indexOf(f);
|
|
2726
|
+
p != -1 && (e.mdia.minf.stbl.boxes[p] = null);
|
|
2727
|
+
}
|
|
2728
|
+
}, y.initSampleGroups = function(t, e, r, n, o) {
|
|
2729
|
+
var a, h, f, p;
|
|
2730
|
+
function u(c, g, x) {
|
|
2731
|
+
this.grouping_type = c, this.grouping_type_parameter = g, this.sbgp = x, this.last_sample_in_run = -1, this.entry_index = -1;
|
|
2732
|
+
}
|
|
2733
|
+
for (e && (e.sample_groups_info = []), t.sample_groups_info || (t.sample_groups_info = []), h = 0; h < r.length; h++) {
|
|
2734
|
+
for (p = r[h].grouping_type + "/" + r[h].grouping_type_parameter, f = new u(r[h].grouping_type, r[h].grouping_type_parameter, r[h]), e && (e.sample_groups_info[p] = f), t.sample_groups_info[p] || (t.sample_groups_info[p] = f), a = 0; a < n.length; a++)
|
|
2735
|
+
n[a].grouping_type === r[h].grouping_type && (f.description = n[a], f.description.used = !0);
|
|
2736
|
+
if (o)
|
|
2737
|
+
for (a = 0; a < o.length; a++)
|
|
2738
|
+
o[a].grouping_type === r[h].grouping_type && (f.fragment_description = o[a], f.fragment_description.used = !0, f.is_fragment = !0);
|
|
2739
|
+
}
|
|
2740
|
+
if (e) {
|
|
2741
|
+
if (o)
|
|
2742
|
+
for (h = 0; h < o.length; h++)
|
|
2743
|
+
!o[h].used && o[h].version >= 2 && (p = o[h].grouping_type + "/0", f = new u(o[h].grouping_type, 0), f.is_fragment = !0, e.sample_groups_info[p] || (e.sample_groups_info[p] = f));
|
|
2744
|
+
} else
|
|
2745
|
+
for (h = 0; h < n.length; h++)
|
|
2746
|
+
!n[h].used && n[h].version >= 2 && (p = n[h].grouping_type + "/0", f = new u(n[h].grouping_type, 0), t.sample_groups_info[p] || (t.sample_groups_info[p] = f));
|
|
2747
|
+
}, y.setSampleGroupProperties = function(t, e, r, n) {
|
|
2748
|
+
var o, a;
|
|
2749
|
+
e.sample_groups = [];
|
|
2750
|
+
for (o in n)
|
|
2751
|
+
if (e.sample_groups[o] = {}, e.sample_groups[o].grouping_type = n[o].grouping_type, e.sample_groups[o].grouping_type_parameter = n[o].grouping_type_parameter, r >= n[o].last_sample_in_run && (n[o].last_sample_in_run < 0 && (n[o].last_sample_in_run = 0), n[o].entry_index++, n[o].entry_index <= n[o].sbgp.entries.length - 1 && (n[o].last_sample_in_run += n[o].sbgp.entries[n[o].entry_index].sample_count)), n[o].entry_index <= n[o].sbgp.entries.length - 1 ? e.sample_groups[o].group_description_index = n[o].sbgp.entries[n[o].entry_index].group_description_index : e.sample_groups[o].group_description_index = -1, e.sample_groups[o].group_description_index !== 0) {
|
|
2752
|
+
var h;
|
|
2753
|
+
n[o].fragment_description ? h = n[o].fragment_description : h = n[o].description, e.sample_groups[o].group_description_index > 0 ? (e.sample_groups[o].group_description_index > 65535 ? a = (e.sample_groups[o].group_description_index >> 16) - 1 : a = e.sample_groups[o].group_description_index - 1, h && a >= 0 && (e.sample_groups[o].description = h.entries[a])) : h && h.version >= 2 && h.default_group_description_index > 0 && (e.sample_groups[o].description = h.entries[h.default_group_description_index - 1]);
|
|
2754
|
+
}
|
|
2755
|
+
}, y.process_sdtp = function(t, e, r) {
|
|
2756
|
+
e && (t ? (e.is_leading = t.is_leading[r], e.depends_on = t.sample_depends_on[r], e.is_depended_on = t.sample_is_depended_on[r], e.has_redundancy = t.sample_has_redundancy[r]) : (e.is_leading = 0, e.depends_on = 0, e.is_depended_on = 0, e.has_redundancy = 0));
|
|
2757
|
+
}, y.prototype.buildSampleLists = function() {
|
|
2758
|
+
var t, e;
|
|
2759
|
+
for (t = 0; t < this.moov.traks.length; t++)
|
|
2760
|
+
e = this.moov.traks[t], this.buildTrakSampleLists(e);
|
|
2761
|
+
}, y.prototype.buildTrakSampleLists = function(t) {
|
|
2762
|
+
var e, r, n, o, a, h, f, p, u, c, g, x, m, E, w, k, N, P, I, F, Y, K, z, O;
|
|
2763
|
+
if (t.samples = [], t.samples_duration = 0, t.samples_size = 0, r = t.mdia.minf.stbl.stco || t.mdia.minf.stbl.co64, n = t.mdia.minf.stbl.stsc, o = t.mdia.minf.stbl.stsz || t.mdia.minf.stbl.stz2, a = t.mdia.minf.stbl.stts, h = t.mdia.minf.stbl.ctts, f = t.mdia.minf.stbl.stss, p = t.mdia.minf.stbl.stsd, u = t.mdia.minf.stbl.subs, x = t.mdia.minf.stbl.stdp, c = t.mdia.minf.stbl.sbgps, g = t.mdia.minf.stbl.sgpds, P = -1, I = -1, F = -1, Y = -1, K = 0, z = 0, O = 0, y.initSampleGroups(t, null, c, g), !(typeof o > "u")) {
|
|
2764
|
+
for (e = 0; e < o.sample_sizes.length; e++) {
|
|
2765
|
+
var U = {};
|
|
2766
|
+
U.number = e, U.track_id = t.tkhd.track_id, U.timescale = t.mdia.mdhd.timescale, U.alreadyRead = 0, t.samples[e] = U, U.size = o.sample_sizes[e], t.samples_size += U.size, e === 0 ? (E = 1, m = 0, U.chunk_index = E, U.chunk_run_index = m, N = n.samples_per_chunk[m], k = 0, m + 1 < n.first_chunk.length ? w = n.first_chunk[m + 1] - 1 : w = 1 / 0) : e < N ? (U.chunk_index = E, U.chunk_run_index = m) : (E++, U.chunk_index = E, k = 0, E <= w || (m++, m + 1 < n.first_chunk.length ? w = n.first_chunk[m + 1] - 1 : w = 1 / 0), U.chunk_run_index = m, N += n.samples_per_chunk[m]), U.description_index = n.sample_description_index[U.chunk_run_index] - 1, U.description = p.entries[U.description_index], U.offset = r.chunk_offsets[U.chunk_index - 1] + k, k += U.size, e > P && (I++, P < 0 && (P = 0), P += a.sample_counts[I]), e > 0 ? (t.samples[e - 1].duration = a.sample_deltas[I], t.samples_duration += t.samples[e - 1].duration, U.dts = t.samples[e - 1].dts + t.samples[e - 1].duration) : U.dts = 0, h ? (e >= F && (Y++, F < 0 && (F = 0), F += h.sample_counts[Y]), U.cts = t.samples[e].dts + h.sample_offsets[Y]) : U.cts = U.dts, f ? (e == f.sample_numbers[K] - 1 ? (U.is_sync = !0, K++) : (U.is_sync = !1, U.degradation_priority = 0), u && u.entries[z].sample_delta + O == e + 1 && (U.subsamples = u.entries[z].subsamples, O += u.entries[z].sample_delta, z++)) : U.is_sync = !0, y.process_sdtp(t.mdia.minf.stbl.sdtp, U, U.number), x ? U.degradation_priority = x.priority[e] : U.degradation_priority = 0, u && u.entries[z].sample_delta + O == e && (U.subsamples = u.entries[z].subsamples, O += u.entries[z].sample_delta), (c.length > 0 || g.length > 0) && y.setSampleGroupProperties(t, U, e, t.sample_groups_info);
|
|
2767
|
+
}
|
|
2768
|
+
e > 0 && (t.samples[e - 1].duration = Math.max(t.mdia.mdhd.duration - t.samples[e - 1].dts, 0), t.samples_duration += t.samples[e - 1].duration);
|
|
2769
|
+
}
|
|
2770
|
+
}, y.prototype.updateSampleLists = function() {
|
|
2771
|
+
var t, e, r, n, o, a, h, f, p, u, c, g, x, m, E;
|
|
2772
|
+
if (this.moov !== void 0) {
|
|
2773
|
+
for (; this.lastMoofIndex < this.moofs.length; )
|
|
2774
|
+
if (p = this.moofs[this.lastMoofIndex], this.lastMoofIndex++, p.type == "moof")
|
|
2775
|
+
for (u = p, t = 0; t < u.trafs.length; t++) {
|
|
2776
|
+
for (c = u.trafs[t], g = this.getTrackById(c.tfhd.track_id), x = this.getTrexById(c.tfhd.track_id), c.tfhd.flags & s.TFHD_FLAG_SAMPLE_DESC ? n = c.tfhd.default_sample_description_index : n = x ? x.default_sample_description_index : 1, c.tfhd.flags & s.TFHD_FLAG_SAMPLE_DUR ? o = c.tfhd.default_sample_duration : o = x ? x.default_sample_duration : 0, c.tfhd.flags & s.TFHD_FLAG_SAMPLE_SIZE ? a = c.tfhd.default_sample_size : a = x ? x.default_sample_size : 0, c.tfhd.flags & s.TFHD_FLAG_SAMPLE_FLAGS ? h = c.tfhd.default_sample_flags : h = x ? x.default_sample_flags : 0, c.sample_number = 0, c.sbgps.length > 0 && y.initSampleGroups(g, c, c.sbgps, g.mdia.minf.stbl.sgpds, c.sgpds), e = 0; e < c.truns.length; e++) {
|
|
2777
|
+
var w = c.truns[e];
|
|
2778
|
+
for (r = 0; r < w.sample_count; r++) {
|
|
2779
|
+
m = {}, m.moof_number = this.lastMoofIndex, m.number_in_traf = c.sample_number, c.sample_number++, m.number = g.samples.length, c.first_sample_index = g.samples.length, g.samples.push(m), m.track_id = g.tkhd.track_id, m.timescale = g.mdia.mdhd.timescale, m.description_index = n - 1, m.description = g.mdia.minf.stbl.stsd.entries[m.description_index], m.size = a, w.flags & s.TRUN_FLAGS_SIZE && (m.size = w.sample_size[r]), g.samples_size += m.size, m.duration = o, w.flags & s.TRUN_FLAGS_DURATION && (m.duration = w.sample_duration[r]), g.samples_duration += m.duration, g.first_traf_merged || r > 0 ? m.dts = g.samples[g.samples.length - 2].dts + g.samples[g.samples.length - 2].duration : (c.tfdt ? m.dts = c.tfdt.baseMediaDecodeTime : m.dts = 0, g.first_traf_merged = !0), m.cts = m.dts, w.flags & s.TRUN_FLAGS_CTS_OFFSET && (m.cts = m.dts + w.sample_composition_time_offset[r]), E = h, w.flags & s.TRUN_FLAGS_FLAGS ? E = w.sample_flags[r] : r === 0 && w.flags & s.TRUN_FLAGS_FIRST_FLAG && (E = w.first_sample_flags), m.is_sync = !(E >> 16 & 1), m.is_leading = E >> 26 & 3, m.depends_on = E >> 24 & 3, m.is_depended_on = E >> 22 & 3, m.has_redundancy = E >> 20 & 3, m.degradation_priority = E & 65535;
|
|
2780
|
+
var k = !!(c.tfhd.flags & s.TFHD_FLAG_BASE_DATA_OFFSET), N = !!(c.tfhd.flags & s.TFHD_FLAG_DEFAULT_BASE_IS_MOOF), P = !!(w.flags & s.TRUN_FLAGS_DATA_OFFSET), I = 0;
|
|
2781
|
+
k ? I = c.tfhd.base_data_offset : N || e === 0 ? I = u.start : I = f, e === 0 && r === 0 ? P ? m.offset = I + w.data_offset : m.offset = I : m.offset = f, f = m.offset + m.size, (c.sbgps.length > 0 || c.sgpds.length > 0 || g.mdia.minf.stbl.sbgps.length > 0 || g.mdia.minf.stbl.sgpds.length > 0) && y.setSampleGroupProperties(g, m, m.number_in_traf, c.sample_groups_info);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
if (c.subs) {
|
|
2785
|
+
g.has_fragment_subsamples = !0;
|
|
2786
|
+
var F = c.first_sample_index;
|
|
2787
|
+
for (e = 0; e < c.subs.entries.length; e++)
|
|
2788
|
+
F += c.subs.entries[e].sample_delta, m = g.samples[F - 1], m.subsamples = c.subs.entries[e].subsamples;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
}, y.prototype.getSample = function(t, e) {
|
|
2793
|
+
var r, n = t.samples[e];
|
|
2794
|
+
if (!this.moov)
|
|
2795
|
+
return null;
|
|
2796
|
+
if (!n.data)
|
|
2797
|
+
n.data = new Uint8Array(n.size), n.alreadyRead = 0, this.samplesDataSize += n.size, l.debug("ISOFile", "Allocating sample #" + e + " on track #" + t.tkhd.track_id + " of size " + n.size + " (total: " + this.samplesDataSize + ")");
|
|
2798
|
+
else if (n.alreadyRead == n.size)
|
|
2799
|
+
return n;
|
|
2800
|
+
for (; ; ) {
|
|
2801
|
+
var o = this.stream.findPosition(!0, n.offset + n.alreadyRead, !1);
|
|
2802
|
+
if (o > -1) {
|
|
2803
|
+
r = this.stream.buffers[o];
|
|
2804
|
+
var a = r.byteLength - (n.offset + n.alreadyRead - r.fileStart);
|
|
2805
|
+
if (n.size - n.alreadyRead <= a)
|
|
2806
|
+
return l.debug("ISOFile", "Getting sample #" + e + " data (alreadyRead: " + n.alreadyRead + " offset: " + (n.offset + n.alreadyRead - r.fileStart) + " read size: " + (n.size - n.alreadyRead) + " full size: " + n.size + ")"), d.memcpy(
|
|
2807
|
+
n.data.buffer,
|
|
2808
|
+
n.alreadyRead,
|
|
2809
|
+
r,
|
|
2810
|
+
n.offset + n.alreadyRead - r.fileStart,
|
|
2811
|
+
n.size - n.alreadyRead
|
|
2812
|
+
), r.usedBytes += n.size - n.alreadyRead, this.stream.logBufferLevel(), n.alreadyRead = n.size, n;
|
|
2813
|
+
if (a === 0) return null;
|
|
2814
|
+
l.debug("ISOFile", "Getting sample #" + e + " partial data (alreadyRead: " + n.alreadyRead + " offset: " + (n.offset + n.alreadyRead - r.fileStart) + " read size: " + a + " full size: " + n.size + ")"), d.memcpy(
|
|
2815
|
+
n.data.buffer,
|
|
2816
|
+
n.alreadyRead,
|
|
2817
|
+
r,
|
|
2818
|
+
n.offset + n.alreadyRead - r.fileStart,
|
|
2819
|
+
a
|
|
2820
|
+
), n.alreadyRead += a, r.usedBytes += a, this.stream.logBufferLevel();
|
|
2821
|
+
} else
|
|
2822
|
+
return null;
|
|
2823
|
+
}
|
|
2824
|
+
}, y.prototype.releaseSample = function(t, e) {
|
|
2825
|
+
var r = t.samples[e];
|
|
2826
|
+
return r.data ? (this.samplesDataSize -= r.size, r.data = null, r.alreadyRead = 0, r.size) : 0;
|
|
2827
|
+
}, y.prototype.getAllocatedSampleDataSize = function() {
|
|
2828
|
+
return this.samplesDataSize;
|
|
2829
|
+
}, y.prototype.getCodecs = function() {
|
|
2830
|
+
var t, e = "";
|
|
2831
|
+
for (t = 0; t < this.moov.traks.length; t++) {
|
|
2832
|
+
var r = this.moov.traks[t];
|
|
2833
|
+
t > 0 && (e += ","), e += r.mdia.minf.stbl.stsd.entries[0].getCodec();
|
|
2834
|
+
}
|
|
2835
|
+
return e;
|
|
2836
|
+
}, y.prototype.getTrexById = function(t) {
|
|
2837
|
+
var e;
|
|
2838
|
+
if (!this.moov || !this.moov.mvex) return null;
|
|
2839
|
+
for (e = 0; e < this.moov.mvex.trexs.length; e++) {
|
|
2840
|
+
var r = this.moov.mvex.trexs[e];
|
|
2841
|
+
if (r.track_id == t) return r;
|
|
2842
|
+
}
|
|
2843
|
+
return null;
|
|
2844
|
+
}, y.prototype.getTrackById = function(t) {
|
|
2845
|
+
if (this.moov === void 0)
|
|
2846
|
+
return null;
|
|
2847
|
+
for (var e = 0; e < this.moov.traks.length; e++) {
|
|
2848
|
+
var r = this.moov.traks[e];
|
|
2849
|
+
if (r.tkhd.track_id == t) return r;
|
|
2850
|
+
}
|
|
2851
|
+
return null;
|
|
2852
|
+
}, y.prototype.itemsDataSize = 0, y.prototype.flattenItemInfo = function() {
|
|
2853
|
+
var t = this.items, e = this.entity_groups, r, n, o, a = this.meta;
|
|
2854
|
+
if (a != null && a.hdlr !== void 0 && a.iinf !== void 0) {
|
|
2855
|
+
for (r = 0; r < a.iinf.item_infos.length; r++)
|
|
2856
|
+
o = {}, o.id = a.iinf.item_infos[r].item_ID, t[o.id] = o, o.ref_to = [], o.name = a.iinf.item_infos[r].item_name, a.iinf.item_infos[r].protection_index > 0 && (o.protection = a.ipro.protections[a.iinf.item_infos[r].protection_index - 1]), a.iinf.item_infos[r].item_type ? o.type = a.iinf.item_infos[r].item_type : o.type = "mime", o.content_type = a.iinf.item_infos[r].content_type, o.content_encoding = a.iinf.item_infos[r].content_encoding, o.item_uri_type = a.iinf.item_infos[r].item_uri_type;
|
|
2857
|
+
if (a.grpl)
|
|
2858
|
+
for (r = 0; r < a.grpl.boxes.length; r++)
|
|
2859
|
+
entity_group = {}, entity_group.id = a.grpl.boxes[r].group_id, entity_group.entity_ids = a.grpl.boxes[r].entity_ids, entity_group.type = a.grpl.boxes[r].type, e[entity_group.id] = entity_group;
|
|
2860
|
+
if (a.iloc)
|
|
2861
|
+
for (r = 0; r < a.iloc.items.length; r++) {
|
|
2862
|
+
var h = a.iloc.items[r];
|
|
2863
|
+
switch (o = t[h.item_ID], h.data_reference_index !== 0 && (l.warn("Item storage with reference to other files: not supported"), o.source = a.dinf.boxes[h.data_reference_index - 1]), h.construction_method) {
|
|
2864
|
+
case 0:
|
|
2865
|
+
break;
|
|
2866
|
+
case 1:
|
|
2867
|
+
break;
|
|
2868
|
+
case 2:
|
|
2869
|
+
l.warn("Item storage with construction_method : not supported");
|
|
2870
|
+
break;
|
|
2871
|
+
}
|
|
2872
|
+
for (o.extents = [], o.size = 0, n = 0; n < h.extents.length; n++)
|
|
2873
|
+
o.extents[n] = {}, o.extents[n].offset = h.extents[n].extent_offset + h.base_offset, h.construction_method == 1 && (o.extents[n].offset += a.idat.start + a.idat.hdr_size), o.extents[n].length = h.extents[n].extent_length, o.extents[n].alreadyRead = 0, o.size += o.extents[n].length;
|
|
2874
|
+
}
|
|
2875
|
+
if (a.pitm && (t[a.pitm.item_id].primary = !0), a.iref)
|
|
2876
|
+
for (r = 0; r < a.iref.references.length; r++) {
|
|
2877
|
+
var f = a.iref.references[r];
|
|
2878
|
+
for (n = 0; n < f.references.length; n++)
|
|
2879
|
+
t[f.from_item_ID].ref_to.push({ type: f.type, id: f.references[n] });
|
|
2880
|
+
}
|
|
2881
|
+
if (a.iprp)
|
|
2882
|
+
for (var p = 0; p < a.iprp.ipmas.length; p++) {
|
|
2883
|
+
var u = a.iprp.ipmas[p];
|
|
2884
|
+
for (r = 0; r < u.associations.length; r++) {
|
|
2885
|
+
var c = u.associations[r];
|
|
2886
|
+
if (o = t[c.id], o || (o = e[c.id]), o)
|
|
2887
|
+
for (o.properties === void 0 && (o.properties = {}, o.properties.boxes = []), n = 0; n < c.props.length; n++) {
|
|
2888
|
+
var g = c.props[n];
|
|
2889
|
+
if (g.property_index > 0 && g.property_index - 1 < a.iprp.ipco.boxes.length) {
|
|
2890
|
+
var x = a.iprp.ipco.boxes[g.property_index - 1];
|
|
2891
|
+
o.properties[x.type] = x, o.properties.boxes.push(x);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
}, y.prototype.getItem = function(t) {
|
|
2898
|
+
var e, r;
|
|
2899
|
+
if (!this.meta)
|
|
2900
|
+
return null;
|
|
2901
|
+
if (r = this.items[t], !r.data && r.size)
|
|
2902
|
+
r.data = new Uint8Array(r.size), r.alreadyRead = 0, this.itemsDataSize += r.size, l.debug("ISOFile", "Allocating item #" + t + " of size " + r.size + " (total: " + this.itemsDataSize + ")");
|
|
2903
|
+
else if (r.alreadyRead === r.size)
|
|
2904
|
+
return r;
|
|
2905
|
+
for (var n = 0; n < r.extents.length; n++) {
|
|
2906
|
+
var o = r.extents[n];
|
|
2907
|
+
if (o.alreadyRead !== o.length) {
|
|
2908
|
+
var a = this.stream.findPosition(!0, o.offset + o.alreadyRead, !1);
|
|
2909
|
+
if (a > -1) {
|
|
2910
|
+
e = this.stream.buffers[a];
|
|
2911
|
+
var h = e.byteLength - (o.offset + o.alreadyRead - e.fileStart);
|
|
2912
|
+
if (o.length - o.alreadyRead <= h)
|
|
2913
|
+
l.debug("ISOFile", "Getting item #" + t + " extent #" + n + " data (alreadyRead: " + o.alreadyRead + " offset: " + (o.offset + o.alreadyRead - e.fileStart) + " read size: " + (o.length - o.alreadyRead) + " full extent size: " + o.length + " full item size: " + r.size + ")"), d.memcpy(
|
|
2914
|
+
r.data.buffer,
|
|
2915
|
+
r.alreadyRead,
|
|
2916
|
+
e,
|
|
2917
|
+
o.offset + o.alreadyRead - e.fileStart,
|
|
2918
|
+
o.length - o.alreadyRead
|
|
2919
|
+
), e.usedBytes += o.length - o.alreadyRead, this.stream.logBufferLevel(), r.alreadyRead += o.length - o.alreadyRead, o.alreadyRead = o.length;
|
|
2920
|
+
else
|
|
2921
|
+
return l.debug("ISOFile", "Getting item #" + t + " extent #" + n + " partial data (alreadyRead: " + o.alreadyRead + " offset: " + (o.offset + o.alreadyRead - e.fileStart) + " read size: " + h + " full extent size: " + o.length + " full item size: " + r.size + ")"), d.memcpy(
|
|
2922
|
+
r.data.buffer,
|
|
2923
|
+
r.alreadyRead,
|
|
2924
|
+
e,
|
|
2925
|
+
o.offset + o.alreadyRead - e.fileStart,
|
|
2926
|
+
h
|
|
2927
|
+
), o.alreadyRead += h, r.alreadyRead += h, e.usedBytes += h, this.stream.logBufferLevel(), null;
|
|
2928
|
+
} else
|
|
2929
|
+
return null;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
return r.alreadyRead === r.size ? r : null;
|
|
2933
|
+
}, y.prototype.releaseItem = function(t) {
|
|
2934
|
+
var e = this.items[t];
|
|
2935
|
+
if (e.data) {
|
|
2936
|
+
this.itemsDataSize -= e.size, e.data = null, e.alreadyRead = 0;
|
|
2937
|
+
for (var r = 0; r < e.extents.length; r++) {
|
|
2938
|
+
var n = e.extents[r];
|
|
2939
|
+
n.alreadyRead = 0;
|
|
2940
|
+
}
|
|
2941
|
+
return e.size;
|
|
2942
|
+
} else
|
|
2943
|
+
return 0;
|
|
2944
|
+
}, y.prototype.processItems = function(t) {
|
|
2945
|
+
for (var e in this.items) {
|
|
2946
|
+
var r = this.items[e];
|
|
2947
|
+
this.getItem(r.id), t && !r.sent && (t(r), r.sent = !0, r.data = null);
|
|
2948
|
+
}
|
|
2949
|
+
}, y.prototype.hasItem = function(t) {
|
|
2950
|
+
for (var e in this.items) {
|
|
2951
|
+
var r = this.items[e];
|
|
2952
|
+
if (r.name === t)
|
|
2953
|
+
return r.id;
|
|
2954
|
+
}
|
|
2955
|
+
return -1;
|
|
2956
|
+
}, y.prototype.getMetaHandler = function() {
|
|
2957
|
+
return this.meta ? this.meta.hdlr.handler : null;
|
|
2958
|
+
}, y.prototype.getPrimaryItem = function() {
|
|
2959
|
+
return !this.meta || !this.meta.pitm ? null : this.getItem(this.meta.pitm.item_id);
|
|
2960
|
+
}, y.prototype.itemToFragmentedTrackFile = function(t) {
|
|
2961
|
+
var e = t || {}, r = null;
|
|
2962
|
+
if (e.itemId ? r = this.getItem(e.itemId) : r = this.getPrimaryItem(), r == null) return null;
|
|
2963
|
+
var n = new y();
|
|
2964
|
+
n.discardMdatData = !1;
|
|
2965
|
+
var o = { type: r.type, description_boxes: r.properties.boxes };
|
|
2966
|
+
r.properties.ispe && (o.width = r.properties.ispe.image_width, o.height = r.properties.ispe.image_height);
|
|
2967
|
+
var a = n.addTrack(o);
|
|
2968
|
+
return a ? (n.addSample(a, r.data), n) : null;
|
|
2969
|
+
}, y.prototype.write = function(t) {
|
|
2970
|
+
for (var e = 0; e < this.boxes.length; e++)
|
|
2971
|
+
this.boxes[e].write(t);
|
|
2972
|
+
}, y.prototype.createFragment = function(t, e, r) {
|
|
2973
|
+
var n = this.getTrackById(t), o = this.getSample(n, e);
|
|
2974
|
+
if (o == null)
|
|
2975
|
+
return this.setNextSeekPositionFromSample(n.samples[e]), null;
|
|
2976
|
+
var a = r || new d();
|
|
2977
|
+
a.endianness = d.BIG_ENDIAN;
|
|
2978
|
+
var h = this.createSingleSampleMoof(o);
|
|
2979
|
+
h.write(a), h.trafs[0].truns[0].data_offset = h.size + 8, l.debug("MP4Box", "Adjusting data_offset with new value " + h.trafs[0].truns[0].data_offset), a.adjustUint32(h.trafs[0].truns[0].data_offset_position, h.trafs[0].truns[0].data_offset);
|
|
2980
|
+
var f = new s.mdatBox();
|
|
2981
|
+
return f.data = o.data, f.write(a), a;
|
|
2982
|
+
}, y.writeInitializationSegment = function(t, e, r, n) {
|
|
2983
|
+
var o;
|
|
2984
|
+
l.debug("ISOFile", "Generating initialization segment");
|
|
2985
|
+
var a = new d();
|
|
2986
|
+
a.endianness = d.BIG_ENDIAN, t.write(a);
|
|
2987
|
+
var h = e.add("mvex");
|
|
2988
|
+
for (r && h.add("mehd").set("fragment_duration", r), o = 0; o < e.traks.length; o++)
|
|
2989
|
+
h.add("trex").set("track_id", e.traks[o].tkhd.track_id).set("default_sample_description_index", 1).set("default_sample_duration", n).set("default_sample_size", 0).set("default_sample_flags", 65536);
|
|
2990
|
+
return e.write(a), a.buffer;
|
|
2991
|
+
}, y.prototype.save = function(t) {
|
|
2992
|
+
var e = new d();
|
|
2993
|
+
e.endianness = d.BIG_ENDIAN, this.write(e), e.save(t);
|
|
2994
|
+
}, y.prototype.getBuffer = function() {
|
|
2995
|
+
var t = new d();
|
|
2996
|
+
return t.endianness = d.BIG_ENDIAN, this.write(t), t.buffer;
|
|
2997
|
+
}, y.prototype.initializeSegmentation = function() {
|
|
2998
|
+
var t, e, r, n;
|
|
2999
|
+
for (this.onSegment === null && l.warn("MP4Box", "No segmentation callback set!"), this.isFragmentationInitialized || (this.isFragmentationInitialized = !0, this.nextMoofNumber = 0, this.resetTables()), e = [], t = 0; t < this.fragmentedTracks.length; t++) {
|
|
3000
|
+
var o = new s.moovBox();
|
|
3001
|
+
o.mvhd = this.moov.mvhd, o.boxes.push(o.mvhd), r = this.getTrackById(this.fragmentedTracks[t].id), o.boxes.push(r), o.traks.push(r), n = {}, n.id = r.tkhd.track_id, n.user = this.fragmentedTracks[t].user, n.buffer = y.writeInitializationSegment(this.ftyp, o, this.moov.mvex && this.moov.mvex.mehd ? this.moov.mvex.mehd.fragment_duration : void 0, this.moov.traks[t].samples.length > 0 ? this.moov.traks[t].samples[0].duration : 0), e.push(n);
|
|
3002
|
+
}
|
|
3003
|
+
return e;
|
|
3004
|
+
}, s.Box.prototype.printHeader = function(t) {
|
|
3005
|
+
this.size += 8, this.size > b && (this.size += 8), this.type === "uuid" && (this.size += 16), t.log(t.indent + "size:" + this.size), t.log(t.indent + "type:" + this.type);
|
|
3006
|
+
}, s.FullBox.prototype.printHeader = function(t) {
|
|
3007
|
+
this.size += 4, s.Box.prototype.printHeader.call(this, t), t.log(t.indent + "version:" + this.version), t.log(t.indent + "flags:" + this.flags);
|
|
3008
|
+
}, s.Box.prototype.print = function(t) {
|
|
3009
|
+
this.printHeader(t);
|
|
3010
|
+
}, s.ContainerBox.prototype.print = function(t) {
|
|
3011
|
+
this.printHeader(t);
|
|
3012
|
+
for (var e = 0; e < this.boxes.length; e++)
|
|
3013
|
+
if (this.boxes[e]) {
|
|
3014
|
+
var r = t.indent;
|
|
3015
|
+
t.indent += " ", this.boxes[e].print(t), t.indent = r;
|
|
3016
|
+
}
|
|
3017
|
+
}, y.prototype.print = function(t) {
|
|
3018
|
+
t.indent = "";
|
|
3019
|
+
for (var e = 0; e < this.boxes.length; e++)
|
|
3020
|
+
this.boxes[e] && this.boxes[e].print(t);
|
|
3021
|
+
}, s.mvhdBox.prototype.print = function(t) {
|
|
3022
|
+
s.FullBox.prototype.printHeader.call(this, t), t.log(t.indent + "creation_time: " + this.creation_time), t.log(t.indent + "modification_time: " + this.modification_time), t.log(t.indent + "timescale: " + this.timescale), t.log(t.indent + "duration: " + this.duration), t.log(t.indent + "rate: " + this.rate), t.log(t.indent + "volume: " + (this.volume >> 8)), t.log(t.indent + "matrix: " + this.matrix.join(", ")), t.log(t.indent + "next_track_id: " + this.next_track_id);
|
|
3023
|
+
}, s.tkhdBox.prototype.print = function(t) {
|
|
3024
|
+
s.FullBox.prototype.printHeader.call(this, t), t.log(t.indent + "creation_time: " + this.creation_time), t.log(t.indent + "modification_time: " + this.modification_time), t.log(t.indent + "track_id: " + this.track_id), t.log(t.indent + "duration: " + this.duration), t.log(t.indent + "volume: " + (this.volume >> 8)), t.log(t.indent + "matrix: " + this.matrix.join(", ")), t.log(t.indent + "layer: " + this.layer), t.log(t.indent + "alternate_group: " + this.alternate_group), t.log(t.indent + "width: " + this.width), t.log(t.indent + "height: " + this.height);
|
|
3025
|
+
};
|
|
3026
|
+
var $ = {};
|
|
3027
|
+
$.createFile = function(t, e) {
|
|
3028
|
+
var r = t !== void 0 ? t : !0, n = new y(e);
|
|
3029
|
+
return n.discardMdatData = !r, n;
|
|
3030
|
+
}, v.createFile = $.createFile;
|
|
3031
|
+
})(X)), X;
|
|
3032
|
+
}
|
|
3033
|
+
var dt = lt(), ft = /* @__PURE__ */ ht({
|
|
3034
|
+
__proto__: null
|
|
3035
|
+
}, [dt]);
|
|
3036
|
+
const W = ft;
|
|
3037
|
+
typeof globalThis < "u" && W.DataStream && (globalThis.DataStream = W.DataStream);
|
|
3038
|
+
const pt = W.createFile;
|
|
3039
|
+
let D = !1, st = 0, nt = 0, T = null, V = 0, A = null, L = null;
|
|
3040
|
+
const C = [], et = [], it = 3;
|
|
3041
|
+
function H(v) {
|
|
3042
|
+
self.postMessage(v);
|
|
3043
|
+
}
|
|
3044
|
+
function ot(v, l) {
|
|
3045
|
+
H({ type: "error", message: v, code: l });
|
|
3046
|
+
}
|
|
3047
|
+
function rt(v, l) {
|
|
3048
|
+
st = v, nt = l - performance.timeOrigin;
|
|
3049
|
+
}
|
|
3050
|
+
function ut() {
|
|
3051
|
+
const v = performance.now() - nt;
|
|
3052
|
+
return (st * 1e3 + v) * 1e3;
|
|
3053
|
+
}
|
|
3054
|
+
const ct = 5e3, G = class G {
|
|
3055
|
+
constructor() {
|
|
3056
|
+
this.info = null, this.infoResolver = null, this.errorResolver = null, this.loadError = null, this.videoTrack = null, this.audioTrack = null, this.videoSamples = [], this.audioSamples = [], this.videoSampleResolver = null, this.audioSampleResolver = null, this.file = pt(), this.file.onError = (l) => {
|
|
3057
|
+
this.loadError = new Error(l || "Invalid or unsupported media"), this.errorResolver && (this.errorResolver(this.loadError), this.errorResolver = null), this.infoResolver = null;
|
|
3058
|
+
}, this.file.onReady = this.onReady.bind(this), this.file.onSamples = this.onSamples.bind(this);
|
|
3059
|
+
}
|
|
3060
|
+
async loadFromUrl(l) {
|
|
3061
|
+
this.loadError = null, this.info = null;
|
|
3062
|
+
const _ = await fetch(l, {
|
|
3063
|
+
headers: { Range: `bytes=0-${G.STREAM_CHUNK_SIZE - 1}` }
|
|
3064
|
+
});
|
|
3065
|
+
if (_.status === 200 && !_.headers.has("Content-Range")) {
|
|
3066
|
+
await this.loadFromBuffer(await _.arrayBuffer());
|
|
3067
|
+
return;
|
|
3068
|
+
}
|
|
3069
|
+
if (_.status !== 200 && _.status !== 206)
|
|
3070
|
+
throw new Error(`Fetch failed: ${_.status}`);
|
|
3071
|
+
let d = 0;
|
|
3072
|
+
const b = G.STREAM_CHUNK_SIZE;
|
|
3073
|
+
for (; ; ) {
|
|
3074
|
+
const S = d === 0 ? _ : await fetch(l, {
|
|
3075
|
+
headers: { Range: `bytes=${d}-${d + b - 1}` }
|
|
3076
|
+
});
|
|
3077
|
+
if (S.status !== 200 && S.status !== 206)
|
|
3078
|
+
throw new Error(`Fetch failed: ${S.status}`);
|
|
3079
|
+
const B = await S.arrayBuffer();
|
|
3080
|
+
if (B.byteLength === 0) {
|
|
3081
|
+
this.file.flush();
|
|
3082
|
+
break;
|
|
3083
|
+
}
|
|
3084
|
+
const s = B;
|
|
3085
|
+
s.fileStart = d;
|
|
3086
|
+
const R = this.file.appendBuffer(s);
|
|
3087
|
+
if (d = typeof R == "number" ? R : d + B.byteLength, B.byteLength < b) {
|
|
3088
|
+
this.file.flush();
|
|
3089
|
+
break;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
async loadFromBuffer(l) {
|
|
3094
|
+
this.loadError = null, this.info = null;
|
|
3095
|
+
const _ = l;
|
|
3096
|
+
_.fileStart = 0, this.file.appendBuffer(_), this.file.flush();
|
|
3097
|
+
}
|
|
3098
|
+
onReady(l) {
|
|
3099
|
+
this.info = l, this.videoTrack = l.videoTracks[0], this.audioTrack = l.audioTracks[0], this.videoTrack && this.file.setExtractionOptions(this.videoTrack.id, null, { nbSamples: 50 }), this.audioTrack && this.file.setExtractionOptions(this.audioTrack.id, null, { nbSamples: 50 }), this.file.start(), this.infoResolver && (this.infoResolver(l), this.infoResolver = null);
|
|
3100
|
+
}
|
|
3101
|
+
onSamples(l, _, d) {
|
|
3102
|
+
if (this.videoTrack && l === this.videoTrack.id) {
|
|
3103
|
+
if (this.videoSamples.push(...d), this.videoSampleResolver && this.videoSamples.length > 0) {
|
|
3104
|
+
const b = this.videoSamples.shift();
|
|
3105
|
+
b !== void 0 && this.videoSampleResolver(b), this.videoSampleResolver = null;
|
|
3106
|
+
}
|
|
3107
|
+
} else if (this.audioTrack && l === this.audioTrack.id && (this.audioSamples.push(...d), this.audioSampleResolver && this.audioSamples.length > 0)) {
|
|
3108
|
+
const b = this.audioSamples.shift();
|
|
3109
|
+
b !== void 0 && this.audioSampleResolver(b), this.audioSampleResolver = null;
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
async getInfo() {
|
|
3113
|
+
if (this.info) return this.info;
|
|
3114
|
+
if (this.loadError) return Promise.reject(this.loadError);
|
|
3115
|
+
const l = new Promise((d, b) => {
|
|
3116
|
+
setTimeout(
|
|
3117
|
+
() => b(new Error("Invalid or unsupported media")),
|
|
3118
|
+
ct
|
|
3119
|
+
);
|
|
3120
|
+
}), _ = new Promise((d, b) => {
|
|
3121
|
+
this.infoResolver = d, this.errorResolver = b;
|
|
3122
|
+
});
|
|
3123
|
+
return Promise.race([_, l]);
|
|
3124
|
+
}
|
|
3125
|
+
getVideoDecoderConfig() {
|
|
3126
|
+
if (!this.videoTrack) return null;
|
|
3127
|
+
const l = this.videoTrack.codec.startsWith("vp08") ? "vp8" : this.videoTrack.codec, _ = this.getVideoDescription();
|
|
3128
|
+
return {
|
|
3129
|
+
codec: l,
|
|
3130
|
+
codedWidth: this.videoTrack.video.width,
|
|
3131
|
+
codedHeight: this.videoTrack.video.height,
|
|
3132
|
+
..._ && { description: _ }
|
|
3133
|
+
};
|
|
3134
|
+
}
|
|
3135
|
+
getAudioDecoderConfig() {
|
|
3136
|
+
if (!this.audioTrack) return null;
|
|
3137
|
+
const l = this.getAudioDescription();
|
|
3138
|
+
return {
|
|
3139
|
+
codec: this.audioTrack.codec,
|
|
3140
|
+
sampleRate: this.audioTrack.audio.sample_rate,
|
|
3141
|
+
numberOfChannels: this.audioTrack.audio.channel_count,
|
|
3142
|
+
...l && { description: l }
|
|
3143
|
+
};
|
|
3144
|
+
}
|
|
3145
|
+
getVideoDescription() {
|
|
3146
|
+
if (!this.videoTrack) return;
|
|
3147
|
+
const l = this.file.getTrackById(this.videoTrack.id);
|
|
3148
|
+
if (l)
|
|
3149
|
+
for (const _ of l.mdia.minf.stbl.stsd.entries) {
|
|
3150
|
+
const d = _.avcC || _.hvcC || _.vpcC || _.av1C;
|
|
3151
|
+
if (d) {
|
|
3152
|
+
const b = new DataStream(void 0, 0, DataStream.BIG_ENDIAN);
|
|
3153
|
+
return d.write(b), b.buffer.slice(8);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
getAudioDescription() {
|
|
3158
|
+
if (!this.audioTrack) return;
|
|
3159
|
+
const l = this.file.getTrackById(this.audioTrack.id);
|
|
3160
|
+
if (!l) return;
|
|
3161
|
+
const _ = l.mdia.minf.stbl.stsd.entries[0];
|
|
3162
|
+
if (_?.esds?.esd?.descs?.[0]?.descs?.[0]?.data) {
|
|
3163
|
+
const d = _.esds.esd.descs[0].descs[0].data;
|
|
3164
|
+
return d.buffer.slice(d.byteOffset, d.byteOffset + d.byteLength);
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
startVideoExtraction() {
|
|
3168
|
+
this.videoTrack && this.file.start();
|
|
3169
|
+
}
|
|
3170
|
+
startAudioExtraction() {
|
|
3171
|
+
this.audioTrack && this.file.start();
|
|
3172
|
+
}
|
|
3173
|
+
async getNextVideoSample() {
|
|
3174
|
+
return this.videoSamples.length > 0 ? this.videoSamples.shift() ?? null : this.videoTrack ? new Promise((l) => {
|
|
3175
|
+
this.videoSampleResolver = l, this.file.start();
|
|
3176
|
+
}) : null;
|
|
3177
|
+
}
|
|
3178
|
+
async getNextAudioSample() {
|
|
3179
|
+
return this.audioSamples.length > 0 ? this.audioSamples.shift() ?? null : this.audioTrack ? new Promise((l) => {
|
|
3180
|
+
this.audioSampleResolver = l, this.file.start();
|
|
3181
|
+
}) : null;
|
|
3182
|
+
}
|
|
3183
|
+
/** Reset extraction position so next getNextVideoSample() returns from given time (e.g. after seek). */
|
|
3184
|
+
seek(l) {
|
|
3185
|
+
this.file.seek(l, !0);
|
|
3186
|
+
}
|
|
3187
|
+
getMediaInfo() {
|
|
3188
|
+
const l = this.info;
|
|
3189
|
+
if (!l) throw new Error("Demuxer not initialized");
|
|
3190
|
+
const _ = {
|
|
3191
|
+
duration: l.duration / l.timescale,
|
|
3192
|
+
isFragmented: l.isFragmented,
|
|
3193
|
+
brands: l.brands
|
|
3194
|
+
};
|
|
3195
|
+
if (this.videoTrack) {
|
|
3196
|
+
const d = this.videoTrack.nb_samples / (this.videoTrack.duration / this.videoTrack.timescale);
|
|
3197
|
+
_.videoTrack = {
|
|
3198
|
+
codec: this.videoTrack.codec,
|
|
3199
|
+
width: this.videoTrack.video.width,
|
|
3200
|
+
height: this.videoTrack.video.height,
|
|
3201
|
+
frameRate: d,
|
|
3202
|
+
bitrate: this.videoTrack.bitrate
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
return this.audioTrack && (_.audioTrack = {
|
|
3206
|
+
codec: this.audioTrack.codec,
|
|
3207
|
+
sampleRate: this.audioTrack.audio.sample_rate,
|
|
3208
|
+
channelCount: this.audioTrack.audio.channel_count,
|
|
3209
|
+
bitrate: this.audioTrack.bitrate
|
|
3210
|
+
}), _;
|
|
3211
|
+
}
|
|
3212
|
+
hasVideoTrack() {
|
|
3213
|
+
return this.videoTrack !== null;
|
|
3214
|
+
}
|
|
3215
|
+
hasAudioTrack() {
|
|
3216
|
+
return this.audioTrack !== null;
|
|
3217
|
+
}
|
|
3218
|
+
};
|
|
3219
|
+
G.STREAM_CHUNK_SIZE = 256 * 1024;
|
|
3220
|
+
let Z = G;
|
|
3221
|
+
class _t {
|
|
3222
|
+
constructor(l) {
|
|
3223
|
+
this.fillInProgress = !1, this.getNextSample = l, this.decoder = new VideoDecoder({
|
|
3224
|
+
output: (_) => {
|
|
3225
|
+
C.push(_);
|
|
3226
|
+
},
|
|
3227
|
+
error: (_) => {
|
|
3228
|
+
console.error("[VideoDecoder]", _), ot(`Video decode error: ${_.message}`, "DECODE_ERROR");
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
3231
|
+
}
|
|
3232
|
+
async configure(l) {
|
|
3233
|
+
if (!(await VideoDecoder.isConfigSupported(l)).supported)
|
|
3234
|
+
throw new Error(`Video codec not supported: ${l.codec}`);
|
|
3235
|
+
this.decoder.configure(l);
|
|
3236
|
+
}
|
|
3237
|
+
async fillBuffer() {
|
|
3238
|
+
if (!this.fillInProgress) {
|
|
3239
|
+
this.fillInProgress = !0;
|
|
3240
|
+
try {
|
|
3241
|
+
for (; C.length < it && this.decoder.decodeQueueSize < it; ) {
|
|
3242
|
+
const l = await this.getNextSample();
|
|
3243
|
+
if (!l) break;
|
|
3244
|
+
const _ = new EncodedVideoChunk({
|
|
3245
|
+
type: l.is_sync ? "key" : "delta",
|
|
3246
|
+
timestamp: l.cts * 1e6 / l.timescale,
|
|
3247
|
+
duration: l.duration * 1e6 / l.timescale,
|
|
3248
|
+
data: l.data
|
|
3249
|
+
});
|
|
3250
|
+
this.decoder.decode(_);
|
|
3251
|
+
}
|
|
3252
|
+
} catch (l) {
|
|
3253
|
+
console.error("[VideoDecoder] Fill error:", l);
|
|
3254
|
+
}
|
|
3255
|
+
this.fillInProgress = !1;
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
async flush() {
|
|
3259
|
+
this.decoder.state === "configured" && await this.decoder.flush();
|
|
3260
|
+
}
|
|
3261
|
+
close() {
|
|
3262
|
+
this.decoder.state !== "closed" && this.decoder.close();
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
function at() {
|
|
3266
|
+
if (!D) return;
|
|
3267
|
+
const v = ut(), l = v / 1e6;
|
|
3268
|
+
if (V > 0 && l >= V - 1e-3) {
|
|
3269
|
+
D = !1, T !== null && (cancelAnimationFrame(T), T = null), H({ type: "ended" });
|
|
3270
|
+
return;
|
|
3271
|
+
}
|
|
3272
|
+
let _ = null, d = -1, b = Number.MAX_VALUE;
|
|
3273
|
+
for (let S = 0; S < C.length; S++) {
|
|
3274
|
+
const B = Math.abs(v - C[S].timestamp);
|
|
3275
|
+
B < b && (b = B, d = S);
|
|
3276
|
+
}
|
|
3277
|
+
if (d >= 0) {
|
|
3278
|
+
for (let S = 0; S < d; S++)
|
|
3279
|
+
C[S].close();
|
|
3280
|
+
C.splice(0, d), _ = C.shift() || null;
|
|
3281
|
+
}
|
|
3282
|
+
if (_) {
|
|
3283
|
+
const S = {
|
|
3284
|
+
type: "frame-ready",
|
|
3285
|
+
frame: _,
|
|
3286
|
+
timestamp: _.timestamp
|
|
3287
|
+
};
|
|
3288
|
+
H(S);
|
|
3289
|
+
}
|
|
3290
|
+
L?.fillBuffer(), T = requestAnimationFrame(at);
|
|
3291
|
+
}
|
|
3292
|
+
async function yt(v) {
|
|
3293
|
+
switch (v.command) {
|
|
3294
|
+
case "initialize": {
|
|
3295
|
+
try {
|
|
3296
|
+
if (A = new Z(), typeof v.source == "string" ? await A.loadFromUrl(v.source) : await A.loadFromBuffer(v.source), await A.getInfo(), A.hasVideoTrack()) {
|
|
3297
|
+
const S = A.getVideoDecoderConfig();
|
|
3298
|
+
if (S) {
|
|
3299
|
+
const B = A;
|
|
3300
|
+
L = new _t(
|
|
3301
|
+
() => B ? B.getNextVideoSample() : Promise.resolve(null)
|
|
3302
|
+
), await L.configure(S), A.startVideoExtraction(), await L.fillBuffer();
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
let l = null, _;
|
|
3306
|
+
A.hasAudioTrack() && (l = A.getAudioDecoderConfig(), l && A.startAudioExtraction());
|
|
3307
|
+
const d = A.getMediaInfo();
|
|
3308
|
+
V = d.duration;
|
|
3309
|
+
const b = {
|
|
3310
|
+
type: "initialize-done",
|
|
3311
|
+
mediaInfo: d,
|
|
3312
|
+
sampleRate: l?.sampleRate,
|
|
3313
|
+
channelCount: l?.numberOfChannels,
|
|
3314
|
+
sharedArrayBuffer: _
|
|
3315
|
+
};
|
|
3316
|
+
H(b);
|
|
3317
|
+
} catch (l) {
|
|
3318
|
+
ot(l.message, "LOAD_ERROR");
|
|
3319
|
+
}
|
|
3320
|
+
break;
|
|
3321
|
+
}
|
|
3322
|
+
case "play": {
|
|
3323
|
+
D = !0, rt(v.mediaTimeSecs, v.mediaTimeCapturedAtHighResTimestamp), T = requestAnimationFrame(at);
|
|
3324
|
+
break;
|
|
3325
|
+
}
|
|
3326
|
+
case "pause": {
|
|
3327
|
+
D = !1, T !== null && (cancelAnimationFrame(T), T = null);
|
|
3328
|
+
break;
|
|
3329
|
+
}
|
|
3330
|
+
case "update-media-time": {
|
|
3331
|
+
rt(v.mediaTimeSecs, v.mediaTimeCapturedAtHighResTimestamp);
|
|
3332
|
+
break;
|
|
3333
|
+
}
|
|
3334
|
+
case "seek": {
|
|
3335
|
+
A && A.seek(v.time);
|
|
3336
|
+
for (const l of C)
|
|
3337
|
+
l.close();
|
|
3338
|
+
C.length = 0;
|
|
3339
|
+
for (const l of et)
|
|
3340
|
+
l.close();
|
|
3341
|
+
et.length = 0, await L?.flush(), await L?.fillBuffer(), H({ type: "seek-done", time: v.time });
|
|
3342
|
+
break;
|
|
3343
|
+
}
|
|
3344
|
+
case "stop": {
|
|
3345
|
+
D = !1, T !== null && (cancelAnimationFrame(T), T = null);
|
|
3346
|
+
for (const l of C)
|
|
3347
|
+
l.close();
|
|
3348
|
+
C.length = 0;
|
|
3349
|
+
break;
|
|
3350
|
+
}
|
|
3351
|
+
case "destroy": {
|
|
3352
|
+
D = !1, V = 0, T !== null && cancelAnimationFrame(T);
|
|
3353
|
+
for (const l of C)
|
|
3354
|
+
l.close();
|
|
3355
|
+
C.length = 0, L?.close();
|
|
3356
|
+
break;
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
self.addEventListener("message", async (v) => {
|
|
3361
|
+
await yt(v.data);
|
|
3362
|
+
});
|
|
3363
|
+
//# sourceMappingURL=media-worker-DqCztg6H.js.map
|