• 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

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 {Guards, NumberUtils} from "../../utils";
1✔
9

10
/**
11
 * This class extends @see IsoSampleEntry and implements @see 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 @see IsoVisualSampleEntry with a provided header and
28
     * handler by reading the contents from a specified file.
29
     * @param file A @see File to read the contents of the box from.
30
     *     new instance, or undefined if no handler applies.
31
     * @param header A @see 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
     * @returns A new instance of @see IsoVisualSampleEntry
34
     */
35
    public static fromFile(file: File, header: Mpeg4BoxHeader, handlerType: ByteVector): IsoAudioSampleEntry {
36
        const instance = new IsoAudioSampleEntry();
×
37
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
38
        const dataPositionBeforeIncrease = instance.increaseDataPosition(20);
×
39

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

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

48
        return instance;
×
49
    }
50

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

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

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

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

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

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

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

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

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