2 * Filter Seeking and Control Interfaces
4 * Copyright 2003 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 /* FIXME: critical sections */
22 #include "quartz_private.h"
23 #include "control_private.h"
26 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
32 HRESULT
MediaSeekingImpl_Init(LPVOID pUserData
, CHANGEPROC fnChangeStop
, CHANGEPROC fnChangeStart
, CHANGEPROC fnChangeRate
, MediaSeekingImpl
* pSeeking
)
34 assert(fnChangeStop
&& fnChangeStart
&& fnChangeRate
);
36 pSeeking
->refCount
= 1;
37 pSeeking
->pUserData
= pUserData
;
38 pSeeking
->fnChangeRate
= fnChangeRate
;
39 pSeeking
->fnChangeStop
= fnChangeStop
;
40 pSeeking
->fnChangeStart
= fnChangeStart
;
41 pSeeking
->dwCapabilities
= AM_SEEKING_CanSeekForwards
|
42 AM_SEEKING_CanSeekBackwards
|
43 AM_SEEKING_CanSeekAbsolute
|
44 AM_SEEKING_CanGetStopPos
|
45 AM_SEEKING_CanGetDuration
;
46 pSeeking
->llStart
= 0;
47 pSeeking
->llStop
= ((ULONGLONG
)0x80000000) << 32;
48 pSeeking
->llDuration
= pSeeking
->llStop
- pSeeking
->llStart
;
49 pSeeking
->dRate
= 1.0;
55 HRESULT WINAPI
MediaSeekingImpl_GetCapabilities(IMediaSeeking
* iface
, DWORD
* pCapabilities
)
57 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
59 TRACE("(%p)\n", pCapabilities
);
61 *pCapabilities
= This
->dwCapabilities
;
66 HRESULT WINAPI
MediaSeekingImpl_CheckCapabilities(IMediaSeeking
* iface
, DWORD
* pCapabilities
)
68 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
72 TRACE("(%p)\n", pCapabilities
);
74 dwCommonCaps
= *pCapabilities
& This
->dwCapabilities
;
79 hr
= (*pCapabilities
== dwCommonCaps
) ? S_OK
: S_FALSE
;
80 *pCapabilities
= dwCommonCaps
;
85 HRESULT WINAPI
MediaSeekingImpl_IsFormatSupported(IMediaSeeking
* iface
, const GUID
* pFormat
)
87 TRACE("(%s)\n", qzdebugstr_guid(pFormat
));
89 return (IsEqualIID(pFormat
, &TIME_FORMAT_MEDIA_TIME
) ? S_OK
: S_FALSE
);
92 HRESULT WINAPI
MediaSeekingImpl_QueryPreferredFormat(IMediaSeeking
* iface
, GUID
* pFormat
)
94 TRACE("(%s)\n", qzdebugstr_guid(pFormat
));
96 *pFormat
= TIME_FORMAT_MEDIA_TIME
;
100 HRESULT WINAPI
MediaSeekingImpl_GetTimeFormat(IMediaSeeking
* iface
, GUID
* pFormat
)
102 TRACE("(%s)\n", qzdebugstr_guid(pFormat
));
104 *pFormat
= TIME_FORMAT_MEDIA_TIME
;
108 HRESULT WINAPI
MediaSeekingImpl_IsUsingTimeFormat(IMediaSeeking
* iface
, const GUID
* pFormat
)
110 TRACE("(%s)\n", qzdebugstr_guid(pFormat
));
112 return (IsEqualIID(pFormat
, &TIME_FORMAT_MEDIA_TIME
) ? S_OK
: S_FALSE
);
115 HRESULT WINAPI
MediaSeekingImpl_SetTimeFormat(IMediaSeeking
* iface
, const GUID
* pFormat
)
117 TRACE("(%s)\n", qzdebugstr_guid(pFormat
));
119 return (IsEqualIID(pFormat
, &TIME_FORMAT_MEDIA_TIME
) ? S_OK
: S_FALSE
);
122 HRESULT WINAPI
MediaSeekingImpl_GetDuration(IMediaSeeking
* iface
, LONGLONG
* pDuration
)
124 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
126 TRACE("(%p)\n", pDuration
);
128 *pDuration
= This
->llDuration
;
133 HRESULT WINAPI
MediaSeekingImpl_GetStopPosition(IMediaSeeking
* iface
, LONGLONG
* pStop
)
135 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
137 TRACE("(%p)\n", pStop
);
139 *pStop
= This
->llStop
;
144 HRESULT WINAPI
MediaSeekingImpl_GetCurrentPosition(IMediaSeeking
* iface
, LONGLONG
* pCurrent
)
146 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
148 TRACE("(%p)\n", pCurrent
);
150 *pCurrent
= This
->llStart
;
155 HRESULT WINAPI
MediaSeekingImpl_ConvertTimeFormat(IMediaSeeking
* iface
, LONGLONG
* pTarget
, const GUID
* pTargetFormat
, LONGLONG Source
, const GUID
* pSourceFormat
)
157 if (IsEqualIID(pTargetFormat
, &TIME_FORMAT_MEDIA_TIME
) && IsEqualIID(pSourceFormat
, &TIME_FORMAT_MEDIA_TIME
))
162 /* FIXME: clear pTarget? */
166 __inline LONGLONG
Adjust(LONGLONG value
, LONGLONG
* pModifier
, DWORD dwFlags
)
168 switch (dwFlags
& AM_SEEKING_PositioningBitsMask
)
170 case AM_SEEKING_NoPositioning
:
172 case AM_SEEKING_AbsolutePositioning
:
174 case AM_SEEKING_RelativePositioning
:
175 case AM_SEEKING_IncrementalPositioning
:
176 return value
+ *pModifier
;
183 HRESULT WINAPI
MediaSeekingImpl_SetPositions(IMediaSeeking
* iface
, LONGLONG
* pCurrent
, DWORD dwCurrentFlags
, LONGLONG
* pStop
, DWORD dwStopFlags
)
185 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
186 BOOL bChangeStart
= FALSE
, bChangeStop
= FALSE
;
187 LONGLONG llNewStart
, llNewStop
;
189 TRACE("(%p, %lx, %p, %lx)\n", pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
191 llNewStart
= Adjust(This
->llStart
, pCurrent
, dwCurrentFlags
);
192 llNewStop
= Adjust(This
->llStop
, pStop
, dwStopFlags
);
194 if (llNewStart
!= This
->llStart
)
196 if (llNewStop
!= This
->llStop
)
199 This
->llStart
= llNewStart
;
200 This
->llStop
= llNewStop
;
202 if (dwCurrentFlags
& AM_SEEKING_ReturnTime
)
203 *pCurrent
= llNewStart
;
204 if (dwStopFlags
& AM_SEEKING_ReturnTime
)
208 This
->fnChangeStart(This
->pUserData
);
210 This
->fnChangeStop(This
->pUserData
);
215 HRESULT WINAPI
MediaSeekingImpl_GetPositions(IMediaSeeking
* iface
, LONGLONG
* pCurrent
, LONGLONG
* pStop
)
217 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
219 TRACE("(%p, %p)\n", pCurrent
, pStop
);
221 *pCurrent
= This
->llStart
;
222 *pStop
= This
->llStop
;
227 HRESULT WINAPI
MediaSeekingImpl_GetAvailable(IMediaSeeking
* iface
, LONGLONG
* pEarliest
, LONGLONG
* pLatest
)
229 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
231 TRACE("(%p, %p)\n", pEarliest
, pLatest
);
234 *pLatest
= This
->llDuration
;
239 HRESULT WINAPI
MediaSeekingImpl_SetRate(IMediaSeeking
* iface
, double dRate
)
241 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
242 BOOL bChangeRate
= (dRate
!= This
->dRate
);
244 TRACE("(%e)\n", dRate
);
249 return This
->fnChangeRate(This
->pUserData
);
254 HRESULT WINAPI
MediaSeekingImpl_GetRate(IMediaSeeking
* iface
, double * dRate
)
256 MediaSeekingImpl
*This
= (MediaSeekingImpl
*)iface
;
258 TRACE("(%p)\n", dRate
);
260 *dRate
= This
->dRate
;
265 HRESULT WINAPI
MediaSeekingImpl_GetPreroll(IMediaSeeking
* iface
, LONGLONG
* pPreroll
)
267 TRACE("(%p)\n", pPreroll
);