mf_sample_grabber.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (C) 2013 Mamadou DIOP
  2. * Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. */
  19. #ifndef PLUGIN_WIN_MF_SAMPLE_GRABBER_H
  20. #define PLUGIN_WIN_MF_SAMPLE_GRABBER_H
  21. #include "../plugin_win_mf_config.h"
  22. #include <new>
  23. #include <mfapi.h>
  24. #include <mfidl.h>
  25. #include <Mferror.h>
  26. #include <shlwapi.h>
  27. //
  28. // Sample Grabber callback [Declaration]
  29. // http://msdn.microsoft.com/en-us/library/windows/desktop/hh184779(v=vs.85).aspx
  30. //
  31. class SampleGrabberCB : public IMFSampleGrabberSinkCallback
  32. {
  33. bool m_bMuted;
  34. long m_cRef;
  35. const struct tmedia_producer_s* m_pWrappedProducer;
  36. SampleGrabberCB(const struct tmedia_producer_s* pcWrappedProducer) : m_cRef(1), m_bMuted(false), m_pWrappedProducer(pcWrappedProducer) {}
  37. public:
  38. static HRESULT CreateInstance(const struct tmedia_producer_s* pcWrappedProducer, SampleGrabberCB **ppCB);
  39. void SetMute(bool bMuted) {
  40. m_bMuted = bMuted;
  41. }
  42. // IUnknown methods
  43. STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
  44. STDMETHODIMP_(ULONG) AddRef();
  45. STDMETHODIMP_(ULONG) Release();
  46. // IMFClockStateSink methods
  47. STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset);
  48. STDMETHODIMP OnClockStop(MFTIME hnsSystemTime);
  49. STDMETHODIMP OnClockPause(MFTIME hnsSystemTime);
  50. STDMETHODIMP OnClockRestart(MFTIME hnsSystemTime);
  51. STDMETHODIMP OnClockSetRate(MFTIME hnsSystemTime, float flRate);
  52. // IMFSampleGrabberSinkCallback methods
  53. STDMETHODIMP OnSetPresentationClock(IMFPresentationClock* pClock);
  54. STDMETHODIMP OnProcessSample(REFGUID guidMajorMediaType, DWORD dwSampleFlags,
  55. LONGLONG llSampleTime, LONGLONG llSampleDuration, const BYTE * pSampleBuffer,
  56. DWORD dwSampleSize);
  57. STDMETHODIMP OnShutdown();
  58. };
  59. #endif /* PLUGIN_WIN_MF_SAMPLE_GRABBER_H */