• 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 UserDataAtom Class                            */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This UserDataAtom Class is a container atom for informative user-data.
25 */
26 
27 
28 #define __IMPLEMENT_AssetInfoAtoms__
29 
30 #include "assetinfoatoms.h"
31 #include "atomdefs.h"
32 #include "oscl_utf8conv.h"
33 #include "oscl_snprintf.h"
34 
35 #define UInt32ToFourChar(num, characters) \
36 { \
37     characters[3] = (num & 0xFF); \
38     characters[2] = (num & 0xFF00)>>8; \
39     characters[1] = (num & 0xFF0000)>>16; \
40     characters[0] = (num & 0xFF000000)>>24; \
41 }
42 
43 typedef Oscl_Vector<AssestInfoKeyWord*, OsclMemAllocator> assestInfoKeyWordVecType;
44 
AssestInfoBaseParser(MP4_FF_FILE * fp,uint32 size,uint32 sizeofDataFieldBeforeString)45 AssestInfoBaseParser::AssestInfoBaseParser(MP4_FF_FILE *fp,
46         uint32 size,
47         uint32 sizeofDataFieldBeforeString)
48 {
49     _success = true;
50     _charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
51     if (_success)
52     {
53         uint32 _count = 0;
54 
55         if (sizeofDataFieldBeforeString == 2)
56         {
57             if (!AtomUtils::read16(fp, _dataPriorToString))
58             {
59                 _success = false;
60                 return;
61             }
62             _count += 2;
63         }
64         else if (sizeofDataFieldBeforeString == 1)
65         {
66             uint8 data8;
67 
68             if (!AtomUtils::read8(fp, data8))
69             {
70                 _success = false;
71                 return;
72             }
73             _count += 1;
74             _dataPriorToString = (uint16)(data8);
75         }
76         else
77         {
78             //error
79             _success = false;
80             return;
81         }
82 
83         uint32 delta = (size - _count);
84 
85         if (delta > 0)
86         {
87             if (!AtomUtils::readString(fp, delta, _charType , _infoNotice))
88             {
89                 //error
90                 _success = false;
91                 return;
92             }
93             _count += delta;
94         }
95         else
96         {
97             _charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
98             _infoNotice = NULL;
99         }
100 
101         if (_count < size)
102             AtomUtils::seekFromCurrPos(fp, (size - _count));
103     }
104 }
105 
AssetInfoTitleAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)106 AssetInfoTitleAtom::AssetInfoTitleAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
107         : FullAtom(fp, size, type)
108 {
109     _pAssetInfoBaseParser = NULL;
110     if (_success)
111     {
112         uint32 count = getDefaultSize();
113 
114         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
115 
116         if (!(_pAssetInfoBaseParser->GetMP4Success()))
117         {
118             _success = false;
119             _mp4ErrorCode = READ_UDTA_TITL_FAILED;
120             return;
121         }
122     }
123     else
124     {
125         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
126         {
127             _mp4ErrorCode = READ_UDTA_TITL_FAILED;
128         }
129     }
130 }
131 
~AssetInfoTitleAtom()132 AssetInfoTitleAtom::~AssetInfoTitleAtom()
133 {
134     if (_pAssetInfoBaseParser != NULL)
135     {
136         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
137 
138     }
139 }
140 
AssetInfoDescAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)141 AssetInfoDescAtom::AssetInfoDescAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
142         : FullAtom(fp, size, type)
143 {
144     _pAssetInfoBaseParser = NULL;
145     if (_success)
146     {
147         uint32 count = getDefaultSize();
148 
149         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
150 
151         if (!(_pAssetInfoBaseParser->GetMP4Success()))
152         {
153             _success = false;
154             _mp4ErrorCode = READ_UDTA_DSCP_FAILED;
155             return;
156         }
157     }
158     else
159     {
160         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
161         {
162             _mp4ErrorCode = READ_UDTA_DSCP_FAILED;
163         }
164     }
165 }
166 
~AssetInfoDescAtom()167 AssetInfoDescAtom::~AssetInfoDescAtom()
168 {
169     if (_pAssetInfoBaseParser != NULL)
170     {
171         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
172     }
173 }
174 
AssetInfoPerformerAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)175 AssetInfoPerformerAtom::AssetInfoPerformerAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
176         : FullAtom(fp, size, type)
177 {
178     _pAssetInfoBaseParser = NULL;
179 
180     if (_success)
181     {
182         uint32 count = getDefaultSize();
183 
184         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
185 
186         if (!(_pAssetInfoBaseParser->GetMP4Success()))
187         {
188             _success = false;
189             _mp4ErrorCode = READ_UDTA_PERF_FAILED;
190             return;
191         }
192     }
193     else
194     {
195         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
196         {
197             _mp4ErrorCode = READ_UDTA_PERF_FAILED;
198         }
199     }
200 }
201 
~AssetInfoPerformerAtom()202 AssetInfoPerformerAtom::~AssetInfoPerformerAtom()
203 {
204     if (_pAssetInfoBaseParser != NULL)
205     {
206         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
207     }
208 }
209 
AssetInfoAuthorAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)210 AssetInfoAuthorAtom::AssetInfoAuthorAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
211         : FullAtom(fp, size, type)
212 {
213     _pAssetInfoBaseParser = NULL;
214 
215     if (_success)
216     {
217         uint32 count = getDefaultSize();
218 
219         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
220 
221         if (!(_pAssetInfoBaseParser->GetMP4Success()))
222         {
223             _success = false;
224             _mp4ErrorCode = READ_UDTA_AUTH_FAILED;
225             return;
226         }
227     }
228     else
229     {
230         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
231         {
232             _mp4ErrorCode = READ_UDTA_AUTH_FAILED;
233         }
234     }
235 }
236 
~AssetInfoAuthorAtom()237 AssetInfoAuthorAtom::~AssetInfoAuthorAtom()
238 {
239     if (_pAssetInfoBaseParser != NULL)
240     {
241         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
242     }
243 }
244 
AssetInfoGenreAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)245 AssetInfoGenreAtom::AssetInfoGenreAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
246         : FullAtom(fp, size, type)
247 {
248     _pAssetInfoBaseParser = NULL;
249 
250     if (_success)
251     {
252         uint32 count = getDefaultSize();
253 
254         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
255 
256         if (!(_pAssetInfoBaseParser->GetMP4Success()))
257         {
258             _success = false;
259             _mp4ErrorCode = READ_UDTA_GNRE_FAILED;
260             return;
261         }
262     }
263     else
264     {
265         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
266         {
267             _mp4ErrorCode = READ_UDTA_GNRE_FAILED;
268         }
269     }
270 }
271 
~AssetInfoGenreAtom()272 AssetInfoGenreAtom::~AssetInfoGenreAtom()
273 {
274     if (_pAssetInfoBaseParser != NULL)
275     {
276         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
277     }
278 }
279 
AssetInfoRatingAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)280 AssetInfoRatingAtom::AssetInfoRatingAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
281         : FullAtom(fp, size, type)
282 {
283     _pAssetInfoBaseParser = NULL;
284 
285     if (_success)
286     {
287         uint32 count = getDefaultSize();
288 
289         if (!AtomUtils::read32(fp, _ratingEntity))
290         {
291             _success = false;
292             _mp4ErrorCode = READ_UDTA_RTNG_FAILED;
293             return;
294         }
295         count += 4;
296 
297         if (!AtomUtils::read32(fp, _ratingCriteria))
298         {
299             _success = false;
300             _mp4ErrorCode = READ_UDTA_RTNG_FAILED;
301             return;
302         }
303         count += 4;
304 
305         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
306         if (!(_pAssetInfoBaseParser->GetMP4Success()))
307         {
308             _success = false;
309             _mp4ErrorCode = READ_UDTA_RTNG_FAILED;
310             return;
311         }
312         OSCL_wHeapString<OsclMemAllocator> addnlratingInfo;
313 
314         addnlratingInfo += _STRLIT_WCHAR(";rating-criteria=");
315         char Criteria[4];
316         oscl_memset(Criteria, 0, 4*sizeof(char));
317         UInt32ToFourChar(_ratingCriteria, Criteria);
318         oscl_wchar wCriteria[5];
319         oscl_UTF8ToUnicode(Criteria, 4, wCriteria, 5);
320         addnlratingInfo += wCriteria;
321 
322         addnlratingInfo += _STRLIT_WCHAR(";rating-entity=");
323         char Entity[4];
324         oscl_memset(Entity, 0, 4);
325         UInt32ToFourChar(_ratingEntity, Entity);
326         oscl_wchar wEntity[5];
327         oscl_UTF8ToUnicode(Entity, 4, wEntity, 5);
328         addnlratingInfo += wEntity;
329 
330         _pAssetInfoBaseParser->updateInfoNotice(addnlratingInfo);
331     }
332     else
333     {
334         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
335         {
336             _mp4ErrorCode = READ_UDTA_RTNG_FAILED;
337         }
338     }
339 }
340 
~AssetInfoRatingAtom()341 AssetInfoRatingAtom::~AssetInfoRatingAtom()
342 {
343     if (_pAssetInfoBaseParser != NULL)
344     {
345         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
346     }
347 }
348 
AssetInfoClassificationAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)349 AssetInfoClassificationAtom::AssetInfoClassificationAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
350         : FullAtom(fp, size, type)
351 {
352     _pAssetInfoBaseParser = NULL;
353 
354     if (_success)
355     {
356         uint32 count = getDefaultSize();
357 
358         if (!AtomUtils::read32(fp, _classificationEntity))
359         {
360             _success = false;
361             _mp4ErrorCode = READ_UDTA_CLSF_FAILED;
362             return;
363         }
364         count += 4;
365 
366         if (!AtomUtils::read16(fp, _classificationTable))
367         {
368             _success = false;
369             _mp4ErrorCode = READ_UDTA_CLSF_FAILED;
370             return;
371         }
372         count += 2;
373 
374         PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
375 
376         if (!(_pAssetInfoBaseParser->GetMP4Success()))
377         {
378             _success = false;
379             _mp4ErrorCode = READ_UDTA_CLSF_FAILED;
380             return;
381         }
382         OSCL_wHeapString<OsclMemAllocator> addnlclassificationInfo;
383 
384         addnlclassificationInfo += _STRLIT_WCHAR(";classification-table=");
385         char Table[4];
386         oscl_memset(Table, 0, 4);
387         oscl_snprintf(Table, 4, _STRLIT_CHAR("%d"), _classificationTable);
388         oscl_wchar wTable[5];
389         oscl_UTF8ToUnicode(Table, 4, wTable, 5);
390         addnlclassificationInfo += wTable;
391 
392         addnlclassificationInfo += _STRLIT_WCHAR(";classification-entity=");
393         char Entity[4];
394         oscl_memset(Entity, 0, 4);
395         UInt32ToFourChar(_classificationEntity, Entity);
396         oscl_wchar wEntity[5];
397         oscl_UTF8ToUnicode(Entity, 4, wEntity, 5);
398         addnlclassificationInfo += wEntity;
399 
400         _pAssetInfoBaseParser->updateInfoNotice(addnlclassificationInfo);
401     }
402     else
403     {
404         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
405         {
406             _mp4ErrorCode = READ_UDTA_CLSF_FAILED;
407         }
408     }
409 }
410 
~AssetInfoClassificationAtom()411 AssetInfoClassificationAtom::~AssetInfoClassificationAtom()
412 {
413     if (_pAssetInfoBaseParser != NULL)
414     {
415         PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
416     }
417 };
418 
419 
AssestInfoKeyWord(MP4_FF_FILE * fp)420 AssestInfoKeyWord::AssestInfoKeyWord(MP4_FF_FILE *fp)
421 {
422     int32 currfilePos = AtomUtils::getCurrentFilePosition(fp);
423 
424     uint8 keywordSize = 0;
425     if (!AtomUtils::read8(fp, keywordSize))
426     {
427         return;
428     }
429     uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
430 
431     uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
432 
433 
434     if (byteOrderMask == BYTE_ORDER_MASK)
435     {
436         _charType = ORIGINAL_CHAR_TYPE_UTF16;
437         if (!AtomUtils::read16(fp, byteOrderMask))
438         {
439             return;
440         }
441 
442         // Check to see if the string is actually null-terminated
443         if (!AtomUtils::readNullTerminatedUnicodeString(fp, _defaultKeyWord))
444         {
445             return;
446         }
447     }
448     else
449     {
450         _charType = ORIGINAL_CHAR_TYPE_UTF8;
451         // Check to see if the string is actually null-terminated
452 
453         if (!AtomUtils::readNullTerminatedString(fp, _defaultKeyWord))
454         {
455             return;
456         }
457     }
458     int32 newfilePos = AtomUtils::getCurrentFilePosition(fp);
459     size = newfilePos - currfilePos;
460 }
461 
462 
AssetInfoKeyWordAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)463 AssetInfoKeyWordAtom::AssetInfoKeyWordAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
464         : FullAtom(fp, size, type)
465 
466 {
467     _pAssetInfoKeyWordVec = NULL;
468 
469     PV_MP4_FF_NEW(fp->auditCB, assestInfoKeyWordVecType, (), _pAssetInfoKeyWordVec);
470 
471     if (_success)
472     {
473         uint32 count = getDefaultSize();
474 
475         if (!AtomUtils::read16(fp, _langCode))
476         {
477             _success = false;
478             _mp4ErrorCode = READ_UDTA_KYWD_FAILED;
479             return;
480         }
481         count += 2;
482 
483         if (!AtomUtils::read8(fp, _keyWordCount))
484         {
485             _success = false;
486             _mp4ErrorCode = READ_UDTA_KYWD_FAILED;
487             return;
488         }
489         count += 1;
490 
491         for (uint8 i = 0; i < _keyWordCount; i++)
492         {
493             AssestInfoKeyWord * pAssetInfoKeyWord = NULL;
494 
495             PV_MP4_FF_NEW(fp->auditCB, AssestInfoKeyWord, (fp), pAssetInfoKeyWord);
496 
497             if (pAssetInfoKeyWord == NULL)
498             {
499                 _success = false;
500                 _mp4ErrorCode = READ_UDTA_KYWD_FAILED;
501                 return;
502             }
503             (*_pAssetInfoKeyWordVec).push_back(pAssetInfoKeyWord);
504             count += pAssetInfoKeyWord->size;
505         }
506         if (count < size)
507         {
508             int32 tmp = size - count;
509             AtomUtils::seekFromCurrPos(fp, tmp);
510         }
511     }
512     else
513     {
514         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
515         {
516             _mp4ErrorCode = READ_UDTA_KYWD_FAILED;
517         }
518     }
519 }
520 
~AssetInfoKeyWordAtom()521 AssetInfoKeyWordAtom::~AssetInfoKeyWordAtom()
522 {
523     for (uint32 i = 0; i < _pAssetInfoKeyWordVec->size(); i++)
524     {
525         PV_MP4_FF_DELETE(NULL, AssestInfoKeyWord, (*_pAssetInfoKeyWordVec)[i]);
526         (*_pAssetInfoKeyWordVec)[i] = NULL;
527     }
528     PV_MP4_FF_TEMPLATED_DELETE(NULL, assestInfoKeyWordVecType, Oscl_Vector, _pAssetInfoKeyWordVec);
529 };
530 
getKeyWordAt(int32 index)531 OSCL_wString& AssetInfoKeyWordAtom::getKeyWordAt(int32 index)
532 {
533     MP4FFParserOriginalCharEnc charType;
534     if ((_pAssetInfoKeyWordVec->size() == 0) ||
535             ((uint32)index >= (_pAssetInfoKeyWordVec->size())))
536     {
537         return _defaultKeyWord;
538     }
539     else
540     {
541         return ((*_pAssetInfoKeyWordVec)[index])->getInfoNotice(charType);
542     }
543 }
544 
AssetInfoLocationAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)545 AssetInfoLocationAtom::AssetInfoLocationAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
546         : FullAtom(fp, size, type)
547 {
548     _pLocationStruct = NULL;
549 
550     int32 count = getSize() - getDefaultSize();
551 
552     if (_success)
553     {
554         PV_MP4_FF_NEW(fp->auditCB, PvmfAssetInfo3GPPLocationStruct, (), _pLocationStruct);
555 
556         if (!AtomUtils::read16(fp, _langCode))
557         {
558             _success = false;
559             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
560             return;
561         }
562 
563         count -= 2;
564 
565         _pLocationStruct->_langCode = _langCode;
566 
567         uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
568 
569         uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
570 
571         if (byteOrderMask == BYTE_ORDER_MASK)
572         {
573             _charType = ORIGINAL_CHAR_TYPE_UTF16;
574             if (!AtomUtils::read16(fp, byteOrderMask))
575             {
576                 _success = false;
577                 return;
578             }
579 
580             count -= 2;
581             if (!AtomUtils::readNullTerminatedUnicodeString(fp, _defaultNotice))
582             {
583                 _success = false;
584                 return;
585             }
586             count -= (_defaultNotice.get_size() + 1) * 2;
587         }
588         else
589         {
590             _charType = ORIGINAL_CHAR_TYPE_UTF8;
591             // Check to see if the string is actually null-terminated
592             if (!AtomUtils::readNullTerminatedString(fp, _defaultNotice))
593             {
594                 _success = false;
595                 return;
596             }
597             count -= _defaultNotice.get_size() + 1;
598         }
599 
600         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _defaultNotice.get_size() + 1, _pLocationStruct->_location_name);
601         oscl_strncpy(_pLocationStruct->_location_name, _defaultNotice.get_str(), _defaultNotice.get_size());
602         _pLocationStruct->_location_name[_defaultNotice.get_size()] = 0;
603 
604         if (_defaultNotice.get_size() > size)
605         {
606             _pLocationStruct->_location_name = NULL;
607             _pLocationStruct->_role = 0;
608             _pLocationStruct->_longitude = 0;
609             _pLocationStruct->_latitude = 0;
610             _pLocationStruct->_altitude = 0;
611             _pLocationStruct->_additional_notes = NULL;
612             _pLocationStruct->_astronomical_body = NULL;
613             if (count > 0)
614                 AtomUtils::seekFromCurrPos(fp, count);
615             return;
616         }
617 
618         if (!AtomUtils::read8(fp, _role))
619         {
620             _success = false;
621             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
622             return;
623         }
624         _pLocationStruct->_role = _role;
625         count -= 1;
626 
627         if (!AtomUtils::read32(fp, _longitude))
628         {
629             _success = false;
630             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
631             return;
632         }
633         _pLocationStruct->_longitude = _longitude ;
634         count -= 4;
635 
636         if (!AtomUtils::read32(fp, _latitude))
637         {
638             _success = false;
639             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
640             return;
641         }
642         _pLocationStruct->_latitude = _latitude;
643         count -= 4;
644 
645         if (!AtomUtils::read32(fp, _altitude))
646         {
647             _success = false;
648             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
649             return;
650         }
651         _pLocationStruct->_altitude = _altitude;
652         count -= 4;
653 
654         temp = AtomUtils::peekNextNthBytes(fp, 1);
655 
656         byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
657 
658         if (byteOrderMask == BYTE_ORDER_MASK)
659         {
660             _charType = ORIGINAL_CHAR_TYPE_UTF16;
661             if (!AtomUtils::read16(fp, byteOrderMask))
662             {
663                 _success = false;
664                 return;
665             }
666             count -= 2;
667 
668             if (!AtomUtils::readNullTerminatedUnicodeString(fp, _astronomical_body))
669             {
670                 _success = false;
671                 return;
672             }
673             count -= (_astronomical_body.get_size() + 1) * 2;
674         }
675         else
676         {
677             _charType = ORIGINAL_CHAR_TYPE_UTF8;
678             // Check to see if the string is actually null-terminated
679             if (!AtomUtils::readNullTerminatedString(fp, _astronomical_body))
680             {
681                 _success = false;
682                 return;
683             }
684             count -= _astronomical_body.get_size() + 1;
685         }
686         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _astronomical_body.get_size() + 1, _pLocationStruct->_astronomical_body);
687         oscl_strncpy(_pLocationStruct->_astronomical_body, _astronomical_body.get_str(), _astronomical_body.get_size());
688         _pLocationStruct->_astronomical_body[_astronomical_body.get_size()] = 0;
689 
690         if (_astronomical_body.get_size() > size)
691         {
692             _pLocationStruct->_additional_notes = NULL;
693             _pLocationStruct->_astronomical_body = NULL;
694             if (count > 0)
695                 AtomUtils::seekFromCurrPos(fp, count);
696 
697             return;
698         }
699 
700         temp = AtomUtils::peekNextNthBytes(fp, 1);
701 
702         byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
703 
704         if (byteOrderMask == BYTE_ORDER_MASK)
705         {
706             _charType = ORIGINAL_CHAR_TYPE_UTF16;
707             if (!AtomUtils::read16(fp, byteOrderMask))
708             {
709                 _success = false;
710                 return;
711             }
712             count -= 2;
713 
714             if (!AtomUtils::readNullTerminatedUnicodeString(fp, _additional_notes))
715             {
716                 _success = false;
717                 return;
718             }
719             count -= (_additional_notes.get_size() + 1) * 2;
720         }
721         else
722         {
723             _charType = ORIGINAL_CHAR_TYPE_UTF8;
724             // Check to see if the string is actually null-terminated
725             if (!AtomUtils::readNullTerminatedString(fp, _additional_notes))
726             {
727                 _success = false;
728                 return;
729             }
730             count -= _additional_notes.get_size() + 1;
731         }
732         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _additional_notes.get_size() + 1, _pLocationStruct->_additional_notes);
733         oscl_strncpy(_pLocationStruct->_additional_notes, _additional_notes.get_str(), _additional_notes.get_size());
734         _pLocationStruct->_additional_notes[_additional_notes.get_size()] = 0;
735 
736         if (_additional_notes.get_size() > size)
737         {
738             _pLocationStruct->_additional_notes = NULL;
739             if (count > 0)
740                 AtomUtils::seekFromCurrPos(fp, count);
741 
742             return;
743         }
744     }
745     if (count > 0)
746         AtomUtils::seekFromCurrPos(fp, count);
747 }
748 
~AssetInfoLocationAtom()749 AssetInfoLocationAtom::~AssetInfoLocationAtom()
750 {
751     if (_pLocationStruct != NULL)
752     {
753         if (_pLocationStruct->_location_name != NULL)
754         {
755             PV_MP4_ARRAY_DELETE(NULL, _pLocationStruct->_location_name);
756             _pLocationStruct->_location_name = NULL;
757         }
758         if (_pLocationStruct->_astronomical_body != NULL)
759         {
760             PV_MP4_ARRAY_DELETE(NULL, _pLocationStruct->_astronomical_body);
761             _pLocationStruct->_astronomical_body = NULL;
762         }
763         if (_pLocationStruct->_additional_notes != NULL)
764         {
765             PV_MP4_ARRAY_DELETE(NULL, _pLocationStruct->_additional_notes);
766             _pLocationStruct->_additional_notes = NULL;
767         }
768     }
769     PV_MP4_FF_DELETE(NULL, PvmfAssetInfo3GPPLocationStruct, _pLocationStruct);
770     _pLocationStruct = NULL;
771 }
772 
AssetInfoAlbumAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)773 AssetInfoAlbumAtom::AssetInfoAlbumAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
774         : FullAtom(fp, size, type)
775 {
776     int32 count = getSize() - getDefaultSize();
777     if (_success)
778     {
779         if (!AtomUtils::read16(fp, _langCode))
780         {
781             _success = false;
782             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
783             return;
784         }
785         count -= 2;
786 
787         uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
788 
789         uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
790 
791         if (byteOrderMask == BYTE_ORDER_MASK)
792         {
793             _charType = ORIGINAL_CHAR_TYPE_UTF16;
794             if (!AtomUtils::read16(fp, byteOrderMask))
795             {
796                 _success = false;
797                 return;
798             }
799             count -= 2;
800 
801             if (!AtomUtils::readNullTerminatedUnicodeString(fp, _defaultNotice))
802             {
803                 _success = false;
804                 return;
805             }
806             count -= (_defaultNotice.get_size() + 1) * 2;
807         }
808         else
809         {
810             _charType = ORIGINAL_CHAR_TYPE_UTF8;
811             // Check to see if the string is actually null-terminated
812             if (!AtomUtils::readNullTerminatedString(fp, _defaultNotice))
813             {
814                 _success = false;
815                 return;
816             }
817             count -= _defaultNotice.get_size() + 1;
818         }
819         if (_defaultNotice.get_size() > size)
820         {
821             _defaultNotice = NULL;
822             _trackNumber = 0;
823 
824             if (count > 0)
825                 AtomUtils::seekFromCurrPos(fp, count);
826 
827             return;
828         }
829         if (count > 0)
830         {
831             if (!AtomUtils::read8(fp, _trackNumber))
832             {
833                 _success = false;
834                 _mp4ErrorCode = READ_UDTA_LOC_FAILED;
835                 return;
836             }
837             count -= 1;
838         }
839     }
840     if (count > 0)
841         AtomUtils::seekFromCurrPos(fp, count);
842 
843 }
844 
AssetInfoRecordingYearAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)845 AssetInfoRecordingYearAtom::AssetInfoRecordingYearAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
846         : FullAtom(fp, size, type)
847 {
848     if (_success)
849     {
850         if (!AtomUtils::read16(fp, _recordingYear))
851         {
852             _success = false;
853             _mp4ErrorCode = READ_UDTA_LOC_FAILED;
854             return;
855         }
856     }
857 }
858 
859