00001
00002
00003
00004
00005
00006 typedef CGenericList<IMediaSample> CSampleList;
00007
00008 class COutputQueue : public CCritSec
00009 {
00010 public:
00011
00012 COutputQueue(IPin *pInputPin,
00013 HRESULT *phr,
00014 BOOL bAuto = TRUE,
00015 BOOL bQueue = TRUE,
00016
00017 LONG lBatchSize = 1,
00018 BOOL bBatchExact = FALSE,
00019 LONG lListSize =
00020 DEFAULTCACHE,
00021 DWORD dwPriority =
00022 THREAD_PRIORITY_NORMAL,
00023 bool bFlushingOpt = false
00024 );
00025 ~COutputQueue();
00026
00027
00028 void BeginFlush();
00029
00030
00031 void EndFlush();
00032
00033
00034 void EOS();
00035
00036 void SendAnyway();
00037
00038 void NewSegment(
00039 REFERENCE_TIME tStart,
00040 REFERENCE_TIME tStop,
00041 double dRate);
00042
00043 HRESULT Receive(IMediaSample *pSample);
00044
00045
00046 HRESULT ReceiveMultiple (
00047 IMediaSample **pSamples,
00048 long nSamples,
00049 long *nSamplesProcessed);
00050
00051 void Reset();
00052
00053
00054 BOOL IsIdle();
00055
00056
00057 void SetPopEvent(HANDLE hEvent);
00058
00059 protected:
00060 static DWORD WINAPI InitialThreadProc(LPVOID pv);
00061 DWORD ThreadProc();
00062 BOOL IsQueued()
00063 {
00064 return m_List != NULL;
00065 };
00066
00067
00068 void QueueSample(IMediaSample *pSample);
00069
00070 BOOL IsSpecialSample(IMediaSample *pSample)
00071 {
00072 return (DWORD_PTR)pSample > (DWORD_PTR)(LONG_PTR)(-16);
00073 };
00074
00075
00076 void FreeSamples();
00077
00078
00079 void NotifyThread();
00080
00081 protected:
00082
00083 #define SEND_PACKET ((IMediaSample *)(LONG_PTR)(-2))
00084 #define EOS_PACKET ((IMediaSample *)(LONG_PTR)(-3))
00085 #define RESET_PACKET ((IMediaSample *)(LONG_PTR)(-4))
00086 #define NEW_SEGMENT ((IMediaSample *)(LONG_PTR)(-5))
00087
00088
00089 struct NewSegmentPacket {
00090 REFERENCE_TIME tStart;
00091 REFERENCE_TIME tStop;
00092 double dRate;
00093 };
00094
00095
00096 IPin * const m_pPin;
00097 IMemInputPin * m_pInputPin;
00098 BOOL const m_bBatchExact;
00099 LONG const m_lBatchSize;
00100
00101 CSampleList * m_List;
00102 HANDLE m_hSem;
00103 CAMEvent m_evFlushComplete;
00104 HANDLE m_hThread;
00105 IMediaSample ** m_ppSamples;
00106 LONG m_nBatched;
00107
00108
00109 LONG m_lWaiting;
00110
00111 BOOL m_bFlushing;
00112
00113
00114
00115 BOOL m_bFlushed;
00116 bool m_bFlushingOpt;
00117
00118
00119 BOOL m_bTerminate;
00120
00121
00122 BOOL m_bSendAnyway;
00123
00124
00125 BOOL volatile m_hr;
00126
00127
00128 HANDLE m_hEventPop;
00129 };
00130