MediaThread.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef NULLSOFT_MEDIATHREADH
  2. #define NULLSOFT_MEDIATHREADH
  3. #include <deque>
  4. #include <wmsdk.h>
  5. #include <vector>
  6. VOID CALLBACK MediaThread_StartAPC(ULONG_PTR param);
  7. VOID CALLBACK MediaThread_AddAPC(ULONG_PTR param);
  8. struct MediaBuffer
  9. {
  10. MediaBuffer(INSSBuffer *b, QWORD t, unsigned long f, bool d) : buffer(b), timestamp(t), flags(f), drmProtected(d) {}
  11. INSSBuffer *buffer;
  12. QWORD timestamp;
  13. unsigned long flags;
  14. bool drmProtected;
  15. };
  16. struct MediaBufferAPC;
  17. class MediaThread
  18. {
  19. public:
  20. MediaThread();
  21. ~MediaThread();
  22. bool AddBuffer(INSSBuffer *buff, QWORD ts, unsigned long flags, bool drmProtected);
  23. void Stop();
  24. void SignalStop();
  25. void WaitForStop();
  26. void Kill();
  27. public:
  28. void StopAPC();
  29. void StartAPC();
  30. virtual void AddAPC(MediaBuffer *buffer)=0;
  31. protected:
  32. void OrderedInsert(MediaBuffer *buffer);
  33. protected:
  34. int wait;
  35. HANDLE thread;
  36. HANDLE killEvent, stopped, bufferFreed;
  37. typedef std::vector<MediaBuffer*> BufferList;
  38. BufferList buffers;
  39. };
  40. struct MediaBufferAPC
  41. {
  42. MediaBuffer *buffer;
  43. MediaThread *thread;
  44. };
  45. #endif