Ejemplo n.º 1
0
int main()
{
	CAAFInitialize aafInit;
	
	const aafWChar *		pwFileName	= L"ExportAudioExample.aaf";
	const char *	pFileName	= "ExportAudioExample.aaf";
	
  // Make sure all of our required plugins have been registered.
  checkFatal(RegisterRequiredPlugins());

  printf("Creating file %s using WriteSamples (Internal Media)...\n", pFileName);
	checkFatal(CreateAAFFile(pwFileName, NULL, testStandardCalls));

	printf("DONE\n\n");

	return(0);
}
Ejemplo n.º 2
0
int main(int /*argc*/, char** /*argv*/)
{
  CAAFInitialize aafInit;

  const aafWChar* pwFileName = L"MetadataTest.aaf";
  const char* pFileName = "";

  // Make sure all of our required plugins have been registered.
  checkFatal(RegisterRequiredPlugins());

  /**/
  printf("***Creating file %s using WriteSamples (Internal Media)\n", pFileName);
  checkFatal(CreateAAFFile(pwFileName, NULL, testStandardCalls));
  printf("***Re-opening file %s using ReadSamples\n", pFileName);
  ReadAAFFile(pwFileName, testStandardCalls);
  /**/

  printf("Done\n");


  return(0);
}
Ejemplo n.º 3
0
static HRESULT ProcessAAFFile(const aafWChar * pFileName, testType_t testType)
{
	IAAFFile *					pFile = NULL;
	IAAFHeader *				pHeader = NULL;
	IAAFDictionary*				pDictionary = NULL;
	IEnumAAFMobs*				pMobIter = NULL;
	aafNumSlots_t				numMobs, numSlots;
	aafSearchCrit_t				criteria;
	aafMobID_t					mobID;
	aafWChar					namebuf[1204];
	const aafWChar*				slotName = L"A slot in Composition Mob";
	IAAFComponent*				pComponent = NULL;
	IAAFComponent*				aComponent = NULL;
	IEnumAAFMobSlots*			pMobSlotIter = NULL;
	IAAFMobSlot*				pMobSlot = NULL;
	IAAFTimelineMobSlot*		newSlot = NULL;
	IAAFSegment*				seg = NULL;
	IAAFSegment*				pSegment = NULL;
	IAAFMob*					pCompMob = NULL;
	IAAFMob*					pMob = NULL;
	aafPosition_t				zeroPos = 0;
	IAAFSequence*				pAudioSequence = NULL;
	IAAFSourceClip*				pSourceClip = NULL;
	aafLength_t					duration;
	IAAFTimelineMobSlot* pTimelineMobSlot = NULL;
  IAAFClassDef *pCompositionMobDef = NULL;
  IAAFClassDef *pSequenceDef = NULL;
  IAAFClassDef *pSourceClipDef = NULL;
  IAAFDataDef *pSoundDef = NULL;
  IAAFDataDef *pDataDef = NULL;
	

	// Set the edit rate information
	aafRational_t				editRate;
	editRate.numerator = 48000;
	editRate.denominator = 1;

	// Set search condition to true
	bool lookingForAudio = true;

	// Call the routine (from ExportAudioExample) to make the file for processing
	check(CreateAAFFile(pwFileName, NULL, testStandardCalls, &pFile));

	/* Get the Header and iterate through the Master Mobs in the existing file */
	check(pFile->GetHeader(&pHeader));
	check(pHeader->GetDictionary(&pDictionary));

	
  /* Lookup class definitions for the objects we want to create. */
  check(pDictionary->LookupClassDef(AUID_AAFCompositionMob, &pCompositionMobDef));
  check(pDictionary->LookupClassDef(AUID_AAFSequence, &pSequenceDef));
  check(pDictionary->LookupClassDef(AUID_AAFSourceClip, &pSourceClipDef));

  /* Lookup any necessary data definitions. */
  check(pDictionary->LookupDataDef(kAAFDataDef_Sound, &pSoundDef));
  

	// Get the number of master mobs in the existing file (must not be zero)
	check(pHeader->CountMobs(kAAFMasterMob, &numMobs));
	if (numMobs != 0)
	{
		printf("Found %d Master Mobs\n", numMobs);
		criteria.searchTag = kAAFByMobKind;
		criteria.tags.mobKind = kAAFMasterMob;
		check(pHeader->GetMobs(&criteria, &pMobIter));

		/* Create a Composition Mob */
		check(pCompositionMobDef->
			  CreateInstance(IID_IAAFMob,
							 (IUnknown **)&pCompMob));
		/* Append the Mob to the Header */
		check(pHeader->AddMob(pCompMob));
 
		/* Create a TimelineMobSlot with an audio sequence */
		check(pSequenceDef->
			  CreateInstance(IID_IAAFSequence,
							 (IUnknown **)&pAudioSequence));
		check(pAudioSequence->QueryInterface(IID_IAAFSegment, (void **)&seg));

		check(pAudioSequence->QueryInterface(IID_IAAFComponent,
											 (void **)&aComponent));

		check(aComponent->SetDataDef(pSoundDef));
		check(pCompMob->AppendNewTimelineSlot(editRate, seg, 1, slotName, zeroPos, &newSlot));
    seg->Release();
    seg = NULL;
    newSlot->Release();
    newSlot = NULL;

		// This variable is about to be overwritten so we need to release the old interface
		aComponent->Release();
		aComponent = NULL;

		while((AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob)))
		{
			//  Print out information about the Mob
			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);
			
			// Add a Source Clip for each Master Mob to the audio sequence by iterating
			check(pMob->GetSlots(&pMobSlotIter));
			
			/* Iterating through all Mob Slots */
			// Get the number of slots
			check(pMob->CountSlots(&numSlots));
			
			while (lookingForAudio && (AAFRESULT_SUCCESS == pMobSlotIter->NextOne(&pMobSlot)));
			{
				/* Check to see if it is an Audio Timeline Mob Slot */
				HRESULT hr;
				
				hr=pMobSlot->QueryInterface(IID_IAAFTimelineMobSlot,(void **) &pTimelineMobSlot);
				if (SUCCEEDED(hr))
				{
					printf("Found a timeline mob slot\n");
					check(pMobSlot->GetDataDef(&pDataDef));
					
					// Check that we have a sound file by examining its data definition
          aafBool bIsSoundKind = kAAFFalse;
          check(pDataDef->IsSoundKind(&bIsSoundKind));

          if (kAAFTrue == bIsSoundKind)
					{
						printf("Found a sound file\n");

						// We are no longer looking for audio data so set boolean	
						lookingForAudio = false;

						/* Get the information for the new source clip */
						check(pMob->GetMobID(&sourceRef.sourceID));
						check(pMobSlot->GetSlotID(&sourceRef.sourceSlotID));
						check(pTimelineMobSlot->GetOrigin(&sourceRef.startTime));
						check(pMobSlot->GetSegment(&pSegment));
						check(pSegment->QueryInterface(IID_IAAFComponent, (void **)&pComponent));
						check(pComponent->GetLength(&duration));
            pComponent->Release();
            pComponent = NULL;
            pSegment->Release();
            pSegment = NULL;
						
						// this loop is to be removed upon fixing of the bug
						// in essenceaccess relating to codec definitions...
						int j = 0;
						for (j=0; j<10; j++)
						{
							/* Create a new Source Clip */
							check(pSourceClipDef->
								  CreateInstance(IID_IAAFSourceClip,
												 (IUnknown **)&pSourceClip));
							// Initialize the Source Clip
							check(pSourceClip->Initialize( pSoundDef, duration, sourceRef));
							check(pSourceClip->QueryInterface(IID_IAAFComponent, (void **) &pComponent));
							check(pAudioSequence->AppendComponent(pComponent));
              pComponent->Release();
              pComponent = NULL;
							pSourceClip->Release();
							pSourceClip = NULL;
						}
					}
					pTimelineMobSlot->Release();
					pTimelineMobSlot = NULL;

          pDataDef->Release();
          pDataDef = NULL;
				}	
        
        pMobSlot->Release();
        pMobSlot = NULL;
			}

      pMobSlotIter->Release();
      pMobSlotIter = NULL;
		  pMob->Release();
		  pMob = NULL;
		}
		

    pAudioSequence->Release();
    pAudioSequence = NULL;

    pCompMob->Release();
    pCompMob = NULL;

		pMobIter->Release();
		pMobIter = NULL;
	}
	else
	{
		printf("Error with file: File has no Master mobs.\n");
	}

cleanup:
	// Cleanup and return
  if (pSourceClip)
    pSourceClip->Release();

  if (pComponent)
    pComponent->Release();

  if (pSegment)
    pSegment->Release();

  if (pTimelineMobSlot)
    pTimelineMobSlot->Release();

  if (pMobSlotIter)
    pMobSlotIter->Release();

  if (pMob)
    pMob->Release();

  if (newSlot)
    newSlot->Release();

  if (aComponent)
    aComponent->Release();

  if (seg)
    seg->Release();

  if (pAudioSequence)
    pAudioSequence->Release();

  if (pCompMob)
    pCompMob->Release();

  if (pMobIter)
		pMobIter->Release();

  if (pDataDef)
    pDataDef->Release();

  if (pSoundDef)
    pSoundDef->Release();

  if (pSourceClipDef)
    pSourceClipDef->Release();

  if (pSequenceDef)
    pSequenceDef->Release();

  if (pCompositionMobDef)
    pCompositionMobDef->Release();

	if (pDictionary)
		pDictionary->Release();

	if (pHeader)
		pHeader->Release();

	if (pFile) 
	{
	  /* Save the AAF file */
    pFile->Save();
	  /* Close the AAF file */
		pFile->Close();
		pFile->Release();
	}

	return moduleErrorTmp;
}
Ejemplo n.º 4
0
//  Main adapted to use command-line arguments with argument checking
//  NOTE:  defining [0] program name; [1] Number N of components;
//  [2] filename.aaf;
int main(int argumentCount, char *argumentVector[])
{
  //  First check for correct number of arguments
  //  printf("%ld\n",argumentCount);
  if ((argumentCount < 2) || (argumentCount > 3)) {
    usage();
    return 0;
  }
  //  Processing the second argument to be stored as global variable N
  char* Ns = argumentVector[1];
  char* expectedEnd = &Ns[strlen(Ns)];
  char* end = 0;
  long int N = strtoul(Ns, &end, 10);

  //  Testing for correct second argument
  if ((end != expectedEnd) || (N < 1)) {
    printf("The first argument was of the incorrect form. [%s]\n",
           argumentVector[1]);
    usage();
    return 0;
  }

  //  With no second argument, set output filename to CreateSequence<N>.aaf
  if (argumentCount == 2) {
    strncpy(niceFileName, Ns, FILENAME_MAX);
  } else  {
    //  Otherwise output to filename specified in the second argument
    //  NB this case must have argC ==3 from earlier check

    strncpy(niceFileName, argumentVector[2], FILENAME_MAX);
  }
  if (strstr(niceFileName, ".aaf") == 0)
    strcat (niceFileName, ".aaf");

  //  and then carry on...

  // Load the AAF library explicity to catch the common error
  // that the AAF DLL is not in the user's path, otherwise this
  // error looks like an error opening the file.
  //
  HRESULT hr = AAFLoad(0);
  if (!AAFRESULT_SUCCEEDED(hr)) {
    fprintf(stderr, "Error : Failed to load the AAF library, ");
    fprintf(stderr, "check environment variables -\n");
    fprintf(stderr, "  Windows    - $PATH\n");
    fprintf(stderr, "  Unix/Linux - $LD_LIBRARY_PATH\n");
    exit(hr);
  }

  aafWChar FileNameBuffer[MAX];
  mbstowcs(FileNameBuffer, niceFileName, MAX);

  aafWChar * pwFileName = FileNameBuffer;

  //  Give a nice output here too...
  printf("Creating file %s with %ld components.\n", niceFileName, N);
  checkFatal(CreateAAFFile(pwFileName, N));

  // Open the file and gather statistics
  ReadAAFFile(pwFileName);

  return(0);
}