import VbrHeader from "./vbrHeader"; import { File } from "../file"; import { IAudioCodec, MediaTypes } from "../properties"; import { ChannelMode, MpegVersion } from "./mpegEnums"; /** * Provides information about an MPEG audio stream. For more information and definition of the * header, see http://www.mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm */ export default class MpegAudioHeader implements IAudioCodec { private static readonly BITRATES; private static readonly BLOCK_SIZES; private static readonly SAMPLE_RATES; private readonly _bitrate; private readonly _channelMode; private readonly _layer; private readonly _isCopyrighted; private readonly _isOriginal; private readonly _isProtected; private readonly _sampleRate; private readonly _samplesPerFrame; private readonly _streamLength; private readonly _version; private readonly _versionString; private _vbrHeader; private constructor(); /** * Constructs an MPEG audio header by searching the provided file for an MPEG sync signature * and reading the header that immediately follows. * @param file File from which to read the audio header * @param searchStart Offset into the file to begin searching * @param searchEnd Offset into the file to stop searching * @param streamBytes Total number of bytes in the audio stream. Used to calculate duration if * a VBR header does not additionally specify it. If VBR header is not present and * {@link streamBytes} is `undefined`, then duration will be 0. * @returns MpegAudioHeader Header as read from the file, `undefined` if not found. */ static fromFile(file: File, searchStart: number, searchEnd: number, streamBytes?: number): MpegAudioHeader; /** @inheritDoc */ get audioBitrate(): number; /** @inheritDoc */ get audioChannels(): number; /** @inheritDoc */ get audioSampleRate(): number; /** * Gets the MPEG audio channel mode of the audio represented by the current instance. */ get channelMode(): ChannelMode; /** @inheritDoc */ get description(): string; /** @inheritDoc */ get durationMilliseconds(): number; /** * Whether the current audio is copyrighted. */ get isCopyrighted(): boolean; /** * Whether the current audio is original. */ get isOriginal(): boolean; /** * Gets whether the audio represented by the current instance is protected by CRC. */ get isProtected(): boolean; /** * Gets the MPEG audio layer used to encode the audio represented by the current instance. */ get layer(): number; /** @inheritDoc */ get mediaTypes(): MediaTypes; /** * Gets the variable bitrate header (VBR) if the MPEG audio frame contains one. */ get vbrHeader(): VbrHeader; /** * Gets the MPEG version used to encode the audio represented by the current instance. */ get version(): MpegVersion; private static isHeaderValid; }