evr: Partially implement MFCreateVideoSampleFromSurface().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5abdd39838
commit
db8f859114
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue