void MP4DrefAtom::Read() { /* do the usual read */ MP4Atom::Read(); // check that number of children == entryCount MP4Integer32Property* pCount = (MP4Integer32Property*)m_pProperties[2]; if (m_pChildAtoms.Size() != pCount->GetValue()) { VERBOSE_READ(GetVerbosity(), MP4Printf("Warning: dref inconsistency with number of entries")); /* fix it */ pCount->SetReadOnly(false); pCount->SetValue(m_pChildAtoms.Size()); pCount->SetReadOnly(true); } }
MP4DrefAtom::MP4DrefAtom() : MP4Atom("dref") { AddVersionAndFlags(); MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); pCount->SetReadOnly(); AddProperty(pCount); ExpectChildAtom("url ", Optional, Many); ExpectChildAtom("urn ", Optional, Many); ExpectChildAtom("alis", Optional, Many); }
MP4StsdAtom::MP4StsdAtom() : MP4Atom("stsd") { AddVersionAndFlags(); MP4Integer32Property* pCount = new MP4Integer32Property("entryCount"); pCount->SetReadOnly(); AddProperty(pCount); ExpectChildAtom("mp4a", Optional, Many); ExpectChildAtom("enca", Optional, Many); ExpectChildAtom("mp4s", Optional, Many); ExpectChildAtom("mp4v", Optional, Many); ExpectChildAtom("encv", Optional, Many); ExpectChildAtom("rtp ", Optional, Many); ExpectChildAtom("samr", Optional, Many); // For AMR-NB ExpectChildAtom("sawb", Optional, Many); // For AMR-WB ExpectChildAtom("s263", Optional, Many); // For H.263 ExpectChildAtom("avc1", Optional, Many); ExpectChildAtom("alac", Optional, Many); }
void MP4File::MakeFtypAtom(char* majorBrand, u_int32_t minorVersion, char** supportedBrands, u_int32_t supportedBrandsCount) { bool rewriteNeeded = false; u_int32_t currentSupportedBrandsCount; u_int32_t i; MP4Atom* ftypAtom = m_pRootAtom->FindAtom("ftyp"); if (ftypAtom == NULL) { ftypAtom = InsertChildAtom(m_pRootAtom, "ftyp", 0); } if (majorBrand == NULL) return; MP4StringProperty* pMajorBrandProperty; if (!ftypAtom->FindProperty( "ftyp.majorBrand", (MP4Property**)&pMajorBrandProperty)) return; pMajorBrandProperty->SetValue(majorBrand); MP4Integer32Property* pMinorVersionProperty; if (!ftypAtom->FindProperty( "ftype.minorVersion", (MP4Property**)&pMinorVersionProperty)) return; pMinorVersionProperty->SetValue(minorVersion); MP4Integer32Property* pCompatibleBrandsCountProperty; if (!ftypAtom->FindProperty( "ftyp.compatibleBrandsCount", (MP4Property**)&pCompatibleBrandsCountProperty)) return; currentSupportedBrandsCount = pCompatibleBrandsCountProperty->GetValue(); MP4TableProperty* pCompatibleBrandsProperty; if (!ftypAtom->FindProperty( "ftyp.compatibleBrands", (MP4Property**)&pCompatibleBrandsProperty)) return; MP4StringProperty* pBrandProperty = (MP4StringProperty*) pCompatibleBrandsProperty->GetProperty(0); ASSERT(pBrandProperty); for (i = 0 ; i < ((currentSupportedBrandsCount > supportedBrandsCount) ? supportedBrandsCount : currentSupportedBrandsCount) ; i++) { pBrandProperty->SetValue(supportedBrands[i], i); } if (i < supportedBrandsCount) { for ( ; i < supportedBrandsCount ; i++) { pBrandProperty->AddValue(supportedBrands[i]); } } if (currentSupportedBrandsCount != supportedBrandsCount) { rewriteNeeded = true; pBrandProperty->SetCount(supportedBrandsCount); pCompatibleBrandsCountProperty->SetReadOnly(false); pCompatibleBrandsCountProperty->SetValue(supportedBrandsCount); pCompatibleBrandsCountProperty->SetReadOnly(true); } }