Implement ResetDC and PHYSICALOFFSET[X|Y] devcaps.
[wine] / dlls / quartz / impos.c
1 /*
2  * Implementation of IMediaPosition for FilterGraph.
3  *
4  * FIXME - stub.
5  *
6  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winerror.h"
30 #include "strmif.h"
31 #include "control.h"
32 #include "uuids.h"
33
34 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
36
37 #include "quartz_private.h"
38 #include "fgraph.h"
39
40
41 static HRESULT WINAPI
42 IMediaPosition_fnQueryInterface(IMediaPosition* iface,REFIID riid,void** ppobj)
43 {
44         CFilterGraph_THIS(iface,mediaposition);
45
46         TRACE("(%p)->()\n",This);
47
48         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
49 }
50
51 static ULONG WINAPI
52 IMediaPosition_fnAddRef(IMediaPosition* iface)
53 {
54         CFilterGraph_THIS(iface,mediaposition);
55
56         TRACE("(%p)->()\n",This);
57
58         return IUnknown_AddRef(This->unk.punkControl);
59 }
60
61 static ULONG WINAPI
62 IMediaPosition_fnRelease(IMediaPosition* iface)
63 {
64         CFilterGraph_THIS(iface,mediaposition);
65
66         TRACE("(%p)->()\n",This);
67
68         return IUnknown_Release(This->unk.punkControl);
69 }
70
71 static HRESULT WINAPI
72 IMediaPosition_fnGetTypeInfoCount(IMediaPosition* iface,UINT* pcTypeInfo)
73 {
74         CFilterGraph_THIS(iface,mediaposition);
75
76         TRACE("(%p)->()\n",This);
77
78         return IDispatch_GetTypeInfoCount(
79                 CFilterGraph_IDispatch(This),pcTypeInfo);
80 }
81
82 static HRESULT WINAPI
83 IMediaPosition_fnGetTypeInfo(IMediaPosition* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
84 {
85         CFilterGraph_THIS(iface,mediaposition);
86
87         TRACE("(%p)->()\n",This);
88
89         return IDispatch_GetTypeInfo(
90                 CFilterGraph_IDispatch(This),iTypeInfo,lcid,ppobj);
91 }
92
93 static HRESULT WINAPI
94 IMediaPosition_fnGetIDsOfNames(IMediaPosition* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
95 {
96         CFilterGraph_THIS(iface,mediaposition);
97
98         TRACE("(%p)->()\n",This);
99
100         return IDispatch_GetIDsOfNames(
101                 CFilterGraph_IDispatch(This),riid,ppwszName,cNames,lcid,pDispId);
102 }
103
104 static HRESULT WINAPI
105 IMediaPosition_fnInvoke(IMediaPosition* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
106 {
107         CFilterGraph_THIS(iface,mediaposition);
108
109         TRACE("(%p)->()\n",This);
110
111         return IDispatch_Invoke(
112                 CFilterGraph_IDispatch(This),
113                 DispId,riid,lcid,wFlags,pDispParams,pVarRes,pExcepInfo,puArgErr);
114 }
115
116
117 static HRESULT WINAPI
118 IMediaPosition_fnget_Duration(IMediaPosition* iface,REFTIME* prefTime)
119 {
120         CFilterGraph_THIS(iface,mediaposition);
121         HRESULT hr = E_NOTIMPL;
122         HRESULT hrFilter;
123         DWORD   n;
124
125         TRACE("(%p)->(%p)\n",This,prefTime);
126
127         EnterCriticalSection( &This->m_csFilters );
128
129         for ( n = 0; n < This->m_cActiveFilters; n++ )
130         {
131                 if ( This->m_pActiveFilters[n].pPosition != NULL )
132                 {
133                         hrFilter = IMediaPosition_get_Duration( This->m_pActiveFilters[n].pPosition, prefTime );
134                         if ( hr == E_NOTIMPL )
135                         {
136                                 hr = hrFilter;
137                         }
138                         else
139                         if ( hrFilter != E_NOTIMPL )
140                         {
141                                 if ( SUCCEEDED(hr) )
142                                         hr = hrFilter;
143                         }
144                 }
145         }
146
147         LeaveCriticalSection( &This->m_csFilters );
148
149         return hr;
150 }
151
152 static HRESULT WINAPI
153 IMediaPosition_fnput_CurrentPosition(IMediaPosition* iface,REFTIME refTime)
154 {
155         CFilterGraph_THIS(iface,mediaposition);
156         HRESULT hr = E_NOTIMPL;
157         HRESULT hrFilter;
158         DWORD   n;
159
160         TRACE("(%p)->()\n",This);
161
162         EnterCriticalSection( &This->m_csFilters );
163
164         for ( n = 0; n < This->m_cActiveFilters; n++ )
165         {
166                 if ( This->m_pActiveFilters[n].pPosition != NULL )
167                 {
168                         hrFilter = IMediaPosition_put_CurrentPosition( This->m_pActiveFilters[n].pPosition, refTime );
169                         if ( hr == E_NOTIMPL )
170                         {
171                                 hr = hrFilter;
172                         }
173                         else
174                         if ( hrFilter != E_NOTIMPL )
175                         {
176                                 if ( SUCCEEDED(hr) )
177                                         hr = hrFilter;
178                         }
179                 }
180         }
181
182         LeaveCriticalSection( &This->m_csFilters );
183
184         return hr;
185 }
186
187 static HRESULT WINAPI
188 IMediaPosition_fnget_CurrentPosition(IMediaPosition* iface,REFTIME* prefTime)
189 {
190         CFilterGraph_THIS(iface,mediaposition);
191         HRESULT hr = E_NOTIMPL;
192         HRESULT hrFilter;
193         DWORD   n;
194
195         TRACE("(%p)->()\n",This);
196
197         EnterCriticalSection( &This->m_csFilters );
198
199         for ( n = 0; n < This->m_cActiveFilters; n++ )
200         {
201                 if ( This->m_pActiveFilters[n].pPosition != NULL )
202                 {
203                         hrFilter = IMediaPosition_get_CurrentPosition( This->m_pActiveFilters[n].pPosition, prefTime );
204                         if ( hr == E_NOTIMPL )
205                         {
206                                 hr = hrFilter;
207                         }
208                         else
209                         if ( hrFilter != E_NOTIMPL )
210                         {
211                                 if ( SUCCEEDED(hr) )
212                                         hr = hrFilter;
213                         }
214                 }
215         }
216
217         LeaveCriticalSection( &This->m_csFilters );
218
219         return hr;
220 }
221
222 static HRESULT WINAPI
223 IMediaPosition_fnget_StopTime(IMediaPosition* iface,REFTIME* prefTime)
224 {
225         CFilterGraph_THIS(iface,mediaposition);
226         HRESULT hr = E_NOTIMPL;
227         HRESULT hrFilter;
228         DWORD   n;
229
230         TRACE("(%p)->()\n",This);
231
232         EnterCriticalSection( &This->m_csFilters );
233
234         for ( n = 0; n < This->m_cActiveFilters; n++ )
235         {
236                 if ( This->m_pActiveFilters[n].pPosition != NULL )
237                 {
238                         hrFilter = IMediaPosition_get_StopTime( This->m_pActiveFilters[n].pPosition, prefTime );
239                         if ( hr == E_NOTIMPL )
240                         {
241                                 hr = hrFilter;
242                         }
243                         else
244                         if ( hrFilter != E_NOTIMPL )
245                         {
246                                 if ( SUCCEEDED(hr) )
247                                         hr = hrFilter;
248                         }
249                 }
250         }
251
252         LeaveCriticalSection( &This->m_csFilters );
253
254         return hr;
255 }
256
257 static HRESULT WINAPI
258 IMediaPosition_fnput_StopTime(IMediaPosition* iface,REFTIME refTime)
259 {
260         CFilterGraph_THIS(iface,mediaposition);
261         HRESULT hr = E_NOTIMPL;
262         HRESULT hrFilter;
263         DWORD   n;
264
265         TRACE("(%p)->()\n",This);
266
267         EnterCriticalSection( &This->m_csFilters );
268
269         for ( n = 0; n < This->m_cActiveFilters; n++ )
270         {
271                 if ( This->m_pActiveFilters[n].pPosition != NULL )
272                 {
273                         hrFilter = IMediaPosition_put_StopTime( This->m_pActiveFilters[n].pPosition, refTime );
274                         if ( hr == E_NOTIMPL )
275                         {
276                                 hr = hrFilter;
277                         }
278                         else
279                         if ( hrFilter != E_NOTIMPL )
280                         {
281                                 if ( SUCCEEDED(hr) )
282                                         hr = hrFilter;
283                         }
284                 }
285         }
286
287         LeaveCriticalSection( &This->m_csFilters );
288
289         return hr;
290 }
291
292 static HRESULT WINAPI
293 IMediaPosition_fnget_PrerollTime(IMediaPosition* iface,REFTIME* prefTime)
294 {
295         CFilterGraph_THIS(iface,mediaposition);
296         HRESULT hr = E_NOTIMPL;
297         HRESULT hrFilter;
298         DWORD   n;
299
300         TRACE("(%p)->()\n",This);
301
302         EnterCriticalSection( &This->m_csFilters );
303
304         for ( n = 0; n < This->m_cActiveFilters; n++ )
305         {
306                 if ( This->m_pActiveFilters[n].pPosition != NULL )
307                 {
308                         hrFilter = IMediaPosition_get_PrerollTime( This->m_pActiveFilters[n].pPosition, prefTime );
309                         if ( hr == E_NOTIMPL )
310                         {
311                                 hr = hrFilter;
312                         }
313                         else
314                         if ( hrFilter != E_NOTIMPL )
315                         {
316                                 if ( SUCCEEDED(hr) )
317                                         hr = hrFilter;
318                         }
319                 }
320         }
321
322         LeaveCriticalSection( &This->m_csFilters );
323
324         return hr;
325 }
326
327 static HRESULT WINAPI
328 IMediaPosition_fnput_PrerollTime(IMediaPosition* iface,REFTIME refTime)
329 {
330         CFilterGraph_THIS(iface,mediaposition);
331         HRESULT hr = E_NOTIMPL;
332         HRESULT hrFilter;
333         DWORD   n;
334
335         TRACE("(%p)->()\n",This);
336
337         EnterCriticalSection( &This->m_csFilters );
338
339         for ( n = 0; n < This->m_cActiveFilters; n++ )
340         {
341                 if ( This->m_pActiveFilters[n].pPosition != NULL )
342                 {
343                         hrFilter = IMediaPosition_put_PrerollTime( This->m_pActiveFilters[n].pPosition, refTime );
344                         if ( hr == E_NOTIMPL )
345                         {
346                                 hr = hrFilter;
347                         }
348                         else
349                         if ( hrFilter != E_NOTIMPL )
350                         {
351                                 if ( SUCCEEDED(hr) )
352                                         hr = hrFilter;
353                         }
354                 }
355         }
356
357         LeaveCriticalSection( &This->m_csFilters );
358
359         return hr;
360 }
361
362 static HRESULT WINAPI
363 IMediaPosition_fnput_Rate(IMediaPosition* iface,double dblRate)
364 {
365         CFilterGraph_THIS(iface,mediaposition);
366         HRESULT hr = E_NOTIMPL;
367         HRESULT hrFilter;
368         DWORD   n;
369
370         TRACE("(%p)->()\n",This);
371
372         EnterCriticalSection( &This->m_csFilters );
373
374         for ( n = 0; n < This->m_cActiveFilters; n++ )
375         {
376                 if ( This->m_pActiveFilters[n].pPosition != NULL )
377                 {
378                         hrFilter = IMediaPosition_put_Rate( This->m_pActiveFilters[n].pPosition, dblRate );
379                         if ( hr == E_NOTIMPL )
380                         {
381                                 hr = hrFilter;
382                         }
383                         else
384                         if ( hrFilter != E_NOTIMPL )
385                         {
386                                 if ( SUCCEEDED(hr) )
387                                         hr = hrFilter;
388                         }
389                 }
390         }
391
392         LeaveCriticalSection( &This->m_csFilters );
393
394         return hr;
395 }
396
397 static HRESULT WINAPI
398 IMediaPosition_fnget_Rate(IMediaPosition* iface,double* pdblRate)
399 {
400         CFilterGraph_THIS(iface,mediaposition);
401         HRESULT hr = E_NOTIMPL;
402         HRESULT hrFilter;
403         DWORD   n;
404
405         TRACE("(%p)->()\n",This);
406
407         EnterCriticalSection( &This->m_csFilters );
408
409         for ( n = 0; n < This->m_cActiveFilters; n++ )
410         {
411                 if ( This->m_pActiveFilters[n].pPosition != NULL )
412                 {
413                         hrFilter = IMediaPosition_get_Rate( This->m_pActiveFilters[n].pPosition, pdblRate );
414                         if ( hr == E_NOTIMPL )
415                         {
416                                 hr = hrFilter;
417                         }
418                         else
419                         if ( hrFilter != E_NOTIMPL )
420                         {
421                                 if ( SUCCEEDED(hr) )
422                                         hr = hrFilter;
423                         }
424                 }
425         }
426
427         LeaveCriticalSection( &This->m_csFilters );
428
429         return hr;
430 }
431
432 static HRESULT WINAPI
433 IMediaPosition_fnCanSeekForward(IMediaPosition* iface,LONG* pCanSeek)
434 {
435         CFilterGraph_THIS(iface,mediaposition);
436         HRESULT hr = E_NOTIMPL;
437         HRESULT hrFilter;
438         DWORD   n;
439
440         TRACE("(%p)->()\n",This);
441
442         EnterCriticalSection( &This->m_csFilters );
443
444         for ( n = 0; n < This->m_cActiveFilters; n++ )
445         {
446                 if ( This->m_pActiveFilters[n].pPosition != NULL )
447                 {
448                         hrFilter = IMediaPosition_CanSeekForward( This->m_pActiveFilters[n].pPosition, pCanSeek );
449                         if ( hr == E_NOTIMPL )
450                         {
451                                 hr = hrFilter;
452                         }
453                         else
454                         if ( hrFilter != E_NOTIMPL )
455                         {
456                                 if ( SUCCEEDED(hr) )
457                                         hr = hrFilter;
458                         }
459                 }
460         }
461
462         LeaveCriticalSection( &This->m_csFilters );
463
464         return hr;
465 }
466
467 static HRESULT WINAPI
468 IMediaPosition_fnCanSeekBackward(IMediaPosition* iface,LONG* pCanSeek)
469 {
470         CFilterGraph_THIS(iface,mediaposition);
471         HRESULT hr = E_NOTIMPL;
472         HRESULT hrFilter;
473         DWORD   n;
474
475         TRACE("(%p)->()\n",This);
476
477         EnterCriticalSection( &This->m_csFilters );
478
479         for ( n = 0; n < This->m_cActiveFilters; n++ )
480         {
481                 if ( This->m_pActiveFilters[n].pPosition != NULL )
482                 {
483                         hrFilter = IMediaPosition_CanSeekBackward( This->m_pActiveFilters[n].pPosition, pCanSeek );
484                         if ( hr == E_NOTIMPL )
485                         {
486                                 hr = hrFilter;
487                         }
488                         else
489                         if ( hrFilter != E_NOTIMPL )
490                         {
491                                 if ( SUCCEEDED(hr) )
492                                         hr = hrFilter;
493                         }
494                 }
495         }
496
497         LeaveCriticalSection( &This->m_csFilters );
498
499         return hr;
500 }
501
502
503 static ICOM_VTABLE(IMediaPosition) imediaposition =
504 {
505         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
506         /* IUnknown fields */
507         IMediaPosition_fnQueryInterface,
508         IMediaPosition_fnAddRef,
509         IMediaPosition_fnRelease,
510         /* IDispatch fields */
511         IMediaPosition_fnGetTypeInfoCount,
512         IMediaPosition_fnGetTypeInfo,
513         IMediaPosition_fnGetIDsOfNames,
514         IMediaPosition_fnInvoke,
515         /* IMediaPosition fields */
516         IMediaPosition_fnget_Duration,
517         IMediaPosition_fnput_CurrentPosition,
518         IMediaPosition_fnget_CurrentPosition,
519         IMediaPosition_fnget_StopTime,
520         IMediaPosition_fnput_StopTime,
521         IMediaPosition_fnget_PrerollTime,
522         IMediaPosition_fnput_PrerollTime,
523         IMediaPosition_fnput_Rate,
524         IMediaPosition_fnget_Rate,
525         IMediaPosition_fnCanSeekForward,
526         IMediaPosition_fnCanSeekBackward,
527 };
528
529
530 HRESULT CFilterGraph_InitIMediaPosition( CFilterGraph* pfg )
531 {
532         TRACE("(%p)\n",pfg);
533         ICOM_VTBL(&pfg->mediaposition) = &imediaposition;
534
535         return NOERROR;
536 }
537
538 void CFilterGraph_UninitIMediaPosition( CFilterGraph* pfg )
539 {
540         TRACE("(%p)\n",pfg);
541 }