From: Derek Lesho dlesho@codeweavers.com
Signed-off-by: Derek Lesho dlesho@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 19 ++++++++++++------- dlls/mfplat/tests/mfplat.c | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 1ebd443131..264c10e5cf 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -3287,22 +3287,27 @@ static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length) return E_NOTIMPL; }
-static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position) +static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position) { mfbytestream *This = impl_from_IMFByteStream(iface);
- FIXME("%p, %p\n", This, position); + FIXME("%p, %s\n", This, wine_dbgstr_longlong(position));
return E_NOTIMPL; }
-static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position) +static HRESULT WINAPI bytestream_file_GetCurrentPosition(IMFByteStream *iface, QWORD *position) { - mfbytestream *This = impl_from_IMFByteStream(iface); + struct bytestream *stream = impl_from_IMFByteStream(iface);
- FIXME("%p, %s\n", This, wine_dbgstr_longlong(position)); + TRACE("%p, %p.\n", iface, position);
- return E_NOTIMPL; + if (!position) + return E_INVALIDARG; + + *position = stream->position; + + return S_OK; }
static HRESULT WINAPI bytestream_file_GetLength(IMFByteStream *iface, QWORD *length) @@ -3453,7 +3458,7 @@ static const IMFByteStreamVtbl bytestream_file_vtbl = bytestream_GetCapabilities, bytestream_file_GetLength, mfbytestream_SetLength, - mfbytestream_GetCurrentPosition, + bytestream_file_GetCurrentPosition, mfbytestream_SetCurrentPosition, bytestream_file_IsEndOfStream, bytestream_file_Read, diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 7ec0b01982..67123d0b69 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -1340,15 +1340,16 @@ static void test_MFCreateMFByteStreamOnStream(void) static void test_file_stream(void) { IMFByteStream *bytestream, *bytestream2; + QWORD bytestream_length, position; IMFAttributes *attributes = NULL; MF_ATTRIBUTE_TYPE item_type; - QWORD bytestream_length; WCHAR pathW[MAX_PATH]; DWORD caps, count; WCHAR *filename; IUnknown *unk; HRESULT hr; WCHAR *str; + BOOL eos;
static const WCHAR newfilename[] = {'n','e','w','.','m','p','4',0};
@@ -1415,6 +1416,23 @@ static void test_file_stream(void) ok(hr == S_OK, "Failed to get bytestream length, hr %#x.\n", hr); ok(bytestream_length > 0, "Unexpected bytestream length %s.\n", wine_dbgstr_longlong(bytestream_length));
+ hr = IMFByteStream_SetCurrentPosition(bytestream, bytestream_length); + ok(hr == S_OK, "Failed to set bytestream position, hr %#x.\n", hr); + + hr = IMFByteStream_IsEndOfStream(bytestream, &eos); + ok(hr == S_OK, "Failed query end of stream, hr %#x.\n", hr); + ok(eos == TRUE, "Unexpected IsEndOfStream result, %u.\n", eos); + + hr = IMFByteStream_SetCurrentPosition(bytestream, 2 * bytestream_length); + ok(hr == S_OK, "Failed to set bytestream position, hr %#x.\n", hr); + + hr = IMFByteStream_GetCurrentPosition(bytestream, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMFByteStream_GetCurrentPosition(bytestream, &position); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(position == 2 * bytestream_length, "Unexpected position.\n"); + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &bytestream2); ok(hr == S_OK, "got 0x%08x\n", hr);