wineps: Change initial printer font to DEVICE_DEFAULT_FONT.
[wine.git] / include / wine / strmbase.h
blob1b4cc3f7657f3052862884a16b79cbfc942c25d2
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"
24 HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE * pDest, const AM_MEDIA_TYPE *pSrc);
25 void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType);
26 AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc);
27 void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
29 void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt);
31 /* Pin functions */
33 struct strmbase_pin
35 IPin IPin_iface;
36 struct strmbase_filter *filter;
37 PIN_DIRECTION dir;
38 WCHAR name[128];
39 WCHAR id[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_DecideAllocator(struct strmbase_source *pin, IMemInputPin *peer, IMemAllocator **allocator);
110 HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(struct strmbase_source *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
112 void strmbase_source_cleanup(struct strmbase_source *pin);
113 void strmbase_source_init(struct strmbase_source *pin, struct strmbase_filter *filter,
114 const WCHAR *name, const struct strmbase_source_ops *func_table);
116 void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter,
117 const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator);
118 void strmbase_sink_cleanup(struct strmbase_sink *pin);
120 struct strmbase_filter
122 IBaseFilter IBaseFilter_iface;
123 IUnknown IUnknown_inner;
124 IUnknown *outer_unk;
125 LONG refcount;
126 CRITICAL_SECTION filter_cs;
127 CRITICAL_SECTION stream_cs;
129 FILTER_STATE state;
130 IReferenceClock *clock;
131 WCHAR name[128];
132 IFilterGraph *graph;
133 CLSID clsid;
134 LONG pin_version;
136 const struct strmbase_filter_ops *ops;
139 struct strmbase_filter_ops
141 struct strmbase_pin *(*filter_get_pin)(struct strmbase_filter *iface, unsigned int index);
142 void (*filter_destroy)(struct strmbase_filter *iface);
143 HRESULT (*filter_query_interface)(struct strmbase_filter *iface, REFIID iid, void **out);
145 HRESULT (*filter_init_stream)(struct strmbase_filter *iface);
146 HRESULT (*filter_start_stream)(struct strmbase_filter *iface, REFERENCE_TIME time);
147 HRESULT (*filter_stop_stream)(struct strmbase_filter *iface);
148 HRESULT (*filter_cleanup_stream)(struct strmbase_filter *iface);
149 HRESULT (*filter_wait_state)(struct strmbase_filter *iface, DWORD timeout);
152 VOID WINAPI BaseFilterImpl_IncrementPinVersion(struct strmbase_filter *filter);
154 void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer,
155 const CLSID *clsid, const struct strmbase_filter_ops *func_table);
156 void strmbase_filter_cleanup(struct strmbase_filter *filter);
158 /* Source Seeking */
159 typedef HRESULT (WINAPI *SourceSeeking_ChangeRate)(IMediaSeeking *iface);
160 typedef HRESULT (WINAPI *SourceSeeking_ChangeStart)(IMediaSeeking *iface);
161 typedef HRESULT (WINAPI *SourceSeeking_ChangeStop)(IMediaSeeking *iface);
163 typedef struct SourceSeeking
165 IMediaSeeking IMediaSeeking_iface;
167 ULONG refCount;
168 SourceSeeking_ChangeStop fnChangeStop;
169 SourceSeeking_ChangeStart fnChangeStart;
170 SourceSeeking_ChangeRate fnChangeRate;
171 DWORD dwCapabilities;
172 double dRate;
173 LONGLONG llCurrent, llStop, llDuration;
174 GUID timeformat;
175 CRITICAL_SECTION cs;
176 } SourceSeeking;
178 HRESULT strmbase_seeking_init(SourceSeeking *seeking, const IMediaSeekingVtbl *vtbl,
179 SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart,
180 SourceSeeking_ChangeRate fnChangeRate);
181 void strmbase_seeking_cleanup(SourceSeeking *seeking);
183 HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
184 HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
185 HRESULT WINAPI SourceSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat);
186 HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat);
187 HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat);
188 HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
189 HRESULT WINAPI SourceSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
190 HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration);
191 HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop);
192 HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent);
193 HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat);
194 HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags);
195 HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop);
196 HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest);
197 HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
198 HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
199 HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
201 enum strmbase_type_id
203 IBasicAudio_tid,
204 IBasicVideo_tid,
205 IMediaControl_tid,
206 IMediaEvent_tid,
207 IMediaPosition_tid,
208 IVideoWindow_tid,
209 last_tid
212 HRESULT strmbase_get_typeinfo(enum strmbase_type_id tid, ITypeInfo **typeinfo);
213 void strmbase_release_typelibs(void);
215 struct strmbase_passthrough
217 ISeekingPassThru ISeekingPassThru_iface;
218 IMediaSeeking IMediaSeeking_iface;
219 IMediaPosition IMediaPosition_iface;
221 IUnknown *outer_unk;
222 IPin *pin;
223 BOOL renderer;
224 BOOL timevalid;
225 CRITICAL_SECTION time_cs;
226 REFERENCE_TIME time_earliest;
229 void strmbase_passthrough_init(struct strmbase_passthrough *passthrough, IUnknown *outer);
230 void strmbase_passthrough_cleanup(struct strmbase_passthrough *passthrough);
232 void strmbase_passthrough_eos(struct strmbase_passthrough *passthrough);
233 void strmbase_passthrough_invalidate_time(struct strmbase_passthrough *passthrough);
234 void strmbase_passthrough_update_time(struct strmbase_passthrough *passthrough, REFERENCE_TIME time);
236 struct strmbase_renderer
238 struct strmbase_filter filter;
239 struct strmbase_passthrough passthrough;
240 IQualityControl IQualityControl_iface;
242 struct strmbase_sink sink;
244 /* Signaled when the filter has completed a state change. The filter waits
245 * for this event in IBaseFilter::GetState(). */
246 HANDLE state_event;
247 /* Signaled when the sample presentation time occurs. The streaming thread
248 * waits for this event in Receive() if applicable. */
249 HANDLE advise_event;
250 /* Signaled when the filter is running. The streaming thread waits for this
251 * event in Receive() while paused. */
252 HANDLE run_event;
253 /* Signaled when a flush or state change occurs, i.e. anything that needs
254 * to immediately unblock the streaming thread. */
255 HANDLE flush_event;
256 REFERENCE_TIME stream_start;
258 IMediaSample *current_sample;
260 IQualityControl *qc_sink;
261 REFERENCE_TIME last_left, avg_duration, avg_pt;
262 double avg_rate;
264 const struct strmbase_renderer_ops *ops;
266 BOOL eos;
269 struct strmbase_renderer_ops
271 HRESULT (*renderer_query_accept)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
272 HRESULT (*renderer_render)(struct strmbase_renderer *iface, IMediaSample *sample);
273 void (*renderer_init_stream)(struct strmbase_renderer *iface);
274 void (*renderer_start_stream)(struct strmbase_renderer *iface);
275 void (*renderer_stop_stream)(struct strmbase_renderer *iface);
276 HRESULT (*renderer_connect)(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt);
277 void (*renderer_disconnect)(struct strmbase_renderer *iface);
278 void (*renderer_destroy)(struct strmbase_renderer *iface);
279 HRESULT (*renderer_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
280 HRESULT (*renderer_pin_query_interface)(struct strmbase_renderer *iface, REFIID iid, void **out);
283 void strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
284 const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops);
285 void strmbase_renderer_cleanup(struct strmbase_renderer *filter);