Skip to content

Commit 331f01c

Browse files
committed
Cleanup docs for MPEG4
1 parent 2ad64ba commit 331f01c

34 files changed

Lines changed: 284 additions & 301 deletions

src/mpeg4/appleTag.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default class AppleTag extends Tag {
2323
private readonly _ilstBox: AppleItemListBox;
2424

2525
/**
26-
* Constructs and initializes a new instance of @see AppleTag for a specified ISO user data box.
27-
* @param box A @see IsoUserDataBox from which the tag is to be read.
26+
* Constructs and initializes a new instance of {@link AppleTag} for a specified ISO user data box.
27+
* @param box A {@link IsoUserDataBox} from which the tag is to be read.
2828
*/
2929
public constructor(box: IsoUserDataBox) {
3030
super();
@@ -505,16 +505,37 @@ export default class AppleTag extends Tag {
505505

506506
// #region Public Methods
507507

508+
/**
509+
* Gets all strings from the iTunes boxes with the given MEAN/NAME combination.
510+
* @param meanString MEAN box contents to look for
511+
* @param nameString NAME box contents to look for
512+
* @returns string[] Text contents of the iTunes boxes with the given NAME/MEAN combination or
513+
* `[]` if there are no matches.
514+
*/
508515
public getItunesStrings(meanString: string, nameString: string): string[] {
516+
// @TODO: You know, MEAN is the same for every known box. Maybe we can just drop it.
509517
return this._ilstBox.getItunesTagDataBoxes(meanString, nameString)
510518
.filter(b => NumberUtils.hasFlag(b.flags, AppleDataBoxFlagType.ContainsText, true))
511519
.map(b => b.text);
512520
}
513521

522+
/**
523+
* Gets the first string from the iTunes boxes with the given MEAN/NAME combination.
524+
* @param meanString MEAN box contents to search for
525+
* @param nameString NAME box contents to search for
526+
* @returns string Text contents of the first iTunes box found with the given MEAN/NAME
527+
* combination or `undefined` if no matches found.
528+
*/
514529
public getFirstItunesString(meanString: string, nameString: string): string {
515530
return this.getItunesStrings(meanString, nameString)[0];
516531
}
517532

533+
/**
534+
* Gets the text contents of all boxes with the given `boxType` inside the tag's ILST box.
535+
* @param boxType Type of box to search for
536+
* @returns string[] Text contents of all boxes with the given `boxType` or `undefined` if no
537+
* matches were found.
538+
*/
518539
public getQuickTimeStrings(boxType: ByteVector): string[] {
519540
return this._ilstBox.getQuickTimeDataBoxes(boxType)
520541
.filter(b => NumberUtils.hasFlag(b.flags, AppleDataBoxFlagType.ContainsText, true))
@@ -529,6 +550,14 @@ export default class AppleTag extends Tag {
529550
}, []);
530551
}
531552

553+
/**
554+
* Gets the raw data of all boxes within this tag's ILST box of the given `boxType`, optionally
555+
* matching the provided `flags
556+
* @param boxType Type of box to search for
557+
* @param flags Optional, box flags to search for. Defaults to
558+
* {@link AppleDataBoxFlagType.ContainsData}
559+
* @returns ByteVector[] Raw contents of the matching boxes, `[]` if no matches are found.
560+
*/
532561
public getQuickTimeData(
533562
boxType: ByteVector,
534563
flags: AppleDataBoxFlagType = AppleDataBoxFlagType.ContainsData
@@ -538,10 +567,25 @@ export default class AppleTag extends Tag {
538567
.map(b => b.data);
539568
}
540569

570+
/**
571+
* Gets the text contents of the first box within this tag's ILST box that matches the provided
572+
* `boxType`.
573+
* @param boxType Type of the box to search for.
574+
* @returns string Text contents of the first matching box. `undefined` if no matches are found
575+
*/
541576
public getFirstQuickTimeString(boxType: ByteVector): string {
542577
return this.getQuickTimeStrings(boxType)[0];
543578
}
544579

580+
/**
581+
* Gets the raw data contents of the first box within this tag's ILST box that matches the
582+
* provided `boxType`, optionally matching `flags` and a predicate.
583+
* @param boxType Type of box to search for
584+
* @param flags Optional flags to match, defaults to {@see AppleDataBoxFlagType.ContainsData}
585+
* @param predicate Optional additional criteria the box must match
586+
* @returns ByteVector Raw data contents of the first matching box. `undefined` if no matches
587+
* are found
588+
*/
545589
public getFirstQuickTimeData(
546590
boxType: ByteVector,
547591
flags: AppleDataBoxFlagType = AppleDataBoxFlagType.ContainsData,
@@ -553,10 +597,26 @@ export default class AppleTag extends Tag {
553597
: data[0];
554598
}
555599

600+
/**
601+
* Stores the provided `dataStrings` in iTunes boxes with the provided MEAN and NAME strings.
602+
* This replaces any existing boxes.
603+
* @param meanString MEAN box contents to set
604+
* @param nameString NAME box contents to set
605+
* @param dataStrings Contents of the iTunes box to store. Use `[]` or `undefined` to clear
606+
* the existing contents and leave empty.
607+
*/
556608
public setItunesStrings(meanString: string, nameString: string, ...dataStrings: string[]): void {
557609
this._ilstBox.setItunesTagBoxes(meanString, nameString, dataStrings);
558610
}
559611

612+
/**
613+
* Stores the provided `data` in boxes with the provided box type. If `flags` are provided, the
614+
* DATA boxes created to store `data` will have the `flags` applied to them. This replaces all
615+
* existing boxes of the given type.
616+
* @param boxType Type of the box to set
617+
* @param data Data to store in the boxes
618+
* @param flags Optional, flags to set on the DATA boxes
619+
*/
560620
public setQuickTimeData(
561621
boxType: ByteVector,
562622
data: ByteVector[],
@@ -566,10 +626,23 @@ export default class AppleTag extends Tag {
566626
this._ilstBox.setQuickTimeBoxes(boxType, dataBoxes);
567627
}
568628

629+
/**
630+
* Stores the provided string in a box with the provided box type. This replaces all boxes of
631+
* the given type with a single box containing the provided data.
632+
* @param boxType Type of box to set
633+
* @param dataString Contents to store in the box
634+
*/
569635
public setQuickTimeString(boxType: ByteVector, dataString: string): void {
570636
this.setQuickTimeStrings(boxType, dataString ? [dataString] : undefined);
571637
}
572638

639+
/**
640+
* Stores the provided strings in boxes with the provided box type. This replaces all boxes of
641+
* the given type with a single box of the given type containing a DATA box for each of the
642+
* provided `dataStrings`.
643+
* @param boxType Type of box to set
644+
* @param dataStrings Contents to store in the box
645+
*/
573646
public setQuickTimeStrings(boxType: ByteVector, dataStrings: string[]): void {
574647
let dataBoxes: AppleDataBox[];
575648
if (!ArrayUtils.isFalsyOrEmpty(dataStrings)) {
@@ -587,6 +660,7 @@ export default class AppleTag extends Tag {
587660

588661
/**
589662
* Detaches the internal "ilst" box from its parent element.
663+
* @internal
590664
*/
591665
public detachIlst(): void {
592666
this._metaBox.removeChildByBox(this._ilstBox);

src/mpeg4/boxes/appleAdditionalInfoBox.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {File} from "../../file";
55
import {Guards, StringUtils} from "../../utils";
66

77
/**
8-
* This class extends @see FullBox to provide an implementation of an Apple AdditionalInfoBox.
8+
* This class extends {@link FullBox} to provide an implementation of an Apple AdditionalInfoBox.
99
*/
1010
export default class AppleAdditionalInfoBox extends FullBox {
1111
/**
@@ -16,13 +16,12 @@ export default class AppleAdditionalInfoBox extends FullBox {
1616
}
1717

1818
/**
19-
* Constructs and initializes a new instance of @see AppleAdditionalInfoBox with a provided header
19+
* Constructs and initializes a new instance of {@link AppleAdditionalInfoBox} with a provided header
2020
* and handler by reading the contents from a specified file.
21-
* @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
22-
* @param file A @see File object to read the contents of the box from.
21+
* @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
22+
* @param file A {@link File} object to read the contents of the box from.
2323
* @param handlerType Type of the handler box object containing the handler that applies to the
2424
* new instance, or undefined if no handler applies.
25-
* @returns A new instance of @see AppleAdditionalInfoBox.
2625
*/
2726
public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): AppleAdditionalInfoBox {
2827
const instance = new AppleAdditionalInfoBox();
@@ -33,11 +32,10 @@ export default class AppleAdditionalInfoBox extends FullBox {
3332
}
3433

3534
/**
36-
* Constructs and initializes a new instance of @see FullBox with a provided header, version, and flags.
37-
* @param type A @see Mpeg4BoxHeader object containing the header to use for the new instance.
35+
* Constructs and initializes a new instance of {@link FullBox} with a provided header, version, and flags.
36+
* @param type A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
3837
* @param version A value containing the version of the new instance.
3938
* @param flags A value containing the flags for the new instance.
40-
* @returns A new instance of @see FullBox.
4139
*/
4240
public static fromTypeVersionAndFlags(type: ByteVector, version: number, flags: number): AppleAdditionalInfoBox {
4341
const instance = new AppleAdditionalInfoBox();

src/mpeg4/boxes/appleAnnotationBox.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mpeg4BoxHeader from "../mpeg4BoxHeader";
33
import {ByteVector} from "../../byteVector";
44

55
/**
6-
* This class extends @see Mpeg4Box to provide an implementation of an Apple AnnotationBox.
6+
* This class extends {@link Mpeg4Box} to provide an implementation of an Apple AnnotationBox.
77
*/
88
export default class AppleAnnotationBox extends Mpeg4Box {
99
/**
@@ -14,12 +14,11 @@ export default class AppleAnnotationBox extends Mpeg4Box {
1414
}
1515

1616
/**
17-
* Constructs and initializes a new instance of @see AppleAnnotationBox with a provided header and
17+
* Constructs and initializes a new instance of {@link AppleAnnotationBox} with a provided header and
1818
* handler by reading the contents from a specified file.
19-
* @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
19+
* @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
2020
* @param handlerType Type of the handler box object containing the handler that applies to the
2121
* new instance, or undefined if no handler applies.
22-
* @returns A new instance of @see AppleAnnotationBox
2322
*/
2423
public static fromHeader(header: Mpeg4BoxHeader, handlerType: ByteVector): AppleAnnotationBox {
2524
const instance = new AppleAnnotationBox();
@@ -29,9 +28,8 @@ export default class AppleAnnotationBox extends Mpeg4Box {
2928
}
3029

3130
/**
32-
* Constructs and initializes a new instance of @see AppleAnnotationBox of specified type with no children.
33-
* @param type A @see ByteVector object containing a 4-byte box type.
34-
* @returns A new instance of @see AppleAnnotationBox
31+
* Constructs and initializes a new instance of {@link AppleAnnotationBox} of specified type with no children.
32+
* @param type A {@link ByteVector} object containing a 4-byte box type.
3533
*/
3634
public static fromType(type: ByteVector): AppleAnnotationBox {
3735
const instance = new AppleAnnotationBox();

src/mpeg4/boxes/appleDataBox.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export enum AppleDataBoxFlagType {
4141
}
4242

4343
/**
44-
* This class extends @see FullBox to provide an implementation of an Apple DataBox.
44+
* This class extends {@link FullBox} to provide an implementation of an Apple DataBox.
4545
*/
4646
export class AppleDataBox extends FullBox {
4747
/**
@@ -52,13 +52,12 @@ export class AppleDataBox extends FullBox {
5252
}
5353

5454
/**
55-
* Constructs and initializes a new instance of @see AppleDataBox with a provided header and handler
55+
* Constructs and initializes a new instance of {@link AppleDataBox} with a provided header and handler
5656
* by reading the contents from a specified file.
57-
* @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
58-
* @param file A @see File object to read the contents of the box from.
57+
* @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
58+
* @param file A {@link File} object to read the contents of the box from.
5959
* @param handlerType Type of the handler box object containing the handler that applies to the
6060
* new instance, or undefined if no handler applies.
61-
* @returns A new instance of @see AppleDataBox
6261
*/
6362
public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): AppleDataBox {
6463
const instance = new AppleDataBox();
@@ -70,10 +69,9 @@ export class AppleDataBox extends FullBox {
7069
}
7170

7271
/**
73-
* Constructs and initializes a new instance of @see AppleDataBox with specified data and flags.
74-
* @param data A @see ByteVector object containing the data to store in the new instance.
72+
* Constructs and initializes a new instance of {@link AppleDataBox} with specified data and flags.
73+
* @param data A {@link ByteVector} object containing the data to store in the new instance.
7574
* @param flags A value containing flags to use for the new instance.
76-
* @returns
7775
*/
7876
public static fromDataAndFlags(data: ByteVector, flags: number): AppleDataBox {
7977
Guards.truthy(data, "data");
@@ -103,6 +101,10 @@ export class AppleDataBox extends FullBox {
103101
this.data = ByteVector.fromString(v, StringType.UTF8);
104102
}
105103

104+
/**
105+
* Renders the headers for the box.
106+
* @returns ByteVector Rendered headers of the current instance
107+
*/
106108
public renderBoxHeaders(): ByteVector[] {
107109
return [
108110
...super.renderBoxHeaders(),

src/mpeg4/boxes/appleElementaryStreamDescriptor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {File} from "../../file";
77
import {NumberUtils} from "../../utils";
88

99
/**
10-
* This class extends @see FullBox to provide an implementation of an Apple ElementaryStreamDescriptor.
11-
* This box may appear as a child of a @see IsoAudioSampleEntry and provided further information about an audio stream.
10+
* This class extends {@link FullBox} to provide an implementation of an Apple ElementaryStreamDescriptor.
11+
* This box may appear as a child of a {@link IsoAudioSampleEntry} and provided further information about an audio stream.
1212
*/
1313
export default class AppleElementaryStreamDescriptor extends FullBox {
1414
private _dependsOnEsId: number;
@@ -36,13 +36,12 @@ export default class AppleElementaryStreamDescriptor extends FullBox {
3636
}
3737

3838
/**
39-
* Constructs and initializes a new instance of @see AppleElementaryStreamDescriptor with a provided
39+
* Constructs and initializes a new instance of {@link AppleElementaryStreamDescriptor} with a provided
4040
* header and handler by reading the contents from a specified file.
41-
* @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
42-
* @param file A @see File object to read the contents of the box from.
41+
* @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
42+
* @param file A {@link File} object to read the contents of the box from.
4343
* @param handlerType Type of the handler box object containing the handler that applies to the
4444
* new instance, or undefined if no handler applies.
45-
* @returns A new instance of @see AppleElementaryStreamDescriptor
4645
*/
4746
public static fromFile(
4847
header: Mpeg4BoxHeader,

0 commit comments

Comments
 (0)