本文整理汇总了C++中AP4_AtomParent::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_AtomParent::AddChild方法的具体用法?C++ AP4_AtomParent::AddChild怎么用?C++ AP4_AtomParent::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_AtomParent
的用法示例。
在下文中一共展示了AP4_AtomParent::AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateAtomFromStream
/*----------------------------------------------------------------------
| AP4_AtomFactory::CreateAtomsFromStream
+---------------------------------------------------------------------*/
AP4_Result
AP4_AtomFactory::CreateAtomsFromStream(AP4_ByteStream& stream,
AP4_LargeSize bytes_available,
AP4_AtomParent& atoms)
{
AP4_Result result;
do {
AP4_Atom* atom = NULL;
result = CreateAtomFromStream(stream, bytes_available, atom);
if (AP4_SUCCEEDED(result) && atom != NULL) {
atoms.AddChild(atom);
}
} while (AP4_SUCCEEDED(result));
return AP4_SUCCESS;
}
示例2:
/*----------------------------------------------------------------------
| AP4_OmaDcfEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
AP4_Result
AP4_OmaDcfEncryptingProcessor::Initialize(AP4_AtomParent& top_level,
AP4_ByteStream& /*stream*/,
AP4_Processor::ProgressListener* /*listener*/)
{
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
// add the OMA compatible brand if it is not already there
if (!ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_OPF2)) {
compatible_brands.Append(AP4_OMA_DCF_BRAND_OPF2);
}
// create a replacement
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(ftyp->GetMajorBrand(),
ftyp->GetMinorVersion(),
&compatible_brands[0],
compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
} else {
AP4_UI32 opf2 = AP4_OMA_DCF_BRAND_OPF2;
ftyp = new AP4_FtypAtom(AP4_FTYP_BRAND_ISOM, 0, &opf2, 1);
}
// insert the ftyp atom as the first child
return top_level.AddChild(ftyp, 0);
}
示例3: od_update
/*----------------------------------------------------------------------
| AP4_MarlinIpmpEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
AP4_Result
AP4_MarlinIpmpEncryptingProcessor::Initialize(
AP4_AtomParent& top_level,
AP4_ByteStream& /*stream*/,
AP4_Processor::ProgressListener* /*listener = NULL*/)
{
// get the moov atom
AP4_MoovAtom* moov = AP4_DYNAMIC_CAST(AP4_MoovAtom, top_level.GetChild(AP4_ATOM_TYPE_MOOV));
if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
// deal with the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
// add the MGSV compatible brand if it is not already there
if (!ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV)) {
compatible_brands.Append(AP4_MARLIN_BRAND_MGSV);
}
// create a replacement for the major brand
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV,
0x13c078c, //AP4_MARLIN_BRAND_MGSV_MAJOR_VERSION,
&compatible_brands[0],
compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
} else {
AP4_UI32 isom = AP4_FTYP_BRAND_ISOM;
ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV, 0, &isom, 1);
}
// insert the ftyp atom as the first child
top_level.AddChild(ftyp, 0);
// create and 'mpod' track reference atom
AP4_TrefTypeAtom* mpod = new AP4_TrefTypeAtom(AP4_ATOM_TYPE_MPOD);
// look for an available track ID, starting at 1
unsigned int od_track_id = 0;
unsigned int od_track_position = 0;
AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
while (trak_item) {
AP4_TrakAtom* trak = trak_item->GetData();
if (trak) {
od_track_position++;
if (trak->GetId() >= od_track_id) {
od_track_id = trak->GetId()+1;
}
// if the track is encrypted, reference it in the mpod
if (m_KeyMap.GetKey(trak->GetId())) {
mpod->AddTrackId(trak->GetId());
}
//m_SinfEntries.Add(new SinfEntry(trak->GetId(), NULL));
}
trak_item = trak_item->GetNext();
}
// check that there was at least one track in the file
if (od_track_id == 0) return AP4_ERROR_INVALID_FORMAT;
// create an initial object descriptor
AP4_InitialObjectDescriptor* iod =
// FIXME: get real values from the property map
new AP4_InitialObjectDescriptor(AP4_DESCRIPTOR_TAG_MP4_IOD,
1022, // object descriptor id
false,
0xFE, // OD profile level (0xFE = No OD profile specified)
0xFF, // scene profile level
0xFE, // audio profile level
0xFE, // visual profile level
0xFF); // graphics profile
// create an ES_ID_Inc subdescriptor and add it to the initial object descriptor
AP4_EsIdIncDescriptor* es_id_inc = new AP4_EsIdIncDescriptor(od_track_id);
iod->AddSubDescriptor(es_id_inc);
// create an iods atom to hold the initial object descriptor
AP4_IodsAtom* iods = new AP4_IodsAtom(iod);
// add the iods atom to the moov atom (try to put it just after mvhd)
int iods_position = 0;
int item_position = 0;
for (AP4_List<AP4_Atom>::Item* item = moov->GetChildren().FirstItem();
item;
++item) {
++item_position;
//.........这里部分代码省略.........
示例4: od_update
/*----------------------------------------------------------------------
| AP4_MarlinIpmpEncryptingProcessor::Initialize
+---------------------------------------------------------------------*/
AP4_Result
AP4_MarlinIpmpEncryptingProcessor::Initialize(
AP4_AtomParent& top_level,
AP4_ByteStream& /*stream*/,
AP4_Processor::ProgressListener* /*listener = NULL*/)
{
// get the moov atom
AP4_MoovAtom* moov = AP4_DYNAMIC_CAST(AP4_MoovAtom, top_level.GetChild(AP4_ATOM_TYPE_MOOV));
if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
// deal with the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp) {
// remove the atom, it will be replaced with a new one
top_level.RemoveChild(ftyp);
// keep the existing brand and compatible brands
AP4_Array<AP4_UI32> compatible_brands;
compatible_brands.EnsureCapacity(ftyp->GetCompatibleBrands().ItemCount()+1);
for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
compatible_brands.Append(ftyp->GetCompatibleBrands()[i]);
}
// add the MGSV compatible brand if it is not already there
if (!ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV)) {
compatible_brands.Append(AP4_MARLIN_BRAND_MGSV);
}
// create a replacement for the major brand
AP4_FtypAtom* new_ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV,
0x13c078c, //AP4_MARLIN_BRAND_MGSV_MAJOR_VERSION,
&compatible_brands[0],
compatible_brands.ItemCount());
delete ftyp;
ftyp = new_ftyp;
} else {
AP4_UI32 isom = AP4_FTYP_BRAND_ISOM;
ftyp = new AP4_FtypAtom(AP4_MARLIN_BRAND_MGSV, 0, &isom, 1);
}
// insert the ftyp atom as the first child
top_level.AddChild(ftyp, 0);
// create and 'mpod' track reference atom
AP4_TrefTypeAtom* mpod = new AP4_TrefTypeAtom(AP4_ATOM_TYPE_MPOD);
// look for an available track ID, starting at 1
unsigned int od_track_id = 0;
unsigned int od_track_position = 0;
for (AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
trak_item;
trak_item = trak_item->GetNext()) {
AP4_TrakAtom* trak = trak_item->GetData();
if (trak) {
od_track_position++;
if (trak->GetId() >= od_track_id) {
od_track_id = trak->GetId()+1;
}
// if the track is encrypted, reference it in the mpod
if (m_KeyMap.GetKey(trak->GetId())) {
mpod->AddTrackId(trak->GetId());
}
//m_SinfEntries.Add(new SinfEntry(trak->GetId(), NULL));
}
}
// check that there was at least one track in the file
if (od_track_id == 0) return AP4_ERROR_INVALID_FORMAT;
// create an initial object descriptor
AP4_InitialObjectDescriptor* iod =
// FIXME: get real values from the property map
new AP4_InitialObjectDescriptor(AP4_DESCRIPTOR_TAG_MP4_IOD,
1022, // object descriptor id
false,
0xFE, // OD profile level (0xFE = No OD profile specified)
0xFF, // scene profile level
0xFE, // audio profile level
0xFE, // visual profile level
0xFF); // graphics profile
// create an ES_ID_Inc subdescriptor and add it to the initial object descriptor
AP4_EsIdIncDescriptor* es_id_inc = new AP4_EsIdIncDescriptor(od_track_id);
iod->AddSubDescriptor(es_id_inc);
// create an iods atom to hold the initial object descriptor
AP4_IodsAtom* iods = new AP4_IodsAtom(iod);
// add the iods atom to the moov atom (try to put it just after mvhd)
int iods_position = 0;
int item_position = 0;
for (AP4_List<AP4_Atom>::Item* moov_item = moov->GetChildren().FirstItem();
moov_item;
moov_item = moov_item->GetNext()) {
++item_position;
//.........这里部分代码省略.........