Started implementing AVI splitter.
[wine.git] / dlls / quartz / seekpass.c
blob1c20f67cd042808b0f1d4a59efb577e053f73538
1 /*
2 * Implementation of CLSID_SeekingPassThru
4 * FIXME - not tested yet.
6 * hidenori@a2.ctktv.ne.jp
7 */
9 #include "config.h"
11 #include "windef.h"
12 #include "winbase.h"
13 #include "wingdi.h"
14 #include "winuser.h"
15 #include "winerror.h"
16 #include "strmif.h"
17 #include "control.h"
18 #include "uuids.h"
20 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(quartz);
23 #include "quartz_private.h"
24 #include "seekpass.h"
27 /***************************************************************************
29 * CSeekingPassThru::ISeekingPassThru
33 static HRESULT WINAPI
34 ISeekingPassThru_fnQueryInterface(ISeekingPassThru* iface,REFIID riid,void** ppobj)
36 CSeekingPassThru_THIS(iface,seekpass);
38 TRACE("(%p)->()\n",This);
40 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
43 static ULONG WINAPI
44 ISeekingPassThru_fnAddRef(ISeekingPassThru* iface)
46 CSeekingPassThru_THIS(iface,seekpass);
48 TRACE("(%p)->()\n",This);
50 return IUnknown_AddRef(This->unk.punkControl);
53 static ULONG WINAPI
54 ISeekingPassThru_fnRelease(ISeekingPassThru* iface)
56 CSeekingPassThru_THIS(iface,seekpass);
58 TRACE("(%p)->()\n",This);
60 return IUnknown_Release(This->unk.punkControl);
63 static HRESULT WINAPI
64 ISeekingPassThru_fnInit(ISeekingPassThru* iface,BOOL bRendering,IPin* pPin)
66 CSeekingPassThru_THIS(iface,seekpass);
68 FIXME("(%p)->(%d,%p) not tested!\n",This,bRendering,pPin);
70 if ( pPin == NULL )
71 return E_POINTER;
73 /* Why is 'bRendering' given as an argument?? */
74 EnterCriticalSection( &This->cs );
76 if ( This->passthru.pPin != NULL )
77 IPin_Release( This->passthru.pPin );
78 This->passthru.pPin = pPin; IPin_AddRef( pPin );
80 LeaveCriticalSection( &This->cs );
82 return NOERROR;
86 static ICOM_VTABLE(ISeekingPassThru) iseekingpassthru =
88 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
89 /* IUnknown fields */
90 ISeekingPassThru_fnQueryInterface,
91 ISeekingPassThru_fnAddRef,
92 ISeekingPassThru_fnRelease,
93 /* ISeekingPassThru fields */
94 ISeekingPassThru_fnInit,
97 static
98 HRESULT CSeekingPassThru_InitISeekingPassThru(CSeekingPassThru* This)
100 TRACE("(%p)\n",This);
101 ICOM_VTBL(&This->seekpass) = &iseekingpassthru;
102 This->passthru.punk = This->unk.punkControl;
103 This->passthru.pPin = NULL;
104 InitializeCriticalSection( &This->cs );
106 return NOERROR;
109 static
110 void CSeekingPassThru_UninitISeekingPassThru(CSeekingPassThru* This)
112 TRACE("(%p)\n",This);
113 if ( This->passthru.pPin != NULL )
115 IPin_Release( This->passthru.pPin );
116 This->passthru.pPin = NULL;
118 DeleteCriticalSection( &This->cs );
121 /***************************************************************************
123 * new/delete for CLSID_SeekingPassThru.
127 /* can I use offsetof safely? - FIXME? */
128 static QUARTZ_IFEntry IFEntries[] =
130 { &IID_ISeekingPassThru, offsetof(CSeekingPassThru,seekpass)-offsetof(CSeekingPassThru,unk) },
131 { &IID_IMediaPosition, offsetof(CSeekingPassThru,passthru.mpos)-offsetof(CSeekingPassThru,unk) },
132 { &IID_IMediaSeeking, offsetof(CSeekingPassThru,passthru.mseek)-offsetof(CSeekingPassThru,unk) },
136 static void QUARTZ_DestroySeekingPassThru(IUnknown* punk)
138 CSeekingPassThru_THIS(punk,unk);
140 CSeekingPassThru_UninitISeekingPassThru(This);
143 HRESULT QUARTZ_CreateSeekingPassThru(IUnknown* punkOuter,void** ppobj)
145 CSeekingPassThru* This;
146 HRESULT hr;
148 TRACE("(%p,%p)\n",punkOuter,ppobj);
150 This = (CSeekingPassThru*)QUARTZ_AllocObj( sizeof(CSeekingPassThru) );
151 if ( This == NULL )
152 return E_OUTOFMEMORY;
154 QUARTZ_IUnkInit( &This->unk, punkOuter );
155 hr = CSeekingPassThru_InitISeekingPassThru(This);
156 if ( FAILED(hr) )
158 QUARTZ_FreeObj( This );
159 return hr;
162 This->unk.pEntries = IFEntries;
163 This->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
164 This->unk.pOnFinalRelease = QUARTZ_DestroySeekingPassThru;
166 *ppobj = (void*)(&This->unk);
168 return S_OK;
174 /***************************************************************************
176 * CPassThruImpl Helper methods.
180 static
181 HRESULT CPassThruImpl_GetConnected( CPassThruImpl* pImpl, IPin** ppPin )
183 return IPin_ConnectedTo( pImpl->pPin, ppPin );
186 HRESULT CPassThruImpl_QueryPosPass(
187 CPassThruImpl* pImpl, IMediaPosition** ppPosition )
189 IPin* pPin;
190 HRESULT hr;
192 hr = CPassThruImpl_GetConnected( pImpl, &pPin );
193 if ( FAILED(hr) )
194 return hr;
195 hr = IPin_QueryInterface(pPin,&IID_IMediaPosition,(void**)ppPosition);
196 IPin_Release(pPin);
198 return hr;
201 HRESULT CPassThruImpl_QuerySeekPass(
202 CPassThruImpl* pImpl, IMediaSeeking** ppSeeking )
204 IPin* pPin;
205 HRESULT hr;
207 hr = CPassThruImpl_GetConnected( pImpl, &pPin );
208 if ( FAILED(hr) )
209 return hr;
210 hr = IPin_QueryInterface(pPin,&IID_IMediaSeeking,(void**)ppSeeking);
211 IPin_Release(pPin);
213 return hr;
216 /***************************************************************************
218 * An implementation for CPassThruImpl::IMediaPosition.
223 #define QUERYPOSPASS \
224 IMediaPosition* pPos = NULL; \
225 HRESULT hr; \
226 hr = CPassThruImpl_QueryPosPass( This, &pPos ); \
227 if ( FAILED(hr) ) return hr;
229 static HRESULT WINAPI
230 IMediaPosition_fnQueryInterface(IMediaPosition* iface,REFIID riid,void** ppobj)
232 CPassThruImpl_THIS(iface,mpos);
234 TRACE("(%p)->()\n",This);
236 return IUnknown_QueryInterface(This->punk,riid,ppobj);
239 static ULONG WINAPI
240 IMediaPosition_fnAddRef(IMediaPosition* iface)
242 CPassThruImpl_THIS(iface,mpos);
244 TRACE("(%p)->()\n",This);
246 return IUnknown_AddRef(This->punk);
249 static ULONG WINAPI
250 IMediaPosition_fnRelease(IMediaPosition* iface)
252 CPassThruImpl_THIS(iface,mpos);
254 TRACE("(%p)->()\n",This);
256 return IUnknown_Release(This->punk);
259 static HRESULT WINAPI
260 IMediaPosition_fnGetTypeInfoCount(IMediaPosition* iface,UINT* pcTypeInfo)
262 CPassThruImpl_THIS(iface,mpos);
264 FIXME("(%p)->() stub!\n",This);
266 return E_NOTIMPL;
269 static HRESULT WINAPI
270 IMediaPosition_fnGetTypeInfo(IMediaPosition* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
272 CPassThruImpl_THIS(iface,mpos);
274 FIXME("(%p)->() stub!\n",This);
276 return E_NOTIMPL;
279 static HRESULT WINAPI
280 IMediaPosition_fnGetIDsOfNames(IMediaPosition* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
282 CPassThruImpl_THIS(iface,mpos);
284 FIXME("(%p)->() stub!\n",This);
286 return E_NOTIMPL;
289 static HRESULT WINAPI
290 IMediaPosition_fnInvoke(IMediaPosition* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
292 CPassThruImpl_THIS(iface,mpos);
294 FIXME("(%p)->() stub!\n",This);
296 return E_NOTIMPL;
300 static HRESULT WINAPI
301 IMediaPosition_fnget_Duration(IMediaPosition* iface,REFTIME* prefTime)
303 CPassThruImpl_THIS(iface,mpos);
304 QUERYPOSPASS
306 TRACE("(%p)->()\n",This);
308 return IMediaPosition_get_Duration(pPos,prefTime);
311 static HRESULT WINAPI
312 IMediaPosition_fnput_CurrentPosition(IMediaPosition* iface,REFTIME refTime)
314 CPassThruImpl_THIS(iface,mpos);
315 QUERYPOSPASS
317 TRACE("(%p)->()\n",This);
319 return IMediaPosition_put_CurrentPosition(pPos,refTime);
322 static HRESULT WINAPI
323 IMediaPosition_fnget_CurrentPosition(IMediaPosition* iface,REFTIME* prefTime)
325 CPassThruImpl_THIS(iface,mpos);
326 QUERYPOSPASS
328 TRACE("(%p)->()\n",This);
330 return IMediaPosition_get_CurrentPosition(pPos,prefTime);
333 static HRESULT WINAPI
334 IMediaPosition_fnget_StopTime(IMediaPosition* iface,REFTIME* prefTime)
336 CPassThruImpl_THIS(iface,mpos);
337 QUERYPOSPASS
339 TRACE("(%p)->()\n",This);
341 return IMediaPosition_get_StopTime(pPos,prefTime);
344 static HRESULT WINAPI
345 IMediaPosition_fnput_StopTime(IMediaPosition* iface,REFTIME refTime)
347 CPassThruImpl_THIS(iface,mpos);
348 QUERYPOSPASS
350 TRACE("(%p)->()\n",This);
352 return IMediaPosition_put_StopTime(pPos,refTime);
355 static HRESULT WINAPI
356 IMediaPosition_fnget_PrerollTime(IMediaPosition* iface,REFTIME* prefTime)
358 CPassThruImpl_THIS(iface,mpos);
359 QUERYPOSPASS
361 TRACE("(%p)->()\n",This);
363 return IMediaPosition_get_PrerollTime(pPos,prefTime);
366 static HRESULT WINAPI
367 IMediaPosition_fnput_PrerollTime(IMediaPosition* iface,REFTIME refTime)
369 CPassThruImpl_THIS(iface,mpos);
370 QUERYPOSPASS
372 TRACE("(%p)->()\n",This);
374 return IMediaPosition_put_PrerollTime(pPos,refTime);
377 static HRESULT WINAPI
378 IMediaPosition_fnput_Rate(IMediaPosition* iface,double dblRate)
380 CPassThruImpl_THIS(iface,mpos);
381 QUERYPOSPASS
383 TRACE("(%p)->()\n",This);
385 return IMediaPosition_put_Rate(pPos,dblRate);
388 static HRESULT WINAPI
389 IMediaPosition_fnget_Rate(IMediaPosition* iface,double* pdblRate)
391 CPassThruImpl_THIS(iface,mpos);
392 QUERYPOSPASS
394 TRACE("(%p)->()\n",This);
396 return IMediaPosition_get_Rate(pPos,pdblRate);
399 static HRESULT WINAPI
400 IMediaPosition_fnCanSeekForward(IMediaPosition* iface,LONG* pCanSeek)
402 CPassThruImpl_THIS(iface,mpos);
403 QUERYPOSPASS
405 TRACE("(%p)->()\n",This);
407 return IMediaPosition_CanSeekForward(pPos,pCanSeek);
410 static HRESULT WINAPI
411 IMediaPosition_fnCanSeekBackward(IMediaPosition* iface,LONG* pCanSeek)
413 CPassThruImpl_THIS(iface,mpos);
414 QUERYPOSPASS
416 TRACE("(%p)->()\n",This);
418 return IMediaPosition_CanSeekBackward(pPos,pCanSeek);
422 static ICOM_VTABLE(IMediaPosition) impos =
424 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
425 /* IUnknown fields */
426 IMediaPosition_fnQueryInterface,
427 IMediaPosition_fnAddRef,
428 IMediaPosition_fnRelease,
429 /* IDispatch fields */
430 IMediaPosition_fnGetTypeInfoCount,
431 IMediaPosition_fnGetTypeInfo,
432 IMediaPosition_fnGetIDsOfNames,
433 IMediaPosition_fnInvoke,
434 /* IMediaPosition fields */
435 IMediaPosition_fnget_Duration,
436 IMediaPosition_fnput_CurrentPosition,
437 IMediaPosition_fnget_CurrentPosition,
438 IMediaPosition_fnget_StopTime,
439 IMediaPosition_fnput_StopTime,
440 IMediaPosition_fnget_PrerollTime,
441 IMediaPosition_fnput_PrerollTime,
442 IMediaPosition_fnput_Rate,
443 IMediaPosition_fnget_Rate,
444 IMediaPosition_fnCanSeekForward,
445 IMediaPosition_fnCanSeekBackward,
449 HRESULT CPassThruImpl_InitIMediaPosition( CPassThruImpl* pImpl )
451 TRACE("(%p)\n",pImpl);
452 ICOM_VTBL(&pImpl->mpos) = &impos;
454 return NOERROR;
457 void CPassThruImpl_UninitIMediaPosition( CPassThruImpl* pImpl )
459 TRACE("(%p)\n",pImpl);
462 #undef QUERYPOSPASS
465 /***************************************************************************
467 * An implementation for CPassThruImpl::IMediaSeeking.
471 #define QUERYSEEKPASS \
472 IMediaSeeking* pSeek = NULL; \
473 HRESULT hr; \
474 hr = CPassThruImpl_QuerySeekPass( This, &pSeek ); \
475 if ( FAILED(hr) ) return hr;
478 static HRESULT WINAPI
479 IMediaSeeking_fnQueryInterface(IMediaSeeking* iface,REFIID riid,void** ppobj)
481 CPassThruImpl_THIS(iface,mseek);
483 TRACE("(%p)->()\n",This);
485 return IUnknown_QueryInterface(This->punk,riid,ppobj);
488 static ULONG WINAPI
489 IMediaSeeking_fnAddRef(IMediaSeeking* iface)
491 CPassThruImpl_THIS(iface,mseek);
493 TRACE("(%p)->()\n",This);
495 return IUnknown_AddRef(This->punk);
498 static ULONG WINAPI
499 IMediaSeeking_fnRelease(IMediaSeeking* iface)
501 CPassThruImpl_THIS(iface,mseek);
503 TRACE("(%p)->()\n",This);
505 return IUnknown_Release(This->punk);
509 static HRESULT WINAPI
510 IMediaSeeking_fnGetCapabilities(IMediaSeeking* iface,DWORD* pdwCaps)
512 CPassThruImpl_THIS(iface,mseek);
513 QUERYSEEKPASS
515 TRACE("(%p)->()\n",This);
517 return IMediaSeeking_GetCapabilities(pSeek,pdwCaps);
520 static HRESULT WINAPI
521 IMediaSeeking_fnCheckCapabilities(IMediaSeeking* iface,DWORD* pdwCaps)
523 CPassThruImpl_THIS(iface,mseek);
524 QUERYSEEKPASS
526 TRACE("(%p)->()\n",This);
528 return IMediaSeeking_CheckCapabilities(pSeek,pdwCaps);
531 static HRESULT WINAPI
532 IMediaSeeking_fnIsFormatSupported(IMediaSeeking* iface,const GUID* pidFormat)
534 CPassThruImpl_THIS(iface,mseek);
535 QUERYSEEKPASS
537 TRACE("(%p)->()\n",This);
539 return IMediaSeeking_IsFormatSupported(pSeek,pidFormat);
542 static HRESULT WINAPI
543 IMediaSeeking_fnQueryPreferredFormat(IMediaSeeking* iface,GUID* pidFormat)
545 CPassThruImpl_THIS(iface,mseek);
546 QUERYSEEKPASS
548 TRACE("(%p)->()\n",This);
550 return IMediaSeeking_QueryPreferredFormat(pSeek,pidFormat);
553 static HRESULT WINAPI
554 IMediaSeeking_fnGetTimeFormat(IMediaSeeking* iface,GUID* pidFormat)
556 CPassThruImpl_THIS(iface,mseek);
557 QUERYSEEKPASS
559 TRACE("(%p)->()\n",This);
561 return IMediaSeeking_GetTimeFormat(pSeek,pidFormat);
564 static HRESULT WINAPI
565 IMediaSeeking_fnIsUsingTimeFormat(IMediaSeeking* iface,const GUID* pidFormat)
567 CPassThruImpl_THIS(iface,mseek);
568 QUERYSEEKPASS
570 TRACE("(%p)->()\n",This);
572 return IMediaSeeking_IsUsingTimeFormat(pSeek,pidFormat);
575 static HRESULT WINAPI
576 IMediaSeeking_fnSetTimeFormat(IMediaSeeking* iface,const GUID* pidFormat)
578 CPassThruImpl_THIS(iface,mseek);
579 QUERYSEEKPASS
581 TRACE("(%p)->()\n",This);
583 return IMediaSeeking_SetTimeFormat(pSeek,pidFormat);
586 static HRESULT WINAPI
587 IMediaSeeking_fnGetDuration(IMediaSeeking* iface,LONGLONG* pllDuration)
589 CPassThruImpl_THIS(iface,mseek);
590 QUERYSEEKPASS
592 TRACE("(%p)->()\n",This);
594 return IMediaSeeking_GetDuration(pSeek,pllDuration);
597 static HRESULT WINAPI
598 IMediaSeeking_fnGetStopPosition(IMediaSeeking* iface,LONGLONG* pllPos)
600 CPassThruImpl_THIS(iface,mseek);
601 QUERYSEEKPASS
603 TRACE("(%p)->()\n",This);
605 return IMediaSeeking_GetStopPosition(pSeek,pllPos);
608 static HRESULT WINAPI
609 IMediaSeeking_fnGetCurrentPosition(IMediaSeeking* iface,LONGLONG* pllPos)
611 CPassThruImpl_THIS(iface,mseek);
612 QUERYSEEKPASS
614 TRACE("(%p)->()\n",This);
616 return IMediaSeeking_GetCurrentPosition(pSeek,pllPos);
619 static HRESULT WINAPI
620 IMediaSeeking_fnConvertTimeFormat(IMediaSeeking* iface,LONGLONG* pllOut,const GUID* pidFmtOut,LONGLONG llIn,const GUID* pidFmtIn)
622 CPassThruImpl_THIS(iface,mseek);
623 QUERYSEEKPASS
625 TRACE("(%p)->()\n",This);
627 return IMediaSeeking_ConvertTimeFormat(pSeek,pllOut,pidFmtOut,llIn,pidFmtIn);
630 static HRESULT WINAPI
631 IMediaSeeking_fnSetPositions(IMediaSeeking* iface,LONGLONG* pllCur,DWORD dwCurFlags,LONGLONG* pllStop,DWORD dwStopFlags)
633 CPassThruImpl_THIS(iface,mseek);
634 QUERYSEEKPASS
636 TRACE("(%p)->()\n",This);
638 return IMediaSeeking_SetPositions(pSeek,pllCur,dwCurFlags,pllStop,dwStopFlags);
641 static HRESULT WINAPI
642 IMediaSeeking_fnGetPositions(IMediaSeeking* iface,LONGLONG* pllCur,LONGLONG* pllStop)
644 CPassThruImpl_THIS(iface,mseek);
645 QUERYSEEKPASS
647 TRACE("(%p)->()\n",This);
649 return IMediaSeeking_GetPositions(pSeek,pllCur,pllStop);
652 static HRESULT WINAPI
653 IMediaSeeking_fnGetAvailable(IMediaSeeking* iface,LONGLONG* pllFirst,LONGLONG* pllLast)
655 CPassThruImpl_THIS(iface,mseek);
656 QUERYSEEKPASS
658 TRACE("(%p)->()\n",This);
660 return IMediaSeeking_GetAvailable(pSeek,pllFirst,pllLast);
663 static HRESULT WINAPI
664 IMediaSeeking_fnSetRate(IMediaSeeking* iface,double dblRate)
666 CPassThruImpl_THIS(iface,mseek);
667 QUERYSEEKPASS
669 TRACE("(%p)->()\n",This);
671 return IMediaSeeking_SetRate(pSeek,dblRate);
674 static HRESULT WINAPI
675 IMediaSeeking_fnGetRate(IMediaSeeking* iface,double* pdblRate)
677 CPassThruImpl_THIS(iface,mseek);
678 QUERYSEEKPASS
680 TRACE("(%p)->()\n",This);
682 return IMediaSeeking_GetRate(pSeek,pdblRate);
685 static HRESULT WINAPI
686 IMediaSeeking_fnGetPreroll(IMediaSeeking* iface,LONGLONG* pllPreroll)
688 CPassThruImpl_THIS(iface,mseek);
689 QUERYSEEKPASS
691 TRACE("(%p)->()\n",This);
693 return IMediaSeeking_GetPreroll(pSeek,pllPreroll);
699 static ICOM_VTABLE(IMediaSeeking) imseek =
701 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
702 /* IUnknown fields */
703 IMediaSeeking_fnQueryInterface,
704 IMediaSeeking_fnAddRef,
705 IMediaSeeking_fnRelease,
706 /* IMediaSeeking fields */
707 IMediaSeeking_fnGetCapabilities,
708 IMediaSeeking_fnCheckCapabilities,
709 IMediaSeeking_fnIsFormatSupported,
710 IMediaSeeking_fnQueryPreferredFormat,
711 IMediaSeeking_fnGetTimeFormat,
712 IMediaSeeking_fnIsUsingTimeFormat,
713 IMediaSeeking_fnSetTimeFormat,
714 IMediaSeeking_fnGetDuration,
715 IMediaSeeking_fnGetStopPosition,
716 IMediaSeeking_fnGetCurrentPosition,
717 IMediaSeeking_fnConvertTimeFormat,
718 IMediaSeeking_fnSetPositions,
719 IMediaSeeking_fnGetPositions,
720 IMediaSeeking_fnGetAvailable,
721 IMediaSeeking_fnSetRate,
722 IMediaSeeking_fnGetRate,
723 IMediaSeeking_fnGetPreroll,
728 HRESULT CPassThruImpl_InitIMediaSeeking( CPassThruImpl* pImpl )
730 TRACE("(%p)\n",pImpl);
731 ICOM_VTBL(&pImpl->mseek) = &imseek;
733 return NOERROR;
736 void CPassThruImpl_UninitIMediaSeeking( CPassThruImpl* pImpl )
738 TRACE("(%p)\n",pImpl);
741 #undef QUERYSEEKPASS