jmuxer 2.0.7 → 2.1.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/src/util/nalu.js DELETED
@@ -1,72 +0,0 @@
1
- export class NALU {
2
- static get NDR() { return 1; }
3
- static get IDR() { return 5; }
4
- static get SEI() { return 6; }
5
- static get SPS() { return 7; }
6
- static get PPS() { return 8; }
7
- static get AUD() { return 9; }
8
-
9
- static get TYPES() {
10
- return {
11
- [NALU.IDR]: 'IDR',
12
- [NALU.SEI]: 'SEI',
13
- [NALU.SPS]: 'SPS',
14
- [NALU.PPS]: 'PPS',
15
- [NALU.NDR]: 'NDR',
16
- [NALU.AUD]: 'AUD',
17
- };
18
- }
19
-
20
- static type(nalu) {
21
- if (nalu.ntype in NALU.TYPES) {
22
- return NALU.TYPES[nalu.ntype];
23
- } else {
24
- return 'UNKNOWN';
25
- }
26
- }
27
-
28
- constructor(data) {
29
- this.payload = data;
30
- this.nri = (this.payload[0] & 0x60) >> 5; // nal_ref_idc
31
- this.ntype = this.payload[0] & 0x1f;
32
- this.isvcl = this.ntype == 1 || this.ntype == 5;
33
- this.stype = ''; // slice_type
34
- this.isfmb = false; // first_mb_in_slice
35
- }
36
-
37
- toString() {
38
- return `${NALU.type(this)}: NRI: ${this.getNri()}`;
39
- }
40
-
41
- getNri() {
42
- return this.nri;
43
- }
44
-
45
- type() {
46
- return this.ntype;
47
- }
48
-
49
- isKeyframe() {
50
- return this.ntype === NALU.IDR;
51
- }
52
-
53
- getPayload() {
54
- return this.payload;
55
- }
56
-
57
- getPayloadSize() {
58
- return this.payload.byteLength;
59
- }
60
-
61
- getSize() {
62
- return 4 + this.getPayloadSize();
63
- }
64
-
65
- getData() {
66
- const result = new Uint8Array(this.getSize());
67
- const view = new DataView(result.buffer);
68
- view.setUint32(0, this.getSize() - 4);
69
- result.set(this.getPayload(), 4);
70
- return result;
71
- }
72
- }