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 ESDAtom Class */
21 /* ------------------------------------------------------------------- */
22 /*********************************************************************************/
23 /*
24 This ESDAtom Class provides the offset between decoding
25 time and composition time.
26 */
27
28
29 #define IMPLEMENT_ESDAtom
30
31 #include "esdatom.h"
32 #include "atomdefs.h"
33 #include "atomutils.h"
34
35
ESDAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)36 ESDAtom::ESDAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
37 : FullAtom(fp, size, type)
38 {
39 _pdescriptor = NULL;
40
41 if (_success)
42 {
43 _pparent = NULL;
44
45 uint8 descr_tag = AtomUtils::peekNextByte(fp);
46
47 if (descr_tag == ES_DESCRIPTOR_TAG)
48 {
49 PV_MP4_FF_NEW(fp->auditCB, ESDescriptor, (fp), _pdescriptor);
50
51 if (!_pdescriptor->MP4Success())
52 {
53 _success = false;
54 _mp4ErrorCode = _pdescriptor->GetMP4Error();
55 }
56 else
57 {
58 _pdescriptor->setParent(this);
59 }
60 }
61 else
62 {
63 _success = false;
64 _mp4ErrorCode = READ_ESD_ATOM_FAILED;
65 }
66 }
67 else
68 {
69 if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
70 _mp4ErrorCode = READ_ESD_ATOM_FAILED;
71 }
72 }
73
74 // Destructor
~ESDAtom()75 ESDAtom::~ESDAtom()
76 {
77 if (_pdescriptor != NULL)
78 {
79 // Cleanup the ESDescriptor
80 PV_MP4_FF_DELETE(NULL, ESDescriptor, _pdescriptor);
81 }
82 }
83
84
85