My Project
dshowtextures.h
1 #pragma once
2 #include "mutex.h"
3 #include <streams.h>
4 #include <vector>
5 
6 //-----------------------------------------------------------------------------
7 // Define GUID for Texture Renderer
8 // {71771540-2017-11cf-AE26-0020AFD79767}
9 //-----------------------------------------------------------------------------
10 struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureRenderer;
11 //#define REGISTER_FILTERGRAPH
12 
13 namespace ParaEngine
14 {
15  using namespace std;
16 
17  class CGraphBuilder;
21  class CTextureRenderer:public CBaseVideoRenderer
22  {
23  public:
24  CTextureRenderer(LPUNKNOWN pUnk,HRESULT *phr);
25  ~CTextureRenderer();
26 
27  //void SetPinConnectState(BOOL bStatus);
28 
30  //
31  // the following function just override the base renderer interface. They are called in the codec thread.
32  //
34 
36  HRESULT CheckMediaType(const CMediaType *pmt);
37 
41  HRESULT SetMediaType(const CMediaType *pmt );
42  HRESULT GetConnectedMediaType(D3DFORMAT *uiTexFmt, LONG *uiVidBpp);
43 
48  HRESULT DoRenderSample(IMediaSample *pMediaSample);
49 
50  HRESULT GetDDMediaSample(IMediaSample *pSample);
51 #ifdef REGISTER_FILTERGRAPH
52  HRESULT AddToROT(IUnknown *pUnkGraph);
53  void RemoveFromROT(void);
54 #endif
55 
56  public:
58  //
59  // the following functions provide interface for the game thread to retrieve video data.
60  //
62 
66  HRESULT lock(byte** data, int* nSize);
68  HRESULT unlock();
69 
73  int GetWidth();
77  int GetHeight();
78 
82  HRESULT CreateTexture(LPDIRECT3DTEXTURE9 *pTexture);
83 
86  HRESULT UpdateTexture(LPDIRECT3DTEXTURE9 pTexture);
87 
88  protected:
89  D3DFORMAT m_TextureFormat;
90  LONG m_VideoBpp;
91 
92  VIDEOINFO m_viBmp;
93  bool m_bUseDynamicTextures;
94  LONG m_lVidWidth,m_lVidHeight,m_lVidPitch;
95  bool m_bUpSideDown;
96  HANDLE m_hInitDone;
97 
98  Mutex mMutex;
99  vector <byte> m_textureData;
100  bool m_bFrameChanged;
101  };
102 }