diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 07c037505e1..be8fd4ecbfc 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -298,6 +298,16 @@ static HRESULT WINAPI multimedia_stream_GetFilter(IAMMultiMediaStream *iface, return S_OK; } +static void add_stream(struct multimedia_stream *mmstream, IAMMediaStream *stream, IMediaStream **ret_stream) +{ + IMediaStreamFilter_AddMediaStream(mmstream->filter, stream); + if (ret_stream) + { + *ret_stream = (IMediaStream *)stream; + IMediaStream_AddRef(*ret_stream); + } +} + static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *iface, IUnknown *stream_object, const MSPID *PurposeId, DWORD dwFlags, IMediaStream **ret_stream) { @@ -309,9 +319,6 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac TRACE("mmstream %p, stream_object %p, id %s, flags %#x, ret_stream %p.\n", This, stream_object, debugstr_guid(PurposeId), dwFlags, ret_stream); - if (!IsEqualGUID(PurposeId, &MSPID_PrimaryVideo) && !IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) - return MS_E_PURPOSEID; - if (IMediaStreamFilter_GetMediaStream(This->filter, PurposeId, &stream) == S_OK) { IMediaStream_Release(stream); @@ -343,19 +350,43 @@ static HRESULT WINAPI multimedia_stream_AddMediaStream(IAMMultiMediaStream *ifac return hr; } + if (stream_object) + { + hr = IUnknown_QueryInterface(stream_object, &IID_IAMMediaStream, (void **)&pStream); + if (SUCCEEDED(hr)) + { + MSPID stream_id; + hr = IAMMediaStream_GetInformation(pStream, &stream_id, NULL); + if (SUCCEEDED(hr)) + { + if (IsEqualGUID(PurposeId, &stream_id)) + { + add_stream(This, pStream, ret_stream); + hr = S_OK; + } + else + { + hr = MS_E_PURPOSEID; + } + } + + IAMMediaStream_Release(pStream); + + return hr; + } + } + if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) hr = ddraw_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream); - else + else if (IsEqualGUID(PurposeId, &MSPID_PrimaryAudio)) hr = audio_stream_create((IMultiMediaStream*)iface, PurposeId, stream_object, This->type, &pStream); + else + return MS_E_PURPOSEID; if (SUCCEEDED(hr)) { - /* Add stream to the media stream filter */ - IMediaStreamFilter_AddMediaStream(This->filter, pStream); - if (ret_stream) - *ret_stream = (IMediaStream *)pStream; - else - IAMMediaStream_Release(pStream); + add_stream(This, pStream, ret_stream); + IAMMediaStream_Release(pStream); } return hr; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a55884d8abf..09686cfcf4d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -684,21 +684,21 @@ static void test_add_stream(void) ok(hr == MS_E_PURPOSEID, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)&teststream, &test_mspid, 0, &stream); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(stream == (IMediaStream *)&teststream, "Streams didn't match.\n"); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(stream == (IMediaStream *)&teststream, "Streams didn't match.\n"); if (hr == S_OK) IMediaStream_Release(stream); todo_wine ok(teststream_mmstream == mmstream, "IAMMultiMediaStream objects didn't match.\n"); - todo_wine ok(teststream_filter == stream_filter, "IMediaStreamFilter objects didn't match.\n"); + ok(teststream_filter == stream_filter, "IMediaStreamFilter objects didn't match.\n"); todo_wine ok(!!teststream_graph, "Expected a non-NULL graph.\n"); check_enum_stream(mmstream, stream_filter, 0, video_stream); check_enum_stream(mmstream, stream_filter, 1, audio_stream); - todo_wine check_enum_stream(mmstream, stream_filter, 2, (IMediaStream *)&teststream); + check_enum_stream(mmstream, stream_filter, 2, (IMediaStream *)&teststream); check_enum_stream(mmstream, stream_filter, 3, NULL); check_get_stream(mmstream, stream_filter, &MSPID_PrimaryVideo, video_stream); check_get_stream(mmstream, stream_filter, &MSPID_PrimaryAudio, audio_stream); - todo_wine check_get_stream(mmstream, stream_filter, &test_mspid, (IMediaStream *)&teststream); + check_get_stream(mmstream, stream_filter, &test_mspid, (IMediaStream *)&teststream); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == MS_E_PURPOSEID, "Got hr %#x.\n", hr); @@ -839,7 +839,7 @@ static void test_add_stream(void) ok(hr == MS_E_PURPOSEID, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &test_mspid, AMMSF_ADDDEFAULTRENDERER, &audio_stream); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); IMediaStreamFilter_Release(stream_filter); ref = IAMMultiMediaStream_Release(mmstream);