Signed-off-by: Derek Lesho dlesho@codeweavers.com --- v2: - Fix premature removal of code. - Add tests. --- dlls/mfplat/main.c | 22 ++++++++++++++-------- dlls/mfplat/tests/mfplat.c | 5 +++++ 2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index e96a972909..85d676a0d6 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -3278,13 +3278,6 @@ static HRESULT WINAPI bytestream_GetCapabilities(IMFByteStream *iface, DWORD *ca return S_OK; }
-static HRESULT WINAPI mfbytestream_GetLength(IMFByteStream *iface, QWORD *length) -{ - FIXME("%p, %p.\n", iface, length); - - return E_NOTIMPL; -} - static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length) { mfbytestream *This = impl_from_IMFByteStream(iface); @@ -3312,6 +3305,19 @@ static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWOR return E_NOTIMPL; }
+static HRESULT WINAPI bytestream_file_GetLength(IMFByteStream *iface, QWORD *length) +{ + struct bytestream *stream = impl_from_IMFByteStream(iface); + LARGE_INTEGER li; + + if (GetFileSizeEx(stream->hfile, &li)) + *length = li.QuadPart; + else + return HRESULT_FROM_WIN32(GetLastError()); + + return S_OK; +} + static HRESULT WINAPI bytestream_file_IsEndOfStream(IMFByteStream *iface, BOOL *ret) { struct bytestream *stream = impl_from_IMFByteStream(iface); @@ -3440,7 +3446,7 @@ static const IMFByteStreamVtbl bytestream_file_vtbl = bytestream_AddRef, bytestream_Release, bytestream_GetCapabilities, - mfbytestream_GetLength, + bytestream_file_GetLength, mfbytestream_SetLength, mfbytestream_GetCurrentPosition, mfbytestream_SetCurrentPosition, diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 43ca186236..81219adff4 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -1524,6 +1524,7 @@ static void test_file_stream(void) DWORD caps, count; WCHAR *filename; IUnknown *unk; + QWORD bytestream_length; HRESULT hr; WCHAR *str;
@@ -1583,6 +1584,10 @@ static void test_file_stream(void)
IMFAttributes_Release(attributes);
+ hr = IMFByteStream_GetLength(bytestream, &bytestream_length); + ok(hr == S_OK, "Failed to get bytestream length, hr %#x.\n", hr); + ok(bytestream_length == 1554, "Unexpected bytestream length %s.\n", wine_dbgstr_longlong(bytestream_length)); + 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);