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.

186 lines
5.5 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. */
  4. #ifndef __SAMPLE_H_
  5. #define __SAMPLE_H_
  6. #include "resource.h" // main symbols
  7. #include "stream.h"
  8. //
  9. // Samples don't use their own critical sections -- They always take the critical section of their
  10. // stream. This avoids all sorts of deadlocks, and reduces the number of locks we take. These
  11. // macros are helpers.
  12. //
  13. #define LOCK_SAMPLE m_pStream->Lock();
  14. #define UNLOCK_SAMPLE m_pStream->Unlock();
  15. #define AUTO_SAMPLE_LOCK CAutoObjectLock lck(m_pStream);
  16. class CSample;
  17. class CMediaSampleTM : public IMediaSample
  18. {
  19. public:
  20. CMediaSampleTM(CSample *pSample);
  21. virtual ~CMediaSampleTM();
  22. //
  23. // IUnknown
  24. //
  25. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  26. STDMETHODIMP_(ULONG) AddRef();
  27. STDMETHODIMP_(ULONG) Release();
  28. //
  29. // IMediaSample
  30. //
  31. STDMETHODIMP GetPointer(BYTE ** ppBuffer);
  32. STDMETHODIMP_(LONG) GetSize(void);
  33. STDMETHODIMP GetTime(REFERENCE_TIME * pTimeStart, REFERENCE_TIME * pTimeEnd);
  34. STDMETHODIMP SetTime(REFERENCE_TIME * pTimeStart, REFERENCE_TIME * pTimeEnd);
  35. STDMETHODIMP IsSyncPoint(void);
  36. STDMETHODIMP SetSyncPoint(BOOL bIsSyncPoint);
  37. STDMETHODIMP IsPreroll(void);
  38. STDMETHODIMP SetPreroll(BOOL bIsPreroll);
  39. STDMETHODIMP_(LONG) GetActualDataLength(void);
  40. STDMETHODIMP SetActualDataLength(LONG lActual);
  41. STDMETHODIMP GetMediaType(AM_MEDIA_TYPE **ppMediaType);
  42. STDMETHODIMP SetMediaType(AM_MEDIA_TYPE *pMediaType);
  43. STDMETHODIMP IsDiscontinuity(void);
  44. STDMETHODIMP SetDiscontinuity(BOOL bDiscontinuity);
  45. STDMETHODIMP GetMediaTime(LONGLONG * pTimeStart, LONGLONG * pTimeEnd);
  46. STDMETHODIMP SetMediaTime(LONGLONG * pTimeStart, LONGLONG * pTimeEnd);
  47. public:
  48. CSample *m_pSample;
  49. BOOL m_bIsPreroll;
  50. DWORD m_dwFlags;
  51. long m_cRef;
  52. AM_MEDIA_TYPE *m_pMediaType;
  53. REFERENCE_TIME m_rtStartTime;
  54. REFERENCE_TIME m_rtEndTime;
  55. };
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CSample
  58. class ATL_NO_VTABLE CSample :
  59. public CComObjectRootEx<CComMultiThreadModel>,
  60. public IStreamSample
  61. {
  62. public:
  63. //
  64. // METHODS
  65. //
  66. CSample();
  67. HRESULT InitSample(CStream *pStream, bool bIsInternalSample);
  68. virtual ~CSample();
  69. DECLARE_GET_CONTROLLING_UNKNOWN()
  70. //
  71. // IStreamSample
  72. //
  73. STDMETHODIMP GetMediaStream(
  74. /* [in] */ IMediaStream **ppMediaStream);
  75. STDMETHODIMP GetSampleTimes(
  76. /* [optional][out] */ STREAM_TIME *pStartTime,
  77. /* [optional][out] */ STREAM_TIME *pEndTime,
  78. /* [optional][out] */ STREAM_TIME *pCurrentTime);
  79. STDMETHODIMP SetSampleTimes(
  80. /* [optional][in] */ const STREAM_TIME *pStartTime,
  81. /* [optional][in] */ const STREAM_TIME *pEndTime);
  82. STDMETHODIMP Update(
  83. /* [in] */ DWORD dwFlags,
  84. /* [optional][in] */ HANDLE hEvent,
  85. /* [optional][in] */ PAPCFUNC pfnAPC,
  86. /* [optional][in] */ DWORD_PTR dwAPCData);
  87. STDMETHODIMP CompletionStatus(
  88. /* [in] */ DWORD dwFlags,
  89. /* [optional][in] */ DWORD dwMilliseconds);
  90. //
  91. // Forwarding functions for various Media Sample interfaces that can be
  92. //
  93. virtual HRESULT MSCallback_GetPointer(BYTE ** ppBuffer) = 0;
  94. virtual LONG MSCallback_GetSize(void) = 0;
  95. virtual LONG MSCallback_GetActualDataLength(void) = 0;
  96. virtual HRESULT MSCallback_SetActualDataLength(LONG lActual) = 0;
  97. virtual bool MSCallback_AllowSetMediaTypeOnMediaSample(void) {return false;}
  98. //
  99. // ATL class methods
  100. //
  101. void FinalRelease(void);
  102. //
  103. // Internal methods
  104. //
  105. virtual void FinalMediaSampleRelease(void);
  106. virtual HRESULT SetCompletionStatus(HRESULT hrCompletionStatus);
  107. void CopyFrom(CSample *pSrcSample);
  108. void CopyFrom(IMediaSample *pSrcMediaSample);
  109. virtual HRESULT InternalUpdate(
  110. DWORD dwFlags,
  111. HANDLE hEvent,
  112. PAPCFUNC pfnAPC,
  113. DWORD_PTR dwAPCData)
  114. {
  115. return E_NOTIMPL;
  116. }
  117. // Temp?
  118. bool IsTemp() { return m_bTemp; }
  119. BEGIN_COM_MAP(CSample)
  120. COM_INTERFACE_ENTRY(IStreamSample)
  121. END_COM_MAP()
  122. public:
  123. //
  124. // MEMBER VARIABLES
  125. //
  126. CMediaSampleTM * m_pMediaSample;
  127. bool m_bReceived;
  128. bool m_bWantAbort;
  129. bool m_bContinuous;
  130. bool m_bModified;
  131. bool m_bInternal;
  132. bool m_bTemp;
  133. CStream *m_pStream;
  134. CSample *m_pNextFree;
  135. CSample *m_pPrevFree;
  136. HANDLE m_hUserHandle;
  137. PAPCFUNC m_UserAPC;
  138. DWORD_PTR m_dwptrUserAPCData;
  139. HRESULT m_Status;
  140. HRESULT m_MediaSampleIoStatus;
  141. HANDLE m_hCompletionEvent;
  142. };
  143. #endif //__SAMPLE_H_