2017-06-05 01:09:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Nikolay Sivov
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "mfidl.h"
|
2019-02-25 09:33:52 +01:00
|
|
|
#include "mfapi.h"
|
2019-03-05 08:49:38 +01:00
|
|
|
#include "mferror.h"
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2019-02-25 09:33:52 +01:00
|
|
|
#include "wine/heap.h"
|
2019-03-07 08:07:53 +01:00
|
|
|
#include "wine/list.h"
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session
|
2017-06-05 01:09:48 +02:00
|
|
|
{
|
|
|
|
IMFMediaSession IMFMediaSession_iface;
|
2019-02-25 09:33:52 +01:00
|
|
|
LONG refcount;
|
|
|
|
IMFMediaEventQueue *event_queue;
|
|
|
|
};
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-03-07 08:07:53 +01:00
|
|
|
struct clock_sink
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IMFClockStateSink *state_sink;
|
|
|
|
};
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
enum clock_command
|
|
|
|
{
|
|
|
|
CLOCK_CMD_START = 0,
|
|
|
|
CLOCK_CMD_STOP,
|
|
|
|
CLOCK_CMD_PAUSE,
|
|
|
|
CLOCK_CMD_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum clock_notification
|
|
|
|
{
|
|
|
|
CLOCK_NOTIFY_START,
|
|
|
|
CLOCK_NOTIFY_STOP,
|
|
|
|
CLOCK_NOTIFY_PAUSE,
|
|
|
|
CLOCK_NOTIFY_RESTART,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sink_notification
|
|
|
|
{
|
|
|
|
IUnknown IUnknown_iface;
|
|
|
|
LONG refcount;
|
|
|
|
MFTIME system_time;
|
|
|
|
LONGLONG offset;
|
|
|
|
enum clock_notification notification;
|
|
|
|
IMFClockStateSink *sink;
|
|
|
|
};
|
|
|
|
|
2019-03-05 08:49:38 +01:00
|
|
|
struct presentation_clock
|
|
|
|
{
|
|
|
|
IMFPresentationClock IMFPresentationClock_iface;
|
|
|
|
IMFRateControl IMFRateControl_iface;
|
|
|
|
IMFTimer IMFTimer_iface;
|
|
|
|
IMFShutdown IMFShutdown_iface;
|
2019-03-07 08:07:54 +01:00
|
|
|
IMFAsyncCallback IMFAsyncCallback_iface;
|
2019-03-05 08:49:38 +01:00
|
|
|
LONG refcount;
|
|
|
|
IMFPresentationTimeSource *time_source;
|
2019-03-07 08:07:52 +01:00
|
|
|
IMFClockStateSink *time_source_sink;
|
2019-03-05 08:49:38 +01:00
|
|
|
MFCLOCK_STATE state;
|
2019-03-07 08:07:53 +01:00
|
|
|
struct list sinks;
|
2019-03-05 08:49:38 +01:00
|
|
|
CRITICAL_SECTION cs;
|
|
|
|
};
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
static inline struct media_session *impl_from_IMFMediaSession(IMFMediaSession *iface)
|
2017-06-05 01:09:48 +02:00
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct media_session, IMFMediaSession_iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-05 08:49:38 +01:00
|
|
|
static struct presentation_clock *impl_from_IMFPresentationClock(IMFPresentationClock *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct presentation_clock, IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct presentation_clock *impl_from_IMFRateControl(IMFRateControl *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct presentation_clock, IMFRateControl_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct presentation_clock *impl_from_IMFTimer(IMFTimer *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct presentation_clock, IMFTimer_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct presentation_clock *impl_from_IMFShutdown(IMFShutdown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct presentation_clock, IMFShutdown_iface);
|
|
|
|
}
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
static struct presentation_clock *impl_from_IMFAsyncCallback(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct presentation_clock, IMFAsyncCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sink_notification *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct sink_notification, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
2017-06-05 01:09:48 +02:00
|
|
|
static HRESULT WINAPI mfsession_QueryInterface(IMFMediaSession *iface, REFIID riid, void **out)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), out);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFMediaSession) ||
|
|
|
|
IsEqualIID(riid, &IID_IMFMediaEventGenerator) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
*out = &session->IMFMediaSession_iface;
|
|
|
|
IMFMediaSession_AddRef(iface);
|
|
|
|
return S_OK;
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
WARN("Unsupported %s.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfsession_AddRef(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&session->refcount);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p) refcount=%u\n", iface, refcount);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return refcount;
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfsession_Release(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&session->refcount);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p) refcount=%u\n", iface, refcount);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
if (!refcount)
|
2017-06-05 01:09:48 +02:00
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
if (session->event_queue)
|
|
|
|
IMFMediaEventQueue_Release(session->event_queue);
|
|
|
|
heap_free(session);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return refcount;
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_GetEvent(IMFMediaSession *iface, DWORD flags, IMFMediaEvent **event)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p)->(%#x, %p)\n", iface, flags, event);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return IMFMediaEventQueue_GetEvent(session->event_queue, flags, event);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_BeginGetEvent(IMFMediaSession *iface, IMFAsyncCallback *callback, IUnknown *state)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, callback, state);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return IMFMediaEventQueue_BeginGetEvent(session->event_queue, callback, state);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_EndGetEvent(IMFMediaSession *iface, IMFAsyncResult *result, IMFMediaEvent **event)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, result, event);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return IMFMediaEventQueue_EndGetEvent(session->event_queue, result, event);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_QueueEvent(IMFMediaSession *iface, MediaEventType event_type, REFGUID ext_type,
|
|
|
|
HRESULT hr, const PROPVARIANT *value)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
TRACE("(%p)->(%d, %s, %#x, %p)\n", iface, event_type, debugstr_guid(ext_type), hr, value);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
return IMFMediaEventQueue_QueueEventParamVar(session->event_queue, event_type, ext_type, hr, value);
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_SetTopology(IMFMediaSession *iface, DWORD flags, IMFTopology *topology)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)->(%#x, %p)\n", iface, flags, topology);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_ClearTopologies(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)\n", iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_Start(IMFMediaSession *iface, const GUID *format, const PROPVARIANT *start)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)->(%s, %p)\n", iface, debugstr_guid(format), start);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_Pause(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)\n", iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_Stop(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)\n", iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_Close(IMFMediaSession *iface)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)\n", iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2018-11-25 20:45:04 +01:00
|
|
|
return S_OK;
|
2017-06-05 01:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface)
|
|
|
|
{
|
2019-03-04 11:33:44 +01:00
|
|
|
struct media_session *session = impl_from_IMFMediaSession(iface);
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)\n", iface);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
2019-03-04 11:33:44 +01:00
|
|
|
IMFMediaEventQueue_Shutdown(session->event_queue);
|
|
|
|
|
2017-06-05 01:09:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_GetClock(IMFMediaSession *iface, IMFClock **clock)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)->(%p)\n", iface, clock);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_GetSessionCapabilities(IMFMediaSession *iface, DWORD *caps)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)->(%p)\n", iface, caps);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsession_GetFullTopology(IMFMediaSession *iface, DWORD flags, TOPOID id, IMFTopology **topology)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
FIXME("(%p)->(%#x, %s, %p)\n", iface, flags, wine_dbgstr_longlong(id), topology);
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFMediaSessionVtbl mfmediasessionvtbl =
|
|
|
|
{
|
|
|
|
mfsession_QueryInterface,
|
|
|
|
mfsession_AddRef,
|
|
|
|
mfsession_Release,
|
|
|
|
mfsession_GetEvent,
|
|
|
|
mfsession_BeginGetEvent,
|
|
|
|
mfsession_EndGetEvent,
|
|
|
|
mfsession_QueueEvent,
|
|
|
|
mfsession_SetTopology,
|
|
|
|
mfsession_ClearTopologies,
|
|
|
|
mfsession_Start,
|
|
|
|
mfsession_Pause,
|
|
|
|
mfsession_Stop,
|
|
|
|
mfsession_Close,
|
|
|
|
mfsession_Shutdown,
|
|
|
|
mfsession_GetClock,
|
|
|
|
mfsession_GetSessionCapabilities,
|
|
|
|
mfsession_GetFullTopology,
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
2019-02-25 09:33:52 +01:00
|
|
|
* MFCreateMediaSession (mf.@)
|
2017-06-05 01:09:48 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateMediaSession(IMFAttributes *config, IMFMediaSession **session)
|
|
|
|
{
|
2019-02-25 09:33:52 +01:00
|
|
|
struct media_session *object;
|
|
|
|
HRESULT hr;
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", config, session);
|
|
|
|
|
|
|
|
if (config)
|
|
|
|
FIXME("session configuration ignored\n");
|
|
|
|
|
2019-02-25 09:33:52 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
2017-06-05 01:09:48 +02:00
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IMFMediaSession_iface.lpVtbl = &mfmediasessionvtbl;
|
2019-02-25 09:33:52 +01:00
|
|
|
object->refcount = 1;
|
|
|
|
if (FAILED(hr = MFCreateEventQueue(&object->event_queue)))
|
|
|
|
{
|
|
|
|
IMFMediaSession_Release(&object->IMFMediaSession_iface);
|
|
|
|
return hr;
|
|
|
|
}
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
*session = &object->IMFMediaSession_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2019-03-05 08:49:38 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_QueryInterface(IMFPresentationClock *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFPresentationClock) ||
|
|
|
|
IsEqualIID(riid, &IID_IMFClock) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = &clock->IMFPresentationClock_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IMFRateControl))
|
|
|
|
{
|
|
|
|
*out = &clock->IMFRateControl_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IMFTimer))
|
|
|
|
{
|
|
|
|
*out = &clock->IMFTimer_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IMFShutdown))
|
|
|
|
{
|
|
|
|
*out = &clock->IMFShutdown_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Unsupported %s.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_AddRef(IMFPresentationClock *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&clock->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_Release(IMFPresentationClock *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&clock->refcount);
|
2019-03-07 08:07:53 +01:00
|
|
|
struct clock_sink *sink, *sink2;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
if (clock->time_source)
|
|
|
|
IMFPresentationTimeSource_Release(clock->time_source);
|
2019-03-07 08:07:52 +01:00
|
|
|
if (clock->time_source_sink)
|
|
|
|
IMFClockStateSink_Release(clock->time_source_sink);
|
2019-03-07 08:07:53 +01:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(sink, sink2, &clock->sinks, struct clock_sink, entry)
|
|
|
|
{
|
|
|
|
list_remove(&sink->entry);
|
|
|
|
IMFClockStateSink_Release(sink->state_sink);
|
|
|
|
heap_free(sink);
|
|
|
|
}
|
2019-03-05 08:49:38 +01:00
|
|
|
DeleteCriticalSection(&clock->cs);
|
|
|
|
heap_free(clock);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetClockCharacteristics(IMFPresentationClock *iface, DWORD *flags)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetCorrelatedTime(IMFPresentationClock *iface, DWORD reserved,
|
|
|
|
LONGLONG *clock_time, MFTIME *system_time)
|
|
|
|
{
|
|
|
|
FIXME("%p, %#x, %p, %p.\n", iface, reserved, clock_time, system_time);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetContinuityKey(IMFPresentationClock *iface, DWORD *key)
|
|
|
|
{
|
|
|
|
TRACE("%p, %p.\n", iface, key);
|
|
|
|
|
|
|
|
*key = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetState(IMFPresentationClock *iface, DWORD reserved, MFCLOCK_STATE *state)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %#x, %p.\n", iface, reserved, state);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
|
|
|
*state = clock->state;
|
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetProperties(IMFPresentationClock *iface, MFCLOCK_PROPERTIES *props)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, props);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_SetTimeSource(IMFPresentationClock *iface,
|
|
|
|
IMFPresentationTimeSource *time_source)
|
|
|
|
{
|
2019-03-07 08:07:52 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
HRESULT hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:52 +01:00
|
|
|
TRACE("%p, %p.\n", iface, time_source);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
|
|
|
if (clock->time_source)
|
|
|
|
IMFPresentationTimeSource_Release(clock->time_source);
|
|
|
|
if (clock->time_source_sink)
|
|
|
|
IMFClockStateSink_Release(clock->time_source_sink);
|
|
|
|
clock->time_source = NULL;
|
|
|
|
clock->time_source_sink = NULL;
|
|
|
|
|
|
|
|
hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&clock->time_source_sink);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
clock->time_source = time_source;
|
|
|
|
IMFPresentationTimeSource_AddRef(clock->time_source);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetTimeSource(IMFPresentationClock *iface,
|
|
|
|
IMFPresentationTimeSource **time_source)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, time_source);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
|
|
|
if (clock->time_source)
|
|
|
|
{
|
|
|
|
*time_source = clock->time_source;
|
|
|
|
IMFPresentationTimeSource_AddRef(*time_source);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = MF_E_CLOCK_NO_TIME_SOURCE;
|
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_GetTime(IMFPresentationClock *iface, MFTIME *time)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, time);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_AddClockStateSink(IMFPresentationClock *iface, IMFClockStateSink *state_sink)
|
|
|
|
{
|
2019-03-07 08:07:53 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
struct clock_sink *sink, *cur;
|
|
|
|
HRESULT hr = S_OK;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:53 +01:00
|
|
|
TRACE("%p, %p.\n", iface, state_sink);
|
|
|
|
|
|
|
|
if (!state_sink)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
sink = heap_alloc(sizeof(*sink));
|
|
|
|
if (!sink)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
sink->state_sink = state_sink;
|
|
|
|
IMFClockStateSink_AddRef(sink->state_sink);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(cur, &clock->sinks, struct clock_sink, entry)
|
|
|
|
{
|
|
|
|
if (cur->state_sink == state_sink)
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
list_add_tail(&clock->sinks, &sink->entry);
|
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMFClockStateSink_Release(sink->state_sink);
|
|
|
|
heap_free(sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_RemoveClockStateSink(IMFPresentationClock *iface,
|
|
|
|
IMFClockStateSink *state_sink)
|
|
|
|
{
|
2019-03-07 08:07:53 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
struct clock_sink *sink;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:53 +01:00
|
|
|
TRACE("%p, %p.\n", iface, state_sink);
|
|
|
|
|
|
|
|
if (!state_sink)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(sink, &clock->sinks, struct clock_sink, entry)
|
|
|
|
{
|
|
|
|
if (sink->state_sink == state_sink)
|
|
|
|
{
|
|
|
|
IMFClockStateSink_Release(sink->state_sink);
|
|
|
|
list_remove(&sink->entry);
|
|
|
|
heap_free(sink);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
static HRESULT WINAPI sink_notification_QueryInterface(IUnknown *iface, REFIID riid, void **out)
|
2019-03-07 08:07:52 +01:00
|
|
|
{
|
2019-03-07 08:07:54 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported %s.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sink_notification_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct sink_notification *notification = impl_from_IUnknown(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(¬ification->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sink_notification_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct sink_notification *notification = impl_from_IUnknown(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(¬ification->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
IMFClockStateSink_Release(notification->sink);
|
|
|
|
heap_free(notification);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl sinknotificationvtbl =
|
|
|
|
{
|
|
|
|
sink_notification_QueryInterface,
|
|
|
|
sink_notification_AddRef,
|
|
|
|
sink_notification_Release,
|
2019-03-07 08:07:52 +01:00
|
|
|
};
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
static HRESULT create_sink_notification(MFTIME system_time, LONGLONG offset, enum clock_notification notification,
|
|
|
|
IMFClockStateSink *sink, IUnknown **out)
|
|
|
|
{
|
|
|
|
struct sink_notification *object;
|
|
|
|
|
|
|
|
object = heap_alloc(sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IUnknown_iface.lpVtbl = &sinknotificationvtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
object->system_time = system_time;
|
|
|
|
object->offset = offset;
|
|
|
|
object->notification = notification;
|
|
|
|
object->sink = sink;
|
|
|
|
IMFClockStateSink_AddRef(object->sink);
|
|
|
|
|
|
|
|
*out = &object->IUnknown_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT clock_call_state_change(MFTIME system_time, LONGLONG offset, enum clock_notification notification,
|
|
|
|
IMFClockStateSink *sink)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
switch (notification)
|
|
|
|
{
|
|
|
|
case CLOCK_NOTIFY_START:
|
|
|
|
hr = IMFClockStateSink_OnClockStart(sink, system_time, offset);
|
|
|
|
break;
|
|
|
|
case CLOCK_NOTIFY_STOP:
|
|
|
|
hr = IMFClockStateSink_OnClockStop(sink, system_time);
|
|
|
|
break;
|
|
|
|
case CLOCK_NOTIFY_PAUSE:
|
|
|
|
hr = IMFClockStateSink_OnClockPause(sink, system_time);
|
|
|
|
break;
|
|
|
|
case CLOCK_NOTIFY_RESTART:
|
|
|
|
hr = IMFClockStateSink_OnClockRestart(sink, system_time);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT clock_change_state(struct presentation_clock *clock, enum clock_command command, LONGLONG offset)
|
2019-03-07 08:07:52 +01:00
|
|
|
{
|
|
|
|
static const BYTE state_change_is_allowed[MFCLOCK_STATE_PAUSED+1][CLOCK_CMD_MAX] =
|
|
|
|
{ /* S S* P */
|
|
|
|
/* INVALID */ { 1, 1, 1 },
|
|
|
|
/* RUNNING */ { 1, 1, 1 },
|
|
|
|
/* STOPPED */ { 1, 1, 0 },
|
|
|
|
/* PAUSED */ { 1, 1, 0 },
|
|
|
|
};
|
|
|
|
static const MFCLOCK_STATE states[CLOCK_CMD_MAX] =
|
|
|
|
{
|
|
|
|
/* CLOCK_CMD_START */ MFCLOCK_STATE_RUNNING,
|
|
|
|
/* CLOCK_CMD_STOP */ MFCLOCK_STATE_STOPPED,
|
|
|
|
/* CLOCK_CMD_PAUSE */ MFCLOCK_STATE_PAUSED,
|
|
|
|
};
|
2019-03-07 08:07:54 +01:00
|
|
|
enum clock_notification notification;
|
|
|
|
struct clock_sink *sink;
|
|
|
|
IUnknown *notify_object;
|
|
|
|
IMFAsyncResult *result;
|
|
|
|
MFTIME system_time;
|
2019-03-07 08:07:52 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (clock->state == states[command] && clock->state != MFCLOCK_STATE_RUNNING)
|
|
|
|
return MF_E_CLOCK_STATE_ALREADY_SET;
|
|
|
|
|
|
|
|
if (!state_change_is_allowed[clock->state][command])
|
|
|
|
return MF_E_INVALIDREQUEST;
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
system_time = MFGetSystemTime();
|
|
|
|
|
2019-03-07 08:07:52 +01:00
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case CLOCK_CMD_START:
|
2019-03-07 08:07:54 +01:00
|
|
|
if (clock->state == MFCLOCK_STATE_PAUSED && offset == PRESENTATION_CURRENT_POSITION)
|
|
|
|
notification = CLOCK_NOTIFY_RESTART;
|
2019-03-07 08:07:52 +01:00
|
|
|
else
|
2019-03-07 08:07:54 +01:00
|
|
|
notification = CLOCK_NOTIFY_START;
|
2019-03-07 08:07:52 +01:00
|
|
|
break;
|
|
|
|
case CLOCK_CMD_STOP:
|
2019-03-07 08:07:54 +01:00
|
|
|
notification = CLOCK_NOTIFY_STOP;
|
2019-03-07 08:07:52 +01:00
|
|
|
break;
|
|
|
|
case CLOCK_CMD_PAUSE:
|
2019-03-07 08:07:54 +01:00
|
|
|
notification = CLOCK_NOTIFY_PAUSE;
|
2019-03-07 08:07:52 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
if (FAILED(hr = clock_call_state_change(system_time, offset, notification, clock->time_source_sink)))
|
2019-03-07 08:07:52 +01:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
clock->state = states[command];
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(sink, &clock->sinks, struct clock_sink, entry)
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(create_sink_notification(system_time, offset, notification, sink->state_sink, ¬ify_object)))
|
|
|
|
{
|
|
|
|
hr = MFCreateAsyncResult(notify_object, &clock->IMFAsyncCallback_iface, NULL, &result);
|
|
|
|
IUnknown_Release(notify_object);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
MFPutWorkItemEx(MFASYNC_CALLBACK_QUEUE_STANDARD, result);
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-07 08:07:52 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-05 08:49:38 +01:00
|
|
|
static HRESULT WINAPI present_clock_Start(IMFPresentationClock *iface, LONGLONG start_offset)
|
|
|
|
{
|
2019-03-07 08:07:52 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
HRESULT hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:52 +01:00
|
|
|
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(start_offset));
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
2019-03-07 08:07:54 +01:00
|
|
|
hr = clock_change_state(clock, CLOCK_CMD_START, start_offset);
|
2019-03-07 08:07:52 +01:00
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_Stop(IMFPresentationClock *iface)
|
|
|
|
{
|
2019-03-07 08:07:52 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
HRESULT hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:52 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
2019-03-07 08:07:54 +01:00
|
|
|
hr = clock_change_state(clock, CLOCK_CMD_STOP, 0);
|
2019-03-07 08:07:52 +01:00
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_Pause(IMFPresentationClock *iface)
|
|
|
|
{
|
2019-03-07 08:07:52 +01:00
|
|
|
struct presentation_clock *clock = impl_from_IMFPresentationClock(iface);
|
|
|
|
HRESULT hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
|
2019-03-07 08:07:52 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&clock->cs);
|
2019-03-07 08:07:54 +01:00
|
|
|
hr = clock_change_state(clock, CLOCK_CMD_PAUSE, 0);
|
2019-03-07 08:07:52 +01:00
|
|
|
LeaveCriticalSection(&clock->cs);
|
|
|
|
|
|
|
|
return hr;
|
2019-03-05 08:49:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFPresentationClockVtbl presentationclockvtbl =
|
|
|
|
{
|
|
|
|
present_clock_QueryInterface,
|
|
|
|
present_clock_AddRef,
|
|
|
|
present_clock_Release,
|
|
|
|
present_clock_GetClockCharacteristics,
|
|
|
|
present_clock_GetCorrelatedTime,
|
|
|
|
present_clock_GetContinuityKey,
|
|
|
|
present_clock_GetState,
|
|
|
|
present_clock_GetProperties,
|
|
|
|
present_clock_SetTimeSource,
|
|
|
|
present_clock_GetTimeSource,
|
|
|
|
present_clock_GetTime,
|
|
|
|
present_clock_AddClockStateSink,
|
|
|
|
present_clock_RemoveClockStateSink,
|
|
|
|
present_clock_Start,
|
|
|
|
present_clock_Stop,
|
|
|
|
present_clock_Pause,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_rate_control_QueryInterface(IMFRateControl *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFRateControl(iface);
|
|
|
|
return IMFPresentationClock_QueryInterface(&clock->IMFPresentationClock_iface, riid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_rate_control_AddRef(IMFRateControl *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFRateControl(iface);
|
|
|
|
return IMFPresentationClock_AddRef(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_rate_control_Release(IMFRateControl *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFRateControl(iface);
|
|
|
|
return IMFPresentationClock_Release(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_rate_SetRate(IMFRateControl *iface, BOOL thin, float rate)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d, %f.\n", iface, thin, rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_rate_GetRate(IMFRateControl *iface, BOOL *thin, float *rate)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %p.\n", iface, thin, rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFRateControlVtbl presentclockratecontrolvtbl =
|
|
|
|
{
|
|
|
|
present_clock_rate_control_QueryInterface,
|
|
|
|
present_clock_rate_control_AddRef,
|
|
|
|
present_clock_rate_control_Release,
|
|
|
|
present_clock_rate_SetRate,
|
|
|
|
present_clock_rate_GetRate,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_timer_QueryInterface(IMFTimer *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFTimer(iface);
|
|
|
|
return IMFPresentationClock_QueryInterface(&clock->IMFPresentationClock_iface, riid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_timer_AddRef(IMFTimer *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFTimer(iface);
|
|
|
|
return IMFPresentationClock_AddRef(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_timer_Release(IMFTimer *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFTimer(iface);
|
|
|
|
return IMFPresentationClock_Release(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_timer_SetTimer(IMFTimer *iface, DWORD flags, LONGLONG time,
|
|
|
|
IMFAsyncCallback *callback, IUnknown *state, IUnknown **cancel_key)
|
|
|
|
{
|
|
|
|
FIXME("%p, %#x, %s, %p, %p, %p.\n", iface, flags, wine_dbgstr_longlong(time), callback, state, cancel_key);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_timer_CancelTimer(IMFTimer *iface, IUnknown *cancel_key)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, cancel_key);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFTimerVtbl presentclocktimervtbl =
|
|
|
|
{
|
|
|
|
present_clock_timer_QueryInterface,
|
|
|
|
present_clock_timer_AddRef,
|
|
|
|
present_clock_timer_Release,
|
|
|
|
present_clock_timer_SetTimer,
|
|
|
|
present_clock_timer_CancelTimer,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_shutdown_QueryInterface(IMFShutdown *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFShutdown(iface);
|
|
|
|
return IMFPresentationClock_QueryInterface(&clock->IMFPresentationClock_iface, riid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_shutdown_AddRef(IMFShutdown *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFShutdown(iface);
|
|
|
|
return IMFPresentationClock_AddRef(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_shutdown_Release(IMFShutdown *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFShutdown(iface);
|
|
|
|
return IMFPresentationClock_Release(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_shutdown_Shutdown(IMFShutdown *iface)
|
|
|
|
{
|
|
|
|
FIXME("%p.\n", iface);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_shutdown_GetShutdownStatus(IMFShutdown *iface, MFSHUTDOWN_STATUS *status)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, status);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFShutdownVtbl presentclockshutdownvtbl =
|
|
|
|
{
|
|
|
|
present_clock_shutdown_QueryInterface,
|
|
|
|
present_clock_shutdown_AddRef,
|
|
|
|
present_clock_shutdown_Release,
|
|
|
|
present_clock_shutdown_Shutdown,
|
|
|
|
present_clock_shutdown_GetShutdownStatus,
|
|
|
|
};
|
|
|
|
|
2019-03-07 08:07:54 +01:00
|
|
|
static HRESULT WINAPI present_clock_sink_callback_QueryInterface(IMFAsyncCallback *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IMFAsyncCallback) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
IMFAsyncCallback_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported %s.\n", wine_dbgstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_sink_callback_AddRef(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFAsyncCallback(iface);
|
|
|
|
return IMFPresentationClock_AddRef(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI present_clock_sink_callback_Release(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct presentation_clock *clock = impl_from_IMFAsyncCallback(iface);
|
|
|
|
return IMFPresentationClock_Release(&clock->IMFPresentationClock_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_sink_callback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI present_clock_sink_callback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result)
|
|
|
|
{
|
|
|
|
struct sink_notification *data;
|
|
|
|
IUnknown *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = IMFAsyncResult_GetObject(result, &object)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
data = impl_from_IUnknown(object);
|
|
|
|
|
|
|
|
clock_call_state_change(data->system_time, data->offset, data->notification, data->sink);
|
|
|
|
|
|
|
|
IUnknown_Release(object);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFAsyncCallbackVtbl presentclocksinkcallbackvtbl =
|
|
|
|
{
|
|
|
|
present_clock_sink_callback_QueryInterface,
|
|
|
|
present_clock_sink_callback_AddRef,
|
|
|
|
present_clock_sink_callback_Release,
|
|
|
|
present_clock_sink_callback_GetParameters,
|
|
|
|
present_clock_sink_callback_Invoke,
|
|
|
|
};
|
|
|
|
|
2019-03-05 08:49:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFCreatePresentationClock (mf.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreatePresentationClock(IMFPresentationClock **clock)
|
|
|
|
{
|
|
|
|
struct presentation_clock *object;
|
|
|
|
|
|
|
|
TRACE("%p.\n", clock);
|
|
|
|
|
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IMFPresentationClock_iface.lpVtbl = &presentationclockvtbl;
|
|
|
|
object->IMFRateControl_iface.lpVtbl = &presentclockratecontrolvtbl;
|
|
|
|
object->IMFTimer_iface.lpVtbl = &presentclocktimervtbl;
|
|
|
|
object->IMFShutdown_iface.lpVtbl = &presentclockshutdownvtbl;
|
2019-03-07 08:07:54 +01:00
|
|
|
object->IMFAsyncCallback_iface.lpVtbl = &presentclocksinkcallbackvtbl;
|
2019-03-05 08:49:38 +01:00
|
|
|
object->refcount = 1;
|
2019-03-07 08:07:53 +01:00
|
|
|
list_init(&object->sinks);
|
2019-03-05 08:49:38 +01:00
|
|
|
InitializeCriticalSection(&object->cs);
|
|
|
|
|
|
|
|
*clock = &object->IMFPresentationClock_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|