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"
|
2017-06-05 01:09:48 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2019-02-25 09:33:52 +01:00
|
|
|
#include "wine/heap.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-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
|
|
|
}
|
|
|
|
|
|
|
|
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-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_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;
|
|
|
|
}
|