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;
   WCHAR wstrUpdate[255];

   pProfile->get_MutualExclusionCount(&lMCount);
   
   // iterate through the objects
   for (int i=0; i<lMCount; i++)
   {
      pProfile->GetMutualExclusion(i, &pMutualExc);
      pMutualExc->get_StreamCount(&lSCount);
      if (lSCount == 0)
      {
         pProfile->RemoveMutualExclusion(pMutualExc);
         pMutualExc->Release();
      }
      else
      {
         for (int j=0; j<lSCount; j++)
         {
            // obtain the stream number
            pMutualExc->GetStream(j, &lStreamNumber);
            // get the stream using it's number
            pProfile->GetStreamByNumber(lStreamNumber, &pStreamConfig);
            // check it's quality, if it is less than 50, remove it...
            pStreamConfig->get_Quality(&lQuality);
            if (lQuality < 50)
            {
               // remove it...
               pMutualExc->RemoveStream(lStreamNumber);
            }
            // report the user with update...
            pMutualExc->get_Type(&bstrData);
            wsprintf(wstrUpdate, TEXT("Updating Mutual object with type :\n %s"), bstrData);
            SysFreeString(bstrData);
            
            MessageBox(NULL, wstrUpdate, TEXT("Update..."), MB_OK);

            pStreamConfig->Release();
            pMutualExc->Release();
         }
      }
   }
}