本文整理汇总了C++中IAAFFile::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IAAFFile::Release方法的具体用法?C++ IAAFFile::Release怎么用?C++ IAAFFile::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAAFFile
的用法示例。
在下文中一共展示了IAAFFile::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadAAFFile
// now need the reading functionality
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
IAAFFile * pFile = NULL;
// printing file open time
clock_t start = clock();
clock_t finish;
double duration;
check(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
finish = clock();
duration = ((double) (finish - start) / CLOCKS_PER_SEC);
pFile->Close();
pFile->Release();
pFile=NULL;
#if 0
printf("Open time = %f seconds\n", duration);
#endif
cleanup:
if (pFile) {
pFile->Close();
pFile->Release();
}
return AAFRESULT_SUCCESS;
}
示例2: Close
void EventTest::Close()
{
if (_pDictionary)
{
_pDictionary->Release();
_pDictionary = NULL;
}
if (_pHeader)
{
_pHeader->Release();
_pHeader = NULL;
}
if (_pFile)
{
if (_bWritableFile)
checkResult(_pFile->Save());
checkResult(_pFile->Close());
_pFile->Release();
_pFile = NULL;
}
}
示例3: cleanupReferences
void EnumEssenceDataTest::cleanupReferences()
{
if (NULL != _pEssenceData)
{
_pEssenceData->Release();
_pEssenceData = NULL;
}
if (NULL != _pEnumEssenceData)
{
_pEnumEssenceData->Release();
_pEnumEssenceData = NULL;
}
if (NULL != _pFileDescriptor)
{
_pFileDescriptor->Release();
_pFileDescriptor = NULL;
}
if (NULL != _pEssenceDescriptor)
{
_pEssenceDescriptor->Release();
_pEssenceDescriptor = NULL;
}
if (NULL != _pSourceMob)
{
_pSourceMob->Release();
_pSourceMob = NULL;
}
if (NULL != _pMob)
{
_pMob->Release();
_pMob = NULL;
}
if (NULL != _pDictionary)
{
_pDictionary->Release();
_pDictionary = NULL;
}
if (NULL != _pHeader)
{
_pHeader->Release();
_pHeader = NULL;
}
if (NULL != _pFile)
{
if (_bFileOpen)
_pFile->Close();
_pFile->Release();
_pFile = NULL;
}
}
示例4: ReadAAFFile
static HRESULT ReadAAFFile(aafWChar * pFileName )
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile* pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary * pDict = NULL;
aafBoolean_t bFileOpen = kAAFFalse;
try
{
// Open the file
checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
bFileOpen = kAAFTrue;
checkResult (pFile->GetHeader (&pHeader));
assert (pHeader);
checkResult (pHeader->GetDictionary (&pDict));
assert (pDict);
// Read the mob, slots, etc to verify the contents ...
checkResult(verifyContents (pHeader, pDict, kAAFFalse)); //False => NOT minimal testing; i.e. test everything
}//try
catch (HRESULT & rResult)
{
hr = rResult;
}
if (pDict) pDict->Release();
if (pHeader) pHeader->Release();
if (bFileOpen && pFile)
{
stopGap(pFile->Close());
pFile->Release();
}
return hr;
}//ReadAAFFile()
示例5: main
extern int main(int argc, char *argv[])
{
if (argc < 2)
{
printUsage(argv[0]);
return 1;
}
aafWChar Filename[FILENAME_MAX];
size_t status = mbstowcs(Filename, argv[1], sizeof(Filename));
if (status == (size_t)-1) {
fprintf(stderr, "mbstowcs failed for \"%s\"\n", argv[1]);
return 1;
}
IAAFFile *pFile = NULL;
int mode = 0;
HRESULT res_open;
// Perform the simplest possible use of the AAF SDK to open an
// existing AAF file. This is enough to cause a memory leak in
// AAF SDK v1.1.2 and up to at least CVS snapshot 2008-05-12.
res_open = AAFFileOpenExistingRead(Filename, mode, &pFile);
if (AAFRESULT_FAILED(res_open))
{
aafCharacter buf[100] = L"";
AAFResultToText(res_open, buf, sizeof(buf));
fprintf(stderr, "AAFFileOpenExistingRead() failed, result=0x%08x %ls\n", res_open, buf);
return 1;
}
pFile->Close();
pFile->Release();
return 0;
}
示例6: ReadAAFFile
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
IAAFFile * pFile = NULL;
bool bFileOpen = false;
IAAFHeader * pHeader = NULL;
HRESULT hr = S_OK;
try
{
// Open the file
checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
bFileOpen = true;
// We can't really do anthing in AAF without the header.
checkResult(pFile->GetHeader(&pHeader));
}
catch (HRESULT& rResult)
{
hr = rResult;
}
// Cleanup and return
if (pHeader)
pHeader->Release();
if (pFile)
{ // Close file
if (bFileOpen)
pFile->Close();
pFile->Release();
}
return hr;
}
示例7: ReadAAFFile
static void ReadAAFFile(aafWChar * pFileName)
{
HRESULT hr = S_OK;
IAAFFile * pFile = NULL;
hr = AAFFileOpenExistingRead (pFileName, AAF_FILE_MODE_LAZY_LOADING, &pFile);
if (SUCCEEDED(hr))
{
IAAFHeader * pHeader = NULL;
hr = pFile->GetHeader(&pHeader);
check(hr); // display error message
if (SUCCEEDED(hr))
{
IAAFIdentification * pIdent = NULL;
hr = pHeader->GetLastIdentification(&pIdent);
check(hr); // display error message
if (SUCCEEDED(hr))
{
printIdentification(pIdent);
pIdent->Release();
pIdent = NULL;
// count Mobs
aafNumSlots_t n;
hr = pHeader->CountMobs(kAAFAllMob, &n);
check(hr);
printf("\nNumber of Mobs = %d\n", n);
// Header::Version, Header::ObjectModelVersion
aafVersionType_t version = {0};
check(pHeader->GetFileRevision (&version) );
printf("\nHeader::Version = %d.%d\n", version.major, version.minor);
aafFileRev_t fileVersion = kAAFRev1;
check(pFile->GetRevision (&fileVersion) );
printf("\nHeader::ObjectModelVersion = %d", fileVersion);
if (fileVersion == kAAFRev1)
printf(" (recognized as kAAFRev1)\n");
else if (fileVersion == kAAFRev2)
printf(" (recognized as kAAFRev2)\n");
else
printf("\n");
// Show datadefs, with version
IEnumAAFDataDefsSP pEnumDataDef;
IAAFDictionarySP pDictionary;
check(pHeader->GetDictionary(&pDictionary));
check(pDictionary->GetDataDefs(&pEnumDataDef));
IAAFDataDef* pDataDef;
printf("\nDatadefs = ");
while (SUCCEEDED(pEnumDataDef->NextOne(&pDataDef)))
{
IAAFDefObjectSP pDefObject;
check(pDataDef->QueryInterface(IID_IAAFDefObject, (void**)&pDefObject));
pDataDef->Release();
pDataDef = NULL;
aafUID_t id = {0};
check(pDefObject->GetAUID(&id));
aafWChar wchName[500];
char chName[1000];
check( pDefObject->GetName(wchName, sizeof (wchName)) );
convert(chName, sizeof(chName), wchName);
if (memcmp( &id, &kAAFDataDef_LegacyPicture, sizeof(id)) == 0)
printf("\"%s\" (recognized as legacy Picture)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Picture, sizeof(id)) == 0)
printf("\"%s\" (recognized as Picture)\n", chName);
else if (memcmp( &id, &kAAFDataDef_LegacySound, sizeof(id)) == 0)
printf("\"%s\" (recognized as legacy Sound)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Sound, sizeof(id)) == 0)
printf("\"%s\" (recognized as Sound)\n", chName);
else if (memcmp( &id, &kAAFDataDef_LegacyTimecode, sizeof(id)) == 0)
printf("\"%s\" (recognized as legacy Timecode)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Timecode, sizeof(id)) == 0)
printf("\"%s\" (recognized as Timecode)\n", chName);
else if (memcmp( &id, &kAAFDataDef_PictureWithMatte, sizeof(id)) == 0)
printf("\"%s\" (recognized as PictureWithMatte)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Edgecode, sizeof(id)) == 0)
printf("\"%s\" (recognized as Edgecode)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Auxiliary, sizeof(id)) == 0)
printf("\"%s\" (recognized as Auxiliary)\n", chName);
else if (memcmp( &id, &kAAFDataDef_DescriptiveMetadata, sizeof(id)) == 0)
printf("\"%s\" (recognized as DescriptiveMetadata)\n", chName);
else if (memcmp( &id, &kAAFDataDef_Matte, sizeof(id)) == 0)
printf("\"%s\" (recognized as Matte)\n", chName);
else
printf("\"%s\"\n", chName);
printf(" ");
}
// Check if file contains TypeDefs known to cause a v1.0 reader to assert.
// Known instances of this are UInt32Set and AUIDSet added to the v1.1 SDK.
// Cannot use Dictionary::LookupTypeDef to check for them, because this
//.........这里部分代码省略.........
示例8: ReadAAFFile
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFSourceMob* pSourceMob = NULL;
IAAFMob* pMob = NULL;
IAAFEssenceDescriptor* pEssDesc = NULL;
IAAFBWFImportDescriptor* pBWFImportDesc = NULL;
IEnumAAFRIFFChunks* pEnum = NULL;
IAAFRIFFChunk* pRIFFChunk = NULL;
IAAFRIFFChunk* pRIFFChunkTest = NULL;
IEnumAAFMobs* pMobIter = NULL;
aafUInt32 numData, bytesRead, com, testNum;
aafLength_t testRIFFLen;
aafNumSlots_t numMobs;
char Value[sizeof(RIFFChunksmiley)];
char Value2[sizeof(RIFFChunkfrowney)];
HRESULT hr = AAFRESULT_SUCCESS;
wchar_t testString[256];
checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
checkResult( pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create a fake RIFFChunk to test RemoveUnknownBWFChunks.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk,
(IUnknown **)&pRIFFChunkTest));
checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
if (1 == numMobs )
{
checkResult(pHeader->GetMobs(NULL, &pMobIter));
checkResult(pMobIter->NextOne(&pMob));
checkResult(pMob->QueryInterface(IID_IAAFSourceMob, (void **)&pSourceMob));
// Back into testing mode
checkResult(pSourceMob->GetEssenceDescriptor(&pEssDesc));
checkResult( pEssDesc->QueryInterface( IID_IAAFBWFImportDescriptor, (void**)&pBWFImportDesc ));
checkResult(pBWFImportDesc->GetFileSecurityReport(&testNum));
checkExpression(testNum==TEST_FileSecurityReport, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetFileSecurityWave(&testNum));
checkExpression(testNum==TEST_FileSecurityWave, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetCodingHistory(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_CodingHistory) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetBasicData(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_BasicData) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetStartOfModulation(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_StartOfModulation) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetQualityEvent(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_QualityEvent) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetEndOfModulation(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_EndOfModulation) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetQualityParameter(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_QualityParameter) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetOperatorComment(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_OperatorComment) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetCueSheet(testString, sizeof(testString)));
checkExpression(wcscmp(testString, TEST_CueSheet) == 0, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->CountUnknownBWFChunks(&numData));
checkExpression(2 == numData, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->GetUnknownBWFChunks(&pEnum));
for(com = 0; com < numData; com++)
{
checkResult(pEnum->NextOne(&pRIFFChunk));
pRIFFChunk->GetLength(&testRIFFLen);
checkExpression(testRIFFLen!=chunkLength /*huh?*/, AAFRESULT_TEST_FAILED);
checkResult(pRIFFChunk->GetLength(&testRIFFLen));
pRIFFChunk->GetChunkID(&testNum);
if (testNum==1){
checkExpression(sizeof(RIFFChunksmiley) == testRIFFLen, AAFRESULT_TEST_FAILED);
checkResult(pRIFFChunk->Read( sizeof(Value), (unsigned char *)Value, &bytesRead));
checkExpression(memcmp(Value, RIFFChunksmiley, sizeof(RIFFChunksmiley)) == 0, AAFRESULT_TEST_FAILED);
}
else if (testNum==2){
checkExpression(sizeof(RIFFChunkfrowney) == testRIFFLen, AAFRESULT_TEST_FAILED);
checkResult(pRIFFChunk->Read( sizeof(Value2), (unsigned char *)Value2, &bytesRead));
checkExpression(memcmp(Value2, RIFFChunkfrowney, sizeof(RIFFChunkfrowney)) == 0, AAFRESULT_TEST_FAILED);
}
pRIFFChunk->Release();
pRIFFChunk = NULL;
}
checkResult(pEnum->Reset());
checkResult(pEnum->NextOne(&pRIFFChunk));
checkExpression((pBWFImportDesc->RemoveUnknownBWFChunkAt(2))==AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->RemoveUnknownBWFChunkAt(0));
checkResult(pBWFImportDesc->CountUnknownBWFChunks(&numData));
checkExpression(1 == numData, AAFRESULT_TEST_FAILED);
pRIFFChunk->Release();
pRIFFChunk = NULL;
pEnum->Release();
pEnum = NULL;
pBWFImportDesc->Release();
//.........这里部分代码省略.........
示例9: CreateAAFFile
static HRESULT CreateAAFFile(
aafWChar * pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID)
{
IAAFFile * pFile = NULL;
bool bFileOpen = false;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFMob* pMob = NULL;
IAAFRIFFChunk* pRIFFChunk = NULL;
IAAFRIFFChunk* pRIFFChunk2 = NULL;
IAAFSourceMob* pSourceMob = NULL;
IAAFEssenceDescriptor* pEssDesc = NULL;
IAAFBWFImportDescriptor* pBWFImportDesc = NULL;
aafUInt32 testNum;
HRESULT hr = S_OK;
// Remove the previous test file if any.
RemoveTestFile(pFileName);
// Create the file.
checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
bFileOpen = true;
// We can't really do anthing in AAF without the header.
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
checkResult(defs.cdSourceMob()->
CreateInstance(IID_IAAFSourceMob,
(IUnknown **)&pSourceMob));
pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob);
pMob->SetMobID(TEST_MobID);
pMob->SetName(L"BWFImportDescriptorTest");
//Create BWFImportDescriptor to hold the RIFFChunk
checkResult( defs.cdBWFImportDescriptor()->
CreateInstance(IID_IAAFBWFImportDescriptor, (IUnknown **)&pBWFImportDesc));
// Create RIFFChunks and append them to BWFImportDescriptor
checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk,
(IUnknown **)&pRIFFChunk));
checkResult(defs.cdRIFFChunk()->CreateInstance(IID_IAAFRIFFChunk,
(IUnknown **)&pRIFFChunk2));
checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk));
checkResult(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk2));
checkExpression(pBWFImportDesc->AppendUnknownBWFChunk(pRIFFChunk)==AAFRESULT_OBJECT_ALREADY_ATTACHED, AAFRESULT_TEST_FAILED);
checkResult(pBWFImportDesc->SetFileSecurityReport(TEST_FileSecurityReport));
checkResult(pBWFImportDesc->SetFileSecurityWave(TEST_FileSecurityWave));
checkResult(pBWFImportDesc->SetCodingHistory(TEST_CodingHistory));
checkResult(pBWFImportDesc->SetBasicData(TEST_BasicData));
checkResult(pBWFImportDesc->SetStartOfModulation(TEST_StartOfModulation));
checkResult(pBWFImportDesc->SetQualityEvent(TEST_QualityEvent));
checkResult(pBWFImportDesc->SetEndOfModulation(TEST_EndOfModulation));
checkResult(pBWFImportDesc->SetQualityParameter(TEST_QualityParameter));
checkResult(pBWFImportDesc->SetOperatorComment(TEST_OperatorComment));
checkResult(pBWFImportDesc->SetCueSheet(TEST_CueSheet));
checkResult( pBWFImportDesc->QueryInterface(IID_IAAFEssenceDescriptor, (void **)&pEssDesc));
checkResult(pSourceMob->SetEssenceDescriptor(pEssDesc));
//Add the MOB to the file
checkResult(pHeader->AddMob(pMob));
testNum = 0;
checkResult(pRIFFChunk->Initialize(chunkID));
checkResult(pRIFFChunk->Write(sizeof(RIFFChunksmiley), (unsigned char *)RIFFChunksmiley, &testNum));
checkExpression(testNum == sizeof(RIFFChunksmiley), AAFRESULT_TEST_FAILED);
testNum = 0;
checkResult(pRIFFChunk2->Initialize(chunkID2));
checkResult(pRIFFChunk2->Write(sizeof(RIFFChunkfrowney), (unsigned char *)RIFFChunkfrowney, &testNum));
checkExpression(testNum == sizeof(RIFFChunkfrowney), AAFRESULT_TEST_FAILED);
pFile->Save();
pEssDesc->Release();
pEssDesc = NULL;
pBWFImportDesc->Release();
pBWFImportDesc = NULL;
pRIFFChunk->Release();
pRIFFChunk = NULL;
pRIFFChunk2->Release();
pRIFFChunk2 = NULL;
pMob->Release();
pMob = NULL;
pSourceMob->Release();
pSourceMob = NULL;
//.........这里部分代码省略.........
示例10: CreateAAFFile
static HRESULT CreateAAFFile(aafWChar *filename, aafUID_constref fileKind)
{
TestProductID.companyName = companyName;
TestProductID.productName = productName;
TestProductID.productVersionString = NULL;
TestProductID.productID = UnitTestProductID;
TestProductID.platform = NULL;
TestProductID.productVersion = &TestVersion;
HRESULT hr = S_OK;
try
{
RemoveTestFile(filename);
// Open new file
IAAFFile *pFile = NULL;
TestProductID.productVersionString = const_cast<aafWChar*>(L"CreateAAFFile");
checkResult( AAFFileOpenNewModifyEx(
filename,
&fileKind,
0,
&TestProductID,
&pFile) );
// Get the header & dictionary
IAAFHeader *pHeader = NULL;
IAAFDictionary *pDictionary = NULL;
checkResult(pFile->GetHeader(&pHeader));
checkResult(pHeader->GetDictionary(&pDictionary));
// Create a MasterMob
IAAFMob *pMob = NULL;
IAAFClassDef *classDef = NULL;
checkResult(pDictionary->LookupClassDef(AUID_AAFMasterMob, &classDef));
checkResult(classDef->CreateInstance(IID_IAAFMob, (IUnknown **)&pMob));
classDef->Release();
checkResult(pMob->SetMobID(TEST_MobID));
checkResult(pMob->SetName(L"CreateAAFFile - MasterMob"));
checkResult(pHeader->AddMob(pMob));
pMob->Release();
// Create a SourceMob
IAAFSourceMob *pSourceMob = NULL;
checkResult(pDictionary->LookupClassDef(AUID_AAFSourceMob, &classDef));
checkResult(classDef->CreateInstance(IID_IAAFSourceMob, (IUnknown **)&pSourceMob));
classDef->Release();
checkResult(pSourceMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
checkResult(pMob->SetMobID(TEST_SourceMobID));
checkResult(pMob->SetName(L"CreateAAFFile - SourceMob"));
IAAFEssenceDescriptor *edesc = NULL;
IAAFAIFCDescriptor *pAIFCDesc = NULL;
checkResult(pDictionary->LookupClassDef(AUID_AAFAIFCDescriptor, &classDef));
checkResult(classDef->CreateInstance(IID_IAAFEssenceDescriptor, (IUnknown **)&edesc));
classDef->Release();
checkResult(edesc->QueryInterface(IID_IAAFAIFCDescriptor, (void **)&pAIFCDesc));
aafUInt8 buf[] = {0x00};
checkResult(pAIFCDesc->SetSummary(sizeof(buf), buf));
checkResult(pSourceMob->SetEssenceDescriptor(edesc));
checkResult(pHeader->AddMob(pMob));
pAIFCDesc->Release();
edesc->Release();
pSourceMob->Release();
pMob->Release();
pDictionary->Release();
pHeader->Release();
// Save & close the file
checkResult(pFile->Save());
checkResult(pFile->Close());
checkResult(pFile->Release());
cout << "CreateAAFFile() - created new file" << endl;
}
catch (HRESULT& rResult)
{
hr = rResult;
cout << "*** CreateAAFFile: caught error hr=0x" << hex << hr << dec << endl;
}
return hr;
}
示例11: CreateAAFFile
//.........这里部分代码省略.........
checkResult(pOperationDef->AddParameterDef (pParamDef));
checkResult(pOperationDef->SetBypass (TEST_BYPASS));
// ------------------------------------------------------------
// To test a Transition we need to create a Sequence which will
// a Filler, a transition and another Filler. I know this is not
// very interesting, but it will let us test the Transition
// interface with the least amount of other stuff.
// ------------------------------------------------------------
//
// Create a CompositionMob
checkResult(defs.cdCompositionMob()->
CreateInstance(IID_IAAFCompositionMob,
(IUnknown **)&pCompMob));
checkResult(pCompMob->Initialize(L"Transition Test"));
// Get a MOB interface
checkResult(pCompMob->QueryInterface (IID_IAAFMob, (void **)&pMob));
checkResult(pMob->SetMobID(TEST_MobID));
// Create a Sequence
checkResult(defs.cdSequence()->
CreateInstance(IID_IAAFSequence,
(IUnknown **) &pSequence));
// Get a Segment interface
checkResult(pSequence->QueryInterface(IID_IAAFSegment, (void **)&pSegment));
// Get a component interface and
checkResult(pSequence->QueryInterface(IID_IAAFComponent, (void **)&pComponent));
// set the Data definition for it !
checkResult(pComponent->SetDataDef(defs.ddkAAFPicture()));
// Release the component - because we need to reuse the pointer later
pComponent->Release();
pComponent = NULL;
// Create a new Mob Slot that will contain the sequence
aafRational_t editRate = { 0, 1};
checkResult(pMob->AppendNewTimelineSlot(editRate,
pSegment,
1,
L"Transition",
0,
&pNewSlot));
// Create a Filler
checkResult(defs.cdFiller()->
CreateInstance(IID_IAAFFiller,
(IUnknown **) &pFiller));
// Get a component interface
checkResult(pFiller->QueryInterface(IID_IAAFComponent, (void **) &pComponent));
// Set values for the filler
checkResult(pFiller->Initialize(defs.ddkAAFPicture(), fillerLength));
// append the filler to the sequence
checkResult(pSequence->AppendComponent(pComponent));
// Release the component - because we need to reuse the pointer later
pFiller->Release();
pFiller = NULL;
pComponent->Release();
pComponent = NULL;
checkResult(defs.cdTransition()->
CreateInstance(IID_IAAFTransition,
示例12: ReadAAFFile
static HRESULT ReadAAFFile(aafWChar* pFileName)
{
IAAFFile* pFile = NULL;
IAAFHeader* pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IEnumAAFContainerDefs *pPlug = NULL;
IAAFDefObject* pDef = NULL;
IAAFContainerDef* pContainerDef = NULL;
bool bFileOpen = false;
HRESULT hr = S_OK;
aafUID_t readUID;
wchar_t testString[256];
try
{
// Open the AAF file
checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
bFileOpen = true;
// Get the AAF file header.
checkResult(pFile->GetHeader(&pHeader));
checkResult(pHeader->GetDictionary(&pDictionary));
checkResult(pDictionary->GetContainerDefs(&pPlug));
while(pPlug->NextOne (&pContainerDef) == AAFRESULT_SUCCESS)
{
checkResult(pContainerDef->QueryInterface (IID_IAAFDefObject, (void **)&pDef));
checkResult(pDef->GetAUID(&readUID));
if(memcmp(&readUID, &testUID, sizeof(aafUID_t)) == 0)
{
checkResult(pDef->GetName (testString, sizeof(testString)));
checkExpression (wcscmp(testString, sName) == 0, AAFRESULT_TEST_FAILED);
aafUInt32 nameLen;
checkResult (pDef->GetNameBufLen (&nameLen));
checkExpression (((wcslen (sName)+1) * sizeof (aafCharacter) == nameLen),
AAFRESULT_TEST_FAILED);
checkResult(pDef->GetDescription (testString, sizeof(testString)));
checkExpression (wcscmp(testString, sDescription) == 0, AAFRESULT_TEST_FAILED);
checkResult (pDef->GetDescriptionBufLen (&nameLen));
checkExpression (((wcslen (sDescription)+1) * sizeof (aafCharacter) == nameLen),
AAFRESULT_TEST_FAILED);
break;
}
pDef->Release();
pDef = NULL;
pContainerDef->Release();
pContainerDef = NULL;
}// checkResult(pPlug->NextOne(&pContainerDef));
}
catch (HRESULT& rResult)
{
hr = rResult;
}
// Cleanup and return
if (pHeader)
pHeader->Release();
if (pPlug)
pPlug->Release();
if (pDef)
pDef->Release();
if (pContainerDef)
pContainerDef->Release();
if (pDictionary)
pDictionary->Release();
if (pFile)
{ // Close file
if (bFileOpen)
pFile->Close();
pFile->Release();
}
return hr;
}
示例13: ReadAAFFile
static HRESULT ReadAAFFile(const aafWChar * pFileName, testType_t testType)
{
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormat *fmtTemplate = NULL;
IEnumAAFMobs* pMobIter = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceFormat* pFormat = NULL;
aafNumSlots_t numMobs, numSlots;
aafSearchCrit_t criteria;
aafRational_t readSampleRate;
aafMobID_t mobID;
aafWChar namebuf[1204];
unsigned char AAFDataBuf[4096];
aafUInt32 AAFBytesRead, samplesRead;
FILE* pWavFile = NULL;
unsigned char WAVDataBuf[4096], *dataPtr;
size_t WAVBytesRead;
aafUInt32 dataOffset, dataLen;
aafUInt16 bitsPerSample, numCh;
check(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
check(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
check(pHeader->GetDictionary(&pDictionary));
// Here we check on the number of mobs in the file.
// Get the number of master mobs in the file (should be one)
check(pHeader->CountMobs(kAAFMasterMob, &numMobs));
// ** causes leak
if (1 == numMobs )
{
printf("Found %d Master Mobs\n", numMobs);
criteria.searchTag = kAAFByMobKind;
criteria.tags.mobKind = kAAFMasterMob;
check(pHeader->GetMobs(&criteria, &pMobIter));
while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
{
char mobIDstr[256];
char mobName[256];
check(pMob->GetMobID (&mobID));
check(pMob->GetName (namebuf, sizeof(namebuf)));
convert(mobName, sizeof(mobName), namebuf);
MobIDtoString(mobID, mobIDstr);
printf(" MasterMob Name = '%s'\n", mobName);
printf(" (mobID %s)\n", mobIDstr);
// Make sure we have two slots
check(pMob->CountSlots(&numSlots));
if (2 == numSlots)
{
// The essence data is in SlotID 1
// Get a Master Mob interface
check(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob));
// Open the Essence Data
check(pMasterMob->OpenEssence( 1, // SlotID 1
NULL, // mediaCriteria (Don't care)
kAAFMediaOpenReadOnly, // Open mode
kAAFCompressionDisable,// Compress disabled
&pEssenceAccess));
// Open and read the Wave file (for comparison)
pWavFile = fopen("Laser.wav", "r");
if (pWavFile)
{
// read in the essence data
WAVBytesRead = fread(WAVDataBuf, sizeof(unsigned char), sizeof(WAVDataBuf), pWavFile);
fclose(pWavFile);
pWavFile = NULL;
check(loadWAVEHeader(WAVDataBuf,
&bitsPerSample,
&numCh,
&readSampleRate,
&dataOffset,
&dataLen));
dataPtr = WAVDataBuf + dataOffset;
aafUInt32 sampleBits;
aafInt32 bytesRead;
check(pEssenceAccess->GetEmptyFileFormat (&fmtTemplate));
check(fmtTemplate->AddFormatSpecifier (kAAFAudioSampleBits, 0, NULL));
check(pEssenceAccess->GetFileFormat (fmtTemplate, &pFormat));
fmtTemplate->Release();
fmtTemplate = NULL;
check(pFormat->GetFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleBits),
(aafDataBuffer_t)&sampleBits, &bytesRead));
pFormat->Release();
pFormat = NULL;
//.........这里部分代码省略.........
示例14: CAAFCachePageAllocator_test
HRESULT CAAFCachePageAllocator_test(testMode_t /* mode */,
aafUID_t fileKind,
testRawStorageType_t /* rawStorageType */,
aafProductIdentification_t productID)
{
const size_t fileNameBufLen = 128;
aafWChar pFileName[ fileNameBufLen ] = L"";
GenerateTestFileName( productID.productName, fileKind, fileNameBufLen, pFileName );
(void)RemoveTestFile(pFileName );
IAAFRawStorage* pRawStorage = 0;
HRESULT hr = AAFCreateRawStorageDisk(pFileName,
kAAFFileExistence_new,
kAAFFileAccess_modify,
&pRawStorage);
if (!AAFRESULT_SUCCEEDED(hr)) return hr;
IAAFCachePageAllocator* pAllocator = 0;
hr = TestCachePageAllocator::Create(&pAllocator);
if (!AAFRESULT_SUCCEEDED(hr)) {
pRawStorage->Release();
pRawStorage = 0;
return hr;
}
IAAFRawStorage* pCachedRawStorage = 0;
hr = AAFCreateRawStorageCached2(pRawStorage,
16,
4096,
pAllocator,
&pCachedRawStorage);
if (!AAFRESULT_SUCCEEDED(hr)) {
pRawStorage->Release();
pRawStorage = 0;
pAllocator->Release();
pAllocator = 0;
return hr;
}
aafUID_t encoding = EffectiveTestFileEncoding(fileKind);
IAAFFile* pFile = 0;
hr = AAFCreateAAFFileOnRawStorage(pCachedRawStorage,
kAAFFileExistence_new,
kAAFFileAccess_modify,
&encoding,
0,
&productID,
&pFile);
if (!AAFRESULT_SUCCEEDED(hr)) {
pRawStorage->Release();
pRawStorage = 0;
pAllocator->Release();
pAllocator = 0;
pCachedRawStorage->Release();
pCachedRawStorage = 0;
return hr;
}
hr = pFile->Open();
if (!AAFRESULT_SUCCEEDED(hr)) {
pRawStorage->Release();
pRawStorage = 0;
pAllocator->Release();
pAllocator = 0;
pCachedRawStorage->Release();
pCachedRawStorage = 0;
pFile->Release();
pFile = 0;
return hr;
}
hr = pFile->Save();
if (!AAFRESULT_SUCCEEDED(hr)) return hr;
hr = pFile->Close();
if (!AAFRESULT_SUCCEEDED(hr)) return hr;
pRawStorage->Release();
pRawStorage = 0;
pAllocator->Release();
pAllocator = 0;
pCachedRawStorage->Release();
pCachedRawStorage = 0;
pFile->Release();
pFile = 0;
return hr;
}
示例15: ReadAAFFile
static HRESULT ReadAAFFile(aafWChar * pFileName)
{
// IAAFSession * pSession = NULL;
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IEnumAAFMobs* pMobIter = NULL;
IAAFMob* pMob = NULL;
IAAFMob* pReferencedMob = NULL;
IEnumAAFMobSlots* pSlotIter = NULL;
IAAFMobSlot* pSlot = NULL;
IAAFSegment* pSegment = NULL;
IAAFSourceClip* pSourceClip = NULL;
bool bFileOpen = false;
aafSearchCrit_t criteria;
aafNumSlots_t numMobs, numSlots;
HRESULT hr = AAFRESULT_SUCCESS;
try
{
// Open the file
checkResult(AAFFileOpenExistingRead(pFileName, 0, &pFile));
bFileOpen = true;
// We can't really do anthing in AAF without the header.
checkResult(pFile->GetHeader(&pHeader));
// Get the number of mobs in the file (should be one)
checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs));
checkExpression(2 == numMobs, AAFRESULT_TEST_FAILED);
// Enumerate over all Composition Mobs
criteria.searchTag = kAAFByMobKind;
criteria.tags.mobKind = kAAFCompMob;
checkResult(pHeader->GetMobs(&criteria, &pMobIter));
while (AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
{
checkResult(pMob->CountSlots(&numSlots));
checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED);
checkResult(pMob->GetSlots(&pSlotIter));
while (AAFRESULT_SUCCESS == pSlotIter->NextOne(&pSlot))
{
// The segment should be a source clip...
checkResult(pSlot->GetSegment(&pSegment));
pSegment->Release();
pSegment = NULL;
pSlot->Release();
pSlot = NULL;
}
pMob->Release();
pMob = NULL;
}
}
catch (HRESULT& rResult)
{
hr = rResult;
}
// Cleanup and return
if (pReferencedMob)
pReferencedMob->Release();
if (pSourceClip)
pSourceClip->Release();
if (pSegment)
pSegment->Release();
if (pSlot)
pSlot->Release();
if (pSlotIter)
pSlotIter->Release();
if (pMob)
pMob->Release();
if (pMobIter)
pMobIter->Release();
if (pHeader)
pHeader->Release();
if (pFile)
{
if (bFileOpen)
pFile->Close();
pFile->Release();
}
return hr;
}