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

benrr101 / node-taglib-sharp / 48393127

29 Oct 2023 04:39AM UTC coverage: 92.535% (-1.4%) from 93.934%
48393127

push

appveyor

benrr101
Merge branch 'release/v5.2.0'

3244 of 4129 branches covered (0.0%)

Branch coverage included in aggregate %.

2177 of 2177 new or added lines in 61 files covered. (100.0%)

26728 of 28261 relevant lines covered (94.58%)

423.2 hits per line

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

42.42
/src/mpeg4/boxes/isoHandlerBox.ts
1
import FullBox from "./fullBox";
1✔
2
import Mpeg4BoxHeader from "../mpeg4BoxHeader";
3
import Mpeg4BoxType from "../mpeg4BoxType";
1✔
4
import {ByteVector, StringType} from "../../byteVector";
1✔
5
import {File} from "../../file";
6
import {Guards} from "../../utils";
1✔
7

8
/**
9
 * This class extends {@link FullBox} to provide an implementation of a ISO/IEC 14496-12 FullBox.
10
 */
11
export default class IsoHandlerBox extends FullBox {
1✔
12
    private _dataHandlerType: ByteVector;
13
    private _name: string;
14

15
    // #region Constructors
16

17
    /**
18
     * Private constructor to force construction via static functions.
19
     */
20
    private constructor() {
21
        super();
113✔
22
    }
23

24
    /**
25
     * Constructs and initializes a new instance of {@link IsoHandlerBox} with a provided header and h
26
     * handler by reading the contents from a specified file.
27
     * @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
28
     * @param file A {@link File} object to read the contents of the box from.
29
     * @param handlerType Type of the handler box object containing the handler that applies to the
30
     *     new instance, or undefined if no handler applies.
31
     */
32
    public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): IsoHandlerBox {
33
                const instance = new IsoHandlerBox();
×
34
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
35

36
        file.seek(instance.dataPosition + 4);
×
37
        const boxData = file.readBlock(instance.dataSize - 4);
×
38
        instance._dataHandlerType = boxData.subarray(0, 4);
×
39

40
        let end = boxData.offsetFind(ByteVector.fromByte(0), 16);
×
41
        if (end < 16) {
×
42
            end = boxData.length;
×
43
        }
44

45
        instance._name = end > 16
×
46
            ? boxData.subarray(16, end - 16).toString(StringType.UTF8)
×
47
            : "";
48

49
        return instance;
×
50
    }
51

52
    /**
53
     * Constructs and initializes a new instance of {@link IsoHandlerBox} with a specified type and name.
54
     * @param handlerType A {@link ByteVector} object specifying a 4 byte handler type.
55
     * @param name An object specifying the handler name.
56
     */
57
    public static fromHandlerTypeAndHandlerName(handlerType: ByteVector, name: string): IsoHandlerBox {
58
        Guards.truthy(handlerType, "handlerType");
113✔
59
        if (handlerType.length < 4) {
113!
60
            throw new Error("The handler type must be four bytes long.");
×
61
        }
62

63
        const instance = new IsoHandlerBox();
113✔
64
        instance.initializeFromTypeVersionAndFlags(Mpeg4BoxType.HDLR, 0, 0);
113✔
65
        instance._dataHandlerType = handlerType.subarray(0, 4);
113✔
66
        instance._name = name;
113✔
67

68
        return instance;
113✔
69
    }
70

71
    // #endregion
72

73
    /**
74
     * Gets the data contained in the current instance.
75
     */
76
    public get data(): ByteVector {
77
        return ByteVector.concatenate(
×
78
            ByteVector.fromSize(4),
79
            this.dataHandlerType,
80
            ByteVector.fromSize(12),
81
            ByteVector.fromString(this.name, StringType.UTF8),
82
            ByteVector.fromSize(2)
83
        );
84
    }
85

86
    /**
87
     * Gets the handler type as described in the data of the current instance.
88
     */
89
    public get dataHandlerType(): ByteVector { return this._dataHandlerType; }
×
90

91
    /**
92
     * Gets the name of the current instance.
93
     */
94
    public get name(): string { return this._name; }
×
95
}
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