2008-02-13 23:47:12 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for Media Detector
|
|
|
|
*
|
2008-04-10 01:01:30 +02:00
|
|
|
* Copyright (C) 2008 Google (Lei Zhang, Dan Hipschman)
|
2008-02-13 23:47:12 +01:00
|
|
|
*
|
|
|
|
* 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
|
2011-11-21 14:46:57 +01:00
|
|
|
#define CONST_VTABLE
|
2008-02-13 23:47:12 +01:00
|
|
|
|
2008-04-05 01:01:27 +02:00
|
|
|
#include "ole2.h"
|
2008-04-10 01:02:02 +02:00
|
|
|
#include "vfwmsgs.h"
|
2008-04-05 01:01:27 +02:00
|
|
|
#include "uuids.h"
|
2020-04-23 21:45:43 +02:00
|
|
|
#include "wine/strmbase.h"
|
2008-02-13 23:47:12 +01:00
|
|
|
#include "wine/test.h"
|
|
|
|
#include "qedit.h"
|
2014-02-12 01:05:05 +01:00
|
|
|
#include "control.h"
|
2008-04-09 01:53:52 +02:00
|
|
|
#include "rc.h"
|
2008-02-13 23:47:12 +01:00
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static ULONG get_refcount(void *iface)
|
2011-11-21 14:46:57 +01:00
|
|
|
{
|
2019-04-16 06:20:51 +02:00
|
|
|
IUnknown *unknown = iface;
|
|
|
|
IUnknown_AddRef(unknown);
|
|
|
|
return IUnknown_Release(unknown);
|
2011-11-21 14:46:57 +01:00
|
|
|
}
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static const GUID test_iid = {0x33333333};
|
|
|
|
static LONG outer_ref = 1;
|
2011-11-21 14:46:57 +01:00
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(iid, &IID_IMediaDet)
|
|
|
|
|| IsEqualGUID(iid, &test_iid))
|
|
|
|
{
|
|
|
|
*out = (IUnknown *)0xdeadbeef;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
2011-11-21 14:46:57 +01:00
|
|
|
}
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static ULONG WINAPI outer_AddRef(IUnknown *iface)
|
2011-11-21 14:46:57 +01:00
|
|
|
{
|
2019-04-16 06:20:51 +02:00
|
|
|
return InterlockedIncrement(&outer_ref);
|
2011-11-21 14:46:57 +01:00
|
|
|
}
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static ULONG WINAPI outer_Release(IUnknown *iface)
|
2011-11-21 14:46:57 +01:00
|
|
|
{
|
2019-04-16 06:20:51 +02:00
|
|
|
return InterlockedDecrement(&outer_ref);
|
2011-11-21 14:46:57 +01:00
|
|
|
}
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static const IUnknownVtbl outer_vtbl =
|
2011-11-21 14:46:57 +01:00
|
|
|
{
|
2019-04-16 06:20:51 +02:00
|
|
|
outer_QueryInterface,
|
|
|
|
outer_AddRef,
|
|
|
|
outer_Release,
|
2011-11-21 14:46:57 +01:00
|
|
|
};
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
static IUnknown test_outer = {&outer_vtbl};
|
|
|
|
|
|
|
|
static void test_aggregation(void)
|
|
|
|
{
|
|
|
|
IMediaDet *detector, *detector2;
|
|
|
|
IUnknown *unk, *unk2;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
detector = (IMediaDet *)0xdeadbeef;
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, &test_outer, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (void **)&detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(!detector, "Got interface %p.\n", detector);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, &test_outer, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IUnknown, (void **)&unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
|
|
|
|
ref = get_refcount(unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
|
2019-04-16 06:20:51 +02:00
|
|
|
|
|
|
|
ref = IUnknown_AddRef(unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2019-04-16 06:20:51 +02:00
|
|
|
|
|
|
|
ref = IUnknown_Release(unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2019-04-16 06:20:51 +02:00
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
IUnknown_Release(unk2);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IMediaDet, (void **)&detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_QueryInterface(detector, &IID_IUnknown, (void **)&unk2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
hr = IMediaDet_QueryInterface(detector, &IID_IMediaDet, (void **)&detector2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(detector2 == (IMediaDet *)0xdeadbeef, "Got unexpected IMediaDet %p.\n", detector2);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
hr = IMediaDet_QueryInterface(detector, &test_iid, (void **)&unk2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2019-04-16 06:20:51 +02:00
|
|
|
ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
|
|
|
|
|
|
|
|
IMediaDet_Release(detector);
|
|
|
|
ref = IUnknown_Release(unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got unexpected refcount %ld.\n", ref);
|
|
|
|
ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
|
2019-04-16 06:20:51 +02:00
|
|
|
}
|
2011-11-21 14:46:57 +01:00
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
struct testfilter
|
|
|
|
{
|
|
|
|
struct strmbase_filter filter;
|
|
|
|
struct strmbase_source source;
|
2020-04-27 21:14:05 +02:00
|
|
|
IMediaSeeking IMediaSeeking_iface;
|
2020-04-23 21:45:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct testfilter, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, unsigned int index)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
return index ? NULL : &filter->source.pin;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testfilter_destroy(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
strmbase_source_cleanup(&filter->source);
|
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct strmbase_filter_ops testfilter_ops =
|
|
|
|
{
|
|
|
|
.filter_get_pin = testfilter_get_pin,
|
|
|
|
.filter_destroy = testfilter_destroy,
|
|
|
|
};
|
|
|
|
|
2020-04-27 21:14:05 +02:00
|
|
|
static inline struct testfilter *impl_from_strmbase_pin(struct strmbase_pin *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct testfilter, source.pin);
|
|
|
|
}
|
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
static HRESULT testsource_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
|
|
|
|
{
|
|
|
|
static const VIDEOINFOHEADER source_format =
|
|
|
|
{
|
|
|
|
.bmiHeader.biSize = sizeof(BITMAPINFOHEADER),
|
|
|
|
.bmiHeader.biWidth = 640,
|
|
|
|
.bmiHeader.biHeight = 480,
|
|
|
|
.bmiHeader.biPlanes = 1,
|
|
|
|
.bmiHeader.biBitCount = 24,
|
|
|
|
.bmiHeader.biCompression = BI_RGB,
|
|
|
|
.bmiHeader.biSizeImage = 640 * 480 * 3
|
|
|
|
};
|
|
|
|
|
|
|
|
if (index)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
mt->majortype = MEDIATYPE_Video;
|
|
|
|
mt->subtype = MEDIASUBTYPE_RGB24;
|
|
|
|
mt->bFixedSizeSamples = TRUE;
|
|
|
|
mt->bTemporalCompression = FALSE;
|
|
|
|
mt->lSampleSize = source_format.bmiHeader.biSizeImage;
|
|
|
|
mt->formattype = FORMAT_VideoInfo;
|
|
|
|
mt->pUnk = NULL;
|
|
|
|
mt->cbFormat = sizeof(source_format);
|
|
|
|
mt->pbFormat = CoTaskMemAlloc(mt->cbFormat);
|
|
|
|
memcpy(mt->pbFormat, &source_format, mt->cbFormat);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-27 21:14:05 +02:00
|
|
|
static HRESULT testsource_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_strmbase_pin(iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
|
|
|
*out = &filter->IMediaSeeking_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
static HRESULT WINAPI testsource_DecideAllocator(struct strmbase_source *iface,
|
|
|
|
IMemInputPin *peer, IMemAllocator **allocator)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct strmbase_source_ops testsource_ops =
|
|
|
|
{
|
|
|
|
.base.pin_get_media_type = testsource_get_media_type,
|
2020-04-27 21:14:05 +02:00
|
|
|
.base.pin_query_interface = testsource_query_interface,
|
2020-04-23 21:45:43 +02:00
|
|
|
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
|
|
|
|
.pfnDecideAllocator = testsource_DecideAllocator,
|
|
|
|
};
|
|
|
|
|
2020-04-27 21:14:05 +02:00
|
|
|
static inline struct testfilter *impl_from_IMediaSeeking(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct testfilter, IMediaSeeking_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI testseek_AddRef(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_AddRef(&filter->source.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI testseek_Release(IMediaSeeking *iface)
|
|
|
|
{
|
|
|
|
struct testfilter *filter = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetCapabilities(IMediaSeeking *iface, DWORD *caps)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_CheckCapabilities(IMediaSeeking *iface, DWORD *caps)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_IsFormatSupported(IMediaSeeking *iface, const GUID *format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_QueryPreferredFormat(IMediaSeeking *iface, GUID *format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetTimeFormat(IMediaSeeking *iface, GUID *format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_IsUsingTimeFormat(IMediaSeeking *iface, const GUID *format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_SetTimeFormat(IMediaSeeking *iface, const GUID *format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetDuration(IMediaSeeking *iface, LONGLONG *duration)
|
|
|
|
{
|
|
|
|
if (winetest_debug > 1) trace("IMediaSeeking_GetDuration()\n");
|
|
|
|
|
|
|
|
*duration = 42000000;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetStopPosition(IMediaSeeking *iface, LONGLONG *stop)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *target,
|
|
|
|
const GUID *target_format, LONGLONG source, const GUID *source_format)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_SetPositions(IMediaSeeking *iface, LONGLONG *current,
|
|
|
|
DWORD current_flags, LONGLONG *stop, DWORD stop_flags)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetPositions(IMediaSeeking *iface, LONGLONG *current, LONGLONG *stop)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetAvailable(IMediaSeeking *iface, LONGLONG *earliest, LONGLONG *latest)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_SetRate(IMediaSeeking *iface, double rate)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetRate(IMediaSeeking *iface, double *rate)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI testseek_GetPreroll(IMediaSeeking *iface, LONGLONG *preroll)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl testseek_vtbl =
|
|
|
|
{
|
|
|
|
testseek_QueryInterface,
|
|
|
|
testseek_AddRef,
|
|
|
|
testseek_Release,
|
|
|
|
testseek_GetCapabilities,
|
|
|
|
testseek_CheckCapabilities,
|
|
|
|
testseek_IsFormatSupported,
|
|
|
|
testseek_QueryPreferredFormat,
|
|
|
|
testseek_GetTimeFormat,
|
|
|
|
testseek_IsUsingTimeFormat,
|
|
|
|
testseek_SetTimeFormat,
|
|
|
|
testseek_GetDuration,
|
|
|
|
testseek_GetStopPosition,
|
|
|
|
testseek_GetCurrentPosition,
|
|
|
|
testseek_ConvertTimeFormat,
|
|
|
|
testseek_SetPositions,
|
|
|
|
testseek_GetPositions,
|
|
|
|
testseek_GetAvailable,
|
|
|
|
testseek_SetRate,
|
|
|
|
testseek_GetRate,
|
|
|
|
testseek_GetPreroll
|
|
|
|
};
|
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
static void testfilter_init(struct testfilter *filter)
|
|
|
|
{
|
|
|
|
static const GUID clsid = {0xabacab};
|
|
|
|
|
|
|
|
memset(filter, 0, sizeof(*filter));
|
|
|
|
strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops);
|
|
|
|
strmbase_source_init(&filter->source, &filter->filter, L"", &testsource_ops);
|
2020-04-27 21:14:05 +02:00
|
|
|
filter->IMediaSeeking_iface.lpVtbl = &testseek_vtbl;
|
2020-04-23 21:45:43 +02:00
|
|
|
}
|
|
|
|
|
2008-04-05 00:59:08 +02:00
|
|
|
static WCHAR test_avi_filename[MAX_PATH];
|
2008-04-09 01:53:52 +02:00
|
|
|
static WCHAR test_sound_avi_filename[MAX_PATH];
|
2008-04-05 00:59:08 +02:00
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
static BOOL unpack_avi_file(int id, WCHAR name[MAX_PATH])
|
2008-04-05 00:59:08 +02:00
|
|
|
{
|
|
|
|
static WCHAR temp_path[MAX_PATH];
|
|
|
|
HRSRC res;
|
|
|
|
HGLOBAL data;
|
|
|
|
char *mem;
|
|
|
|
DWORD size, written;
|
|
|
|
HANDLE fh;
|
2014-04-10 07:18:17 +02:00
|
|
|
BOOL ret;
|
2008-04-05 00:59:08 +02:00
|
|
|
|
2013-10-01 23:16:31 +02:00
|
|
|
res = FindResourceW(NULL, MAKEINTRESOURCEW(id), MAKEINTRESOURCEW(AVI_RES_TYPE));
|
2008-04-05 00:59:08 +02:00
|
|
|
if (!res)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
data = LoadResource(NULL, res);
|
|
|
|
if (!data)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
mem = LockResource(data);
|
|
|
|
if (!mem)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
size = SizeofResource(NULL, res);
|
|
|
|
if (size == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-04-09 01:51:28 +02:00
|
|
|
if (!GetTempPathW(MAX_PATH, temp_path))
|
2008-04-05 00:59:08 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* We might end up relying on the extension here, so .TMP is no good. */
|
2020-01-16 03:30:28 +01:00
|
|
|
if (!GetTempFileNameW(temp_path, L"DES", 0, name))
|
2008-04-05 00:59:08 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
DeleteFileW(name);
|
2020-01-16 03:30:28 +01:00
|
|
|
wcscpy(name + wcslen(name) - 3, L"avi");
|
2008-04-05 00:59:08 +02:00
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
fh = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_NEW,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
2008-04-05 00:59:08 +02:00
|
|
|
if (fh == INVALID_HANDLE_VALUE)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-04-10 07:18:17 +02:00
|
|
|
ret = WriteFile(fh, mem, size, &written, NULL);
|
2008-04-05 00:59:08 +02:00
|
|
|
CloseHandle(fh);
|
2014-04-10 07:18:17 +02:00
|
|
|
return ret && written == size;
|
2008-04-05 00:59:08 +02:00
|
|
|
}
|
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
static BOOL init_tests(void)
|
|
|
|
{
|
|
|
|
return unpack_avi_file(TEST_AVI_RES, test_avi_filename)
|
|
|
|
&& unpack_avi_file(TEST_SOUND_AVI_RES, test_sound_avi_filename);
|
|
|
|
}
|
|
|
|
|
2008-02-13 23:47:12 +01:00
|
|
|
static void test_mediadet(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2020-04-17 22:02:08 +02:00
|
|
|
FILTER_INFO filter_info;
|
|
|
|
AM_MEDIA_TYPE mt, *pmt;
|
2022-03-03 18:40:58 +01:00
|
|
|
LONG index, ref, count;
|
2020-04-17 22:02:08 +02:00
|
|
|
IEnumMediaTypes *type;
|
2008-02-13 23:47:12 +01:00
|
|
|
IMediaDet *pM = NULL;
|
2008-04-05 00:59:08 +02:00
|
|
|
BSTR filename = NULL;
|
2020-04-17 22:02:08 +02:00
|
|
|
IBaseFilter *filter;
|
|
|
|
IEnumPins *enumpins;
|
|
|
|
IUnknown *unk;
|
|
|
|
IPin *pin;
|
2020-04-17 22:02:06 +02:00
|
|
|
GUID guid;
|
2020-04-17 22:02:07 +02:00
|
|
|
BSTR bstr;
|
2008-04-10 01:02:02 +02:00
|
|
|
double fps;
|
2008-04-09 01:53:52 +02:00
|
|
|
int flags;
|
2008-04-10 01:02:02 +02:00
|
|
|
int i;
|
2008-02-13 23:47:12 +01:00
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
/* test.avi has one video stream. */
|
2008-02-13 23:47:12 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (LPVOID*)&pM);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-02-13 23:47:12 +01:00
|
|
|
ok(pM != NULL, "pM is NULL\n");
|
2008-02-13 23:12:17 +01:00
|
|
|
|
2008-04-09 01:52:50 +02:00
|
|
|
filename = NULL;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
|
|
|
/* Despite what MSDN claims, this returns S_OK. */
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
ok(filename == NULL, "IMediaDet_get_Filename\n");
|
|
|
|
|
|
|
|
filename = (BSTR) -1;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
|
|
|
/* Despite what MSDN claims, this returns S_OK. */
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
ok(filename == NULL, "IMediaDet_get_Filename\n");
|
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
count = -1;
|
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &count);
|
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
|
|
|
ok(count == -1, "Got %ld streams.\n", count);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
2008-04-09 01:55:37 +02:00
|
|
|
/* The stream defaults to 0, even without a file! */
|
2022-03-03 18:40:58 +01:00
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream index %ld.\n", index);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
/* But put_CurrentStream doesn't. */
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 0);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, -1);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-10 01:01:30 +02:00
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
|
2020-04-17 22:02:06 +02:00
|
|
|
hr = IMediaDet_get_StreamType(pM, &guid);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:06 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamType(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:06 +02:00
|
|
|
|
2020-04-17 22:02:07 +02:00
|
|
|
hr = IMediaDet_get_StreamTypeB(pM, &bstr);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:07 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamTypeB(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:07 +02:00
|
|
|
|
2020-04-17 22:02:08 +02:00
|
|
|
hr = IMediaDet_get_Filter(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
|
|
|
|
unk = (IUnknown*)0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_Filter(pM, &unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
ok(!unk, "Got filter %p.\n", unk);
|
|
|
|
|
2008-04-05 00:59:08 +02:00
|
|
|
filename = SysAllocString(test_avi_filename);
|
|
|
|
hr = IMediaDet_put_Filename(pM, filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-05 00:59:08 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
2008-04-09 01:55:37 +02:00
|
|
|
/* The stream defaults to 0. */
|
2022-03-03 18:40:58 +01:00
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream index %ld.\n", index);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-10 01:01:30 +02:00
|
|
|
ZeroMemory(&mt, sizeof mt);
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
CoTaskMemFree(mt.pbFormat);
|
|
|
|
|
2020-04-17 22:02:06 +02:00
|
|
|
hr = IMediaDet_get_StreamType(pM, &guid);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:06 +02:00
|
|
|
ok(IsEqualGUID(&guid, &MEDIATYPE_Video), "Got major type %s.\n", debugstr_guid(&guid));
|
|
|
|
|
2020-04-17 22:02:07 +02:00
|
|
|
hr = IMediaDet_get_StreamTypeB(pM, &bstr);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:07 +02:00
|
|
|
ok(!wcscmp(bstr, L"{73646976-0000-0010-8000-00AA00389B71}"),
|
|
|
|
"Got major type %s.\n", debugstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
/* Even before get_OutputStreams. */
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 1);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &count);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(count == 1, "Got %ld streams.\n", count);
|
2008-04-05 01:00:05 +02:00
|
|
|
|
2008-04-05 01:00:41 +02:00
|
|
|
filename = NULL;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-01-16 03:30:28 +01:00
|
|
|
ok(!wcscmp(filename, test_avi_filename), "Expected filename %s, got %s.\n",
|
|
|
|
debugstr_w(test_avi_filename), debugstr_w(filename));
|
2008-04-05 01:00:41 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
2008-04-09 01:52:50 +02:00
|
|
|
hr = IMediaDet_get_Filename(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream index %ld.\n", index);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, -1);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 1);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
/* Try again. */
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream index %ld.\n", index);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-05 01:01:06 +02:00
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 0);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-05 01:01:06 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream index %ld.\n", index);
|
2008-04-05 01:01:06 +02:00
|
|
|
|
2008-04-05 01:01:27 +02:00
|
|
|
ZeroMemory(&mt, sizeof mt);
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
ok(IsEqualGUID(&mt.majortype, &MEDIATYPE_Video),
|
2008-04-05 01:01:27 +02:00
|
|
|
"IMediaDet_get_StreamMediaType\n");
|
2008-04-10 01:01:30 +02:00
|
|
|
CoTaskMemFree(mt.pbFormat);
|
2008-04-05 01:01:27 +02:00
|
|
|
|
2020-04-17 22:02:06 +02:00
|
|
|
hr = IMediaDet_get_StreamType(pM, &guid);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:06 +02:00
|
|
|
ok(IsEqualGUID(&guid, &MEDIATYPE_Video), "Got major type %s.\n", debugstr_guid(&guid));
|
|
|
|
|
2020-04-17 22:02:07 +02:00
|
|
|
hr = IMediaDet_get_StreamTypeB(pM, &bstr);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:07 +02:00
|
|
|
ok(!wcscmp(bstr, L"{73646976-0000-0010-8000-00AA00389B71}"),
|
|
|
|
"Got major type %s.\n", debugstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
2008-04-10 01:02:02 +02:00
|
|
|
hr = IMediaDet_get_FrameRate(pM, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_FrameRate(pM, &fps);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(fps == 10.0, "IMediaDet_get_FrameRate: fps is %f\n", fps);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
ref = IMediaDet_Release(pM);
|
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2008-04-05 00:59:08 +02:00
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
/* test_sound.avi has one video stream and one audio stream. */
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (LPVOID*)&pM);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-09 01:53:52 +02:00
|
|
|
ok(pM != NULL, "pM is NULL\n");
|
|
|
|
|
|
|
|
filename = SysAllocString(test_sound_avi_filename);
|
|
|
|
hr = IMediaDet_put_Filename(pM, filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-09 01:53:52 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &count);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(count == 2, "Got %ld streams.\n", count);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
|
|
|
filename = NULL;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-01-16 03:30:28 +01:00
|
|
|
ok(!wcscmp(filename, test_sound_avi_filename), "Expected filename %s, got %s.\n",
|
|
|
|
debugstr_w(test_sound_avi_filename), debugstr_w(filename));
|
2008-04-09 01:53:52 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
|
|
|
/* I don't know if the stream order is deterministic. Just check
|
|
|
|
for both an audio and video stream. */
|
|
|
|
flags = 0;
|
|
|
|
|
2008-04-10 01:02:02 +02:00
|
|
|
for (i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, i);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == i, "Got stream index %ld.\n", index);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
|
|
|
ZeroMemory(&mt, sizeof mt);
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
flags += (IsEqualGUID(&mt.majortype, &MEDIATYPE_Video)
|
|
|
|
? 1
|
|
|
|
: (IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio)
|
|
|
|
? 2
|
|
|
|
: 0));
|
|
|
|
|
|
|
|
if (IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio))
|
|
|
|
{
|
2020-04-17 22:02:06 +02:00
|
|
|
hr = IMediaDet_get_StreamType(pM, &guid);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:06 +02:00
|
|
|
ok(IsEqualGUID(&guid, &MEDIATYPE_Audio), "Got major type %s.\n", debugstr_guid(&guid));
|
|
|
|
|
2020-04-17 22:02:07 +02:00
|
|
|
hr = IMediaDet_get_StreamTypeB(pM, &bstr);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:07 +02:00
|
|
|
ok(!wcscmp(bstr, L"{73647561-0000-0010-8000-00AA00389B71}"),
|
|
|
|
"Got major type %s.\n", debugstr_w(bstr));
|
|
|
|
SysFreeString(bstr);
|
|
|
|
|
2008-04-10 01:02:02 +02:00
|
|
|
hr = IMediaDet_get_FrameRate(pM, &fps);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == VFW_E_INVALIDMEDIATYPE, "Got hr %#lx.\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(mt.pbFormat);
|
|
|
|
}
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(flags == 3, "IMediaDet_get_StreamMediaType: flags are %i\n", flags);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
index = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &index);
|
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 1, "Got stream index %ld.\n", index);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2020-04-17 22:02:08 +02:00
|
|
|
unk = NULL;
|
|
|
|
hr = IMediaDet_get_Filter(pM, &unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
ok(!!unk, "Expected a non-NULL filter.\n");
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void**)&filter);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
hr = IBaseFilter_EnumPins(filter, &enumpins);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
hr = IEnumPins_Next(enumpins, 1, &pin, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
hr = IPin_EnumMediaTypes(pin, &type);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
hr = IEnumMediaTypes_Next(type, 1, &pmt, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Stream), "Got major type %s.\n",
|
|
|
|
debugstr_guid(&pmt->majortype));
|
|
|
|
IEnumMediaTypes_Release(type);
|
|
|
|
CoTaskMemFree(pmt->pbFormat);
|
|
|
|
CoTaskMemFree(pmt);
|
|
|
|
IPin_Release(pin);
|
|
|
|
|
|
|
|
hr = IEnumPins_Next(enumpins, 1, &pin, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:08 +02:00
|
|
|
IEnumPins_Release(enumpins);
|
|
|
|
|
|
|
|
hr = IBaseFilter_QueryFilterInfo(filter, &filter_info);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-17 22:02:09 +02:00
|
|
|
ok(!wcscmp(filter_info.achName, L"Source"), "Got name %s.\n", debugstr_w(filter_info.achName));
|
2020-04-17 22:02:08 +02:00
|
|
|
IFilterGraph_Release(filter_info.pGraph);
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
|
2022-03-03 18:40:58 +01:00
|
|
|
ref = IMediaDet_Release(pM);
|
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2020-04-23 21:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_put_filter(void)
|
|
|
|
{
|
|
|
|
struct testfilter testfilter, testfilter2;
|
|
|
|
IFilterGraph *graph;
|
|
|
|
IBaseFilter *filter;
|
|
|
|
IMediaDet *detector;
|
|
|
|
LONG index, count;
|
|
|
|
AM_MEDIA_TYPE mt;
|
2020-04-27 21:14:05 +02:00
|
|
|
double duration;
|
2020-04-23 21:45:43 +02:00
|
|
|
IUnknown *unk;
|
|
|
|
BSTR filename;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (void **)&detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_Filter(detector, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_Filter(detector, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
2020-04-27 21:14:05 +02:00
|
|
|
hr = IMediaDet_get_StreamLength(detector, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
|
2020-04-27 21:14:05 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamLength(detector, &duration);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
|
2020-04-27 21:14:05 +02:00
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
testfilter_init(&testfilter);
|
|
|
|
hr = IMediaDet_put_Filter(detector, &testfilter.filter.IUnknown_inner);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
hr = IMediaDet_get_Filter(detector, &unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
ok(!!unk, "Expected a non-NULL interface.\n");
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
ok(filter == &testfilter.filter.IBaseFilter_iface, "Expected the same filter.\n");
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
ok(!wcscmp(testfilter.filter.name, L"Source"), "Got name %s.\n",
|
|
|
|
debugstr_w(testfilter.filter.name));
|
|
|
|
graph = testfilter.filter.graph;
|
|
|
|
IFilterGraph_AddRef(graph);
|
|
|
|
|
|
|
|
testfilter_init(&testfilter2);
|
|
|
|
hr = IMediaDet_put_Filter(detector, &testfilter2.filter.IUnknown_inner);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_Filter(detector, &unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
ok(!!unk, "Expected a non-NULL interface.\n");
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
ok(filter == &testfilter2.filter.IBaseFilter_iface, "Expected the same filter.\n");
|
|
|
|
IBaseFilter_Release(filter);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
ok(testfilter2.filter.graph != graph, "Expected a different graph.\n");
|
|
|
|
|
|
|
|
ref = IFilterGraph_Release(graph);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2020-04-23 21:45:43 +02:00
|
|
|
ref = IBaseFilter_Release(&testfilter.filter.IBaseFilter_iface);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_OutputStreams(detector, &count);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(count == 1, "Got %ld streams.\n", count);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
index = 0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_CurrentStream(detector, &index);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream %ld.\n", index);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
filename = (BSTR)0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_Filename(detector, &filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
ok(!filename, "Got filename %s.\n", debugstr_w(filename));
|
|
|
|
|
2020-04-27 21:14:05 +02:00
|
|
|
hr = IMediaDet_get_StreamLength(detector, &duration);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-27 21:14:05 +02:00
|
|
|
ok(duration == 4.2, "Got duration %.16e.\n", duration);
|
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
ref = IMediaDet_Release(detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2020-04-23 21:45:43 +02:00
|
|
|
ref = IBaseFilter_Release(&testfilter2.filter.IBaseFilter_iface);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (void **)&detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
filename = SysAllocString(test_sound_avi_filename);
|
|
|
|
hr = IMediaDet_put_Filename(detector, filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamMediaType(detector, &mt);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
FreeMediaType(&mt);
|
|
|
|
|
|
|
|
hr = IMediaDet_get_Filter(detector, &unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
hr = IMediaDet_put_Filter(detector, unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:43 +02:00
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
filename = (BSTR)0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_Filename(detector, &filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2020-04-23 21:45:44 +02:00
|
|
|
ok(!filename, "Got filename %s.\n", debugstr_w(filename));
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
count = 0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_OutputStreams(detector, &count);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(count == 2, "Got %ld streams.\n", count);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
index = 0xdeadbeef;
|
|
|
|
hr = IMediaDet_get_CurrentStream(detector, &index);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
|
|
|
ok(index == 0, "Got stream %ld.\n", index);
|
2020-04-23 21:45:43 +02:00
|
|
|
|
|
|
|
ref = IMediaDet_Release(detector);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(!ref, "Got outstanding refcount %ld.\n", ref);
|
2008-02-13 23:47:12 +01:00
|
|
|
}
|
|
|
|
|
2016-05-16 15:28:38 +02:00
|
|
|
static HRESULT WINAPI ms_QueryInterface(IMediaSample *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ms_AddRef(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ms_Release(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_GetPointer(IMediaSample *iface, BYTE **ppBuffer)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG WINAPI ms_GetSize(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_GetTime(IMediaSample *iface, REFERENCE_TIME *pTimeStart,
|
|
|
|
REFERENCE_TIME *pTimeEnd)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetTime(IMediaSample *iface, REFERENCE_TIME *pTimeStart,
|
|
|
|
REFERENCE_TIME *pTimeEnd)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_IsSyncPoint(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetSyncPoint(IMediaSample *iface, BOOL bIsSyncPoint)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_IsPreroll(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetPreroll(IMediaSample *iface, BOOL bIsPreroll)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG WINAPI ms_GetActualDataLength(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetActualDataLength(IMediaSample *iface, LONG length)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_GetMediaType(IMediaSample *iface, AM_MEDIA_TYPE
|
|
|
|
**ppMediaType)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetMediaType(IMediaSample *iface, AM_MEDIA_TYPE *pMediaType)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_IsDiscontinuity(IMediaSample *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetDiscontinuity(IMediaSample *iface, BOOL bDiscontinuity)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_GetMediaTime(IMediaSample *iface, LONGLONG *pTimeStart,
|
|
|
|
LONGLONG *pTimeEnd)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ms_SetMediaTime(IMediaSample *iface, LONGLONG *pTimeStart,
|
|
|
|
LONGLONG *pTimeEnd)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSampleVtbl my_sample_vt = {
|
|
|
|
ms_QueryInterface,
|
|
|
|
ms_AddRef,
|
|
|
|
ms_Release,
|
|
|
|
ms_GetPointer,
|
|
|
|
ms_GetSize,
|
|
|
|
ms_GetTime,
|
|
|
|
ms_SetTime,
|
|
|
|
ms_IsSyncPoint,
|
|
|
|
ms_SetSyncPoint,
|
|
|
|
ms_IsPreroll,
|
|
|
|
ms_SetPreroll,
|
|
|
|
ms_GetActualDataLength,
|
|
|
|
ms_SetActualDataLength,
|
|
|
|
ms_GetMediaType,
|
|
|
|
ms_SetMediaType,
|
|
|
|
ms_IsDiscontinuity,
|
|
|
|
ms_SetDiscontinuity,
|
|
|
|
ms_GetMediaTime,
|
|
|
|
ms_SetMediaTime
|
|
|
|
};
|
|
|
|
|
|
|
|
static IMediaSample my_sample = { &my_sample_vt };
|
|
|
|
|
|
|
|
static BOOL samplecb_called = FALSE;
|
|
|
|
|
|
|
|
static HRESULT WINAPI sgcb_QueryInterface(ISampleGrabberCB *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sgcb_AddRef(ISampleGrabberCB *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sgcb_Release(ISampleGrabberCB *iface)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI sgcb_SampleCB(ISampleGrabberCB *iface, double SampleTime,
|
|
|
|
IMediaSample *pSample)
|
|
|
|
{
|
|
|
|
ok(pSample == &my_sample, "Got wrong IMediaSample: %p, expected %p\n", pSample, &my_sample);
|
|
|
|
samplecb_called = TRUE;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI sgcb_BufferCB(ISampleGrabberCB *iface, double SampleTime,
|
|
|
|
BYTE *pBuffer, LONG BufferLen)
|
|
|
|
{
|
|
|
|
ok(0, "BufferCB should not have been called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ISampleGrabberCBVtbl sgcb_vt = {
|
|
|
|
sgcb_QueryInterface,
|
|
|
|
sgcb_AddRef,
|
|
|
|
sgcb_Release,
|
|
|
|
sgcb_SampleCB,
|
|
|
|
sgcb_BufferCB
|
|
|
|
};
|
|
|
|
|
|
|
|
static ISampleGrabberCB my_sg_cb = { &sgcb_vt };
|
|
|
|
|
2011-11-21 14:46:57 +01:00
|
|
|
static void test_samplegrabber(void)
|
|
|
|
{
|
|
|
|
ISampleGrabber *sg;
|
2014-02-12 01:05:05 +01:00
|
|
|
IBaseFilter *bf;
|
2016-05-16 15:28:38 +02:00
|
|
|
IPin *pin;
|
|
|
|
IMemInputPin *inpin;
|
|
|
|
IEnumPins *pins;
|
2011-11-21 14:46:57 +01:00
|
|
|
HRESULT hr;
|
2016-05-16 15:28:38 +02:00
|
|
|
FILTER_STATE fstate;
|
2011-11-21 14:46:57 +01:00
|
|
|
|
2014-02-12 01:05:05 +01:00
|
|
|
/* Invalid RIID */
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory,
|
|
|
|
(void**)&sg);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
|
2014-02-12 01:05:05 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_ISampleGrabber,
|
|
|
|
(void**)&sg);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:05:05 +01:00
|
|
|
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IBaseFilter, (void**)&bf);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:05:05 +01:00
|
|
|
|
2016-05-16 15:28:38 +02:00
|
|
|
hr = ISampleGrabber_SetCallback(sg, &my_sg_cb, 0);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
|
|
|
|
hr = IBaseFilter_GetState(bf, 100, &fstate);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
ok(fstate == State_Stopped, "Got wrong filter state: %u\n", fstate);
|
|
|
|
|
|
|
|
hr = IBaseFilter_EnumPins(bf, &pins);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
|
|
|
|
hr = IEnumPins_Next(pins, 1, &pin, NULL);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
|
|
|
|
IEnumPins_Release(pins);
|
|
|
|
|
|
|
|
hr = IPin_QueryInterface(pin, &IID_IMemInputPin, (void**)&inpin);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
|
|
|
|
hr = IMemInputPin_Receive(inpin, &my_sample);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2016-05-16 15:28:38 +02:00
|
|
|
ok(samplecb_called == TRUE, "SampleCB should have been called\n");
|
|
|
|
|
|
|
|
IMemInputPin_Release(inpin);
|
|
|
|
IPin_Release(pin);
|
|
|
|
|
2014-02-12 01:05:05 +01:00
|
|
|
while (ISampleGrabber_Release(sg));
|
2011-11-21 14:46:57 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 01:10:54 +01:00
|
|
|
static void test_COM_sg_enumpins(void)
|
|
|
|
{
|
|
|
|
IBaseFilter *bf;
|
|
|
|
IEnumPins *pins, *pins2;
|
|
|
|
IUnknown *unk;
|
|
|
|
ULONG refcount;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter,
|
|
|
|
(void**)&bf);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:10:54 +01:00
|
|
|
hr = IBaseFilter_EnumPins(bf, &pins);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:10:54 +01:00
|
|
|
|
|
|
|
/* Same refcount for all EnumPins interfaces */
|
|
|
|
refcount = IEnumPins_AddRef(pins);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
|
2014-02-12 01:10:54 +01:00
|
|
|
hr = IEnumPins_QueryInterface(pins, &IID_IEnumPins, (void**)&pins2);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:10:54 +01:00
|
|
|
ok(pins == pins2, "QueryInterface for self failed (%p != %p)\n", pins, pins2);
|
|
|
|
IEnumPins_Release(pins2);
|
|
|
|
|
|
|
|
hr = IEnumPins_QueryInterface(pins, &IID_IUnknown, (void**)&unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
2014-02-12 01:10:54 +01:00
|
|
|
refcount = IUnknown_AddRef(unk);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
|
2014-02-12 01:10:54 +01:00
|
|
|
refcount = IUnknown_Release(unk);
|
|
|
|
|
|
|
|
while (IEnumPins_Release(pins));
|
|
|
|
IBaseFilter_Release(bf);
|
|
|
|
}
|
|
|
|
|
2008-02-13 23:47:12 +01:00
|
|
|
START_TEST(mediadet)
|
|
|
|
{
|
2019-04-19 06:01:22 +02:00
|
|
|
IMediaDet *detector;
|
|
|
|
HRESULT hr;
|
2020-04-23 21:45:43 +02:00
|
|
|
BOOL ret;
|
2019-04-19 06:01:22 +02:00
|
|
|
|
2008-04-05 00:59:08 +02:00
|
|
|
if (!init_tests())
|
|
|
|
{
|
|
|
|
skip("Couldn't initialize tests!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-13 23:47:12 +01:00
|
|
|
CoInitialize(NULL);
|
2019-04-16 06:20:51 +02:00
|
|
|
|
2019-04-19 06:01:22 +02:00
|
|
|
if (FAILED(hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IMediaDet, (void **)&detector)))
|
|
|
|
{
|
|
|
|
/* qedit.dll does not exist on 2003. */
|
2022-03-03 18:40:58 +01:00
|
|
|
win_skip("Failed to create media detector object, hr %#lx.\n", hr);
|
2019-04-19 06:01:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
IMediaDet_Release(detector);
|
|
|
|
|
2019-04-16 06:20:51 +02:00
|
|
|
test_aggregation();
|
2008-02-13 23:47:12 +01:00
|
|
|
test_mediadet();
|
2020-04-23 21:45:43 +02:00
|
|
|
test_put_filter();
|
2011-11-21 14:46:57 +01:00
|
|
|
test_samplegrabber();
|
2014-02-12 01:10:54 +01:00
|
|
|
test_COM_sg_enumpins();
|
2019-04-16 06:20:51 +02:00
|
|
|
|
2020-04-23 21:45:43 +02:00
|
|
|
ret = DeleteFileW(test_avi_filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
|
2020-04-23 21:45:43 +02:00
|
|
|
ret = DeleteFileW(test_sound_avi_filename);
|
2022-03-03 18:40:58 +01:00
|
|
|
ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
|
2020-04-23 21:45:43 +02:00
|
|
|
|
2008-04-05 00:58:17 +02:00
|
|
|
CoUninitialize();
|
2008-02-13 23:47:12 +01:00
|
|
|
}
|