strmbase: Move mediaSeeking to strmbase SourceSeeking.
diff --git a/dlls/quartz/avisplit.c b/dlls/quartz/avisplit.c
index ffc0f27..fadca7d 100644
--- a/dlls/quartz/avisplit.c
+++ b/dlls/quartz/avisplit.c
@@ -101,6 +101,11 @@
DWORD stream;
};
+static inline AVISplitterImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
+{
+ return (AVISplitterImpl *)((char*)iface - FIELD_OFFSET(AVISplitterImpl, Parser.sourceSeeking.lpVtbl));
+}
+
/* The threading stuff cries for an explanation
*
* PullPin starts processing and calls AVISplitter_first_request
@@ -970,16 +975,16 @@
frames *= stream->streamheader.dwScale;
/* Keep accuracy as high as possible for duration */
- This->Parser.mediaSeeking.llDuration = frames * 10000000;
- This->Parser.mediaSeeking.llDuration /= stream->streamheader.dwRate;
- This->Parser.mediaSeeking.llStop = This->Parser.mediaSeeking.llDuration;
- This->Parser.mediaSeeking.llCurrent = 0;
+ This->Parser.sourceSeeking.llDuration = frames * 10000000;
+ This->Parser.sourceSeeking.llDuration /= stream->streamheader.dwRate;
+ This->Parser.sourceSeeking.llStop = This->Parser.sourceSeeking.llDuration;
+ This->Parser.sourceSeeking.llCurrent = 0;
frames /= stream->streamheader.dwRate;
TRACE("Duration: %d days, %d hours, %d minutes and %d.%03u seconds\n", (DWORD)(frames / 86400),
(DWORD)((frames % 86400) / 3600), (DWORD)((frames % 3600) / 60), (DWORD)(frames % 60),
- (DWORD)(This->Parser.mediaSeeking.llDuration/10000) % 1000);
+ (DWORD)(This->Parser.sourceSeeking.llDuration/10000) % 1000);
}
return S_OK;
@@ -1252,15 +1257,15 @@
return ref;
}
-static HRESULT AVISplitter_seek(IBaseFilter *iface)
+static HRESULT WINAPI AVISplitter_seek(IMediaSeeking *iface)
{
- AVISplitterImpl *This = (AVISplitterImpl *)iface;
+ AVISplitterImpl *This = impl_from_IMediaSeeking(iface);
PullPin *pPin = This->Parser.pInputPin;
LONGLONG newpos, endpos;
DWORD x;
- newpos = This->Parser.mediaSeeking.llCurrent;
- endpos = This->Parser.mediaSeeking.llDuration;
+ newpos = This->Parser.sourceSeeking.llCurrent;
+ endpos = This->Parser.sourceSeeking.llDuration;
if (newpos > endpos)
{
diff --git a/dlls/quartz/control.c b/dlls/quartz/control.c
index b1485a4..9ff4c83 100644
--- a/dlls/quartz/control.c
+++ b/dlls/quartz/control.c
@@ -224,288 +224,6 @@
return S_OK;
}
-HRESULT MediaSeekingImpl_Init(IBaseFilter *pUserData, CHANGEPROC fnChangeStop, CHANGEPROC fnChangeCurrent, CHANGEPROC fnChangeRate, MediaSeekingImpl * pSeeking, PCRITICAL_SECTION crit_sect)
-{
- assert(fnChangeStop && fnChangeCurrent && fnChangeRate);
-
- pSeeking->refCount = 1;
- pSeeking->pUserData = pUserData;
- pSeeking->fnChangeRate = fnChangeRate;
- pSeeking->fnChangeStop = fnChangeStop;
- pSeeking->fnChangeCurrent = fnChangeCurrent;
- pSeeking->dwCapabilities = AM_SEEKING_CanSeekForwards |
- AM_SEEKING_CanSeekBackwards |
- AM_SEEKING_CanSeekAbsolute |
- AM_SEEKING_CanGetStopPos |
- AM_SEEKING_CanGetDuration;
- pSeeking->llCurrent = 0;
- pSeeking->llStop = ((ULONGLONG)0x80000000) << 32;
- pSeeking->llDuration = pSeeking->llStop;
- pSeeking->dRate = 1.0;
- pSeeking->timeformat = TIME_FORMAT_MEDIA_TIME;
- pSeeking->crst = crit_sect;
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p)\n", pCapabilities);
-
- *pCapabilities = This->dwCapabilities;
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- HRESULT hr;
- DWORD dwCommonCaps;
-
- TRACE("(%p)\n", pCapabilities);
-
- if (!pCapabilities)
- return E_POINTER;
-
- dwCommonCaps = *pCapabilities & This->dwCapabilities;
-
- if (!dwCommonCaps)
- hr = E_FAIL;
- else
- hr = (*pCapabilities == dwCommonCaps) ? S_OK : S_FALSE;
- *pCapabilities = dwCommonCaps;
- return hr;
-}
-
-HRESULT WINAPI MediaSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat)
-{
- TRACE("(%s)\n", qzdebugstr_guid(pFormat));
-
- return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : S_FALSE);
-}
-
-HRESULT WINAPI MediaSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat)
-{
- TRACE("(%s)\n", qzdebugstr_guid(pFormat));
-
- *pFormat = TIME_FORMAT_MEDIA_TIME;
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- TRACE("(%s)\n", qzdebugstr_guid(pFormat));
-
- EnterCriticalSection(This->crst);
- *pFormat = This->timeformat;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- HRESULT hr = S_OK;
-
- TRACE("(%s)\n", qzdebugstr_guid(pFormat));
-
- EnterCriticalSection(This->crst);
- if (!IsEqualIID(pFormat, &This->timeformat))
- hr = S_FALSE;
- LeaveCriticalSection(This->crst);
-
- return hr;
-}
-
-HRESULT WINAPI MediaSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- TRACE("%p %s\n", This, qzdebugstr_guid(pFormat));
- return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : E_INVALIDARG);
-}
-
-
-HRESULT WINAPI MediaSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p)\n", pDuration);
-
- EnterCriticalSection(This->crst);
- *pDuration = This->llDuration;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p)\n", pStop);
-
- EnterCriticalSection(This->crst);
- *pStop = This->llStop;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-/* FIXME: Make use of the info the filter should expose */
-HRESULT WINAPI MediaSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p)\n", pCurrent);
-
- EnterCriticalSection(This->crst);
- *pCurrent = This->llCurrent;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat)
-{
- if (IsEqualIID(pTargetFormat, &TIME_FORMAT_MEDIA_TIME) && IsEqualIID(pSourceFormat, &TIME_FORMAT_MEDIA_TIME))
- {
- *pTarget = Source;
- return S_OK;
- }
- /* FIXME: clear pTarget? */
- return E_INVALIDARG;
-}
-
-static inline LONGLONG Adjust(LONGLONG value, const LONGLONG * pModifier, DWORD dwFlags)
-{
- switch (dwFlags & AM_SEEKING_PositioningBitsMask)
- {
- case AM_SEEKING_NoPositioning:
- return value;
- case AM_SEEKING_AbsolutePositioning:
- return *pModifier;
- case AM_SEEKING_RelativePositioning:
- case AM_SEEKING_IncrementalPositioning:
- return value + *pModifier;
- default:
- assert(FALSE);
- return 0;
- }
-}
-
-HRESULT WINAPI MediaSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- BOOL bChangeCurrent = FALSE, bChangeStop = FALSE;
- LONGLONG llNewCurrent, llNewStop;
-
- TRACE("(%p, %x, %p, %x)\n", pCurrent, dwCurrentFlags, pStop, dwStopFlags);
- EnterCriticalSection(This->crst);
-
- llNewCurrent = Adjust(This->llCurrent, pCurrent, dwCurrentFlags);
- llNewStop = Adjust(This->llStop, pStop, dwStopFlags);
-
- if (pCurrent)
- bChangeCurrent = TRUE;
- if (llNewStop != This->llStop)
- bChangeStop = TRUE;
-
- TRACE("Old: %u, New: %u\n", (DWORD)(This->llCurrent/10000000), (DWORD)(llNewCurrent/10000000));
-
- This->llCurrent = llNewCurrent;
- This->llStop = llNewStop;
-
- if (pCurrent && (dwCurrentFlags & AM_SEEKING_ReturnTime))
- *pCurrent = llNewCurrent;
- if (pStop && (dwStopFlags & AM_SEEKING_ReturnTime))
- *pStop = llNewStop;
- LeaveCriticalSection(This->crst);
-
- if (bChangeCurrent)
- This->fnChangeCurrent(This->pUserData);
- if (bChangeStop)
- This->fnChangeStop(This->pUserData);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p, %p)\n", pCurrent, pStop);
-
- EnterCriticalSection(This->crst);
- IMediaSeeking_GetCurrentPosition(iface, pCurrent);
- IMediaSeeking_GetStopPosition(iface, pStop);
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p, %p)\n", pEarliest, pLatest);
-
- EnterCriticalSection(This->crst);
- *pEarliest = 0;
- *pLatest = This->llDuration;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_SetRate(IMediaSeeking * iface, double dRate)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
- BOOL bChangeRate = (dRate != This->dRate);
- HRESULT hr = S_OK;
-
- TRACE("(%e)\n", dRate);
-
- if (dRate > 100 || dRate < .001)
- {
- FIXME("Excessive rate %e, ignoring\n", dRate);
- return VFW_E_UNSUPPORTED_AUDIO;
- }
-
- EnterCriticalSection(This->crst);
- This->dRate = dRate;
- if (bChangeRate)
- hr = This->fnChangeRate(This->pUserData);
- LeaveCriticalSection(This->crst);
-
- return hr;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate)
-{
- MediaSeekingImpl *This = (MediaSeekingImpl *)iface;
-
- TRACE("(%p)\n", dRate);
-
- EnterCriticalSection(This->crst);
- /* Forward? */
- *dRate = This->dRate;
- LeaveCriticalSection(This->crst);
-
- return S_OK;
-}
-
-HRESULT WINAPI MediaSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll)
-{
- TRACE("(%p)\n", pPreroll);
-
- *pPreroll = 0;
- return S_OK;
-}
-
static HRESULT WINAPI MediaSeekingPassThru_QueryInterface(IMediaSeeking *iface, REFIID riid, LPVOID *ppvObj)
{
ICOM_THIS_MULTI(PassThruImpl, IMediaSeeking_vtbl, iface);
diff --git a/dlls/quartz/control_private.h b/dlls/quartz/control_private.h
index a3ca7c7..016a675 100644
--- a/dlls/quartz/control_private.h
+++ b/dlls/quartz/control_private.h
@@ -21,44 +21,6 @@
#ifndef QUARTZ_CONTROL_H
#define QUARTZ_CONTROL_H
-typedef HRESULT (* CHANGEPROC)(IBaseFilter *pUserData);
-
-typedef struct MediaSeekingImpl
-{
- const IMediaSeekingVtbl * lpVtbl;
-
- ULONG refCount;
- IBaseFilter *pUserData;
- CHANGEPROC fnChangeStop;
- CHANGEPROC fnChangeCurrent;
- CHANGEPROC fnChangeRate;
- DWORD dwCapabilities;
- double dRate;
- LONGLONG llCurrent, llStop, llDuration;
- GUID timeformat;
- PCRITICAL_SECTION crst;
-} MediaSeekingImpl;
-
-HRESULT MediaSeekingImpl_Init(IBaseFilter *pUserData, CHANGEPROC fnChangeStop, CHANGEPROC fnChangeCurrent, CHANGEPROC fnChangeRate, MediaSeekingImpl * pSeeking, PCRITICAL_SECTION crit_sect);
-
-HRESULT WINAPI MediaSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
-HRESULT WINAPI MediaSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities);
-HRESULT WINAPI MediaSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat);
-HRESULT WINAPI MediaSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat);
-HRESULT WINAPI MediaSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat);
-HRESULT WINAPI MediaSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
-HRESULT WINAPI MediaSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat);
-HRESULT WINAPI MediaSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration);
-HRESULT WINAPI MediaSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop);
-HRESULT WINAPI MediaSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent);
-HRESULT WINAPI MediaSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat);
-HRESULT WINAPI MediaSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags);
-HRESULT WINAPI MediaSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop);
-HRESULT WINAPI MediaSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest);
-HRESULT WINAPI MediaSeekingImpl_SetRate(IMediaSeeking * iface, double dRate);
-HRESULT WINAPI MediaSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate);
-HRESULT WINAPI MediaSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll);
-
void MediaSeekingPassThru_RegisterMediaTime(IUnknown *iface, REFERENCE_TIME start);
void MediaSeekingPassThru_ResetMediaTime(IUnknown *iface);
void MediaSeekingPassThru_EOS(IUnknown *iface);
diff --git a/dlls/quartz/mpegsplit.c b/dlls/quartz/mpegsplit.c
index 0cffb19..8321131 100644
--- a/dlls/quartz/mpegsplit.c
+++ b/dlls/quartz/mpegsplit.c
@@ -77,6 +77,11 @@
struct seek_entry *seektable;
} MPEGSplitterImpl;
+static inline MPEGSplitterImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
+{
+ return (MPEGSplitterImpl *)((char*)iface - FIELD_OFFSET(MPEGSplitterImpl, Parser.sourceSeeking.lpVtbl));
+}
+
static int MPEGSplitter_head_check(const BYTE *header)
{
/* If this is a possible start code, check for a system or video header */
@@ -280,7 +285,7 @@
}
}
- if (BYTES_FROM_MEDIATIME(tStop) >= This->EndOfFile || This->position >= This->Parser.mediaSeeking.llStop)
+ if (BYTES_FROM_MEDIATIME(tStop) >= This->EndOfFile || This->position >= This->Parser.sourceSeeking.llStop)
{
unsigned int i;
@@ -587,9 +592,9 @@
TRACE("Parsing took %u ms\n", GetTickCount() - ticks);
This->duration = duration;
- This->Parser.mediaSeeking.llCurrent = 0;
- This->Parser.mediaSeeking.llDuration = duration;
- This->Parser.mediaSeeking.llStop = duration;
+ This->Parser.sourceSeeking.llCurrent = 0;
+ This->Parser.sourceSeeking.llDuration = duration;
+ This->Parser.sourceSeeking.llStop = duration;
break;
}
case MPEG_VIDEO_HEADER:
@@ -618,15 +623,15 @@
return S_OK;
}
-static HRESULT MPEGSplitter_seek(IBaseFilter *iface)
+static HRESULT WINAPI MPEGSplitter_seek(IMediaSeeking *iface)
{
- MPEGSplitterImpl *This = (MPEGSplitterImpl*)iface;
+ MPEGSplitterImpl *This = impl_from_IMediaSeeking(iface);
PullPin *pPin = This->Parser.pInputPin;
LONGLONG newpos, timepos, bytepos;
HRESULT hr = S_OK;
BYTE header[4];
- newpos = This->Parser.mediaSeeking.llCurrent;
+ newpos = This->Parser.sourceSeeking.llCurrent;
if (newpos > This->duration)
{
diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c
index 5d95f60..efa68f6 100644
--- a/dlls/quartz/parser.c
+++ b/dlls/quartz/parser.c
@@ -20,7 +20,6 @@
*/
#include "quartz_private.h"
-#include "control_private.h"
#include "pin.h"
#include "vfwmsgs.h"
@@ -41,13 +40,13 @@
static const IPinVtbl Parser_OutputPin_Vtbl;
static const IPinVtbl Parser_InputPin_Vtbl;
-static HRESULT Parser_ChangeCurrent(IBaseFilter *iface);
-static HRESULT Parser_ChangeStop(IBaseFilter *iface);
-static HRESULT Parser_ChangeRate(IBaseFilter *iface);
+static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface);
+static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface);
+static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface);
static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
{
- return (ParserImpl *)((char*)iface - FIELD_OFFSET(ParserImpl, mediaSeeking.lpVtbl));
+ return (ParserImpl *)((char*)iface - FIELD_OFFSET(ParserImpl, sourceSeeking.lpVtbl));
}
/* FIXME: WRONG */
@@ -72,7 +71,7 @@
return This->cStreams;
}
-HRESULT Parser_Create(ParserImpl* pParser, const IBaseFilterVtbl *Parser_Vtbl, const CLSID* pClsid, PFN_PROCESS_SAMPLE fnProcessSample, PFN_QUERY_ACCEPT fnQueryAccept, PFN_PRE_CONNECT fnPreConnect, PFN_CLEANUP fnCleanup, PFN_DISCONNECT fnDisconnect, REQUESTPROC fnRequest, STOPPROCESSPROC fnDone, CHANGEPROC stop, CHANGEPROC current, CHANGEPROC rate)
+HRESULT Parser_Create(ParserImpl* pParser, const IBaseFilterVtbl *Parser_Vtbl, const CLSID* pClsid, PFN_PROCESS_SAMPLE fnProcessSample, PFN_QUERY_ACCEPT fnQueryAccept, PFN_PRE_CONNECT fnPreConnect, PFN_CLEANUP fnCleanup, PFN_DISCONNECT fnDisconnect, REQUESTPROC fnRequest, STOPPROCESSPROC fnDone, SourceSeeking_ChangeStop stop, SourceSeeking_ChangeStart start, SourceSeeking_ChangeRate rate)
{
HRESULT hr;
PIN_INFO piInput;
@@ -90,8 +89,8 @@
piInput.pFilter = (IBaseFilter *)pParser;
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
- if (!current)
- current = Parser_ChangeCurrent;
+ if (!start)
+ start = Parser_ChangeStart;
if (!stop)
stop = Parser_ChangeStop;
@@ -99,8 +98,7 @@
if (!rate)
rate = Parser_ChangeRate;
- MediaSeekingImpl_Init((IBaseFilter*)pParser, stop, current, rate, &pParser->mediaSeeking, &pParser->filter.csFilter);
- pParser->mediaSeeking.lpVtbl = &Parser_Seeking_Vtbl;
+ SourceSeeking_Init(&pParser->sourceSeeking, &Parser_Seeking_Vtbl, stop, start, rate, &pParser->filter.csFilter);
hr = PullPin_Construct(&Parser_InputPin_Vtbl, &piInput, fnProcessSample, (LPVOID)pParser, fnQueryAccept, fnCleanup, fnRequest, fnDone, &pParser->filter.csFilter, (IPin **)&pParser->pInputPin);
@@ -466,19 +464,19 @@
return S_OK;
}
-static HRESULT Parser_ChangeCurrent(IBaseFilter *iface)
+static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface)
{
- FIXME("(%p) filter hasn't implemented current position change!\n", iface);
+ FIXME("(%p) filter hasn't implemented start position change!\n", iface);
return S_OK;
}
-static HRESULT Parser_ChangeStop(IBaseFilter *iface)
+static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface)
{
FIXME("(%p) filter hasn't implemented stop position change!\n", iface);
return S_OK;
}
-static HRESULT Parser_ChangeRate(IBaseFilter *iface)
+static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface)
{
FIXME("(%p) filter hasn't implemented rate change!\n", iface);
return S_OK;
@@ -511,23 +509,23 @@
Parser_Seeking_QueryInterface,
Parser_Seeking_AddRef,
Parser_Seeking_Release,
- MediaSeekingImpl_GetCapabilities,
- MediaSeekingImpl_CheckCapabilities,
- MediaSeekingImpl_IsFormatSupported,
- MediaSeekingImpl_QueryPreferredFormat,
- MediaSeekingImpl_GetTimeFormat,
- MediaSeekingImpl_IsUsingTimeFormat,
- MediaSeekingImpl_SetTimeFormat,
- MediaSeekingImpl_GetDuration,
- MediaSeekingImpl_GetStopPosition,
- MediaSeekingImpl_GetCurrentPosition,
- MediaSeekingImpl_ConvertTimeFormat,
- MediaSeekingImpl_SetPositions,
- MediaSeekingImpl_GetPositions,
- MediaSeekingImpl_GetAvailable,
- MediaSeekingImpl_SetRate,
- MediaSeekingImpl_GetRate,
- MediaSeekingImpl_GetPreroll
+ SourceSeekingImpl_GetCapabilities,
+ SourceSeekingImpl_CheckCapabilities,
+ SourceSeekingImpl_IsFormatSupported,
+ SourceSeekingImpl_QueryPreferredFormat,
+ SourceSeekingImpl_GetTimeFormat,
+ SourceSeekingImpl_IsUsingTimeFormat,
+ SourceSeekingImpl_SetTimeFormat,
+ SourceSeekingImpl_GetDuration,
+ SourceSeekingImpl_GetStopPosition,
+ SourceSeekingImpl_GetCurrentPosition,
+ SourceSeekingImpl_ConvertTimeFormat,
+ SourceSeekingImpl_SetPositions,
+ SourceSeekingImpl_GetPositions,
+ SourceSeekingImpl_GetAvailable,
+ SourceSeekingImpl_SetRate,
+ SourceSeekingImpl_GetRate,
+ SourceSeekingImpl_GetPreroll
};
static HRESULT WINAPI Parser_OutputPin_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
diff --git a/dlls/quartz/parser.h b/dlls/quartz/parser.h
index a88b2ad..3103c19 100644
--- a/dlls/quartz/parser.h
+++ b/dlls/quartz/parser.h
@@ -36,7 +36,7 @@
PullPin * pInputPin;
IPin ** ppPins;
ULONG cStreams;
- MediaSeekingImpl mediaSeeking;
+ SourceSeeking sourceSeeking;
};
typedef struct Parser_OutputPin
@@ -50,7 +50,7 @@
extern HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt);
extern HRESULT Parser_Create(ParserImpl*, const IBaseFilterVtbl *, const CLSID*, PFN_PROCESS_SAMPLE, PFN_QUERY_ACCEPT, PFN_PRE_CONNECT,
- PFN_CLEANUP, PFN_DISCONNECT, REQUESTPROC, STOPPROCESSPROC, CHANGEPROC stop, CHANGEPROC current, CHANGEPROC rate);
+ PFN_CLEANUP, PFN_DISCONNECT, REQUESTPROC, STOPPROCESSPROC, SourceSeeking_ChangeStop stop, SourceSeeking_ChangeStart start, SourceSeeking_ChangeRate rate);
/* Override the _Release function and call this when releasing */
extern void Parser_Destroy(ParserImpl *This);
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c
index 7975e4d..86e2607 100644
--- a/dlls/quartz/videorenderer.c
+++ b/dlls/quartz/videorenderer.c
@@ -82,7 +82,6 @@
BOOL bUnkOuterValid;
BOOL bAggregatable;
REFERENCE_TIME rtLastStop;
- MediaSeekingImpl mediaSeeking;
LONG WindowStyle;
/* During pause we can hold a single sample, for use in GetCurrentImage */
diff --git a/dlls/quartz/waveparser.c b/dlls/quartz/waveparser.c
index 952aad9..0ac6384 100644
--- a/dlls/quartz/waveparser.c
+++ b/dlls/quartz/waveparser.c
@@ -49,6 +49,11 @@
DWORD dwLength;
} WAVEParserImpl;
+static inline WAVEParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
+{
+ return (WAVEParserImpl*)((char*)iface - FIELD_OFFSET(WAVEParserImpl, Parser.sourceSeeking.lpVtbl));
+}
+
static LONGLONG bytepos_to_duration(WAVEParserImpl *This, LONGLONG bytepos)
{
LONGLONG duration = BYTES_FROM_MEDIATIME(bytepos - This->StartOfFile);
@@ -140,7 +145,7 @@
This->Parser.pInputPin->rtCurrent = tStart;
}
- if (tStop >= This->EndOfFile || (bytepos_to_duration(This, tStop) >= This->Parser.mediaSeeking.llStop) || hr == VFW_E_NOT_CONNECTED)
+ if (tStop >= This->EndOfFile || (bytepos_to_duration(This, tStop) >= This->Parser.sourceSeeking.llStop) || hr == VFW_E_NOT_CONNECTED)
{
unsigned int i;
@@ -184,14 +189,14 @@
return S_FALSE;
}
-static HRESULT WAVEParserImpl_seek(IBaseFilter *iface)
+static HRESULT WINAPI WAVEParserImpl_seek(IMediaSeeking *iface)
{
- WAVEParserImpl *This = (WAVEParserImpl *)iface;
+ WAVEParserImpl *This = impl_from_IMediaSeeking(iface);
PullPin *pPin = This->Parser.pInputPin;
IPin *victim = NULL;
LONGLONG newpos, curpos, endpos, bytepos;
- newpos = This->Parser.mediaSeeking.llCurrent;
+ newpos = This->Parser.sourceSeeking.llCurrent;
curpos = bytepos_to_duration(This, pPin->rtCurrent);
endpos = bytepos_to_duration(This, This->EndOfFile);
bytepos = duration_to_bytepos(This, newpos);
@@ -319,9 +324,9 @@
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
CoTaskMemFree(amt.pbFormat);
- pWAVEParser->Parser.mediaSeeking.llCurrent = 0;
- pWAVEParser->Parser.mediaSeeking.llStop = pWAVEParser->Parser.mediaSeeking.llDuration = bytepos_to_duration(pWAVEParser, pWAVEParser->EndOfFile);
- TRACE("Duration: %u seconds\n", (DWORD)(pWAVEParser->Parser.mediaSeeking.llDuration / (LONGLONG)10000000));
+ pWAVEParser->Parser.sourceSeeking.llCurrent = 0;
+ pWAVEParser->Parser.sourceSeeking.llStop = pWAVEParser->Parser.sourceSeeking.llDuration = bytepos_to_duration(pWAVEParser, pWAVEParser->EndOfFile);
+ TRACE("Duration: %u seconds\n", (DWORD)(pWAVEParser->Parser.sourceSeeking.llDuration / (LONGLONG)10000000));
This->rtStop = pWAVEParser->EndOfFile;
This->rtStart = pWAVEParser->StartOfFile;
diff --git a/dlls/strmbase/Makefile.in b/dlls/strmbase/Makefile.in
index 938e478..848049d 100644
--- a/dlls/strmbase/Makefile.in
+++ b/dlls/strmbase/Makefile.in
@@ -5,6 +5,7 @@
filter.c \
mediatype.c \
pin.c \
+ seeking.c \
transform.c
@MAKE_IMPLIB_RULES@
diff --git a/dlls/strmbase/seeking.c b/dlls/strmbase/seeking.c
new file mode 100644
index 0000000..93fc6db
--- /dev/null
+++ b/dlls/strmbase/seeking.c
@@ -0,0 +1,315 @@
+/*
+ * Filter Seeking and Control Interfaces
+ *
+ * Copyright 2003 Robert Shearman
+ * Copyright 2010 Aric Stewart, CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+/* FIXME: critical sections */
+
+#define COBJMACROS
+
+#include "dshow.h"
+#include "wine/strmbase.h"
+
+#include "uuids.h"
+#include "wine/debug.h"
+
+#include <assert.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
+
+HRESULT SourceSeeking_Init(SourceSeeking *pSeeking, const IMediaSeekingVtbl *Vtbl, SourceSeeking_ChangeStop fnChangeStop, SourceSeeking_ChangeStart fnChangeStart, SourceSeeking_ChangeRate fnChangeRate, PCRITICAL_SECTION crit_sect)
+{
+ assert(fnChangeStop && fnChangeStart && fnChangeRate);
+
+ pSeeking->lpVtbl = Vtbl;
+ pSeeking->refCount = 1;
+ pSeeking->fnChangeRate = fnChangeRate;
+ pSeeking->fnChangeStop = fnChangeStop;
+ pSeeking->fnChangeStart = fnChangeStart;
+ pSeeking->dwCapabilities = AM_SEEKING_CanSeekForwards |
+ AM_SEEKING_CanSeekBackwards |
+ AM_SEEKING_CanSeekAbsolute |
+ AM_SEEKING_CanGetStopPos |
+ AM_SEEKING_CanGetDuration;
+ pSeeking->llCurrent = 0;
+ pSeeking->llStop = ((ULONGLONG)0x80000000) << 32;
+ pSeeking->llDuration = pSeeking->llStop;
+ pSeeking->dRate = 1.0;
+ pSeeking->timeformat = TIME_FORMAT_MEDIA_TIME;
+ pSeeking->crst = crit_sect;
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p)\n", pCapabilities);
+
+ *pCapabilities = This->dwCapabilities;
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_CheckCapabilities(IMediaSeeking * iface, DWORD * pCapabilities)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ HRESULT hr;
+ DWORD dwCommonCaps;
+
+ TRACE("(%p)\n", pCapabilities);
+
+ if (!pCapabilities)
+ return E_POINTER;
+
+ dwCommonCaps = *pCapabilities & This->dwCapabilities;
+
+ if (!dwCommonCaps)
+ hr = E_FAIL;
+ else
+ hr = (*pCapabilities == dwCommonCaps) ? S_OK : S_FALSE;
+ *pCapabilities = dwCommonCaps;
+ return hr;
+}
+
+HRESULT WINAPI SourceSeekingImpl_IsFormatSupported(IMediaSeeking * iface, const GUID * pFormat)
+{
+ TRACE("(%s)\n", debugstr_guid(pFormat));
+
+ return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : S_FALSE);
+}
+
+HRESULT WINAPI SourceSeekingImpl_QueryPreferredFormat(IMediaSeeking * iface, GUID * pFormat)
+{
+ TRACE("(%s)\n", debugstr_guid(pFormat));
+
+ *pFormat = TIME_FORMAT_MEDIA_TIME;
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetTimeFormat(IMediaSeeking * iface, GUID * pFormat)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ TRACE("(%s)\n", debugstr_guid(pFormat));
+
+ EnterCriticalSection(This->crst);
+ *pFormat = This->timeformat;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_IsUsingTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ HRESULT hr = S_OK;
+
+ TRACE("(%s)\n", debugstr_guid(pFormat));
+
+ EnterCriticalSection(This->crst);
+ if (!IsEqualIID(pFormat, &This->timeformat))
+ hr = S_FALSE;
+ LeaveCriticalSection(This->crst);
+
+ return hr;
+}
+
+HRESULT WINAPI SourceSeekingImpl_SetTimeFormat(IMediaSeeking * iface, const GUID * pFormat)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ TRACE("%p %s\n", This, debugstr_guid(pFormat));
+ return (IsEqualIID(pFormat, &TIME_FORMAT_MEDIA_TIME) ? S_OK : E_INVALIDARG);
+}
+
+
+HRESULT WINAPI SourceSeekingImpl_GetDuration(IMediaSeeking * iface, LONGLONG * pDuration)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p)\n", pDuration);
+
+ EnterCriticalSection(This->crst);
+ *pDuration = This->llDuration;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetStopPosition(IMediaSeeking * iface, LONGLONG * pStop)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p)\n", pStop);
+
+ EnterCriticalSection(This->crst);
+ *pStop = This->llStop;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+/* FIXME: Make use of the info the filter should expose */
+HRESULT WINAPI SourceSeekingImpl_GetCurrentPosition(IMediaSeeking * iface, LONGLONG * pCurrent)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p)\n", pCurrent);
+
+ EnterCriticalSection(This->crst);
+ *pCurrent = This->llCurrent;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_ConvertTimeFormat(IMediaSeeking * iface, LONGLONG * pTarget, const GUID * pTargetFormat, LONGLONG Source, const GUID * pSourceFormat)
+{
+ if (IsEqualIID(pTargetFormat, &TIME_FORMAT_MEDIA_TIME) && IsEqualIID(pSourceFormat, &TIME_FORMAT_MEDIA_TIME))
+ {
+ *pTarget = Source;
+ return S_OK;
+ }
+ /* FIXME: clear pTarget? */
+ return E_INVALIDARG;
+}
+
+static inline LONGLONG Adjust(LONGLONG value, const LONGLONG * pModifier, DWORD dwFlags)
+{
+ switch (dwFlags & AM_SEEKING_PositioningBitsMask)
+ {
+ case AM_SEEKING_NoPositioning:
+ return value;
+ case AM_SEEKING_AbsolutePositioning:
+ return *pModifier;
+ case AM_SEEKING_RelativePositioning:
+ case AM_SEEKING_IncrementalPositioning:
+ return value + *pModifier;
+ default:
+ assert(FALSE);
+ return 0;
+ }
+}
+
+HRESULT WINAPI SourceSeekingImpl_SetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, DWORD dwCurrentFlags, LONGLONG * pStop, DWORD dwStopFlags)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ BOOL bChangeCurrent = FALSE, bChangeStop = FALSE;
+ LONGLONG llNewCurrent, llNewStop;
+
+ TRACE("(%p, %x, %p, %x)\n", pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ EnterCriticalSection(This->crst);
+
+ llNewCurrent = Adjust(This->llCurrent, pCurrent, dwCurrentFlags);
+ llNewStop = Adjust(This->llStop, pStop, dwStopFlags);
+
+ if (pCurrent)
+ bChangeCurrent = TRUE;
+ if (llNewStop != This->llStop)
+ bChangeStop = TRUE;
+
+ TRACE("Old: %u, New: %u\n", (DWORD)(This->llCurrent/10000000), (DWORD)(llNewCurrent/10000000));
+
+ This->llCurrent = llNewCurrent;
+ This->llStop = llNewStop;
+
+ if (pCurrent && (dwCurrentFlags & AM_SEEKING_ReturnTime))
+ *pCurrent = llNewCurrent;
+ if (pStop && (dwStopFlags & AM_SEEKING_ReturnTime))
+ *pStop = llNewStop;
+ LeaveCriticalSection(This->crst);
+
+ if (bChangeCurrent)
+ This->fnChangeStart(iface);
+ if (bChangeStop)
+ This->fnChangeStop(iface);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetPositions(IMediaSeeking * iface, LONGLONG * pCurrent, LONGLONG * pStop)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p, %p)\n", pCurrent, pStop);
+
+ EnterCriticalSection(This->crst);
+ IMediaSeeking_GetCurrentPosition(iface, pCurrent);
+ IMediaSeeking_GetStopPosition(iface, pStop);
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetAvailable(IMediaSeeking * iface, LONGLONG * pEarliest, LONGLONG * pLatest)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p, %p)\n", pEarliest, pLatest);
+
+ EnterCriticalSection(This->crst);
+ *pEarliest = 0;
+ *pLatest = This->llDuration;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_SetRate(IMediaSeeking * iface, double dRate)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+ BOOL bChangeRate = (dRate != This->dRate);
+ HRESULT hr = S_OK;
+
+ TRACE("(%e)\n", dRate);
+
+ if (dRate > 100 || dRate < .001)
+ {
+ FIXME("Excessive rate %e, ignoring\n", dRate);
+ return VFW_E_UNSUPPORTED_AUDIO;
+ }
+
+ EnterCriticalSection(This->crst);
+ This->dRate = dRate;
+ if (bChangeRate)
+ hr = This->fnChangeRate(iface);
+ LeaveCriticalSection(This->crst);
+
+ return hr;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetRate(IMediaSeeking * iface, double * dRate)
+{
+ SourceSeeking *This = (SourceSeeking *)iface;
+
+ TRACE("(%p)\n", dRate);
+
+ EnterCriticalSection(This->crst);
+ /* Forward? */
+ *dRate = This->dRate;
+ LeaveCriticalSection(This->crst);
+
+ return S_OK;
+}
+
+HRESULT WINAPI SourceSeekingImpl_GetPreroll(IMediaSeeking * iface, LONGLONG * pPreroll)
+{
+ TRACE("(%p)\n", pPreroll);
+
+ *pPreroll = 0;
+ return S_OK;
+}