1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #ifndef PV_AVIFILE_PARSER_H_INCLUDED 19 #define PV_AVIFILE_PARSER_H_INCLUDED 20 21 #ifndef PV_AVIFILE_TYPEDEFS_H_INCLUDED 22 #include "pv_avifile_typedefs.h" 23 #endif 24 25 #ifndef PV_AVIFILE_PARSER_UTILS_H_INCLUDED 26 #include "pv_avifile_parser_utils.h" 27 #endif 28 29 #ifndef PV_AVIFILE_HEADER_H_INCLUDED 30 #include "pv_avifile_header.h" 31 #endif 32 33 #ifndef PV_AVIFILE_INDX_H_INCLUDED 34 #include "pv_avifile_indx.h" 35 #endif 36 37 #ifndef PV_AVIFILE_H_INCLUDED 38 #include "pv_avifile.h" 39 #endif 40 41 42 //class to parse avi file 43 class PVAviFileParser: public PVAviFile 44 { 45 46 public: 47 48 //constructor 49 PVAviFileParser(OSCL_wHeapString<OsclMemAllocator> aFileName, int32& aError, Oscl_FileServer* aFileServer, 50 PVMFCPMPluginAccessInterfaceFactory* aCPM, OsclFileHandle* aFileHandle); 51 52 //destructor 53 ~PVAviFileParser(); 54 55 PV_AVI_FILE_PARSER_ERROR_TYPE ParseFile(); 56 57 //Read Media Sample form the file in order they exist in 'movi' chunk 58 PV_AVI_FILE_PARSER_ERROR_TYPE 59 GetNextMediaSample(uint32& arStreamNo, uint8* aBuffer, uint32& arSize, 60 uint32& arTimeStamp); 61 62 //read next media samples for a stream with stream number = aStreamNo. 63 PV_AVI_FILE_PARSER_ERROR_TYPE 64 GetNextStreamMediaSample(uint32 aStreamNo, uint8* aBuffer, uint32& arSize, 65 uint32& arTimeStamp); 66 67 PV_AVI_FILE_PARSER_ERROR_TYPE 68 GetNextStreamSampleInfo(uint32 aStreamNo, uint32& arSize, uint32& arOffset); 69 70 //methods to retrieve file properties GetMainHeaderStruct()71 PVAviFileMainHeaderStruct GetMainHeaderStruct() 72 { 73 return (ipFileHeader->GetMainHeaderStruct()); 74 } 75 76 OSCL_IMPORT_REF uint32 GetFileDuration(); 77 78 OSCL_IMPORT_REF void Reset(); 79 OSCL_IMPORT_REF void Reset(uint32 aStreamNo); 80 81 OSCL_IMPORT_REF uint32 GetFrameDuration(); 82 83 OSCL_IMPORT_REF uint32 GetNumStreams(); 84 85 uint32 GetFileSuggestedBufferSize(); 86 GetFileDataRate()87 uint32 GetFileDataRate() 88 { 89 return (ipFileHeader->GetFileDataRate()); 90 } 91 IsCopyrighted()92 bool IsCopyrighted() 93 { 94 return (ipFileHeader->IsCopyrighted()); 95 } HasIndexTable()96 bool HasIndexTable() 97 { 98 return (ipFileHeader->HasIndexTable()); 99 } 100 IsInterleaved()101 bool IsInterleaved() 102 { 103 return (ipFileHeader->IsInterleaved()); 104 } 105 MustUseIndex()106 bool MustUseIndex() 107 { 108 return (ipFileHeader->MustUseIndex()); 109 } 110 IsCaptureFile()111 bool IsCaptureFile() 112 { 113 return (ipFileHeader->IsCaptureFile()); 114 } 115 GetTotalFrames()116 uint32 GetTotalFrames() 117 { 118 return (ipFileHeader->GetTotalFrames()); 119 } 120 GetInitialFrames()121 uint32 GetInitialFrames() 122 { 123 return (ipFileHeader->GetInitialFrames()); 124 } 125 126 OSCL_IMPORT_REF uint32 GetWidth(int32 aStreamNo); 127 128 OSCL_IMPORT_REF uint32 GetHeight(bool& rBottomUp, int32 aStreamNo); 129 130 //methods to retrieve stream properties 131 OSCL_IMPORT_REF PVAviFileStreamHeaderStruct GetStreamHeaderStruct(uint32 aStreamNum); 132 133 OSCL_IMPORT_REF OSCL_HeapString<OsclMemAllocator> GetStreamMimeType(uint32 aStreamNum); 134 OSCL_IMPORT_REF uint32 GetStreamDuration(uint32 aStreamNum); 135 PalletChangeAvailable(uint32 aStreamNum)136 bool PalletChangeAvailable(uint32 aStreamNum) 137 { 138 return (ipFileHeader->PalletChangeAvailable(aStreamNum)); 139 } 140 ISDisabledByDefault(uint32 aStreamNum)141 bool ISDisabledByDefault(uint32 aStreamNum) 142 { 143 return (ipFileHeader->ISDisabledByDefault(aStreamNum)); 144 } 145 146 bool GetVideoFormatType(uint8* aHdlr, uint32& arSize, uint32 aStreamNo); 147 GetAudioFormatType(uint32 aStreamNo)148 uint32 GetAudioFormatType(uint32 aStreamNo) 149 { 150 return ipFileHeader->GetAudioFormat(aStreamNo); 151 } 152 GetNumAudioChannels(uint32 aStreamNo)153 uint32 GetNumAudioChannels(uint32 aStreamNo) 154 { 155 return ipFileHeader->GetNumAudioChannels(aStreamNo); 156 } 157 GetPriority(uint32 aStreamNum)158 uint16 GetPriority(uint32 aStreamNum) 159 { 160 return (ipFileHeader->GetPriority(aStreamNum)); 161 } 162 GetLanguage(uint32 aStreamNum)163 uint16 GetLanguage(uint32 aStreamNum) 164 { 165 return (ipFileHeader->GetLanguage(aStreamNum)); 166 } 167 GetInitalFrames(uint32 aStreamNum)168 uint32 GetInitalFrames(uint32 aStreamNum) 169 { 170 return (ipFileHeader->GetInitalFrames(aStreamNum)); 171 } 172 GetRate(uint32 aStreamNum)173 uint32 GetRate(uint32 aStreamNum) 174 { 175 return (ipFileHeader->GetRate(aStreamNum)); 176 } 177 GetScale(uint32 aStreamNum)178 uint32 GetScale(uint32 aStreamNum) 179 { 180 return (ipFileHeader->GetScale(aStreamNum)); 181 } 182 183 OSCL_IMPORT_REF OsclFloat GetFrameRate(uint32 aStreamNum); 184 GetStartTime(uint32 aStreamNum)185 uint32 GetStartTime(uint32 aStreamNum) 186 { 187 return (ipFileHeader->GetStartTime(aStreamNum)); 188 } 189 190 GetStreamSuggestedBufferSize(uint32 aStreamNum)191 uint32 GetStreamSuggestedBufferSize(uint32 aStreamNum) 192 { 193 return (ipFileHeader->GetStreamSuggestedBufferSize(aStreamNum)); 194 } 195 GetBitsPerSample(uint32 aStreamNum)196 uint32 GetBitsPerSample(uint32 aStreamNum) 197 { 198 return (ipFileHeader->GetBitsPerSample(aStreamNum)); 199 } 200 GetQuality(uint32 aStreamNum)201 int32 GetQuality(uint32 aStreamNum) 202 { 203 return (ipFileHeader->GetQuality(aStreamNum)); 204 } 205 GetSampleSize(uint32 aStreamNum)206 uint32 GetSampleSize(uint32 aStreamNum) 207 { 208 return (ipFileHeader->GetSampleSize(aStreamNum)); 209 } 210 GetRCFrame(uint32 aStreamNum)211 rcFrameType GetRCFrame(uint32 aStreamNum) 212 { 213 return (ipFileHeader->GetRCFrame(aStreamNum)); 214 } 215 216 //method to get codec specific info 217 OSCL_IMPORT_REF bool GetCodecSpecificData(uint32 aStreamNum, OsclRefCounterMemFrag& arFormatSpecificDataFrag); 218 219 //method to retrieve stream format specific info 220 OSCL_IMPORT_REF bool GetFormatSpecificInfo(uint32 aStreamNum, OsclRefCounterMemFrag& arFormatSpecificDataFrag); 221 GetStreamCountList()222 Oscl_Vector<uint32, OsclMemAllocator> GetStreamCountList() 223 { 224 return iStreamCount; 225 } 226 227 OSCL_IMPORT_REF Oscl_Vector<uint32, OsclMemAllocator> GetAudioStreamCountList(); 228 OSCL_IMPORT_REF Oscl_Vector<uint32, OsclMemAllocator> GetVideoStreamCountList(); 229 230 private: 231 232 PV_AVI_FILE_PARSER_ERROR_TYPE 233 GetStreamOffsetFromIndexTable(uint32 aStreamNo, uint32& arSize, uint32& aOffset); 234 235 PV_AVI_FILE_PARSER_ERROR_TYPE 236 GetStreamOffset(uint32 aStreamNo, uint32& aSampleSize, uint32& aOffset); 237 238 239 PVAviFileHeader* ipFileHeader; 240 PVAviFileIdxChunk* ipIdxChunk; 241 bool iIdxChunkPresent; 242 uint32 iFileSize; 243 uint32 iHeaderChunkSize; 244 uint32 iMovieChunkSize; 245 246 //store the offset of first sample. used if index table is not present. 247 uint32 iMovieChunkStartOffset; 248 uint32 iIndxChunkSize; 249 Oscl_Vector < uint32, 250 OsclMemAllocator > iStreamCount; 251 252 Oscl_Vector < uint32, 253 OsclMemAllocator > iStreamSampleCount; 254 255 //stores current offset if index table is not present 256 uint32 iSampleOffset; 257 258 //store latest sample offset if index table is not present 259 Oscl_Vector < uint32, 260 OsclMemAllocator > iStreamSampleOffset; 261 262 PVFile* ipFilePtr; 263 uint32 iTimeStampAudio; 264 uint32 iTimeStampVideo; 265 266 }; 267 268 #endif //#ifndef PV_AVIFILE_PARSER_H_INCLUDED 269 270