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
22
#include "mp4common.h"
24
MP4ContentClassDescriptor::MP4ContentClassDescriptor()
28
new MP4Integer32Property("classificationEntity"));
30
new MP4Integer16Property("classificationTable"));
32
new MP4BytesProperty("contentClassificationData"));
35
void MP4ContentClassDescriptor::Read(MP4File* pFile)
39
/* byte properties need to know how long they are before reading */
40
((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 6);
42
ReadProperties(pFile);
45
MP4KeywordDescriptor::MP4KeywordDescriptor()
49
new MP4BytesProperty("languageCode", 3));
51
new MP4BitfieldProperty("isUTF8String", 1));
53
new MP4BitfieldProperty("reserved", 7));
54
MP4Integer8Property* pCount =
55
new MP4Integer8Property("keywordCount");
56
AddProperty(pCount); /* 3 */
58
MP4TableProperty* pTable = new MP4TableProperty("keywords", pCount);
59
AddProperty(pTable); /* 4 */
61
pTable->AddProperty( /* 4, 0 */
62
new MP4StringProperty("string", Counted));
67
void MP4KeywordDescriptor::Mutate()
69
bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue();
70
MP4Property* pProperty =
71
((MP4TableProperty*)m_pProperties[4])->GetProperty(0);
73
((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag);
76
MP4RatingDescriptor::MP4RatingDescriptor()
80
new MP4Integer32Property("ratingEntity"));
82
new MP4Integer16Property("ratingCriteria"));
84
new MP4BytesProperty("ratingInfo"));
87
void MP4RatingDescriptor::Read(MP4File* pFile)
91
/* byte properties need to know how long they are before reading */
92
((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 6);
94
ReadProperties(pFile);
97
MP4LanguageDescriptor::MP4LanguageDescriptor()
101
new MP4BytesProperty("languageCode", 3));
104
MP4ShortTextDescriptor::MP4ShortTextDescriptor()
108
new MP4BytesProperty("languageCode", 3));
110
new MP4BitfieldProperty("isUTF8String", 1));
112
new MP4BitfieldProperty("reserved", 7));
114
new MP4StringProperty("eventName", Counted));
116
new MP4StringProperty("eventText", Counted));
121
void MP4ShortTextDescriptor::Mutate()
123
bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue();
124
((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag);
125
((MP4StringProperty*)m_pProperties[4])->SetUnicode(!utf8Flag);
128
MP4ExpandedTextDescriptor::MP4ExpandedTextDescriptor()
132
new MP4BytesProperty("languageCode", 3));
134
new MP4BitfieldProperty("isUTF8String", 1));
136
new MP4BitfieldProperty("reserved", 7));
137
MP4Integer8Property* pCount =
138
new MP4Integer8Property("itemCount");
139
AddProperty(pCount); /* 3 */
141
MP4TableProperty* pTable = new MP4TableProperty("items", pCount);
142
AddProperty(pTable); /* 4 */
144
pTable->AddProperty( /* Table 0 */
145
new MP4StringProperty("itemDescription", Counted));
146
pTable->AddProperty( /* Table 1 */
147
new MP4StringProperty("itemText", Counted));
150
new MP4StringProperty("nonItemText"));
151
((MP4StringProperty*)m_pProperties[5])->SetExpandedCountedFormat(true);
156
void MP4ExpandedTextDescriptor::Mutate()
158
bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue();
160
MP4Property* pProperty =
161
((MP4TableProperty*)m_pProperties[4])->GetProperty(0);
163
((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag);
165
pProperty = ((MP4TableProperty*)m_pProperties[4])->GetProperty(1);
167
((MP4StringProperty*)pProperty)->SetUnicode(!utf8Flag);
169
((MP4StringProperty*)m_pProperties[5])->SetUnicode(!utf8Flag);
172
class MP4CreatorTableProperty : public MP4TableProperty {
174
MP4CreatorTableProperty(char* name, MP4Integer8Property* pCountProperty) :
175
MP4TableProperty(name, pCountProperty) {
178
void ReadEntry(MP4File* pFile, u_int32_t index);
179
void WriteEntry(MP4File* pFile, u_int32_t index);
182
MP4CreatorDescriptor::MP4CreatorDescriptor(u_int8_t tag)
185
MP4Integer8Property* pCount =
186
new MP4Integer8Property("creatorCount");
187
AddProperty(pCount); /* 0 */
189
MP4TableProperty* pTable = new MP4CreatorTableProperty("creators", pCount);
190
AddProperty(pTable); /* 1 */
192
pTable->AddProperty( /* Table 0 */
193
new MP4BytesProperty("languageCode", 3, 3));
194
pTable->AddProperty( /* Table 1 */
195
new MP4BitfieldProperty("isUTF8String", 1));
196
pTable->AddProperty( /* Table 2 */
197
new MP4BitfieldProperty("reserved", 7));
198
pTable->AddProperty( /* Table 3 */
199
new MP4StringProperty("name", Counted));
202
void MP4CreatorTableProperty::ReadEntry(MP4File* pFile, u_int32_t index)
204
m_pProperties[0]->Read(pFile, index);
205
m_pProperties[1]->Read(pFile, index);
207
bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(index);
208
((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag);
210
m_pProperties[2]->Read(pFile, index);
211
m_pProperties[3]->Read(pFile, index);
214
void MP4CreatorTableProperty::WriteEntry(MP4File* pFile, u_int32_t index)
216
bool utf8Flag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(index);
217
((MP4StringProperty*)m_pProperties[3])->SetUnicode(!utf8Flag);
219
MP4TableProperty::WriteEntry(pFile, index);
222
MP4CreationDescriptor::MP4CreationDescriptor(u_int8_t tag)
226
new MP4BitfieldProperty("contentCreationDate", 40));
229
MP4SmpteCameraDescriptor::MP4SmpteCameraDescriptor()
232
MP4Integer8Property* pCount =
233
new MP4Integer8Property("parameterCount");
236
MP4TableProperty* pTable = new MP4TableProperty("parameters", pCount);
240
new MP4Integer8Property("id"));
242
new MP4Integer32Property("value"));
245
MP4UnknownOCIDescriptor::MP4UnknownOCIDescriptor()
249
new MP4BytesProperty("data"));
252
void MP4UnknownOCIDescriptor::Read(MP4File* pFile)
256
/* byte properties need to know how long they are before reading */
257
((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size);
259
ReadProperties(pFile);
262
MP4Descriptor* CreateOCIDescriptor(u_int8_t tag)
264
MP4Descriptor* pDescriptor = NULL;
267
case MP4ContentClassDescrTag:
268
pDescriptor = new MP4ContentClassDescriptor();
270
case MP4KeywordDescrTag:
271
pDescriptor = new MP4KeywordDescriptor();
273
case MP4RatingDescrTag:
274
pDescriptor = new MP4RatingDescriptor();
276
case MP4LanguageDescrTag:
277
pDescriptor = new MP4LanguageDescriptor();
279
case MP4ShortTextDescrTag:
280
pDescriptor = new MP4ShortTextDescriptor();
282
case MP4ExpandedTextDescrTag:
283
pDescriptor = new MP4ExpandedTextDescriptor();
285
case MP4ContentCreatorDescrTag:
286
case MP4OCICreatorDescrTag:
287
pDescriptor = new MP4CreatorDescriptor(tag);
289
case MP4ContentCreationDescrTag:
290
case MP4OCICreationDescrTag:
291
pDescriptor = new MP4CreationDescriptor(tag);
293
case MP4SmpteCameraDescrTag:
294
pDescriptor = new MP4SmpteCameraDescriptor();
298
if (pDescriptor == NULL) {
299
if (tag >= MP4OCIDescrTagsStart && tag <= MP4OCIDescrTagsEnd) {
300
pDescriptor = new MP4UnknownOCIDescriptor();
301
pDescriptor->SetTag(tag);