mf_sample_queue.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_QUEUE_H
  20. #define PLUGIN_WIN_MF_SAMPLE_QUEUE_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. class MFSampleQueue : public IUnknown
  28. {
  29. protected:
  30. // Nodes in the linked list
  31. struct Node {
  32. Node *prev;
  33. Node *next;
  34. IMFSample* item;
  35. Node() : prev(NULL), next(NULL) {
  36. }
  37. Node(IMFSample* item) : prev(NULL), next(NULL) {
  38. this->item = item;
  39. }
  40. IMFSample* Item() const {
  41. return item;
  42. }
  43. };
  44. protected:
  45. Node m_anchor;
  46. long m_nCount;
  47. CRITICAL_SECTION m_critSec;
  48. private:
  49. long m_nRefCount;
  50. public:
  51. MFSampleQueue();
  52. virtual ~MFSampleQueue();
  53. // IUnknown
  54. STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
  55. STDMETHODIMP_(ULONG) AddRef();
  56. STDMETHODIMP_(ULONG) Release();
  57. HRESULT Queue(IMFSample* item);
  58. HRESULT Dequeue(IMFSample**ppItem);
  59. HRESULT Clear();
  60. inline BOOL IsEmpty() const {
  61. return m_anchor.next == &m_anchor;
  62. }
  63. inline long Count() {
  64. return m_nCount;
  65. }
  66. };
  67. #endif /* PLUGIN_WIN_MF_SAMPLE_QUEUE_H */