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