Commit 782abff9 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Implement IWMOutputMediaProps_SetMediaType.

parent b3d6e0cf
......@@ -116,8 +116,18 @@ static HRESULT WINAPI output_props_GetMediaType(IWMOutputMediaProps *iface, WM_M
static HRESULT WINAPI output_props_SetMediaType(IWMOutputMediaProps *iface, WM_MEDIA_TYPE *mt)
{
FIXME("iface %p, mt %p, stub!\n", iface, mt);
return E_NOTIMPL;
const struct output_props *props = impl_from_IWMOutputMediaProps(iface);
TRACE("iface %p, mt %p.\n", iface, mt);
if (!mt)
return E_POINTER;
if (!IsEqualGUID(&props->mt.majortype, &mt->majortype))
return E_FAIL;
FreeMediaType((AM_MEDIA_TYPE *)&props->mt);
return CopyMediaType((AM_MEDIA_TYPE *)&props->mt, (AM_MEDIA_TYPE *)mt);
}
static HRESULT WINAPI output_props_GetStreamGroupName(IWMOutputMediaProps *iface, WCHAR *name, WORD *len)
......@@ -1754,6 +1764,7 @@ HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
struct output_props *props = unsafe_impl_from_IWMOutputMediaProps(props_iface);
struct wg_format format, pref_format;
struct wm_stream *stream;
int i;
strmbase_dump_media_type(&props->mt);
......@@ -1780,6 +1791,32 @@ HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
return NS_E_INCOMPATIBLE_FORMAT;
}
switch (pref_format.major_type)
{
case WG_MAJOR_TYPE_AUDIO:
if (format.u.audio.format == WG_AUDIO_FORMAT_UNKNOWN)
return NS_E_AUDIO_CODEC_NOT_INSTALLED;
if (format.u.audio.channels > pref_format.u.audio.channels)
return NS_E_AUDIO_CODEC_NOT_INSTALLED;
break;
case WG_MAJOR_TYPE_VIDEO:
for (i = 0; i < ARRAY_SIZE(video_formats); ++i)
if (format.u.video.format == video_formats[i])
break;
if (i == ARRAY_SIZE(video_formats))
return NS_E_INVALID_OUTPUT_FORMAT;
if (pref_format.u.video.width != format.u.video.width)
return NS_E_INVALID_OUTPUT_FORMAT;
if (pref_format.u.video.height != format.u.video.height)
return NS_E_INVALID_OUTPUT_FORMAT;
break;
default:
return NS_E_INCOMPATIBLE_FORMAT;
}
stream->format = format;
wg_parser_stream_enable(stream->wg_stream, &format);
......
......@@ -1295,12 +1295,10 @@ static void test_sync_reader_types(void)
debugstr_guid(&majortype), debugstr_guid(&majortype2));
hr = IWMOutputMediaProps_SetMediaType(output_props, NULL);
todo_wine
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
memset(mt2_buffer, 0, sizeof(mt2_buffer));
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == E_FAIL, "Got hr %#lx.\n", hr);
if (IsEqualGUID(&majortype, &MEDIATYPE_Audio))
......@@ -1309,22 +1307,18 @@ static void test_sync_reader_types(void)
init_audio_type(mt2, &MEDIASUBTYPE_IEEE_FLOAT, 32, format->nChannels * 2, format->nSamplesPerSec);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
todo_wine
ok(hr == NS_E_AUDIO_CODEC_NOT_INSTALLED, "Got hr %#lx.\n", hr);
init_audio_type(mt2, &MEDIASUBTYPE_PCM, 8, 1, 11025);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
init_audio_type(mt2, &MEDIASUBTYPE_IEEE_FLOAT, 32, format->nChannels, format->nSamplesPerSec / 4);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
......@@ -1336,14 +1330,12 @@ static void test_sync_reader_types(void)
init_video_type(mt2, &MEDIASUBTYPE_RGB32, 32, BI_RGB, &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
init_video_type(mt2, &MEDIASUBTYPE_NV12, 12, MAKEFOURCC('N','V','1','2'), &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
todo_wine
......@@ -1353,15 +1345,12 @@ static void test_sync_reader_types(void)
init_video_type(mt2, &MEDIASUBTYPE_RGB32, 32, BI_RGB, &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
todo_wine
ok(hr == NS_E_INVALID_OUTPUT_FORMAT, "Got hr %#lx.\n", hr);
}
hr = IWMOutputMediaProps_SetMediaType(output_props, mt);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
......@@ -2578,12 +2567,10 @@ static void test_async_reader_types(void)
debugstr_guid(&majortype), debugstr_guid(&majortype2));
hr = IWMOutputMediaProps_SetMediaType(output_props, NULL);
todo_wine
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
memset(mt2_buffer, 0, sizeof(mt2_buffer));
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == E_FAIL, "Got hr %#lx.\n", hr);
if (IsEqualGUID(&majortype, &MEDIATYPE_Audio))
......@@ -2592,22 +2579,18 @@ static void test_async_reader_types(void)
init_audio_type(mt2, &MEDIASUBTYPE_IEEE_FLOAT, 32, format->nChannels * 2, format->nSamplesPerSec);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
todo_wine
ok(hr == NS_E_AUDIO_CODEC_NOT_INSTALLED, "Got hr %#lx.\n", hr);
init_audio_type(mt2, &MEDIASUBTYPE_PCM, 8, 1, 11025);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
init_audio_type(mt2, &MEDIASUBTYPE_IEEE_FLOAT, 32, format->nChannels, format->nSamplesPerSec / 4);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
......@@ -2619,14 +2602,12 @@ static void test_async_reader_types(void)
init_video_type(mt2, &MEDIASUBTYPE_RGB32, 32, BI_RGB, &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
init_video_type(mt2, &MEDIASUBTYPE_NV12, 12, MAKEFOURCC('N','V','1','2'), &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
todo_wine
......@@ -2636,15 +2617,12 @@ static void test_async_reader_types(void)
init_video_type(mt2, &MEDIASUBTYPE_RGB32, 32, BI_RGB, &rect);
hr = IWMOutputMediaProps_SetMediaType(output_props, mt2);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
todo_wine
ok(hr == NS_E_INVALID_OUTPUT_FORMAT, "Got hr %#lx.\n", hr);
}
hr = IWMOutputMediaProps_SetMediaType(output_props, mt);
todo_wine
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IWMReader_SetOutputProps(reader, output_number, output_props);
ok(hr == S_OK, "Got hr %#lx.\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