1/* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17declare module 'mp4box' { 18 // mp4box does not have TypeScript support, so we must declare the types below 19 export interface FileInfo { 20 tracks: Track[]; 21 } 22 23 export interface Track { 24 id: number; 25 } 26 27 export interface Sample { 28 duration: number; 29 timescale: number; 30 } 31 32 export type MP4ArrayBuffer = ArrayBuffer & {fileStart: number}; 33 34 export interface MP4File { 35 onReady?: (info: FileInfo) => void; 36 onSamples?: (id: number, user: unknown, samples: Sample[]) => void; 37 appendBuffer(data: MP4ArrayBuffer): number; 38 start(): void; 39 setExtractionOptions( 40 trackId: number, 41 user?: unknown, 42 options?: {nbSamples?: number; rapAlignment?: number}, 43 ): void; 44 } 45 46 export function createFile(): MP4File; 47} 48