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.

111 lines
3.0 KiB

  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(TCHAR *pObjectName,
  16. CBaseFilter *pFilter,
  17. CCritSec *pLock,
  18. HRESULT *phr,
  19. 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(CHAR *pObjectName,
  27. CBaseFilter *pFilter,
  28. CCritSec *pLock,
  29. HRESULT *phr,
  30. 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. }