ntdll: Only use sysinfo function when present.
[wine.git] / include / wine / strmbase.h
blob788abfd1c9f40b2faf3c72ea72474faee29c9704
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 filter_cs;
130 CRITICAL_SECTION stream_cs;
132 FILTER_STATE state;
133 IReferenceClock *clock;
134 WCHAR name[128];
135 IFilterGraph *graph;
136 CLSID clsid;
137 LONG pin_version;
139 const struct strmbase_filter_ops *ops;
142 struct strmbase_filter_ops
144 struct strmbase_pin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index);
145 void (*filter_destroy)(struct strmbase_filter *iface);
146 HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out);
148 HRESULT (*filter_init_stream)(struct strmbase_filter *iface);
149 HRESULT (*filter_start_stream)(struct strmbase_filter *iface, REFERENCE_TIME time);
150 HRESULT (*filter_stop_stream)(struct strmbase_filter *iface);
151 HRESULT (*filter_cleanup_stream)(struct strmbase_filter *iface);
152 HRESULT (*filter_wait_state)(struct strmbase_filter *iface, DWORD timeout);
155 VOID WINAPI BaseFilterImpl_IncrementPinVersion(struct strmbase_filter *filter);
157 void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer,
158 const CLSID *clsid, const struct strmbase_filter_ops *func_table);
159 void strmbase_filter_cleanup(struct strmbase_filter *filter);
161 /* Source Seeking */
162 typedef HRESULT (WINAPI *SourceSeeking_ChangeRate)(IMediaSeeking *iface);
163 typedef HRESULT (WINAPI *SourceSeeking_ChangeStart)(IMediaSeeking *iface);
164 typedef HRESULT (WINAPI *SourceSeeking_ChangeStop)(IMediaSeeking *iface);
166 typedef struct SourceSeeking
168 IMediaSeeking IMediaSeeking_iface;
170 ULONG refCount;
171 SourceSeeking_ChangeStop fnChangeStop;
172 SourceSeeking_ChangeStart fnChangeStart;
173 SourceSeeking_ChangeRate fnChangeRate;
174 DWORD dwCapabilities;
175 double dRate;
176 LONGLONG llCurrent, llStop, llDuration;
177 GUID timeformat;
178 CRITICAL_SECTION cs;
179 } SourceSeeking;
181 HRESULT strmbase_seeking_init(SourceSeeking *seeking, const IMediaSeekingVtbl *vtbl,
182 SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
183 SourceSeeking_ChangeRate fnChangeRate);
184 void strmbase_seeking_cleanup(SourceSeeking *seeking);
186 HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
187 HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
188 HRESULT WINAPI SourceSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat);
189 HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat);
190 HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat);
191 HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
192 HRESULT WINAPI SourceSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
193 HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration);
194 HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop);
195 HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent);
196 HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat);
197 HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags);
198 HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop);
199 HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest);
200 HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
201 HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
202 HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
204 /* Output Queue */
205 typedef struct tagOutputQueue {
206 CRITICAL_SECTION csQueue;
208 struct strmbase_source *pInputPin;
210 HANDLE hThread;
211 HANDLE hProcessQueue;
213 LONG lBatchSize;
214 BOOL bBatchExact;
215 BOOL bTerminate;
216 BOOL bSendAnyway;
218 struct list SampleList;
220 const struct OutputQueueFuncTable* pFuncsTable;
221 } OutputQueue;
223 typedef DWORD (WINAPI *OutputQueue_ThreadProc)(OutputQueue *This);
225 typedef struct OutputQueueFuncTable
227 OutputQueue_ThreadProc pfnThreadProc;
228 } OutputQueueFuncTable;
230 HRESULT WINAPI OutputQueue_Construct( struct strmbase_source *pin, BOOL bAuto,
231 BOOL bQueue, LONG lBatchSize, BOOL bBatchExact, DWORD dwPriority,
232 const OutputQueueFuncTable* pFuncsTable, OutputQueue **ppOutputQueue );
233 HRESULT WINAPI OutputQueue_Destroy(OutputQueue *pOutputQueue);
234 HRESULT WINAPI OutputQueue_ReceiveMultiple(OutputQueue *pOutputQueue, IMediaSample **ppSamples, LONG nSamples, LONG *nSamplesProcessed);
235 HRESULT WINAPI OutputQueue_Receive(OutputQueue *pOutputQueue, IMediaSample *pSample);
236 VOID WINAPI OutputQueue_EOS(OutputQueue *pOutputQueue);
237 VOID WINAPI OutputQueue_SendAnyway(OutputQueue *pOutputQueue);
238 DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue);
240 enum strmbase_type_id
242 IBasicAudio_tid,
243 IBasicVideo_tid,
244 IMediaControl_tid,
245 IMediaEvent_tid,
246 IMediaPosition_tid,
247 IVideoWindow_tid,
248 last_tid
251 HRESULT strmbase_get_typeinfo(enum strmbase_type_id tid, ITypeInfo **typeinfo);
252 void strmbase_release_typelibs(void);
254 struct strmbase_passthrough
256 ISeekingPassThru ISeekingPassThru_iface;
257 IMediaSeeking IMediaSeeking_iface;
258 IMediaPosition IMediaPosition_iface;
260 IUnknown *outer_unk;
261 IPin *pin;
262 BOOL renderer;
263 BOOL timevalid;
264 CRITICAL_SECTION time_cs;
265 REFERENCE_TIME time_earliest;
268 void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer);
269 void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough);
271 void strmbase_passthrough_eos(struct strmbase_passthrough *passthrough);
272 void strmbase_passthrough_invalidate_time(struct strmbase_passthrough *passthrough);
273 void strmbase_passthrough_update_time(struct strmbase_passthrough *passthrough, REFERENCE_TIME time);
275 struct strmbase_renderer
277 struct strmbase_filter filter;
278 struct strmbase_passthrough passthrough;
279 IQualityControl IQualityControl_iface;
281 struct strmbase_sink sink;
283 /* Signaled when the filter has completed a state change. The filter waits
284 * for this event in IBaseFilter::GetState(). */
285 HANDLE state_event;
286 /* Signaled when the sample presentation time occurs. The streaming thread
287 * waits for this event in Receive() if applicable. */
288 HANDLE advise_event;
289 /* Signaled when the filter is running. The streaming thread waits for this
290 * event in Receive() while paused. */
291 HANDLE run_event;
292 /* Signaled when a flush or state change occurs, i.e. anything that needs
293 * to immediately unblock the streaming thread. */
294 HANDLE flush_event;
295 REFERENCE_TIME stream_start;
297 IMediaSample *current_sample;
299 IQualityControl *qc_sink;
300 REFERENCE_TIME last_left, avg_duration, avg_pt;
301 double avg_rate;
303 const struct strmbase_renderer_ops *ops;
305 BOOL eos;
308 struct strmbase_renderer_ops
310 HRESULT (*renderer_query_accept)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
311 HRESULT (*renderer_render)(struct strmbase_renderer *iface, IMediaSample *sample);
312 void (*renderer_init_stream)(struct strmbase_renderer *iface);
313 void (*renderer_start_stream)(struct strmbase_renderer *iface);
314 void (*renderer_stop_stream)(struct strmbase_renderer *iface);
315 HRESULT (*renderer_connect)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
316 void (*renderer_disconnect)(struct strmbase_renderer *iface);
317 void (*renderer_destroy)(struct strmbase_renderer *iface);
318 HRESULT (*renderer_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
319 HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
322 void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
323 const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops);
324 void strmbase_renderer_cleanup(struct strmbase_renderer *filter);