1
0

CWAAudioRenderer.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "CWAAudioRenderer.h"
  2. CWAAudioRenderer::CWAAudioRenderer()
  3. : CAudioSwitchRenderer(CLSID_WAAudioRend, TEXT("WAAudioRenderer"), NULL, NULL)//,
  4. //CBaseReferenceClock(TEXT("WARefClock"), NULL, NULL, NULL)
  5. {
  6. m_callback = NULL;
  7. }
  8. CWAAudioRenderer::~CWAAudioRenderer()
  9. {
  10. delete(m_callback);
  11. }
  12. HRESULT CWAAudioRenderer::DoRenderSample(IMediaSample *pMediaSample)
  13. {
  14. if (m_callback)
  15. {
  16. REFERENCE_TIME StartTime, StopTime;
  17. pMediaSample->GetTime( &StartTime, &StopTime);
  18. StartTime += m_pInputPin[m_inputSelected]->CurrentStartTime( );
  19. StopTime += m_pInputPin[m_inputSelected]->CurrentStartTime( );
  20. m_callback->sample_cb(StartTime, StopTime, pMediaSample);
  21. }
  22. return NOERROR;
  23. }
  24. HRESULT CWAAudioRenderer::CheckMediaType(const CMediaType *pmt)
  25. {
  26. if (pmt->majortype != MEDIATYPE_Audio) return E_INVALIDARG;
  27. if (pmt->formattype != FORMAT_WaveFormatEx) return E_INVALIDARG;
  28. if (pmt->subtype != MEDIASUBTYPE_PCM && pmt->subtype != MEDIASUBTYPE_IEEE_FLOAT) return E_INVALIDARG;
  29. return NOERROR;
  30. }
  31. HRESULT CWAAudioRenderer::SetMediaType(const CMediaType *pmt)
  32. {
  33. m_mt = *pmt;
  34. return NOERROR;
  35. }
  36. CMediaType *CWAAudioRenderer::GetAcceptedType()
  37. {
  38. return &m_mt;
  39. }
  40. HRESULT CWAAudioRenderer::SetCallback(CSampleCB *Callback)
  41. {
  42. m_callback = Callback;
  43. return NOERROR;
  44. }
  45. HRESULT CWAAudioRenderer::EndOfStream(void)
  46. {
  47. if (m_callback)
  48. m_callback->endofstream();
  49. return CAudioSwitchRenderer::EndOfStream();
  50. }
  51. HRESULT CWAAudioRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime)
  52. {
  53. return S_OK;
  54. }
  55. HRESULT CWAAudioRenderer::GetSampleTimes(IMediaSample *pMediaSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime)
  56. {
  57. return S_OK;
  58. }