Commit 1e053810 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mfplat/mediatype: Implement MFCreateMediaTypeFromRepresentation.

parent a4fb357c
......@@ -4334,3 +4334,29 @@ HRESULT WINAPI MFInitMediaTypeFromAMMediaType(IMFMediaType *media_type, const AM
return hr;
}
/***********************************************************************
* MFCreateMediaTypeFromRepresentation (mfplat.@)
*/
HRESULT WINAPI MFCreateMediaTypeFromRepresentation(GUID guid_representation, void *representation,
IMFMediaType **media_type)
{
HRESULT hr;
TRACE("%s, %p, %p\n", debugstr_guid(&guid_representation), representation, media_type);
if (!IsEqualGUID(&guid_representation, &AM_MEDIA_TYPE_REPRESENTATION))
return MF_E_UNSUPPORTED_REPRESENTATION;
if (!representation || !media_type)
return E_INVALIDARG;
if (FAILED(hr = MFCreateMediaType(media_type)))
return hr;
if (FAILED(hr = MFInitMediaTypeFromAMMediaType(*media_type, representation)))
{
IMFMediaType_Release(*media_type);
*media_type = NULL;
}
return hr;
}
......@@ -59,7 +59,7 @@
@ stub MFCreateMediaBufferWrapper
@ stdcall MFCreateMediaEvent(long ptr long ptr ptr)
@ stdcall MFCreateMediaType(ptr)
@ stub MFCreateMediaTypeFromRepresentation
@ stdcall MFCreateMediaTypeFromRepresentation(int128 ptr ptr)
@ stdcall MFCreateMemoryBuffer(long ptr)
@ stub MFCreateMemoryStream
@ stdcall MFCreatePathFromURL(wstr ptr)
......
......@@ -8524,6 +8524,56 @@ static void test_IMFMediaType_GetRepresentation(void)
IMFMediaType_Release(media_type);
}
static void test_MFCreateMediaTypeFromRepresentation(void)
{
IMFMediaType *media_type;
AM_MEDIA_TYPE amt = {0};
WAVEFORMATEX wfx = {0};
HRESULT hr;
GUID guid;
hr = MFCreateMediaTypeFromRepresentation(GUID_NULL, &amt, &media_type);
ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr);
hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, NULL, &media_type);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &amt, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &amt, &media_type);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (hr == S_OK)
{
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(IsEqualGUID(&guid, &GUID_NULL), "got %s.\n", debugstr_guid(&guid));
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(IsEqualGUID(&guid, &GUID_NULL), "got %s.\n", debugstr_guid(&guid));
IMFMediaType_Release(media_type);
}
amt.formattype = FORMAT_WaveFormatEx;
amt.majortype = MFMediaType_Audio;
amt.subtype = MFAudioFormat_PCM;
amt.pbFormat = (BYTE *)&wfx;
amt.cbFormat = sizeof(wfx);
hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &amt, &media_type);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(IsEqualGUID(&guid, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&guid));
memset(&guid, 0xcd, sizeof(guid));
hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(IsEqualGUID(&guid, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&guid));
IMFMediaType_Release(media_type);
}
static void test_MFCreateDXSurfaceBuffer(void)
{
IDirect3DSurface9 *backbuffer = NULL, *surface;
......@@ -11798,6 +11848,7 @@ START_TEST(mfplat)
test_MFCreateAMMediaTypeFromMFMediaType();
test_MFInitMediaTypeFromMFVideoFormat();
test_IMFMediaType_GetRepresentation();
test_MFCreateMediaTypeFromRepresentation();
test_MFCreateDXSurfaceBuffer();
test_MFCreateTrackedSample();
test_MFFrameRateToAverageTimePerFrame();
......
......@@ -549,6 +549,8 @@ HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HR
HRESULT WINAPI MFCreateMediaType(IMFMediaType **type);
HRESULT WINAPI MFCreateAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format_type, AM_MEDIA_TYPE **am_type);
HRESULT WINAPI MFCreateMFVideoFormatFromMFMediaType(IMFMediaType *media_type, MFVIDEOFORMAT **video_format, UINT32 *size);
HRESULT WINAPI MFCreateMediaTypeFromRepresentation(GUID guid_representation, void *representation,
IMFMediaType **media_type);
HRESULT WINAPI MFCreateSample(IMFSample **sample);
HRESULT WINAPI MFCreateTempFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags,
IMFByteStream **bytestream);
......
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