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

winegstreamer: Keep input / output stream info in struct resampler.

And calculate the sizes when media type is successfully changed.
parent d98eae89
......@@ -43,8 +43,11 @@ struct resampler
IPropertyStore IPropertyStore_iface;
IUnknown *outer;
LONG refcount;
IMFMediaType *input_type;
MFT_INPUT_STREAM_INFO input_info;
IMFMediaType *output_type;
MFT_OUTPUT_STREAM_INFO output_info;
struct wg_transform *wg_transform;
struct wg_sample_queue *wg_sample_queue;
......@@ -191,44 +194,32 @@ static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_si
static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info)
{
struct resampler *impl = impl_from_IMFTransform(iface);
UINT32 block_alignment;
HRESULT hr;
TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
if (!impl->input_type || !impl->output_type)
{
memset(info, 0, sizeof(*info));
return MF_E_TRANSFORM_TYPE_NOT_SET;
}
if (FAILED(hr = IMFMediaType_GetUINT32(impl->input_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment)))
return hr;
info->dwFlags = 0;
info->cbSize = block_alignment;
info->cbAlignment = 1;
info->hnsMaxLatency = 0;
info->cbMaxLookahead = 0;
*info = impl->input_info;
return S_OK;
}
static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
{
struct resampler *impl = impl_from_IMFTransform(iface);
UINT32 block_alignment;
HRESULT hr;
TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
if (!impl->input_type || !impl->output_type)
{
memset(info, 0, sizeof(*info));
return MF_E_TRANSFORM_TYPE_NOT_SET;
}
if (FAILED(hr = IMFMediaType_GetUINT32(impl->output_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment)))
return hr;
info->dwFlags = 0;
info->cbSize = block_alignment;
info->cbAlignment = 1;
*info = impl->output_info;
return S_OK;
}
......@@ -367,9 +358,6 @@ static HRESULT check_media_type(IMFMediaType *type)
if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) ||
item_type != MF_ATTRIBUTE_UINT32)
return MF_E_INVALIDMEDIATYPE;
return S_OK;
}
......@@ -377,12 +365,15 @@ static HRESULT check_media_type(IMFMediaType *type)
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
struct resampler *impl = impl_from_IMFTransform(iface);
UINT32 block_alignment;
HRESULT hr;
TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
if (FAILED(hr = check_media_type(type)))
return hr;
if (FAILED(hr = IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment)))
return MF_E_INVALIDMEDIATYPE;
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
......@@ -395,9 +386,12 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
impl->output_type = NULL;
}
if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->input_type)))
if (SUCCEEDED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->input_type)))
impl->input_info.cbSize = block_alignment;
else
{
IMFMediaType_Release(impl->input_type);
impl->input_info.cbSize = 0;
impl->input_type = NULL;
}
......@@ -407,6 +401,7 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
struct resampler *impl = impl_from_IMFTransform(iface);
UINT32 block_alignment;
HRESULT hr;
TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
......@@ -416,6 +411,8 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
if (FAILED(hr = check_media_type(type)))
return hr;
if (FAILED(hr = IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment)))
return MF_E_INVALIDMEDIATYPE;
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
......@@ -428,10 +425,12 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
if (FAILED(hr = try_create_wg_transform(impl)))
goto failed;
impl->output_info.cbSize = block_alignment;
return hr;
failed:
IMFMediaType_Release(impl->output_type);
impl->output_info.cbSize = 0;
impl->output_type = NULL;
return hr;
}
......@@ -940,6 +939,9 @@ HRESULT resampler_create(IUnknown *outer, IUnknown **out)
impl->refcount = 1;
impl->outer = outer ? outer : &impl->IUnknown_inner;
impl->input_info.cbAlignment = 1;
impl->output_info.cbAlignment = 1;
*out = &impl->IUnknown_inner;
TRACE("Created %p\n", *out);
return S_OK;
......
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