本文整理汇总了C++中AP4_TrakAtom::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_TrakAtom::GetChild方法的具体用法?C++ AP4_TrakAtom::GetChild怎么用?C++ AP4_TrakAtom::GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_TrakAtom
的用法示例。
在下文中一共展示了AP4_TrakAtom::GetChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)) {