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 TrackReferenceAtom Class */
21 /* ------------------------------------------------------------------- */
22 /*********************************************************************************/
23
24
25 #define IMPLEMENT_TrackReferenceAtom
26
27 #include "trackreferenceatom.h"
28 #include "atomutils.h"
29 #include "atomdefs.h"
30
31
32 // Stream-in Constructor
TrackReferenceAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)33 TrackReferenceAtom::TrackReferenceAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
34 : Atom(fp, size, type)
35 {
36 _ptrackReferenceTypeAtom = NULL;
37
38 if (_success)
39 {
40 _pparent = NULL;
41
42 uint32 count = _size - DEFAULT_ATOM_SIZE;
43
44 while (count > 0)
45 {
46 uint32 atomType = UNKNOWN_ATOM;
47 uint32 atomSize = 0;
48
49 AtomUtils::getNextAtomType(fp, atomSize, atomType);
50
51 // Currently we support only tref type "dpnd"
52 if (atomType == DPND_TRACK_REFERENCE_TYPE)
53 {
54 if (_ptrackReferenceTypeAtom == NULL)
55 {
56 PV_MP4_FF_NEW(fp->auditCB, TrackReferenceTypeAtom, (fp, atomSize, atomType), _ptrackReferenceTypeAtom);
57
58 if (!_ptrackReferenceTypeAtom->MP4Success())
59 {
60 _success = false;
61 _mp4ErrorCode = _ptrackReferenceTypeAtom->GetMP4Error();
62 return;
63 }
64 else
65 {
66 _ptrackReferenceTypeAtom->setParent(this);
67 count -= _ptrackReferenceTypeAtom->getSize();
68 }
69 }
70 else
71 {
72 // Multiple "dpnd" - skip
73 count -= atomSize;
74 atomSize -= DEFAULT_ATOM_SIZE;
75 AtomUtils::seekFromCurrPos(fp, atomSize);
76 }
77 }
78 else
79 {
80 count -= atomSize;
81 atomSize -= DEFAULT_ATOM_SIZE;
82 AtomUtils::seekFromCurrPos(fp, atomSize);
83 }
84 }
85 }
86 else
87 {
88 _mp4ErrorCode = READ_TRACK_REFERENCE_ATOM_FAILED;
89 }
90 }
91
92 // Destructor
~TrackReferenceAtom()93 TrackReferenceAtom::~TrackReferenceAtom()
94 {
95 if (_ptrackReferenceTypeAtom != NULL)
96 {
97 PV_MP4_FF_DELETE(NULL, TrackReferenceTypeAtom, _ptrackReferenceTypeAtom);
98 }
99 }
100
101
102