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 #include "atom.h" 19 #include "atomutils.h" 20 #include "oscl_file_io.h" 21 #include "boxrecord.h" 22 #include"a_atomdefs.h" 23 24 25 26 27 PVA_FF_BoxRecord::PVA_FF_BoxRecord() : PVA_FF_Atom(FourCharConstToUint32('t', 't', 's', 'b')) 28 { 29 _top = 0; 30 _left = 0; 31 _bottom = 0; 32 _right = 0; 33 recomputeSize(); 34 } 35 36 void PVA_FF_BoxRecord::setBoxTop(int16 top1) 37 { 38 if (_top == 0) 39 { 40 _top = top1; 41 } 42 } 43 44 void PVA_FF_BoxRecord::setBoxLeft(int16 left1) 45 { 46 if (_left == 0) 47 { 48 _left = left1; 49 } 50 } 51 52 void PVA_FF_BoxRecord::setBoxBottom(int16 bottom1) 53 { 54 if (_bottom == 0) 55 { 56 _bottom = bottom1; 57 } 58 } 59 60 void PVA_FF_BoxRecord::setBoxRight(int16 right1) 61 { 62 if (_right == 0) 63 { 64 _right = right1; 65 } 66 } 67 68 69 bool PVA_FF_BoxRecord::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) 70 { 71 int32 rendered = 0; 72 73 if (!PVA_FF_AtomUtils::render16(fp, _top)) 74 { 75 return false; 76 } 77 rendered += 2; 78 if (!PVA_FF_AtomUtils::render16(fp, _left)) 79 { 80 return false; 81 } 82 rendered += 2; 83 if (!PVA_FF_AtomUtils::render16(fp, _bottom)) 84 { 85 return false; 86 } 87 rendered += 2; 88 if (!PVA_FF_AtomUtils::render16(fp, _right)) 89 { 90 return false; 91 } 92 rendered += 2; 93 94 return true; 95 } 96 97 void PVA_FF_BoxRecord::recomputeSize() 98 { 99 int32 size = 0; 100 101 size += 2; 102 size += 2; 103 size += 2; 104 size += 2; 105 106 _size = size; 107 108 // Update size of parent 109 if (_pparent != NULL) 110 { 111 _pparent->recomputeSize(); 112 } 113 } 114 115 uint32 PVA_FF_BoxRecord::getSize() 116 { 117 recomputeSize(); 118 return (_size); 119 } 120