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

benrr101 / node-taglib-sharp / 46462135

pending completion
46462135

push

appveyor

Benjamin Russell
Merge branch 'release/v5.1.0'

3096 of 3788 branches covered (81.73%)

Branch coverage included in aggregate %.

2171 of 2171 new or added lines in 47 files covered. (100.0%)

25320 of 26463 relevant lines covered (95.68%)

437.0 hits per line

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

70.37
/src/aac/aacFile.ts
1
import AacAudioHeader from "./aacAudioHeader";
1✔
2
import AacFileSettings from "./aacFileSettings";
1✔
3
import SandwichFile from "../sandwich/sandwichFile";
1✔
4
import {CorruptFileError} from "../errors";
1✔
5
import {File, ReadStyle} from "../file";
1✔
6
import {IFileAbstraction} from "../fileAbstraction";
7
import {Properties} from "../properties";
1✔
8
import {TagTypes} from "../tag";
1✔
9
import {NumberUtils} from "../utils";
1✔
10

11
/**
12
 * This class extends {@link File} to provide tagging and properties for ADTS AAC audio files.
13
 * @remarks
14
 *     A {@link Id3v1Tag} and {@link Id3v2Tag} will be added automatically to any file
15
 *     that doesn't contain one. This change does not affect the file until it is saved and can be
16
 *     reversed using the following method:
17
 *     `file.removeTags(file.tagTypes & ~file.tagTypesOnDisk);`
18
 */
19
export default class AacFile extends SandwichFile {
1✔
20
    private static readonly DEFAULT_TAG_LOCATION_MAPPING = new Map<TagTypes, () => boolean>([
1✔
21
        [TagTypes.Ape, () => AacFileSettings.preferApeTagAtFileEnd],
2✔
22
        [TagTypes.Id3v1, () => true],
1✔
23
        [TagTypes.Id3v2, () => AacFileSettings.preferId3v2TagAtFileEnd]
2✔
24
    ]);
25

26
    /** @inheritDoc */
27
    public constructor(file: IFileAbstraction|string, propertiesStyle: ReadStyle) {
28
        super(file, propertiesStyle, AacFile.DEFAULT_TAG_LOCATION_MAPPING, AacFileSettings.defaultTagTypes);
3✔
29
    }
30

31
    protected readProperties(readStyle: ReadStyle): Properties {
32
        // Skip if we're not reading the properties
33
        if (!NumberUtils.hasFlag(readStyle, ReadStyle.Average)) {
3!
34
            return undefined;
3✔
35
        }
36

37
        // Only search the first 16k before giving up
38
        const firstHeader = AacAudioHeader.find(this, this.mediaStartPosition, 0x4000);
×
39
        if (!firstHeader) {
×
40
            throw new CorruptFileError("ADTS audio header not found");
×
41
        }
42

43
        firstHeader.streamLength = this.mediaEndPosition - this.mediaStartPosition;
×
44
        return new Properties(firstHeader.durationMilliseconds, [firstHeader]);
×
45
    }
46
}
47

48
// /////////////////////////////////////////////////////////////////////////
49
// Register the file type
50
[
1✔
51
    "taglib/aac",
52
    "audio/aac"
53
].forEach((mt) => File.addFileType(mt, AacFile));
2✔
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