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 "src/impl.h"
23
24 namespace mp4v2 {
25 namespace impl {
26
27 ///////////////////////////////////////////////////////////////////////////////
28
MP4ODUpdateDescriptor(MP4Atom & parentAtom)29 MP4ODUpdateDescriptor::MP4ODUpdateDescriptor(MP4Atom& parentAtom)
30 : MP4Descriptor(parentAtom, MP4ODUpdateODCommandTag)
31 {
32 // just a container for ObjectDescriptors
33 AddProperty( /* 0 */
34 new MP4DescriptorProperty(parentAtom, NULL,
35 MP4FileODescrTag, 0, Required, Many));
36 }
37
MP4ODRemoveDescriptor(MP4Atom & parentAtom)38 MP4ODRemoveDescriptor::MP4ODRemoveDescriptor(MP4Atom& parentAtom)
39 : MP4Descriptor(parentAtom, MP4ODRemoveODCommandTag)
40 {
41 MP4Integer32Property* pCount =
42 new MP4Integer32Property(parentAtom, "entryCount");
43 pCount->SetImplicit();
44 AddProperty(pCount); /* 0 */
45
46 MP4TableProperty* pTable =
47 new MP4TableProperty(parentAtom, "entries", pCount);
48 AddProperty(pTable); /* 1 */
49
50 pTable->AddProperty( /* 1, 0 */
51 new MP4BitfieldProperty(pTable->GetParentAtom(), "objectDescriptorId", 10));
52 }
53
Read(MP4File & file)54 void MP4ODRemoveDescriptor::Read(MP4File& file)
55 {
56 // table entry count computed from descriptor size
57 ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(false);
58 ((MP4Integer32Property*)m_pProperties[0])->SetValue((m_size * 8) / 10);
59 ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(true);
60
61 MP4Descriptor::Read(file);
62 }
63
MP4ESUpdateDescriptor(MP4Atom & parentAtom)64 MP4ESUpdateDescriptor::MP4ESUpdateDescriptor(MP4Atom& parentAtom)
65 : MP4Descriptor(parentAtom, MP4ESUpdateODCommandTag)
66 {
67 AddProperty( /* 0 */
68 new MP4BitfieldProperty(parentAtom, "objectDescriptorId", 10));
69 AddProperty( /* 1 */
70 new MP4BitfieldProperty(parentAtom, "pad", 6));
71 AddProperty( /* 2 */
72 new MP4DescriptorProperty(parentAtom, "esIdRefs",
73 MP4ESIDRefDescrTag, 0, Required, Many));
74 }
75
76 // LATER might be able to combine with ESUpdateDescriptor
MP4ESRemoveDescriptor(MP4Atom & parentAtom)77 MP4ESRemoveDescriptor::MP4ESRemoveDescriptor(MP4Atom& parentAtom)
78 : MP4Descriptor(parentAtom, MP4ESRemoveODCommandTag)
79 {
80 AddProperty( /* 0 */
81 new MP4BitfieldProperty(parentAtom, "objectDescriptorId", 10));
82 AddProperty( /* 1 */
83 new MP4BitfieldProperty(parentAtom, "pad", 6));
84 AddProperty( /* 2 */
85 new MP4DescriptorProperty(parentAtom, "esIdRefs",
86 MP4ESIDRefDescrTag, 0, Required, Many));
87 }
88
CreateODCommand(MP4Atom & parentAtom,uint8_t tag)89 MP4Descriptor* CreateODCommand(MP4Atom& parentAtom, uint8_t tag)
90 {
91 MP4Descriptor* pDescriptor = NULL;
92
93 switch (tag) {
94 case MP4ODUpdateODCommandTag:
95 pDescriptor = new MP4ODUpdateDescriptor(parentAtom);
96 break;
97 case MP4ODRemoveODCommandTag:
98 pDescriptor = new MP4ODRemoveDescriptor(parentAtom);
99 break;
100 case MP4ESUpdateODCommandTag:
101 pDescriptor = new MP4ESUpdateDescriptor(parentAtom);
102 break;
103 case MP4ESRemoveODCommandTag:
104 pDescriptor = new MP4ESRemoveDescriptor(parentAtom);
105 break;
106 }
107 return pDescriptor;
108 }
109
110 ///////////////////////////////////////////////////////////////////////////////
111
112 }
113 } // namespace mp4v2::impl
114