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.

140 lines
4.2 KiB

  1. // Copyright (c) 1997 - 1998 Microsoft Corporation. All Rights Reserved.
  2. /////////////////////////////////////////////////////////////////////////////
  3. // CDDSample
  4. class ATL_NO_VTABLE CDDSample :
  5. public CSample,
  6. public IDirectDrawStreamSample
  7. {
  8. public:
  9. CDDSample();
  10. HRESULT InitSample(CStream *pStream, IDirectDrawSurface *pSurface, const RECT *pRect, bool bIsProgressiveRender, bool bIsInternalSample,
  11. bool bTemp);
  12. //
  13. // IStreamSample
  14. //
  15. STDMETHODIMP GetMediaStream(
  16. /* [in] */ IMediaStream **ppMediaStream)
  17. {
  18. return CSample::GetMediaStream(ppMediaStream);
  19. }
  20. STDMETHODIMP GetSampleTimes(
  21. /* [optional][out] */ STREAM_TIME *pStartTime,
  22. /* [optional][out] */ STREAM_TIME *pEndTime,
  23. /* [optional][out] */ STREAM_TIME *pCurrentTime)
  24. {
  25. return CSample::GetSampleTimes(
  26. pStartTime,
  27. pEndTime,
  28. pCurrentTime
  29. );
  30. }
  31. STDMETHODIMP SetSampleTimes(
  32. /* [optional][in] */ const STREAM_TIME *pStartTime,
  33. /* [optional][in] */ const STREAM_TIME *pEndTime)
  34. {
  35. return CSample::SetSampleTimes(pStartTime, pEndTime);
  36. }
  37. STDMETHODIMP Update(
  38. /* [in] */ DWORD dwFlags,
  39. /* [optional][in] */ HANDLE hEvent,
  40. /* [optional][in] */ PAPCFUNC pfnAPC,
  41. /* [optional][in] */ DWORD_PTR dwAPCData)
  42. {
  43. return CSample::Update(dwFlags, hEvent, pfnAPC, dwAPCData);
  44. }
  45. STDMETHODIMP CompletionStatus(
  46. /* [in] */ DWORD dwFlags,
  47. /* [optional][in] */ DWORD dwMilliseconds)
  48. {
  49. return CSample::CompletionStatus(dwFlags, dwMilliseconds);
  50. }
  51. //
  52. // IDirectDrawStreamSample
  53. //
  54. STDMETHODIMP GetSurface(IDirectDrawSurface **ppDirectDrawSurface, RECT * pRect);
  55. STDMETHODIMP SetRect(const RECT * pRect);
  56. //
  57. // Overridden virtual function for CSample
  58. //
  59. void FinalMediaSampleRelease(void);
  60. //
  61. // Methods forwarded from MediaSample object.
  62. //
  63. HRESULT MSCallback_GetPointer(BYTE ** ppBuffer);
  64. LONG MSCallback_GetSize(void);
  65. LONG MSCallback_GetActualDataLength(void);
  66. HRESULT MSCallback_SetActualDataLength(LONG lActual);
  67. //
  68. // Internal methods
  69. //
  70. long LockAndPrepareMediaSample(long lLastPinPitch);
  71. void ReleaseMediaSampleLock(void);
  72. HRESULT CopyFrom(CDDSample *pSrcSample);
  73. HRESULT CopyFrom(IMediaSample *pSrcMediaSample, const AM_MEDIA_TYPE *pmt);
  74. HRESULT LockMediaSamplePointer();
  75. BEGIN_COM_MAP(CDDSample)
  76. COM_INTERFACE_ENTRY(IDirectDrawStreamSample)
  77. COM_INTERFACE_ENTRY_CHAIN(CSample)
  78. END_COM_MAP()
  79. public:
  80. CComPtr<IDirectDrawSurface> m_pSurface;
  81. RECT m_Rect;
  82. long m_lLastSurfacePitch;
  83. bool m_bProgressiveRender;
  84. bool m_bFormatChanged;
  85. LONG m_lImageSize;
  86. void * m_pvLockedSurfacePtr;
  87. };
  88. class CDDInternalSample : public CDDSample
  89. {
  90. public:
  91. CDDInternalSample();
  92. ~CDDInternalSample();
  93. HRESULT InternalInit(void);
  94. HRESULT SetCompletionStatus(HRESULT hrStatus);
  95. HRESULT Die(void);
  96. HRESULT JoinToBuddy(CDDSample *pBuddy);
  97. BOOL HasBuddy() const
  98. {
  99. return m_pBuddySample != NULL;
  100. }
  101. private:
  102. CDDSample *m_pBuddySample;
  103. long m_lWaiting;
  104. HANDLE m_hWaitFreeSem;
  105. bool m_bDead;
  106. };
  107. class CDDMediaSample : public CMediaSample, public IDirectDrawMediaSample
  108. {
  109. public:
  110. CDDMediaSample(CSample *pSample) :
  111. CMediaSample(pSample) {};
  112. STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);
  113. STDMETHODIMP_(ULONG) AddRef() {return CMediaSample::AddRef();}
  114. STDMETHODIMP_(ULONG) Release() {return CMediaSample::Release();}
  115. STDMETHODIMP GetSurfaceAndReleaseLock(IDirectDrawSurface **ppDirectDrawSurface, RECT * pRect);
  116. STDMETHODIMP LockMediaSamplePointer();
  117. };