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

benrr101 / node-taglib-sharp / 48391045

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

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

23.33
/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 {IAudioCodec, MediaTypes} from "../../properties";
1✔
8
import {NumberUtils} from "../../utils";
1✔
9

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

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

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

39
        file.seek(dataPositionBeforeIncrease + 8);
×
40
        instance._audioChannels = file.readBlock(2).toUshort();
×
41
        instance._audioSampleSize = file.readBlock(2).toUshort();
×
42

43
        file.seek(dataPositionBeforeIncrease + 16);
×
44
        const sampleRate = file.readBlock(4).toUint();
×
45
        instance._audioSampleRate = NumberUtils.uintRShift(sampleRate, 16);
×
46

47
        return instance;
×
48
    }
49

50
    /**
51
     * Gets the bitrate of the audio represented by the current instance.
52
     */
53
    public get audioBitrate(): number {
54
        const esds = this.getChildRecursively(Mpeg4BoxType.ESDS);
×
55

56
        // If we don't have a stream descriptor, we don't know what's what.
57
        if (!(esds instanceof AppleElementaryStreamDescriptor)) {
×
58
            return 0;
×
59
        }
60

61
        // Return from the elementary stream descriptor.
62
        return esds.averageBitrate;
×
63
    }
64

65
    /** @inheritDoc */
66
    public get audioChannels(): number { return this._audioChannels; }
×
67

68
    /** @inheritDoc */
69
    public get audioSampleRate(): number { return this._audioSampleRate; }
×
70

71
    /** @inheritDoc */
72
    public get audioSampleSize(): number { return this._audioSampleSize; }
×
73

74
    /** @inheritDoc */
75
    // @TODO I'm sure we can get a better description than this
76
    public get description(): string { return `MPEG-4 Audio (${this.boxType.toString(StringType.Latin1)})`; }
×
77

78
    /** @inheritDoc */
79
    public get durationMilliseconds(): number { return 0; }
×
80

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