Leaked source code of windows server 2003
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.

232 lines
7.0 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. */
  4. #ifndef __MEDIA_STREAM_TERMINAL__
  5. #define __MEDIA_STREAM_TERMINAL__
  6. //
  7. // The CLSID that's used to create us.
  8. //
  9. EXTERN_C const CLSID CLSID_MediaStreamingTerminal_PRIVATE;
  10. #ifdef INSTANTIATE_GUIDS_NOW
  11. // {AED6483F-3304-11d2-86F1-006008B0E5D2}
  12. const GUID CLSID_MediaStreamingTerminal_PRIVATE =
  13. { 0xaed6483f, 0x3304, 0x11d2, { 0x86, 0xf1, 0x0, 0x60, 0x8, 0xb0, 0xe5, 0xd2 } };
  14. #endif // INSTANTIATE_GUIDS_NOW
  15. ///////////////////////////////////////////////////////////////////////////////
  16. ///////////////////////////////////////////////////////////////////////////////
  17. //
  18. // The terminal object itself
  19. //
  20. ///////////////////////////////////////////////////////////////////////////////
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // forward declaration for the class being aggregated by CMediaTerminal
  23. class CMediaTerminalFilter;
  24. class CMediaTerminal :
  25. public CComCoClass<CMediaTerminal, &CLSID_MediaStreamingTerminal_PRIVATE>,
  26. public CBaseTerminal,
  27. public ITPluggableTerminalInitialization,
  28. public ITAMMediaFormat,
  29. public IAMStreamConfig,
  30. public IAMBufferNegotiation,
  31. public CMSPObjectSafetyImpl
  32. {
  33. public:
  34. // REMOVE THESE when we derive from CSingleFilterTerminal.
  35. STDMETHOD(RunRenderFilter) (void) { return E_NOTIMPL; }
  36. STDMETHOD(StopRenderFilter) (void) { return E_NOTIMPL; }
  37. virtual HRESULT GetNumExposedPins(
  38. IN IGraphBuilder * pGraph,
  39. OUT DWORD * pdwNumPins
  40. );
  41. virtual HRESULT GetExposedPins(
  42. OUT IPin ** ppPins
  43. );
  44. public:
  45. BEGIN_COM_MAP(CMediaTerminal)
  46. COM_INTERFACE_ENTRY(ITPluggableTerminalInitialization)
  47. COM_INTERFACE_ENTRY(ITAMMediaFormat)
  48. COM_INTERFACE_ENTRY(IAMStreamConfig)
  49. COM_INTERFACE_ENTRY(IAMBufferNegotiation)
  50. COM_INTERFACE_ENTRY(IObjectSafety)
  51. COM_INTERFACE_ENTRY_CHAIN(CBaseTerminal)
  52. COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pIUnkTerminalFilter.p)
  53. END_COM_MAP()
  54. DECLARE_PROTECT_FINAL_CONSTRUCT()
  55. DECLARE_GET_CONTROLLING_UNKNOWN()
  56. DECLARE_REGISTRY_RESOURCEID(IDR_MediaStreamingTerminal)
  57. // set the member variables
  58. inline CMediaTerminal();
  59. #ifdef DEBUG
  60. virtual ~CMediaTerminal();
  61. #endif // DEBUG
  62. HRESULT FinalConstruct();
  63. void FinalRelease();
  64. // ITPluggableTerminalInitialization
  65. STDMETHOD(InitializeDynamic) (
  66. IN IID iidTerminalClass,
  67. IN DWORD dwMediaType,
  68. IN TERMINAL_DIRECTION Direction,
  69. IN MSP_HANDLE htAddress
  70. );
  71. // IAMStreamConfig - this is for use by the filter graph end of the terminal
  72. // to configure the format and capture capabilities if relevant
  73. // the application is supposed to call DeleteMediaType(*ppmt) (on success)
  74. // implemented using the aggregated filter's public GetFormat method
  75. STDMETHOD(GetFormat)(
  76. OUT AM_MEDIA_TYPE **ppmt
  77. );
  78. // implemented using the aggregated filter's public SetFormat method
  79. STDMETHOD(SetFormat)(
  80. IN AM_MEDIA_TYPE *pmt
  81. );
  82. // IAMStreamConfig - Used by the MSP, queried from the output pin
  83. // if our pin is an input pin (we are a render MST) then these return VFW_E_INVALID_DIRECTION
  84. STDMETHOD(GetNumberOfCapabilities)(
  85. /*[out]*/ int *piCount,
  86. /*[out]*/ int *piSize
  87. // ); // pSCC of GetStreamC
  88. ) { return E_NOTIMPL; }
  89. STDMETHOD(GetStreamCaps)(
  90. /*[in]*/ int iIndex, // 0 to #caps-1
  91. /*[out]*/ AM_MEDIA_TYPE **ppmt,
  92. /*[out]*/ BYTE *pSCC
  93. ) { return E_NOTIMPL; }
  94. // IAMBufferNegotiation - these return E_NOTIMPL
  95. STDMETHOD(GetAllocatorProperties)(
  96. OUT ALLOCATOR_PROPERTIES *pProperties
  97. );
  98. STDMETHOD(SuggestAllocatorProperties)(
  99. IN const ALLOCATOR_PROPERTIES *pProperties
  100. );
  101. // ITAMMediaFormat - the read/write user of the terminal uses this to
  102. // get and set the media format of the samples
  103. // since there is only one filter in this base class implementation (i.e. the two
  104. // ends of the terminal have the same media format), both of
  105. // the get and set methods are redirected to Get/Set Format
  106. STDMETHOD(get_MediaFormat)(
  107. OUT AM_MEDIA_TYPE **ppFormat
  108. );
  109. STDMETHOD(put_MediaFormat)(
  110. IN const AM_MEDIA_TYPE *pFormat
  111. );
  112. protected:
  113. typedef CComAggObject<CMediaTerminalFilter> FILTER_COM_OBJECT;
  114. // we create an aggregated instance of this
  115. FILTER_COM_OBJECT *m_pAggInstance;
  116. // ptr to the created media terminal filter
  117. CComContainedObject<CMediaTerminalFilter> *m_pAggTerminalFilter;
  118. // NOTE: m_pIUnkTerminalFilter, m_pOwnPin are references
  119. // to the media terminal filter that are obtained in
  120. // FinalConstruct. The corresponding refcnts are released
  121. // immediately after obtaining the interfaces
  122. // IUnknown i/f of the aggregated media terminal filter
  123. CComPtr<IUnknown> m_pIUnkTerminalFilter;
  124. // holds the pin exposed by the aggregated media terminal filter
  125. // this is returned in GetTerminalPin()
  126. // its a weak reference and shouldn't be a CComPtr
  127. IPin *m_pOwnPin;
  128. // holds the IAMMediaStream i/f exposed by the aggregated media
  129. // terminal filter
  130. // its a weak reference and shouldn't be a CComPtr
  131. IAMMediaStream *m_pIAMMediaStream;
  132. // holds the internally created Media stream filter interface
  133. // needed in JoinFilter to compare the internally created filter with
  134. // the passed in filter to join
  135. CComPtr<IMediaStreamFilter> m_pICreatedMediaStreamFilter;
  136. // the base filter interface for the internally created media
  137. // stream filter
  138. CComPtr<IBaseFilter> m_pBaseFilter;
  139. long m_lMediaType;
  140. // CBaseTerminal methods
  141. virtual HRESULT AddFiltersToGraph();
  142. virtual HRESULT RemoveFiltersFromGraph();
  143. virtual DWORD GetSupportedMediaTypes(void)
  144. {
  145. return (DWORD) (TAPIMEDIATYPE_AUDIO | TAPIMEDIATYPE_VIDEO) ;
  146. }
  147. private:
  148. // used to implement other methods
  149. void SetMemberInfo(
  150. IN DWORD dwFriendlyName,
  151. IN long lMediaType
  152. );
  153. HRESULT SetNameInfo(
  154. IN long lMediaType,
  155. IN TERMINAL_DIRECTION TerminalDirection,
  156. OUT MSPID &PurposeId,
  157. OUT STREAM_TYPE &StreamType,
  158. OUT const GUID *&pAmovieMajorType
  159. );
  160. // creates the media stream filter and adds own IAMMediaStream i/f to it
  161. HRESULT CreateAndJoinMediaStreamFilter();
  162. };
  163. // set the member variables
  164. inline
  165. CMediaTerminal::CMediaTerminal(
  166. )
  167. : m_pAggInstance(NULL),
  168. m_pAggTerminalFilter(NULL),
  169. m_pIUnkTerminalFilter(NULL),
  170. m_pOwnPin(NULL),
  171. m_pIAMMediaStream(NULL),
  172. m_lMediaType(0)
  173. {
  174. }
  175. #endif // __MEDIA_STREAM_TERMINAL__