2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is MPEG4IP.
14
* The Initial Developer of the Original Code is Cisco Systems Inc.
15
* Portions created by Cisco Systems Inc. are
16
* Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
19
* Dave Mackie dmackie@cisco.com
22
#include "mp4common.h"
24
MP4TkhdAtom::MP4TkhdAtom()
30
void MP4TkhdAtom::AddProperties(u_int8_t version)
34
new MP4Integer64Property("creationTime"));
36
new MP4Integer64Property("modificationTime"));
37
} else { // version == 0
39
new MP4Integer32Property("creationTime"));
41
new MP4Integer32Property("modificationTime"));
45
new MP4Integer32Property("trackId"));
46
AddReserved("reserved1", 4); /* 5 */
50
new MP4Integer64Property("duration"));
53
new MP4Integer32Property("duration"));
56
AddReserved("reserved2", 12); /* 7 */
58
MP4Float32Property* pProp;
60
pProp = new MP4Float32Property("volume");
61
pProp->SetFixed16Format();
62
AddProperty(pProp); /* 8 */
64
AddReserved("reserved3", 38); /* 9 */
66
pProp = new MP4Float32Property("width");
67
pProp->SetFixed32Format();
68
AddProperty(pProp); /* 10 */
70
pProp = new MP4Float32Property("height");
71
pProp->SetFixed32Format();
72
AddProperty(pProp); /* 11 */
75
void MP4TkhdAtom::Generate()
77
u_int8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0;
79
AddProperties(version);
83
// set creation and modification times
84
MP4Timestamp now = MP4GetAbsTimestamp();
86
((MP4Integer64Property*)m_pProperties[2])->SetValue(now);
87
((MP4Integer64Property*)m_pProperties[3])->SetValue(now);
89
((MP4Integer32Property*)m_pProperties[2])->SetValue(now);
90
((MP4Integer32Property*)m_pProperties[3])->SetValue(now);
93
// property reserved3 has non-zero fixed values
94
static u_int8_t reserved3[38] = {
96
0x00, 0x01, 0x00, 0x00,
97
0x00, 0x00, 0x00, 0x00,
98
0x00, 0x00, 0x00, 0x00,
99
0x00, 0x00, 0x00, 0x00,
100
0x00, 0x01, 0x00, 0x00,
101
0x00, 0x00, 0x00, 0x00,
102
0x00, 0x00, 0x00, 0x00,
103
0x00, 0x00, 0x00, 0x00,
104
0x40, 0x00, 0x00, 0x00,
106
m_pProperties[9]->SetReadOnly(false);
107
((MP4BytesProperty*)m_pProperties[9])->
108
SetValue(reserved3, sizeof(reserved3));
109
m_pProperties[9]->SetReadOnly(true);
112
void MP4TkhdAtom::Read()
114
/* read atom version */
115
ReadProperties(0, 1);
117
/* need to create the properties based on the atom version */
118
AddProperties(GetVersion());
120
/* now we can read the remaining properties */
123
Skip(); // to end of atom