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

多媒体编程

开发平台:

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. #include "BaseGraph.h"
  23. #include "DX7AllocatorPresenter.h"
  24. #include "DX9AllocatorPresenter.h"
  25. #include "......includeRealMediapntypes.h"
  26. #include "......includeRealMediapnwintyp.h"
  27. #include "......includeRealMediapncom.h"
  28. #include "......includeRealMediarmapckts.h"
  29. #include "......includeRealMediarmacomm.h"
  30. #include "......includeRealMediarmamon.h"
  31. #include "......includeRealMediarmafiles.h"
  32. #include "......includeRealMediarmaengin.h"
  33. #include "......includeRealMediarmacore.h"
  34. #include "......includeRealMediarmaclsnk.h"
  35. #include "......includeRealMediarmaerror.h"
  36. #include "......includeRealMediarmaauth.h"
  37. #include "......includeRealMediarmawin.h"
  38. #include "......includeRealMediarmasite2.h"
  39. #include "......includeRealMediarmaausvc.h"
  40. #include "......includeRealMediarmavsurf.h"
  41. namespace DSObjects
  42. {
  43. class CRealMediaGraph;
  44. class CRealMediaPlayer
  45. : public CUnknown
  46. , public IRMAErrorSink
  47. , public IRMAClientAdviseSink
  48. , public IRMAAuthenticationManager
  49. , public IRMASiteSupplier
  50. , public IRMAPassiveSiteWatcher
  51. , public IRMAAudioHook
  52. {
  53. protected:
  54. friend class CRealMediaGraph;
  55. CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here
  56. HWND m_hWndParent;
  57. CSize m_VideoSize;
  58. bool m_fVideoSizeChanged;
  59. //
  60. DWORD m_wndStyle;
  61. CPlayerWindow m_wndWindowFrame, m_wndDestFrame;
  62. //
  63. FPRMCREATEENGINE m_fpCreateEngine;
  64. FPRMCLOSEENGINE   m_fpCloseEngine;
  65. FPRMSETDLLACCESSPATH m_fpSetDLLAccessPath;
  66. HMODULE m_hRealMediaCore;
  67. CComPtr<IRMAClientEngine> m_pEngine;
  68.     CComPtr<IRMAPlayer> m_pPlayer;
  69. CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
  70. CComPtr<IRMAVolume> m_pVolume;
  71.     CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
  72.     CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;
  73. CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
  74. CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
  75. CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;
  76. //
  77. OAFilterState m_State, m_UserState;
  78. REFERENCE_TIME m_nCurrent, m_nDuration;
  79. UINT16 m_unPercentComplete;
  80. //
  81. public:
  82. CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
  83. virtual ~CRealMediaPlayer();
  84.     DECLARE_IUNKNOWN;
  85.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
  86. bool Init();
  87. void Deinit();
  88. virtual CSize GetVideoSize() {return(m_VideoSize);}
  89. virtual void SetWindowRect(CRect r) {}
  90. virtual void SetDestRect(CRect r) {}
  91. virtual bool CreateSite(IRMASite** pSite) = 0;
  92. virtual void DestroySite(IRMASite* pSite) = 0;
  93. // IRMAErrorSink
  94.     STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);
  95.     // IRMAClientAdviseSink
  96.     STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
  97.     STDMETHODIMP OnPresentationOpened();
  98.     STDMETHODIMP OnPresentationClosed();
  99.     STDMETHODIMP OnStatisticsChanged();
  100.     STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
  101.     STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
  102.     STDMETHODIMP OnStop();
  103.     STDMETHODIMP OnPause(UINT32 ulTime);
  104.     STDMETHODIMP OnBegin(UINT32 ulTime);
  105.     STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
  106.     STDMETHODIMP OnContacting(const char* pHostName);
  107. // IRMAAuthenticationManager
  108.     STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);
  109. // IRMASiteSupplier
  110.     STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
  111.     STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
  112.     STDMETHODIMP BeginChangeLayout();
  113.     STDMETHODIMP DoneChangeLayout();
  114. // IRMAPassiveSiteWatcher
  115.     STDMETHODIMP PositionChanged(PNxPoint* pos);
  116. STDMETHODIMP SizeChanged(PNxSize* size);
  117. // IRMAAudioHook
  118. STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
  119. STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
  120. };
  121. class CRealMediaPlayerWindowed
  122. : public CRealMediaPlayer
  123. {
  124. public:
  125. CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
  126. virtual ~CRealMediaPlayerWindowed();
  127. void SetWindowRect(CRect r);
  128. void SetDestRect(CRect r);
  129. bool CreateSite(IRMASite** pSite);
  130. void DestroySite(IRMASite* pSite);
  131. };
  132. class CRealMediaPlayerWindowless
  133. : public CRealMediaPlayer
  134. {
  135. CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
  136. public:
  137. CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
  138. virtual ~CRealMediaPlayerWindowless();
  139.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
  140. bool CreateSite(IRMASite** pSite);
  141. void DestroySite(IRMASite* pSite);
  142. STDMETHODIMP SizeChanged(PNxSize* size);
  143. };
  144. class CRealMediaGraph : public CBaseGraph
  145. {
  146. CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
  147. public:
  148. CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
  149. virtual ~CRealMediaGraph();
  150.     DECLARE_IUNKNOWN;
  151.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
  152. protected:
  153. // IGraphBuilder
  154.     STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);
  155. // IMediaControl
  156.     STDMETHODIMP Run();
  157.     STDMETHODIMP Pause();
  158.     STDMETHODIMP Stop();
  159. STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);
  160. // IMediaSeeking
  161. STDMETHODIMP GetDuration(LONGLONG* pDuration);
  162. STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
  163. STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);
  164. // IVideoWindow
  165.     STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
  166. // IBasicVideo
  167.     STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
  168.     STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);
  169. // IBasicAudio
  170.     STDMETHODIMP put_Volume(long lVolume);
  171.     STDMETHODIMP get_Volume(long* plVolume);
  172. // IAMOpenProgress
  173. STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
  174. // IGraphEngine
  175. STDMETHODIMP_(engine_t) GetEngine();
  176. };
  177. }
  178. using namespace DSObjects;