本文整理汇总了C++中AP4_AtomParent::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_AtomParent::GetChildren方法的具体用法?C++ AP4_AtomParent::GetChildren怎么用?C++ AP4_AtomParent::GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_AtomParent
的用法示例。
在下文中一共展示了AP4_AtomParent::GetChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDecryptingStream
/*----------------------------------------------------------------------
| AP4_OmaDcfAtomDecrypter::DecryptAtoms
+---------------------------------------------------------------------*/
AP4_Result
AP4_OmaDcfAtomDecrypter::DecryptAtoms(AP4_AtomParent& atoms,
AP4_Processor::ProgressListener* /*listener*/,
AP4_BlockCipherFactory* block_cipher_factory,
AP4_ProtectionKeyMap& key_map)
{
// default factory
if (block_cipher_factory == NULL) {
block_cipher_factory = &AP4_DefaultBlockCipherFactory::Instance;
}
unsigned int index = 1;
for (AP4_List<AP4_Atom>::Item* item = atoms.GetChildren().FirstItem();
item;
item = item->GetNext()) {
AP4_Atom* atom = item->GetData();
if (atom->GetType() != AP4_ATOM_TYPE_ODRM) continue;
// check that we have the key
const AP4_DataBuffer* key = key_map.GetKey(index++);
if (key == NULL) return AP4_ERROR_INVALID_PARAMETERS;
// check that we have all the atoms we need
AP4_ContainerAtom* odrm = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
if (odrm == NULL) continue; // not enough info
AP4_OdheAtom* odhe = AP4_DYNAMIC_CAST(AP4_OdheAtom, odrm->GetChild(AP4_ATOM_TYPE_ODHE));
if (odhe == NULL) continue; // not enough info
AP4_OddaAtom* odda = AP4_DYNAMIC_CAST(AP4_OddaAtom, odrm->GetChild(AP4_ATOM_TYPE_ODDA));;
if (odda == NULL) continue; // not enough info
AP4_OhdrAtom* ohdr = AP4_DYNAMIC_CAST(AP4_OhdrAtom, odhe->GetChild(AP4_ATOM_TYPE_OHDR));
if (ohdr == NULL) continue; // not enough info
// do nothing if the atom is not encrypted
if (ohdr->GetEncryptionMethod() == AP4_OMA_DCF_ENCRYPTION_METHOD_NULL) {
continue;
}
// create the byte stream
AP4_ByteStream* cipher_stream = NULL;
AP4_Result result = CreateDecryptingStream(*odrm,
key->GetData(),
key->GetDataSize(),
block_cipher_factory,
cipher_stream);
if (AP4_SUCCEEDED(result)) {
// replace the odda atom's payload with the decrypted stream
odda->SetEncryptedPayload(*cipher_stream, ohdr->GetPlaintextLength());
cipher_stream->Release();
// the atom will now be in the clear
ohdr->SetEncryptionMethod(AP4_OMA_DCF_ENCRYPTION_METHOD_NULL);
ohdr->SetPaddingScheme(AP4_OMA_DCF_PADDING_SCHEME_NONE);
}
}
return AP4_SUCCESS;
}