ReactOS  0.4.14-dev-593-g1793dcc
seeking.c File Reference
#include "dshow.h"
#include "wine/strmbase.h"
#include "uuids.h"
#include "wine/debug.h"
#include <assert.h>
Include dependency graph for seeking.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (strmbase)
 
static SourceSeekingimpl_from_IMediaSeeking (IMediaSeeking *iface)
 
HRESULT SourceSeeking_Init (SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtbl, SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart, SourceSeeking_ChangeRate fnChangeRate, PCRITICAL_SECTION crit_sect)
 
HRESULT WINAPI SourceSeekingImpl_GetCapabilities (IMediaSeeking *iface, DWORD *pCapabilities)
 
HRESULT WINAPI SourceSeekingImpl_CheckCapabilities (IMediaSeeking *iface, DWORD *pCapabilities)
 
HRESULT WINAPI SourceSeekingImpl_IsFormatSupported (IMediaSeeking *iface, const GUID *pFormat)
 
HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat (IMediaSeeking *iface, GUID *pFormat)
 
HRESULT WINAPI SourceSeekingImpl_GetTimeFormat (IMediaSeeking *iface, GUID *pFormat)
 
HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat (IMediaSeeking *iface, const GUID *pFormat)
 
HRESULT WINAPI SourceSeekingImpl_SetTimeFormat (IMediaSeeking *iface, const GUID *pFormat)
 
HRESULT WINAPI SourceSeekingImpl_GetDuration (IMediaSeeking *iface, LONGLONG *pDuration)
 
HRESULT WINAPI SourceSeekingImpl_GetStopPosition (IMediaSeeking *iface, LONGLONG *pStop)
 
HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition (IMediaSeeking *iface, LONGLONG *pCurrent)
 
HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat (IMediaSeeking *iface, LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat)
 
static LONGLONG Adjust (LONGLONG value, const LONGLONG *pModifier, DWORD dwFlags)
 
HRESULT WINAPI SourceSeekingImpl_SetPositions (IMediaSeeking *iface, LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)
 
HRESULT WINAPI SourceSeekingImpl_GetPositions (IMediaSeeking *iface, LONGLONG *pCurrent, LONGLONG *pStop)
 
HRESULT WINAPI SourceSeekingImpl_GetAvailable (IMediaSeeking *iface, LONGLONG *pEarliest, LONGLONG *pLatest)
 
HRESULT WINAPI SourceSeekingImpl_SetRate (IMediaSeeking *iface, double dRate)
 
HRESULT WINAPI SourceSeekingImpl_GetRate (IMediaSeeking *iface, double *dRate)
 
HRESULT WINAPI SourceSeekingImpl_GetPreroll (IMediaSeeking *iface, LONGLONG *pPreroll)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file seeking.c.

Function Documentation

◆ Adjust()

static LONGLONG Adjust ( LONGLONG  value,
const LONGLONG pModifier,
DWORD  dwFlags 
)
inlinestatic

Definition at line 201 of file seeking.c.

202 {
204  {
206  return value;
208  return *pModifier;
211  return value + *pModifier;
212  default:
213  assert(FALSE);
214  return 0;
215  }
216 }
#define assert(x)
Definition: debug.h:53
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLsizei const GLfloat * value
Definition: glext.h:6069

Referenced by AdjustPacket(), and SourceSeekingImpl_SetPositions().

◆ impl_from_IMediaSeeking()

static SourceSeeking* impl_from_IMediaSeeking ( IMediaSeeking iface)
inlinestatic

◆ SourceSeeking_Init()

HRESULT SourceSeeking_Init ( SourceSeeking pSeeking,
const IMediaSeekingVtbl *  Vtbl,
SourceSeeking_ChangeStop  fnChangeStop,
SourceSeeking_ChangeStart  fnChangeStart,
SourceSeeking_ChangeRate  fnChangeRate,
PCRITICAL_SECTION  crit_sect 
)

Definition at line 40 of file seeking.c.

41 {
42  assert(fnChangeStop && fnChangeStart && fnChangeRate);
43 
44  pSeeking->IMediaSeeking_iface.lpVtbl = Vtbl;
45  pSeeking->refCount = 1;
46  pSeeking->fnChangeRate = fnChangeRate;
47  pSeeking->fnChangeStop = fnChangeStop;
48  pSeeking->fnChangeStart = fnChangeStart;
54  pSeeking->llCurrent = 0;
55  pSeeking->llStop = ((ULONGLONG)0x80000000) << 32;
56  pSeeking->llDuration = pSeeking->llStop;
57  pSeeking->dRate = 1.0;
58  pSeeking->timeformat = TIME_FORMAT_MEDIA_TIME;
59  pSeeking->crst = crit_sect;
60  return S_OK;
61 }
SourceSeeking_ChangeStart fnChangeStart
Definition: strmbase.h:280
DWORD dwCapabilities
Definition: strmbase.h:282
LONGLONG llStop
Definition: strmbase.h:284
#define assert(x)
Definition: debug.h:53
IMediaSeeking IMediaSeeking_iface
Definition: strmbase.h:276
GUID timeformat
Definition: strmbase.h:285
SourceSeeking_ChangeStop fnChangeStop
Definition: strmbase.h:279
uint64_t ULONGLONG
Definition: typedefs.h:65
LONGLONG llDuration
Definition: strmbase.h:284
LONGLONG llCurrent
Definition: strmbase.h:284
#define S_OK
Definition: intsafe.h:59
double dRate
Definition: strmbase.h:283
SourceSeeking_ChangeRate fnChangeRate
Definition: strmbase.h:281
PCRITICAL_SECTION crst
Definition: strmbase.h:286
ULONG refCount
Definition: strmbase.h:278

Referenced by Parser_Create().

◆ SourceSeekingImpl_CheckCapabilities()

HRESULT WINAPI SourceSeekingImpl_CheckCapabilities ( IMediaSeeking iface,
DWORD pCapabilities 
)

Definition at line 74 of file seeking.c.

75 {
77  HRESULT hr;
78  DWORD dwCommonCaps;
79 
80  TRACE("(%p)\n", pCapabilities);
81 
82  if (!pCapabilities)
83  return E_POINTER;
84 
85  dwCommonCaps = *pCapabilities & This->dwCapabilities;
86 
87  if (!dwCommonCaps)
88  hr = E_FAIL;
89  else
90  hr = (*pCapabilities == dwCommonCaps) ? S_OK : S_FALSE;
91  *pCapabilities = dwCommonCaps;
92  return hr;
93 }
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
#define E_POINTER
Definition: winerror.h:2365

◆ SourceSeekingImpl_ConvertTimeFormat()

HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat ( IMediaSeeking iface,
LONGLONG pTarget,
const GUID pTargetFormat,
LONGLONG  Source,
const GUID pSourceFormat 
)

Definition at line 185 of file seeking.c.

186 {
188  if (!pTargetFormat)
189  pTargetFormat = &This->timeformat;
190  if (!pSourceFormat)
191  pSourceFormat = &This->timeformat;
192  if (IsEqualIID(pTargetFormat, &TIME_FORMAT_MEDIA_TIME) && IsEqualIID(pSourceFormat, &TIME_FORMAT_MEDIA_TIME))
193  {
194  *pTarget = Source;
195  return S_OK;
196  }
197  /* FIXME: clear pTarget? */
198  return E_INVALIDARG;
199 }
#define E_INVALIDARG
Definition: ddrawi.h:101
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ SourceSeekingImpl_GetAvailable()

HRESULT WINAPI SourceSeekingImpl_GetAvailable ( IMediaSeeking iface,
LONGLONG pEarliest,
LONGLONG pLatest 
)

Definition at line 268 of file seeking.c.

269 {
271 
272  TRACE("(%p, %p)\n", pEarliest, pLatest);
273 
274  EnterCriticalSection(This->crst);
275  *pEarliest = 0;
276  *pLatest = This->llDuration;
277  LeaveCriticalSection(This->crst);
278 
279  return S_OK;
280 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetCapabilities()

HRESULT WINAPI SourceSeekingImpl_GetCapabilities ( IMediaSeeking iface,
DWORD pCapabilities 
)

Definition at line 63 of file seeking.c.

64 {
66 
67  TRACE("(%p)\n", pCapabilities);
68 
69  *pCapabilities = This->dwCapabilities;
70 
71  return S_OK;
72 }
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59

◆ SourceSeekingImpl_GetCurrentPosition()

HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition ( IMediaSeeking iface,
LONGLONG pCurrent 
)

Definition at line 172 of file seeking.c.

173 {
175 
176  TRACE("(%p)\n", pCurrent);
177 
178  EnterCriticalSection(This->crst);
179  *pCurrent = This->llCurrent;
180  LeaveCriticalSection(This->crst);
181 
182  return S_OK;
183 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetDuration()

HRESULT WINAPI SourceSeekingImpl_GetDuration ( IMediaSeeking iface,
LONGLONG pDuration 
)

Definition at line 145 of file seeking.c.

146 {
148 
149  TRACE("(%p)\n", pDuration);
150 
151  EnterCriticalSection(This->crst);
152  *pDuration = This->llDuration;
153  LeaveCriticalSection(This->crst);
154 
155  return S_OK;
156 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetPositions()

HRESULT WINAPI SourceSeekingImpl_GetPositions ( IMediaSeeking iface,
LONGLONG pCurrent,
LONGLONG pStop 
)

Definition at line 254 of file seeking.c.

255 {
257 
258  TRACE("(%p, %p)\n", pCurrent, pStop);
259 
260  EnterCriticalSection(This->crst);
261  IMediaSeeking_GetCurrentPosition(iface, pCurrent);
262  IMediaSeeking_GetStopPosition(iface, pStop);
263  LeaveCriticalSection(This->crst);
264 
265  return S_OK;
266 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetPreroll()

HRESULT WINAPI SourceSeekingImpl_GetPreroll ( IMediaSeeking iface,
LONGLONG pPreroll 
)

Definition at line 319 of file seeking.c.

320 {
321  TRACE("(%p)\n", pPreroll);
322 
323  *pPreroll = 0;
324  return S_OK;
325 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ SourceSeekingImpl_GetRate()

HRESULT WINAPI SourceSeekingImpl_GetRate ( IMediaSeeking iface,
double dRate 
)

Definition at line 305 of file seeking.c.

306 {
308 
309  TRACE("(%p)\n", dRate);
310 
311  EnterCriticalSection(This->crst);
312  /* Forward? */
313  *dRate = This->dRate;
314  LeaveCriticalSection(This->crst);
315 
316  return S_OK;
317 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetStopPosition()

HRESULT WINAPI SourceSeekingImpl_GetStopPosition ( IMediaSeeking iface,
LONGLONG pStop 
)

Definition at line 158 of file seeking.c.

159 {
161 
162  TRACE("(%p)\n", pStop);
163 
164  EnterCriticalSection(This->crst);
165  *pStop = This->llStop;
166  LeaveCriticalSection(This->crst);
167 
168  return S_OK;
169 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_GetTimeFormat()

HRESULT WINAPI SourceSeekingImpl_GetTimeFormat ( IMediaSeeking iface,
GUID pFormat 
)

Definition at line 110 of file seeking.c.

111 {
113  TRACE("(%s)\n", debugstr_guid(pFormat));
114 
115  EnterCriticalSection(This->crst);
116  *pFormat = This->timeformat;
117  LeaveCriticalSection(This->crst);
118 
119  return S_OK;
120 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_IsFormatSupported()

HRESULT WINAPI SourceSeekingImpl_IsFormatSupported ( IMediaSeeking iface,
const GUID pFormat 
)

Definition at line 95 of file seeking.c.

96 {
97  TRACE("(%s)\n", debugstr_guid(pFormat));
98 
99  return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : S_FALSE);
100 }
#define S_FALSE
Definition: winerror.h:2357
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ SourceSeekingImpl_IsUsingTimeFormat()

HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat ( IMediaSeeking iface,
const GUID pFormat 
)

Definition at line 122 of file seeking.c.

123 {
125  HRESULT hr = S_OK;
126 
127  TRACE("(%s)\n", debugstr_guid(pFormat));
128 
129  EnterCriticalSection(This->crst);
130  if (!IsEqualIID(pFormat, &This->timeformat))
131  hr = S_FALSE;
132  LeaveCriticalSection(This->crst);
133 
134  return hr;
135 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define S_FALSE
Definition: winerror.h:2357
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ SourceSeekingImpl_QueryPreferredFormat()

HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat ( IMediaSeeking iface,
GUID pFormat 
)

Definition at line 102 of file seeking.c.

103 {
104  TRACE("(%s)\n", debugstr_guid(pFormat));
105 
106  *pFormat = TIME_FORMAT_MEDIA_TIME;
107  return S_OK;
108 }
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ SourceSeekingImpl_SetPositions()

HRESULT WINAPI SourceSeekingImpl_SetPositions ( IMediaSeeking iface,
LONGLONG pCurrent,
DWORD  dwCurrentFlags,
LONGLONG pStop,
DWORD  dwStopFlags 
)

Definition at line 218 of file seeking.c.

219 {
221  BOOL bChangeCurrent = FALSE, bChangeStop = FALSE;
222  LONGLONG llNewCurrent, llNewStop;
223 
224  TRACE("(%p, %x, %p, %x)\n", pCurrent, dwCurrentFlags, pStop, dwStopFlags);
225  EnterCriticalSection(This->crst);
226 
227  llNewCurrent = Adjust(This->llCurrent, pCurrent, dwCurrentFlags);
228  llNewStop = Adjust(This->llStop, pStop, dwStopFlags);
229 
230  if (pCurrent)
231  bChangeCurrent = TRUE;
232  if (llNewStop != This->llStop)
233  bChangeStop = TRUE;
234 
235  TRACE("Old: %u, New: %u\n", (DWORD)(This->llCurrent/10000000), (DWORD)(llNewCurrent/10000000));
236 
237  This->llCurrent = llNewCurrent;
238  This->llStop = llNewStop;
239 
240  if (pCurrent && (dwCurrentFlags & AM_SEEKING_ReturnTime))
241  *pCurrent = llNewCurrent;
242  if (pStop && (dwStopFlags & AM_SEEKING_ReturnTime))
243  *pStop = llNewStop;
244  LeaveCriticalSection(This->crst);
245 
246  if (bChangeCurrent)
247  This->fnChangeStart(iface);
248  if (bChangeStop)
249  This->fnChangeStop(iface);
250 
251  return S_OK;
252 }
#define TRUE
Definition: types.h:120
static LONGLONG Adjust(LONGLONG value, const LONGLONG *pModifier, DWORD dwFlags)
Definition: seeking.c:201
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
unsigned int BOOL
Definition: ntddk_ex.h:94
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_SetRate()

HRESULT WINAPI SourceSeekingImpl_SetRate ( IMediaSeeking iface,
double  dRate 
)

Definition at line 282 of file seeking.c.

283 {
285  BOOL bChangeRate = (dRate != This->dRate);
286  HRESULT hr = S_OK;
287 
288  TRACE("(%e)\n", dRate);
289 
290  if (dRate > 100 || dRate < .001)
291  {
292  FIXME("Excessive rate %e, ignoring\n", dRate);
294  }
295 
296  EnterCriticalSection(This->crst);
297  This->dRate = dRate;
298  if (bChangeRate)
299  hr = This->fnChangeRate(iface);
300  LeaveCriticalSection(This->crst);
301 
302  return hr;
303 }
#define VFW_E_UNSUPPORTED_AUDIO
Definition: vfwmsgs.h:112
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ SourceSeekingImpl_SetTimeFormat()

HRESULT WINAPI SourceSeekingImpl_SetTimeFormat ( IMediaSeeking iface,
const GUID pFormat 
)

Definition at line 137 of file seeking.c.

138 {
140  TRACE("%p %s\n", This, debugstr_guid(pFormat));
141  return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : E_INVALIDARG);
142 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
static SourceSeeking * impl_from_IMediaSeeking(IMediaSeeking *iface)
Definition: seeking.c:35
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( strmbase  )