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.

197 lines
6.2 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. */
  4. // Stream.h : Declaration of the CStream
  5. #ifndef __STREAM_H_
  6. #define __STREAM_H_
  7. class CSample;
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CStream
  10. class ATL_NO_VTABLE CStream :
  11. public CComObjectRootEx<CComMultiThreadModel>,
  12. public IPin,
  13. public IMemInputPin,
  14. public IAMMediaStream,
  15. public IMemAllocator
  16. {
  17. public:
  18. typedef CComObjectRootEx<CComMultiThreadModel> _BaseClass;
  19. DECLARE_GET_CONTROLLING_UNKNOWN()
  20. //
  21. // METHODS
  22. //
  23. CStream();
  24. virtual ~CStream();
  25. //
  26. // IMediaStream
  27. //
  28. STDMETHODIMP GetMultiMediaStream(
  29. /* [out] */ IMultiMediaStream **ppMultiMediaStream);
  30. STDMETHODIMP GetInformation(
  31. /* [optional][out] */ MSPID *pPurposeId,
  32. /* [optional][out] */ STREAM_TYPE *pType);
  33. STDMETHODIMP SendEndOfStream(DWORD dwFlags);
  34. //
  35. // IAMMediaStream
  36. //
  37. STDMETHODIMP Initialize(
  38. IUnknown *pSourceObject,
  39. DWORD dwFlags,
  40. /* [in] */ REFMSPID PurposeId,
  41. /* [in] */ const STREAM_TYPE StreamType);
  42. STDMETHODIMP SetState(
  43. /* [in] */ FILTER_STATE State) = 0; // derived class supplies pump class
  44. STDMETHODIMP JoinAMMultiMediaStream(
  45. /* [in] */ IAMMultiMediaStream *pAMMultiMediaStream);
  46. STDMETHODIMP JoinFilter(
  47. /* [in] */ IMediaStreamFilter *pMediaStreamFilter);
  48. STDMETHODIMP JoinFilterGraph(
  49. /* [in] */ IFilterGraph *pFilterGraph);
  50. //
  51. // IPin
  52. //
  53. STDMETHODIMP Disconnect();
  54. STDMETHODIMP ConnectedTo(IPin **pPin);
  55. STDMETHODIMP ConnectionMediaType(AM_MEDIA_TYPE *pmt);
  56. STDMETHODIMP QueryPinInfo(PIN_INFO * pInfo);
  57. STDMETHODIMP QueryDirection(PIN_DIRECTION * pPinDir);
  58. STDMETHODIMP QueryId(LPWSTR * Id);
  59. STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE *pmt);
  60. STDMETHODIMP QueryInternalConnections(IPin* *apPin, ULONG *nPin);
  61. STDMETHODIMP EndOfStream(void);
  62. STDMETHODIMP BeginFlush(void);
  63. STDMETHODIMP EndFlush(void);
  64. STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
  65. //
  66. // IMemInputPin
  67. //
  68. STDMETHODIMP GetAllocator(IMemAllocator ** ppAllocator);
  69. STDMETHODIMP NotifyAllocator(IMemAllocator * pAllocator, BOOL bReadOnly);
  70. STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES*pProps);
  71. STDMETHODIMP ReceiveMultiple(IMediaSample **pSamples, long nSamples, long *nSamplesProcessed);
  72. STDMETHODIMP ReceiveCanBlock();
  73. STDMETHODIMP Connect(IPin * pReceivePin, const AM_MEDIA_TYPE *pmt);
  74. STDMETHODIMP EnumMediaTypes(IEnumMediaTypes **ppEnum);
  75. //
  76. // IMemAllocator
  77. //
  78. STDMETHODIMP Commit() = 0; // derived class supplies pump class
  79. STDMETHODIMP Decommit() = 0; // derived class supplies pump class
  80. STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);
  81. // Note that NotifyAllocator calls this so override it
  82. // if you care. Audio doesn't care becuase it's not
  83. // really using this allocator at all.
  84. STDMETHODIMP SetProperties(
  85. ALLOCATOR_PROPERTIES* pRequest,
  86. ALLOCATOR_PROPERTIES* pActual)
  87. {
  88. return S_OK;
  89. }
  90. STDMETHODIMP GetProperties(ALLOCATOR_PROPERTIES* pProps)
  91. {
  92. return E_UNEXPECTED;
  93. }
  94. //
  95. // Special CStream methods
  96. //
  97. virtual HRESULT GetMediaType(ULONG Index, AM_MEDIA_TYPE **ppMediaType) = 0;
  98. public:
  99. //
  100. // Private methods
  101. //
  102. void GetName(LPWSTR);
  103. HRESULT AllocSampleFromPool(const REFERENCE_TIME * pStartTime, CSample **ppSample, DWORD dwFlags);
  104. void AddSampleToFreePool(CSample *pSample);
  105. bool StealSampleFromFreePool(CSample *pSample, BOOL bAbort);
  106. HRESULT FinalConstruct(void);
  107. HRESULT ConnectThisMediaType(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);
  108. HRESULT CheckReceiveConnectionPin(IPin * pConnector);
  109. #ifdef DEBUG
  110. #define CHECKSAMPLELIST TM_ASSERT(CheckSampleList());
  111. bool CheckSampleList();
  112. #else
  113. #define CHECKSAMPLELIST
  114. #endif
  115. BEGIN_COM_MAP(CStream)
  116. COM_INTERFACE_ENTRY(IPin)
  117. COM_INTERFACE_ENTRY(IMemInputPin)
  118. COM_INTERFACE_ENTRY(IMemAllocator)
  119. COM_INTERFACE_ENTRY2(IMediaStream, IAMMediaStream)
  120. COM_INTERFACE_ENTRY(IAMMediaStream)
  121. END_COM_MAP()
  122. //
  123. // MEMBER VARIABLES
  124. //
  125. public:
  126. //
  127. // These SHOULD NOT BE CCOMPTRS since we hold weak references to both of them
  128. // (we never addref them).
  129. //
  130. IMediaStreamFilter *m_pFilter;
  131. IBaseFilter *m_pBaseFilter;
  132. IFilterGraph *m_pFilterGraph;
  133. IAMMultiMediaStream *m_pMMStream;
  134. // Allocator held during connection
  135. CComPtr<IMemAllocator> m_pAllocator;
  136. // Stream configuration
  137. STREAM_TYPE m_StreamType;
  138. PIN_DIRECTION m_Direction;
  139. MSPID m_PurposeId;
  140. REFERENCE_TIME m_rtSegmentStart;
  141. // Allocator state information
  142. bool m_bUsingMyAllocator;
  143. bool m_bSamplesAreReadOnly;
  144. bool m_bCommitted;
  145. long m_lRequestedBufferCount;
  146. // Sample list and semaphores
  147. CSample *m_pFirstFree;
  148. CSample *m_pLastFree;
  149. long m_cAllocated;
  150. long m_lWaiting;
  151. HANDLE m_hWaitFreeSem;
  152. REFERENCE_TIME m_rtWaiting;
  153. // Filter state
  154. FILTER_STATE m_FilterState;
  155. // Pin state
  156. CComPtr<IPin> m_pConnectedPin;
  157. CComPtr<IQualityControl> m_pQC;
  158. CComQIPtr<IMemInputPin, &IID_IMemInputPin> m_pConnectedMemInputPin;
  159. AM_MEDIA_TYPE m_ConnectedMediaType;
  160. AM_MEDIA_TYPE m_ActualMediaType;
  161. bool m_bFlushing;
  162. bool m_bEndOfStream;
  163. bool m_bStopIfNoSamples;
  164. };
  165. #endif //__STREAM_H_