Commit e756c28b authored by Derek Lesho's avatar Derek Lesho Committed by Alexandre Julliard

mfplat: Implement IMFByteStream::GetLength() for file streams.

parent 19519f02
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment