Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cDirectShow.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cDirectShow_H
7 #define _INC_cDirectShow_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../AV/cSoundBase.h"
13 
14 #if defined(USE_DX_SHOW)
15 #include "../WinAPI/WinTypes.h"
18 #include "GrayCore/include/cOSHandle.h" // HANDLE_NULL
20 
21 MIDL_INTERFACE("56a868a9-0ad4-11ce-b03a-0020af0ba770") IGraphBuilder;
22 MIDL_INTERFACE("56a868b1-0ad4-11ce-b03a-0020af0ba770") IMediaControl;
23 MIDL_INTERFACE("56a868c0-0ad4-11ce-b03a-0020af0ba770") IMediaEventEx;
24 MIDL_INTERFACE("56a868b2-0ad4-11ce-b03a-0020af0ba770") IMediaPosition;
25 typedef double REFTIME;
26 
27 namespace GrayLib
28 {
29  class GRAYLIB_LINK cDirectShowObj
30  {
35  public:
36  enum STATE_TYPE // m_eState
37  {
38  STATE_UNINITIALIZED,
39  STATE_INIT,
40  STATE_STOPPED,
41  STATE_PAUSED,
42  STATE_PLAYING,
43  STATE_PLAYING_LOOP,
44  };
45 
46  static const GUID k_CLSID_GraphBuilder;
47 
48  protected:
49  STATE_TYPE m_eState;
50  cIUnkPtr<IGraphBuilder> m_pGraph;
51 #ifdef USE_DX_GraphROT
52  DWORD m_dwGraphROT;
53 #endif
54 
55  cIUnkPtr<IMediaControl> m_pMediaControl;
56  cIUnkPtr<IMediaEventEx> m_pMediaEvent;
57  cIUnkPtr<IMediaPosition> m_pMediaPosition;
58 
59  protected:
60  void OnGraphEventObj();
61  public:
62  cDirectShowObj(void);
63  virtual ~cDirectShowObj(void);
64 
65 #ifdef USE_DX_GraphROT
66  static HRESULT GRAYCALL AddGraphROT(IUnknown *pUnkGraph, DWORD *pdwRegister);
67  static void GRAYCALL RemoveGraphROT(DWORD dwRegister);
68  HRESULT AddGraphROT();
69  void RemoveGraphROT();
70 #endif
71 
72  IGraphBuilder* get_Graph() const
73  {
74  return m_pGraph;
75  }
76  void CleanUp(void);
77 
78  // state
79  bool CanPlay(void) const noexcept
80  {
81  return((m_eState == STATE_STOPPED) || (m_eState == STATE_PAUSED));
82  }
83  bool CanPause(void) const noexcept
84  {
85  return((m_eState >= STATE_PLAYING) || (m_eState == STATE_STOPPED));
86  }
87  bool CanStop(void) const noexcept
88  {
89  return((m_eState >= STATE_PLAYING) || (m_eState == STATE_PAUSED));
90  }
91  bool isInitialized(void) const
92  {
93  if ( m_eState == STATE_UNINITIALIZED)
94  {
95  ASSERT(m_pGraph==nullptr);
96  return false;
97  }
98  ASSERT(m_pGraph!=nullptr);
99  return true;
100  }
101  bool isStopped(void) const noexcept
102  {
103  return( m_eState == STATE_STOPPED );
104  }
105  bool isPaused(void) const noexcept
106  {
107  return( m_eState == STATE_PAUSED);
108  }
109  bool isPlaying(void) const noexcept
110  {
111  return( m_eState >= STATE_PLAYING );
112  }
113  bool isPlayingLoop(void) const noexcept
114  {
115  return( m_eState == STATE_PLAYING_LOOP );
116  }
117  bool CheckCompleted( TIMESYSD_t dwTimeout=0 ) const;
118 
119  // play
120  HRESULT PlayShow( bool bLoop = false );
121  HRESULT Pause(void);
122  HRESULT Rewind(void);
123  HRESULT Stop(void);
124 
125  HRESULT put_Volume( SOUND_VOL_t nVol ); // k_VOL_MAX
126 
127  HRESULT GetTimeDuration( REFTIME *plength ) const;
128  HRESULT SeekTime( REFTIME tpos );
129 
130  static void GRAYCALL OnGraphEvent( LPARAM dwInstance ); // called back from window message
131 
132  HRESULT AttachFilterGraph(IGraphBuilder* pGraph, HWND hWndEvents = WINHANDLE_NULL, WINMSG_t uMsgEvent = WM_NULL, HANDLE hLogFile = INVALID_HANDLE_VALUE);
133  HRESULT CreateFilterGraph(HWND hWndEvents = WINHANDLE_NULL, WINMSG_t uMsgEvent = WM_NULL, HANDLE hLogFile = INVALID_HANDLE_VALUE);
134 
135  UNITTEST_FRIEND(cDirectShow);
136  };
137 
138  class GRAYLIB_LINK cDirectShowFile : public cDirectShowObj
139  {
142  protected:
143  cStringF m_strFile;
144  public:
145  HRESULT LoadShowFile(cStringF strFile, HWND hWndEvents = WINHANDLE_NULL, WINMSG_t uMsgEvent = WM_NULL, HANDLE hLogFile = INVALID_HANDLE_VALUE);
146  void CleanUp(void);
147 
148  cStringF get_FileName(void) const
149  {
150  return m_strFile;
151  }
152  };
153 }
154 #endif // USE_DX_SHOW
155 #endif // _INC_cDirectShow_H
MIDL_INTERFACE("7ED943DD-52E8-40b5-A8D8-76685C406330") ID3DXBaseMesh
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
UINT WINMSG_t
Supplement _WIN32 "windows.h".
Definition: WinTypes.h:111
#define WM_NULL
Windows HWND messages not always defined.
Definition: WinTypes.h:115
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: IUnknown.h:68
Definition: cMesh.h:22
WORD SOUND_VOL_t
Mono Attenuation of the audio. linear perception 0 to k_VOL_MAX(0xffff). NOT decibels.
Definition: cSoundBase.h:29
cStringT< FILECHAR_t > cStringF
A file name. checks USE_UNICODE_FN. related to cFilePath.
Definition: cFilePath.h:17
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
Definition: IUnknown.h:34