00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #ifndef __strmctl_h__ 00007 #define __strmctl_h__ 00008 00009 class CBaseStreamControl : public IAMStreamControl 00010 { 00011 public: 00012 00013 enum StreamControlState 00014 { STREAM_FLOWING = 0x1000, 00015 STREAM_DISCARDING 00016 }; 00017 00018 private: 00019 enum StreamControlState m_StreamState; 00020 enum StreamControlState m_StreamStateOnStop; 00021 00022 00023 REFERENCE_TIME m_tStartTime; 00024 REFERENCE_TIME m_tStopTime; 00025 DWORD m_dwStartCookie; 00026 DWORD m_dwStopCookie; 00027 volatile BOOL m_bIsFlushing; 00028 volatile BOOL m_bStopSendExtra; 00029 volatile BOOL m_bStopExtraSent; 00030 00031 CCritSec m_CritSec; 00032 00033 CAMEvent m_StreamEvent; 00034 00035 void ExecuteStop(); 00036 void ExecuteStart(); 00037 void CancelStop(); 00038 void CancelStart(); 00039 00040 IReferenceClock * m_pRefClock; 00041 00042 IMediaEventSink * m_pSink; 00043 00044 00045 FILTER_STATE m_FilterState; 00046 00047 00048 REFERENCE_TIME m_tRunStart; 00049 00050 00051 enum StreamControlState CheckSampleTimes( const REFERENCE_TIME * pSampleStart, 00052 const REFERENCE_TIME * pSampleStop ); 00053 00054 public: 00055 00056 CBaseStreamControl(); 00057 ~CBaseStreamControl(); 00058 00059 void SetSyncSource( IReferenceClock * pRefClock ) 00060 { 00061 CAutoLock lck(&m_CritSec); 00062 if (m_pRefClock) m_pRefClock->Release(); 00063 m_pRefClock = pRefClock; 00064 if (m_pRefClock) m_pRefClock->AddRef(); 00065 } 00066 00067 00068 void SetFilterGraph( IMediaEventSink *pSink ) { 00069 m_pSink = pSink; 00070 } 00071 00072 void NotifyFilterState( FILTER_STATE new_state, REFERENCE_TIME tStart = 0 ); 00073 00074 void Flushing( BOOL bInProgress ); 00075 00076 STDMETHODIMP StopAt( const REFERENCE_TIME * ptStop = NULL, 00077 BOOL bSendExtra = FALSE, 00078 DWORD dwCookie = 0 ); 00079 STDMETHODIMP StartAt( const REFERENCE_TIME * ptStart = NULL, 00080 DWORD dwCookie = 0 ); 00081 STDMETHODIMP GetInfo( AM_STREAM_INFO *pInfo); 00082 00083 enum StreamControlState CheckStreamState( IMediaSample * pSample ); 00084 00085 private: 00086 00087 HANDLE GetStreamEventHandle() const { return m_StreamEvent; } 00088 enum StreamControlState GetStreamState() const { return m_StreamState; } 00089 BOOL IsStreaming() const { return m_StreamState == STREAM_FLOWING; } 00090 }; 00091 00092 #endif
1.5.6