quartz: Add the ability to force a pin to use a certain renderer.
[wine/testsucceed.git] / dlls / quartz / pin.h
blob6d0600efec1bde2455e2d0c6360f601b7a1ec073
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 than 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 /* This function is called after processing is done (for whatever reason that is caused)
63 * This is useful if you create processing threads that need to die
65 typedef HRESULT (* STOPPROCESSPROC) (LPVOID userdata);
67 #define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary))
68 #define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary)))
70 typedef struct IPinImpl
72 const struct IPinVtbl * lpVtbl;
73 LONG refCount;
74 LPCRITICAL_SECTION pCritSec;
75 PIN_INFO pinInfo;
76 IPin * pConnectedTo;
77 AM_MEDIA_TYPE mtCurrent;
78 ENUMMEDIADETAILS enumMediaDetails;
79 QUERYACCEPTPROC fnQueryAccept;
80 LPVOID pUserData;
81 } IPinImpl;
83 typedef struct InputPin
85 /* inheritance C style! */
86 IPinImpl pin;
88 const IMemInputPinVtbl * lpVtblMemInput;
89 IMemAllocator * pAllocator;
90 SAMPLEPROC_PUSH fnSampleProc;
91 CLEANUPPROC fnCleanProc;
92 REFERENCE_TIME tStart;
93 REFERENCE_TIME tStop;
94 double dRate;
95 BOOL flushing, end_of_stream;
96 IMemAllocator *preferred_allocator;
97 } InputPin;
99 typedef struct OutputPin
101 /* inheritance C style! */
102 IPinImpl pin;
104 IMemInputPin * pMemInputPin;
105 HRESULT (* pConnectSpecific)(IPin * iface, IPin * pReceiver, const AM_MEDIA_TYPE * pmt);
106 BOOL custom_allocator;
107 IMemAllocator *alloc;
108 BOOL readonly;
109 ALLOCATOR_PROPERTIES allocProps;
110 } OutputPin;
112 typedef struct PullPin
114 /* inheritance C style! */
115 IPinImpl pin;
117 REFERENCE_TIME rtStart, rtCurrent, rtNext, rtStop;
118 IAsyncReader * pReader;
119 IMemAllocator * pAlloc;
120 SAMPLEPROC_PULL fnSampleProc;
121 PRECONNECTPROC fnPreConnect;
122 REQUESTPROC fnCustomRequest;
123 CLEANUPPROC fnCleanProc;
124 STOPPROCESSPROC fnDone;
125 double dRate;
126 BOOL stop_playback;
127 DWORD cbAlign;
129 /* Any code that touches the thread must hold the thread lock,
130 * lock order: thread_lock and then the filter critical section
131 * also signal thread_sleepy so the thread knows to wake up
133 CRITICAL_SECTION thread_lock;
134 HANDLE hThread;
135 DWORD requested_state;
136 HANDLE hEventStateChanged, thread_sleepy;
137 DWORD state;
138 } PullPin;
140 #define Req_Sleepy 0
141 #define Req_Die 1
142 #define Req_Run 2
143 #define Req_Pause 3
145 /*** Constructors ***/
146 HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin);
147 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);
148 HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, STOPPROCESSPROC, REQUESTPROC pCustomRequest, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
150 /**************************/
151 /*** Pin Implementation ***/
153 /* Common */
154 ULONG WINAPI IPinImpl_AddRef(IPin * iface);
155 HRESULT WINAPI IPinImpl_Disconnect(IPin * iface);
156 HRESULT WINAPI IPinImpl_ConnectedTo(IPin * iface, IPin ** ppPin);
157 HRESULT WINAPI IPinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt);
158 HRESULT WINAPI IPinImpl_QueryPinInfo(IPin * iface, PIN_INFO * pInfo);
159 HRESULT WINAPI IPinImpl_QueryDirection(IPin * iface, PIN_DIRECTION * pPinDir);
160 HRESULT WINAPI IPinImpl_QueryId(IPin * iface, LPWSTR * Id);
161 HRESULT WINAPI IPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
162 HRESULT WINAPI IPinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum);
163 HRESULT WINAPI IPinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin);
165 /* Input Pin */
166 HRESULT WINAPI InputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
167 ULONG WINAPI InputPin_Release(IPin * iface);
168 HRESULT WINAPI InputPin_Connect(IPin * iface, IPin * pConnector, const AM_MEDIA_TYPE * pmt);
169 HRESULT WINAPI InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
170 HRESULT WINAPI InputPin_EndOfStream(IPin * iface);
171 HRESULT WINAPI InputPin_BeginFlush(IPin * iface);
172 HRESULT WINAPI InputPin_EndFlush(IPin * iface);
173 HRESULT WINAPI InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
175 /* Output Pin */
176 HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
177 ULONG WINAPI OutputPin_Release(IPin * iface);
178 HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
179 HRESULT WINAPI OutputPin_Disconnect(IPin * iface);
180 HRESULT WINAPI OutputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
181 HRESULT WINAPI OutputPin_EndOfStream(IPin * iface);
182 HRESULT WINAPI OutputPin_BeginFlush(IPin * iface);
183 HRESULT WINAPI OutputPin_EndFlush(IPin * iface);
184 HRESULT WINAPI OutputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
186 HRESULT OutputPin_CommitAllocator(OutputPin * This);
187 HRESULT OutputPin_GetDeliveryBuffer(OutputPin * This, IMediaSample ** ppSample, REFERENCE_TIME * tStart, REFERENCE_TIME * tStop, DWORD dwFlags);
188 HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample);
189 HRESULT OutputPin_DeliverDisconnect(OutputPin * This);
190 HRESULT OutputPin_DeliverNewSegment(OutputPin * This, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
192 /**********************************/
193 /*** MemInputPin Implementation ***/
195 HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin * iface, REFIID riid, LPVOID * ppv);
196 ULONG WINAPI MemInputPin_AddRef(IMemInputPin * iface);
197 ULONG WINAPI MemInputPin_Release(IMemInputPin * iface);
198 HRESULT WINAPI MemInputPin_GetAllocator(IMemInputPin * iface, IMemAllocator ** ppAllocator);
199 HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin * iface, IMemAllocator * pAllocator, BOOL bReadOnly);
200 HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface, ALLOCATOR_PROPERTIES * pProps);
201 HRESULT WINAPI MemInputPin_Receive(IMemInputPin * iface, IMediaSample * pSample);
202 HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin * iface, IMediaSample ** pSamples, long nSamples, long *nSamplesProcessed);
203 HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface);
205 /* Pull Pin */
206 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
207 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
208 ULONG WINAPI PullPin_Release(IPin * iface);
209 HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
210 HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
211 HRESULT WINAPI PullPin_EndFlush(IPin * iface);
212 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
214 /* Thread interaction functions: Hold the thread_lock before calling them */
215 HRESULT PullPin_InitProcessing(PullPin * This);
216 HRESULT PullPin_StartProcessing(PullPin * This);
217 HRESULT PullPin_StopProcessing(PullPin * This);
218 HRESULT PullPin_PauseProcessing(PullPin * This);
219 HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds);