DSOutputStream.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #ifndef PLUGIN_DSHOW_DSOUTPUTSTREAM_H
  19. #define PLUGIN_DSHOW_DSOUTPUTSTREAM_H
  20. #include "plugin_dshow_config.h"
  21. #include <streams.h>
  22. #include "tsk_mutex.h"
  23. class DSOutputFilter;
  24. class DSOutputStream : public CSourceStream
  25. {
  26. public:
  27. DSOutputStream(HRESULT *phr, DSOutputFilter *pParent, LPCWSTR pPinName);
  28. virtual ~DSOutputStream();
  29. void setFps(int fps_);
  30. void showOverlay(int value);
  31. HRESULT setImageFormat(UINT width, UINT height);
  32. bool getImageFormat(UINT &width, UINT &height);
  33. STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
  34. return E_NOTIMPL;
  35. };
  36. inline bool lockBuffer() {
  37. if (this->mutex) {
  38. return tsk_mutex_lock(this->mutex) == 0;
  39. }
  40. return false;
  41. }
  42. inline bool unlockBuffer() {
  43. if (this->mutex) {
  44. return tsk_mutex_unlock(this->mutex) == 0;
  45. }
  46. return false;
  47. }
  48. public:
  49. void *buffer;
  50. int buffer_size;
  51. LONGLONG frameNumber;
  52. protected: // Overrides
  53. HRESULT GetMediaType(CMediaType *pMediaType);
  54. HRESULT DecideBufferSize(IMemAllocator *pMemAlloc, ALLOCATOR_PROPERTIES *pProperties);
  55. HRESULT OnThreadCreate();
  56. HRESULT OnThreadDestroy();
  57. HRESULT FillBuffer(IMediaSample *pSample);
  58. private:
  59. inline HRESULT DrawOverLay(void *pBuffer, long lSize);
  60. private:
  61. // TIMING
  62. REFERENCE_TIME frameLength;
  63. int fps;
  64. // sizing
  65. UINT width;
  66. UINT height;
  67. // overlaying
  68. bool overlay;
  69. BITMAPINFO bitmapInfo;
  70. void *paintBuffer;
  71. HDC paintDC;
  72. HBITMAP hDibSection;
  73. HGDIOBJ hObject;
  74. tsk_mutex_handle_t* mutex;
  75. };
  76. #endif