import { BufferSlices, BufferSlice } from './buffer'; import { BufferProperties } from './buffer-props'; import { PacketDataModel } from './packet-model'; import { PacketSymbol } from './packet-symbol'; export { PacketSymbol } from './packet-symbol'; export declare type PacketReceiveCallback = ((p: Packet) => boolean); export declare type PacketFilter = (p: Packet) => Packet; export declare class Packet implements PacketDataModel { data: BufferSlices; timestamp: number; presentationTimeOffset: number; createdAt: Date; private _synchronizationId; /** * used to recover a packet that was transferred from a another thread (worker) context (passed via a message-event). * the object is then a "dead" structure of metadata and needs to be reconstructed so it has "methods" * again on its instance. all buffer-slices need to be recovered as well. in JS terms, we have lost all of our * prototypical nature and are more of a 1-to-1 serialized snapshot of the object state from which we create * a new instance with the identical properties. * @param p */ static fromTransferable(p: Packet): Packet; /** * same as above but we are creating copies of the buffer data as well. * this is usually done when we pass data from a processing thread (worker) into the control/user thread via a message. * the message is attached a copy of the original data which was processed in the thread in this case. * @param p */ static makeTransferableCopy(p: Packet): Packet; /** * Creates a new packet based on an existing ("dead") packets metadata and some arbitrary data that is passed in. * This is used to convert back and for packet-data to be attached to inter-thread messages. * @param p Expected to be only a state snapshot of a packet without the actual prototype applied (no methods) * @param data */ private static fromData; static fromArrayBuffer(arrayBuffer: ArrayBuffer, mimeType?: string, bufferProps?: BufferProperties): Packet; static fromSlice(bufferSlice: BufferSlice, timestamp?: number, pto?: number): Packet; static fromSlices(timestamp: number, pto: number, ...bufferSlices: BufferSlice[]): Packet; static fromSymbol(symbol: PacketSymbol): Packet; static newEos(): Packet; static newFlush(): Packet; static newGap(): Packet; static newResume(): Packet; private _symbol; private _timescale; private _hasDefaultBufferProps; private _timestampOffset; constructor(data?: BufferSlices, timestamp?: number, presentationTimeOffset?: number, createdAt?: Date, _synchronizationId?: number); get dataSlicesLength(): number; get dataSlicesBytes(): number; get timeScale(): number; get timestampOffset(): number; get symbol(): PacketSymbol; get defaultPayloadInfo(): BufferProperties; get defaultMimeType(): string; get hasDefaultPayloadInfo(): boolean; get synchronizationId(): number; setTimingInfo(dts: any, pts?: number, timeScale?: number, timeOffset?: number): Packet; setTimescale(timescale: number): Packet; setTimestampOffset(tOffset: number): Packet; setSynchronizationId(id: number): Packet; setSymbol(symbol: PacketSymbol): Packet; isSymbolic(): boolean; getTotalBytes(): number; getSymbolName(): string; toString(): string; mapArrayBuffers(): ArrayBuffer[]; forEachBufferSlice(method: (bs: BufferSlice) => void, errorHandler?: (bs: BufferSlice, err: Error) => boolean, context?: any): void; /** * alias for timestamp */ getDts(): number; /** * alias for presentationTimeOffset */ getCto(): number; /** * CTS <==> PTS * * CT(n) = DT(n) + CTO(n) */ getPresentationTimestamp(): number; getDecodingTimestamp(): number; getCompositionTimeOffset(): number; /** * CTO == PTO == presentationTimeOffset */ getNormalizedCto(): number; getNormalizedTimestampOffset(): number; getNormalizedPts(): number; getNormalizedDts(): number; getScaledPts(timescale: number): number; getScaledDts(timescale: number): number; getScaledCto(timescale: any): number; }