Enumerating MPEG2 Format Compatible Compressors Example for C

/* the following code demonstrates enumerates the valid audio and video compressors for the
   MPEG2 target format. A recommended compressor is also retrieved. */
void EnumMPEG2Compressors(IltmmConvert *pConvert)
{
   IltmmCompressors *pCompressors;
   IltmmCompressor *pCompressor;
   IltmmTargetFormats *pTargetformats;
   IltmmTargetFormat* pTargetformat;
   long lCount, lIndex, lValid;
   BSTR Name;

   /* set the target format to MPEG2 */
   IltmmConvert__put_TargetFormat(pConvert, ltmmCapture_TargetFormat_MPEG2_PROGRAM);

   IltmmConvert__get_TargetFormats(pConvert, &pTargetformats);
   IltmmTargetformats_Item(pTargetformats, ltmmCapture_TargetFormat_MPEG2_PROGRAM, &pTargetformat);
   IUnknown_Release(pTargetformats);

   /* Audio */
   /* get the compressors collection */
   IltmmConvert__get_AudioCompressors(pConvert, &Compressors);
   IltmmCompressors__get_Count(pCompressors, &lCount);

   for(lIndex = 0; lIndex < lCount; lIndex++)
   {
      long lValid;
      IltmmCompressors_Item(pCompressors, lIndex, &pCompressor);
      IltmmCompressor__get_Name(pCompressor, &Name);
      IltmmTargetformat_IsValidCompressor(pTargetformat, Name, &valid);
      if( lValid != ltmmTargetFormat_Compressor_Invalid )
      {
         // do whatever needed with the valid compressor (i.e. add it to some list)
      }
      ::SysFreeString(Name);
      IUnknown_Release(pCompressor);
   }

   // get the recommended compressor for the current format
   IltmmTargetformat__get_RecommendedAudioCompressor(pTargetformat, &Name);
   if( Name )
   {
      // do whatever needed with the recommended compressor (i.e. select it)
   }

   IUnknown_Release(pCompressors);

   /*Video*/
   /* get the compressors collection */
   IltmmConvert__get_VideoCompressors(pConvert, &Compressors);
   IltmmCompressors__get_Count(pCompressors, &lCount);

   for(lIndex = 0; lIndex < lCount; lIndex++)
   {
      long lValid;
      IltmmCompressors_Item(pCompressors, lIndex, &pCompressor);
      IltmmCompressor__get_Name(pCompressor, &Name);
      IltmmTargetformat_IsValidCompressor(pTargetformat, Name, &valid);
      if( lValid != ltmmTargetFormat_Compressor_Invalid )
      {
         // do whatever needed with the valid compressor (i.e. add it to some list)
      }
      ::SysFreeString(Name);
      IUnknown_Release(pCompressor);
   }

   // get the recommended compressor for the current format
   IltmmTargetformat__get_RecommendedVideoCompressor(pTargetformat, &Name);
   if( Name )
   {
      // do whatever needed with the recommended compressor (i.e. select it)
   }

   IUnknown_Release(pCompressors);
   pTargetformat->Release();
}