• 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

2.86
/src/mpeg4/boxes/isoMovieHeaderBox.ts
1
import FullBox from "./fullBox";
1✔
2
import Mpeg4BoxHeader from "../mpeg4BoxHeader";
3
import {ByteVector} from "../../byteVector";
4
import {File} from "../../file";
5

6
/**
7
 * This class extends {@link FullBox} to provide an implementation of a ISO/IEC 14496-12 MovieHeaderBox.
8
 */
9
export default class IsoMovieHeaderBox extends FullBox {
1✔
10
    private _nextTrackId: number;
11
    private _creationTime: number;
12
    private _modificationTime: number;
13
    private _durationInMilliseconds: number;
14
    private _rate: number;
15
    private _volume: number;
16
    /**
17
     * Private constructor to force construction via static functions.
18
     */
19
    private constructor() {
20
        super();
×
21
    }
22

23
    /**
24
     * Constructs and initializes a new instance of {@link IsoMovieHeaderBox} with a provided header and
25
     * handler by reading the contents from a specified file.
26
     * @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
27
     * @param file A {@link 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
    public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): IsoMovieHeaderBox {
32
        const instance = new IsoMovieHeaderBox();
×
33
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
34

35
        let bytesRemaining = instance.dataSize;
×
36
        let data: ByteVector;
37

38
        if (instance.version === 1) {
×
39
            // Read version one (large integers).
40
            data = file.readBlock(Math.min(28, bytesRemaining));
×
41

42
            if (data.length >= 8) {
×
43
                instance._creationTime = Number(data.subarray(0, 8).toUlong());
×
44
            }
45

46
            if (data.length >= 16) {
×
47
                instance._modificationTime = Number(data.subarray(8, 8).toUlong());
×
48
            }
49

50
            const timescale = data.length >= 20
×
51
                ? data.subarray(16, 4).toUint()
×
52
                : 0;
53

54
            let duration = 0;
×
55
            if (data.length >= 28) {
×
56
                duration = Number(data.subarray(20, 8).toUlong());
×
57
                instance._durationInMilliseconds = (duration / timescale) * 1000;
×
58
            }
59

60
            bytesRemaining -= 28;
×
61
        } else {
62
            // Read version zero (normal integers).
63
            data = file.readBlock(Math.min(16, bytesRemaining));
×
64

65
            if (data.length >= 4) {
×
66
                instance._creationTime = data.subarray(0, 4).toUint();
×
67
            }
68

69
            if (data.length >= 8) {
×
70
                instance._modificationTime = data.subarray(4, 4).toUint();
×
71
            }
72

73
            const timescale = data.length >= 12
×
74
                ? data.subarray(8, 4).toUint()
×
75
                : 0;
76

77
            let duration = 0;
×
78
            if (data.length >= 16) {
×
79
                duration = data.subarray(12, 4).toUint();
×
80
                instance._durationInMilliseconds = (duration / timescale) * 1000;
×
81
            }
82

83
            bytesRemaining -= 16;
×
84
        }
85

86
        data = file.readBlock(Math.min(6, bytesRemaining));
×
87

88
        if (data.length >= 4) {
×
89
            instance._rate = data.subarray(0, 4).toUint() / 0x10000;
×
90
        }
91

92
        if (data.length >= 6) {
×
93
            instance._volume = data.subarray(4, 2).toUshort() / 0x100;
×
94
        }
95

96
        file.seek(file.position + 70);
×
97
        bytesRemaining -= 76;
×
98

99
        data = file.readBlock(Math.min(4, bytesRemaining));
×
100

101
        if (data.length >= 4) {
×
102
            instance._nextTrackId = data.subarray(0, 4).toUint();
×
103
        }
104

105
        return instance;
×
106
    }
107

108
    /**
109
     * Gets the ID of the next track in the movie represented by the current instance.
110
     */
111
    public get nextTrackId(): number { return this._nextTrackId; }
×
112

113
    /**
114
     * Gets the creation time of the movie.
115
     */
116
    public get creationTime(): number { return this._creationTime; }
×
117

118
    /**
119
     * Gets the modification time of the movie.
120
     */
121
    public get modificationTime(): number { return this._modificationTime; }
×
122

123
    /**
124
     * Gets the duration of the movie represented by the current instance.
125
     */
126
    public get durationInMilliseconds(): number { return this._durationInMilliseconds; }
×
127

128
    /**
129
     * Gets the playback rate of the movie represented by the current instance.
130
     */
131
    public get rate(): number { return this._rate; }
×
132

133
    /**
134
     * Gets the playback volume of the movie represented by the current instance.
135
     */
136
    public get volume(): number { return this._volume; }
×
137
}
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