@probityrules/jsmediatags 4.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE.md +36 -0
  3. package/README.md +548 -0
  4. package/build/ArrayBufferFileReader.d.ts +12 -0
  5. package/build/ArrayBufferFileReader.js +27 -0
  6. package/build/ArrayFileReader.d.ts +11 -0
  7. package/build/ArrayFileReader.js +30 -0
  8. package/build/BlobFileReader.d.ts +12 -0
  9. package/build/BlobFileReader.js +47 -0
  10. package/build/ByteArrayUtils.d.ts +9 -0
  11. package/build/ByteArrayUtils.js +46 -0
  12. package/build/ChunkedFileData.d.ts +28 -0
  13. package/build/ChunkedFileData.js +171 -0
  14. package/build/DecodedString.d.ts +6 -0
  15. package/build/DecodedString.js +2 -0
  16. package/build/FLACTagContents.d.ts +19 -0
  17. package/build/FLACTagContents.js +54 -0
  18. package/build/FLACTagReader.d.ts +103 -0
  19. package/build/FLACTagReader.js +320 -0
  20. package/build/ID3v1TagReader.d.ts +10 -0
  21. package/build/ID3v1TagReader.js +176 -0
  22. package/build/ID3v2FrameReader.d.ts +25 -0
  23. package/build/ID3v2FrameReader.js +582 -0
  24. package/build/ID3v2TagContents.d.ts +82 -0
  25. package/build/ID3v2TagContents.js +318 -0
  26. package/build/ID3v2TagReader.d.ts +13 -0
  27. package/build/ID3v2TagReader.js +118 -0
  28. package/build/MP4TagContents.d.ts +17 -0
  29. package/build/MP4TagContents.js +52 -0
  30. package/build/MP4TagReader.d.ts +19 -0
  31. package/build/MP4TagReader.js +291 -0
  32. package/build/MediaFileReader.d.ts +46 -0
  33. package/build/MediaFileReader.js +168 -0
  34. package/build/MediaTagReader.d.ts +18 -0
  35. package/build/MediaTagReader.js +76 -0
  36. package/build/NodeFileReader.d.ts +12 -0
  37. package/build/NodeFileReader.js +103 -0
  38. package/build/ReactNativeFileReader.d.ts +12 -0
  39. package/build/ReactNativeFileReader.js +48 -0
  40. package/build/StringUtils.d.ts +7 -0
  41. package/build/StringUtils.js +102 -0
  42. package/build/XhrFileReader.d.ts +41 -0
  43. package/build/XhrFileReader.js +238 -0
  44. package/build/jsmediatags.d.ts +45 -0
  45. package/build/jsmediatags.js +219 -0
  46. package/build/registerNodeFileReaders.d.ts +5 -0
  47. package/build/registerNodeFileReaders.js +19 -0
  48. package/build/registerNodeFileReaders.noop.d.ts +2 -0
  49. package/build/registerNodeFileReaders.noop.js +3 -0
  50. package/build/types.d.ts +77 -0
  51. package/build/types.js +2 -0
  52. package/dist/jsmediatags.min.js +2 -0
  53. package/package.json +110 -0
@@ -0,0 +1,318 @@
1
+ 'use strict';
2
+ const ByteArrayUtils = require('./ByteArrayUtils');
3
+ const bin = ByteArrayUtils.bin;
4
+ const getSynchsafeInteger32 = ByteArrayUtils.getSynchsafeInteger32;
5
+ const getInteger32 = ByteArrayUtils.getInteger32;
6
+ const getInteger24 = ByteArrayUtils.getInteger24;
7
+ // Offsets
8
+ const FLAGS = 5;
9
+ const SIZE = 6;
10
+ const EXTENDED_HEADER = 10;
11
+ const EXTENDED_FLAGS_V3 = 14;
12
+ const EXTENDED_FLAGS_V4 = 15;
13
+ const START_EXTENDED_DATA_V3 = 20;
14
+ const START_EXTENDED_DATA_V4 = 16;
15
+ // Sizes
16
+ const HEADER_SIZE = 10;
17
+ class ID3v2TagContents {
18
+ constructor(major, revision) {
19
+ if (major < 2 || major > 4) {
20
+ throw new Error('Major version not supported');
21
+ }
22
+ this._major = major;
23
+ this._revision = revision;
24
+ this._contents = [].concat(bin("ID3"), [major, revision], [0], [0, 0, 0, 0]);
25
+ this._frames = {};
26
+ this._updateSize();
27
+ this._extendedHeader = {
28
+ UPDATE: 0,
29
+ CRC: 0,
30
+ RESTRICTIONS: 0,
31
+ };
32
+ }
33
+ toArray() {
34
+ return this._contents.slice(0);
35
+ }
36
+ setFlags(flags) {
37
+ return this._updateFlags(flags, 0);
38
+ }
39
+ _updateFlags(flags, binaryFlags) {
40
+ if (typeof binaryFlags !== 'number') {
41
+ binaryFlags = this._contents[FLAGS] || 0;
42
+ }
43
+ function setOrUnsetBit(shouldSet, bitmap, bit) {
44
+ if (shouldSet) {
45
+ return bitmap |= 1 << bit;
46
+ }
47
+ else {
48
+ return bitmap &= ~(1 << bit);
49
+ }
50
+ }
51
+ if (flags.hasOwnProperty('unsynchronisation')) {
52
+ binaryFlags = setOrUnsetBit(!!flags.unsynchronisation, binaryFlags, 7);
53
+ }
54
+ if (flags.hasOwnProperty('extended_header')) {
55
+ binaryFlags = setOrUnsetBit(!!flags.extended_header, binaryFlags, 6);
56
+ }
57
+ if (flags.hasOwnProperty('experimental_indicator')) {
58
+ binaryFlags = setOrUnsetBit(!!flags.experimental_indicator, binaryFlags, 5);
59
+ }
60
+ if (flags.hasOwnProperty('footer_present')) {
61
+ binaryFlags = setOrUnsetBit(!!flags.footer_present, binaryFlags, 4);
62
+ }
63
+ this._contents[FLAGS] = binaryFlags;
64
+ return this;
65
+ }
66
+ setCrc(crc) {
67
+ if (!this._hasExtendedHeader) {
68
+ this._initExtendedHeader();
69
+ }
70
+ if (this._major === 3) {
71
+ this._setBitAtOffset(EXTENDED_FLAGS_V3, 7);
72
+ this._setData(START_EXTENDED_DATA_V3, crc);
73
+ this._extendedHeader['CRC'] = crc.length;
74
+ // Update extended header size.
75
+ this._setData(EXTENDED_HEADER, getInteger32(10));
76
+ }
77
+ else if (this._major === 4) {
78
+ this._setBitAtOffset(EXTENDED_FLAGS_V4, 5);
79
+ this._addExtendedHeaderData('CRC', crc);
80
+ }
81
+ this._updateSize();
82
+ return this;
83
+ }
84
+ setTagIsUpdate() {
85
+ if (!this._hasExtendedHeader) {
86
+ this._initExtendedHeader();
87
+ }
88
+ if (this._major === 4) {
89
+ this._setBitAtOffset(EXTENDED_FLAGS_V4, 6);
90
+ }
91
+ this._updateSize();
92
+ return this;
93
+ }
94
+ /**
95
+ * For some applications it might be desired to restrict a tag in more
96
+ * ways than imposed by the ID3v2 specification. Note that the
97
+ * presence of these restrictions does not affect how the tag is
98
+ * decoded, merely how it was restricted before encoding. If this flag
99
+ * is set the tag is restricted as follows:
100
+ *
101
+ * Flag data length $01
102
+ * Restrictions %ppqrrstt
103
+ *
104
+ * p - Tag size restrictions
105
+
106
+ * 00 No more than 128 frames and 1 MB total tag size.
107
+ * 01 No more than 64 frames and 128 KB total tag size.
108
+ * 10 No more than 32 frames and 40 KB total tag size.
109
+ * 11 No more than 32 frames and 4 KB total tag size.
110
+ *
111
+ * q - Text encoding restrictions
112
+ *
113
+ * 0 No restrictions
114
+ * 1 Strings are only encoded with ISO-8859-1 [ISO-8859-1] or
115
+ * UTF-8 [UTF-8].
116
+ *
117
+ * r - Text fields size restrictions
118
+ *
119
+ * 00 No restrictions
120
+ * 01 No string is longer than 1024 characters.
121
+ * 10 No string is longer than 128 characters.
122
+ * 11 No string is longer than 30 characters.
123
+ *
124
+ * Note that nothing is said about how many bytes is used to
125
+ * represent those characters, since it is encoding dependent. If a
126
+ * text frame consists of more than one string, the sum of the
127
+ * strungs is restricted as stated.
128
+ *
129
+ * s - Image encoding restrictions
130
+ *
131
+ * 0 No restrictions
132
+ * 1 Images are encoded only with PNG [PNG] or JPEG [JFIF].
133
+ *
134
+ * t - Image size restrictions
135
+ *
136
+ * 00 No restrictions
137
+ * 01 All images are 256x256 pixels or smaller.
138
+ * 10 All images are 64x64 pixels or smaller.
139
+ * 11 All images are exactly 64x64 pixels, unless required
140
+ * otherwise.
141
+ */
142
+ setTagRestrictions(size, textEncoding, textSize, imageEncoding, imageSize) {
143
+ if (!this._hasExtendedHeader) {
144
+ this._initExtendedHeader();
145
+ }
146
+ if (this._major === 4) {
147
+ this._setBitAtOffset(EXTENDED_FLAGS_V4, 4);
148
+ // 0x03 = 0b11
149
+ this._addExtendedHeaderData('RESTRICTIONS', [
150
+ (size & 0x3) << 6 |
151
+ (textEncoding & 0x1) << 5 |
152
+ (textSize & 0x3) << 3 |
153
+ (imageEncoding & 0x1) << 2 |
154
+ (imageSize & 0x3) << 1
155
+ ]);
156
+ }
157
+ this._updateSize();
158
+ return this;
159
+ }
160
+ /**
161
+ * noFlagsDataLength - The data length if all flags were set to 0,
162
+ * for instance, the length before compression and unsynchronisation.
163
+ * This field is only needed when data_length_indicator flag is set.
164
+ */
165
+ addFrame(id, data, flags, noFlagsDataLength) {
166
+ var _a, _b;
167
+ var size = 0;
168
+ var frameFlags = [0, 0];
169
+ if (flags) {
170
+ flags.message = (_a = flags.message) !== null && _a !== void 0 ? _a : {
171
+ tag_alter_preservation: false,
172
+ file_alter_preservation: false,
173
+ read_only: false,
174
+ };
175
+ flags.format = (_b = flags.format) !== null && _b !== void 0 ? _b : {
176
+ grouping_identity: false,
177
+ compression: false,
178
+ encryption: false,
179
+ unsynchronisation: false,
180
+ data_length_indicator: false,
181
+ };
182
+ }
183
+ data = data || [];
184
+ var dataLength = data.length;
185
+ var isTagUnsynchronised = this._contents[FLAGS] & (1 << 7);
186
+ if (isTagUnsynchronised) {
187
+ var unsynchronisedByteCount = 0;
188
+ for (var i = 0; i < data.length - 1; i++) {
189
+ if (data[i] === 0xff && data[i + 1] === 0x00) {
190
+ unsynchronisedByteCount++;
191
+ }
192
+ }
193
+ dataLength -= unsynchronisedByteCount;
194
+ }
195
+ if (this._major === 2) {
196
+ size = getInteger24(dataLength);
197
+ }
198
+ else if (this._major === 3) {
199
+ size = getInteger32(dataLength);
200
+ if (flags) {
201
+ frameFlags[0] |= (flags.message.tag_alter_preservation ? 1 : 0) << 7;
202
+ frameFlags[0] |= (flags.message.file_alter_preservation ? 1 : 0) << 6;
203
+ frameFlags[0] |= (flags.message.read_only ? 1 : 0) << 5;
204
+ frameFlags[1] |= (flags.format.compression ? 1 : 0) << 7;
205
+ frameFlags[1] |= (flags.format.encryption ? 1 : 0) << 6;
206
+ frameFlags[1] |= (flags.format.grouping_identity ? 1 : 0) << 5;
207
+ }
208
+ }
209
+ else if (this._major === 4) {
210
+ if (flags) {
211
+ frameFlags[0] |= (flags.message.tag_alter_preservation ? 1 : 0) << 6;
212
+ frameFlags[0] |= (flags.message.file_alter_preservation ? 1 : 0) << 5;
213
+ frameFlags[0] |= (flags.message.read_only ? 1 : 0) << 4;
214
+ frameFlags[1] |= (flags.format.grouping_identity ? 1 : 0) << 6;
215
+ frameFlags[1] |= (flags.format.compression ? 1 : 0) << 3;
216
+ frameFlags[1] |= (flags.format.encryption ? 1 : 0) << 2;
217
+ frameFlags[1] |= (flags.format.unsynchronisation ? 1 : 0) << 1;
218
+ frameFlags[1] |= flags.format.data_length_indicator ? 1 : 0;
219
+ if (flags.format.data_length_indicator) {
220
+ dataLength += 4;
221
+ }
222
+ }
223
+ size = getSynchsafeInteger32(dataLength);
224
+ }
225
+ else {
226
+ throw Error("Major version not supported");
227
+ }
228
+ var frame = [].concat(bin(id), size, frameFlags, flags && flags.format.data_length_indicator && noFlagsDataLength
229
+ ? getSynchsafeInteger32(noFlagsDataLength)
230
+ : [], data);
231
+ if (!this._frames[id]) {
232
+ this._frames[id] = [];
233
+ }
234
+ this._frames[id].push(frame);
235
+ this._addData(this._nextFrameOffset, frame);
236
+ this._updateSize();
237
+ return this;
238
+ }
239
+ _addExtendedHeaderData(tagKey, tagData) {
240
+ var offset = START_EXTENDED_DATA_V4;
241
+ // Each flag that is set in the extended header has data attached, which
242
+ // comes in the order in which the flags are encountered (i.e. the data
243
+ // for flag 'b' comes before the data for flag 'c').
244
+ // _extendedHeader keeps track of which tag data we have by storing the
245
+ // size of the data. To know where to add a particular tag data we just need
246
+ // to sum all the data lengths of the tags that come before this tagKey
247
+ // because the keys in the map are in order.
248
+ for (var key in this._extendedHeader) {
249
+ if (this._extendedHeader.hasOwnProperty(key)) {
250
+ if (key === tagKey) {
251
+ break;
252
+ }
253
+ else {
254
+ offset += this._extendedHeader[key];
255
+ }
256
+ }
257
+ }
258
+ var data = [].concat([tagData.length], tagData);
259
+ this._extendedHeader[tagKey] = data.length;
260
+ this._addData(offset, data);
261
+ }
262
+ _initExtendedHeader() {
263
+ this._hasExtendedHeader = true;
264
+ this._updateFlags({ extended_header: true });
265
+ if (this._major === 3) {
266
+ this._addData(EXTENDED_HEADER, [
267
+ 0, 0, 0, 6, // size
268
+ 0, 0, // flags
269
+ 0, 0, 0, 0 // padding
270
+ ]);
271
+ }
272
+ else if (this._major === 4) {
273
+ this._addData(EXTENDED_HEADER, [].concat(getSynchsafeInteger32(6), [1], [0]));
274
+ }
275
+ else {
276
+ throw new Error("Version doesn't support extended header.");
277
+ }
278
+ }
279
+ _updateSize() {
280
+ // Header (10 bytes) is not included in the size.
281
+ var size = 0;
282
+ if (this._hasExtendedHeader) {
283
+ // Extended header size
284
+ size += this._major === 4 ? 6 : 10;
285
+ // Extended header data size
286
+ for (var key in this._extendedHeader) {
287
+ if (this._extendedHeader.hasOwnProperty(key)) {
288
+ size += this._extendedHeader[key];
289
+ }
290
+ }
291
+ }
292
+ for (var frameId in this._frames) {
293
+ if (this._frames.hasOwnProperty(frameId)) {
294
+ for (var i = 0, frame; frame = this._frames[frameId][i]; i++) {
295
+ size += frame.length;
296
+ }
297
+ }
298
+ }
299
+ this._nextFrameOffset = size + HEADER_SIZE;
300
+ this._size = size;
301
+ this._setData(SIZE, getSynchsafeInteger32(size));
302
+ }
303
+ _setBitAtOffset(offset, bit) {
304
+ var data = this._getData(offset, 1);
305
+ data[0] |= 1 << bit;
306
+ this._setData(offset, data);
307
+ }
308
+ _getData(offset, length) {
309
+ return this._contents.slice(offset, offset + length);
310
+ }
311
+ _setData(offset, data) {
312
+ this._contents.splice(offset, data.length, ...data);
313
+ }
314
+ _addData(offset, data) {
315
+ this._contents.splice(offset, 0, ...data);
316
+ }
317
+ }
318
+ module.exports = ID3v2TagContents;
@@ -0,0 +1,13 @@
1
+ declare const MediaTagReader: any;
2
+ declare const MediaFileReader: any;
3
+ import type { TagFrames, ByteRange, TagType } from "./types";
4
+ import type { LoadCallbackType } from "./types";
5
+ declare class ID3v2TagReader extends MediaTagReader {
6
+ static getTagIdentifierByteRange(): ByteRange;
7
+ static canReadTagFormat(tagIdentifier: Array<number>): boolean;
8
+ _loadData(mediaFileReader: InstanceType<typeof MediaFileReader>, callbacks: LoadCallbackType): void;
9
+ _parseData(data: InstanceType<typeof MediaFileReader>, tags: string[] | null): TagType;
10
+ _getFrameData(frames: TagFrames, ids: string[]): unknown;
11
+ getShortcuts(): Record<string, string | string[]>;
12
+ }
13
+ export = ID3v2TagReader;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ const MediaTagReader = require("./MediaTagReader");
3
+ const MediaFileReader = require("./MediaFileReader");
4
+ const ID3v2FrameReader = require("./ID3v2FrameReader");
5
+ const ID3_HEADER_SIZE = 10;
6
+ class ID3v2TagReader extends MediaTagReader {
7
+ static getTagIdentifierByteRange() {
8
+ return {
9
+ offset: 0,
10
+ length: ID3_HEADER_SIZE,
11
+ };
12
+ }
13
+ static canReadTagFormat(tagIdentifier) {
14
+ const id = String.fromCharCode.apply(String, tagIdentifier.slice(0, 3));
15
+ return id === "ID3";
16
+ }
17
+ _loadData(mediaFileReader, callbacks) {
18
+ mediaFileReader.loadRange([6, 9], {
19
+ onSuccess: function () {
20
+ mediaFileReader.loadRange([
21
+ 0,
22
+ ID3_HEADER_SIZE + mediaFileReader.getSynchsafeInteger32At(6) - 1,
23
+ ], callbacks);
24
+ },
25
+ onError: callbacks.onError,
26
+ });
27
+ }
28
+ _parseData(data, tags) {
29
+ let offset = 0;
30
+ const major = data.getByteAt(offset + 3);
31
+ if (major > 4) {
32
+ return { type: "ID3", tags: { version: ">2.4" } };
33
+ }
34
+ const revision = data.getByteAt(offset + 4);
35
+ const unsynch = data.isBitSetAt(offset + 5, 7);
36
+ const xheader = data.isBitSetAt(offset + 5, 6);
37
+ const xindicator = data.isBitSetAt(offset + 5, 5);
38
+ const size = data.getSynchsafeInteger32At(offset + 6);
39
+ offset += 10;
40
+ if (xheader) {
41
+ if (major === 4) {
42
+ const xheadersize = data.getSynchsafeInteger32At(offset);
43
+ offset += xheadersize;
44
+ }
45
+ else {
46
+ const xheadersize = data.getLongAt(offset, true);
47
+ offset += xheadersize + 4;
48
+ }
49
+ }
50
+ const id3 = {
51
+ type: "ID3",
52
+ version: "2." + major + "." + revision,
53
+ major: major,
54
+ revision: revision,
55
+ flags: {
56
+ unsynchronisation: unsynch,
57
+ extended_header: xheader,
58
+ experimental_indicator: xindicator,
59
+ footer_present: false,
60
+ },
61
+ size: size,
62
+ tags: {},
63
+ };
64
+ let expandedTags;
65
+ if (tags) {
66
+ expandedTags = this._expandShortcutTags(tags);
67
+ }
68
+ let offsetEnd = size + 10;
69
+ let reader = data;
70
+ if (id3.flags.unsynchronisation) {
71
+ reader = ID3v2FrameReader.getUnsyncFileReader(reader, offset, size);
72
+ offset = 0;
73
+ offsetEnd = reader.getSize();
74
+ }
75
+ const frames = ID3v2FrameReader.readFrames(offset, offsetEnd, reader, id3, expandedTags !== null && expandedTags !== void 0 ? expandedTags : undefined);
76
+ for (const name in SHORTCUTS) {
77
+ if (SHORTCUTS.hasOwnProperty(name)) {
78
+ const frameData = this._getFrameData(frames, SHORTCUTS[name]);
79
+ if (frameData) {
80
+ id3.tags[name] = frameData;
81
+ }
82
+ }
83
+ }
84
+ for (const frame in frames) {
85
+ if (frames.hasOwnProperty(frame)) {
86
+ id3.tags[frame] = frames[frame];
87
+ }
88
+ }
89
+ return id3;
90
+ }
91
+ _getFrameData(frames, ids) {
92
+ let frame;
93
+ for (let i = 0, id; (id = ids[i]); i++) {
94
+ if (id in frames) {
95
+ frame = frames[id];
96
+ if (Array.isArray(frame)) {
97
+ frame = frame[0];
98
+ }
99
+ return frame.data;
100
+ }
101
+ }
102
+ }
103
+ getShortcuts() {
104
+ return SHORTCUTS;
105
+ }
106
+ }
107
+ const SHORTCUTS = {
108
+ title: ["TIT2", "TT2"],
109
+ artist: ["TPE1", "TP1"],
110
+ album: ["TALB", "TAL"],
111
+ year: ["TYER", "TYE"],
112
+ comment: ["COMM", "COM"],
113
+ track: ["TRCK", "TRK"],
114
+ genre: ["TCON", "TCO"],
115
+ picture: ["APIC", "PIC"],
116
+ lyrics: ["USLT", "ULT"],
117
+ };
118
+ module.exports = ID3v2TagReader;
@@ -0,0 +1,17 @@
1
+ import type { ByteArray } from './types';
2
+ declare class MP4TagContents {
3
+ _atoms: Array<Atom>;
4
+ constructor(ftyp: string, atoms?: Array<Atom>);
5
+ toArray(): ByteArray;
6
+ static createAtom(atomName: string): Atom;
7
+ static createContainerAtom(atomName: string, atoms: Array<Atom>, data?: ByteArray): Atom;
8
+ static createMetadataAtom(atomName: string, type: string, data: ByteArray): Atom;
9
+ }
10
+ declare class Atom {
11
+ _name: string;
12
+ _data: Array<number>;
13
+ _atoms: Array<Atom>;
14
+ constructor(name: string, data?: ByteArray | null, atoms?: Array<Atom> | null);
15
+ toArray(): ByteArray;
16
+ }
17
+ export = MP4TagContents;
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+ const ByteArrayUtils = require('./ByteArrayUtils');
3
+ const bin = ByteArrayUtils.bin;
4
+ const pad = ByteArrayUtils.pad;
5
+ const getInteger32 = ByteArrayUtils.getInteger32;
6
+ class MP4TagContents {
7
+ constructor(ftyp, atoms) {
8
+ this._atoms = [
9
+ new Atom("ftyp", pad(bin(ftyp), 24))
10
+ ].concat(atoms || []);
11
+ }
12
+ toArray() {
13
+ return this._atoms.reduce(function (array, atom) {
14
+ return array.concat(atom.toArray());
15
+ }, []);
16
+ }
17
+ static createAtom(atomName) {
18
+ return new Atom(atomName);
19
+ }
20
+ static createContainerAtom(atomName, atoms, data) {
21
+ return new Atom(atomName, data !== null && data !== void 0 ? data : null, atoms !== null && atoms !== void 0 ? atoms : null);
22
+ }
23
+ static createMetadataAtom(atomName, type, data) {
24
+ var _a;
25
+ const klassMap = {
26
+ uint8: 0,
27
+ uint8b: 21,
28
+ text: 1,
29
+ jpeg: 13,
30
+ png: 14,
31
+ };
32
+ var klass = (_a = klassMap[type]) !== null && _a !== void 0 ? _a : 0;
33
+ return this.createContainerAtom(atomName, [
34
+ new Atom("data", [].concat([0x00, 0x00, 0x00, klass], [0x00, 0x00, 0x00, 0x00], data)),
35
+ ]);
36
+ }
37
+ }
38
+ class Atom {
39
+ constructor(name, data, atoms) {
40
+ this._name = name;
41
+ this._data = data || [];
42
+ this._atoms = atoms || [];
43
+ }
44
+ toArray() {
45
+ var atomsArray = this._atoms.reduce(function (array, atom) {
46
+ return array.concat(atom.toArray());
47
+ }, []);
48
+ var length = 4 + this._name.length + this._data.length + atomsArray.length;
49
+ return [].concat(getInteger32(length), bin(this._name), this._data, atomsArray);
50
+ }
51
+ }
52
+ module.exports = MP4TagContents;
@@ -0,0 +1,19 @@
1
+ declare const MediaTagReader: any;
2
+ declare const MediaFileReader: any;
3
+ import type { LoadCallbackType, ByteRange, TagType, TagFrame } from './types';
4
+ type MediaReader = InstanceType<typeof MediaFileReader>;
5
+ declare class MP4TagReader extends MediaTagReader {
6
+ static getTagIdentifierByteRange(): ByteRange;
7
+ static canReadTagFormat(tagIdentifier: Array<number>): boolean;
8
+ _loadData(mediaFileReader: MediaReader, callbacks: LoadCallbackType): void;
9
+ _loadAtom(mediaFileReader: MediaReader, offset: number, parentAtomFullName: string, callbacks: LoadCallbackType): void;
10
+ _isContainerAtom(atomName: string): boolean;
11
+ _canReadAtom(atomName: string): boolean;
12
+ _parseData(data: MediaReader, tagsToRead: Array<string> | null): TagType;
13
+ _readAtom(tags: Record<string, unknown>, data: MediaReader, offset: number, length: number, tagsToRead: Array<string> | null, parentAtomFullName?: string, indent?: string): void;
14
+ _readMetadataAtom(data: MediaReader, offset: number): TagFrame;
15
+ getShortcuts(): {
16
+ [key: string]: string | Array<string>;
17
+ };
18
+ }
19
+ export = MP4TagReader;