• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

benrr101 / node-taglib-sharp / 48389652

28 Oct 2023 06:22PM UTC coverage: 92.443% (+0.5%) from 91.9%
48389652

push

appveyor

web-flow
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

3250 of 4147 branches covered (0.0%)

Branch coverage included in aggregate %.

1763 of 1763 new or added lines in 39 files covered. (100.0%)

26757 of 28313 relevant lines covered (94.5%)

422.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.0
/src/mpeg4/boxes/fullBox.ts
1
import Mpeg4Box from "./mpeg4Box";
1✔
2
import Mpeg4BoxHeader from "../mpeg4BoxHeader";
1✔
3
import {ByteVector} from "../../byteVector";
1✔
4
import {File} from "../../file";
5
import {Guards, NumberUtils} from "../../utils";
1✔
6

7
/**
8
 * This class extends @see Mpeg4Box to provide an implementation of a ISO/IEC 14496-12 FullBox.
9
 */
10
export default abstract class FullBox extends Mpeg4Box {
1✔
11
    private _version: number;
12
    private _flags: number;
13

14
    // #region Constructors
15

16
    /**
17
     * Protected constructor to force construction via static functions.
18
     */
19
    protected constructor() {
20
        super();
700✔
21
    }
22

23
    /**
24
     * Initializes a new instance of @see FullBox with a provided header and handler
25
     * by reading the contents from a specified file.
26
     * @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
27
     * @param file A @see File object to read the contents of the box from.
28
     * @param handlerType Type of the handler box object containing the handler that applies to the
29
     *     new instance, or undefined if no handler applies.
30
     */
31
    protected initializeFromHeaderFileAndHandler(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): void {
32
        Guards.truthy(header, "header");
×
33
        Guards.truthy(file, "file");
×
34

35
        this.initializeFromHeader(header, handlerType);
×
36
        const dataPositionBeforeIncrease = this.increaseDataPosition(4);
×
37

38
        file.seek(dataPositionBeforeIncrease);
×
39
        const headerData = file.readBlock(4);
×
40

41
        this._version = headerData.get(0);
×
42
        this._flags = headerData.subarray(1, 3).toUint();
×
43
    }
44

45
    /**
46
     * Initializes a new instance of @see FullBox with a provided header, version, and flags.
47
     * @param type A @see ByteVector object containing the four byte box type.
48
     * @param version A value containing the version of the new instance.
49
     * @param flags A value containing the flags for the new instance.
50
     * @returns A new instance of @see FullBox.
51
     */
52
    protected initializeFromTypeVersionAndFlags(type: ByteVector, version: number, flags: number): void {
53
        Guards.byte(version, "version");
700✔
54
        Guards.byte(flags, "flags");
700✔
55

56
        this.initializeFromHeader(Mpeg4BoxHeader.fromType(type));
700✔
57
        this.increaseDataPosition(4);
700✔
58

59
        this._version = version;
700✔
60
        this._flags = flags;
700✔
61
    }
62

63
    // #endregion
64

65
    /**
66
     * Gets the flags that apply to the current instance.
67
     */
68
    public get flags(): number { return this._flags; }
733✔
69
    /**
70
     * Sets the flags that apply to the current instance.
71
     * @protected
72
     */
73
    protected set flags(value: number) { this._flags = value; }
34✔
74

75
    /**
76
     * Gets the version number of the current instance.
77
     */
78
    public get version(): number { return this._version; }
×
79

80
    /**
81
     * @inheritDoc
82
     * @internal
83
     */
84
    public renderBoxHeaders(): ByteVector[] {
85
        // Generate |<ver>|<    |flags|    >|
86
        const flagsWithVersion = NumberUtils.uintOr(
×
87
            this.flags,
88
            NumberUtils.uintLShift(this.version, 24)
89
        );
90
        return [ByteVector.fromUint(flagsWithVersion)];
×
91
    }
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc