61
|
1 /*
|
|
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/
|
|
6 *
|
|
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.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
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.
|
|
17 *
|
|
18 * Contributor(s):
|
|
19 * Dave Mackie dmackie@cisco.com
|
|
20 */
|
|
21
|
|
22 #include "mp4common.h"
|
|
23
|
|
24 MP4TrunAtom::MP4TrunAtom()
|
|
25 : MP4Atom("trun")
|
|
26 {
|
|
27 AddVersionAndFlags(); /* 0, 1 */
|
|
28 AddProperty( /* 2 */
|
|
29 new MP4Integer32Property("sampleCount"));
|
|
30 }
|
|
31
|
|
32 void MP4TrunAtom::AddProperties(u_int32_t flags)
|
|
33 {
|
|
34 if (flags & 0x01) {
|
|
35 // Note this is a signed 32 value
|
|
36 AddProperty(
|
|
37 new MP4Integer32Property("dataOffset"));
|
|
38 }
|
|
39 if (flags & 0x04) {
|
|
40 AddProperty(
|
|
41 new MP4Integer32Property("firstSampleFlags"));
|
|
42 }
|
|
43
|
|
44 MP4TableProperty* pTable =
|
|
45 new MP4TableProperty("samples",
|
|
46 (MP4Integer32Property *)m_pProperties[2]);
|
|
47 AddProperty(pTable);
|
|
48
|
|
49 if (flags & 0x100) {
|
|
50 pTable->AddProperty(
|
|
51 new MP4Integer32Property("sampleDuration"));
|
|
52 }
|
|
53 if (flags & 0x200) {
|
|
54 pTable->AddProperty(
|
|
55 new MP4Integer32Property("sampleSize"));
|
|
56 }
|
|
57 if (flags & 0x400) {
|
|
58 pTable->AddProperty(
|
|
59 new MP4Integer32Property("sampleFlags"));
|
|
60 }
|
|
61 if (flags & 0x800) {
|
|
62 pTable->AddProperty(
|
|
63 new MP4Integer32Property("sampleCompositionTimeOffset"));
|
|
64 }
|
|
65 }
|
|
66
|
|
67 void MP4TrunAtom::Read()
|
|
68 {
|
|
69 /* read atom version, flags, and sampleCount */
|
|
70 ReadProperties(0, 3);
|
|
71
|
|
72 /* need to create the properties based on the atom flags */
|
|
73 AddProperties(GetFlags());
|
|
74
|
|
75 /* now we can read the remaining properties */
|
|
76 ReadProperties(3);
|
|
77
|
|
78 Skip(); // to end of atom
|
|
79 }
|