wordpad: Apply changes on dropdown selection for comboboxes on toolbar.
[wine/multimedia.git] / dlls / quartz / pin.h
blob8f160bf44c3e6fba9b2ce922c2636fecdfd91527
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 } InputPin;
98 typedef struct OutputPin
100 /* inheritance C style! */
101 IPinImpl pin;
103 IMemInputPin * pMemInputPin;
104 HRESULT (* pConnectSpecific)(IPin * iface, IPin * pReceiver, const AM_MEDIA_TYPE * pmt);
105 BOOL custom_allocator;
106 IMemAllocator *alloc;
107 BOOL readonly;
108 ALLOCATOR_PROPERTIES allocProps;
109 } OutputPin;
111 typedef struct PullPin
113 /* inheritance C style! */
114 IPinImpl pin;
116 REFERENCE_TIME rtStart, rtCurrent, rtNext, rtStop;
117 IAsyncReader * pReader;
118 IMemAllocator * pAlloc;
119 SAMPLEPROC_PULL fnSampleProc;
120 PRECONNECTPROC fnPreConnect;
121 REQUESTPROC fnCustomRequest;
122 CLEANUPPROC fnCleanProc;
123 STOPPROCESSPROC fnDone;
124 double dRate;
125 BOOL stop_playback;
126 DWORD cbAlign;
128 /* Any code that touches the thread must hold the thread lock,
129 * lock order: thread_lock and then the filter critical section
130 * also signal thread_sleepy so the thread knows to wake up
132 CRITICAL_SECTION thread_lock;
133 HANDLE hThread;
134 DWORD requested_state;
135 HANDLE hEventStateChanged, thread_sleepy;
136 DWORD state;
137 } PullPin;
139 #define Req_Sleepy 0
140 #define Req_Die 1
141 #define Req_Run 2
142 #define Req_Pause 3
144 /*** Constructors ***/
145 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);
146 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);
147 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);
149 /**************************/
150 /*** Pin Implementation ***/
152 /* Common */
153 ULONG WINAPI IPinImpl_AddRef(IPin * iface);
154 HRESULT WINAPI IPinImpl_Disconnect(IPin * iface);
155 HRESULT WINAPI IPinImpl_ConnectedTo(IPin * iface, IPin ** ppPin);
156 HRESULT WINAPI IPinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt);
157 HRESULT WINAPI IPinImpl_QueryPinInfo(IPin * iface, PIN_INFO * pInfo);
158 HRESULT WINAPI IPinImpl_QueryDirection(IPin * iface, PIN_DIRECTION * pPinDir);
159 HRESULT WINAPI IPinImpl_QueryId(IPin * iface, LPWSTR * Id);
160 HRESULT WINAPI IPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
161 HRESULT WINAPI IPinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum);
162 HRESULT WINAPI IPinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin);
164 /* Input Pin */
165 HRESULT WINAPI InputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
166 ULONG WINAPI InputPin_Release(IPin * iface);
167 HRESULT WINAPI InputPin_Connect(IPin * iface, IPin * pConnector, const AM_MEDIA_TYPE * pmt);
168 HRESULT WINAPI InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
169 HRESULT WINAPI InputPin_EndOfStream(IPin * iface);
170 HRESULT WINAPI InputPin_BeginFlush(IPin * iface);
171 HRESULT WINAPI InputPin_EndFlush(IPin * iface);
172 HRESULT WINAPI InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
174 /* Output Pin */
175 HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
176 ULONG WINAPI OutputPin_Release(IPin * iface);
177 HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
178 HRESULT WINAPI OutputPin_Disconnect(IPin * iface);
179 HRESULT WINAPI OutputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
180 HRESULT WINAPI OutputPin_EndOfStream(IPin * iface);
181 HRESULT WINAPI OutputPin_BeginFlush(IPin * iface);
182 HRESULT WINAPI OutputPin_EndFlush(IPin * iface);
183 HRESULT WINAPI OutputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
185 HRESULT OutputPin_CommitAllocator(OutputPin * This);
186 HRESULT OutputPin_GetDeliveryBuffer(OutputPin * This, IMediaSample ** ppSample, REFERENCE_TIME * tStart, REFERENCE_TIME * tStop, DWORD dwFlags);
187 HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample);
188 HRESULT OutputPin_DeliverDisconnect(OutputPin * This);
189 HRESULT OutputPin_DeliverNewSegment(OutputPin * This, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
191 /**********************************/
192 /*** MemInputPin Implementation ***/
194 HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin * iface, REFIID riid, LPVOID * ppv);
195 ULONG WINAPI MemInputPin_AddRef(IMemInputPin * iface);
196 ULONG WINAPI MemInputPin_Release(IMemInputPin * iface);
197 HRESULT WINAPI MemInputPin_GetAllocator(IMemInputPin * iface, IMemAllocator ** ppAllocator);
198 HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin * iface, IMemAllocator * pAllocator, BOOL bReadOnly);
199 HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface, ALLOCATOR_PROPERTIES * pProps);
200 HRESULT WINAPI MemInputPin_Receive(IMemInputPin * iface, IMediaSample * pSample);
201 HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin * iface, IMediaSample ** pSamples, long nSamples, long *nSamplesProcessed);
202 HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface);
204 /* Pull Pin */
205 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
206 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
207 ULONG WINAPI PullPin_Release(IPin * iface);
208 HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
209 HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
210 HRESULT WINAPI PullPin_EndFlush(IPin * iface);
211 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
213 /* Thread interaction functions: Hold the thread_lock before calling them */
214 HRESULT PullPin_InitProcessing(PullPin * This);
215 HRESULT PullPin_StartProcessing(PullPin * This);
216 HRESULT PullPin_StopProcessing(PullPin * This);
217 HRESULT PullPin_PauseProcessing(PullPin * This);
218 HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds);