InetSendSound Example for C++ 5.0 and later

// This example uses LEAD Capture control to capture audio from the microphone and uses the LEAD //Internet Control to send it to a remote computer. For an example of starting and stopping recording
//refer to the LEAD Capture control documentation.

void CNetDlg::OnCapAudioDataLeadcapctrl(const VARIANT FAR& pData, long lBytesRecorded, short iIndex)
{
   // send sound to remote computer (items in SendList property)
   // you should be connected to a remote computer first by using the
   // InetConnect method of the Internet COM


   ILEADRasterVariant * pltRasVar1 = NULL;
   ILEADRasterVariant * pltRasVar2 = NULL;

   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant, (void **)&pltRasVar1);

   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant, (void **)&pltRasVar2);

   VARIANT var;
   var = m_LEADCap1.GetCapWaveExtraData(iIndex);

   if(var.vt = VT_ARRAY | VT_UI1)
   {
      pltRasVar1->Type = VALUE_ARRAY_BYTE;
      pltRasVar1->ItemCount = var.parray->rgsabound->cElements;
      for(long i = 0; i<pltRasVar1->ItemCount ; i++)
      SafeArrayGetElement(pData.parray , &i, pltRasVar1->ShortItemValue (i));
   }
   else if (var.vt = VT_BSTR)
   {
      pltRasVar1->Type = VALUE_STRING;
      pltRasVar1->StringValue = var.bstrVal;
   }
   else
      return;


   if(pData.vt = VT_ARRAY | VT_UI1)
   {
      pltRasVar2->Type = VALUE_ARRAY_BYTE;
      pltRasVar2->ItemCount = pData.parray->rgsabound->cElements;
      for(long i = 0; i<pltRasVar2->ItemCount ; i++)
         SafeArrayGetElement(pData.parray , &i, pltRasVar2->ShortItemValue (i));
   }
   else if (pData.vt = VT_BSTR)
   {
      pltRasVar2->Type = VALUE_STRING;
      pltRasVar2->StringValue = pData.bstrVal ;
   }
   else
      return;

   m_pRasterInet->InetSendSound(m_LEADCap1.GetCapWaveFormatTag (iIndex), m_LEADCap1.GetCapWaveChannels (iIndex),
m_LEADCap1.GetCapWaveSamplesPerSec (iIndex), m_LEADCap1.GetCapWaveAvgBytesPerSec (iIndex), m_LEADCap1.GetCapWaveBlockAlign (iIndex), m_LEADCap1.GetCapWaveBitsPerSample (iIndex), (short)m_LEADCap1.GetCapWaveExtraSize (iIndex), pltRasVar1, pltRasVar2, lBytesRecorded);

   VariantClear(&var);
   pltRasVar1->Release ();
   pltRasVar2->Release ();
}