[PATCH 8/9] mfplat: Implement IMFByteStream::GetLength() for file streams.

Nikolay Sivov nsivov at codeweavers.com
Tue Feb 11 03:19:10 CST 2020


From: Derek Lesho <dlesho at codeweavers.com>

Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/mfplat/main.c         | 27 +++++++++++++++++++--------
 dlls/mfplat/tests/mfplat.c | 10 ++++++++++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index e96a972909..1ebd443131 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,24 @@ 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;
+
+    TRACE("%p, %p.\n", iface, length);
+
+    if (!length)
+        return E_INVALIDARG;
+
+    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 +3451,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 56aa23c68c..7ec0b01982 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -1342,6 +1342,7 @@ static void test_file_stream(void)
     IMFByteStream *bytestream, *bytestream2;
     IMFAttributes *attributes = NULL;
     MF_ATTRIBUTE_TYPE item_type;
+    QWORD bytestream_length;
     WCHAR pathW[MAX_PATH];
     DWORD caps, count;
     WCHAR *filename;
@@ -1405,6 +1406,15 @@ static void test_file_stream(void)
 
     IMFAttributes_Release(attributes);
 
+    /* Length. */
+    hr = IMFByteStream_GetLength(bytestream, NULL);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+    bytestream_length = 0;
+    hr = IMFByteStream_GetLength(bytestream, &bytestream_length);
+    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 = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST,
                       MF_FILEFLAGS_NONE, filename, &bytestream2);
     ok(hr == S_OK, "got 0x%08x\n", hr);
-- 
2.25.0




More information about the wine-devel mailing list