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
27 ///////////////////////////////////////////////////////////////////////////////
29 MP4MvhdAtom::MP4MvhdAtom(MP4File &file)
30 : MP4Atom(file, "mvhd")
35 void MP4MvhdAtom::AddProperties(uint8_t version)
39 new MP4Integer64Property(*this, "creationTime"));
41 new MP4Integer64Property(*this, "modificationTime"));
44 new MP4Integer32Property(*this, "creationTime"));
46 new MP4Integer32Property(*this, "modificationTime"));
50 new MP4Integer32Property(*this, "timeScale"));
54 new MP4Integer64Property(*this, "duration"));
57 new MP4Integer32Property(*this, "duration"));
60 MP4Float32Property* pProp;
62 pProp = new MP4Float32Property(*this, "rate");
63 pProp->SetFixed32Format();
64 AddProperty(pProp); /* 6 */
66 pProp = new MP4Float32Property(*this, "volume");
67 pProp->SetFixed16Format();
68 AddProperty(pProp); /* 7 */
70 AddReserved(*this, "reserved1", 70); /* 8 */
73 new MP4Integer32Property(*this, "nextTrackId"));
76 void MP4MvhdAtom::Generate()
78 uint8_t version = m_File.Use64Bits(GetType()) ? 1 : 0;
80 AddProperties(version);
84 // set creation and modification times
85 MP4Timestamp now = MP4GetAbsTimestamp();
87 ((MP4Integer64Property*)m_pProperties[2])->SetValue(now);
88 ((MP4Integer64Property*)m_pProperties[3])->SetValue(now);
90 ((MP4Integer32Property*)m_pProperties[2])->SetValue(now);
91 ((MP4Integer32Property*)m_pProperties[3])->SetValue(now);
94 ((MP4Integer32Property*)m_pProperties[4])->SetValue(1000);
96 ((MP4Float32Property*)m_pProperties[6])->SetValue(1.0);
97 ((MP4Float32Property*)m_pProperties[7])->SetValue(1.0);
99 // property reserved has non-zero fixed values
100 static uint8_t reserved[70] = {
102 0x00, 0x00, 0x00, 0x00,
103 0x00, 0x00, 0x00, 0x00,
104 0x00, 0x01, 0x00, 0x00,
105 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x01, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00,
112 0x40, 0x00, 0x00, 0x00,
113 0x00, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00,
115 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00,
118 0x00, 0x00, 0x00, 0x00,
120 m_pProperties[8]->SetReadOnly(false);
121 ((MP4BytesProperty*)m_pProperties[8])->
122 SetValue(reserved, sizeof(reserved));
123 m_pProperties[8]->SetReadOnly(true);
126 ((MP4Integer32Property*)m_pProperties[9])->SetValue(1);
129 void MP4MvhdAtom::Read()
131 /* read atom version */
132 ReadProperties(0, 1);
134 /* need to create the properties based on the atom version */
135 AddProperties(GetVersion());
137 /* now we can read the remaining properties */
140 Skip(); // to end of atom
143 ///////////////////////////////////////////////////////////////////////////////
146 } // namespace mp4v2::impl