Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/evr.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/evr/evr.spec b/dlls/evr/evr.spec index aa839295658..dcf062cf5aa 100644 --- a/dlls/evr/evr.spec +++ b/dlls/evr/evr.spec @@ -3,14 +3,14 @@ @ stdcall -private DllRegisterServer() @ stdcall -private DllUnregisterServer() @ stub MFConvertColorInfoFromDXVA -@ stub MFConvertColorInfoToDXVA +@ stdcall -import MFConvertColorInfoToDXVA(ptr ptr) @ stub MFConvertFromFP16Array @ stub MFConvertToFP16Array -@ stub MFCopyImage +@ stdcall -import MFCopyImage(ptr long ptr long long long) @ stub MFCreateDXSurfaceBuffer @ stub MFCreateVideoMediaType @ stub MFCreateVideoMediaTypeFromBitMapInfoHeader -@ stub MFCreateVideoMediaTypeFromSubtype +@ stdcall -import MFCreateVideoMediaTypeFromSubtype(ptr ptr) @ stub MFCreateVideoMediaTypeFromVideoInfoHeader2 @ stub MFCreateVideoMediaTypeFromVideoInfoHeader @ stdcall MFCreateVideoMixer(ptr ptr ptr ptr) @@ -20,7 +20,7 @@ @ stdcall MFCreateVideoPresenter(ptr ptr ptr ptr) @ stdcall MFCreateVideoSampleAllocator(ptr ptr) @ stdcall MFCreateVideoSampleFromSurface(ptr ptr) -@ stub MFGetPlaneSize +@ stdcall -import MFGetPlaneSize(long long long ptr) @ stub MFGetStrideForBitmapInfoHeader @ stub MFGetUncompressedVideoFormat @ stub MFInitVideoFormat
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/mixer.c | 7 - dlls/evr/sample.c | 701 +++++++++++++++++++++++++++++++++++++++++++ dlls/evr/tests/evr.c | 98 +++++- 3 files changed, 796 insertions(+), 10 deletions(-)
diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c index f199aaee110..9969c8187db 100644 --- a/dlls/evr/mixer.c +++ b/dlls/evr/mixer.c @@ -1947,10 +1947,3 @@ HRESULT evr_mixer_create(IUnknown *outer, void **out)
return S_OK; } - -HRESULT WINAPI MFCreateVideoSampleFromSurface(IUnknown *surface, IMFSample **sample) -{ - FIXME("%p, %p.\n", surface, sample); - - return E_NOTIMPL; -} diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 2887a37e8d9..1073fb1f382 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -19,12 +19,63 @@ #define COBJMACROS
#include "evr.h" +#include "mfapi.h" +#include "mferror.h"
#include "wine/debug.h" #include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(evr);
+static const char *debugstr_time(LONGLONG time) +{ + ULONGLONG abstime = time >= 0 ? time : -time; + unsigned int i = 0, j = 0; + char buffer[23], rev[23]; + + while (abstime || i <= 8) + { + buffer[i++] = '0' + (abstime % 10); + abstime /= 10; + if (i == 7) buffer[i++] = '.'; + } + if (time < 0) buffer[i++] = '-'; + + while (i--) rev[j++] = buffer[i]; + while (rev[j-1] == '0' && rev[j-2] != '.') --j; + rev[j] = 0; + + return wine_dbg_sprintf("%s", rev); +} + +struct video_sample +{ + IMFSample IMFSample_iface; + IMFTrackedSample IMFTrackedSample_iface; + IMFDesiredSample IMFDesiredSample_iface; + LONG refcount; + + IMFSample *sample; + + IMFAsyncResult *tracked_result; + LONG tracked_refcount; +}; + +static struct video_sample *impl_from_IMFSample(IMFSample *iface) +{ + return CONTAINING_RECORD(iface, struct video_sample, IMFSample_iface); +} + +static struct video_sample *impl_from_IMFTrackedSample(IMFTrackedSample *iface) +{ + return CONTAINING_RECORD(iface, struct video_sample, IMFTrackedSample_iface); +} + +static struct video_sample *impl_from_IMFDesiredSample(IMFDesiredSample *iface) +{ + return CONTAINING_RECORD(iface, struct video_sample, IMFDesiredSample_iface); +} + struct sample_allocator { IMFVideoSampleAllocator IMFVideoSampleAllocator_iface; @@ -222,3 +273,653 @@ HRESULT WINAPI MFCreateVideoSampleAllocator(REFIID riid, void **obj)
return hr; } + +static HRESULT WINAPI video_sample_QueryInterface(IMFSample *iface, REFIID riid, void **out) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out); + + if (IsEqualIID(riid, &IID_IMFSample) || + IsEqualIID(riid, &IID_IMFAttributes) || + IsEqualIID(riid, &IID_IUnknown)) + { + *out = &sample->IMFSample_iface; + } + else if (IsEqualIID(riid, &IID_IMFTrackedSample)) + { + *out = &sample->IMFTrackedSample_iface; + } + else if (IsEqualIID(riid, &IID_IMFDesiredSample)) + { + *out = &sample->IMFDesiredSample_iface; + } + else + { + WARN("Unsupported %s.\n", debugstr_guid(riid)); + *out = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI video_sample_AddRef(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + ULONG refcount = InterlockedIncrement(&sample->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI video_sample_Release(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + ULONG refcount; + HRESULT hr; + + IMFSample_LockStore(sample->sample); + refcount = InterlockedDecrement(&sample->refcount); + if (sample->tracked_result && sample->tracked_refcount == refcount) + { + /* Call could fail if queue system is not initialized, it's not critical. */ + if (FAILED(hr = MFInvokeCallback(sample->tracked_result))) + WARN("Failed to invoke tracking callback, hr %#x.\n", hr); + IMFAsyncResult_Release(sample->tracked_result); + sample->tracked_result = NULL; + sample->tracked_refcount = 0; + } + IMFSample_UnlockStore(sample->sample); + + TRACE("%p, refcount %u.\n", iface, refcount); + + if (!refcount) + { + if (sample->sample) + IMFSample_Release(sample->sample); + heap_free(sample); + } + + return refcount; +} + +static HRESULT WINAPI video_sample_GetItem(IMFSample *iface, REFGUID key, PROPVARIANT *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_GetItem(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_GetItemType(IMFSample *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), type); + + return IMFSample_GetItemType(sample->sample, key, type); +} + +static HRESULT WINAPI video_sample_CompareItem(IMFSample *iface, REFGUID key, REFPROPVARIANT value, BOOL *result) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, result); + + return IMFSample_CompareItem(sample->sample, key, value, result); +} + +static HRESULT WINAPI video_sample_Compare(IMFSample *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type, + BOOL *result) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p, %d, %p.\n", iface, theirs, type, result); + + return IMFSample_Compare(sample->sample, theirs, type, result); +} + +static HRESULT WINAPI video_sample_GetUINT32(IMFSample *iface, REFGUID key, UINT32 *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_GetUINT32(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_GetUINT64(IMFSample *iface, REFGUID key, UINT64 *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_GetUINT64(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_GetDouble(IMFSample *iface, REFGUID key, double *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_GetDouble(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_GetGUID(IMFSample *iface, REFGUID key, GUID *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_GetGUID(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_GetStringLength(IMFSample *iface, REFGUID key, UINT32 *length) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), length); + + return IMFSample_GetStringLength(sample->sample, key, length); +} + +static HRESULT WINAPI video_sample_GetString(IMFSample *iface, REFGUID key, WCHAR *value, UINT32 size, UINT32 *length) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %u, %p.\n", iface, debugstr_guid(key), value, size, length); + + return IMFSample_GetString(sample->sample, key, value, size, length); +} + +static HRESULT WINAPI video_sample_GetAllocatedString(IMFSample *iface, REFGUID key, WCHAR **value, UINT32 *length) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, length); + + return IMFSample_GetAllocatedString(sample->sample, key, value, length); +} + +static HRESULT WINAPI video_sample_GetBlobSize(IMFSample *iface, REFGUID key, UINT32 *size) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), size); + + return IMFSample_GetBlobSize(sample->sample, key, size); +} + +static HRESULT WINAPI video_sample_GetBlob(IMFSample *iface, REFGUID key, UINT8 *buf, UINT32 bufsize, UINT32 *blobsize) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %u, %p.\n", iface, debugstr_guid(key), buf, bufsize, blobsize); + + return IMFSample_GetBlob(sample->sample, key, buf, bufsize, blobsize); +} + +static HRESULT WINAPI video_sample_GetAllocatedBlob(IMFSample *iface, REFGUID key, UINT8 **buf, UINT32 *size) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), buf, size); + + return IMFSample_GetAllocatedBlob(sample->sample, key, buf, size); +} + +static HRESULT WINAPI video_sample_GetUnknown(IMFSample *iface, REFGUID key, REFIID riid, void **out) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(key), debugstr_guid(riid), out); + + return IMFSample_GetUnknown(sample->sample, key, riid, out); +} + +static HRESULT WINAPI video_sample_SetItem(IMFSample *iface, REFGUID key, REFPROPVARIANT value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value); + + return IMFSample_SetItem(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_DeleteItem(IMFSample *iface, REFGUID key) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s.\n", iface, debugstr_guid(key)); + + return IMFSample_DeleteItem(sample->sample, key); +} + +static HRESULT WINAPI video_sample_DeleteAllItems(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p.\n", iface); + + return IMFSample_DeleteAllItems(sample->sample); +} + +static HRESULT WINAPI video_sample_SetUINT32(IMFSample *iface, REFGUID key, UINT32 value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %u.\n", iface, debugstr_guid(key), value); + + return IMFSample_SetUINT32(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_SetUINT64(IMFSample *iface, REFGUID key, UINT64 value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), wine_dbgstr_longlong(value)); + + return IMFSample_SetUINT64(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_SetDouble(IMFSample *iface, REFGUID key, double value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %f.\n", iface, debugstr_guid(key), value); + + return IMFSample_SetDouble(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_SetGUID(IMFSample *iface, REFGUID key, REFGUID value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_guid(value)); + + return IMFSample_SetGUID(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_SetString(IMFSample *iface, REFGUID key, const WCHAR *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_w(value)); + + return IMFSample_SetString(sample->sample, key, value); +} + +static HRESULT WINAPI video_sample_SetBlob(IMFSample *iface, REFGUID key, const UINT8 *buf, UINT32 size) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p, %u.\n", iface, debugstr_guid(key), buf, size); + + return IMFSample_SetBlob(sample->sample, key, buf, size); +} + +static HRESULT WINAPI video_sample_SetUnknown(IMFSample *iface, REFGUID key, IUnknown *unknown) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), unknown); + + return IMFSample_SetUnknown(sample->sample, key, unknown); +} + +static HRESULT WINAPI video_sample_LockStore(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p.\n", iface); + + return IMFSample_LockStore(sample->sample); +} + +static HRESULT WINAPI video_sample_UnlockStore(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p.\n", iface); + + return IMFSample_UnlockStore(sample->sample); +} + +static HRESULT WINAPI video_sample_GetCount(IMFSample *iface, UINT32 *count) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, count); + + return IMFSample_GetCount(sample->sample, count); +} + +static HRESULT WINAPI video_sample_GetItemByIndex(IMFSample *iface, UINT32 index, GUID *key, PROPVARIANT *value) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %u, %p, %p.\n", iface, index, key, value); + + return IMFSample_GetItemByIndex(sample->sample, index, key, value); +} + +static HRESULT WINAPI video_sample_CopyAllItems(IMFSample *iface, IMFAttributes *dest) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, dest); + + return IMFSample_CopyAllItems(sample->sample, dest); +} + +static HRESULT WINAPI video_sample_GetSampleFlags(IMFSample *iface, DWORD *flags) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, flags); + + return IMFSample_GetSampleFlags(sample->sample, flags); +} + +static HRESULT WINAPI video_sample_SetSampleFlags(IMFSample *iface, DWORD flags) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %#x.\n", iface, flags); + + return IMFSample_SetSampleFlags(sample->sample, flags); +} + +static HRESULT WINAPI video_sample_GetSampleTime(IMFSample *iface, LONGLONG *timestamp) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, timestamp); + + return IMFSample_GetSampleTime(sample->sample, timestamp); +} + +static HRESULT WINAPI video_sample_SetSampleTime(IMFSample *iface, LONGLONG timestamp) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s.\n", iface, debugstr_time(timestamp)); + + return IMFSample_SetSampleTime(sample->sample, timestamp); +} + +static HRESULT WINAPI video_sample_GetSampleDuration(IMFSample *iface, LONGLONG *duration) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, duration); + + return IMFSample_GetSampleDuration(sample->sample, duration); +} + +static HRESULT WINAPI video_sample_SetSampleDuration(IMFSample *iface, LONGLONG duration) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %s.\n", iface, debugstr_time(duration)); + + return IMFSample_SetSampleDuration(sample->sample, duration); +} + +static HRESULT WINAPI video_sample_GetBufferCount(IMFSample *iface, DWORD *count) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, count); + + return IMFSample_GetBufferCount(sample->sample, count); +} + +static HRESULT WINAPI video_sample_GetBufferByIndex(IMFSample *iface, DWORD index, IMFMediaBuffer **buffer) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %u, %p.\n", iface, index, buffer); + + return IMFSample_GetBufferByIndex(sample->sample, index, buffer); +} + +static HRESULT WINAPI video_sample_ConvertToContiguousBuffer(IMFSample *iface, IMFMediaBuffer **buffer) +{ + TRACE("%p, %p.\n", iface, buffer); + + return E_NOTIMPL; +} + +static HRESULT WINAPI video_sample_AddBuffer(IMFSample *iface, IMFMediaBuffer *buffer) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %p.\n", iface, buffer); + + return IMFSample_AddBuffer(sample->sample, buffer); +} + +static HRESULT WINAPI video_sample_RemoveBufferByIndex(IMFSample *iface, DWORD index) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p, %u.\n", iface, index); + + return IMFSample_RemoveBufferByIndex(sample->sample, index); +} + +static HRESULT WINAPI video_sample_RemoveAllBuffers(IMFSample *iface) +{ + struct video_sample *sample = impl_from_IMFSample(iface); + + TRACE("%p.\n", iface); + + return IMFSample_RemoveAllBuffers(sample->sample); +} + +static HRESULT WINAPI video_sample_GetTotalLength(IMFSample *iface, DWORD *total_length) +{ + TRACE("%p, %p.\n", iface, total_length); + + *total_length = 0; + + return S_OK; +} + +static HRESULT WINAPI video_sample_CopyToBuffer(IMFSample *iface, IMFMediaBuffer *buffer) +{ + TRACE("%p, %p.\n", iface, buffer); + + return E_NOTIMPL; +} + +static const IMFSampleVtbl video_sample_vtbl = +{ + video_sample_QueryInterface, + video_sample_AddRef, + video_sample_Release, + video_sample_GetItem, + video_sample_GetItemType, + video_sample_CompareItem, + video_sample_Compare, + video_sample_GetUINT32, + video_sample_GetUINT64, + video_sample_GetDouble, + video_sample_GetGUID, + video_sample_GetStringLength, + video_sample_GetString, + video_sample_GetAllocatedString, + video_sample_GetBlobSize, + video_sample_GetBlob, + video_sample_GetAllocatedBlob, + video_sample_GetUnknown, + video_sample_SetItem, + video_sample_DeleteItem, + video_sample_DeleteAllItems, + video_sample_SetUINT32, + video_sample_SetUINT64, + video_sample_SetDouble, + video_sample_SetGUID, + video_sample_SetString, + video_sample_SetBlob, + video_sample_SetUnknown, + video_sample_LockStore, + video_sample_UnlockStore, + video_sample_GetCount, + video_sample_GetItemByIndex, + video_sample_CopyAllItems, + video_sample_GetSampleFlags, + video_sample_SetSampleFlags, + video_sample_GetSampleTime, + video_sample_SetSampleTime, + video_sample_GetSampleDuration, + video_sample_SetSampleDuration, + video_sample_GetBufferCount, + video_sample_GetBufferByIndex, + video_sample_ConvertToContiguousBuffer, + video_sample_AddBuffer, + video_sample_RemoveBufferByIndex, + video_sample_RemoveAllBuffers, + video_sample_GetTotalLength, + video_sample_CopyToBuffer, +}; + +static HRESULT WINAPI tracked_video_sample_QueryInterface(IMFTrackedSample *iface, REFIID riid, void **obj) +{ + struct video_sample *sample = impl_from_IMFTrackedSample(iface); + return IMFSample_QueryInterface(&sample->IMFSample_iface, riid, obj); +} + +static ULONG WINAPI tracked_video_sample_AddRef(IMFTrackedSample *iface) +{ + struct video_sample *sample = impl_from_IMFTrackedSample(iface); + return IMFSample_AddRef(&sample->IMFSample_iface); +} + +static ULONG WINAPI tracked_video_sample_Release(IMFTrackedSample *iface) +{ + struct video_sample *sample = impl_from_IMFTrackedSample(iface); + return IMFSample_Release(&sample->IMFSample_iface); +} + +static HRESULT WINAPI tracked_video_sample_SetAllocator(IMFTrackedSample *iface, + IMFAsyncCallback *sample_allocator, IUnknown *state) +{ + struct video_sample *sample = impl_from_IMFTrackedSample(iface); + HRESULT hr = S_OK; + + TRACE("%p, %p, %p.\n", iface, sample_allocator, state); + + IMFSample_LockStore(sample->sample); + + if (sample->tracked_result) + hr = MF_E_NOTACCEPTING; + else + { + if (SUCCEEDED(hr = MFCreateAsyncResult((IUnknown *)iface, sample_allocator, state, &sample->tracked_result))) + { + /* Account for additional refcount brought by 'state' object. This threshold is used + on Release() to invoke tracker callback. */ + sample->tracked_refcount = 1; + if (state == (IUnknown *)&sample->IMFTrackedSample_iface || + state == (IUnknown *)&sample->IMFSample_iface) + { + ++sample->tracked_refcount; + } + } + } + + IMFSample_UnlockStore(sample->sample); + + return hr; +} + +static const IMFTrackedSampleVtbl tracked_video_sample_vtbl = +{ + tracked_video_sample_QueryInterface, + tracked_video_sample_AddRef, + tracked_video_sample_Release, + tracked_video_sample_SetAllocator, +}; + +static HRESULT WINAPI desired_video_sample_QueryInterface(IMFDesiredSample *iface, REFIID riid, void **obj) +{ + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + return IMFSample_QueryInterface(&sample->IMFSample_iface, riid, obj); +} + +static ULONG WINAPI desired_video_sample_AddRef(IMFDesiredSample *iface) +{ + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + return IMFSample_AddRef(&sample->IMFSample_iface); +} + +static ULONG WINAPI desired_video_sample_Release(IMFDesiredSample *iface) +{ + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + return IMFSample_Release(&sample->IMFSample_iface); +} + +static HRESULT WINAPI desired_video_sample_GetDesiredSampleTimeAndDuration(IMFDesiredSample *iface, + LONGLONG *sample_time, LONGLONG *sample_duration) +{ + FIXME("%p, %p, %p.\n", iface, sample_time, sample_duration); + + return E_NOTIMPL; +} + +static void WINAPI desired_video_sample_SetDesiredSampleTimeAndDuration(IMFDesiredSample *iface, + LONGLONG sample_time, LONGLONG sample_duration) +{ + FIXME("%p, %s, %s.\n", iface, debugstr_time(sample_time), debugstr_time(sample_duration)); +} + +static void WINAPI desired_video_sample_Clear(IMFDesiredSample *iface) +{ + FIXME("%p.\n", iface); +} + +static const IMFDesiredSampleVtbl desired_video_sample_vtbl = +{ + desired_video_sample_QueryInterface, + desired_video_sample_AddRef, + desired_video_sample_Release, + desired_video_sample_GetDesiredSampleTimeAndDuration, + desired_video_sample_SetDesiredSampleTimeAndDuration, + desired_video_sample_Clear, +}; + +HRESULT WINAPI MFCreateVideoSampleFromSurface(IUnknown *surface, IMFSample **sample) +{ + struct video_sample *object; + HRESULT hr; + + TRACE("%p, %p.\n", surface, sample); + + if (surface) + FIXME("Create surface buffer.\n"); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IMFSample_iface.lpVtbl = &video_sample_vtbl; + object->IMFTrackedSample_iface.lpVtbl = &tracked_video_sample_vtbl; + object->IMFDesiredSample_iface.lpVtbl = &desired_video_sample_vtbl; + object->refcount = 1; + + if (FAILED(hr = MFCreateSample(&object->sample))) + { + heap_free(object); + return hr; + } + + *sample = &object->IMFSample_iface; + + return S_OK; +} diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 6a69305c9e5..2d4cdc832a5 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -722,8 +722,8 @@ static void test_surface_sample(void) IMFDesiredSample *desired_sample; IMFMediaBuffer *buffer, *buffer2; IDirect3DSwapChain9 *swapchain; + DWORD flags, count, length; IDirect3DDevice9 *device; - DWORD count, length; IMFSample *sample; LONGLONG duration; IDirect3D9 *d3d; @@ -751,9 +751,7 @@ static void test_surface_sample(void) IDirect3DSwapChain9_Release(swapchain);
hr = MFCreateVideoSampleFromSurface((IUnknown *)backbuffer, &sample); -todo_wine ok(hr == S_OK, "Failed to create surface sample, hr %#x.\n", hr); - if (FAILED(hr)) goto done;
hr = IMFSample_QueryInterface(sample, &IID_IMFTrackedSample, (void **)&unk); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -778,8 +776,10 @@ todo_wine ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr); ok(!count, "Unexpected attribute count.\n");
+ count = 0; hr = IMFSample_GetBufferCount(sample, &count); ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); +todo_wine ok(count == 1, "Unexpected attribute count.\n");
hr = IMFSample_GetTotalLength(sample, &length); @@ -793,8 +793,11 @@ todo_wine ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#x.\n", hr);
hr = IMFSample_GetBufferByIndex(sample, 0, &buffer); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+if (SUCCEEDED(hr)) +{ hr = IMFMediaBuffer_GetMaxLength(buffer, &length); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
@@ -829,6 +832,17 @@ todo_wine ok(!count, "Unexpected attribute count.\n");
IMFMediaBuffer_Release(buffer); +} + hr = IMFSample_GetSampleFlags(sample, &flags); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFSample_SetSampleFlags(sample, 0x123); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + flags = 0; + hr = IMFSample_GetSampleFlags(sample, &flags); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(flags == 0x123, "Unexpected flags %#x.\n", flags);
IMFSample_Release(sample);
@@ -1931,6 +1945,83 @@ static void test_mixer_zorder(void) IMFTransform_Release(mixer); }
+static void test_mixer_samples(void) +{ + IDirect3DDeviceManager9 *manager; + MFT_OUTPUT_DATA_BUFFER buffer; + IDirect3DDevice9 *device; + IMFMediaType *video_type; + IMFTransform *mixer; + IMFSample *sample; + IDirect3D9 *d3d; + DWORD status; + HWND window; + UINT token; + HRESULT hr; + + window = create_window(); + d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d, window))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + goto done; + } + + hr = MFCreateVideoMixer(NULL, &IID_IDirect3DDevice9, &IID_IMFTransform, (void **)&mixer); + ok(hr == S_OK, "Failed to create a mixer, hr %#x.\n", hr); + + /* Configure device and media types. */ + hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token); + ok(hr == S_OK, "Failed to set a device, hr %#x.\n", hr); + + hr = IMFTransform_ProcessMessage(mixer, MFT_MESSAGE_SET_D3D_MANAGER, (ULONG_PTR)manager); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IDirect3DDeviceManager9_Release(manager); + + video_type = create_video_type(&MFVideoFormat_RGB32); + + hr = IMFMediaType_SetUINT64(video_type, &MF_MT_FRAME_SIZE, (UINT64)640 << 32 | 480); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMFMediaType_SetUINT32(video_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFTransform_SetInputType(mixer, 0, video_type, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMFTransform_SetOutputType(mixer, 0, video_type, 0); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + IMFMediaType_Release(video_type); + + memset(&buffer, 0, sizeof(buffer)); + hr = IMFTransform_ProcessOutput(mixer, 0, 1, &buffer, &status); +todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = MFCreateSample(&sample); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + buffer.pSample = sample; + hr = IMFTransform_ProcessOutput(mixer, 0, 1, &buffer, &status); +todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + IMFSample_Release(sample); + + IMFTransform_Release(mixer); + + IDirect3DDevice9_Release(device); + +done: + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + START_TEST(evr) { CoInitialize(NULL); @@ -1951,6 +2042,7 @@ START_TEST(evr) test_presenter_ar_mode(); test_mixer_output_rectangle(); test_mixer_zorder(); + test_mixer_samples();
CoUninitialize(); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/sample.c | 42 ++++++++++++++++++++++++++++++++++++++---- dlls/evr/tests/evr.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 1073fb1f382..5427833a2c3 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -59,6 +59,10 @@ struct video_sample
IMFAsyncResult *tracked_result; LONG tracked_refcount; + + LONGLONG desired_time; + LONGLONG desired_duration; + BOOL desired_set; };
static struct video_sample *impl_from_IMFSample(IMFSample *iface) @@ -869,20 +873,50 @@ static ULONG WINAPI desired_video_sample_Release(IMFDesiredSample *iface) static HRESULT WINAPI desired_video_sample_GetDesiredSampleTimeAndDuration(IMFDesiredSample *iface, LONGLONG *sample_time, LONGLONG *sample_duration) { - FIXME("%p, %p, %p.\n", iface, sample_time, sample_duration); + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + HRESULT hr = S_OK;
- return E_NOTIMPL; + TRACE("%p, %p, %p.\n", iface, sample_time, sample_duration); + + if (!sample_time || !sample_duration) + return E_POINTER; + + IMFSample_LockStore(sample->sample); + if (sample->desired_set) + { + *sample_time = sample->desired_time; + *sample_duration = sample->desired_duration; + } + else + hr = MF_E_NOT_AVAILABLE; + IMFSample_UnlockStore(sample->sample); + + return hr; }
static void WINAPI desired_video_sample_SetDesiredSampleTimeAndDuration(IMFDesiredSample *iface, LONGLONG sample_time, LONGLONG sample_duration) { - FIXME("%p, %s, %s.\n", iface, debugstr_time(sample_time), debugstr_time(sample_duration)); + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + + TRACE("%p, %s, %s.\n", iface, debugstr_time(sample_time), debugstr_time(sample_duration)); + + IMFSample_LockStore(sample->sample); + sample->desired_set = TRUE; + sample->desired_time = sample_time; + sample->desired_duration = sample_duration; + IMFSample_UnlockStore(sample->sample); }
static void WINAPI desired_video_sample_Clear(IMFDesiredSample *iface) { - FIXME("%p.\n", iface); + struct video_sample *sample = impl_from_IMFDesiredSample(iface); + + TRACE("%p.\n", iface); + + IMFSample_LockStore(sample->sample); + sample->desired_set = FALSE; + IMFSample_UnlockStore(sample->sample); }
static const IMFDesiredSampleVtbl desired_video_sample_vtbl = diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 2d4cdc832a5..b924ac2d9b9 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -721,11 +721,11 @@ static void test_surface_sample(void) IDirect3DSurface9 *backbuffer = NULL; IMFDesiredSample *desired_sample; IMFMediaBuffer *buffer, *buffer2; + LONGLONG duration, time1, time2; IDirect3DSwapChain9 *swapchain; DWORD flags, count, length; IDirect3DDevice9 *device; IMFSample *sample; - LONGLONG duration; IDirect3D9 *d3d; IUnknown *unk; HWND window; @@ -764,8 +764,37 @@ static void test_surface_sample(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!count, "Unexpected attribute count %u.\n", count);
+ hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, NULL, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, NULL, &time2); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, &time1, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, &time1, &time2); + ok(hr == MF_E_NOT_AVAILABLE, "Unexpected hr %#x.\n", hr); + IMFDesiredSample_SetDesiredSampleTimeAndDuration(desired_sample, 123, 456);
+ time1 = time2 = 0; + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, &time1, &time2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(time1 == 123 && time2 == 456, "Unexpected time values.\n"); + + IMFDesiredSample_SetDesiredSampleTimeAndDuration(desired_sample, 0, 0); + + time1 = time2 = 1; + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, &time1, &time2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(time1 == 0 && time2 == 0, "Unexpected time values.\n"); + + IMFDesiredSample_Clear(desired_sample); + + hr = IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired_sample, &time1, &time2); + ok(hr == MF_E_NOT_AVAILABLE, "Unexpected hr %#x.\n", hr); + hr = IMFSample_GetCount(sample, &count); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!count, "Unexpected attribute count %u.\n", count);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/sample.c | 190 ++++++++++++++++++++++++++++++++++++++++++- dlls/evr/tests/evr.c | 20 +++-- 2 files changed, 202 insertions(+), 8 deletions(-)
diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 5427833a2c3..668e675da2b 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -48,6 +48,16 @@ static const char *debugstr_time(LONGLONG time) return wine_dbg_sprintf("%s", rev); }
+struct surface_buffer +{ + IMFMediaBuffer IMFMediaBuffer_iface; + IMFGetService IMFGetService_iface; + LONG refcount; + + IUnknown *surface; + ULONG length; +}; + struct video_sample { IMFSample IMFSample_iface; @@ -80,6 +90,16 @@ static struct video_sample *impl_from_IMFDesiredSample(IMFDesiredSample *iface) return CONTAINING_RECORD(iface, struct video_sample, IMFDesiredSample_iface); }
+static struct surface_buffer *impl_from_IMFMediaBuffer(IMFMediaBuffer *iface) +{ + return CONTAINING_RECORD(iface, struct surface_buffer, IMFMediaBuffer_iface); +} + +static struct surface_buffer *impl_from_IMFGetService(IMFGetService *iface) +{ + return CONTAINING_RECORD(iface, struct surface_buffer, IMFGetService_iface); +} + struct sample_allocator { IMFVideoSampleAllocator IMFVideoSampleAllocator_iface; @@ -929,16 +949,171 @@ static const IMFDesiredSampleVtbl desired_video_sample_vtbl = desired_video_sample_Clear, };
+static HRESULT WINAPI surface_buffer_QueryInterface(IMFMediaBuffer *iface, REFIID riid, void **obj) +{ + struct surface_buffer *buffer = impl_from_IMFMediaBuffer(iface); + + TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj); + + if (IsEqualIID(riid, &IID_IMFMediaBuffer) || IsEqualIID(riid, &IID_IUnknown)) + { + *obj = &buffer->IMFMediaBuffer_iface; + } + else if (IsEqualIID(riid, &IID_IMFGetService)) + { + *obj = &buffer->IMFGetService_iface; + } + else + { + WARN("Unsupported interface %s.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*obj); + return S_OK; +} + +static ULONG WINAPI surface_buffer_AddRef(IMFMediaBuffer *iface) +{ + struct surface_buffer *buffer = impl_from_IMFMediaBuffer(iface); + ULONG refcount = InterlockedIncrement(&buffer->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI surface_buffer_Release(IMFMediaBuffer *iface) +{ + struct surface_buffer *buffer = impl_from_IMFMediaBuffer(iface); + ULONG refcount = InterlockedDecrement(&buffer->refcount); + + TRACE("%p, refcount %u.\n", iface, refcount); + + if (!refcount) + { + IUnknown_Release(buffer->surface); + heap_free(buffer); + } + + return refcount; +} + +static HRESULT WINAPI surface_buffer_Lock(IMFMediaBuffer *iface, BYTE **data, DWORD *maxlength, DWORD *length) +{ + TRACE("%p, %p, %p, %p.\n", iface, data, maxlength, length); + + return E_NOTIMPL; +} + +static HRESULT WINAPI surface_buffer_Unlock(IMFMediaBuffer *iface) +{ + TRACE("%p.\n", iface); + + return E_NOTIMPL; +} + +static HRESULT WINAPI surface_buffer_GetCurrentLength(IMFMediaBuffer *iface, DWORD *length) +{ + struct surface_buffer *buffer = impl_from_IMFMediaBuffer(iface); + + TRACE("%p.\n", iface); + + *length = buffer->length; + + return S_OK; +} + +static HRESULT WINAPI surface_buffer_SetCurrentLength(IMFMediaBuffer *iface, DWORD length) +{ + struct surface_buffer *buffer = impl_from_IMFMediaBuffer(iface); + + TRACE("%p.\n", iface); + + buffer->length = length; + + return S_OK; +} + +static HRESULT WINAPI surface_buffer_GetMaxLength(IMFMediaBuffer *iface, DWORD *length) +{ + TRACE("%p.\n", iface); + + return E_NOTIMPL; +} + +static const IMFMediaBufferVtbl surface_buffer_vtbl = +{ + surface_buffer_QueryInterface, + surface_buffer_AddRef, + surface_buffer_Release, + surface_buffer_Lock, + surface_buffer_Unlock, + surface_buffer_GetCurrentLength, + surface_buffer_SetCurrentLength, + surface_buffer_GetMaxLength, +}; + +static HRESULT WINAPI surface_buffer_gs_QueryInterface(IMFGetService *iface, REFIID riid, void **obj) +{ + struct surface_buffer *buffer = impl_from_IMFGetService(iface); + return IMFMediaBuffer_QueryInterface(&buffer->IMFMediaBuffer_iface, riid, obj); +} + +static ULONG WINAPI surface_buffer_gs_AddRef(IMFGetService *iface) +{ + struct surface_buffer *buffer = impl_from_IMFGetService(iface); + return IMFMediaBuffer_AddRef(&buffer->IMFMediaBuffer_iface); +} + +static ULONG WINAPI surface_buffer_gs_Release(IMFGetService *iface) +{ + struct surface_buffer *buffer = impl_from_IMFGetService(iface); + return IMFMediaBuffer_Release(&buffer->IMFMediaBuffer_iface); +} + +static HRESULT WINAPI surface_buffer_gs_GetService(IMFGetService *iface, REFGUID service, REFIID riid, void **obj) +{ + FIXME("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj); + + return E_NOTIMPL; +} + +static const IMFGetServiceVtbl surface_buffer_gs_vtbl = +{ + surface_buffer_gs_QueryInterface, + surface_buffer_gs_AddRef, + surface_buffer_gs_Release, + surface_buffer_gs_GetService, +}; + +static HRESULT create_surface_buffer(IUnknown *surface, IMFMediaBuffer **buffer) +{ + struct surface_buffer *object; + + if (!(object = heap_alloc_zero(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IMFMediaBuffer_iface.lpVtbl = &surface_buffer_vtbl; + object->IMFGetService_iface.lpVtbl = &surface_buffer_gs_vtbl; + object->refcount = 1; + object->surface = surface; + IUnknown_AddRef(object->surface); + + *buffer = &object->IMFMediaBuffer_iface; + + return S_OK; +} + HRESULT WINAPI MFCreateVideoSampleFromSurface(IUnknown *surface, IMFSample **sample) { struct video_sample *object; + IMFMediaBuffer *buffer = NULL; HRESULT hr;
TRACE("%p, %p.\n", surface, sample);
- if (surface) - FIXME("Create surface buffer.\n"); - if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY;
@@ -953,6 +1128,15 @@ HRESULT WINAPI MFCreateVideoSampleFromSurface(IUnknown *surface, IMFSample **sam return hr; }
+ if (surface && FAILED(hr = create_surface_buffer(surface, &buffer))) + { + IMFSample_Release(&object->IMFSample_iface); + return hr; + } + + if (buffer) + IMFSample_AddBuffer(object->sample, buffer); + *sample = &object->IMFSample_iface;
return S_OK; diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index b924ac2d9b9..69ee2d3d967 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -750,6 +750,10 @@ static void test_surface_sample(void)
IDirect3DSwapChain9_Release(swapchain);
+ hr = MFCreateVideoSampleFromSurface(NULL, &sample); + ok(hr == S_OK, "Failed to create surface sample, hr %#x.\n", hr); + IMFSample_Release(sample); + hr = MFCreateVideoSampleFromSurface((IUnknown *)backbuffer, &sample); ok(hr == S_OK, "Failed to create surface sample, hr %#x.\n", hr);
@@ -808,7 +812,6 @@ static void test_surface_sample(void) count = 0; hr = IMFSample_GetBufferCount(sample, &count); ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); -todo_wine ok(count == 1, "Unexpected attribute count.\n");
hr = IMFSample_GetTotalLength(sample, &length); @@ -822,11 +825,8 @@ todo_wine ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#x.\n", hr);
hr = IMFSample_GetBufferByIndex(sample, 0, &buffer); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
-if (SUCCEEDED(hr)) -{ hr = IMFMediaBuffer_GetMaxLength(buffer, &length); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
@@ -834,9 +834,19 @@ if (SUCCEEDED(hr)) ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr); ok(!length, "Unexpected length %u.\n", length);
+ hr = IMFMediaBuffer_SetCurrentLength(buffer, 16); + ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr); + + hr = IMFMediaBuffer_GetCurrentLength(buffer, &length); + ok(hr == S_OK, "Failed to get length, hr %#x.\n", hr); + ok(length == 16, "Unexpected length %u.\n", length); + hr = IMFMediaBuffer_Lock(buffer, &data, NULL, NULL); ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
+ hr = IMFMediaBuffer_Unlock(buffer); + ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr); + hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&unk); ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
@@ -861,7 +871,7 @@ if (SUCCEEDED(hr)) ok(!count, "Unexpected attribute count.\n");
IMFMediaBuffer_Release(buffer); -} + hr = IMFSample_GetSampleFlags(sample, &flags); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/sample.c | 9 +++++++-- dlls/evr/tests/evr.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 668e675da2b..cd6cef001aa 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -1075,9 +1075,14 @@ static ULONG WINAPI surface_buffer_gs_Release(IMFGetService *iface)
static HRESULT WINAPI surface_buffer_gs_GetService(IMFGetService *iface, REFGUID service, REFIID riid, void **obj) { - FIXME("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj); + struct surface_buffer *buffer = impl_from_IMFGetService(iface);
- return E_NOTIMPL; + TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(service), debugstr_guid(riid), obj); + + if (IsEqualGUID(service, &MR_BUFFER_SERVICE)) + return IUnknown_QueryInterface(buffer->surface, riid, obj); + + return E_NOINTERFACE; }
static const IMFGetServiceVtbl surface_buffer_gs_vtbl = diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 69ee2d3d967..d0e39cb47c9 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -718,7 +718,7 @@ todo_wine
static void test_surface_sample(void) { - IDirect3DSurface9 *backbuffer = NULL; + IDirect3DSurface9 *backbuffer = NULL, *surface; IMFDesiredSample *desired_sample; IMFMediaBuffer *buffer, *buffer2; LONGLONG duration, time1, time2; @@ -870,6 +870,16 @@ static void test_surface_sample(void) ok(hr == S_OK, "Failed to get buffer count, hr %#x.\n", hr); ok(!count, "Unexpected attribute count.\n");
+ hr = MFGetService((IUnknown *)buffer, &MR_BUFFER_SERVICE, &IID_IDirect3DSurface9, (void **)&surface); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(surface == backbuffer, "Unexpected instance.\n"); + IDirect3DSurface9_Release(surface); + + hr = MFGetService((IUnknown *)buffer, &MR_BUFFER_SERVICE, &IID_IUnknown, (void **)&surface); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(surface == backbuffer, "Unexpected instance.\n"); + IDirect3DSurface9_Release(surface); + IMFMediaBuffer_Release(buffer);
hr = IMFSample_GetSampleFlags(sample, &flags);