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 // has the side effect of registering the typedef we are checking for // from the built-in model. Instead, iterate through typedefs (in file) // and check for the known instances. printf("\nTypes incompatible with SDK v1.0.x ="); IEnumAAFTypeDefsSP pEnumTypeDef; check(pDictionary->GetTypeDefs(&pEnumTypeDef)); IAAFTypeDef* pTypeDef; bool foundToxic = false; while (SUCCEEDED(pEnumTypeDef->NextOne(&pTypeDef))) { IAAFMetaDefinitionSP pMetaDef; check(pTypeDef->QueryInterface(IID_IAAFMetaDefinition, (void**)&pMetaDef)); pTypeDef->Release(); pTypeDef = NULL; aafUID_t typeUID; check(pMetaDef->GetAUID(&typeUID)); aafWChar wchName[500]; char chName[1000]; check( pMetaDef->GetName(wchName, sizeof (wchName)) ); convert(chName, sizeof(chName), wchName); if ((memcmp( &typeUID, &kAAFTypeID_AUIDSet, sizeof(typeUID)) == 0) || (memcmp( &typeUID, &kAAFTypeID_UInt32Set, sizeof(typeUID)) == 0)) { printf(" %s", chName); foundToxic = true; } } if (!foundToxic) printf(" (none)"); printf("\n\n"); } pHeader->Release(); pHeader = NULL; } hr = pFile->Close(); check(hr); pFile->Release(); pFile = NULL; // Get file kind. // Since AAF SDK v1.0.2, the file kind actually identifies the implementation // of the file kind, from which the file kind is inferred. aafUID_t fileKind = {0}; aafBool isAAFFile = kAAFFalse; check(AAFFileIsAAFFile(pFileName, &fileKind, &isAAFFile)); if (isAAFFile) { if (memcmp( &fileKind, &kAAFFileKind_AafM512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with Microsoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafS512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with Schemasoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafG512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with GSF)\n"); else if (memcmp( &fileKind, &kAAFFileKind_Aaf512Binary, sizeof(fileKind)) == 0) printf("Filekind = 512-byte SS (reading with default implementation)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafM4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with Microsoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafS4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with Schemasoft)\n"); else if (memcmp( &fileKind, &kAAFFileKind_AafG4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with GSF)\n"); else if (memcmp( &fileKind, &kAAFFileKind_Aaf4KBinary, sizeof(fileKind)) == 0) printf("Filekind = 4096-byte SS (reading with default implementation)\n"); else printf("Filekind = Recognized by SDK but unknown to AAFInfo\n"); } } else { fprintf(stderr, "Error : Failed to open file (result = %0x).\n", hr); exit(1); } }
static HRESULT ReadAAFFile(aafWChar * pFileName) { IAAFFile *pFile = NULL; bool bFileOpen = false; IAAFHeader *pHeader = NULL; IEnumAAFMobs *mobIter = NULL; IAAFMob *aMob = NULL; IEnumAAFMobSlots *slotIter = NULL; IAAFMobSlot *slot = NULL; IAAFSegment *pSeg = NULL; IAAFSourceClip *pSourceClip = NULL; IAAFDataDef * pDataDef = 0; IAAFDefObject * pDefObj = 0; aafNumSlots_t numMobs, n; aafSlotID_t s; aafUInt32 length; HRESULT hr = S_OK; aafUID_t readUID, typeUID = kAAFDataDef_Picture; 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)); checkResult(pHeader->CountMobs(kAAFAllMob, &numMobs)); checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED); aafSearchCrit_t criteria; criteria.searchTag = kAAFNoSearch; checkResult(pHeader->GetMobs (&criteria, &mobIter)); for(n = 0; n < numMobs; n++) { aafWChar name[500], slotName[500]; aafNumSlots_t numSlots; aafMobID_t mobID; aafSlotID_t trackID; checkResult(mobIter->NextOne (&aMob)); checkResult(aMob->GetName (name, sizeof(name))); checkResult(aMob->GetMobID (&mobID)); checkResult(aMob->CountSlots (&numSlots)); checkExpression(5 == numSlots, AAFRESULT_TEST_FAILED); checkResult(aMob->GetSlots(&slotIter)); for(s = 0; s < (aafSlotID_t)numSlots; s++) { checkResult(slotIter->NextOne (&slot)); checkResult(slot->GetNameBufLen(&length)); checkResult(slot->GetName (slotName, length)); checkExpression (wcscmp(slotName, slotNames[s]) == 0, AAFRESULT_TEST_FAILED); checkResult(slot->GetSlotID(&trackID)); checkExpression (trackID == s+1, AAFRESULT_TEST_FAILED); checkResult(slot->GetPhysicalNum(&trackID)); checkExpression (trackID == s+2, AAFRESULT_TEST_FAILED); checkResult(slot->GetPhysicalNum(&trackID)); checkResult(slot->GetDataDef(&pDataDef)); checkResult(pDataDef->QueryInterface (IID_IAAFDefObject, (void **)&pDefObj)); checkResult(pDefObj->GetAUID(&readUID)); checkExpression (memcmp(&typeUID, &readUID, sizeof(typeUID)) == 0, AAFRESULT_TEST_FAILED); checkResult(slot->GetSegment(&pSeg)); checkResult(pSeg->QueryInterface (IID_IAAFSourceClip, (void **)&pSourceClip)); pDataDef->Release(); pDataDef = 0; pDefObj->Release (); pDefObj = 0; pSourceClip->Release(); pSourceClip = NULL; pSeg->Release(); pSeg = NULL; slot->Release(); slot = NULL; } aMob->Release(); aMob = NULL; } } catch (HRESULT& rResult) { hr = rResult; } // Cleanup object references if (slot) { slot->Release(); slot = 0; } if (pSeg) { pSeg->Release(); pSeg = 0; } if (pSourceClip) { pSourceClip->Release(); pSourceClip = 0; } if (slotIter) { slotIter->Release(); slotIter = 0; } if (aMob) { aMob->Release(); aMob = 0; } if (mobIter) { mobIter->Release(); mobIter = 0; } if (pHeader) { pHeader->Release(); pHeader = 0; } if (pDataDef) { pDataDef->Release(); pDataDef = 0; } if (pDefObj) { pDefObj->Release (); pDefObj = 0; } if (pFile) { // Close file if (bFileOpen) pFile->Close(); pFile->Release(); pFile = 0; } return hr; }