本文整理汇总了C++中AP4_AtomParent::FindChild方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_AtomParent::FindChild方法的具体用法?C++ AP4_AtomParent::FindChild怎么用?C++ AP4_AtomParent::FindChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_AtomParent
的用法示例。
在下文中一共展示了AP4_AtomParent::FindChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/*----------------------------------------------------------------------
| AP4_MarlinIpmpParser:Parse
+---------------------------------------------------------------------*/
AP4_Result
AP4_MarlinIpmpParser::Parse(AP4_AtomParent& top_level,
AP4_ByteStream& stream,
AP4_List<SinfEntry>& sinf_entries,
bool remove_od_data)
{
// check the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp == NULL ||
(ftyp->GetMajorBrand() != AP4_MARLIN_BRAND_MGSV && !ftyp->HasCompatibleBrand(AP4_MARLIN_BRAND_MGSV))) {
return AP4_ERROR_INVALID_FORMAT;
}
// check the initial object descriptor and get the OD Track ID
AP4_IodsAtom* iods = AP4_DYNAMIC_CAST(AP4_IodsAtom, top_level.FindChild("moov/iods"));
AP4_UI32 od_track_id = 0;
if (iods == NULL) return AP4_ERROR_INVALID_FORMAT;
const AP4_ObjectDescriptor* od = iods->GetObjectDescriptor();
if (od == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_EsIdIncDescriptor* es_id_inc = AP4_DYNAMIC_CAST(AP4_EsIdIncDescriptor, od->FindSubDescriptor(AP4_DESCRIPTOR_TAG_ES_ID_INC));
if (es_id_inc == NULL) return AP4_ERROR_INVALID_FORMAT;
od_track_id = es_id_inc->GetTrackId();
// find the track pointed to by the descriptor
AP4_MoovAtom* moov = AP4_DYNAMIC_CAST(AP4_MoovAtom, top_level.GetChild(AP4_ATOM_TYPE_MOOV));
if (moov == NULL) return AP4_ERROR_INVALID_FORMAT;
AP4_TrakAtom* od_trak = NULL;
AP4_List<AP4_TrakAtom>::Item* trak_item = moov->GetTrakAtoms().FirstItem();
while (trak_item) {
AP4_TrakAtom* trak = trak_item->GetData();
if (trak) {
if (trak->GetId() == od_track_id) {
od_trak = trak;
} else {
sinf_entries.Add(new SinfEntry(trak->GetId(), NULL));
}
}
trak_item = trak_item->GetNext();
}
// check that we have found the OD track
if (od_trak == NULL) return AP4_ERROR_INVALID_FORMAT;
// look for the 'mpod' trak references
AP4_TrefTypeAtom* track_references;
track_references = AP4_DYNAMIC_CAST(AP4_TrefTypeAtom, od_trak->FindChild("tref/mpod"));
if (track_references == NULL) return AP4_ERROR_INVALID_FORMAT;
// create an AP4_Track object from the trak atom and check that it has samples
AP4_Track* od_track = new AP4_Track(*od_trak, stream, 0);
if (od_track->GetSampleCount() < 1) {
delete od_track;
return AP4_ERROR_INVALID_FORMAT;
}
// get the first sample (in this version, we only look at a single OD command)
AP4_Sample od_sample;
AP4_Result result = od_track->GetSample(0, od_sample);
if (AP4_FAILED(result)) {
delete od_track;
return AP4_ERROR_INVALID_FORMAT;
}
// adapt the sample data into a byte stream for parsing
AP4_DataBuffer sample_data;
od_sample.ReadData(sample_data);
AP4_MemoryByteStream* sample_stream = new AP4_MemoryByteStream(sample_data);
// look for one ObjectDescriptorUpdate command and
// one IPMP_DescriptorUpdate command
AP4_DescriptorUpdateCommand* od_update = NULL;
AP4_DescriptorUpdateCommand* ipmp_update = NULL;
do {
AP4_Command* command = NULL;
result = AP4_CommandFactory::CreateCommandFromStream(*sample_stream, command);
if (AP4_SUCCEEDED(result)) {
// found a command in the sample, check the type
switch (command->GetTag()) {
case AP4_COMMAND_TAG_OBJECT_DESCRIPTOR_UPDATE:
if (od_update == NULL) {
od_update = AP4_DYNAMIC_CAST(AP4_DescriptorUpdateCommand, command);
}
break;
case AP4_COMMAND_TAG_IPMP_DESCRIPTOR_UPDATE:
if (ipmp_update == NULL) {
ipmp_update = AP4_DYNAMIC_CAST(AP4_DescriptorUpdateCommand, command);
}
break;
default:
break;
}
}
} while (AP4_SUCCEEDED(result));
sample_stream->Release();
sample_stream = NULL;
//.........这里部分代码省略.........