@svta/common-media-library
Version:
A common library for media playback in JavaScript
147 lines • 4.25 kB
TypeScript
import type { Fields } from './boxes/Fields.js';
import type { FullBox } from './boxes/FullBox.js';
import type { IsoBmffBox } from './boxes/IsoBmffBox.js';
import type { IsoViewConfig } from './IsoViewConfig.js';
import type { IsoFieldTypeMap } from './readers/IsoFieldTypeMap.js';
/**
* Raw ISO BMFF data box.
*
* @group ISOBMFF
*
* @beta
*/
export type RawBox = {
type: string;
size: number;
largesize?: number;
usertype?: number[];
data: IsoView;
};
/**
* ISO BMFF data view. Similar to DataView, but with additional methods for reading ISO BMFF data.
* It implements the iterator protocol, so it can be used in a for...of loop.
*
* @group ISOBMFF
*
* @beta
*/
export declare class IsoView {
private dataView;
private offset;
private config;
private truncated;
/**
* Creates a new IsoView instance. Similar to DataView, but with additional
* methods for reading ISO BMFF data. It implements the iterator protocol,
* so it can be used in a for...of loop.
*
* @param raw - The raw data to view.
* @param config - The configuration for the IsoView.
*/
constructor(raw: ArrayBuffer | DataView | Uint8Array, config?: IsoViewConfig);
/**
* The current byteoffset in the data view.
*/
get cursor(): number;
/**
* Whether the end of the data view has been reached.
*/
get done(): boolean;
/**
* The number of bytes remaining in the data view.
*/
get bytesRemaining(): number;
/**
* Creates a new IsoView instance with a slice of the current data view.
*
* @param size - The size of the slice.
* @returns A new IsoView instance.
*/
slice: (size: number) => IsoView;
private read;
/**
* Reads a unsigned integer from the data view.
*
* @param size - The size of the integer in bytes.
* @returns The unsigned integer.
*/
readUint: (size: number) => number;
/**
* Reads a signed integer from the data view.
*
* @param size - The size of the integer in bytes.
* @returns The signed integer.
*/
readInt: (size: number) => number;
/**
* Reads a string from the data view.
*
* @param size - The size of the string in bytes.
* @returns The string.
*/
readString: (size: number) => string;
/**
* Reads a template from the data view.
*
* @param size - The size of the template in bytes.
* @returns The template.
*/
readTemplate: (size: number) => number;
/**
* Reads a byte array from the data view.
*
* @param size - The size of the data in bytes.
* @returns The data.
*/
readData: (size: number) => Uint8Array;
/**
* Reads a UTF-8 string from the data view.
*
* @param size - The size of the string in bytes.
* @returns The UTF-8 string.
*/
readUtf8: (size?: number) => string;
/**
* Reads a full box from the data view.
*
* @returns The full box.
*/
readFullBox: () => Fields<FullBox>;
/**
* Reads an array of values from the data view.
*
* @param type - The type of the values.
* @param size - The size of the values in bytes.
* @param length - The number of values to read.
* @returns The array of values.
*/
readArray: <T extends keyof IsoFieldTypeMap>(type: T, size: number, length: number) => IsoFieldTypeMap[T][];
/**
* Reads a raw box from the data view.
*
* @returns The box.
*/
readBox: () => RawBox;
/**
* Reads a number of boxes from the data view.
*
* @param length - The number of boxes to read.
* @returns The boxes.
*/
readBoxes: <T = IsoBmffBox>(length: number) => T[];
/**
* Reads a number of entries from the data view.
*
* @param length - The number of entries to read.
* @param map - The function to map the entries.
* @returns The entries.
*/
readEntries: <T>(length: number, map: () => T) => T[];
/**
* Iterates over the boxes in the data view.
*
* @returns A generator of boxes.
*/
[Symbol.iterator](): Generator<IsoBmffBox>;
}
//# sourceMappingURL=IsoView.d.ts.map