1
0

amextra.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //------------------------------------------------------------------------------
  2. // File: AMExtra.cpp
  3. //
  4. // Desc: DirectShow base classes - implements CRenderedInputPin class.
  5. //
  6. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #include <streams.h> // DirectShow base class definitions
  9. #include <mmsystem.h> // Needed for definition of timeGetTime
  10. #include <limits.h> // Standard data type limit definitions
  11. #include <measure.h> // Used for time critical log functions
  12. #include "amextra.h"
  13. #pragma warning(disable:4355)
  14. // Implements CRenderedInputPin class
  15. CRenderedInputPin::CRenderedInputPin(__in_opt LPCTSTR pObjectName,
  16. __in CBaseFilter *pFilter,
  17. __in CCritSec *pLock,
  18. __inout HRESULT *phr,
  19. __in_opt LPCWSTR pName) :
  20. CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
  21. m_bAtEndOfStream(FALSE),
  22. m_bCompleteNotified(FALSE)
  23. {
  24. }
  25. #ifdef UNICODE
  26. CRenderedInputPin::CRenderedInputPin(__in_opt LPCSTR pObjectName,
  27. __in CBaseFilter *pFilter,
  28. __in CCritSec *pLock,
  29. __inout HRESULT *phr,
  30. __in_opt LPCWSTR pName) :
  31. CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
  32. m_bAtEndOfStream(FALSE),
  33. m_bCompleteNotified(FALSE)
  34. {
  35. }
  36. #endif
  37. // Flush end of stream condition - caller should do any
  38. // necessary stream level locking before calling this
  39. STDMETHODIMP CRenderedInputPin::EndOfStream()
  40. {
  41. HRESULT hr = CheckStreaming();
  42. // Do EC_COMPLETE handling for rendered pins
  43. if (S_OK == hr && !m_bAtEndOfStream) {
  44. m_bAtEndOfStream = TRUE;
  45. FILTER_STATE fs;
  46. EXECUTE_ASSERT(SUCCEEDED(m_pFilter->GetState(0, &fs)));
  47. if (fs == State_Running) {
  48. DoCompleteHandling();
  49. }
  50. }
  51. return hr;
  52. }
  53. // Called to complete the flush
  54. STDMETHODIMP CRenderedInputPin::EndFlush()
  55. {
  56. CAutoLock lck(m_pLock);
  57. // Clean up renderer state
  58. m_bAtEndOfStream = FALSE;
  59. m_bCompleteNotified = FALSE;
  60. return CBaseInputPin::EndFlush();
  61. }
  62. // Notify of Run() from filter
  63. HRESULT CRenderedInputPin::Run(REFERENCE_TIME tStart)
  64. {
  65. UNREFERENCED_PARAMETER(tStart);
  66. m_bCompleteNotified = FALSE;
  67. if (m_bAtEndOfStream) {
  68. DoCompleteHandling();
  69. }
  70. return S_OK;
  71. }
  72. // Clear status on going into paused state
  73. HRESULT CRenderedInputPin::Active()
  74. {
  75. m_bAtEndOfStream = FALSE;
  76. m_bCompleteNotified = FALSE;
  77. return CBaseInputPin::Active();
  78. }
  79. // Do stuff to deliver end of stream
  80. void CRenderedInputPin::DoCompleteHandling()
  81. {
  82. ASSERT(m_bAtEndOfStream);
  83. if (!m_bCompleteNotified) {
  84. m_bCompleteNotified = TRUE;
  85. m_pFilter->NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)m_pFilter);
  86. }
  87. }