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.

156 lines
4.1 KiB

  1. // Copyright (c) 1997 Microsoft Corporation. All Rights Reserved.
  2. // bytestrm.h : Declaration of the CByteStream
  3. #ifndef __BYTESTRM_H_
  4. #define __BYTESTRM_H_
  5. class CByteSample;
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CByteStream
  8. class ATL_NO_VTABLE CByteStream :
  9. public CStream
  10. {
  11. public:
  12. //
  13. // METHODS
  14. //
  15. CByteStream();
  16. STDMETHODIMP SetState(
  17. /* [in] */ FILTER_STATE State
  18. );
  19. //
  20. // IPin
  21. //
  22. STDMETHODIMP BeginFlush();
  23. STDMETHODIMP EndOfStream(void);
  24. //
  25. // IMemInputPin
  26. //
  27. STDMETHODIMP Receive(IMediaSample *pSample);
  28. STDMETHODIMP GetAllocator(IMemAllocator ** ppAllocator);
  29. //
  30. // IMemAllocator
  31. //
  32. STDMETHODIMP GetBuffer(IMediaSample **ppBuffer, REFERENCE_TIME * pStartTime,
  33. REFERENCE_TIME * pEndTime, DWORD dwFlags);
  34. // Fill any samples waiting to be filled
  35. void FillSamples();
  36. // Check if it's time to do the real EndOfStream
  37. void CheckEndOfStream();
  38. protected:
  39. /* Queue of samples */
  40. CDynamicArray<IMediaSample *, CComPtr<IMediaSample> >
  41. m_arSamples;
  42. /* Current sample/buffer */
  43. PBYTE m_pbData;
  44. DWORD m_cbData;
  45. DWORD m_dwPosition;
  46. /* Track time stamps */
  47. CTimeStamp m_TimeStamp;
  48. /* Byte rate for time stamp computation */
  49. LONG m_lBytesPerSecond;
  50. /* End Of Stream pending - it will be delivered when we've
  51. emptied the last sample off our list
  52. */
  53. bool m_bEOSPending;
  54. };
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CByteStreamSample
  57. class ATL_NO_VTABLE CByteStreamSample :
  58. public CSample
  59. {
  60. friend class CByteStream;
  61. public:
  62. CByteStreamSample();
  63. //
  64. // IStreamSample
  65. //
  66. STDMETHODIMP GetMediaStream(
  67. /* [in] */ IMediaStream **ppMediaStream)
  68. {
  69. return CSample::GetMediaStream(ppMediaStream);
  70. }
  71. STDMETHODIMP GetSampleTimes(
  72. /* [optional][out] */ STREAM_TIME *pStartTime,
  73. /* [optional][out] */ STREAM_TIME *pEndTime,
  74. /* [optional][out] */ STREAM_TIME *pCurrentTime)
  75. {
  76. return CSample::GetSampleTimes(
  77. pStartTime,
  78. pEndTime,
  79. pCurrentTime
  80. );
  81. }
  82. STDMETHODIMP SetSampleTimes(
  83. /* [optional][in] */ const STREAM_TIME *pStartTime,
  84. /* [optional][in] */ const STREAM_TIME *pEndTime)
  85. {
  86. return CSample::SetSampleTimes(pStartTime, pEndTime);
  87. }
  88. STDMETHODIMP CompletionStatus(
  89. /* [in] */ DWORD dwFlags,
  90. /* [optional][in] */ DWORD dwMilliseconds)
  91. {
  92. return CSample::CompletionStatus(dwFlags, dwMilliseconds);
  93. }
  94. HRESULT Init(
  95. IMemoryData *pMemData
  96. );
  97. STDMETHODIMP GetInformation(
  98. /* [out] */ DWORD *pdwLength,
  99. /* [out] */ BYTE **ppbData,
  100. /* [out] */ DWORD *pcbActualData
  101. );
  102. // Override to make sure samples get updated
  103. HRESULT InternalUpdate(
  104. DWORD dwFlags,
  105. HANDLE hEvent,
  106. PAPCFUNC pfnAPC,
  107. DWORD_PTR dwAPCData
  108. );
  109. //
  110. // Methods forwarded from MediaSample object.
  111. //
  112. HRESULT MSCallback_GetPointer(BYTE ** ppBuffer) { *ppBuffer = m_pbData; return NOERROR; };
  113. LONG MSCallback_GetSize(void) { return m_cbSize; };
  114. LONG MSCallback_GetActualDataLength(void) { return m_cbData; };
  115. HRESULT MSCallback_SetActualDataLength(LONG lActual)
  116. {
  117. if ((DWORD)lActual <= m_cbSize) {
  118. m_cbData = lActual;
  119. return NOERROR;
  120. }
  121. return E_INVALIDARG;
  122. };
  123. protected:
  124. PBYTE m_pbData;
  125. DWORD m_cbSize;
  126. DWORD m_cbData;
  127. CComPtr<IMemoryData> m_pMemData;
  128. };
  129. #endif // __BYTESTRM_H_