mf: Validate new current type set for sample grabber.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8467b61a3e
commit
169d6b00bc
|
@ -599,15 +599,11 @@ static ULONG WINAPI sample_grabber_stream_type_handler_Release(IMFMediaTypeHandl
|
|||
return IMFStreamSink_Release(&stream->IMFStreamSink_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_stream_type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface,
|
||||
IMFMediaType *in_type, IMFMediaType **out_type)
|
||||
static HRESULT sample_grabber_stream_is_media_type_supported(struct sample_grabber_stream *stream, IMFMediaType *in_type)
|
||||
{
|
||||
struct sample_grabber_stream *stream = impl_from_IMFMediaTypeHandler(iface);
|
||||
const DWORD supported_flags = MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_TYPES;
|
||||
DWORD flags;
|
||||
|
||||
TRACE("%p, %p, %p.\n", iface, in_type, out_type);
|
||||
|
||||
if (!stream->sink)
|
||||
return MF_E_STREAMSINK_REMOVED;
|
||||
|
||||
|
@ -620,6 +616,16 @@ static HRESULT WINAPI sample_grabber_stream_type_handler_IsMediaTypeSupported(IM
|
|||
return (flags & supported_flags) == supported_flags ? S_OK : MF_E_INVALIDMEDIATYPE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_stream_type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface,
|
||||
IMFMediaType *in_type, IMFMediaType **out_type)
|
||||
{
|
||||
struct sample_grabber_stream *stream = impl_from_IMFMediaTypeHandler(iface);
|
||||
|
||||
TRACE("%p, %p, %p.\n", iface, in_type, out_type);
|
||||
|
||||
return sample_grabber_stream_is_media_type_supported(stream, in_type);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_stream_type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
|
||||
{
|
||||
TRACE("%p, %p.\n", iface, count);
|
||||
|
@ -647,14 +653,12 @@ static HRESULT WINAPI sample_grabber_stream_type_handler_SetCurrentMediaType(IMF
|
|||
IMFMediaType *media_type)
|
||||
{
|
||||
struct sample_grabber_stream *stream = impl_from_IMFMediaTypeHandler(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%p, %p.\n", iface, media_type);
|
||||
|
||||
if (!media_type)
|
||||
return E_POINTER;
|
||||
|
||||
if (!stream->sink)
|
||||
return MF_E_STREAMSINK_REMOVED;
|
||||
if (FAILED(hr = sample_grabber_stream_is_media_type_supported(stream, media_type)))
|
||||
return hr;
|
||||
|
||||
IMFMediaType_Release(stream->sink->media_type);
|
||||
stream->sink->media_type = media_type;
|
||||
|
|
|
@ -2000,14 +2000,20 @@ static void test_sample_grabber(void)
|
|||
hr = MFCreateSampleGrabberSinkActivate(NULL, &grabber_callback, &activate);
|
||||
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = MFCreateSampleGrabberSinkActivate(media_type, &grabber_callback, &activate);
|
||||
ok(hr == S_OK, "Failed to create grabber activate, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
|
||||
EXPECT_REF(media_type, 1);
|
||||
hr = MFCreateSampleGrabberSinkActivate(media_type, &grabber_callback, &activate);
|
||||
ok(hr == S_OK, "Failed to create grabber activate, hr %#x.\n", hr);
|
||||
EXPECT_REF(media_type, 2);
|
||||
|
||||
hr = IMFActivate_GetCount(activate, &count);
|
||||
ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
|
||||
ok(!count, "Unexpected count %u.\n", count);
|
||||
|
||||
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
|
||||
ok(hr == S_OK, "Failed to activate object, hr %#x.\n", hr);
|
||||
|
||||
|
@ -2136,11 +2142,27 @@ static void test_sample_grabber(void)
|
|||
hr = MFCreateMediaType(&media_type2);
|
||||
ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type2);
|
||||
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaType_SetGUID(media_type2, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type2);
|
||||
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaType_SetGUID(media_type2, &MF_MT_SUBTYPE, &MFAudioFormat_Float);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type2);
|
||||
ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaType_SetGUID(media_type2, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaType_SetUINT32(media_type2, &MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100);
|
||||
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, media_type2);
|
||||
ok(hr == S_OK, "Failed to get current type, hr %#x.\n", hr);
|
||||
IMFMediaType_Release(media_type);
|
||||
|
@ -2242,6 +2264,9 @@ static void test_sample_grabber(void)
|
|||
hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, NULL, NULL);
|
||||
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_SetCurrentMediaType(handler, NULL);
|
||||
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
|
||||
ok(hr == S_OK, "Failed to get type count, hr %#x.\n", hr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue