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.

186 lines
6.5 KiB

  1. // Copyright (c) 1997 - 1998 Microsoft Corporation. All Rights Reserved.
  2. // ddstrm.h : Declaration of the CDDStream
  3. #ifndef __DDSTRM_H_
  4. #define __DDSTRM_H_
  5. #include "resource.h" // main symbols
  6. class CDDSample;
  7. class CDDInternalSample;
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CDDStream
  10. class ATL_NO_VTABLE CDDStream :
  11. public CComCoClass<CDDStream, &CLSID_AMDirectDrawStream>,
  12. public CStream,
  13. public IDirectDrawMediaStream,
  14. public IDirectDrawMediaSampleAllocator // This interface indicates that our mem
  15. // allocator supports direct draw surfaces
  16. // from the media samples.
  17. {
  18. friend CDDSample;
  19. public:
  20. //
  21. // METHODS
  22. //
  23. CDDStream();
  24. //
  25. // IMediaStream
  26. //
  27. // HACK HACK - the first 2 are duplicates but it won't link
  28. // without
  29. STDMETHODIMP GetMultiMediaStream(
  30. /* [out] */ IMultiMediaStream **ppMultiMediaStream)
  31. {
  32. return CStream::GetMultiMediaStream(ppMultiMediaStream);
  33. }
  34. STDMETHODIMP GetInformation(
  35. /* [optional][out] */ MSPID *pPurposeId,
  36. /* [optional][out] */ STREAM_TYPE *pType)
  37. {
  38. return CStream::GetInformation(pPurposeId, pType);
  39. }
  40. STDMETHODIMP SetSameFormat(IMediaStream *pStream, DWORD dwFlags);
  41. STDMETHODIMP AllocateSample(
  42. /* [in] */ DWORD dwFlags,
  43. /* [out] */ IStreamSample **ppSample);
  44. STDMETHODIMP CreateSharedSample(
  45. /* [in] */ IStreamSample *pExistingSample,
  46. /* [in] */ DWORD dwFlags,
  47. /* [out] */ IStreamSample **ppNewSample);
  48. STDMETHODIMP SendEndOfStream(DWORD dwFlags)
  49. {
  50. return CStream::SendEndOfStream(dwFlags);
  51. }
  52. //
  53. // IAMMediaStream
  54. //
  55. STDMETHODIMP Initialize(IUnknown *pSourceObject, DWORD dwFlags, REFMSPID PurposeId, const STREAM_TYPE StreamType);
  56. //
  57. // IDirectDrawMediaStream
  58. //
  59. STDMETHODIMP GetFormat(
  60. /* [optional][out] */ DDSURFACEDESC *pDDSDCurrent,
  61. /* [optional][out] */ IDirectDrawPalette **ppDirectDrawPalette,
  62. /* [optional][out] */ DDSURFACEDESC *pDDSDDesired,
  63. /* [optional][out] */ DWORD *pdwFlags);
  64. STDMETHODIMP SetFormat(
  65. /* [in] */ const DDSURFACEDESC *lpDDSurfaceDesc,
  66. /* [optional][in] */ IDirectDrawPalette *pDirectDrawPalette);
  67. STDMETHODIMP GetDirectDraw( // NOTE == Function also used by IDirectDrawMediaSampleAllocator
  68. /* [out] */ IDirectDraw **ppDirectDraw);
  69. STDMETHODIMP SetDirectDraw(
  70. /* [in] */ IDirectDraw *pDirectDraw);
  71. STDMETHODIMP CreateSample(
  72. /* [in] */ IDirectDrawSurface *pSurface,
  73. /* [optional][in] */ const RECT *pRect,
  74. /* [in] */ DWORD dwFlags,
  75. /* [out] */ IDirectDrawStreamSample **ppSample);
  76. STDMETHODIMP GetTimePerFrame(
  77. /* [out] */ STREAM_TIME *pFrameTime);
  78. //
  79. // IPin
  80. //
  81. STDMETHODIMP ReceiveConnection(IPin * pConnector, const AM_MEDIA_TYPE *pmt);
  82. STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE *pmt);
  83. //
  84. // IMemInputPin
  85. //
  86. STDMETHODIMP Receive(IMediaSample *pSample);
  87. STDMETHODIMP NotifyAllocator(IMemAllocator * pAllocator, BOOL bReadOnly);
  88. //
  89. // IMemAllocator
  90. //
  91. STDMETHODIMP SetProperties(ALLOCATOR_PROPERTIES* pRequest, ALLOCATOR_PROPERTIES* pActual);
  92. STDMETHODIMP GetProperties(ALLOCATOR_PROPERTIES* pProps);
  93. STDMETHODIMP GetBuffer(IMediaSample **ppBuffer, REFERENCE_TIME * pStartTime,
  94. REFERENCE_TIME * pEndTime, DWORD dwFlags);
  95. STDMETHODIMP Decommit();
  96. //
  97. // Special CStream methods
  98. //
  99. HRESULT GetMediaType(ULONG Index, AM_MEDIA_TYPE **ppMediaType);
  100. HRESULT CreateTempSample(CSample **ppSample);
  101. protected:
  102. STDMETHODIMP GetFormatInternal(
  103. DDSURFACEDESC *pDDSDCurrent,
  104. IDirectDrawPalette **ppDirectDrawPalette,
  105. DDSURFACEDESC *pDDSDDesired,
  106. DWORD *pdwFlags);
  107. HRESULT InitDirectDraw(void);
  108. void InitSurfaceDesc(LPDDSURFACEDESC);
  109. HRESULT InternalSetFormat(const DDSURFACEDESC *lpDDSurfaceDesc, IDirectDrawPalette *pPalette, bool bFromPin, bool bQuery = false);
  110. HRESULT InternalAllocateSample(DWORD dwFlags,
  111. bool bIsInternalSample,
  112. IDirectDrawStreamSample **ppDDSample,
  113. bool bTemp = false);
  114. HRESULT InternalCreateSample(IDirectDrawSurface *pSurface, const RECT *pRect,
  115. DWORD dwFlags, bool bIsInternalSample,
  116. IDirectDrawStreamSample **ppSample,
  117. bool bTemp = false);
  118. HRESULT GetMyReadOnlySample(CDDSample *pBuddy, CDDSample **ppSample);
  119. HRESULT RenegotiateMediaType(const DDSURFACEDESC *lpDDSurfaceDesc, IDirectDrawPalette *pPalette, const AM_MEDIA_TYPE *pmt);
  120. HRESULT inline CDDStream::AllocDDSampleFromPool(
  121. const REFERENCE_TIME *rtStart,
  122. CDDSample **ppDDSample)
  123. {
  124. CSample *pSample;
  125. HRESULT hr = AllocSampleFromPool(rtStart, &pSample);
  126. *ppDDSample = (CDDSample *)pSample;
  127. return hr;
  128. }
  129. bool CreateInternalSample() const
  130. {
  131. return m_bSamplesAreReadOnly &&
  132. m_StreamType==STREAMTYPE_READ;
  133. }
  134. public:
  135. DECLARE_REGISTRY_RESOURCEID(IDR_STREAM)
  136. BEGIN_COM_MAP(CDDStream)
  137. COM_INTERFACE_ENTRY(IDirectDrawMediaStream)
  138. COM_INTERFACE_ENTRY(IDirectDrawMediaSampleAllocator)
  139. COM_INTERFACE_ENTRY_CHAIN(CStream)
  140. END_COM_MAP()
  141. protected:
  142. //
  143. // Member variables
  144. //
  145. CComPtr<IDirectDraw> m_pDirectDraw;
  146. CComPtr<IDirectDrawPalette> m_pDirectDrawPalette;
  147. DWORD m_dwForcedFormatFlags;
  148. long m_Height;
  149. long m_Width;
  150. DDPIXELFORMAT m_PixelFormat;
  151. const DDPIXELFORMAT *m_pDefPixelFormat;
  152. long m_lLastPitch;
  153. CDDInternalSample *m_pMyReadOnlySample;
  154. };
  155. #endif // __DDSTRM_H_