本文整理汇总了C++中AP4_AtomParent::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_AtomParent::GetChild方法的具体用法?C++ AP4_AtomParent::GetChild怎么用?C++ AP4_AtomParent::GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_AtomParent
的用法示例。
在下文中一共展示了AP4_AtomParent::GetChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*----------------------------------------------------------------------
| AP4_OmaDcfDecryptingProcessor:Initialize
+---------------------------------------------------------------------*/
AP4_Result
AP4_OmaDcfDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
AP4_ByteStream& /* stream */,
ProgressListener* listener)
{
// decide which processor to instantiate based on the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp) {
if (ftyp->GetMajorBrand() == AP4_OMA_DCF_BRAND_ODCF || ftyp->HasCompatibleBrand(AP4_OMA_DCF_BRAND_ODCF)) {
return AP4_OmaDcfAtomDecrypter::DecryptAtoms(top_level, listener, m_BlockCipherFactory, m_KeyMap);
} else {
return AP4_ERROR_INVALID_FORMAT;
}
} else {
return AP4_SUCCESS;
}
}
示例2:
/*----------------------------------------------------------------------
| AP4_MarlinIpmpDecryptingProcessor:Initialize
+---------------------------------------------------------------------*/
AP4_Result
AP4_MarlinIpmpDecryptingProcessor::Initialize(AP4_AtomParent& top_level,
AP4_ByteStream& stream,
ProgressListener* /*listener*/)
{
AP4_Result result = AP4_MarlinIpmpParser::Parse(top_level, stream, m_SinfEntries, true);
if (AP4_FAILED(result)) return result;
// update the file type
AP4_FtypAtom* ftyp = AP4_DYNAMIC_CAST(AP4_FtypAtom, top_level.GetChild(AP4_ATOM_TYPE_FTYP));
if (ftyp) {
ftyp->SetMajorBrandAndVersion(AP4_FTYP_BRAND_MP42, 1);
for (unsigned int i=0; i<ftyp->GetCompatibleBrands().ItemCount(); i++) {
if (ftyp->GetCompatibleBrands()[i] == AP4_MARLIN_BRAND_MGSV) {
ftyp->GetCompatibleBrands()[i] = AP4_FTYP_BRAND_MP42;
}
}
}
return AP4_SUCCESS;
}
示例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: 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;
//.........这里部分代码省略.........
示例5: sizeof
/*----------------------------------------------------------------------
| DcfParser_ParseV2Header
+---------------------------------------------------------------------*/
static BLT_Result
DcfParser_ParseV2Header(DcfParser* self, ATX_InputStream* stream)
{
/* rewind the byte stream */
ATX_InputStream_Seek(stream, 0);
/* parse the atoms from the stream */
AP4_ByteStream* mp4_stream = new ATX_InputStream_To_AP4_ByteStream_Adapter(stream);
AP4_AtomParent atoms;
AP4_Result result = AP4_DefaultAtomFactory::Instance.CreateAtomsFromStream(*mp4_stream, atoms);
mp4_stream->Release();
AP4_ByteStream* decrypting_stream = NULL;
AP4_ContainerAtom* odrm = dynamic_cast<AP4_ContainerAtom*>(atoms.GetChild(AP4_ATOM_TYPE_ODRM));
if (odrm) {
AP4_OdheAtom* odhe = dynamic_cast<AP4_OdheAtom*>(odrm->GetChild(AP4_ATOM_TYPE_ODHE));
AP4_OddaAtom* odda = dynamic_cast<AP4_OddaAtom*>(odrm->GetChild(AP4_ATOM_TYPE_ODDA));
if (odhe && odda) {
const char* content_id = "";
/* get the content ID */
AP4_OhdrAtom* ohdr = dynamic_cast<AP4_OhdrAtom*>(odhe->GetChild(AP4_ATOM_TYPE_OHDR));
if (ohdr) {
content_id = ohdr->GetContentId().GetChars();
}
/* get the content key */
NPT_DataBuffer key;
result = DcfParser_GetContentKey(self, content_id, key);
if (BLT_FAILED(result)) {
ATX_LOG_FINE_2("GetKeyForContent(%s) returned %d",
content_id,
result);
return BLT_ERROR_NO_MEDIA_KEY;
}
/* create the decrypting stream */
result = AP4_OmaDcfAtomDecrypter::CreateDecryptingStream(*odrm,
key.GetData(),
key.GetDataSize(),
self->cipher_factory,
decrypting_stream);
if (AP4_SUCCEEDED(result)) {
/* update the content type */
ATX_CopyStringN(self->input.content_type,
odhe->GetContentType().GetChars(),
sizeof(self->input.content_type));
/* update the encrypted size */
self->input.encrypted_size = odda->GetEncryptedDataLength();
}
}
}
/* check that we have found what we needed in the atoms */
if (decrypting_stream == NULL) return BLT_ERROR_INVALID_MEDIA_FORMAT;
/* update the output size */
AP4_LargeSize plaintext_size = 0;
if (AP4_SUCCEEDED(decrypting_stream->GetSize(plaintext_size))) {
self->output.size = plaintext_size;
} else {
self->output.size = self->input.encrypted_size;
}
/* create a reverse adapter */
result = AP4_ByteStream_To_ATX_InputStream_Adapter_Create(decrypting_stream, &self->output.stream);
decrypting_stream->Release();
return BLT_SUCCESS;
}
示例6: 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;
//.........这里部分代码省略.........