ieframe: Return S_FALSE in IWebBrowser2::get_Document when returning NULL.
[wine.git] / include / wine / strmbase.h
blob6789957e50a96d01ef4ea14465086f370fef5867
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 strmbase_pin_get_media_type(struct strmbase_pin *pin, unsigned int index, AM_MEDIA_TYPE *mt);
111 HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(struct strmbase_source *pin,
112 IMediaSample **sample, REFERENCE_TIME *start, REFERENCE_TIME *stop, DWORD flags);
113 HRESULT WINAPI BaseOutputPinImpl_Active(struct strmbase_source *pin);
114 HRESULT WINAPI BaseOutputPinImpl_Inactive(struct strmbase_source *pin);
115 HRESULT WINAPI BaseOutputPinImpl_InitAllocator(struct strmbase_source *pin, IMemAllocator **allocator);
116 HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(struct strmbase_source *pin, IMemInputPin *peer, IMemAllocator **allocator);
117 HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
119 void strmbase_source_cleanup(struct strmbase_source *pin);
120 void strmbase_source_init(struct strmbase_source *pin, struct strmbase_filter *filter,
121 const WCHAR *name, const struct strmbase_source_ops *func_table);
123 void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter,
124 const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator);
125 void strmbase_sink_cleanup(struct strmbase_sink *pin);
127 struct strmbase_filter
129 IBaseFilter IBaseFilter_iface;
130 IUnknown IUnknown_inner;
131 IUnknown *outer_unk;
132 LONG refcount;
133 CRITICAL_SECTION csFilter;
135 FILTER_STATE state;
136 IReferenceClock *clock;
137 WCHAR name[128];
138 IFilterGraph *graph;
139 CLSID clsid;
140 LONG pin_version;
142 const struct strmbase_filter_ops *ops;
145 struct strmbase_filter_ops
147 struct strmbase_pin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index);
148 void (*filter_destroy)(struct strmbase_filter *iface);
149 HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out);
151 HRESULT (*filter_init_stream)(struct strmbase_filter *iface);
152 HRESULT (*filter_start_stream)(struct strmbase_filter *iface, REFERENCE_TIME time);
153 HRESULT (*filter_stop_stream)(struct strmbase_filter *iface);
154 HRESULT (*filter_cleanup_stream)(struct strmbase_filter *iface);
155 HRESULT (*filter_wait_state)(struct strmbase_filter *iface, DWORD timeout);
158 VOID WINAPI BaseFilterImpl_IncrementPinVersion(struct strmbase_filter *filter);
160 void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer,
161 const CLSID *clsid, const struct strmbase_filter_ops *func_table);
162 void strmbase_filter_cleanup(struct strmbase_filter *filter);
164 /* Source Seeking */
165 typedef HRESULT (WINAPI *SourceSeeking_ChangeRate)(IMediaSeeking *iface);
166 typedef HRESULT (WINAPI *SourceSeeking_ChangeStart)(IMediaSeeking *iface);
167 typedef HRESULT (WINAPI *SourceSeeking_ChangeStop)(IMediaSeeking *iface);
169 typedef struct SourceSeeking
171 IMediaSeeking IMediaSeeking_iface;
173 ULONG refCount;
174 SourceSeeking_ChangeStop fnChangeStop;
175 SourceSeeking_ChangeStart fnChangeStart;
176 SourceSeeking_ChangeRate fnChangeRate;
177 DWORD dwCapabilities;
178 double dRate;
179 LONGLONG llCurrent, llStop, llDuration;
180 GUID timeformat;
181 CRITICAL_SECTION cs;
182 } SourceSeeking;
184 HRESULT strmbase_seeking_init(SourceSeeking *seeking, const IMediaSeekingVtbl *vtbl,
185 SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
186 SourceSeeking_ChangeRate fnChangeRate);
187 void strmbase_seeking_cleanup(SourceSeeking *seeking);
189 HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
190 HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
191 HRESULT WINAPI SourceSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat);
192 HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat);
193 HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat);
194 HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
195 HRESULT WINAPI SourceSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
196 HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration);
197 HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop);
198 HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent);
199 HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat);
200 HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags);
201 HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop);
202 HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest);
203 HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
204 HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
205 HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
207 /* Output Queue */
208 typedef struct tagOutputQueue {
209 CRITICAL_SECTION csQueue;
211 struct strmbase_source *pInputPin;
213 HANDLE hThread;
214 HANDLE hProcessQueue;
216 LONG lBatchSize;
217 BOOL bBatchExact;
218 BOOL bTerminate;
219 BOOL bSendAnyway;
221 struct list SampleList;
223 const struct OutputQueueFuncTable* pFuncsTable;
224 } OutputQueue;
226 typedef DWORD (WINAPI *OutputQueue_ThreadProc)(OutputQueue *This);
228 typedef struct OutputQueueFuncTable
230 OutputQueue_ThreadProc pfnThreadProc;
231 } OutputQueueFuncTable;
233 HRESULT WINAPI OutputQueue_Construct( struct strmbase_source *pin, BOOL bAuto,
234 BOOL bQueue, LONG lBatchSize, BOOL bBatchExact, DWORD dwPriority,
235 const OutputQueueFuncTable* pFuncsTable, OutputQueue **ppOutputQueue );
236 HRESULT WINAPI OutputQueue_Destroy(OutputQueue *pOutputQueue);
237 HRESULT WINAPI OutputQueue_ReceiveMultiple(OutputQueue *pOutputQueue, IMediaSample **ppSamples, LONG nSamples, LONG *nSamplesProcessed);
238 HRESULT WINAPI OutputQueue_Receive(OutputQueue *pOutputQueue, IMediaSample *pSample);
239 VOID WINAPI OutputQueue_EOS(OutputQueue *pOutputQueue);
240 VOID WINAPI OutputQueue_SendAnyway(OutputQueue *pOutputQueue);
241 DWORD WINAPI OutputQueueImpl_ThreadProc(OutputQueue *pOutputQueue);
243 enum strmbase_type_id
245 IBasicAudio_tid,
246 IBasicVideo_tid,
247 IMediaControl_tid,
248 IMediaEvent_tid,
249 IMediaPosition_tid,
250 IVideoWindow_tid,
251 last_tid
254 HRESULT strmbase_get_typeinfo(enum strmbase_type_id tid, ITypeInfo **typeinfo);
256 struct strmbase_passthrough
258 ISeekingPassThru ISeekingPassThru_iface;
259 IMediaSeeking IMediaSeeking_iface;
260 IMediaPosition IMediaPosition_iface;
262 IUnknown *outer_unk;
263 IPin *pin;
264 BOOL renderer;
265 BOOL timevalid;
266 CRITICAL_SECTION time_cs;
267 REFERENCE_TIME time_earliest;
270 void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer);
271 void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough);
273 struct strmbase_renderer
275 struct strmbase_filter filter;
276 struct strmbase_passthrough passthrough;
278 struct strmbase_sink sink;
280 CRITICAL_SECTION csRenderLock;
281 /* Signaled when the filter has completed a state change. The filter waits
282 * for this event in IBaseFilter::GetState(). */
283 HANDLE state_event;
284 /* Signaled when the sample presentation time occurs. The streaming thread
285 * waits for this event in Receive() if applicable. */
286 HANDLE advise_event;
287 /* Signaled when a flush or state change occurs, i.e. anything that needs
288 * to immediately unblock the streaming thread. */
289 HANDLE flush_event;
290 REFERENCE_TIME stream_start;
292 IQualityControl *pQSink;
293 struct QualityControlImpl *qcimpl;
295 const struct strmbase_renderer_ops *pFuncsTable;
297 BOOL eos;
300 typedef HRESULT (WINAPI *BaseRenderer_CheckMediaType)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
301 typedef HRESULT (WINAPI *BaseRenderer_DoRenderSample)(struct strmbase_renderer *iface, IMediaSample *sample);
302 typedef HRESULT (WINAPI *BaseRenderer_ShouldDrawSampleNow)(struct strmbase_renderer *iface,
303 IMediaSample *sample, REFERENCE_TIME *start, REFERENCE_TIME *end);
304 typedef HRESULT (WINAPI *BaseRenderer_PrepareReceive)(struct strmbase_renderer *iface, IMediaSample *sample);
305 typedef HRESULT (WINAPI *BaseRenderer_EndOfStream)(struct strmbase_renderer *iface);
306 typedef HRESULT (WINAPI *BaseRenderer_BeginFlush) (struct strmbase_renderer *iface);
307 typedef HRESULT (WINAPI *BaseRenderer_EndFlush) (struct strmbase_renderer *iface);
308 typedef HRESULT (WINAPI *BaseRenderer_BreakConnect) (struct strmbase_renderer *iface);
310 struct strmbase_renderer_ops
312 BaseRenderer_CheckMediaType pfnCheckMediaType;
313 BaseRenderer_DoRenderSample pfnDoRenderSample;
314 void (*renderer_init_stream)(struct strmbase_renderer *iface);
315 void (*renderer_start_stream)(struct strmbase_renderer *iface);
316 void (*renderer_stop_stream)(struct strmbase_renderer *iface);
317 BaseRenderer_ShouldDrawSampleNow pfnShouldDrawSampleNow;
318 BaseRenderer_PrepareReceive pfnPrepareReceive;
319 HRESULT (*renderer_connect)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
320 BaseRenderer_BreakConnect pfnBreakConnect;
321 BaseRenderer_EndOfStream pfnEndOfStream;
322 BaseRenderer_EndFlush pfnEndFlush;
323 void (*renderer_destroy)(struct strmbase_renderer *iface);
324 HRESULT (*renderer_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
325 HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
328 HRESULT WINAPI BaseRendererImpl_Receive(struct strmbase_renderer *filter, IMediaSample *sample);
330 void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
331 const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops);
332 void strmbase_renderer_cleanup(struct strmbase_renderer *filter);