InetReceiveSound2 Example for C++ 5.0 and later

Note: This is not a complete example for handling events, some steps have been omitted. For a complete example of how to handle events, refer to the example Initializing a Computer as a Server and Accepting Connections.

You should have the following declaration at your H file for exeample ServerDlg.h

int m_nSoundFlag;
long m_hSound;
CLEADCap m_LEADCap1; // Lead capture control class

You should add the following to your project:

1. Edit the RasterInetSink.h file and add the following:

 //{{AFX_MSG(CRasterInetSink)
  // NOTE - the ClassWizard will add and remove member functions here.

  ....
  ....
  ....
afx_msg void OnInetReceiveSound2(short, short, short, long, long, short, short, short, const _variant_t &, const _variant_t &, const long);
//}}AFX_MSG

2. Edit the
RasterInetSink.cpp file and add the following two sections:

a.

BEGIN_DISPATCH_MAP(CRasterInetSink, CCmdTarget)

 //{{AFX_DISPATCH_MAP(CRasterInetSink)

  // NOTE - the ClassWizard will add and remove mapping macros here.

  ...
  ...
  ...

DISP_FUNCTION_ID(CRasterInetSink,"InetReceiveSound2",11,OnInetReceiveSound2, VT_EMPTY,VTS_I2 VTS_I2 VTS_I2 VTS_I4 VTS_I4 VTS_I2 VTS_I2 VTS_I2 VTS_I4) 

//}}AFX_DISPATCH_MAP 

END_DISPATCH_MAP()

 

b.

void CRasterInetSink::OnInetReceiveSound2(

short iComputer,
short iFormatTag,
short nChannels,
long lSamplesPerSec,
long lAvgBytesPerSec,
short iBlockAlign,
short iBitsPerSample,
short iExtraDataSize,
const _variant_t &pExtraData,
const _variant_t &pData,
long lDataSize)

{

   // this example uses the LEAD Capture Module for sound playback
   if (m_pDlg->m_nSoundFlag == FALSE)
   {
      m_pDlg->m_LEADCap1.SetCapWaveFormatTag(CAP_AUDIO_FEED, iFormatTag);
      m_pDlg->m_LEADCap1.SetCapWaveChannels (CAP_AUDIO_FEED, nChannels);
      m_pDlg->m_LEADCap1.SetCapWaveSamplesPerSec (CAP_AUDIO_FEED, lSamplesPerSec);
      m_pDlg->m_LEADCap1.SetCapWaveAvgBytesPerSec (CAP_AUDIO_FEED, lAvgBytesPerSec);
      m_pDlg->m_LEADCap1.SetCapWaveBlockAlign (CAP_AUDIO_FEED, iBlockAlign);
      m_pDlg->m_LEADCap1.SetCapWaveBitsPerSample (CAP_AUDIO_FEED, iBitsPerSample);
      m_pDlg->m_LEADCap1.SetCapWaveExtraSize (CAP_AUDIO_FEED, iExtraDataSize);
      m_pDlg->m_LEADCap1.SetCapWaveExtraData (CAP_AUDIO_FEED, pExtraData);

      m_pDlg->m_LEADCap1.CapStartFeedSound ("", -1, 0, CAP_FEED_PLAYDATA, &m_pDlg->m_hSound);

      m_pDlg->m_nSoundFlag = TRUE;
   }
   else
      m_pDlg->m_LEADCap1.CapFeedSound (m_pDlg->m_hSound, (VARIANT *)&pData, lDataSize);

   // when finished playing sound m_LEADCap1.CapStopFeedSound should be
   // called. A good place to do it would be in the InetDisconnected event