quartz: Make wave parser and mpeg splitter zero copy by getting rid of the seperate...
[wine/dcerpc.git] / dlls / quartz / pin.h
blob147a64ceddf3eaa83715efa03a98092717cf24fa
1 /*
2 * IPin function declarations to allow inheritance
4 * Copyright 2003 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 /* This function will process incoming samples to the pin.
22 * Any return value valid in IMemInputPin::Receive is allowed here
24 * Cookie is the cookie that was set when requesting the buffer, if you don't
25 * implement custom requesting, you can safely ignore this
27 typedef HRESULT (* SAMPLEPROC_PUSH)(LPVOID userdata, IMediaSample * pSample);
28 typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample * pSample, DWORD_PTR cookie);
30 /* This function will determine whether a type is supported or not.
31 * It is allowed to return any error value (within reason), as opposed
32 * to IPin::QueryAccept which is only allowed to return S_OK or S_FALSE.
34 typedef HRESULT (* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE * pmt);
36 /* This function is called prior to finalizing a connection with
37 * another pin and can be used to get things from the other pin
38 * like IMemInput interfaces.
40 * props contains some defaults, but you can safely override them to your liking
42 typedef HRESULT (* PRECONNECTPROC)(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props);
44 /* This function is called whenever a cleanup operation has to occur,
45 * this is usually after a flush, seek, or end of stream notification.
46 * This code may even be repeated multiple times, so build your code to
47 * tolerate this behavior. Return value is ignored and should be S_OK.
49 typedef HRESULT (* CLEANUPPROC) (LPVOID userdata);
51 /* This function is called whenever a request for a new sample is made,
52 * If you implement it (it can be NULL for default behavior), you have to
53 * call IMemAllocator_GetBuffer and IMemAllocator_RequestBuffer
54 * This is useful if you want to request more then 1 buffer at simultaneously
55 * If PullPin->flushed is set, it means that all buffers queued previously are gone
57 * This will also cause the Sample Proc to be called with empty buffers to indicate
58 * failure in retrieving the sample.
60 typedef HRESULT (* REQUESTPROC) (LPVOID userdata);
62 #define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary))
63 #define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary)))
65 typedef struct IPinImpl
67 const struct IPinVtbl * lpVtbl;
68 LONG refCount;
69 LPCRITICAL_SECTION pCritSec;
70 PIN_INFO pinInfo;
71 IPin * pConnectedTo;
72 AM_MEDIA_TYPE mtCurrent;
73 ENUMMEDIADETAILS enumMediaDetails;
74 QUERYACCEPTPROC fnQueryAccept;
75 LPVOID pUserData;
76 } IPinImpl;
78 typedef struct InputPin
80 /* inheritance C style! */
81 IPinImpl pin;
83 const IMemInputPinVtbl * lpVtblMemInput;
84 IMemAllocator * pAllocator;
85 SAMPLEPROC_PUSH fnSampleProc;
86 CLEANUPPROC fnCleanProc;
87 REFERENCE_TIME tStart;
88 REFERENCE_TIME tStop;
89 double dRate;
90 BOOL flushing, end_of_stream;
91 } InputPin;
93 typedef struct OutputPin
95 /* inheritance C style! */
96 IPinImpl pin;
98 IMemInputPin * pMemInputPin;
99 HRESULT (* pConnectSpecific)(IPin * iface, IPin * pReceiver, const AM_MEDIA_TYPE * pmt);
100 BOOL custom_allocator;
101 IMemAllocator *alloc;
102 BOOL readonly;
103 ALLOCATOR_PROPERTIES allocProps;
104 } OutputPin;
106 typedef struct PullPin
108 /* inheritance C style! */
109 IPinImpl pin;
111 REFERENCE_TIME rtStart, rtCurrent, rtNext, rtStop;
112 IAsyncReader * pReader;
113 IMemAllocator * pAlloc;
114 SAMPLEPROC_PULL fnSampleProc;
115 PRECONNECTPROC fnPreConnect;
116 REQUESTPROC fnCustomRequest;
117 CLEANUPPROC fnCleanProc;
118 double dRate;
119 BOOL stop_playback;
120 DWORD cbAlign;
122 /* Any code that touches the thread must hold the thread lock,
123 * lock order: thread_lock and then the filter critical section
124 * also signal thread_sleepy so the thread knows to wake up
126 CRITICAL_SECTION thread_lock;
127 HANDLE hThread;
128 DWORD requested_state;
129 HANDLE hEventStateChanged, thread_sleepy;
130 DWORD state;
131 } PullPin;
133 #define Req_Sleepy 0
134 #define Req_Die 1
135 #define Req_Run 2
136 #define Req_Pause 3
138 /*** Constructors ***/
139 HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
140 HRESULT OutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, long outputpin_size, const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *props, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
141 HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
143 /**************************/
144 /*** Pin Implementation ***/
146 /* Common */
147 ULONG WINAPI IPinImpl_AddRef(IPin * iface);
148 HRESULT WINAPI IPinImpl_Disconnect(IPin * iface);
149 HRESULT WINAPI IPinImpl_ConnectedTo(IPin * iface, IPin ** ppPin);
150 HRESULT WINAPI IPinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt);
151 HRESULT WINAPI IPinImpl_QueryPinInfo(IPin * iface, PIN_INFO * pInfo);
152 HRESULT WINAPI IPinImpl_QueryDirection(IPin * iface, PIN_DIRECTION * pPinDir);
153 HRESULT WINAPI IPinImpl_QueryId(IPin * iface, LPWSTR * Id);
154 HRESULT WINAPI IPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
155 HRESULT WINAPI IPinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum);
156 HRESULT WINAPI IPinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin);
158 /* Input Pin */
159 HRESULT WINAPI InputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
160 ULONG WINAPI InputPin_Release(IPin * iface);
161 HRESULT WINAPI InputPin_Connect(IPin * iface, IPin * pConnector, const AM_MEDIA_TYPE * pmt);
162 HRESULT WINAPI InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
163 HRESULT WINAPI InputPin_EndOfStream(IPin * iface);
164 HRESULT WINAPI InputPin_BeginFlush(IPin * iface);
165 HRESULT WINAPI InputPin_EndFlush(IPin * iface);
166 HRESULT WINAPI InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
168 /* Output Pin */
169 HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
170 ULONG WINAPI OutputPin_Release(IPin * iface);
171 HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
172 HRESULT WINAPI OutputPin_Disconnect(IPin * iface);
173 HRESULT WINAPI OutputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
174 HRESULT WINAPI OutputPin_EndOfStream(IPin * iface);
175 HRESULT WINAPI OutputPin_BeginFlush(IPin * iface);
176 HRESULT WINAPI OutputPin_EndFlush(IPin * iface);
177 HRESULT WINAPI OutputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
179 HRESULT OutputPin_CommitAllocator(OutputPin * This);
180 HRESULT OutputPin_GetDeliveryBuffer(OutputPin * This, IMediaSample ** ppSample, REFERENCE_TIME * tStart, REFERENCE_TIME * tStop, DWORD dwFlags);
181 HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample);
182 HRESULT OutputPin_DeliverDisconnect(OutputPin * This);
183 HRESULT OutputPin_DeliverNewSegment(OutputPin * This, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
185 /**********************************/
186 /*** MemInputPin Implementation ***/
188 HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin * iface, REFIID riid, LPVOID * ppv);
189 ULONG WINAPI MemInputPin_AddRef(IMemInputPin * iface);
190 ULONG WINAPI MemInputPin_Release(IMemInputPin * iface);
191 HRESULT WINAPI MemInputPin_GetAllocator(IMemInputPin * iface, IMemAllocator ** ppAllocator);
192 HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin * iface, IMemAllocator * pAllocator, BOOL bReadOnly);
193 HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface, ALLOCATOR_PROPERTIES * pProps);
194 HRESULT WINAPI MemInputPin_Receive(IMemInputPin * iface, IMediaSample * pSample);
195 HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin * iface, IMediaSample ** pSamples, long nSamples, long *nSamplesProcessed);
196 HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface);
198 /* Pull Pin */
199 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
200 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
201 ULONG WINAPI PullPin_Release(IPin * iface);
202 HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
203 HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
204 HRESULT WINAPI PullPin_EndFlush(IPin * iface);
205 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
207 /* Thread interaction functions: Hold the thread_lock before calling them */
208 HRESULT PullPin_InitProcessing(PullPin * This);
209 HRESULT PullPin_StartProcessing(PullPin * This);
210 HRESULT PullPin_StopProcessing(PullPin * This);
211 HRESULT PullPin_PauseProcessing(PullPin * This);
212 HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds);