annotate Input/aac/libmp4v2/atom_mdhd.cpp @ 53:710d8b266d7e trunk

[svn] Cleaning autogenerated files
author msameer
date Thu, 27 Oct 2005 12:54:05 -0700
parents 6a86fdd4dea4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
1 /*
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
2 * The contents of this file are subject to the Mozilla Public
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
3 * License Version 1.1 (the "License"); you may not use this file
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
4 * except in compliance with the License. You may obtain a copy of
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
5 * the License at http://www.mozilla.org/MPL/
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
6 *
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
7 * Software distributed under the License is distributed on an "AS
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
9 * implied. See the License for the specific language governing
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
10 * rights and limitations under the License.
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
11 *
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
12 * The Original Code is MPEG4IP.
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
13 *
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
15 * Portions created by Cisco Systems Inc. are
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
16 * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
17 *
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
18 * Contributor(s):
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
19 * Dave Mackie dmackie@cisco.com
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
20 */
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
21
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
22 #include "mp4common.h"
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
23
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
24 MP4MdhdAtom::MP4MdhdAtom()
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
25 : MP4Atom("mdhd")
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
26 {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
27 AddVersionAndFlags();
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
28 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
29
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
30 void MP4MdhdAtom::AddProperties(u_int8_t version)
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
31 {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
32 if (version == 1) {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
33 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
34 new MP4Integer64Property("creationTime"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
35 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
36 new MP4Integer64Property("modificationTime"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
37 } else {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
38 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
39 new MP4Integer32Property("creationTime"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
40 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
41 new MP4Integer32Property("modificationTime"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
42 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
43
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
44 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
45 new MP4Integer32Property("timeScale"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
46
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
47 if (version == 1) {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
48 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
49 new MP4Integer64Property("duration"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
50 } else {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
51 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
52 new MP4Integer32Property("duration"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
53 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
54
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
55 AddProperty(
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
56 new MP4Integer16Property("language"));
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
57 AddReserved("reserved", 2);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
58 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
59
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
60 void MP4MdhdAtom::Generate()
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
61 {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
62 u_int8_t version = m_pFile->Use64Bits(GetType()) ? 1 : 0;
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
63 SetVersion(version);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
64 AddProperties(version);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
65
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
66 MP4Atom::Generate();
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
67
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
68 // set creation and modification times
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
69 MP4Timestamp now = MP4GetAbsTimestamp();
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
70 if (version == 1) {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
71 ((MP4Integer64Property*)m_pProperties[2])->SetValue(now);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
72 ((MP4Integer64Property*)m_pProperties[3])->SetValue(now);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
73 } else {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
74 ((MP4Integer32Property*)m_pProperties[2])->SetValue(now);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
75 ((MP4Integer32Property*)m_pProperties[3])->SetValue(now);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
76 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
77 }
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
78
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
79 void MP4MdhdAtom::Read()
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
80 {
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
81 /* read atom version */
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
82 ReadProperties(0, 1);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
83
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
84 /* need to create the properties based on the atom version */
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
85 AddProperties(GetVersion());
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
86
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
87 /* now we can read the remaining properties */
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
88 ReadProperties(1);
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
89
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
90 Skip(); // to end of atom
6a86fdd4dea4 [svn] Replacement libmp4v2.
nenolod
parents:
diff changeset
91 }