IltmmWMProfile::get_MutualExclusionCount Example for C

For complete code, refer to the CNVWM demo.

// The example below checks all the streams for 
// a mutual object. If the quality is less than 50, 
// it is removed. 
void SetupMutualObjects(IltmmWMProfile *pProfile) 
{
   USES_CONVERSION; 

   IltmmWMMutualExclusion *pMutualExc = NULL; 
   IltmmWMStreamConfig *pStreamConfig = NULL; 
   long lMCount; 
   long lSCount; 
   long lStreamNumber; 
   long lQuality; 
   BSTR bstrData; 
   char strUpdate[255];
   int i;
   int j;

   IltmmWMProfile__get_MutualExclusionCount(pProfile, &lMCount); 

   // iterate through the objects
   for(i=0; i<lMCount; i++)
   {
      IltmmWMProfile__getMutualExclusion(pProfile, i, &pMutualExc); 

      IltmmWMMutualExclusion__get_StreamCount(pMutualExc, &lSCount); 

      if(lSCount == 0) 
      {
         IltmmWMProfile_RemoveMutualExclusion(pProfile, pMutualExc); 
         IltmmWMMutualExclusion_Release(pMutualExc); 
      }
      else
      {
         for(j=0; j<lSCount; j++)
         {
            // obtain the stream number
            IltmmWMMutualExclusion__getStream(pMutualExc, j, &lStreamNumber); 
            // get the stream using it's number
            IltmmWMProfile__getStreamByNumber (pProfile, lStreamNumber, &pStreamConfig); 
            // check it's quality, if it is less than 50, remove it... 
            IltmmWMStreamConfig__get_Quality(pStreamConfig, &lQuality); 
            if(lQuality < 50) 
            {
               // remove it... 
               IltmmWMMutualExclusion_RemoveStream(pMutualExc, lStreamNumber); 
            }

            // report the user with update... 
            IltmmWMMutualExclusion__get_Type(pMutualExc, &bstrData); 
            sprintf(strUpdate, "Updating Mutual object with type :\n %s", OLE2A(bstrData)); 
            SysFreeString(bstrData); 

            MessageBox(NULL, strUpdate, "Update...", MB_OK); 

            IltmmWMStreamConfig_Release(pStreamConfig); 
            IltmmWMMutualExclusion_Release(pMutualExc); 
         }
      }
   }
}

For complete code, refer to the CNVWM demo. The example below checks all the streams for a mutual object. If the quality is less than 50, it is removed.

LPTSTR OLE2A(LPCOLESTR lpw)
{
   static CHAR convert[512];

   if(!lpw)
      return NULL;

   convert[0] = '\0';

   WideCharToMultiByte(CP_ACP, 0, lpw, -1, convert, 512, NULL, NULL);

   return convert;
}

L_MULTIMEDIATEX_API void IltmmWMProfile_get_MutualExclusionCount_Example (IltmmWMProfile *pProfile)
{
   IltmmWMMutualExclusion *pMutualExc = NULL; 
   IltmmWMStreamConfig *pStreamConfig = NULL; 
   long lMCount; 
   long lSCount; 
   long lStreamNumber; 
   long lQuality; 
   BSTR bstrData; 
   char strUpdate[255];
   int i;
   int j;

   IltmmWMProfile_get_MutualExclusionCount(pProfile, &lMCount); 

   // iterate through the objects
   for(i=0; i<lMCount; i++)
   {
      IltmmWMProfile_GetMutualExclusion(pProfile, i, &pMutualExc); 

      IltmmWMMutualExclusion_get_StreamCount(pMutualExc, &lSCount); 

      if(lSCount == 0) 
      {
         IltmmWMProfile_RemoveMutualExclusion(pProfile, pMutualExc); 
         IltmmWMMutualExclusion_Release(pMutualExc); 
      }
      else
      {
         for(j=0; j<lSCount; j++)
         {
            // obtain the stream number
            IltmmWMMutualExclusion_GetStream(pMutualExc, j, &lStreamNumber); 
            // get the stream using it's number
            IltmmWMProfile_GetStreamByNumber (pProfile, lStreamNumber, &pStreamConfig); 
            // check it's quality, if it is less than 50, remove it... 
            IltmmWMStreamConfig_get_Quality(pStreamConfig, &lQuality); 
            if(lQuality < 50) 
            {
               // remove it... 
               IltmmWMMutualExclusion_RemoveStream(pMutualExc, lStreamNumber); 
            }

            // report the user with update... 
            IltmmWMMutualExclusion_get_Type(pMutualExc, &bstrData); 
            sprintf(strUpdate, "Updating Mutual object with type :\n %s", OLE2A(bstrData)); 
            SysFreeString(bstrData); 

            MessageBox(NULL, strUpdate, "Update...", MB_OK); 

            IltmmWMStreamConfig_Release(pStreamConfig); 
            IltmmWMMutualExclusion_Release(pMutualExc); 
         }
      }
   }
}