BaseGraph.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:10k
源码类别:

多媒体编程

开发平台:

Visual C++

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