Support unrar64.dll
[xy_vsfilter.git] / src / filters / BaseClasses / outputq.h
blob81eaab285b884f4f83e391b8387ce6a7e44b5caa
1 //------------------------------------------------------------------------------
2 // File: OutputQ.h
3 //
4 // Desc: DirectShow base classes - defines the COutputQueue class, which
5 // makes a queue of samples and sends them to an output pin. The
6 // class will optionally send the samples to the pin directly.
7 //
8 // Copyright (c) 1992-2002 Microsoft Corporation. All rights reserved.
9 //------------------------------------------------------------------------------
12 typedef CGenericList<IMediaSample> CSampleList;
14 class COutputQueue : public CCritSec
16 public:
17 // Constructor
18 COutputQueue(IPin *pInputPin, // Pin to send stuff to
19 HRESULT *phr, // 'Return code'
20 BOOL bAuto = TRUE, // Ask pin if blocks
21 BOOL bQueue = TRUE, // Send through queue (ignored if
22 // bAuto set)
23 LONG lBatchSize = 1, // Batch
24 BOOL bBatchExact = FALSE,// Batch exactly to BatchSize
25 LONG lListSize = // Likely number in the list
26 DEFAULTCACHE,
27 DWORD dwPriority = // Priority of thread to create
28 THREAD_PRIORITY_NORMAL,
29 bool bFlushingOpt = false // flushing optimization
31 ~COutputQueue();
33 // enter flush state - discard all data
34 void BeginFlush(); // Begin flushing samples
36 // re-enable receives (pass this downstream)
37 void EndFlush(); // Complete flush of samples - downstream
38 // pin guaranteed not to block at this stage
40 void EOS(); // Call this on End of stream
42 void SendAnyway(); // Send batched samples anyway (if bBatchExact set)
44 void NewSegment(
45 REFERENCE_TIME tStart,
46 REFERENCE_TIME tStop,
47 double dRate);
49 HRESULT Receive(IMediaSample *pSample);
51 // do something with these media samples
52 HRESULT ReceiveMultiple (
53 IMediaSample **pSamples,
54 long nSamples,
55 long *nSamplesProcessed);
57 void Reset(); // Reset m_hr ready for more data
59 // See if its idle or not
60 BOOL IsIdle();
62 // give the class an event to fire after everything removed from the queue
63 void SetPopEvent(HANDLE hEvent);
65 protected:
66 static DWORD WINAPI InitialThreadProc(LPVOID pv);
67 DWORD ThreadProc();
68 BOOL IsQueued()
70 return m_List != NULL;
73 // The critical section MUST be held when this is called
74 void QueueSample(IMediaSample *pSample);
76 BOOL IsSpecialSample(IMediaSample *pSample)
78 return (DWORD_PTR)pSample > (DWORD_PTR)(LONG_PTR)(-16);
81 // Remove and Release() batched and queued samples
82 void FreeSamples();
84 // Notify the thread there is something to do
85 void NotifyThread();
88 protected:
89 // Queue 'messages'
90 #define SEND_PACKET ((IMediaSample *)(LONG_PTR)(-2)) // Send batch
91 #define EOS_PACKET ((IMediaSample *)(LONG_PTR)(-3)) // End of stream
92 #define RESET_PACKET ((IMediaSample *)(LONG_PTR)(-4)) // Reset m_hr
93 #define NEW_SEGMENT ((IMediaSample *)(LONG_PTR)(-5)) // send NewSegment
95 // new segment packet is always followed by one of these
96 struct NewSegmentPacket {
97 REFERENCE_TIME tStart;
98 REFERENCE_TIME tStop;
99 double dRate;
102 // Remember input stuff
103 IPin * const m_pPin;
104 IMemInputPin * m_pInputPin;
105 BOOL const m_bBatchExact;
106 LONG const m_lBatchSize;
108 CSampleList * m_List;
109 HANDLE m_hSem;
110 CAMEvent m_evFlushComplete;
111 HANDLE m_hThread;
112 IMediaSample ** m_ppSamples;
113 LONG m_nBatched;
115 // Wait optimization
116 LONG m_lWaiting;
117 // Flush synchronization
118 BOOL m_bFlushing;
120 // flushing optimization. some downstream filters have trouble
121 // with the queue's flushing optimization. other rely on it
122 BOOL m_bFlushed;
123 bool m_bFlushingOpt;
125 // Terminate now
126 BOOL m_bTerminate;
128 // Send anyway flag for batching
129 BOOL m_bSendAnyway;
131 // Deferred 'return code'
132 BOOL volatile m_hr;
134 // an event that can be fired after every deliver
135 HANDLE m_hEventPop;