本文整理汇总了C++中AP4_ContainerAtom::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_ContainerAtom::GetChildren方法的具体用法?C++ AP4_ContainerAtom::GetChildren怎么用?C++ AP4_ContainerAtom::GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_ContainerAtom
的用法示例。
在下文中一共展示了AP4_ContainerAtom::GetChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
AP4_Cardinal track_count = 0;
AP4_List<AP4_TrakAtom>* trak_atoms = NULL;
AP4_LargeSize mdat_payload_size = 0;
AP4_SampleCursor* cursors = NULL;
if (moov) {
// build an array of track sample locators
trak_atoms = &moov->GetTrakAtoms();
track_count = trak_atoms->ItemCount();
cursors = new AP4_SampleCursor[track_count];
m_TrackData.SetItemCount(track_count);
m_StreamData.SetItemCount(1);
m_StreamData[0].stream = &input;
unsigned int index = 0;
for (AP4_List<AP4_TrakAtom>::Item* item = trak_atoms->FirstItem(); item; item=item->GetNext()) {
AP4_TrakAtom* trak = item->GetData();
// find the stsd atom
AP4_ContainerAtom* stbl = AP4_DYNAMIC_CAST(AP4_ContainerAtom, trak->FindChild("mdia/minf/stbl"));
if (stbl == NULL) continue;
// see if there's an external data source for this track
AP4_ByteStream* trak_data_stream = &input;
for (AP4_List<ExternalTrackData>::Item* ditem = m_ExternalTrackData.FirstItem(); ditem; ditem=ditem->GetNext()) {
ExternalTrackData* tdata = ditem->GetData();
if (tdata->m_TrackId == trak->GetId()) {
trak_data_stream = tdata->m_MediaData;
break;
}
}
AP4_ContainerAtom *mvex = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->GetChild(AP4_ATOM_TYPE_MVEX));
AP4_TrexAtom* trex = NULL;
if (mvex) {
for (AP4_List<AP4_Atom>::Item* item = mvex->GetChildren().FirstItem(); item; item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
if (atom->GetType() == AP4_ATOM_TYPE_TREX) {
trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, atom);
if (trex && trex->GetTrackId() == trak->GetId())
break;
trex = NULL;
}
}
}
// create the track handler
m_TrackData[index].track_handler = CreateTrackHandler(trak, trex);
m_TrackData[index].new_id = trak->GetId();
cursors[index].m_Locator.m_TrakIndex = index;
cursors[index].m_Locator.m_SampleTable = new AP4_AtomSampleTable(stbl, *trak_data_stream);
cursors[index].m_Locator.m_SampleIndex = 0;
cursors[index].m_Locator.m_ChunkIndex = 0;
if (cursors[index].m_Locator.m_SampleTable->GetSampleCount()) {
cursors[index].m_Locator.m_SampleTable->GetSample(0, cursors[index].m_Locator.m_Sample);
} else {
cursors[index].m_EndReached = true;
}
index++;
}
// figure out the layout of the chunks
for (;;) {
// see which is the next sample to write
AP4_UI64 min_offset = (AP4_UI64)(-1);
int cursor = -1;
for (unsigned int i=0; i<track_count; i++) {
示例2: PrintUsageAndExit
//.........这里部分代码省略.........
if (track == NULL) {
fprintf(stderr, "--video option specified, but no video track found\n");
return 1;
}
Options.track_filter = track->GetId();
} else if (Options.track_id) {
AP4_Track* track = movie->GetTrack(Options.track_id);
if (track == NULL) {
fprintf(stderr, "--track-id option specified, but no such track found\n");
return 1;
}
Options.track_filter = track->GetId();
}
// save the init segment
AP4_ByteStream* output = NULL;
result = AP4_FileByteStream::Create(Options.init_segment_name, AP4_FileByteStream::STREAM_MODE_WRITE, output);
if (AP4_FAILED(result)) {
fprintf(stderr, "ERROR: cannot open output file (%d)\n", result);
return 1;
}
AP4_FtypAtom* ftyp = file->GetFileType();
if (ftyp) {
result = ftyp->Write(*output);
if (AP4_FAILED(result)) {
fprintf(stderr, "ERROR: cannot write ftyp segment (%d)\n", result);
return 1;
}
}
if (Options.track_filter) {
AP4_MoovAtom* moov = movie->GetMoovAtom();
// only keep the 'trak' atom that we need
AP4_List<AP4_Atom>::Item* child = moov->GetChildren().FirstItem();
while (child) {
AP4_Atom* atom = child->GetData();
child = child->GetNext();
if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
AP4_TrakAtom* trak = (AP4_TrakAtom*)atom;
AP4_TkhdAtom* tkhd = (AP4_TkhdAtom*)trak->GetChild(AP4_ATOM_TYPE_TKHD);
if (tkhd && tkhd->GetTrackId() != Options.track_filter) {
atom->Detach();
delete atom;
}
}
}
// only keep the 'trex' atom that we need
AP4_ContainerAtom* mvex = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov->GetChild(AP4_ATOM_TYPE_MVEX));
if (mvex) {
child = mvex->GetChildren().FirstItem();
while (child) {
AP4_Atom* atom = child->GetData();
child = child->GetNext();
if (atom->GetType() == AP4_ATOM_TYPE_TREX) {
AP4_TrexAtom* trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, atom);
if (trex && trex->GetTrackId() != Options.track_filter) {
atom->Detach();
delete atom;
}
}
}
}
}
result = movie->GetMoovAtom()->Write(*output);
if (AP4_FAILED(result)) {
示例3: CreateFragmentHandler
/*----------------------------------------------------------------------
| AP4_Processor::ProcessFragments
+---------------------------------------------------------------------*/
AP4_Result
AP4_Processor::ProcessFragment( AP4_ContainerAtom* moof,
AP4_SidxAtom* sidx,
AP4_Position sidx_position,
AP4_ByteStream& output,
AP4_Array<AP4_Position>& moof_positions,
AP4_Array<AP4_Position>& mdat_positions)
{
unsigned int fragment_index = 0;
//AP4_UI64 mdat_payload_offset = atom_offset+atom->GetSize()+AP4_ATOM_HEADER_SIZE;
AP4_Sample sample;
AP4_DataBuffer sample_data_in;
AP4_DataBuffer sample_data_out;
AP4_Result result = AP4_SUCCESS;
// parse the moof
//AP4_MovieFragment* fragment = new AP4_MovieFragment(moof);
// process all the traf atoms
AP4_Array<AP4_Processor::FragmentHandler*> handlers;
AP4_Array<AP4_FragmentSampleTable*> sample_tables;
for (; AP4_Atom* child = moof->GetChild(AP4_ATOM_TYPE_TRAF, handlers.ItemCount());) {
AP4_TrafAtom* traf = AP4_DYNAMIC_CAST(AP4_TrafAtom, child);
PERTRACK &track_data(m_TrackData[traf->GetInternalTrackId()]);
AP4_TrakAtom* trak = track_data.track_handler->GetTrakAtom();
AP4_TrexAtom* trex = track_data.track_handler->GetTrexAtom();
// create the handler for this traf
AP4_Processor::FragmentHandler* handler = CreateFragmentHandler(trak, trex, traf,
*(m_StreamData[track_data.streamId].stream),
moof_positions[track_data.streamId]);
if (handler) {
result = handler->ProcessFragment();
if (AP4_FAILED(result)) return result;
}
handlers.Append(handler);
// create a sample table object so we can read the sample data
AP4_FragmentSampleTable* sample_table = new AP4_FragmentSampleTable(
traf,
trex,
traf->GetInternalTrackId(),
m_StreamData[track_data.streamId].stream,
moof_positions[traf->GetInternalTrackId()],
mdat_positions[traf->GetInternalTrackId()],
0);
sample_tables.Append(sample_table);
// let the handler look at the samples before we process them
if (handler)
result = handler->PrepareForSamples(sample_table);
if (AP4_FAILED(result))
return result;
}
output.Buffer();
// write the moof
AP4_UI64 moof_out_start = 0;
output.Tell(moof_out_start);
moof->Write(output);
// remember the location of this fragment
FragmentMapEntry map_entry = { moof_positions[0], moof_out_start };
fragment_map_.Append(map_entry);
// write an mdat header
AP4_Position mdat_out_start;
AP4_UI64 mdat_size = AP4_ATOM_HEADER_SIZE;
output.Tell(mdat_out_start);
output.WriteUI32(0);
output.WriteUI32(AP4_ATOM_TYPE_MDAT);
// process all track runs
for (unsigned int i=0; i<handlers.ItemCount(); i++) {
AP4_Processor::FragmentHandler* handler = handlers[i];
// get the track ID
AP4_ContainerAtom* traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof->GetChild(AP4_ATOM_TYPE_TRAF, i));
if (traf == NULL) continue;
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
// compute the base data offset
AP4_UI64 base_data_offset;
if (tfhd->GetFlags() & AP4_TFHD_FLAG_BASE_DATA_OFFSET_PRESENT) {
base_data_offset = mdat_out_start+AP4_ATOM_HEADER_SIZE;
} else {
base_data_offset = moof_out_start;
}
// build a list of all trun atoms
AP4_Array<AP4_TrunAtom*> truns;
for (AP4_List<AP4_Atom>::Item* child_item = traf->GetChildren().FirstItem();
child_item;
//.........这里部分代码省略.........
示例4: GetTrack
/*----------------------------------------------------------------------
| AP4_Movie::ProcessMoof
+---------------------------------------------------------------------*/
void
AP4_Movie::ProcessMoof(AP4_ContainerAtom* moof, AP4_ByteStream& stream)
{
if (moof) {
AP4_Offset offset = 0;
stream.Tell(offset);
AP4_Offset moof_offset = offset - moof->GetSize();
AP4_Offset mdat_payload_offset = offset + 8;
AP4_MfhdAtom* mfhd = AP4_DYNAMIC_CAST(AP4_MfhdAtom, moof->GetChild(AP4_ATOM_TYPE_MFHD));
if (mfhd) {
for (AP4_List<AP4_Atom>::Item* item = moof->GetChildren().FirstItem();
item;
item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
if (atom->GetType() == AP4_ATOM_TYPE_TRAF) {
AP4_ContainerAtom* traf = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
if (traf) {
AP4_TfhdAtom* tfhd = AP4_DYNAMIC_CAST(AP4_TfhdAtom, traf->GetChild(AP4_ATOM_TYPE_TFHD));
if (!tfhd) {
continue;
}
AP4_Track* track = GetTrack(tfhd->GetTrackId());
if (!track) {
continue;
}
AP4_TfdtAtom* tfdt = AP4_DYNAMIC_CAST(AP4_TfdtAtom, traf->GetChild(AP4_ATOM_TYPE_TFDT));
AP4_TrexAtom* trex = NULL;
AP4_ContainerAtom* mvex = AP4_DYNAMIC_CAST(AP4_ContainerAtom, m_MoovAtom->GetChild(AP4_ATOM_TYPE_MVEX));
if (mvex) {
for (AP4_List<AP4_Atom>::Item* child_item = mvex->GetChildren().FirstItem();
child_item;
child_item = child_item->GetNext()) {
AP4_Atom* child_atom = child_item->GetData();
if (child_atom->GetType() == AP4_ATOM_TYPE_TREX) {
trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, child_atom);
if (trex && trex->GetTrackId() == tfhd->GetTrackId()) break;
trex = NULL;
}
}
}
AP4_FragmentSampleTable* sampleTable = track->GetFragmentSampleTable();
AP4_Cardinal sample_count = 0;
for (AP4_List<AP4_Atom>::Item* child_item = traf->GetChildren().FirstItem();
child_item;
child_item = child_item->GetNext()) {
AP4_Atom* child_atom = child_item->GetData();
if (child_atom->GetType() == AP4_ATOM_TYPE_TRUN) {
AP4_TrunAtom* trun = AP4_DYNAMIC_CAST(AP4_TrunAtom, child_atom);
if (trun) {
sample_count += trun->GetEntries().ItemCount();
}
}
}
if (!sample_count) {
return;
}
if (sampleTable->GetSampleCount() == 0) {
track->CreateFragmentFromStdSamples();
}
if (AP4_FAILED(sampleTable->EnsureCapacity(sample_count + sampleTable->GetSampleCount()))) {
return;
}
AP4_UI64 dts_origin = tfdt ? tfdt->GetBaseMediaDecodeTime() : 0;
for (AP4_List<AP4_Atom>::Item* child_item = traf->GetChildren().FirstItem();
child_item;
child_item = child_item->GetNext()) {
AP4_Atom* child_atom = child_item->GetData();
if (child_atom->GetType() == AP4_ATOM_TYPE_TRUN) {
AP4_TrunAtom* trun = AP4_DYNAMIC_CAST(AP4_TrunAtom, child_atom);
if (trun) {
sampleTable->AddTrun(trun, tfhd, trex, stream, dts_origin, moof_offset, mdat_payload_offset);
}
}
}
}
}
}
}
}
}