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_HEADER_H_INCLUDED 19 #define PV_AVIFILE_HEADER_H_INCLUDED 20 21 22 #ifndef PV_AVIFILE_TYPEDEFS_H_INCLUDED 23 #include "pv_avifile_typedefs.h" 24 #endif 25 26 #ifndef PV_AVIFILE_PARSER_UTILS_H_INCLUDED 27 #include "pv_avifile_parser_utils.h" 28 #endif 29 30 #ifndef PV_AVIFILE_STREAMLIST_H_INCLUDED 31 #include "pv_avifile_streamlist.h" 32 #endif 33 34 35 36 // class to parse main header 37 class PVAviFileHeader: public PVAviFileParserStatus 38 { 39 public: 40 41 //constructor 42 PVAviFileHeader(PVFile *aFp, uint32 aHdrSize); 43 44 //destructor ~PVAviFileHeader()45 ~PVAviFileHeader() 46 { 47 for (uint32 ii = 0; ii < iStreamList.size(); ii++) 48 { 49 iStreamList.pop_back(); 50 } 51 } 52 53 //methods to retrieve PVAviFileMainHeaderStruct information GetMainHeaderStruct()54 PVAviFileMainHeaderStruct GetMainHeaderStruct() 55 { 56 return iMainHeader; 57 } 58 GetFrameDuration()59 uint32 GetFrameDuration() 60 { 61 return (iMainHeader.iMicroSecPerFrame); 62 }; 63 GetNumStreams()64 uint32 GetNumStreams() 65 { 66 return (iMainHeader.iStreams); 67 } 68 GetFileSuggestedBufferSize()69 uint32 GetFileSuggestedBufferSize() 70 { 71 return (iMainHeader.iSuggestedBufferSize); 72 } 73 GetFileDataRate()74 uint32 GetFileDataRate() 75 { 76 return (iMainHeader.iMaxBytesPerSec); 77 } 78 IsCopyrighted()79 bool IsCopyrighted() 80 { 81 return (iMainHeader.iIsAVIFileCopyrighted); 82 } 83 HasIndexTable()84 bool HasIndexTable() 85 { 86 return (iMainHeader.iAVIFileHasIndxTbl); 87 } 88 MustUseIndexTbl()89 bool MustUseIndexTbl() 90 { 91 return (iMainHeader.iAVIFileMustUseIndex); 92 } 93 IsInterleaved()94 bool IsInterleaved() 95 { 96 return (iMainHeader.iISAVIFileInterleaved); 97 } 98 MustUseIndex()99 bool MustUseIndex() 100 { 101 return (iMainHeader.iAVIFileMustUseIndex); 102 } 103 IsCaptureFile()104 bool IsCaptureFile() 105 { 106 return (iMainHeader.iAVIFileWasCaptureFile); 107 } 108 GetTotalFrames()109 uint32 GetTotalFrames() 110 { 111 return (iMainHeader.iTotalFrames); 112 } 113 GetInitialFrames()114 uint32 GetInitialFrames() 115 { 116 return (iMainHeader.iInitialFrames); 117 } 118 GetWidth(int32 aStreamNo)119 uint32 GetWidth(int32 aStreamNo) 120 { 121 if (aStreamNo > 0) 122 { 123 return iStreamList[aStreamNo].GetVideoWidth(); 124 } 125 else 126 { 127 return (iMainHeader.iWidth); 128 } 129 } 130 131 uint32 GetHeight(bool& rBottomUp, int32 aStreamNo = -1) 132 { 133 if (aStreamNo > 0) 134 { 135 return iStreamList[aStreamNo].GetVideoHeight(rBottomUp); 136 } 137 else 138 { 139 rBottomUp = true; //rgb bmp is stored as bottom-up by default. 140 return (iMainHeader.iHeight); 141 } 142 } 143 144 //methods to retrieve PVAviFileStreamlist information GetStreamHeaderStruct(uint32 aStreamNum)145 PVAviFileStreamHeaderStruct GetStreamHeaderStruct(uint32 aStreamNum) 146 { 147 return (iStreamList[aStreamNum].GetStreamHeaderStruct()); 148 } 149 GetStreamMimeType(uint32 aStreamNum)150 OSCL_HeapString<OsclMemAllocator> GetStreamMimeType(uint32 aStreamNum) 151 { 152 return (iStreamList[aStreamNum].GetStreamMimeType()); 153 } 154 PalletChangeAvailable(uint32 aStreamNum)155 bool PalletChangeAvailable(uint32 aStreamNum) 156 { 157 return (iStreamList[aStreamNum].PalletChangeAvailable()); 158 } 159 ISDisabledByDefault(uint32 aStreamNum)160 bool ISDisabledByDefault(uint32 aStreamNum) 161 { 162 return (iStreamList[aStreamNum].ISDisabledByDefault()); 163 } 164 GetHandlerType(uint32 aStreamNum,uint8 * aHdlr,uint32 & aSize)165 bool GetHandlerType(uint32 aStreamNum, uint8* aHdlr, uint32& aSize) 166 { 167 return (iStreamList[aStreamNum].GetHandlerType(aHdlr, aSize)); 168 } 169 170 uint32 GetAudioFormat(uint32 aStreamNo); 171 172 uint32 GetNumAudioChannels(uint32 aStreamNo); 173 GetPriority(uint32 aStreamNum)174 uint16 GetPriority(uint32 aStreamNum) 175 { 176 return (iStreamList[aStreamNum].GetPriority()); 177 } 178 GetLanguage(uint32 aStreamNum)179 uint16 GetLanguage(uint32 aStreamNum) 180 { 181 return (iStreamList[aStreamNum].GetLanguage()); 182 } 183 GetInitalFrames(uint32 aStreamNum)184 uint32 GetInitalFrames(uint32 aStreamNum) 185 { 186 return (iStreamList[aStreamNum].GetInitalFrames()); 187 } 188 GetRate(uint32 aStreamNum)189 uint32 GetRate(uint32 aStreamNum) 190 { 191 return (iStreamList[aStreamNum].GetRate()); 192 } 193 GetScale(uint32 aStreamNum)194 uint32 GetScale(uint32 aStreamNum) 195 { 196 return (iStreamList[aStreamNum].GetScale()); 197 } 198 GetSamplingRate(uint32 aStreamNum)199 OsclFloat GetSamplingRate(uint32 aStreamNum) 200 { 201 return (iStreamList[aStreamNum].GetSamplingRate()); 202 } 203 GetStartTime(uint32 aStreamNum)204 uint32 GetStartTime(uint32 aStreamNum) 205 { 206 return (iStreamList[aStreamNum].GetStartTime()); 207 } 208 GetStreamDuration(uint32 aStreamNum)209 uint32 GetStreamDuration(uint32 aStreamNum) 210 { 211 return (iStreamList[aStreamNum].GetStreamDuration()); 212 } 213 GetStreamSuggestedBufferSize(uint32 aStreamNum)214 uint32 GetStreamSuggestedBufferSize(uint32 aStreamNum) 215 { 216 return (iStreamList[aStreamNum].GetStreamSuggestedBufferSize()); 217 } 218 GetQuality(uint32 aStreamNum)219 int32 GetQuality(uint32 aStreamNum) 220 { 221 return (iStreamList[aStreamNum].GetQuality()); 222 } 223 GetBitsPerSample(uint32 aStreamNum)224 uint32 GetBitsPerSample(uint32 aStreamNum) 225 { 226 return (iStreamList[aStreamNum].GetBitsPerSample()); 227 } 228 GetSampleSize(uint32 aStreamNum)229 uint32 GetSampleSize(uint32 aStreamNum) 230 { 231 return (iStreamList[aStreamNum].GetSampleSize()); 232 } 233 GetRCFrame(uint32 aStreamNum)234 rcFrameType GetRCFrame(uint32 aStreamNum) 235 { 236 return (iStreamList[aStreamNum].GetRCFrame()); 237 } 238 GetFormatSpecificInfo(uint32 aStreamNum,uint8 * & aBuff,uint32 & aSize)239 bool GetFormatSpecificInfo(uint32 aStreamNum, uint8*& aBuff, uint32& aSize) 240 { 241 return ((iStreamList[aStreamNum]).GetFormatSpecificInfo(aBuff, aSize)); 242 } 243 GetCodecSpecificData(uint32 aStreamNum,uint8 * & aBuff,uint32 & aSize)244 bool GetCodecSpecificData(uint32 aStreamNum, uint8*& aBuff, uint32& aSize) 245 { 246 return ((iStreamList[aStreamNum]).GetCodecSpecificData(aBuff, aSize)); 247 } 248 249 250 private: 251 252 253 PV_AVI_FILE_PARSER_ERROR_TYPE ParseMainHeader(PVFile *aFp); 254 255 //File Main Header 256 PVAviFileMainHeaderStruct iMainHeader; 257 uint32 iHeaderTotalSize; 258 259 //vector to store stream specific info. 260 //Index of the vector corresponds to stream number 261 Oscl_Vector < PVAviFileStreamlist, 262 OsclMemAllocator > iStreamList; 263 264 }; 265 266 #endif //#ifndef PV_AVIFILE_HEADER_H_INCLUDED 267 268