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

benrr101 / node-taglib-sharp / 48257345

12 Oct 2023 04:06AM UTC coverage: 92.315% (+0.4%) from 91.944%
48257345

push

appveyor

benrr101
Performer roles (bug fixed), genres

3226 of 4153 branches covered (0.0%)

Branch coverage included in aggregate %.

94 of 94 new or added lines in 2 files covered. (100.0%)

27069 of 28664 relevant lines covered (94.44%)

417.21 hits per line

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

24.24
/src/mpeg4/boxes/isoAudioSampleEntry.ts
1
import AppleElementaryStreamDescriptor from "./appleElementaryStreamDescriptor";
1✔
2
import IsoSampleEntry from "./isoSampleEntry";
1✔
3
import Mpeg4BoxHeader from "../mpeg4BoxHeader";
4
import Mpeg4BoxType from "../mpeg4BoxType";
1✔
5
import {ByteVector, StringType} from "../../byteVector";
1✔
6
import {File} from "../../file";
7
import {Mpeg4BoxClassType} from "../mpeg4BoxClassType";
1✔
8
import {IAudioCodec, MediaTypes} from "../../properties";
1✔
9
import {Guards, NumberUtils} from "../../utils";
1✔
10

11
/**
12
 * This class extends @see IsoSampleEntry and implements @see IAudioCodec to provide an implementation of a
13
 * ISO/IEC 14496-12 AudioSampleEntry and support for reading MPEG-4 video properties.
14
 */
15
export default class IsoAudioSampleEntry extends IsoSampleEntry implements IAudioCodec {
1✔
16
    private _audioChannels: number;
17
    private _audioSampleRate: number;
18
    private _audioSampleSize: number;
19

20
    /**
21
     * Private constructor to force construction via static functions.
22
     */
23
    private constructor() {
24
        super();
×
25
    }
26

27
    /**
28
     * Constructs and initializes a new instance of @see IsoVisualSampleEntry with a provided header and
29
     * handler by reading the contents from a specified file.
30
     * @param file A @see File to read the contents of the box from.
31
     *     new instance, or undefined if no handler applies.
32
     * @param header A @see Mpeg4BoxHeader object containing the header to use for the new instance.
33
     * @param handlerType Type of the handler box object containing the handler that applies to the
34
     * @returns A new instance of @see IsoVisualSampleEntry
35
     */
36
    public static fromFile(file: File, header: Mpeg4BoxHeader, handlerType: ByteVector): IsoAudioSampleEntry {
37
        Guards.notNullOrUndefined(file, "file");
×
38

39
        const instance = new IsoAudioSampleEntry();
×
40
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
41
        const dataPositionBeforeIncrease = instance.increaseDataPosition(20);
×
42

43
        file.seek(dataPositionBeforeIncrease + 8);
×
44
        instance._audioChannels = file.readBlock(2).toUshort();
×
45
        instance._audioSampleSize = file.readBlock(2).toUshort();
×
46

47
        file.seek(dataPositionBeforeIncrease + 16);
×
48
        const sampleRate = file.readBlock(4).toUint();
×
49
        instance._audioSampleRate = NumberUtils.uintRShift(sampleRate, 16);
×
50

51
        return instance;
×
52
    }
53

54
    /** @inheritDoc */
55
    public get boxClassType(): Mpeg4BoxClassType { return Mpeg4BoxClassType.IsoAudioSampleEntry; }
×
56

57
    /**
58
     * Gets the bitrate of the audio represented by the current instance.
59
     */
60
    public get audioBitrate(): number {
61
        const esds = this.getChildRecursively(Mpeg4BoxType.ESDS);
×
62

63
        // If we don't have a stream descriptor, we don't know what's what.
64
        if (!(esds instanceof AppleElementaryStreamDescriptor)) {
×
65
            return 0;
×
66
        }
67

68
        // Return from the elementary stream descriptor.
69
        return esds.averageBitrate;
×
70
    }
71

72
    /** @inheritDoc */
73
    public get audioChannels(): number { return this._audioChannels; }
×
74

75
    /** @inheritDoc */
76
    public get audioSampleRate(): number { return this._audioSampleRate; }
×
77

78
    /** @inheritDoc */
79
    public get audioSampleSize(): number { return this._audioSampleSize; }
×
80

81
    /** @inheritDoc */
82
    public get description(): string { return `MPEG-4 Audio (${this.boxType.toString(StringType.Latin1)})`; }
×
83

84
    /** @inheritDoc */
85
    public get durationMilliseconds(): number { return 0; }
×
86

87
    /** @inheritDoc */
88
    public get mediaTypes(): MediaTypes { return MediaTypes.Audio; }
×
89
}
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