widl: Parse attribute custom(guid,expr).
[wine.git] / include / wine / strmbase.h
blob5bd181746a1d53858bde6092187bb26466b88d03
1 /*
2 * Header file for Wine's strmbase implementation
4 * Copyright 2003 Robert Shearman
5 * Copyright 2010 Aric Stewart, CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "dshow.h"
23 #include "wine/list.h"
25 HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc);
26 void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType);
27 AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc);
28 void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
30 void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt);
32 /* Pin functions */
34 struct strmbase_pin
36 IPin IPin_iface;
37 struct strmbase_filter *filter;
38 PIN_DIRECTION dir;
39 WCHAR name[128];
40 IPin *peer;
41 AM_MEDIA_TYPE mt;
43 const struct strmbase_pin_ops *ops;
46 struct strmbase_pin_ops
48 /* Required for QueryAccept(), Connect(), ReceiveConnection(). */
49 HRESULT (*pin_query_accept)(struct strmbase_pin *pin, const AM_MEDIA_TYPE *mt);
50 /* Required for EnumMediaTypes(). */
51 HRESULT (*pin_get_media_type)(struct strmbase_pin *pin, unsigned int index, AM_MEDIA_TYPE *mt);
52 HRESULT (*pin_query_interface)(struct strmbase_pin *pin, REFIID iid, void **out);
55 struct strmbase_source
57 struct strmbase_pin pin;
58 IMemInputPin *pMemInputPin;
59 IMemAllocator *pAllocator;
61 const struct strmbase_source_ops *pFuncsTable;
64 typedef HRESULT (WINAPI *BaseOutputPin_AttemptConnection)(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
65 typedef HRESULT (WINAPI *BaseOutputPin_DecideBufferSize)(struct strmbase_source *pin, IMemAllocator *allocator, ALLOCATOR_PROPERTIES *props);
66 typedef HRESULT (WINAPI *BaseOutputPin_DecideAllocator)(struct strmbase_source *pin, IMemInputPin *peer, IMemAllocator **allocator);
68 struct strmbase_source_ops
70 struct strmbase_pin_ops base;
72 /* Required for Connect(). */
73 BaseOutputPin_AttemptConnection pfnAttemptConnection;
74 /* Required for BaseOutputPinImpl_DecideAllocator */
75 BaseOutputPin_DecideBufferSize pfnDecideBufferSize;
76 /* Required for BaseOutputPinImpl_AttemptConnection */
77 BaseOutputPin_DecideAllocator pfnDecideAllocator;
79 void (*source_disconnect)(struct strmbase_source *pin);
82 struct strmbase_sink
84 struct strmbase_pin pin;
86 IMemInputPin IMemInputPin_iface;
87 IMemAllocator *pAllocator;
88 BOOL flushing;
89 IMemAllocator *preferred_allocator;
91 const struct strmbase_sink_ops *pFuncsTable;
94 typedef HRESULT (WINAPI *BaseInputPin_Receive)(struct strmbase_sink *This, IMediaSample *pSample);
96 struct strmbase_sink_ops
98 struct strmbase_pin_ops base;
99 BaseInputPin_Receive pfnReceive;
100 HRESULT (*sink_connect)(struct strmbase_sink *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
101 void (*sink_disconnect)(struct strmbase_sink *pin);
102 HRESULT (*sink_eos)(struct strmbase_sink *pin);
103 HRESULT (*sink_begin_flush)(struct strmbase_sink *pin);
104 HRESULT (*sink_end_flush)(struct strmbase_sink *pin);
105 HRESULT (*sink_new_segment)(struct strmbase_sink *pin, REFERENCE_TIME start, REFERENCE_TIME stop, double rate);
108 /* Base Pin */
109 HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(struct strmbase_source *pin,
110 IMediaSample **sample, REFERENCE_TIME *start, REFERENCE_TIME *stop, DWORD flags);
111 HRESULT WINAPI BaseOutputPinImpl_InitAllocator(struct strmbase_source *pin, IMemAllocator **allocator);
112 HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(struct strmbase_source *pin, IMemInputPin *peer, IMemAllocator **allocator);
113 HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
115 void strmbase_source_cleanup(struct strmbase_source *pin);
116 void strmbase_source_init(struct strmbase_source *pin, struct strmbase_filter *filter,
117 const WCHAR *name, const struct strmbase_source_ops *func_table);
119 void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter,
120 const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator);
121 void strmbase_sink_cleanup(struct strmbase_sink *pin);
123 struct strmbase_filter
125 IBaseFilter IBaseFilter_iface;
126 IUnknown IUnknown_inner;
127 IUnknown *outer_unk;
128 LONG refcount;
129 CRITICAL_SECTION csFilter;
131 FILTER_STATE state;
132 IReferenceClock *clock;
133 WCHAR name[128];
134 IFilterGraph *graph;
135 CLSID clsid;
136 LONG pin_version;
138 const struct strmbase_filter_ops *ops;
141 struct strmbase_filter_ops
143 struct strmbase_pin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index);
144 void (*filter_destroy)(struct strmbase_filter *iface);
145 HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out);
147 HRESULT (*filter_init_stream)(struct strmbase_filter *iface);
148 HRESULT (*filter_start_stream)(struct strmbase_filter *iface, REFERENCE_TIME time);
149 HRESULT (*filter_stop_stream)(struct strmbase_filter *iface);
150 HRESULT (*filter_cleanup_stream)(struct strmbase_filter *iface);
151 HRESULT (*filter_wait_state)(struct strmbase_filter *iface, DWORD timeout);
154 VOID WINAPI BaseFilterImpl_IncrementPinVersion(struct strmbase_filter *filter);
156 void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer,
157 const CLSID *clsid, const struct strmbase_filter_ops *func_table);
158 void strmbase_filter_cleanup(struct strmbase_filter *filter);
160 /* Source Seeking */
161 typedef HRESULT (WINAPI *SourceSeeking_ChangeRate)(IMediaSeeking *iface);
162 typedef HRESULT (WINAPI *SourceSeeking_ChangeStart)(IMediaSeeking *iface);
163 typedef HRESULT (WINAPI *SourceSeeking_ChangeStop)(IMediaSeeking *iface);
165 typedef struct SourceSeeking
167 IMediaSeeking IMediaSeeking_iface;
169 ULONG refCount;
170 SourceSeeking_ChangeStop fnChangeStop;
171 SourceSeeking_ChangeStart fnChangeStart;
172 SourceSeeking_ChangeRate fnChangeRate;
173 DWORD dwCapabilities;
174 double dRate;
175 LONGLONG llCurrent, llStop, llDuration;
176 GUID timeformat;
177 CRITICAL_SECTION cs;
178 } SourceSeeking;
180 HRESULT strmbase_seeking_init(SourceSeeking *seeking, const IMediaSeekingVtbl *vtbl,
181 SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
182 SourceSeeking_ChangeRate fnChangeRate);
183 void strmbase_seeking_cleanup(SourceSeeking *seeking);
185 HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
186 HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
187 HRESULT WINAPI SourceSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat);
188 HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat);
189 HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat);
190 HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
191 HRESULT WINAPI SourceSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
192 HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration);
193 HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop);
194 HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent);
195 HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat);
196 HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags);
197 HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop);
198 HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest);
199 HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
200 HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
201 HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
203 /* Output Queue */
204 typedef struct tagOutputQueue {
205 CRITICAL_SECTION csQueue;
207 struct strmbase_source *pInputPin;
209 HANDLE hThread;
210 HANDLE hProcessQueue;
212 LONG lBatchSize;
213 BOOL bBatchExact;
214 BOOL bTerminate;
215 BOOL bSendAnyway;
217 struct list SampleList;
219 const struct OutputQueueFuncTable* pFuncsTable;
220 } OutputQueue;
222 typedef DWORD (WINAPI *OutputQueue_ThreadProc)(OutputQueue *This);
224 typedef struct OutputQueueFuncTable
226 OutputQueue_ThreadProc pfnThreadProc;
227 } OutputQueueFuncTable;
229 HRESULT WINAPI OutputQueue_Construct( struct strmbase_source *pin, BOOL bAuto,
230 BOOL bQueue, LONG lBatchSize, BOOL bBatchExact, DWORD dwPriority,
231 const OutputQueueFuncTable* pFuncsTable, OutputQueue **ppOutputQueue );
232 HRESULT WINAPI OutputQueue_Destroy(OutputQueue *pOutputQueue);
233 HRESULT WINAPI OutputQueue_ReceiveMultiple(OutputQueue *pOutputQueue, IMediaSample **ppSamples, LONG nSamples, LONG *nSamplesProcessed);
234 HRESULT WINAPI OutputQueue_Receive(OutputQueue *pOutputQueue, IMediaSample *pSample);
235 VOID WINAPI OutputQueue_EOS(OutputQueue *pOutputQueue);
236 VOID WINAPI OutputQueue_SendAnyway(OutputQueue *pOutputQueue);
237 DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue);
239 enum strmbase_type_id
241 IBasicAudio_tid,
242 IBasicVideo_tid,
243 IMediaControl_tid,
244 IMediaEvent_tid,
245 IMediaPosition_tid,
246 IVideoWindow_tid,
247 last_tid
250 HRESULT strmbase_get_typeinfo(enum strmbase_type_id tid, ITypeInfo **typeinfo);
251 void strmbase_release_typelibs(void);
253 struct strmbase_passthrough
255 ISeekingPassThru ISeekingPassThru_iface;
256 IMediaSeeking IMediaSeeking_iface;
257 IMediaPosition IMediaPosition_iface;
259 IUnknown *outer_unk;
260 IPin *pin;
261 BOOL renderer;
262 BOOL timevalid;
263 CRITICAL_SECTION time_cs;
264 REFERENCE_TIME time_earliest;
267 void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer);
268 void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough);
270 void strmbase_passthrough_eos(struct strmbase_passthrough *passthrough);
271 void strmbase_passthrough_invalidate_time(struct strmbase_passthrough *passthrough);
272 void strmbase_passthrough_update_time(struct strmbase_passthrough *passthrough, REFERENCE_TIME time);
274 struct strmbase_qc
276 IQualityControl IQualityControl_iface;
277 struct strmbase_pin *pin;
278 IQualityControl *tonotify;
280 /* Render stuff */
281 REFERENCE_TIME last_in_time, last_left, avg_duration, avg_pt, avg_render, start, stop;
282 REFERENCE_TIME current_jitter, current_rstart, current_rstop, clockstart;
283 double avg_rate;
284 LONG64 rendered, dropped;
285 BOOL qos_handled, is_dropped;
288 void strmbase_qc_init(struct strmbase_qc *qc, struct strmbase_pin *pin);
290 struct strmbase_renderer
292 struct strmbase_filter filter;
293 struct strmbase_passthrough passthrough;
294 struct strmbase_qc qc;
296 struct strmbase_sink sink;
298 CRITICAL_SECTION csRenderLock;
299 /* Signaled when the filter has completed a state change. The filter waits
300 * for this event in IBaseFilter::GetState(). */
301 HANDLE state_event;
302 /* Signaled when the sample presentation time occurs. The streaming thread
303 * waits for this event in Receive() if applicable. */
304 HANDLE advise_event;
305 /* Signaled when a flush or state change occurs, i.e. anything that needs
306 * to immediately unblock the streaming thread. */
307 HANDLE flush_event;
308 REFERENCE_TIME stream_start;
310 const struct strmbase_renderer_ops *pFuncsTable;
312 BOOL eos;
315 typedef HRESULT (WINAPI *BaseRenderer_CheckMediaType)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
316 typedef HRESULT (WINAPI *BaseRenderer_DoRenderSample)(struct strmbase_renderer *iface, IMediaSample *sample);
317 typedef HRESULT (WINAPI *BaseRenderer_BreakConnect) (struct strmbase_renderer *iface);
319 struct strmbase_renderer_ops
321 BaseRenderer_CheckMediaType pfnCheckMediaType;
322 BaseRenderer_DoRenderSample pfnDoRenderSample;
323 void (*renderer_init_stream)(struct strmbase_renderer *iface);
324 void (*renderer_start_stream)(struct strmbase_renderer *iface);
325 void (*renderer_stop_stream)(struct strmbase_renderer *iface);
326 HRESULT (*renderer_connect)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
327 BaseRenderer_BreakConnect pfnBreakConnect;
328 void (*renderer_destroy)(struct strmbase_renderer *iface);
329 HRESULT (*renderer_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
330 HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
333 void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
334 const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops);
335 void strmbase_renderer_cleanup(struct strmbase_renderer *filter);