📄 descriptors.cpp
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is MPEG4IP. * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved. * * Contributor(s): * Dave Mackie dmackie@cisco.com */#include "mp4common.h"MP4BaseDescriptor::MP4BaseDescriptor (u_int8_t tag) : MP4Descriptor(tag){ switch (tag) { case MP4ESIDIncDescrTag: AddProperty( /* 0 */ new MP4Integer32Property("id")); break; case MP4ESIDRefDescrTag: AddProperty( /* 0 */ new MP4Integer16Property("refIndex")); break; case MP4IPIPtrDescrTag: AddProperty( /* 0 */ new MP4Integer16Property("IPIESId")); break; case MP4SupplContentIdDescrTag: AddProperty( /* 0 */ new MP4BytesProperty("languageCode", 3)); AddProperty( /* 1 */ new MP4StringProperty("title", Counted)); AddProperty( /* 2 */ new MP4StringProperty("value", Counted)); break; case MP4IPMPPtrDescrTag: AddProperty( /* 0 */ new MP4Integer8Property("IPMPDescriptorId")); break; case MP4ExtProfileLevelDescrTag: AddProperty( /* 0 */ new MP4Integer8Property("profileLevelIndicationIndex")); AddProperty( /* 1 */ new MP4Integer8Property("ODProfileLevelIndication")); AddProperty( /* 2 */ new MP4Integer8Property("sceneProfileLevelIndication")); AddProperty( /* 3 */ new MP4Integer8Property("audioProfileLevelIndication")); AddProperty( /* 4 */ new MP4Integer8Property("visualProfileLevelIndication")); AddProperty( /* 5 */ new MP4Integer8Property("graphicsProfileLevelIndication")); AddProperty( /* 6 */ new MP4Integer8Property("MPEGJProfileLevelIndication")); break; default: MP4Printf("error in base descriptor - tag %u", tag); break; }}MP4BytesDescriptor::MP4BytesDescriptor (u_int8_t tag) : MP4Descriptor(tag){ m_size_offset = 0; m_bytes_index = 0; if (tag >= MP4ExtDescrTagsStart && tag <= MP4ExtDescrTagsEnd) { AddProperty( /* 0 */ new MP4BytesProperty("data")); } else { switch (tag) { case MP4DecSpecificDescrTag: AddProperty( /* 0 */ new MP4BytesProperty("info")); // no change to m_size break; case MP4IPMPDescrTag: AddProperty( /* 0 */ new MP4Integer8Property("IPMPDescriptorId")); AddProperty( /* 1 */ new MP4Integer16Property("IPMPSType")); AddProperty( /* 2 */ new MP4BytesProperty("IPMPData")); /* note: if IPMPSType == 0, IPMPData is an URL */ m_size_offset = 3; m_bytes_index = 2; break; case MP4RegistrationDescrTag: AddProperty( /* 0 */ new MP4Integer32Property("formatIdentifier")); AddProperty( /* 1 */ new MP4BytesProperty("additionalIdentificationInfo")); m_size_offset = 4; m_bytes_index = 1; break; default: MP4Printf("error in bytes descriptor - tag %u", tag); break; } }}void MP4BytesDescriptor::Read(MP4File *pFile){ ReadHeader(pFile); /* byte properties need to know how long they are before reading */ ((MP4BytesProperty*)m_pProperties[m_bytes_index])->SetValueSize(m_size - m_size_offset); ReadProperties(pFile);}MP4IODescriptor::MP4IODescriptor() : MP4Descriptor(MP4FileIODescrTag){ /* N.B. other member functions depend on the property indicies */ AddProperty( /* 0 */ new MP4BitfieldProperty("objectDescriptorId", 10)); AddProperty( /* 1 */ new MP4BitfieldProperty("URLFlag", 1)); AddProperty( /* 2 */ new MP4BitfieldProperty("includeInlineProfileLevelFlag", 1)); AddProperty( /* 3 */ new MP4BitfieldProperty("reserved", 4)); AddProperty( /* 4 */ new MP4StringProperty("URL", Counted)); AddProperty( /* 5 */ new MP4Integer8Property("ODProfileLevelId")); AddProperty( /* 6 */ new MP4Integer8Property("sceneProfileLevelId")); AddProperty( /* 7 */ new MP4Integer8Property("audioProfileLevelId")); AddProperty( /* 8 */ new MP4Integer8Property("visualProfileLevelId")); AddProperty( /* 9 */ new MP4Integer8Property("graphicsProfileLevelId")); AddProperty( /* 10 */ new MP4DescriptorProperty("esIds", MP4ESIDIncDescrTag, 0, Required, Many)); AddProperty( /* 11 */ new MP4DescriptorProperty("ociDescr", MP4OCIDescrTagsStart, MP4OCIDescrTagsEnd, Optional, Many)); AddProperty( /* 12 */ new MP4DescriptorProperty("ipmpDescrPtr", MP4IPMPPtrDescrTag, 0, Optional, Many)); AddProperty( /* 13 */ new MP4DescriptorProperty("extDescr", MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); SetReadMutate(2);}void MP4IODescriptor::Generate(){ ((MP4BitfieldProperty*)m_pProperties[0])->SetValue(1); ((MP4BitfieldProperty*)m_pProperties[3])->SetValue(0xF); for (u_int32_t i = 5; i <= 9; i++) { ((MP4Integer8Property*)m_pProperties[i])->SetValue(0xFF); }}void MP4IODescriptor::Mutate(){ bool urlFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); m_pProperties[4]->SetImplicit(!urlFlag); for (u_int32_t i = 5; i <= 12; i++) { m_pProperties[i]->SetImplicit(urlFlag); }}MP4ODescriptor::MP4ODescriptor() : MP4Descriptor(MP4FileODescrTag){ /* N.B. other member functions depend on the property indicies */ AddProperty( /* 0 */ new MP4BitfieldProperty("objectDescriptorId", 10)); AddProperty( /* 1 */ new MP4BitfieldProperty("URLFlag", 1)); AddProperty( /* 2 */ new MP4BitfieldProperty("reserved", 5)); AddProperty( /* 3 */ new MP4StringProperty("URL", Counted)); AddProperty( /* 4 */ new MP4DescriptorProperty("esIds", MP4ESIDRefDescrTag, 0, Required, Many)); AddProperty( /* 5 */ new MP4DescriptorProperty("ociDescr", MP4OCIDescrTagsStart, MP4OCIDescrTagsEnd, Optional, Many)); AddProperty( /* 6 */ new MP4DescriptorProperty("ipmpDescrPtr", MP4IPMPPtrDescrTag, 0, Optional, Many)); AddProperty( /* 7 */ new MP4DescriptorProperty("extDescr", MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); SetReadMutate(2);}void MP4ODescriptor::Generate(){ ((MP4BitfieldProperty*)m_pProperties[2])->SetValue(0x1F);}void MP4ODescriptor::Mutate(){ bool urlFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); m_pProperties[3]->SetImplicit(!urlFlag); for (u_int32_t i = 4; i <= 6; i++) { m_pProperties[i]->SetImplicit(urlFlag); }}MP4ESDescriptor::MP4ESDescriptor() : MP4Descriptor(MP4ESDescrTag){ /* N.B. other class functions depend on the property indicies */ AddProperty( /* 0 */ new MP4Integer16Property("ESID")); AddProperty( /* 1 */ new MP4BitfieldProperty("streamDependenceFlag", 1)); AddProperty( /* 2 */ new MP4BitfieldProperty("URLFlag", 1)); AddProperty( /* 3 */ new MP4BitfieldProperty("OCRstreamFlag", 1)); AddProperty( /* 4 */ new MP4BitfieldProperty("streamPriority", 5)); AddProperty( /* 5 */ new MP4Integer16Property("dependsOnESID")); AddProperty( /* 6 */ new MP4StringProperty("URL", Counted)); AddProperty( /* 7 */ new MP4Integer16Property("OCRESID")); AddProperty( /* 8 */ new MP4DescriptorProperty("decConfigDescr", MP4DecConfigDescrTag, 0, Required, OnlyOne)); AddProperty( /* 9 */ new MP4DescriptorProperty("slConfigDescr", MP4SLConfigDescrTag, 0, Required, OnlyOne)); AddProperty( /* 10 */ new MP4DescriptorProperty("ipiPtr", MP4IPIPtrDescrTag, 0, Optional, OnlyOne)); AddProperty( /* 11 */ new MP4DescriptorProperty("ipIds", MP4ContentIdDescrTag, MP4SupplContentIdDescrTag, Optional, Many)); AddProperty( /* 12 */ new MP4DescriptorProperty("ipmpDescrPtr", MP4IPMPPtrDescrTag, 0, Optional, Many)); AddProperty( /* 13 */ new MP4DescriptorProperty("langDescr", MP4LanguageDescrTag, 0, Optional, Many)); AddProperty( /* 14 */ new MP4DescriptorProperty("qosDescr", MP4QosDescrTag, 0, Optional, OnlyOne)); AddProperty( /* 15 */ new MP4DescriptorProperty("regDescr", MP4RegistrationDescrTag, 0, Optional, OnlyOne)); AddProperty( /* 16 */ new MP4DescriptorProperty("extDescr", MP4ExtDescrTagsStart, MP4ExtDescrTagsEnd, Optional, Many)); SetReadMutate(5);}void MP4ESDescriptor::Mutate(){ bool streamDependFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue(); m_pProperties[5]->SetImplicit(!streamDependFlag); bool urlFlag = ((MP4BitfieldProperty*)m_pProperties[2])->GetValue(); m_pProperties[6]->SetImplicit(!urlFlag); bool ocrFlag = ((MP4BitfieldProperty*)m_pProperties[3])->GetValue(); m_pProperties[7]->SetImplicit(!ocrFlag);}MP4DecConfigDescriptor::MP4DecConfigDescriptor() : MP4Descriptor(MP4DecConfigDescrTag){ AddProperty( /* 0 */ new MP4Integer8Property("objectTypeId")); AddProperty( /* 1 */ new MP4BitfieldProperty("streamType", 6)); AddProperty( /* 2 */ new MP4BitfieldProperty("upStream", 1)); AddProperty( /* 3 */ new MP4BitfieldProperty("reserved", 1)); AddProperty( /* 4 */ new MP4BitfieldProperty("bufferSizeDB", 24)); AddProperty( /* 5 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -