Commit 970c1bc4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Implement IWMSyncReader::SetOutputProps().

parent 6fdae197
......@@ -102,6 +102,7 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format);
bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format);
BOOL init_gstreamer(void) DECLSPEC_HIDDEN;
......@@ -160,5 +161,7 @@ HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output,
IWMOutputMediaProps **props);
void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops);
HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream);
HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
IWMOutputMediaProps *props);
#endif /* __GST_PRIVATE_INCLUDED__ */
......@@ -540,7 +540,7 @@ static bool amt_to_wg_format_video(const AM_MEDIA_TYPE *mt, struct wg_format *fo
return false;
}
static bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format)
bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format)
{
memset(format, 0, sizeof(*format));
......
......@@ -140,6 +140,14 @@ static const struct IWMOutputMediaPropsVtbl output_props_vtbl =
output_props_GetConnectionName,
};
static struct output_props *unsafe_impl_from_IWMOutputMediaProps(IWMOutputMediaProps *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &output_props_vtbl);
return impl_from_IWMOutputMediaProps(iface);
}
static IWMOutputMediaProps *output_props_create(const struct wg_format *format)
{
struct output_props *object;
......@@ -1382,6 +1390,45 @@ HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output,
return *props ? S_OK : E_OUTOFMEMORY;
}
HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output,
IWMOutputMediaProps *props_iface)
{
struct output_props *props = unsafe_impl_from_IWMOutputMediaProps(props_iface);
struct wg_format format, pref_format;
struct wm_stream *stream;
strmbase_dump_media_type(&props->mt);
if (!amt_to_wg_format(&props->mt, &format))
{
ERR("Failed to convert media type to winegstreamer format.\n");
return E_FAIL;
}
EnterCriticalSection(&reader->cs);
if (!(stream = get_stream_by_output_number(reader, output)))
{
LeaveCriticalSection(&reader->cs);
return E_INVALIDARG;
}
wg_parser_stream_get_preferred_format(stream->wg_stream, &pref_format);
if (pref_format.major_type != format.major_type)
{
/* R.U.S.E sets the type of the wrong stream, apparently by accident. */
LeaveCriticalSection(&reader->cs);
WARN("Major types don't match; returning NS_E_INCOMPATIBLE_FORMAT.\n");
return NS_E_INCOMPATIBLE_FORMAT;
}
stream->format = format;
wg_parser_stream_enable(stream->wg_stream, &format);
LeaveCriticalSection(&reader->cs);
return S_OK;
}
void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops)
{
reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl;
......
......@@ -186,11 +186,13 @@ static HRESULT WINAPI WMSyncReader_OpenStream(IWMSyncReader2 *iface, IStream *st
return wm_reader_open_stream(&reader->reader, stream);
}
static HRESULT WINAPI WMSyncReader_SetOutputProps(IWMSyncReader2 *iface, DWORD output_num, IWMOutputMediaProps *output)
static HRESULT WINAPI WMSyncReader_SetOutputProps(IWMSyncReader2 *iface, DWORD output, IWMOutputMediaProps *props)
{
struct sync_reader *This = impl_from_IWMSyncReader2(iface);
FIXME("(%p)->(%u %p): stub!\n", This, output_num, output);
return E_NOTIMPL;
struct sync_reader *reader = impl_from_IWMSyncReader2(iface);
TRACE("reader %p, output %u, props %p.\n", reader, output, props);
return wm_reader_set_output_props(&reader->reader, output, props);
}
static HRESULT WINAPI WMSyncReader_SetOutputSetting(IWMSyncReader2 *iface, DWORD output_num, const WCHAR *name,
......
......@@ -789,14 +789,7 @@ static void test_sync_reader_types(void)
check_video_type(mt);
hr = IWMSyncReader_SetOutputProps(reader, output_number, output_props);
todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
if (hr != S_OK)
{
ref = IWMOutputMediaProps_Release(output_props);
ok(!ref, "Got outstanding refcount %d.\n", ref);
winetest_pop_context();
continue;
}
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IWMSyncReader_SetOutputProps(reader, 1 - output_number, output_props);
if (!i)
todo_wine ok(hr == ASF_E_BADMEDIATYPE, "Got hr %#x.\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