Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/tests/amstream.c | 175 ++++++++++++++++++++++++++++----- 1 file changed, 151 insertions(+), 24 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 000bb40537f..75862e70910 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1039,34 +1039,10 @@ static void test_media_streams(void) ok(nb_pins == expected_nb_pins, "Number of pins is %u instead of %u\n", nb_pins, expected_nb_pins); for (i = 0; i < min(nb_pins, expected_nb_pins); i++) { - IEnumMediaTypes* enum_media_types; - AM_MEDIA_TYPE* media_types[10]; - ULONG nb_media_types; IPin* pin; - PIN_INFO info; - WCHAR id[40]; - - /* Pin name is "I{guid MSPID_PrimaryVideo or MSPID_PrimaryAudio}" */ - id[0] = 'I'; - StringFromGUID2(i ? &MSPID_PrimaryAudio : &MSPID_PrimaryVideo, id + 1, 39);
hr = IPin_ConnectedTo(pins[i], &pin); ok(hr == VFW_E_NOT_CONNECTED, "IPin_ConnectedTo returned: %x\n", hr); - hr = IPin_QueryPinInfo(pins[i], &info); - ok(hr == S_OK, "IPin_QueryPinInfo returned: %x\n", hr); - IBaseFilter_Release(info.pFilter); - ok(info.dir == PINDIR_INPUT, "Pin direction is %u instead of %u\n", info.dir, PINDIR_INPUT); - ok(!lstrcmpW(info.achName, id), "Pin name is %s instead of %s\n", wine_dbgstr_w(info.achName), wine_dbgstr_w(id)); - hr = IPin_EnumMediaTypes(pins[i], &enum_media_types); - ok(hr == S_OK, "IPin_EnumMediaTypes returned: %x\n", hr); - hr = IEnumMediaTypes_Next(enum_media_types, ARRAY_SIZE(media_types), media_types, &nb_media_types); - ok(SUCCEEDED(hr), "IEnumMediaTypes_Next returned: %x\n", hr); - ok(nb_media_types > 0, "nb_media_types should be >0\n"); - IEnumMediaTypes_Release(enum_media_types); - hr = IMediaStream_QueryInterface(i ? audio_stream : video_stream, &IID_IPin, (void **)&pin); - ok(hr == S_OK, "IMediaStream_QueryInterface returned: %x\n", hr); - ok(pin == pins[i], "Pin is %p instead of %p\n", pins[i], pin); - IPin_Release(pin); IPin_Release(pins[i]); } IEnumPins_Release(enum_pins); @@ -1780,6 +1756,156 @@ static void test_enum_media_types(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_media_types(void) +{ + static const VIDEOINFOHEADER req_vih = {}; + static const WAVEFORMATEX expect_wfx = + { + .wFormatTag = WAVE_FORMAT_PCM, + .nChannels = 1, + .nSamplesPerSec = 11025, + .nAvgBytesPerSec = 11025 * 2, + .nBlockAlign = 2, + .wBitsPerSample = 16, + .cbSize = 0, + }; + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IEnumMediaTypes *enummt; + IMediaStream *stream; + AM_MEDIA_TYPE *pmt; + ULONG ref, count; + unsigned int i; + HRESULT hr; + IPin *pin; + + static const GUID *rejected_subtypes[] = + { + &MEDIASUBTYPE_RGB1, + &MEDIASUBTYPE_RGB4, + &MEDIASUBTYPE_RGB565, + &MEDIASUBTYPE_RGB555, + &MEDIASUBTYPE_RGB24, + &MEDIASUBTYPE_RGB32, + &MEDIASUBTYPE_ARGB32, + &MEDIASUBTYPE_ARGB1555, + &MEDIASUBTYPE_ARGB4444, + &GUID_NULL, + }; + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EnumMediaTypes(pin, &enummt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Video), "Got major type %s\n", + wine_dbgstr_guid(&pmt->majortype)); + todo_wine ok(IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB8), "Got subtype %s\n", + wine_dbgstr_guid(&pmt->subtype)); + todo_wine ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); + ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); + todo_wine ok(pmt->lSampleSize == 10000, "Got sample size %u.\n", pmt->lSampleSize); + ok(IsEqualGUID(&pmt->formattype, &GUID_NULL), "Got format type %s.\n", + wine_dbgstr_guid(&pmt->formattype)); + ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); + + hr = IPin_QueryAccept(pin, pmt); + todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + + pmt->formattype = FORMAT_VideoInfo; + pmt->cbFormat = sizeof(VIDEOINFOHEADER); + pmt->pbFormat = (BYTE *)&req_vih; + hr = IPin_QueryAccept(pin, pmt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + pmt->bFixedSizeSamples = FALSE; + pmt->bTemporalCompression = TRUE; + pmt->lSampleSize = 123; + hr = IPin_QueryAccept(pin, pmt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + pmt->majortype = MEDIATYPE_NULL; + hr = IPin_QueryAccept(pin, pmt); + todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + pmt->majortype = MEDIATYPE_Audio; + hr = IPin_QueryAccept(pin, pmt); + todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + pmt->majortype = MEDIATYPE_Stream; + hr = IPin_QueryAccept(pin, pmt); + todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + pmt->majortype = MEDIATYPE_Video; + + for (i = 0; i < ARRAY_SIZE(rejected_subtypes); ++i) + { + pmt->subtype = *rejected_subtypes[i]; + hr = IPin_QueryAccept(pin, pmt); + todo_wine ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x for subtype %s.\n", + hr, wine_dbgstr_guid(rejected_subtypes[i])); + } + + CoTaskMemFree(pmt); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumMediaTypes_Release(enummt); + IPin_Release(pin); + IMediaStream_Release(stream); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EnumMediaTypes(pin, &enummt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(count == 1, "Got count %u.\n", count); + ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Audio), "Got major type %s\n", + wine_dbgstr_guid(&pmt->majortype)); + todo_wine ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s\n", + wine_dbgstr_guid(&pmt->subtype)); + todo_wine ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); + ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); + todo_wine ok(pmt->lSampleSize == 2, "Got sample size %u.\n", pmt->lSampleSize); + ok(IsEqualGUID(&pmt->formattype, &FORMAT_WaveFormatEx), "Got format type %s.\n", + wine_dbgstr_guid(&pmt->formattype)); + ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); + ok(pmt->cbFormat == sizeof(WAVEFORMATEX), "Got format size %u.\n", pmt->cbFormat); + ok(!memcmp(pmt->pbFormat, &expect_wfx, sizeof(WAVEFORMATEX)), "Format blocks didn't match.\n"); + + hr = IPin_QueryAccept(pin, pmt); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + } + + CoTaskMemFree(pmt); + + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumMediaTypes_Release(enummt); + IPin_Release(pin); + IMediaStream_Release(stream); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_IDirectDrawStreamSample(void) { DDSURFACEDESC desc = { sizeof(desc) }; @@ -2158,6 +2284,7 @@ START_TEST(amstream) test_pin_info(); test_initialize(); test_enum_media_types(); + test_media_types(); test_IDirectDrawStreamSample();
file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/Makefile.in | 3 +- dlls/amstream/audiostream.c | 701 ++++++++++++++++++ .../amstream/{mediastream.c => ddrawstream.c} | 690 +---------------- 3 files changed, 705 insertions(+), 689 deletions(-) create mode 100644 dlls/amstream/audiostream.c rename dlls/amstream/{mediastream.c => ddrawstream.c} (56%)
diff --git a/dlls/amstream/Makefile.in b/dlls/amstream/Makefile.in index 0b278f47a69..6320a8407d4 100644 --- a/dlls/amstream/Makefile.in +++ b/dlls/amstream/Makefile.in @@ -5,9 +5,10 @@ EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ audiodata.c \ + audiostream.c \ + ddrawstream.c \ filter.c \ main.c \ - mediastream.c \ multimedia.c
IDL_SRCS = amstream_classes.idl diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c new file mode 100644 index 00000000000..6888137f8cf --- /dev/null +++ b/dlls/amstream/audiostream.c @@ -0,0 +1,701 @@ +/* + * Primary audio stream + * + * Copyright 2012 Christian Costa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS +#include "amstream_private.h" +#include "wine/debug.h" +#include "wine/strmbase.h" + +WINE_DEFAULT_DEBUG_CHANNEL(amstream); + +typedef struct { + IAudioStreamSample IAudioStreamSample_iface; + LONG ref; + IMediaStream *parent; + IAudioData *audio_data; +} IAudioStreamSampleImpl; + +static inline IAudioStreamSampleImpl *impl_from_IAudioStreamSample(IAudioStreamSample *iface) +{ + return CONTAINING_RECORD(iface, IAudioStreamSampleImpl, IAudioStreamSample_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI IAudioStreamSampleImpl_QueryInterface(IAudioStreamSample *iface, + REFIID riid, void **ret_iface) +{ + TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IStreamSample) || + IsEqualGUID(riid, &IID_IAudioStreamSample)) + { + IAudioStreamSample_AddRef(iface); + *ret_iface = iface; + return S_OK; + } + + *ret_iface = NULL; + + ERR("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ret_iface); + return E_NOINTERFACE; +} + +static ULONG WINAPI IAudioStreamSampleImpl_AddRef(IAudioStreamSample *iface) +{ + IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(): new ref = %u\n", iface, ref); + + return ref; +} + +static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface) +{ + IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(): new ref = %u\n", iface, ref); + + if (!ref) + HeapFree(GetProcessHeap(), 0, This); + + return ref; +} + +/*** IStreamSample methods ***/ +static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream) +{ + FIXME("(%p)->(%p): stub\n", iface, media_stream); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time, + STREAM_TIME *end_time, STREAM_TIME *current_time) +{ + FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample *iface, const STREAM_TIME *start_time, + const STREAM_TIME *end_time) +{ + FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, DWORD flags, HANDLE event, + PAPCFUNC func_APC, DWORD APC_data) +{ + FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds) +{ + FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds); + + return E_NOTIMPL; +} + +/*** IAudioStreamSample methods ***/ +static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data) +{ + FIXME("(%p)->(%p): stub\n", iface, audio_data); + + return E_NOTIMPL; +} + +static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl = +{ + /*** IUnknown methods ***/ + IAudioStreamSampleImpl_QueryInterface, + IAudioStreamSampleImpl_AddRef, + IAudioStreamSampleImpl_Release, + /*** IStreamSample methods ***/ + IAudioStreamSampleImpl_GetMediaStream, + IAudioStreamSampleImpl_GetSampleTimes, + IAudioStreamSampleImpl_SetSampleTimes, + IAudioStreamSampleImpl_Update, + IAudioStreamSampleImpl_CompletionStatus, + /*** IAudioStreamSample methods ***/ + IAudioStreamSampleImpl_GetAudioData +}; + +static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample) +{ + IAudioStreamSampleImpl *object; + + TRACE("(%p)\n", audio_stream_sample); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioStreamSampleImpl)); + if (!object) + return E_OUTOFMEMORY; + + object->IAudioStreamSample_iface.lpVtbl = &AudioStreamSample_Vtbl; + object->ref = 1; + object->parent = (IMediaStream*)parent; + object->audio_data = audio_data; + + *audio_stream_sample = &object->IAudioStreamSample_iface; + + return S_OK; +} + +struct AudioMediaStreamImpl; + +typedef struct { + BaseInputPin pin; + struct AudioMediaStreamImpl *parent; +} AudioMediaStreamInputPin; + +typedef struct AudioMediaStreamImpl { + IAMMediaStream IAMMediaStream_iface; + IAudioMediaStream IAudioMediaStream_iface; + LONG ref; + IMultiMediaStream* parent; + MSPID purpose_id; + STREAM_TYPE stream_type; + AudioMediaStreamInputPin *input_pin; + CRITICAL_SECTION critical_section; +} AudioMediaStreamImpl; + +static inline AudioMediaStreamImpl *impl_from_AudioMediaStream_IAMMediaStream(IAMMediaStream *iface) +{ + return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAMMediaStream_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMediaStream *iface, + REFIID riid, void **ret_iface) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IMediaStream) || + IsEqualGUID(riid, &IID_IAMMediaStream)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = iface; + return S_OK; + } + else if (IsEqualGUID(riid, &IID_IAudioMediaStream)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->IAudioMediaStream_iface; + return S_OK; + } + else if (IsEqualGUID(riid, &IID_IPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.pin.IPin_iface; + return S_OK; + } + else if (IsEqualGUID(riid, &IID_IMemInputPin)) + { + IAMMediaStream_AddRef(iface); + *ret_iface = &This->input_pin->pin.IMemInputPin_iface; + return S_OK; + } + + ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ret_iface); + return E_NOINTERFACE; +} + +static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *iface) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); + + return ref; +} + +static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *iface) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); + + if (!ref) + { + BaseInputPin_Destroy((BaseInputPin *)This->input_pin); + DeleteCriticalSection(&This->critical_section); + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +/*** IMediaStream methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, + IMultiMediaStream** multi_media_stream) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + TRACE("(%p/%p)->(%p)\n", This, iface, multi_media_stream); + + if (!multi_media_stream) + return E_POINTER; + + IMultiMediaStream_AddRef(This->parent); + *multi_media_stream = This->parent; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMediaStream *iface, + MSPID *purpose_id, STREAM_TYPE *type) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + TRACE("(%p/%p)->(%p,%p)\n", This, iface, purpose_id, type); + + if (purpose_id) + *purpose_id = This->purpose_id; + if (type) + *type = This->stream_type; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, + IMediaStream *pStreamThatHasDesiredFormat, DWORD flags) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, flags); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMediaStream *iface, + DWORD flags, IStreamSample **sample) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, flags, sample); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, + IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, existing_sample, flags, sample); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%x) stub!\n", This, iface, flags); + + return S_FALSE; +} + +/*** IAMMediaStream methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, + REFMSPID purpose_id, const STREAM_TYPE stream_type) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%p,%x,%p,%u) stub!\n", This, iface, source_object, flags, purpose_id, stream_type); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%u) stub!\n", This, iface, state); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *am_multi_media_stream) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%p) stub!\n", This, iface, am_multi_media_stream); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *media_stream_filter) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter); + + This->input_pin->pin.pin.pinInfo.pFilter = (IBaseFilter *)media_stream_filter; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) +{ + AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); + + FIXME("(%p/%p)->(%p) stub!\n", This, iface, filtergraph); + + return S_FALSE; +} + +static const struct IAMMediaStreamVtbl AudioMediaStreamImpl_IAMMediaStream_Vtbl = +{ + /*** IUnknown methods ***/ + AudioMediaStreamImpl_IAMMediaStream_QueryInterface, + AudioMediaStreamImpl_IAMMediaStream_AddRef, + AudioMediaStreamImpl_IAMMediaStream_Release, + /*** IMediaStream methods ***/ + AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream, + AudioMediaStreamImpl_IAMMediaStream_GetInformation, + AudioMediaStreamImpl_IAMMediaStream_SetSameFormat, + AudioMediaStreamImpl_IAMMediaStream_AllocateSample, + AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample, + AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream, + /*** IAMMediaStream methods ***/ + AudioMediaStreamImpl_IAMMediaStream_Initialize, + AudioMediaStreamImpl_IAMMediaStream_SetState, + AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream, + AudioMediaStreamImpl_IAMMediaStream_JoinFilter, + AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph +}; + +static inline AudioMediaStreamImpl *impl_from_IAudioMediaStream(IAudioMediaStream *iface) +{ + return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAudioMediaStream_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface, + REFIID riid, void **ret_iface) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); + return IAMMediaStream_QueryInterface(&This->IAMMediaStream_iface, riid, ret_iface); +} + +static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_AddRef(IAudioMediaStream *iface) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + TRACE("(%p/%p)\n", iface, This); + return IAMMediaStream_AddRef(&This->IAMMediaStream_iface); +} + +static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaStream *iface) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + TRACE("(%p/%p)\n", iface, This); + return IAMMediaStream_Release(&This->IAMMediaStream_iface); +} + +/*** IMediaStream methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream(IAudioMediaStream *iface, + IMultiMediaStream **multi_media_stream) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + TRACE("(%p/%p)->(%p)\n", iface, This, multi_media_stream); + + if (!multi_media_stream) + return E_POINTER; + + IMultiMediaStream_AddRef(This->parent); + *multi_media_stream = This->parent; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAudioMediaStream *iface, + MSPID *purpose_id, STREAM_TYPE *type) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + TRACE("(%p/%p)->(%p,%p)\n", iface, This, purpose_id, type); + + if (purpose_id) + *purpose_id = This->purpose_id; + if (type) + *type = This->stream_type; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudioMediaStream *iface, + IMediaStream *stream_format, DWORD flags) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%p,%x) stub!\n", iface, This, stream_format, flags); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAudioMediaStream *iface, + DWORD flags, IStreamSample **sample) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%x,%p) stub!\n", iface, This, flags, sample); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample(IAudioMediaStream *iface, + IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%p,%x,%p) stub!\n", iface, This, existing_sample, flags, sample); + + return S_FALSE; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAudioMediaStream *iface, + DWORD flags) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%x) stub!\n", iface, This, flags); + + return S_FALSE; +} + +/*** IAudioMediaStream methods ***/ +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current); + + if (!wave_format_current) + return E_POINTER; + + return MS_E_NOSTREAM; + +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format); + + return E_NOTIMPL; +} + +static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data, + DWORD flags, IAudioStreamSample **sample) +{ + AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); + + TRACE("(%p/%p)->(%p,%u,%p)\n", iface, This, audio_data, flags, sample); + + if (!audio_data) + return E_POINTER; + + return audiostreamsample_create(iface, audio_data, sample); +} + +static const struct IAudioMediaStreamVtbl AudioMediaStreamImpl_IAudioMediaStream_Vtbl = +{ + /*** IUnknown methods ***/ + AudioMediaStreamImpl_IAudioMediaStream_QueryInterface, + AudioMediaStreamImpl_IAudioMediaStream_AddRef, + AudioMediaStreamImpl_IAudioMediaStream_Release, + /*** IMediaStream methods ***/ + AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream, + AudioMediaStreamImpl_IAudioMediaStream_GetInformation, + AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat, + AudioMediaStreamImpl_IAudioMediaStream_AllocateSample, + AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample, + AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream, + /*** IAudioMediaStream methods ***/ + AudioMediaStreamImpl_IAudioMediaStream_GetFormat, + AudioMediaStreamImpl_IAudioMediaStream_SetFormat, + AudioMediaStreamImpl_IAudioMediaStream_CreateSample +}; + +static inline AudioMediaStreamInputPin *impl_from_AudioMediaStreamInputPin_IPin(IPin *iface) +{ + return CONTAINING_RECORD(iface, AudioMediaStreamInputPin, pin.pin.IPin_iface); +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI AudioMediaStreamInputPin_IPin_QueryInterface(IPin *iface, REFIID riid, void **ret_iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_QueryInterface(&This->parent->IAMMediaStream_iface, riid, ret_iface); +} + +static ULONG WINAPI AudioMediaStreamInputPin_IPin_AddRef(IPin *iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_AddRef(&This->parent->IAMMediaStream_iface); +} + +static ULONG WINAPI AudioMediaStreamInputPin_IPin_Release(IPin *iface) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); + + return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); +} + +static const IPinVtbl AudioMediaStreamInputPin_IPin_Vtbl = +{ + AudioMediaStreamInputPin_IPin_QueryInterface, + AudioMediaStreamInputPin_IPin_AddRef, + AudioMediaStreamInputPin_IPin_Release, + BaseInputPinImpl_Connect, + BaseInputPinImpl_ReceiveConnection, + BasePinImpl_Disconnect, + BasePinImpl_ConnectedTo, + BasePinImpl_ConnectionMediaType, + BasePinImpl_QueryPinInfo, + BasePinImpl_QueryDirection, + BasePinImpl_QueryId, + BasePinImpl_QueryAccept, + BasePinImpl_EnumMediaTypes, + BasePinImpl_QueryInternalConnections, + BaseInputPinImpl_EndOfStream, + BaseInputPinImpl_BeginFlush, + BaseInputPinImpl_EndFlush, + BaseInputPinImpl_NewSegment, +}; + +static HRESULT WINAPI AudioMediaStreamInputPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *media_type) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%p)\n", This, media_type); + + if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Audio)) + { + if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_PCM)) + { + TRACE("Audio sub-type %s matches\n", debugstr_guid(&media_type->subtype)); + return S_OK; + } + } + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamInputPin_GetMediaType(BasePin *base, int index, AM_MEDIA_TYPE *media_type) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); + + TRACE("(%p)->(%d,%p)\n", This, index, media_type); + + /* FIXME: Reset structure as we only fill majortype and minortype for now */ + ZeroMemory(media_type, sizeof(*media_type)); + + if (index) + return S_FALSE; + + media_type->majortype = MEDIATYPE_Audio; + media_type->subtype = MEDIASUBTYPE_PCM; + + return S_OK; +} + +static HRESULT WINAPI AudioMediaStreamInputPin_Receive(BaseInputPin *base, IMediaSample *sample) +{ + AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->pin.IPin_iface); + + FIXME("(%p)->(%p) stub!\n", This, sample); + + return E_NOTIMPL; +} + +static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = +{ + { + AudioMediaStreamInputPin_CheckMediaType, + AudioMediaStreamInputPin_GetMediaType, + }, + AudioMediaStreamInputPin_Receive, +}; + +HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, + IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) +{ + AudioMediaStreamImpl *object; + PIN_INFO pin_info; + HRESULT hr; + + TRACE("(%p,%s,%p,%p)\n", parent, debugstr_guid(purpose_id), stream_object, media_stream); + + if (stream_object) + FIXME("Specifying a stream object is not yet supported.\n"); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + return E_OUTOFMEMORY; + + object->IAMMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAMMediaStream_Vtbl; + object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; + object->ref = 1; + + InitializeCriticalSection(&object->critical_section); + + pin_info.pFilter = NULL; + pin_info.dir = PINDIR_INPUT; + pin_info.achName[0] = 'I'; + StringFromGUID2(purpose_id, pin_info.achName + 1, MAX_PIN_NAME - 1); + hr = BaseInputPin_Construct(&AudioMediaStreamInputPin_IPin_Vtbl, + sizeof(AudioMediaStreamInputPin), &pin_info, &AudioMediaStreamInputPin_FuncTable, + &object->critical_section, NULL, (IPin **)&object->input_pin); + if (FAILED(hr)) + goto out_object; + + object->input_pin->parent = object; + + object->parent = parent; + object->purpose_id = *purpose_id; + object->stream_type = stream_type; + + *media_stream = &object->IAMMediaStream_iface; + + return S_OK; + +out_object: + HeapFree(GetProcessHeap(), 0, object); + + return hr; +} diff --git a/dlls/amstream/mediastream.c b/dlls/amstream/ddrawstream.c similarity index 56% rename from dlls/amstream/mediastream.c rename to dlls/amstream/ddrawstream.c index 28c3c01f7be..4c00b95c905 100644 --- a/dlls/amstream/mediastream.c +++ b/dlls/amstream/ddrawstream.c @@ -1,5 +1,5 @@ /* - * Implementation of IMediaStream Interfaces + * Primary DirectDraw video stream * * Copyright 2005, 2008, 2012 Christian Costa * @@ -20,25 +20,14 @@
#define NONAMELESSUNION #define COBJMACROS - -#include <stdarg.h> -#include "windef.h" -#include "winbase.h" -#include "wingdi.h" -#include "dshow.h" - -#include "wine/strmbase.h" - #include "amstream_private.h" - -#include "ddstream.h" #include "wine/debug.h" +#include "wine/strmbase.h"
WINE_DEFAULT_DEBUG_CHANNEL(amstream);
static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectDrawSurface *surface, const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample); -static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample);
struct DirectDrawMediaStreamImpl;
@@ -640,542 +629,6 @@ out_object: return hr; }
-struct AudioMediaStreamImpl; - -typedef struct { - BaseInputPin pin; - struct AudioMediaStreamImpl *parent; -} AudioMediaStreamInputPin; - -typedef struct AudioMediaStreamImpl { - IAMMediaStream IAMMediaStream_iface; - IAudioMediaStream IAudioMediaStream_iface; - LONG ref; - IMultiMediaStream* parent; - MSPID purpose_id; - STREAM_TYPE stream_type; - AudioMediaStreamInputPin *input_pin; - CRITICAL_SECTION critical_section; -} AudioMediaStreamImpl; - -static inline AudioMediaStreamImpl *impl_from_AudioMediaStream_IAMMediaStream(IAMMediaStream *iface) -{ - return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAMMediaStream_iface); -} - -/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMediaStream *iface, - REFIID riid, void **ret_iface) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IMediaStream) || - IsEqualGUID(riid, &IID_IAMMediaStream)) - { - IAMMediaStream_AddRef(iface); - *ret_iface = iface; - return S_OK; - } - else if (IsEqualGUID(riid, &IID_IAudioMediaStream)) - { - IAMMediaStream_AddRef(iface); - *ret_iface = &This->IAudioMediaStream_iface; - return S_OK; - } - else if (IsEqualGUID(riid, &IID_IPin)) - { - IAMMediaStream_AddRef(iface); - *ret_iface = &This->input_pin->pin.pin.IPin_iface; - return S_OK; - } - else if (IsEqualGUID(riid, &IID_IMemInputPin)) - { - IAMMediaStream_AddRef(iface); - *ret_iface = &This->input_pin->pin.IMemInputPin_iface; - return S_OK; - } - - ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ret_iface); - return E_NOINTERFACE; -} - -static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *iface) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); - - return ref; -} - -static ULONG WINAPI AudioMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *iface) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); - - if (!ref) - { - BaseInputPin_Destroy((BaseInputPin *)This->input_pin); - DeleteCriticalSection(&This->critical_section); - HeapFree(GetProcessHeap(), 0, This); - } - - return ref; -} - -/*** IMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, - IMultiMediaStream** multi_media_stream) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, multi_media_stream); - - if (!multi_media_stream) - return E_POINTER; - - IMultiMediaStream_AddRef(This->parent); - *multi_media_stream = This->parent; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_GetInformation(IAMMediaStream *iface, - MSPID *purpose_id, STREAM_TYPE *type) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - TRACE("(%p/%p)->(%p,%p)\n", This, iface, purpose_id, type); - - if (purpose_id) - *purpose_id = This->purpose_id; - if (type) - *type = This->stream_type; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, - IMediaStream *pStreamThatHasDesiredFormat, DWORD flags) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, flags); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMediaStream *iface, - DWORD flags, IStreamSample **sample) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, flags, sample); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, - IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, existing_sample, flags, sample); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%x) stub!\n", This, iface, flags); - - return S_FALSE; -} - -/*** IAMMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, - REFMSPID purpose_id, const STREAM_TYPE stream_type) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%p,%x,%p,%u) stub!\n", This, iface, source_object, flags, purpose_id, stream_type); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%u) stub!\n", This, iface, state); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *am_multi_media_stream) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%p) stub!\n", This, iface, am_multi_media_stream); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *media_stream_filter) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter); - - This->input_pin->pin.pin.pinInfo.pFilter = (IBaseFilter *)media_stream_filter; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) -{ - AudioMediaStreamImpl *This = impl_from_AudioMediaStream_IAMMediaStream(iface); - - FIXME("(%p/%p)->(%p) stub!\n", This, iface, filtergraph); - - return S_FALSE; -} - -static const struct IAMMediaStreamVtbl AudioMediaStreamImpl_IAMMediaStream_Vtbl = -{ - /*** IUnknown methods ***/ - AudioMediaStreamImpl_IAMMediaStream_QueryInterface, - AudioMediaStreamImpl_IAMMediaStream_AddRef, - AudioMediaStreamImpl_IAMMediaStream_Release, - /*** IMediaStream methods ***/ - AudioMediaStreamImpl_IAMMediaStream_GetMultiMediaStream, - AudioMediaStreamImpl_IAMMediaStream_GetInformation, - AudioMediaStreamImpl_IAMMediaStream_SetSameFormat, - AudioMediaStreamImpl_IAMMediaStream_AllocateSample, - AudioMediaStreamImpl_IAMMediaStream_CreateSharedSample, - AudioMediaStreamImpl_IAMMediaStream_SendEndOfStream, - /*** IAMMediaStream methods ***/ - AudioMediaStreamImpl_IAMMediaStream_Initialize, - AudioMediaStreamImpl_IAMMediaStream_SetState, - AudioMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream, - AudioMediaStreamImpl_IAMMediaStream_JoinFilter, - AudioMediaStreamImpl_IAMMediaStream_JoinFilterGraph -}; - -static inline AudioMediaStreamImpl *impl_from_IAudioMediaStream(IAudioMediaStream *iface) -{ - return CONTAINING_RECORD(iface, AudioMediaStreamImpl, IAudioMediaStream_iface); -} - -/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface, - REFIID riid, void **ret_iface) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); - return IAMMediaStream_QueryInterface(&This->IAMMediaStream_iface, riid, ret_iface); -} - -static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_AddRef(IAudioMediaStream *iface) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - TRACE("(%p/%p)\n", iface, This); - return IAMMediaStream_AddRef(&This->IAMMediaStream_iface); -} - -static ULONG WINAPI AudioMediaStreamImpl_IAudioMediaStream_Release(IAudioMediaStream *iface) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - TRACE("(%p/%p)\n", iface, This); - return IAMMediaStream_Release(&This->IAMMediaStream_iface); -} - -/*** IMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream(IAudioMediaStream *iface, - IMultiMediaStream **multi_media_stream) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - TRACE("(%p/%p)->(%p)\n", iface, This, multi_media_stream); - - if (!multi_media_stream) - return E_POINTER; - - IMultiMediaStream_AddRef(This->parent); - *multi_media_stream = This->parent; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetInformation(IAudioMediaStream *iface, - MSPID *purpose_id, STREAM_TYPE *type) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - TRACE("(%p/%p)->(%p,%p)\n", iface, This, purpose_id, type); - - if (purpose_id) - *purpose_id = This->purpose_id; - if (type) - *type = This->stream_type; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat(IAudioMediaStream *iface, - IMediaStream *stream_format, DWORD flags) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%p,%x) stub!\n", iface, This, stream_format, flags); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_AllocateSample(IAudioMediaStream *iface, - DWORD flags, IStreamSample **sample) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%x,%p) stub!\n", iface, This, flags, sample); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample(IAudioMediaStream *iface, - IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%p,%x,%p) stub!\n", iface, This, existing_sample, flags, sample); - - return S_FALSE; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream(IAudioMediaStream *iface, - DWORD flags) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%x) stub!\n", iface, This, flags); - - return S_FALSE; -} - -/*** IAudioMediaStream methods ***/ -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_GetFormat(IAudioMediaStream *iface, WAVEFORMATEX *wave_format_current) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format_current); - - if (!wave_format_current) - return E_POINTER; - - return MS_E_NOSTREAM; - -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_SetFormat(IAudioMediaStream *iface, const WAVEFORMATEX *wave_format) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - FIXME("(%p/%p)->(%p) stub!\n", iface, This, wave_format); - - return E_NOTIMPL; -} - -static HRESULT WINAPI AudioMediaStreamImpl_IAudioMediaStream_CreateSample(IAudioMediaStream *iface, IAudioData *audio_data, - DWORD flags, IAudioStreamSample **sample) -{ - AudioMediaStreamImpl *This = impl_from_IAudioMediaStream(iface); - - TRACE("(%p/%p)->(%p,%u,%p)\n", iface, This, audio_data, flags, sample); - - if (!audio_data) - return E_POINTER; - - return audiostreamsample_create(iface, audio_data, sample); -} - -static const struct IAudioMediaStreamVtbl AudioMediaStreamImpl_IAudioMediaStream_Vtbl = -{ - /*** IUnknown methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_QueryInterface, - AudioMediaStreamImpl_IAudioMediaStream_AddRef, - AudioMediaStreamImpl_IAudioMediaStream_Release, - /*** IMediaStream methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_GetMultiMediaStream, - AudioMediaStreamImpl_IAudioMediaStream_GetInformation, - AudioMediaStreamImpl_IAudioMediaStream_SetSameFormat, - AudioMediaStreamImpl_IAudioMediaStream_AllocateSample, - AudioMediaStreamImpl_IAudioMediaStream_CreateSharedSample, - AudioMediaStreamImpl_IAudioMediaStream_SendEndOfStream, - /*** IAudioMediaStream methods ***/ - AudioMediaStreamImpl_IAudioMediaStream_GetFormat, - AudioMediaStreamImpl_IAudioMediaStream_SetFormat, - AudioMediaStreamImpl_IAudioMediaStream_CreateSample -}; - -static inline AudioMediaStreamInputPin *impl_from_AudioMediaStreamInputPin_IPin(IPin *iface) -{ - return CONTAINING_RECORD(iface, AudioMediaStreamInputPin, pin.pin.IPin_iface); -} - -/*** IUnknown methods ***/ -static HRESULT WINAPI AudioMediaStreamInputPin_IPin_QueryInterface(IPin *iface, REFIID riid, void **ret_iface) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); - - return IAMMediaStream_QueryInterface(&This->parent->IAMMediaStream_iface, riid, ret_iface); -} - -static ULONG WINAPI AudioMediaStreamInputPin_IPin_AddRef(IPin *iface) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); - - return IAMMediaStream_AddRef(&This->parent->IAMMediaStream_iface); -} - -static ULONG WINAPI AudioMediaStreamInputPin_IPin_Release(IPin *iface) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(iface); - - return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); -} - -static const IPinVtbl AudioMediaStreamInputPin_IPin_Vtbl = -{ - AudioMediaStreamInputPin_IPin_QueryInterface, - AudioMediaStreamInputPin_IPin_AddRef, - AudioMediaStreamInputPin_IPin_Release, - BaseInputPinImpl_Connect, - BaseInputPinImpl_ReceiveConnection, - BasePinImpl_Disconnect, - BasePinImpl_ConnectedTo, - BasePinImpl_ConnectionMediaType, - BasePinImpl_QueryPinInfo, - BasePinImpl_QueryDirection, - BasePinImpl_QueryId, - BasePinImpl_QueryAccept, - BasePinImpl_EnumMediaTypes, - BasePinImpl_QueryInternalConnections, - BaseInputPinImpl_EndOfStream, - BaseInputPinImpl_BeginFlush, - BaseInputPinImpl_EndFlush, - BaseInputPinImpl_NewSegment, -}; - -static HRESULT WINAPI AudioMediaStreamInputPin_CheckMediaType(BasePin *base, const AM_MEDIA_TYPE *media_type) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); - - TRACE("(%p)->(%p)\n", This, media_type); - - if (IsEqualGUID(&media_type->majortype, &MEDIATYPE_Audio)) - { - if (IsEqualGUID(&media_type->subtype, &MEDIASUBTYPE_PCM)) - { - TRACE("Audio sub-type %s matches\n", debugstr_guid(&media_type->subtype)); - return S_OK; - } - } - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamInputPin_GetMediaType(BasePin *base, int index, AM_MEDIA_TYPE *media_type) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->IPin_iface); - - TRACE("(%p)->(%d,%p)\n", This, index, media_type); - - /* FIXME: Reset structure as we only fill majortype and minortype for now */ - ZeroMemory(media_type, sizeof(*media_type)); - - if (index) - return S_FALSE; - - media_type->majortype = MEDIATYPE_Audio; - media_type->subtype = MEDIASUBTYPE_PCM; - - return S_OK; -} - -static HRESULT WINAPI AudioMediaStreamInputPin_Receive(BaseInputPin *base, IMediaSample *sample) -{ - AudioMediaStreamInputPin *This = impl_from_AudioMediaStreamInputPin_IPin(&base->pin.IPin_iface); - - FIXME("(%p)->(%p) stub!\n", This, sample); - - return E_NOTIMPL; -} - -static const BaseInputPinFuncTable AudioMediaStreamInputPin_FuncTable = -{ - { - AudioMediaStreamInputPin_CheckMediaType, - AudioMediaStreamInputPin_GetMediaType, - }, - AudioMediaStreamInputPin_Receive, -}; - -HRESULT audiomediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, - IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) -{ - AudioMediaStreamImpl *object; - PIN_INFO pin_info; - HRESULT hr; - - TRACE("(%p,%s,%p,%p)\n", parent, debugstr_guid(purpose_id), stream_object, media_stream); - - if (stream_object) - FIXME("Specifying a stream object is not yet supported.\n"); - - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) - return E_OUTOFMEMORY; - - object->IAMMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAMMediaStream_Vtbl; - object->IAudioMediaStream_iface.lpVtbl = &AudioMediaStreamImpl_IAudioMediaStream_Vtbl; - object->ref = 1; - - InitializeCriticalSection(&object->critical_section); - - pin_info.pFilter = NULL; - pin_info.dir = PINDIR_INPUT; - pin_info.achName[0] = 'I'; - StringFromGUID2(purpose_id, pin_info.achName + 1, MAX_PIN_NAME - 1); - hr = BaseInputPin_Construct(&AudioMediaStreamInputPin_IPin_Vtbl, - sizeof(AudioMediaStreamInputPin), &pin_info, &AudioMediaStreamInputPin_FuncTable, - &object->critical_section, NULL, (IPin **)&object->input_pin); - if (FAILED(hr)) - goto out_object; - - object->input_pin->parent = object; - - object->parent = parent; - object->purpose_id = *purpose_id; - object->stream_type = stream_type; - - *media_stream = &object->IAMMediaStream_iface; - - return S_OK; - -out_object: - HeapFree(GetProcessHeap(), 0, object); - - return hr; -} - typedef struct { IDirectDrawStreamSample IDirectDrawStreamSample_iface; LONG ref; @@ -1394,142 +847,3 @@ static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectD
return S_OK; } - -typedef struct { - IAudioStreamSample IAudioStreamSample_iface; - LONG ref; - IMediaStream *parent; - IAudioData *audio_data; -} IAudioStreamSampleImpl; - -static inline IAudioStreamSampleImpl *impl_from_IAudioStreamSample(IAudioStreamSample *iface) -{ - return CONTAINING_RECORD(iface, IAudioStreamSampleImpl, IAudioStreamSample_iface); -} - -/*** IUnknown methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_QueryInterface(IAudioStreamSample *iface, - REFIID riid, void **ret_iface) -{ - TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface); - - if (IsEqualGUID(riid, &IID_IUnknown) || - IsEqualGUID(riid, &IID_IStreamSample) || - IsEqualGUID(riid, &IID_IAudioStreamSample)) - { - IAudioStreamSample_AddRef(iface); - *ret_iface = iface; - return S_OK; - } - - *ret_iface = NULL; - - ERR("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ret_iface); - return E_NOINTERFACE; -} - -static ULONG WINAPI IAudioStreamSampleImpl_AddRef(IAudioStreamSample *iface) -{ - IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(): new ref = %u\n", iface, ref); - - return ref; -} - -static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface) -{ - IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(): new ref = %u\n", iface, ref); - - if (!ref) - HeapFree(GetProcessHeap(), 0, This); - - return ref; -} - -/*** IStreamSample methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream) -{ - FIXME("(%p)->(%p): stub\n", iface, media_stream); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time, - STREAM_TIME *end_time, STREAM_TIME *current_time) -{ - FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample *iface, const STREAM_TIME *start_time, - const STREAM_TIME *end_time) -{ - FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, DWORD flags, HANDLE event, - PAPCFUNC func_APC, DWORD APC_data) -{ - FIXME("(%p)->(%x,%p,%p,%u): stub\n", iface, flags, event, func_APC, APC_data); - - return E_NOTIMPL; -} - -static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds) -{ - FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds); - - return E_NOTIMPL; -} - -/*** IAudioStreamSample methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data) -{ - FIXME("(%p)->(%p): stub\n", iface, audio_data); - - return E_NOTIMPL; -} - -static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl = -{ - /*** IUnknown methods ***/ - IAudioStreamSampleImpl_QueryInterface, - IAudioStreamSampleImpl_AddRef, - IAudioStreamSampleImpl_Release, - /*** IStreamSample methods ***/ - IAudioStreamSampleImpl_GetMediaStream, - IAudioStreamSampleImpl_GetSampleTimes, - IAudioStreamSampleImpl_SetSampleTimes, - IAudioStreamSampleImpl_Update, - IAudioStreamSampleImpl_CompletionStatus, - /*** IAudioStreamSample methods ***/ - IAudioStreamSampleImpl_GetAudioData -}; - -static HRESULT audiostreamsample_create(IAudioMediaStream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample) -{ - IAudioStreamSampleImpl *object; - - TRACE("(%p)\n", audio_stream_sample); - - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioStreamSampleImpl)); - if (!object) - return E_OUTOFMEMORY; - - object->IAudioStreamSample_iface.lpVtbl = &AudioStreamSample_Vtbl; - object->ref = 1; - object->parent = (IMediaStream*)parent; - object->audio_data = audio_data; - - *audio_stream_sample = &object->IAudioStreamSample_iface; - - return S_OK; -}
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/ddrawstream.c | 146 ++++++++++++++++++++++++++++++++- dlls/amstream/tests/amstream.c | 24 +++--- 2 files changed, 157 insertions(+), 13 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 4c00b95c905..c497d8b58b8 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -448,6 +448,130 @@ static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStreamImpl_IDirect DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetTimePerFrame };
+struct enum_media_types +{ + IEnumMediaTypes IEnumMediaTypes_iface; + LONG refcount; + unsigned int index; +}; + +static const IEnumMediaTypesVtbl enum_media_types_vtbl; + +static struct enum_media_types *impl_from_IEnumMediaTypes(IEnumMediaTypes *iface) +{ + return CONTAINING_RECORD(iface, struct enum_media_types, IEnumMediaTypes_iface); +} + +static HRESULT WINAPI enum_media_types_QueryInterface(IEnumMediaTypes *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumMediaTypes)) + { + IEnumMediaTypes_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI enum_media_types_AddRef(IEnumMediaTypes *iface) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + ULONG refcount = InterlockedIncrement(&enum_media_types->refcount); + TRACE("%p increasing refcount to %u.\n", enum_media_types, refcount); + return refcount; +} + +static ULONG WINAPI enum_media_types_Release(IEnumMediaTypes *iface) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + ULONG refcount = InterlockedDecrement(&enum_media_types->refcount); + TRACE("%p decreasing refcount to %u.\n", enum_media_types, refcount); + if (!refcount) + heap_free(enum_media_types); + return refcount; +} + +static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count, AM_MEDIA_TYPE **mts, ULONG *ret_count) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + + TRACE("iface %p, count %u, mts %p, ret_count %p.\n", iface, count, mts, ret_count); + + if (!ret_count) + return E_POINTER; + + if (count && !enum_media_types->index) + { + mts[0] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); + memset(mts[0], 0, sizeof(AM_MEDIA_TYPE)); + mts[0]->majortype = MEDIATYPE_Video; + mts[0]->subtype = MEDIASUBTYPE_RGB8; + mts[0]->bFixedSizeSamples = TRUE; + mts[0]->lSampleSize = 10000; + ++enum_media_types->index; + *ret_count = 1; + return count == 1 ? S_OK : S_FALSE; + } + + *ret_count = 0; + return count ? S_FALSE : S_OK; +} + +static HRESULT WINAPI enum_media_types_Skip(IEnumMediaTypes *iface, ULONG count) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + + TRACE("iface %p, count %u.\n", iface, count); + + enum_media_types->index += count; + + return S_OK; +} + +static HRESULT WINAPI enum_media_types_Reset(IEnumMediaTypes *iface) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + + TRACE("iface %p.\n", iface); + + enum_media_types->index = 0; + return S_OK; +} + +static HRESULT WINAPI enum_media_types_Clone(IEnumMediaTypes *iface, IEnumMediaTypes **out) +{ + struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface); + struct enum_media_types *object; + + TRACE("iface %p, out %p.\n", iface, out); + + if (!(object = heap_alloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl; + object->refcount = 1; + object->index = enum_media_types->index; + + *out = &object->IEnumMediaTypes_iface; + return S_OK; +} + +static const IEnumMediaTypesVtbl enum_media_types_vtbl = +{ + enum_media_types_QueryInterface, + enum_media_types_AddRef, + enum_media_types_Release, + enum_media_types_Next, + enum_media_types_Skip, + enum_media_types_Reset, + enum_media_types_Clone, +}; + static inline DirectDrawMediaStreamInputPin *impl_from_DirectDrawMediaStreamInputPin_IPin(IPin *iface) { return CONTAINING_RECORD(iface, DirectDrawMediaStreamInputPin, pin.pin.IPin_iface); @@ -475,6 +599,26 @@ static ULONG WINAPI DirectDrawMediaStreamInputPin_IPin_Release(IPin *iface) return IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); }
+static HRESULT WINAPI ddraw_pin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **enum_media_types) +{ + struct enum_media_types *object; + + TRACE("iface %p, enum_media_types %p.\n", iface, enum_media_types); + + if (!enum_media_types) + return E_POINTER; + + if (!(object = heap_alloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->IEnumMediaTypes_iface.lpVtbl = &enum_media_types_vtbl; + object->refcount = 1; + object->index = 0; + + *enum_media_types = &object->IEnumMediaTypes_iface; + return S_OK; +} + static const IPinVtbl DirectDrawMediaStreamInputPin_IPin_Vtbl = { DirectDrawMediaStreamInputPin_IPin_QueryInterface, @@ -489,7 +633,7 @@ static const IPinVtbl DirectDrawMediaStreamInputPin_IPin_Vtbl = BasePinImpl_QueryDirection, BasePinImpl_QueryId, BasePinImpl_QueryAccept, - BasePinImpl_EnumMediaTypes, + ddraw_pin_EnumMediaTypes, BasePinImpl_QueryInternalConnections, BaseInputPinImpl_EndOfStream, BaseInputPinImpl_BeginFlush, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 75862e70910..c224d00ca30 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1648,7 +1648,7 @@ static void test_enum_media_types(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); - todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + ok(hr == E_POINTER, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 0, mts, &count); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1660,15 +1660,15 @@ static void test_enum_media_types(void) CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); - todo_wine ok(!count, "Got count %u.\n", count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Reset(enum1); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 2, mts, &count); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); - todo_wine ok(count == 1, "Got count %u.\n", count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); CoTaskMemFree(mts[0]);
hr = IEnumMediaTypes_Reset(enum1); @@ -1681,8 +1681,8 @@ static void test_enum_media_types(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); - todo_wine ok(!count, "Got count %u.\n", count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count);
hr = IEnumMediaTypes_Next(enum2, 1, mts, &count); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1801,18 +1801,18 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); - todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + ok(hr == E_POINTER, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(count == 1, "Got count %u.\n", count); ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Video), "Got major type %s\n", wine_dbgstr_guid(&pmt->majortype)); - todo_wine ok(IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB8), "Got subtype %s\n", + ok(IsEqualGUID(&pmt->subtype, &MEDIASUBTYPE_RGB8), "Got subtype %s\n", wine_dbgstr_guid(&pmt->subtype)); - todo_wine ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); + ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); - todo_wine ok(pmt->lSampleSize == 10000, "Got sample size %u.\n", pmt->lSampleSize); + ok(pmt->lSampleSize == 10000, "Got sample size %u.\n", pmt->lSampleSize); ok(IsEqualGUID(&pmt->formattype, &GUID_NULL), "Got format type %s.\n", wine_dbgstr_guid(&pmt->formattype)); ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); @@ -1854,7 +1854,7 @@ static void test_media_types(void) CoTaskMemFree(pmt);
hr = IEnumMediaTypes_Next(enummt, 1, &pmt, &count); - todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(hr == S_FALSE, "Got hr %#x.\n", hr);
IEnumMediaTypes_Release(enummt); IPin_Release(pin);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/amstream/ddrawstream.c | 67 +++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 33 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index c497d8b58b8..abff80ab80a 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -29,14 +29,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(amstream); static HRESULT ddrawstreamsample_create(IDirectDrawMediaStream *parent, IDirectDrawSurface *surface, const RECT *rect, IDirectDrawStreamSample **ddraw_stream_sample);
-struct DirectDrawMediaStreamImpl; +struct ddraw_stream;
typedef struct { BaseInputPin pin; - struct DirectDrawMediaStreamImpl *parent; + struct ddraw_stream *parent; } DirectDrawMediaStreamInputPin;
-typedef struct DirectDrawMediaStreamImpl { +struct ddraw_stream +{ IAMMediaStream IAMMediaStream_iface; IDirectDrawMediaStream IDirectDrawMediaStream_iface; LONG ref; @@ -46,18 +47,18 @@ typedef struct DirectDrawMediaStreamImpl { IDirectDraw7 *ddraw; DirectDrawMediaStreamInputPin *input_pin; CRITICAL_SECTION critical_section; -} DirectDrawMediaStreamImpl; +};
-static inline DirectDrawMediaStreamImpl *impl_from_DirectDrawMediaStream_IAMMediaStream(IAMMediaStream *iface) +static inline struct ddraw_stream *impl_from_IAMMediaStream(IAMMediaStream *iface) { - return CONTAINING_RECORD(iface, DirectDrawMediaStreamImpl, IAMMediaStream_iface); + return CONTAINING_RECORD(iface, struct ddraw_stream, IAMMediaStream_iface); }
/*** IUnknown methods ***/ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_QueryInterface(IAMMediaStream *iface, REFIID riid, void **ret_iface) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface);
@@ -94,7 +95,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_QueryInterface(IA
static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStream *iface) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); @@ -104,7 +105,7 @@ static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_AddRef(IAMMediaStre
static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Release(IAMMediaStream *iface) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref); @@ -125,7 +126,7 @@ static ULONG WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Release(IAMMediaStr static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_GetMultiMediaStream(IAMMediaStream *iface, IMultiMediaStream** multi_media_stream) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, multi_media_stream);
@@ -141,7 +142,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_GetMultiMediaStre static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_GetInformation(IAMMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, purpose_id, type);
@@ -156,7 +157,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_GetInformation(IA static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SetSameFormat(IAMMediaStream *iface, IMediaStream *pStreamThatHasDesiredFormat, DWORD flags) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, flags);
@@ -166,7 +167,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SetSameFormat(IAM static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_AllocateSample(IAMMediaStream *iface, DWORD flags, IStreamSample **sample) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, flags, sample);
@@ -176,7 +177,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_AllocateSample(IA static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_CreateSharedSample(IAMMediaStream *iface, IStreamSample *existing_sample, DWORD flags, IStreamSample **sample) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, existing_sample, flags, sample);
@@ -185,7 +186,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_CreateSharedSampl
static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface, DWORD flags) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%x) stub!\n", This, iface, flags);
@@ -196,7 +197,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SendEndOfStream(I static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, REFMSPID purpose_id, const STREAM_TYPE stream_type) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p,%u) stub!\n", This, iface, source_object, flags, purpose_id, stream_type);
@@ -205,7 +206,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_Initialize(IAMMed
static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%u) stub!\n", This, iface, state);
@@ -214,7 +215,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_SetState(IAMMedia
static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *am_multi_media_stream) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", This, iface, am_multi_media_stream);
@@ -223,7 +224,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinAMMultiMediaS
static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMediaStream *iface, IMediaStreamFilter *media_stream_filter) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, media_stream_filter);
@@ -234,7 +235,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilter(IAMMed
static HRESULT WINAPI DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilterGraph(IAMMediaStream *iface, IFilterGraph *filtergraph) { - DirectDrawMediaStreamImpl *This = impl_from_DirectDrawMediaStream_IAMMediaStream(iface); + struct ddraw_stream *This = impl_from_IAMMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", This, iface, filtergraph);
@@ -262,30 +263,30 @@ static const struct IAMMediaStreamVtbl DirectDrawMediaStreamImpl_IAMMediaStream_ DirectDrawMediaStreamImpl_IAMMediaStream_JoinFilterGraph };
-static inline DirectDrawMediaStreamImpl *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface) +static inline struct ddraw_stream *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface) { - return CONTAINING_RECORD(iface, DirectDrawMediaStreamImpl, IDirectDrawMediaStream_iface); + return CONTAINING_RECORD(iface, struct ddraw_stream, IDirectDrawMediaStream_iface); }
/*** IUnknown methods ***/ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_QueryInterface(IDirectDrawMediaStream *iface, REFIID riid, void **ret_iface) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface); TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ret_iface); return IAMMediaStream_QueryInterface(&This->IAMMediaStream_iface, riid, ret_iface); }
static ULONG WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_AddRef(IDirectDrawMediaStream *iface) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface); TRACE("(%p/%p)\n", iface, This); return IAMMediaStream_AddRef(&This->IAMMediaStream_iface); }
static ULONG WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_Release(IDirectDrawMediaStream *iface) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface); TRACE("(%p/%p)\n", iface, This); return IAMMediaStream_Release(&This->IAMMediaStream_iface); } @@ -294,7 +295,7 @@ static ULONG WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_Release(IDi static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetMultiMediaStream(IDirectDrawMediaStream *iface, IMultiMediaStream **multi_media_stream) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, multi_media_stream);
@@ -310,7 +311,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetMultiM static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetInformation(IDirectDrawMediaStream *iface, MSPID *purpose_id, STREAM_TYPE *type) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, purpose_id, type);
@@ -325,7 +326,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetInform static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SetSameFormat(IDirectDrawMediaStream *iface, IMediaStream *pStreamThatHasDesiredFormat, DWORD dwFlags) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
@@ -335,7 +336,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SetSameFo static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_AllocateSample(IDirectDrawMediaStream *iface, DWORD dwFlags, IStreamSample **ppSample) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
@@ -345,7 +346,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_AllocateS static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_CreateSharedSample(IDirectDrawMediaStream *iface, IStreamSample *pExistingSample, DWORD dwFlags, IStreamSample **ppSample) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
@@ -355,7 +356,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_CreateSha static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SendEndOfStream(IDirectDrawMediaStream *iface, DWORD dwFlags) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
@@ -385,7 +386,7 @@ static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_SetFormat static HRESULT WINAPI DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface, IDirectDraw **ddraw) { - DirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface); + struct ddraw_stream *This = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p)->(%p)\n", iface, ddraw);
@@ -727,7 +728,7 @@ static const BaseInputPinFuncTable DirectDrawMediaStreamInputPin_FuncTable = HRESULT ddrawmediastream_create(IMultiMediaStream *parent, const MSPID *purpose_id, IUnknown *stream_object, STREAM_TYPE stream_type, IAMMediaStream **media_stream) { - DirectDrawMediaStreamImpl *object; + struct ddraw_stream *object; PIN_INFO pin_info; HRESULT hr;