Skip to content

Commit 2ad64ba

Browse files
authored
MPEG4 Cleanup (#88)
* Round one * Round 2 * Fixing up mpeg4box file * Fix names of box types to match style * Fix names of box types to match style * Separate boxes into separate files ... not working yet. * Decomposing handler type to a bytevector. This is clumsy but will be cleaned up shortly * Moving rendering to a utility class. Fixes cyclic dependencies * Adding stuff to index and moving things around to let tests run * Fixing iso handler box that was broken * Public fields to properties * Removing redundant variable typing * Removing redundant casts * Removing child factory from isoAudioSampleEntry.ts * Removing child factory from appleAnnotationBox.ts * Removing child factory from appleItemListBox.ts and isoMetaBox.ts * Removing child factory from isoSampleDescriptionBox.ts * Removing child factory from isoSampleTableBox.ts and isoUserDataBox.ts * Child factories have been outlawed * Introduce a handler type class * Simplify the mpeg4boxtype class * handler types in a different class * Rewrite the get* methods * Some tests * Single itunes tag tests * Performer roles (bug fixed), genres * 99% coverage of appletag * Pretty much the last cleanup I want to do before another release cycle. * Leaving a todo * Ok two more tweaks
1 parent 31554cd commit 2ad64ba

45 files changed

Lines changed: 4582 additions & 4582 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/byteVector.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,26 @@ export enum StringType {
3535
/**
3636
* @summary The string is to be UTF-16LE encoded.
3737
*/
38-
UTF16LE = 4
38+
UTF16LE = 4,
39+
40+
/**
41+
* @summary The string is to be encoded as a hex string for each byte (eg, 0x00, 0x12, 0xAF).
42+
* Intended to be used for debugging purposes, only.
43+
*/
44+
Hex = 5
3945
}
4046

4147
/**
4248
* Wrapper around the `iconv-lite` library to provide string encoding and decoding functionality.
4349
*/
4450
export class Encoding {
51+
private static readonly HEX_ENCODING_KEY = "hex";
4552
private static readonly ENCODINGS = new Map<StringType, Encoding>([
4653
[StringType.Latin1, new Encoding("latin1")],
4754
[StringType.UTF8, new Encoding("utf8")],
4855
[StringType.UTF16BE, new Encoding("utf16-be")],
49-
[StringType.UTF16LE, new Encoding("utf16-le")]
56+
[StringType.UTF16LE, new Encoding("utf16-le")],
57+
[StringType.Hex, new Encoding(Encoding.HEX_ENCODING_KEY)]
5058
]);
5159

5260
/**
@@ -96,6 +104,13 @@ export class Encoding {
96104
}
97105

98106
public decode(data: Uint8Array): string {
107+
if (this._encoding === Encoding.HEX_ENCODING_KEY) {
108+
// Special case for HEX string
109+
return data.reduce<string>((accum: string, currentValue) => {
110+
return accum + `0x${currentValue.toString(16).padStart(2, "0")} `;
111+
}, "");
112+
}
113+
99114
// @TODO: The next version of iconv-lite will add Uint8Array to the types for decode. Until
100115
// then, I have word it should work w/an 'unsafe' cast. See
101116
// https://github.com/ashtuchkin/iconv-lite/issues/293

src/index.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,37 @@ export {default as MpegVideoHeader} from "./mpeg/mpegVideoHeader";
146146
export {default as MpegXingHeader} from "./mpeg/xingHeader";
147147

148148
// MPEG4 ///////////////////////////////////////////////////////////////////
149-
export { default as Mpeg4File } from "./mpeg4/mpeg4File";
149+
export {default as Mpeg4File} from "./mpeg4/mpeg4File";
150+
export {default as Mpeg4AppleTag} from "./mpeg4/appleTag";
151+
152+
// Boxes
153+
export {default as Mpeg4BoxType} from "./mpeg4/mpeg4BoxType";
154+
export {default as Mpeg4AppleAdditionalInfoBox} from "./mpeg4/boxes/appleAdditionalInfoBox";
155+
export {default as Mpeg4AppleAnnotationBox} from "./mpeg4/boxes/appleAnnotationBox";
156+
export {
157+
AppleDataBox as Mpeg4AppleDataBox,
158+
AppleDataBoxFlagType as Mpeg4AppleDataBoxFlagType
159+
} from "./mpeg4/boxes/appleDataBox";
160+
export {default as Mpeg4AppleElementaryStreamDescriptor} from "./mpeg4/boxes/appleElementaryStreamDescriptor";
161+
export {default as Mpeg4AppleItemListBox} from "./mpeg4/boxes/appleItemListBox";
162+
export {default as Mpeg4FullBox} from "./mpeg4/boxes/fullBox";
163+
export {default as Mpeg4IsoAudioSampleEntry} from "./mpeg4/boxes/isoAudioSampleEntry";
164+
export {default as Mpeg4IsoChunkLargeOffset} from "./mpeg4/boxes/isoChunkLargeOffsetBox";
165+
export {default as Mpeg4IsoChunkOffsetBox} from "./mpeg4/boxes/isoChunkOffsetBox";
166+
export {default as Mpeg4IsoFreeSpaceBox} from "./mpeg4/boxes/isoFreeSpaceBox";
167+
export {default as Mpeg4IsoHandlerBox} from "./mpeg4/boxes/isoHandlerBox";
168+
export {default as Mpeg4IsoMetaBox} from "./mpeg4/boxes/isoMetaBox";
169+
export {default as Mpeg4IsoMovieHeaderBox} from "./mpeg4/boxes/isoMovieHeaderBox";
170+
export {default as Mpeg4IsoSampleDescriptionBox} from "./mpeg4/boxes/isoSampleDescriptionBox";
171+
export {default as Mpeg4IsoSampleEntry} from "./mpeg4/boxes/isoSampleEntry";
172+
export {default as Mpeg4IsoSampleTableBox} from "./mpeg4/boxes/isoSampleTableBox";
173+
export {default as Mpeg4IsoUnknownSampleEntry} from "./mpeg4/boxes/isoUnknownSampleEntry";
174+
export {default as Mpeg4IsoUserDataBox} from "./mpeg4/boxes/isoUserDataBox";
175+
export {default as Mpeg4IsoVisualSampleEntry} from "./mpeg4/boxes/isoVisualSampleEntry";
176+
export {default as Mpeg4Box} from "./mpeg4/boxes/mpeg4Box";
177+
export {default as Mpeg4TextBox} from "./mpeg4/boxes/textBox";
178+
export {default as Mpeg4UnknownBox} from "./mpeg4/boxes/unknownBox";
179+
export {default as Mpeg4UrlBox} from "./mpeg4/boxes/urlBox";
150180

151181
// OGG /////////////////////////////////////////////////////////////////////
152182
export {default as OggFile} from "./ogg/oggFile";

src/mpeg4/appleDataBoxFlagType.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)