📄 descriptors.cpp
字号:
// reserved = 3
((MP4BitfieldProperty*)m_pProperties[18])->SetValue(3);
}
void MP4SLConfigDescriptor::Read(MP4File* pFile)
{
ReadHeader(pFile);
// read the first property, 'predefined'
ReadProperties(pFile, 0, 1);
// if predefined == 0
if (((MP4Integer8Property*)m_pProperties[0])->GetValue() == 0) {
/* read the next 18 properties */
ReadProperties(pFile, 1, 18);
}
// now mutate
Mutate();
// and read the remaining properties
ReadProperties(pFile, 19);
}
void MP4SLConfigDescriptor::Mutate()
{
u_int32_t i;
u_int8_t predefined =
((MP4Integer8Property*)m_pProperties[0])->GetValue();
if (predefined) {
// properties 1-18 are implicit
for (i = 1; i < m_pProperties.Size(); i++) {
m_pProperties[i]->SetImplicit(true);
}
if (predefined == 1) {
// UseTimestampsFlag = 0
((MP4BitfieldProperty*)m_pProperties[6])->SetValue(0);
// TimestampResolution = 1000
((MP4Integer32Property*)m_pProperties[9])->SetValue(1000);
// TimeStampLength = 32
((MP4Integer8Property*)m_pProperties[11])->SetValue(32);
} else if (predefined == 2) {
// UseTimestampsFlag = 1
((MP4BitfieldProperty*)m_pProperties[6])->SetValue(1);
}
} else {
#if 1
for (i = 1; i <= 18; i++) {
m_pProperties[i]->SetImplicit(false);
}
((MP4BitfieldProperty*)m_pProperties[18])->SetValue(3);
#endif
}
bool durationFlag =
((MP4BitfieldProperty*)m_pProperties[8])->GetValue();
for (i = 19; i <= 21; i++) {
m_pProperties[i]->SetImplicit(!durationFlag);
}
bool useTimeStampsFlag =
((MP4BitfieldProperty*)m_pProperties[6])->GetValue();
for (i = 22; i <= 23; i++) {
m_pProperties[i]->SetImplicit(useTimeStampsFlag);
u_int8_t timeStampLength = MIN(64,
((MP4Integer8Property*)m_pProperties[11])->GetValue());
((MP4BitfieldProperty*)m_pProperties[i])->SetNumBits(timeStampLength);
// handle a nonsensical situation gracefully
if (timeStampLength == 0) {
m_pProperties[i]->SetImplicit(true);
}
}
}
MP4IPIPtrDescriptor::MP4IPIPtrDescriptor()
: MP4Descriptor(MP4IPIPtrDescrTag)
{
AddProperty( /* 0 */
new MP4Integer16Property("IPIESId"));
}
MP4ContentIdDescriptor::MP4ContentIdDescriptor()
: MP4Descriptor(MP4ContentIdDescrTag)
{
AddProperty( /* 0 */
new MP4BitfieldProperty("compatibility", 2));
AddProperty( /* 1 */
new MP4BitfieldProperty("contentTypeFlag", 1));
AddProperty( /* 2 */
new MP4BitfieldProperty("contentIdFlag", 1));
AddProperty( /* 3 */
new MP4BitfieldProperty("protectedContent", 1));
AddProperty( /* 4 */
new MP4BitfieldProperty("reserved", 3));
AddProperty( /* 5 */
new MP4Integer8Property("contentType"));
AddProperty( /* 6 */
new MP4Integer8Property("contentIdType"));
AddProperty( /* 7 */
new MP4BytesProperty("contentId"));
}
void MP4ContentIdDescriptor::Read(MP4File* pFile)
{
ReadHeader(pFile);
/* read the first property, 'compatiblity' */
ReadProperties(pFile, 0, 1);
/* if compatiblity != 0 */
if (((MP4Integer8Property*)m_pProperties[0])->GetValue() != 0) {
/* we don't understand it */
VERBOSE_READ(pFile->GetVerbosity(),
printf("incompatible content id descriptor\n"));
return;
}
/* read the next four properties */
ReadProperties(pFile, 1, 4);
/* which allows us to reconfigure ourselves */
Mutate();
/* read the remaining properties */
ReadProperties(pFile, 5);
}
void MP4ContentIdDescriptor::Mutate()
{
bool contentTypeFlag = ((MP4BitfieldProperty*)m_pProperties[1])->GetValue();
m_pProperties[5]->SetImplicit(!contentTypeFlag);
bool contentIdFlag = ((MP4BitfieldProperty*)m_pProperties[2])->GetValue();
m_pProperties[6]->SetImplicit(!contentIdFlag);
m_pProperties[7]->SetImplicit(!contentIdFlag);
}
MP4SupplContentIdDescriptor::MP4SupplContentIdDescriptor()
: MP4Descriptor(MP4SupplContentIdDescrTag)
{
AddProperty( /* 0 */
new MP4BytesProperty("languageCode", 3));
AddProperty( /* 1 */
new MP4StringProperty("title", Counted));
AddProperty( /* 2 */
new MP4StringProperty("value", Counted));
}
MP4IPMPPtrDescriptor::MP4IPMPPtrDescriptor()
: MP4Descriptor(MP4IPMPPtrDescrTag)
{
AddProperty( /* 0 */
new MP4Integer8Property("IPMPDescriptorId"));
}
MP4IPMPDescriptor::MP4IPMPDescriptor()
: MP4Descriptor(MP4IPMPDescrTag)
{
AddProperty( /* 0 */
new MP4Integer8Property("IPMPDescriptorId"));
AddProperty( /* 1 */
new MP4Integer16Property("IPMPSType"));
AddProperty( /* 2 */
new MP4BytesProperty("IPMPData"));
/* note: if IPMPSType == 0, IPMPData is an URL */
}
void MP4IPMPDescriptor::Read(MP4File* pFile)
{
ReadHeader(pFile);
/* byte properties need to know how long they are before reading */
((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 3);
ReadProperties(pFile);
}
MP4RegistrationDescriptor::MP4RegistrationDescriptor()
: MP4Descriptor(MP4RegistrationDescrTag)
{
AddProperty( /* 0 */
new MP4Integer32Property("formatIdentifier"));
AddProperty( /* 1 */
new MP4BytesProperty("additionalIdentificationInfo"));
}
void MP4RegistrationDescriptor::Read(MP4File* pFile)
{
ReadHeader(pFile);
/* byte properties need to know how long they are before reading */
((MP4BytesProperty*)m_pProperties[1])->SetValueSize(m_size - 4);
ReadProperties(pFile);
}
MP4ExtProfileLevelDescriptor::MP4ExtProfileLevelDescriptor()
: MP4Descriptor(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"));
}
MP4ExtensionDescriptor::MP4ExtensionDescriptor()
: MP4Descriptor()
{
AddProperty( /* 0 */
new MP4BytesProperty("data"));
}
void MP4ExtensionDescriptor::Read(MP4File* pFile)
{
ReadHeader(pFile);
/* byte properties need to know how long they are before reading */
((MP4BytesProperty*)m_pProperties[0])->SetValueSize(m_size);
ReadProperties(pFile);
}
MP4Descriptor* MP4DescriptorProperty::CreateDescriptor(u_int8_t tag)
{
MP4Descriptor* pDescriptor = NULL;
switch (tag) {
case MP4ESDescrTag:
pDescriptor = new MP4ESDescriptor();
break;
case MP4DecConfigDescrTag:
pDescriptor = new MP4DecConfigDescriptor();
break;
case MP4DecSpecificDescrTag:
pDescriptor = new MP4DecSpecificDescriptor();
break;
case MP4SLConfigDescrTag:
pDescriptor = new MP4SLConfigDescriptor();
break;
case MP4ContentIdDescrTag:
pDescriptor = new MP4ContentIdDescriptor();
break;
case MP4SupplContentIdDescrTag:
pDescriptor = new MP4SupplContentIdDescriptor();
break;
case MP4IPIPtrDescrTag:
pDescriptor = new MP4IPIPtrDescriptor();
break;
case MP4IPMPPtrDescrTag:
pDescriptor = new MP4IPMPPtrDescriptor();
break;
case MP4IPMPDescrTag:
pDescriptor = new MP4IPMPDescriptor();
break;
case MP4QosDescrTag:
pDescriptor = new MP4QosDescriptor();
break;
case MP4RegistrationDescrTag:
pDescriptor = new MP4RegistrationDescriptor();
break;
case MP4ESIDIncDescrTag:
pDescriptor = new MP4ESIDIncDescriptor();
break;
case MP4ESIDRefDescrTag:
pDescriptor = new MP4ESIDRefDescriptor();
break;
case MP4IODescrTag:
case MP4FileIODescrTag:
pDescriptor = new MP4IODescriptor();
pDescriptor->SetTag(tag);
break;
case MP4ODescrTag:
case MP4FileODescrTag:
pDescriptor = new MP4ODescriptor();
pDescriptor->SetTag(tag);
break;
case MP4ExtProfileLevelDescrTag:
pDescriptor = new MP4ExtProfileLevelDescriptor();
break;
}
if (pDescriptor == NULL) {
if (tag >= MP4OCIDescrTagsStart && tag <= MP4OCIDescrTagsEnd) {
pDescriptor = CreateOCIDescriptor(tag);
}
if (tag >= MP4ExtDescrTagsStart && tag <= MP4ExtDescrTagsEnd) {
pDescriptor = new MP4ExtensionDescriptor();
pDescriptor->SetTag(tag);
}
}
return pDescriptor;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -