Signed-off-by: Myah Caron qsniyg@protonmail.com --- dlls/amstream/filter.c | 24 +++++- dlls/amstream/tests/amstream.c | 141 +++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/filter.c b/dlls/amstream/filter.c index 0a06e78180..ef23edfae3 100644 --- a/dlls/amstream/filter.c +++ b/dlls/amstream/filter.c @@ -773,9 +773,29 @@ static HRESULT WINAPI filter_seeking_SetTimeFormat(IMediaSeeking *iface, const G
static HRESULT WINAPI filter_seeking_GetDuration(IMediaSeeking *iface, LONGLONG *duration) { - FIXME("iface %p, duration %p, stub!\n", iface, duration); + struct filter *filter = impl_from_IMediaSeeking(iface); + IMediaSeeking *seeking; + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, duration %p\n", iface, duration); + + EnterCriticalSection(&filter->cs); + + seeking = get_seeking(filter->seekable_stream); + + if (!seeking) + { + LeaveCriticalSection(&filter->cs); + return E_NOTIMPL; + } + + hr = IMediaSeeking_GetDuration(seeking, duration); + + IMediaSeeking_Release(seeking); + + LeaveCriticalSection(&filter->cs); + + return hr; }
static HRESULT WINAPI filter_seeking_GetStopPosition(IMediaSeeking *iface, LONGLONG *stop) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 8adf9db934..48953684f9 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5007,6 +5007,146 @@ static void test_mediastreamfilter_set_positions(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_mediastreamfilter_get_duration(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid1 = {0x88888888, 1}; + static const MSPID mspid2 = {0x88888888, 2}; + static const MSPID mspid3 = {0x88888888, 3}; + IMediaStreamFilter *filter; + struct testfilter source1; + struct testfilter source2; + struct testfilter source3; + IAMMediaStream *stream1; + IAMMediaStream *stream2; + IAMMediaStream *stream3; + LONGLONG duration; + IMediaSeeking *seeking; + IGraphBuilder *graph; + IPin *pin1; + IPin *pin2; + IPin *pin3; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream1, NULL, 0, &mspid1, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid2, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream3, NULL, 0, &mspid3, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream1, &mspid1, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid2, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream3, &mspid3, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream1, &IID_IPin, (void **)&pin1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_QueryInterface(stream3, &IID_IPin, (void **)&pin3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + testfilter_init(&source1); + testfilter_init(&source2); + testfilter_init(&source3); + source1.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + source2.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + source3.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IGraphBuilder_AddFilter(graph, &source1.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_AddFilter(graph, &source2.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_AddFilter(graph, &source3.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IGraphBuilder_ConnectDirect(graph, &source2.source.pin.IPin_iface, pin2, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IGraphBuilder_ConnectDirect(graph, &source3.source.pin.IPin_iface, pin3, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IGraphBuilder_ConnectDirect(graph, &source1.source.pin.IPin_iface, pin1, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_QueryInterface(filter, &IID_IMediaSeeking, (void **)&seeking); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + duration = 0xdeadbeefdeadbeefULL; + hr = IMediaSeeking_GetDuration(seeking, &duration); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(duration == 0x8000000000000000ULL, "Got duration %s.\n", + wine_dbgstr_longlong(duration)); + + source2.get_duration_hr = E_FAIL; + duration = 0xdeadbeefdeadbeefULL; + hr = IMediaSeeking_GetDuration(seeking, &duration); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + ok(duration == 0xdeadbeefdeadbeefULL, "Got duration %s.\n", + wine_dbgstr_longlong(duration)); + + source2.get_duration_hr = E_NOTIMPL; + duration = 0xdeadbeefdeadbeefULL; + hr = IMediaSeeking_GetDuration(seeking, &duration); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + ok(duration == 0xdeadbeefdeadbeefULL, "Got duration %s.\n", + wine_dbgstr_longlong(duration)); + + source2.IMediaSeeking_iface.lpVtbl = NULL; + duration = 0xdeadbeefdeadbeefULL; + hr = IMediaSeeking_GetDuration(seeking, &duration); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + ok(duration == 0xdeadbeefdeadbeefULL, "Got duration %s.\n", + wine_dbgstr_longlong(duration)); + + IGraphBuilder_Disconnect(graph, pin2); + IGraphBuilder_Disconnect(graph, &source2.source.pin.IPin_iface); + + source2.IMediaSeeking_iface.lpVtbl = NULL; + duration = 0xdeadbeefdeadbeefULL; + hr = IMediaSeeking_GetDuration(seeking, &duration); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + ok(duration == 0xdeadbeefdeadbeefULL, "Got duration %s.\n", + wine_dbgstr_longlong(duration)); + + IGraphBuilder_Disconnect(graph, pin2); + IGraphBuilder_Disconnect(graph, &source2.source.pin.IPin_iface); + IGraphBuilder_Disconnect(graph, pin3); + IGraphBuilder_Disconnect(graph, &source3.source.pin.IPin_iface); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaSeeking_Release(seeking); + ref = IMediaStreamFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin1); + ref = IAMMediaStream_Release(stream1); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin2); + ref = IAMMediaStream_Release(stream2); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin3); + ref = IAMMediaStream_Release(stream3); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_mediastreamfilter_get_current_stream_time(void) { IMediaStreamFilter *filter; @@ -5247,6 +5387,7 @@ START_TEST(amstream) test_mediastreamfilter_stop_pause_run(); test_mediastreamfilter_support_seeking(); test_mediastreamfilter_set_positions(); + test_mediastreamfilter_get_duration(); test_mediastreamfilter_get_current_stream_time();
CoUninitialize(); -- 2.27.0