xref: /aosp_15_r20/external/libxaac/test/decoder/ixheaacd_fileifc.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2018 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker */
20*15dc779aSAndroid Build Coastguard Worker #ifndef __fileifc_h__
21*15dc779aSAndroid Build Coastguard Worker #define __fileifc_h__
22*15dc779aSAndroid Build Coastguard Worker 
23*15dc779aSAndroid Build Coastguard Worker #ifndef INCLUDE_MP4_PARSER
24*15dc779aSAndroid Build Coastguard Worker //#define INCLUDE_MP4_PARSER
25*15dc779aSAndroid Build Coastguard Worker #endif
26*15dc779aSAndroid Build Coastguard Worker #ifdef INCLUDE_MP4_PARSER
27*15dc779aSAndroid Build Coastguard Worker /* Context structure for media frame*/
28*15dc779aSAndroid Build Coastguard Worker typedef struct {
29*15dc779aSAndroid Build Coastguard Worker   unsigned char *frame;
30*15dc779aSAndroid Build Coastguard Worker   unsigned int frameLength;
31*15dc779aSAndroid Build Coastguard Worker   unsigned int presentationTime;
32*15dc779aSAndroid Build Coastguard Worker } ItMp4FrameCtxt;
33*15dc779aSAndroid Build Coastguard Worker 
34*15dc779aSAndroid Build Coastguard Worker /* Context structure for media header*/
35*15dc779aSAndroid Build Coastguard Worker typedef struct {
36*15dc779aSAndroid Build Coastguard Worker   unsigned char *header;
37*15dc779aSAndroid Build Coastguard Worker   unsigned int headerLength;
38*15dc779aSAndroid Build Coastguard Worker } ItMp4HeaderCtxt;
39*15dc779aSAndroid Build Coastguard Worker #endif
40*15dc779aSAndroid Build Coastguard Worker 
41*15dc779aSAndroid Build Coastguard Worker typedef struct FileWrapper {
42*15dc779aSAndroid Build Coastguard Worker #ifdef INCLUDE_MP4_PARSER
43*15dc779aSAndroid Build Coastguard Worker 
44*15dc779aSAndroid Build Coastguard Worker   void *mp4Ctxt;
45*15dc779aSAndroid Build Coastguard Worker   void *fileCtxt;
46*15dc779aSAndroid Build Coastguard Worker   void *interim_buffer;
47*15dc779aSAndroid Build Coastguard Worker   int avail_buffer;
48*15dc779aSAndroid Build Coastguard Worker   ItMp4HeaderCtxt headerCtxt;
49*15dc779aSAndroid Build Coastguard Worker   ItMp4FrameCtxt frameCtxt;
50*15dc779aSAndroid Build Coastguard Worker   int header_given;
51*15dc779aSAndroid Build Coastguard Worker #endif
52*15dc779aSAndroid Build Coastguard Worker   /*  MPEG_2_PROFILE profile; */
53*15dc779aSAndroid Build Coastguard Worker   unsigned int isMp4File;
54*15dc779aSAndroid Build Coastguard Worker   FILE *inputFile;
55*15dc779aSAndroid Build Coastguard Worker 
56*15dc779aSAndroid Build Coastguard Worker } FileWrapper, *FileWrapperPtr;
57*15dc779aSAndroid Build Coastguard Worker 
58*15dc779aSAndroid Build Coastguard Worker FileWrapperPtr FileWrapper_Open(char fileName[]);
59*15dc779aSAndroid Build Coastguard Worker int FileWrapper_Read(FileWrapperPtr transport, unsigned char *buffer,
60*15dc779aSAndroid Build Coastguard Worker                      int bufSize, unsigned int *len);
61*15dc779aSAndroid Build Coastguard Worker unsigned int FileWrapper_Close(FileWrapperPtr transport);
62*15dc779aSAndroid Build Coastguard Worker 
63*15dc779aSAndroid Build Coastguard Worker unsigned int FileWrapper_IsMp4File(FileWrapperPtr transport);
64*15dc779aSAndroid Build Coastguard Worker 
65*15dc779aSAndroid Build Coastguard Worker /* MP4 function declarations */
66*15dc779aSAndroid Build Coastguard Worker 
67*15dc779aSAndroid Build Coastguard Worker /*File Initialization, File Header Parsing*/
68*15dc779aSAndroid Build Coastguard Worker void *it_mp4_parser_init(void *mp4Ctxt, void *mallocAddr);
69*15dc779aSAndroid Build Coastguard Worker 
70*15dc779aSAndroid Build Coastguard Worker /*Extracts audio header from file*/
71*15dc779aSAndroid Build Coastguard Worker int it_mp4_get_audio_header(void *mp4Ctxt, void *audioheader);
72*15dc779aSAndroid Build Coastguard Worker 
73*15dc779aSAndroid Build Coastguard Worker /*Extracts an audio frame from the file */
74*15dc779aSAndroid Build Coastguard Worker int it_mp4_get_audio(void *mp4Ctxt, void *frameCtxt);
75*15dc779aSAndroid Build Coastguard Worker 
76*15dc779aSAndroid Build Coastguard Worker /*Frees allocated memory*/
77*15dc779aSAndroid Build Coastguard Worker int it_mp4_parser_close(void *mp4);
78*15dc779aSAndroid Build Coastguard Worker 
79*15dc779aSAndroid Build Coastguard Worker void *it_fopen(unsigned char *file_name, unsigned char withFile, int size);
80*15dc779aSAndroid Build Coastguard Worker int it_fclose(void *itf);
81*15dc779aSAndroid Build Coastguard Worker #endif
82