BaseGraph.h
上传用户:tangyu_668
上传日期:2014-02-27
资源大小:678k
文件大小:10k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /* 
  2.  * Copyright (C) 2003-2006 Gabest
  3.  * http://www.gabest.org
  4.  *
  5.  *  This Program 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 2, or (at your option)
  8.  *  any later version.
  9.  *   
  10.  *  This Program 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 GNU Make; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21. #pragma once
  22. #include "IGraphBuilder2.h"
  23. class CPlayerWindow : public CWnd
  24. {
  25. public:
  26. CPlayerWindow() {}
  27. protected:
  28. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  29. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. typedef enum {DirectShow = 0, RealMedia, QuickTime, ShockWave} engine_t;
  33. [uuid("B110CDE5-6331-4118-8AAF-A870D6F7E2E4")]
  34. interface IGraphEngine : public IUnknown
  35. {
  36. STDMETHOD_(engine_t, GetEngine) () = 0;
  37. };
  38. enum 
  39. {
  40. EC_BG_AUDIO_CHANGED = EC_USER+1,
  41. EC_BG_ERROR
  42. };
  43. class CBaseGraph
  44. : public CUnknown
  45. , public IGraphBuilder2
  46. , public IMediaControl
  47. , public IMediaEventEx
  48. , public IMediaSeeking
  49. , public IVideoWindow
  50. , public IBasicVideo
  51. , public IBasicAudio
  52. , public IAMOpenProgress
  53. , public IGraphEngine
  54. {
  55. OAHWND m_hNotifyWnd;
  56. long m_lNotifyMsg;
  57. LONG_PTR m_lNotifyInstData;
  58. typedef struct {long m_lEventCode; LONG_PTR m_lParam1, m_lParam2;} GMSG;
  59. CList<GMSG> m_msgqueue;
  60. protected:
  61. void ClearMessageQueue();
  62. public:
  63. CBaseGraph();
  64. virtual ~CBaseGraph();
  65.     DECLARE_IUNKNOWN;
  66.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
  67. void NotifyEvent(long lEventCode, LONG_PTR lParam1 = 0, LONG_PTR lParam2 = 0);
  68. protected:
  69.     // IDispatch
  70. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  71. STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
  72. STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId);
  73. STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
  74. // IFilterGraph
  75.     STDMETHODIMP AddFilter(IBaseFilter* pFilter, LPCWSTR pName);
  76. STDMETHODIMP RemoveFilter(IBaseFilter* pFilter);
  77. STDMETHODIMP EnumFilters(IEnumFilters** ppEnum);
  78. STDMETHODIMP FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter);
  79. STDMETHODIMP ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt);
  80.     STDMETHODIMP Reconnect(IPin* ppin);
  81. STDMETHODIMP Disconnect(IPin* ppin);
  82.     STDMETHODIMP SetDefaultSyncSource();
  83. // IGraphBuilder
  84. STDMETHODIMP Connect(IPin* ppinOut, IPin* ppinIn);
  85.     STDMETHODIMP Render(IPin* ppinOut);
  86.     STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
  87. STDMETHODIMP AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
  88.     STDMETHODIMP SetLogFile(DWORD_PTR hFile);
  89.     STDMETHODIMP Abort();
  90.     STDMETHODIMP ShouldOperationContinue();
  91. // IFilterGraph2
  92. STDMETHODIMP AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx* pCtx, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter);
  93. STDMETHODIMP ReconnectEx(IPin* ppin, const AM_MEDIA_TYPE* pmt);
  94. STDMETHODIMP RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext);
  95. // IGraphBuilder2
  96. STDMETHODIMP IsPinDirection(IPin* pPin, PIN_DIRECTION dir);
  97. STDMETHODIMP IsPinConnected(IPin* pPin);
  98. STDMETHODIMP ConnectFilter(IBaseFilter* pBF, IPin* pPinIn);
  99. STDMETHODIMP ConnectFilter(IPin* pPinOut, IBaseFilter* pBF);
  100. STDMETHODIMP ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, const AM_MEDIA_TYPE* pmt);
  101. STDMETHODIMP NukeDownstream(IUnknown* pUnk);
  102. STDMETHODIMP FindInterface(REFIID iid, void** ppv, BOOL bRemove);
  103. STDMETHODIMP AddToROT();
  104. STDMETHODIMP RemoveFromROT();
  105. // IMediaControl
  106.     STDMETHODIMP Run();
  107.     STDMETHODIMP Pause();
  108.     STDMETHODIMP Stop();
  109. STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
  110.     STDMETHODIMP RenderFile(BSTR strFilename);
  111.     STDMETHODIMP AddSourceFilter(BSTR strFilename, IDispatch** ppUnk);
  112.     STDMETHODIMP get_FilterCollection(IDispatch** ppUnk);
  113.     STDMETHODIMP get_RegFilterCollection(IDispatch** ppUnk);
  114.     STDMETHODIMP StopWhenReady();
  115. // IMediaEvent
  116.     STDMETHODIMP GetEventHandle(OAEVENT* hEvent);
  117. STDMETHODIMP GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout);
  118.     STDMETHODIMP WaitForCompletion(long msTimeout, long* pEvCode);
  119. STDMETHODIMP CancelDefaultHandling(long lEvCode);
  120. STDMETHODIMP RestoreDefaultHandling(long lEvCode);
  121. STDMETHODIMP FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2);
  122. // IMediaEventEx
  123.     STDMETHODIMP SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
  124.     STDMETHODIMP SetNotifyFlags(long lNoNotifyFlags);
  125. STDMETHODIMP GetNotifyFlags(long* lplNoNotifyFlags);
  126. // IMediaSeeking
  127. STDMETHODIMP GetCapabilities(DWORD* pCapabilities);
  128. STDMETHODIMP CheckCapabilities(DWORD* pCapabilities);
  129. STDMETHODIMP IsFormatSupported(const GUID* pFormat);
  130. STDMETHODIMP QueryPreferredFormat(GUID* pFormat);
  131. STDMETHODIMP GetTimeFormat(GUID* pFormat);
  132. STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
  133. STDMETHODIMP SetTimeFormat(const GUID* pFormat);
  134. STDMETHODIMP GetDuration(LONGLONG* pDuration);
  135. STDMETHODIMP GetStopPosition(LONGLONG* pStop);
  136. STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
  137. STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat);
  138. STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
  139. STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
  140. STDMETHODIMP GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest);
  141. STDMETHODIMP SetRate(double dRate);
  142. STDMETHODIMP GetRate(double* pdRate);
  143. STDMETHODIMP GetPreroll(LONGLONG* pllPreroll);
  144. // IVideoWindow
  145.     STDMETHODIMP put_Caption(BSTR strCaption);    
  146.     STDMETHODIMP get_Caption(BSTR* strCaption);
  147. STDMETHODIMP put_WindowStyle(long WindowStyle);
  148. STDMETHODIMP get_WindowStyle(long* WindowStyle);
  149. STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
  150. STDMETHODIMP get_WindowStyleEx(long* WindowStyleEx);
  151. STDMETHODIMP put_AutoShow(long AutoShow);
  152. STDMETHODIMP get_AutoShow(long* AutoShow);
  153. STDMETHODIMP put_WindowState(long WindowState);
  154. STDMETHODIMP get_WindowState(long* WindowState);
  155. STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
  156. STDMETHODIMP get_BackgroundPalette(long* pBackgroundPalette);
  157. STDMETHODIMP put_Visible(long Visible);
  158. STDMETHODIMP get_Visible(long* pVisible);
  159. STDMETHODIMP put_Left(long Left);
  160. STDMETHODIMP get_Left(long* pLeft);
  161. STDMETHODIMP put_Width(long Width);
  162. STDMETHODIMP get_Width(long* pWidth);
  163. STDMETHODIMP put_Top(long Top);
  164. STDMETHODIMP get_Top(long* pTop);
  165. STDMETHODIMP put_Height(long Height);
  166. STDMETHODIMP get_Height(long* pHeight);
  167. STDMETHODIMP put_Owner(OAHWND Owner);
  168. STDMETHODIMP get_Owner(OAHWND* Owner);
  169. STDMETHODIMP put_MessageDrain(OAHWND Drain);
  170. STDMETHODIMP get_MessageDrain(OAHWND* Drain);
  171. STDMETHODIMP get_BorderColor(long* Color);
  172. STDMETHODIMP put_BorderColor(long Color);
  173. STDMETHODIMP get_FullScreenMode(long* FullScreenMode);
  174. STDMETHODIMP put_FullScreenMode(long FullScreenMode);
  175.     STDMETHODIMP SetWindowForeground(long Focus);
  176.     STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
  177.     STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
  178. STDMETHODIMP GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
  179. STDMETHODIMP GetMinIdealImageSize(long* pWidth, long* pHeight);
  180. STDMETHODIMP GetMaxIdealImageSize(long* pWidth, long* pHeight);
  181. STDMETHODIMP GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
  182. STDMETHODIMP HideCursor(long HideCursor);
  183. STDMETHODIMP IsCursorHidden(long* CursorHidden);
  184. // IBasicVideo
  185.     STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame);
  186.     STDMETHODIMP get_BitRate(long* pBitRate);
  187.     STDMETHODIMP get_BitErrorRate(long* pBitErrorRate);
  188.     STDMETHODIMP get_VideoWidth(long* pVideoWidth);
  189.     STDMETHODIMP get_VideoHeight(long* pVideoHeight);
  190.     STDMETHODIMP put_SourceLeft(long SourceLeft);
  191.     STDMETHODIMP get_SourceLeft(long* pSourceLeft);
  192.     STDMETHODIMP put_SourceWidth(long SourceWidth);
  193.     STDMETHODIMP get_SourceWidth(long* pSourceWidth);
  194.     STDMETHODIMP put_SourceTop(long SourceTop);
  195.     STDMETHODIMP get_SourceTop(long* pSourceTop);
  196.     STDMETHODIMP put_SourceHeight(long SourceHeight);
  197.     STDMETHODIMP get_SourceHeight(long* pSourceHeight);
  198.     STDMETHODIMP put_DestinationLeft(long DestinationLeft);
  199.     STDMETHODIMP get_DestinationLeft(long* pDestinationLeft);
  200.     STDMETHODIMP put_DestinationWidth(long DestinationWidth);
  201.     STDMETHODIMP get_DestinationWidth(long* pDestinationWidth);
  202.     STDMETHODIMP put_DestinationTop(long DestinationTop);
  203.     STDMETHODIMP get_DestinationTop(long* pDestinationTop);
  204.     STDMETHODIMP put_DestinationHeight(long DestinationHeight);
  205.     STDMETHODIMP get_DestinationHeight(long* pDestinationHeight);
  206.     STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
  207.     STDMETHODIMP GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
  208.     STDMETHODIMP SetDefaultSourcePosition();
  209.     STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
  210.     STDMETHODIMP GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight);
  211.     STDMETHODIMP SetDefaultDestinationPosition();
  212.     STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
  213.     STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette);
  214.     STDMETHODIMP GetCurrentImage(long* pBufferSize, long* pDIBImage);
  215.     STDMETHODIMP IsUsingDefaultSource();
  216.     STDMETHODIMP IsUsingDefaultDestination();
  217. // IBasicAudio
  218.     STDMETHODIMP put_Volume(long lVolume);
  219.     STDMETHODIMP get_Volume(long* plVolume);
  220.     STDMETHODIMP put_Balance(long lBalance);
  221.     STDMETHODIMP get_Balance(long* plBalance);
  222. // IAMOpenProgress
  223. STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
  224. STDMETHODIMP AbortOperation();
  225. // IGraphEngine
  226. STDMETHODIMP_(engine_t) GetEngine();
  227. };