Commit 31706387 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Add a stub for sample grabber activation object.

parent f73fefd2
......@@ -4,6 +4,7 @@ IMPORTS = mfplat mfuuid
C_SRCS = \
main.c \
samplegrabber.c \
session.c \
topology.c
......
......@@ -51,7 +51,7 @@
@ stub MFCreateRemoteDesktopPlugin
@ stub MFCreateSAMIByteStreamPlugin
@ stub MFCreateSampleCopierMFT
@ stub MFCreateSampleGrabberSinkActivate
@ stdcall MFCreateSampleGrabberSinkActivate(ptr ptr ptr)
@ stub MFCreateSecureHttpSchemePlugin
@ stub MFCreateSequencerSegmentOffset
@ stdcall MFCreateSequencerSource(ptr ptr)
......
/*
* Copyright 2019 Nikolay Sivov for 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
*/
#include "mfidl.h"
struct activate_funcs
{
HRESULT (*create_object)(void *context, IUnknown **object);
void (*free_private)(void *context);
};
HRESULT create_activation_object(void *context, const struct activate_funcs *funcs, IMFActivate **ret) DECLSPEC_HIDDEN;
/*
* Copyright 2019 Nikolay Sivov for 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
*/
#define COBJMACROS
#include "mfidl.h"
#include "mf_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
struct sample_grabber_activate_context
{
IMFMediaType *media_type;
IMFSampleGrabberSinkCallback *callback;
};
static void sample_grabber_free_private(void *user_context)
{
struct sample_grabber_activate_context *context = user_context;
IMFMediaType_Release(context->media_type);
IMFSampleGrabberSinkCallback_Release(context->callback);
heap_free(context);
}
static HRESULT sample_grabber_create_object(void *user_context, IUnknown **obj)
{
FIXME("%p, %p.\n", user_context, obj);
return E_NOTIMPL;
}
static const struct activate_funcs sample_grabber_activate_funcs =
{
sample_grabber_create_object,
sample_grabber_free_private,
};
/***********************************************************************
* MFCreateSampleGrabberSinkActivate (mf.@)
*/
HRESULT WINAPI MFCreateSampleGrabberSinkActivate(IMFMediaType *media_type, IMFSampleGrabberSinkCallback *callback,
IMFActivate **activate)
{
struct sample_grabber_activate_context *context;
HRESULT hr;
TRACE("%p, %p, %p.\n", media_type, callback, activate);
if (!media_type || !callback || !activate)
return E_POINTER;
context = heap_alloc_zero(sizeof(*context));
if (!context)
return E_OUTOFMEMORY;
context->media_type = media_type;
IMFMediaType_AddRef(context->media_type);
context->callback = callback;
IMFSampleGrabberSinkCallback_AddRef(context->callback);
if (FAILED(hr = create_activation_object(context, &sample_grabber_activate_funcs, activate)))
sample_grabber_free_private(context);
return hr;
}
......@@ -940,6 +940,115 @@ todo_wine
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
}
static HRESULT WINAPI grabber_callback_QueryInterface(IMFSampleGrabberSinkCallback *iface, REFIID riid, void **obj)
{
if (IsEqualIID(riid, &IID_IMFSampleGrabberSinkCallback) ||
IsEqualIID(riid, &IID_IMFClockStateSink) ||
IsEqualIID(riid, &IID_IUnknown))
{
*obj = iface;
IMFSampleGrabberSinkCallback_AddRef(iface);
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI grabber_callback_AddRef(IMFSampleGrabberSinkCallback *iface)
{
return 2;
}
static ULONG WINAPI grabber_callback_Release(IMFSampleGrabberSinkCallback *iface)
{
return 1;
}
static HRESULT WINAPI grabber_callback_OnClockStart(IMFSampleGrabberSinkCallback *iface, MFTIME time, LONGLONG offset)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnClockStop(IMFSampleGrabberSinkCallback *iface, MFTIME time)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnClockPause(IMFSampleGrabberSinkCallback *iface, MFTIME time)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnClockRestart(IMFSampleGrabberSinkCallback *iface, MFTIME time)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnClockSetRate(IMFSampleGrabberSinkCallback *iface, MFTIME time, float rate)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnSetPresentationClock(IMFSampleGrabberSinkCallback *iface,
IMFPresentationClock *clock)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnProcessSample(IMFSampleGrabberSinkCallback *iface, REFGUID major_type,
DWORD sample_flags, LONGLONG sample_time, LONGLONG sample_duration, const BYTE *buffer, DWORD sample_size)
{
return E_NOTIMPL;
}
static HRESULT WINAPI grabber_callback_OnShutdown(IMFSampleGrabberSinkCallback *iface)
{
return E_NOTIMPL;
}
static const IMFSampleGrabberSinkCallbackVtbl grabber_callback_vtbl =
{
grabber_callback_QueryInterface,
grabber_callback_AddRef,
grabber_callback_Release,
grabber_callback_OnClockStart,
grabber_callback_OnClockStop,
grabber_callback_OnClockPause,
grabber_callback_OnClockRestart,
grabber_callback_OnClockSetRate,
grabber_callback_OnSetPresentationClock,
grabber_callback_OnProcessSample,
grabber_callback_OnShutdown,
};
static IMFSampleGrabberSinkCallback grabber_callback = { &grabber_callback_vtbl };
static void test_sample_grabber(void)
{
IMFMediaType *media_type;
IMFActivate *activate;
ULONG refcount;
HRESULT hr;
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
hr = MFCreateSampleGrabberSinkActivate(NULL, NULL, &activate);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = MFCreateSampleGrabberSinkActivate(NULL, &grabber_callback, &activate);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = MFCreateSampleGrabberSinkActivate(media_type, &grabber_callback, &activate);
ok(hr == S_OK, "Failed to create grabber activate, hr %#x.\n", hr);
refcount = IMFMediaType_Release(media_type);
ok(refcount == 1, "Unexpected refcount %u.\n", refcount);
IMFActivate_Release(activate);
}
START_TEST(mf)
{
test_topology();
......@@ -949,4 +1058,5 @@ START_TEST(mf)
test_media_session();
test_MFShutdownObject();
test_presentation_clock();
test_sample_grabber();
}
......@@ -463,8 +463,30 @@ interface IMFSequencerSource : IUnknown
HRESULT UpdateTopologyFlags(
[in] MFSequencerElementId id,
[in] DWORD flags );
}
interface IMFPresentationClock;
[
object,
uuid(8c7b80bf-ee42-4b59-b1df-55668e1bdca8),
local
]
interface IMFSampleGrabberSinkCallback : IMFClockStateSink
{
HRESULT OnSetPresentationClock(
[in] IMFPresentationClock *clock);
};
HRESULT OnProcessSample(
[in] REFGUID major_type,
[in] DWORD sample_flags,
[in] LONGLONG sample_time,
[in] LONGLONG sample_duration,
[in] const BYTE *buffer,
[in] DWORD sample_size);
HRESULT OnShutdown();
}
cpp_quote("HRESULT WINAPI MFCreateMediaSession(IMFAttributes *config, IMFMediaSession **session);")
cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream);" )
......@@ -472,6 +494,8 @@ cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStreamEx(IUnknown *stream, IMFBy
cpp_quote("HRESULT WINAPI MFCreatePresentationClock(IMFPresentationClock **clock);")
cpp_quote("HRESULT WINAPI MFCreatePresentationDescriptor(DWORD count, IMFStreamDescriptor **descriptors,")
cpp_quote(" IMFPresentationDescriptor **presentation_desc);")
cpp_quote("HRESULT WINAPI MFCreateSampleGrabberSinkActivate(IMFMediaType *media_type,")
cpp_quote(" IMFSampleGrabberSinkCallback *callback, IMFActivate **activate);")
cpp_quote("HRESULT WINAPI MFCreateSequencerSource(IUnknown *reserved, IMFSequencerSource **seq_source);" )
cpp_quote("HRESULT WINAPI MFCreateSourceResolver(IMFSourceResolver **resolver);")
cpp_quote("HRESULT WINAPI MFCreateStreamDescriptor(DWORD identifier, DWORD cMediaTypes,")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment