Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.5 KiB

  1. //==========================================================================;
  2. // MSVidAudioRenderer.h : Declaration of the CMSVidAudioRenderer
  3. // copyright (c) Microsoft Corp. 1998-1999.
  4. //==========================================================================;
  5. #ifndef __MSVidAUDIORENDERER_H_
  6. #define __MSVidAUDIORENDERER_H_
  7. #pragma once
  8. #include "segimpl.h"
  9. #include "devimpl.h"
  10. #include "seg.h"
  11. #include <objectwithsiteimplsec.h>
  12. #include "resource.h" // main symbols
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMSVidAudioRenderer
  15. class ATL_NO_VTABLE __declspec(uuid("37B03544-A4C8-11d2-B634-00C04F79498E")) CMSVidAudioRenderer :
  16. public CComObjectRootEx<CComSingleThreadModel>,
  17. public CComCoClass<CMSVidAudioRenderer, &CLSID_MSVidAudioRenderer>,
  18. public IObjectWithSiteImplSec<CMSVidAudioRenderer>,
  19. public ISupportErrorInfo,
  20. public IConnectionPointContainerImpl<CMSVidAudioRenderer>,
  21. public IMSVidGraphSegmentImpl<CMSVidAudioRenderer, MSVidSEG_DEST, &GUID_NULL>,
  22. public IMSVidDeviceImpl<CMSVidAudioRenderer, &LIBID_MSVidCtlLib, &GUID_NULL, IMSVidAudioRenderer>
  23. {
  24. public:
  25. CMSVidAudioRenderer() :
  26. m_fUseKSRenderer(false),
  27. m_fAnalogOnly(false),
  28. m_fDigitalOnly(false),
  29. m_iAudioRenderer(-1)
  30. {}
  31. REGISTER_AUTOMATION_OBJECT(IDS_PROJNAME,
  32. IDS_REG_AUDIORENDERER_PROGID,
  33. IDS_REG_AUDIORENDERER_DESC,
  34. LIBID_MSVidCtlLib,
  35. CLSID_MSVidAudioRenderer);
  36. DECLARE_PROTECT_FINAL_CONSTRUCT()
  37. BEGIN_COM_MAP(CMSVidAudioRenderer)
  38. COM_INTERFACE_ENTRY(IMSVidGraphSegment)
  39. COM_INTERFACE_ENTRY(IMSVidAudioRenderer)
  40. COM_INTERFACE_ENTRY(IMSVidOutputDevice)
  41. COM_INTERFACE_ENTRY(IMSVidDevice)
  42. COM_INTERFACE_ENTRY(IDispatch)
  43. COM_INTERFACE_ENTRY(IObjectWithSite)
  44. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  45. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  46. COM_INTERFACE_ENTRY(IPersist)
  47. END_COM_MAP()
  48. BEGIN_CATEGORY_MAP(CMSVidAudioRenderer)
  49. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  50. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  51. IMPLEMENTED_CATEGORY(CATID_PersistsToPropertyBag)
  52. END_CATEGORY_MAP()
  53. BEGIN_CONNECTION_POINT_MAP(CMSVidAudioRenderer)
  54. END_CONNECTION_POINT_MAP()
  55. DSFilter m_pAR;
  56. int m_iAudioRenderer;
  57. bool m_fUseKSRenderer;
  58. bool m_fAnalogOnly;
  59. bool m_fDigitalOnly;
  60. // ISupportsErrorInfo
  61. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  62. public:
  63. CComBSTR __declspec(property(get=GetName)) m_Name;
  64. CComBSTR GetName(void) {
  65. return CComBSTR(OLESTR("audio renderer"));
  66. }
  67. // IMSVidDevice
  68. STDMETHOD(get_Name)(BSTR * Name)
  69. {
  70. if (!m_fInit) {
  71. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  72. }
  73. if (Name == NULL)
  74. return E_POINTER;
  75. try {
  76. *Name = m_Name.Copy();
  77. } catch(...) {
  78. return E_POINTER;
  79. }
  80. return NOERROR;
  81. }
  82. STDMETHOD(get_Status)(LONG * Status)
  83. {
  84. if (!m_fInit) {
  85. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  86. }
  87. if (Status == NULL)
  88. return E_POINTER;
  89. return E_NOTIMPL;
  90. }
  91. STDMETHOD(get_Segment)(IMSVidGraphSegment * * pIMSVidGraphSegment)
  92. {
  93. if (!m_fInit) {
  94. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  95. }
  96. if (pIMSVidGraphSegment == NULL)
  97. return E_POINTER;
  98. return E_NOTIMPL;
  99. }
  100. // IMSVidAudioRenderer
  101. STDMETHOD(get_Volume)(LONG * plPercent)
  102. {
  103. if (!m_fInit) {
  104. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  105. }
  106. if (plPercent == NULL)
  107. return E_POINTER;
  108. try {
  109. if (!m_pGraph) {
  110. Error(IDS_INVALID_STATE, __uuidof(IMSVidAudioRenderer), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
  111. }
  112. PQBasicAudio pBA(m_pGraph);
  113. if (!pBA) {
  114. Error(IDS_E_CANTQI, __uuidof(IBasicAudio), E_NOINTERFACE);
  115. }
  116. return pBA->get_Volume(plPercent);
  117. } catch(...) {
  118. return E_POINTER;
  119. }
  120. }
  121. STDMETHOD(put_Volume)(LONG plPercent)
  122. {
  123. if (!m_fInit) {
  124. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  125. }
  126. try {
  127. if (!m_pGraph) {
  128. Error(IDS_INVALID_STATE, __uuidof(IMSVidAudioRenderer), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
  129. }
  130. PQBasicAudio pBA(m_pGraph);
  131. if (!pBA) {
  132. Error(IDS_E_CANTQI, __uuidof(IBasicAudio), E_NOINTERFACE);
  133. }
  134. return pBA->put_Volume(plPercent);
  135. } catch(...) {
  136. return E_UNEXPECTED;
  137. }
  138. }
  139. STDMETHOD(get_Balance)(LONG * plPercent)
  140. {
  141. if (!m_fInit) {
  142. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  143. }
  144. if (plPercent == NULL)
  145. return E_POINTER;
  146. try {
  147. if (!m_pGraph) {
  148. Error(IDS_INVALID_STATE, __uuidof(IMSVidAudioRenderer), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
  149. }
  150. PQBasicAudio pBA(m_pGraph);
  151. if (!pBA) {
  152. Error(IDS_E_CANTQI, __uuidof(IBasicAudio), E_NOINTERFACE);
  153. }
  154. return pBA->get_Balance(plPercent);
  155. } catch(...) {
  156. return E_POINTER;
  157. }
  158. }
  159. STDMETHOD(put_Balance)(LONG plPercent)
  160. {
  161. if (!m_fInit) {
  162. return Error(IDS_OBJ_NO_INIT, __uuidof(IMSVidAudioRenderer), CO_E_NOTINITIALIZED);
  163. }
  164. try {
  165. if (!m_pGraph) {
  166. Error(IDS_INVALID_STATE, __uuidof(IMSVidAudioRenderer), HRESULT_FROM_WIN32(ERROR_INVALID_STATE));
  167. }
  168. PQBasicAudio pBA(m_pGraph);
  169. if (!pBA) {
  170. Error(IDS_E_CANTQI, __uuidof(IBasicAudio), E_NOINTERFACE);
  171. }
  172. return pBA->put_Balance(plPercent);
  173. } catch(...) {
  174. return E_UNEXPECTED;
  175. }
  176. }
  177. // IMSVidGraphSegment
  178. STDMETHOD(Build)();
  179. STDMETHOD(PreRun)();
  180. };
  181. #endif //__MSVidAUDIORENDERER_H_