• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*     -------------------------------------------------------------------       */
20 /*                        MPEG-4 TextSampleEntry Class                          */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This TextSampleEntry Class is used for text streams.
25 */
26 
27 #define IMPLEMENT_TextSampleEntry
28 
29 #include "boxrecord.h"
30 #include "fontrecord.h"
31 #include "stylerecord.h"
32 #include "fonttableatom.h"
33 #include "textsampleentry.h"
34 #include "atomutils.h"
35 #include "atomdefs.h"
36 
37 
TextSampleEntry(MP4_FF_FILE * fp,uint32 size,uint32 type)38 OSCL_EXPORT_REF TextSampleEntry:: TextSampleEntry(MP4_FF_FILE *fp, uint32 size, uint32 type)
39         : SampleEntry(fp, size, type)
40 {
41     _pparent = NULL;
42 
43     _pBackgroundRGBA = NULL;
44     _pBoxRecord      = NULL;
45     _pStyleRecord    = NULL;
46     _pFontTableAtom  = NULL;
47 
48     if (_success)
49     {
50 
51         AtomUtils::read32(fp, _displayFlags);
52 
53         uint8 horz = 0;
54         AtomUtils::read8(fp, horz);
55         _horzJustification = (int8)horz;
56 
57         uint8 vert = 0;
58         AtomUtils::read8(fp, vert);
59         _vertJustification = (int8)vert;
60 
61         PV_MP4_FF_ARRAY_NEW(NULL, uint8, (4), _pBackgroundRGBA);
62 
63         AtomUtils::readByteData(fp, 4, _pBackgroundRGBA);
64 
65         PV_MP4_FF_NEW(fp->auditCB, BoxRecord, (fp), _pBoxRecord);
66         if (!_pBoxRecord->MP4Success())
67         {
68             _success = false;
69             _mp4ErrorCode = _pBoxRecord->GetMP4Error();
70             return;
71         }
72 
73         PV_MP4_FF_NEW(fp->auditCB, StyleRecord, (fp), _pStyleRecord);
74         if (!_pStyleRecord->MP4Success())
75         {
76             _success = false;
77             _mp4ErrorCode = _pStyleRecord->GetMP4Error();
78             return;
79         }
80 
81         PV_MP4_FF_NEW(fp->auditCB, FontTableAtom, (fp), _pFontTableAtom);
82         if (!_pFontTableAtom->MP4Success())
83         {
84             _success = false;
85             _mp4ErrorCode = _pFontTableAtom->GetMP4Error();
86             return;
87         }
88     }
89 }
90 
91 // Destructor
~TextSampleEntry()92 OSCL_EXPORT_REF TextSampleEntry::~TextSampleEntry()
93 {
94     if (_pBackgroundRGBA != NULL)
95     {
96         PV_MP4_ARRAY_DELETE(NULL, _pBackgroundRGBA);
97     }
98     if (_pBoxRecord != NULL)
99     {
100         PV_MP4_FF_DELETE(NULL, BoxRecord, _pBoxRecord);
101     }
102     if (_pStyleRecord != NULL)
103     {
104         PV_MP4_FF_DELETE(NULL, StyleRecord, _pStyleRecord);
105     }
106     if (_pFontTableAtom != NULL)
107     {
108         PV_MP4_FF_DELETE(NULL, FontTableAtom, _pFontTableAtom);
109     }
110 }
111 
getBoxTop()112 OSCL_EXPORT_REF int16 TextSampleEntry::getBoxTop()
113 {
114     if (_pBoxRecord != NULL)
115     {
116         return (_pBoxRecord->getBoxTop());
117     }
118     else
119     {
120         return -1;
121     }
122 }
123 
getBoxLeft()124 OSCL_EXPORT_REF int16 TextSampleEntry::getBoxLeft()
125 {
126     if (_pBoxRecord != NULL)
127     {
128         return (_pBoxRecord->getBoxLeft());
129     }
130     else
131     {
132         return -1;
133     }
134 }
135 
getBoxBottom()136 OSCL_EXPORT_REF int16 TextSampleEntry::getBoxBottom()
137 {
138     if (_pBoxRecord != NULL)
139     {
140         return (_pBoxRecord->getBoxBottom());
141     }
142     else
143     {
144         return -1;
145     }
146 }
147 
getBoxRight()148 OSCL_EXPORT_REF int16 TextSampleEntry::getBoxRight()
149 {
150     if (_pBoxRecord != NULL)
151     {
152         return (_pBoxRecord->getBoxRight());
153     }
154     else
155     {
156         return -1;
157     }
158 }
getFontID()159 OSCL_EXPORT_REF uint16 TextSampleEntry::getFontID()
160 {
161     if (_pStyleRecord != NULL)
162     {
163         return _pStyleRecord-> getFontID();
164     }
165     else
166     {
167         return 0;
168     }
169 }
170 
getStartChar()171 OSCL_EXPORT_REF uint16 TextSampleEntry::getStartChar()
172 {
173     if (_pStyleRecord != NULL)
174     {
175         return _pStyleRecord-> getStartChar();
176     }
177     else
178     {
179         return 0;
180     }
181 }
182 
getEndChar()183 OSCL_EXPORT_REF uint16 TextSampleEntry::getEndChar()
184 {
185     if (_pStyleRecord != NULL)
186     {
187         return _pStyleRecord-> getEndChar();
188     }
189     else
190     {
191         return 0;
192     }
193 }
194 
getFontStyleFlags()195 OSCL_EXPORT_REF uint8 TextSampleEntry::getFontStyleFlags()
196 {
197     if (_pStyleRecord != NULL)
198     {
199         return _pStyleRecord-> getFontStyleFlags();
200     }
201     else
202     {
203         return 0;
204     }
205 }
206 
getfontSize()207 OSCL_EXPORT_REF uint8 TextSampleEntry::getfontSize()
208 {
209     if (_pStyleRecord != NULL)
210     {
211         return _pStyleRecord->getfontSize();
212     }
213     else
214     {
215         return 0;
216     }
217 }
218 
getTextColourRGBA()219 OSCL_EXPORT_REF uint8* TextSampleEntry::getTextColourRGBA()
220 {
221     if (_pStyleRecord != NULL)
222     {
223         return _pStyleRecord-> getTextColourRGBA();
224     }
225     else
226     {
227         return NULL;
228     }
229 }
230 
getFontListSize()231 OSCL_EXPORT_REF uint16 TextSampleEntry:: getFontListSize()
232 {
233     if (_pFontTableAtom != NULL)
234     {
235         return _pFontTableAtom-> getFontListSize();
236     }
237     else
238     {
239         return 0;
240     }
241 }
242 
getFontRecordAt(uint16 index)243 OSCL_EXPORT_REF FontRecord* TextSampleEntry::getFontRecordAt(uint16 index)
244 {
245     if (_pFontTableAtom != NULL)
246     {
247         return _pFontTableAtom->getFontRecordAt(index);
248     }
249     else
250     {
251         return NULL;
252     }
253 }
254 
getObjectTypeIndication() const255 uint8 TextSampleEntry::getObjectTypeIndication() const
256 {
257     return TIMED_TEXT;
258 }
259 
260 
261 
262 
263 
264 
265