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 /* 19 This PVA_FF_Atom Class is the base class for all other Atoms in the MPEG-4 File 20 Format. 21 */ 22 23 24 #ifndef __Atom_H__ 25 #define __Atom_H__ 26 27 #ifndef OSCL_TYPES_H_INCLUDED 28 #include "oscl_types.h" 29 #endif 30 31 #ifndef OSCL_VECTOR_H_INCLUDED 32 #include "oscl_vector.h" 33 #endif 34 35 #ifndef PARENTABLE_H_INCLUDED 36 #include "parentable.h" 37 #endif 38 39 #ifndef RENDERABLE_H_INCLUDED 40 #include "renderable.h" 41 #endif 42 43 const uint32 DEFAULT_ATOM_SIZE = 8; //(8 bytes - 64 bits: 4 bytes for type, 4 for size) 44 45 class PVA_FF_Atom : public PVA_FF_Parentable, public PVA_FF_Renderable 46 { 47 48 public: 49 PVA_FF_Atom(uint32 type); // Constructor 50 virtual ~PVA_FF_Atom(); 51 52 // Member get methods getSize()53 virtual uint32 getSize() const 54 { 55 return _size; 56 } getType()57 uint32 getType() const 58 { 59 return _type; 60 } 61 getLargeSize()62 uint64 getLargeSize() const 63 { 64 return _largeSize; 65 } getUserType()66 uint8 getUserType() const 67 { 68 return _userType; 69 } 70 71 // Overriden by all derived classes. Called when change to atom that affects its _size takes place 72 virtual void recomputeSize() = 0; // To implement the PVA_FF_Parentable interface 73 virtual uint32 getDefaultSize() const; 74 75 // Render the base members of PVA_FF_Atom - i.e. the type and size 76 virtual bool renderAtomBaseMembers(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) const; 77 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ofstream 78 // Each subclass will override this method to render its own contents. 79 virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) = 0; 80 81 protected: 82 uint32 _size; // 4 (32bits) 83 uint32 _type; // 4 (32bits) 84 85 private: 86 uint64 _largeSize; // 8 (64bits) 87 uint8 _userType; // 1 (8bits) 88 89 90 }; 91 92 93 94 #endif 95 96