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
29 #if 1
MP4QosDescriptorBase(MP4Atom & parentAtom,uint8_t tag)30 MP4QosDescriptorBase::MP4QosDescriptorBase (MP4Atom& parentAtom, uint8_t tag)
31 : MP4Descriptor(parentAtom, tag)
32 {
33 switch (tag) {
34 case MP4QosDescrTag:
35 AddProperty( /* 0 */
36 new MP4Integer8Property(parentAtom, "predefined"));
37 AddProperty( /* 1 */
38 new MP4QosQualifierProperty(parentAtom, "qualifiers",
39 MP4QosTagsStart,
40 MP4QosTagsEnd, Optional, Many));
41 break;
42 case MP4MaxDelayQosTag:
43 AddProperty( /* 0 */
44 new MP4Integer32Property(parentAtom, "maxDelay"));
45 break;
46 case MP4PrefMaxDelayQosTag:
47 AddProperty( /* 0 */
48 new MP4Integer32Property(parentAtom, "prefMaxDelay"));
49 break;
50 case MP4LossProbQosTag:
51 AddProperty( /* 0 */
52 new MP4Float32Property(parentAtom, "lossProb"));
53 break;
54 case MP4MaxGapLossQosTag:
55 AddProperty( /* 0 */
56 new MP4Integer32Property(parentAtom, "maxGapLoss"));
57 break;
58 case MP4MaxAUSizeQosTag:
59 AddProperty( /* 0 */
60 new MP4Integer32Property(parentAtom, "maxAUSize"));
61 break;
62 case MP4AvgAUSizeQosTag:
63 AddProperty( /* 0 */
64 new MP4Integer32Property(parentAtom, "avgAUSize"));
65 break;
66 case MP4MaxAURateQosTag:
67 AddProperty( /* 0 */
68 new MP4Integer32Property(parentAtom, "maxAURate"));
69 break;
70 }
71 }
72
73 #else
74 MP4QosDescriptor::MP4QosDescriptor(MP4Atom &parentAtom)
75 : MP4Descriptor(parentAtom, MP4QosDescrTag)
76 {
77 AddProperty( /* 0 */
78 new MP4Integer8Property(parentAtom, "predefined"));
79 AddProperty( /* 1 */
80 new MP4QosQualifierProperty(parentAtom, "qualifiers",
81 MP4QosTagsStart, MP4QosTagsEnd, Optional, Many));
82 }
83
84 MP4MaxDelayQosQualifier::MP4MaxDelayQosQualifier(MP4Atom &parentAtom)
85 : MP4QosQualifier(parentAtom, MP4MaxDelayQosTag)
86 {
87 AddProperty( /* 0 */
88 new MP4Integer32Property(parentAtom, "maxDelay"));
89 }
90
91 MP4PrefMaxDelayQosQualifier::MP4PrefMaxDelayQosQualifier(MP4Atom &parentAtom)
92 : MP4QosQualifier(parentAtom, MP4PrefMaxDelayQosTag)
93 {
94 AddProperty( /* 0 */
95 new MP4Integer32Property(parentAtom, "prefMaxDelay"));
96 }
97
98 MP4LossProbQosQualifier::MP4LossProbQosQualifier(MP4Atom &parentAtom)
99 : MP4QosQualifier(parentAtom, MP4LossProbQosTag)
100 {
101 AddProperty( /* 0 */
102 new MP4Float32Property(parentAtom, "lossProb"));
103 }
104
105 MP4MaxGapLossQosQualifier::MP4MaxGapLossQosQualifier(MP4Atom &parentAtom)
106 : MP4QosQualifier(parentAtom, MP4MaxGapLossQosTag)
107 {
108 AddProperty( /* 0 */
109 new MP4Integer32Property(parentAtom, "maxGapLoss"));
110 }
111
112 MP4MaxAUSizeQosQualifier::MP4MaxAUSizeQosQualifier(MP4Atom &parentAtom)
113 : MP4QosQualifier(parentAtom, MP4MaxAUSizeQosTag)
114 {
115 AddProperty( /* 0 */
116 new MP4Integer32Property(parentAtom, "maxAUSize"));
117 }
118
119 MP4AvgAUSizeQosQualifier::MP4AvgAUSizeQosQualifier(MP4Atom &parentAtom)
120 : MP4QosQualifier(parentAtom, MP4AvgAUSizeQosTag)
121 {
122 AddProperty( /* 0 */
123 new MP4Integer32Property(parentAtom, "avgAUSize"));
124 }
125
126 MP4MaxAURateQosQualifier::MP4MaxAURateQosQualifier(MP4Atom &parentAtom)
127 : MP4QosQualifier(parentAtom, MP4MaxAURateQosTag)
128 {
129 AddProperty( /* 0 */
130 new MP4Integer32Property(parentAtom, "maxAURate"));
131 }
132 #endif
MP4UnknownQosQualifier(MP4Atom & parentAtom)133 MP4UnknownQosQualifier::MP4UnknownQosQualifier(MP4Atom &parentAtom)
134 : MP4Descriptor(parentAtom)
135 {
136 AddProperty( /* 0 */
137 new MP4BytesProperty(parentAtom, "data"));
138 }
139
Read(MP4File & file)140 void MP4UnknownQosQualifier::Read(MP4File& file)
141 {
142 ReadHeader(file);
143
144 /* byte properties need to know how long they are before reading */
145 ((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size);
146
147 ReadProperties(file);
148 }
149
CreateDescriptor(MP4Atom & parentAtom,uint8_t tag)150 MP4Descriptor* MP4QosQualifierProperty::CreateDescriptor(MP4Atom &parentAtom, uint8_t tag)
151 {
152 MP4Descriptor* pDescriptor = NULL;
153 switch (tag) {
154 case MP4MaxDelayQosTag:
155 case MP4PrefMaxDelayQosTag:
156 case MP4LossProbQosTag:
157 case MP4MaxGapLossQosTag:
158 case MP4MaxAUSizeQosTag:
159 case MP4AvgAUSizeQosTag:
160 case MP4MaxAURateQosTag:
161 pDescriptor = new MP4QosDescriptorBase(parentAtom, tag);
162 break;
163 default:
164 pDescriptor = new MP4UnknownQosQualifier(parentAtom);
165 pDescriptor->SetTag(tag);
166 }
167
168 return pDescriptor;
169 }
170
171 ///////////////////////////////////////////////////////////////////////////////
172
173 }
174 } // namespace mp4v2::impl
175