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-07-08 16:17:17 +02:00
|
|
|
#include "initguid.h"
|
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"
|
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
|
|
|
|
2011-11-21 14:46:57 +01:00
|
|
|
/* Outer IUnknown for COM aggregation tests */
|
|
|
|
struct unk_impl {
|
|
|
|
IUnknown IUnknown_iface;
|
|
|
|
LONG ref;
|
|
|
|
IUnknown *inner_unk;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
struct unk_impl *This = impl_from_IUnknown(iface);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(This->inner_unk, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unk_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct unk_impl *This = impl_from_IUnknown(iface);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unk_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct unk_impl *This = impl_from_IUnknown(iface);
|
|
|
|
|
|
|
|
return InterlockedDecrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl unk_vtbl =
|
|
|
|
{
|
|
|
|
unk_QueryInterface,
|
|
|
|
unk_AddRef,
|
|
|
|
unk_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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];
|
2013-12-28 14:10:44 +01:00
|
|
|
static const WCHAR prefix[] = {'D','E','S',0};
|
|
|
|
static const WCHAR avi[] = {'a','v','i',0};
|
2008-04-05 00:59:08 +02:00
|
|
|
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. */
|
2008-04-09 01:53:52 +02:00
|
|
|
if (!GetTempFileNameW(temp_path, prefix, 0, name))
|
2008-04-05 00:59:08 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
DeleteFileW(name);
|
|
|
|
lstrcpyW(name + lstrlenW(name) - 3, 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;
|
2012-07-01 00:07:41 +02:00
|
|
|
struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
|
2008-02-13 23:47:12 +01:00
|
|
|
IMediaDet *pM = NULL;
|
2012-07-01 00:07:41 +02:00
|
|
|
ULONG refcount;
|
2008-04-05 00:59:08 +02:00
|
|
|
BSTR filename = NULL;
|
2009-03-12 01:42:24 +01:00
|
|
|
LONG nstrms = 0;
|
|
|
|
LONG strm;
|
2008-04-05 01:01:27 +02:00
|
|
|
AM_MEDIA_TYPE mt;
|
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
|
|
|
|
2012-07-01 00:07:41 +02:00
|
|
|
/* COM aggregation */
|
|
|
|
hr = CoCreateInstance(&CLSID_MediaDet, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IUnknown, (void**)&unk_obj.inner_unk);
|
|
|
|
ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk_obj.inner_unk, &IID_IMediaDet, (void**)&pM);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IMediaDet failed: %08x\n", hr);
|
|
|
|
refcount = IMediaDet_AddRef(pM);
|
|
|
|
ok(refcount == unk_obj.ref, "MediaDet just pretends to support COM aggregation\n");
|
|
|
|
refcount = IMediaDet_Release(pM);
|
|
|
|
ok(refcount == unk_obj.ref, "MediaDet just pretends to support COM aggregation\n");
|
|
|
|
refcount = IMediaDet_Release(pM);
|
|
|
|
ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
|
|
|
|
|
|
|
|
IUnknown_Release(unk_obj.inner_unk);
|
|
|
|
|
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);
|
|
|
|
ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
|
|
|
|
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. */
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\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. */
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
ok(filename == NULL, "IMediaDet_get_Filename\n");
|
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
nstrms = -1;
|
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &nstrms);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
|
|
|
|
ok(nstrms == -1, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
strm = -1;
|
|
|
|
/* The stream defaults to 0, even without a file! */
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, NULL);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_POINTER, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
/* But put_CurrentStream doesn't. */
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 0);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, -1);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-10 01:01:30 +02:00
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, NULL);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_POINTER, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
|
2008-04-05 00:59:08 +02:00
|
|
|
filename = SysAllocString(test_avi_filename);
|
|
|
|
hr = IMediaDet_put_Filename(pM, filename);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr);
|
2008-04-05 00:59:08 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
strm = -1;
|
|
|
|
/* The stream defaults to 0. */
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
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);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
|
2008-04-10 01:01:30 +02:00
|
|
|
CoTaskMemFree(mt.pbFormat);
|
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
/* Even before get_OutputStreams. */
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 1);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-05 01:00:05 +02:00
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &nstrms);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
|
|
|
|
ok(nstrms == 1, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
|
2008-04-05 01:00:05 +02:00
|
|
|
|
2008-04-05 01:00:41 +02:00
|
|
|
filename = NULL;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
ok(lstrcmpW(filename, test_avi_filename) == 0,
|
|
|
|
"IMediaDet_get_Filename\n");
|
2008-04-05 01:00:41 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
2008-04-09 01:52:50 +02:00
|
|
|
hr = IMediaDet_get_Filename(pM, NULL);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_POINTER, "IMediaDet_get_Filename failed: %08x\n", hr);
|
2008-04-09 01:52:50 +02:00
|
|
|
|
2008-04-09 01:55:37 +02:00
|
|
|
strm = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, NULL);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_POINTER, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, -1);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 1);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
/* Try again. */
|
|
|
|
strm = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-05 01:01:06 +02:00
|
|
|
hr = IMediaDet_put_CurrentStream(pM, 0);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-05 01:01:06 +02:00
|
|
|
|
|
|
|
strm = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
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);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\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
|
|
|
|
2008-04-10 01:02:02 +02:00
|
|
|
hr = IMediaDet_get_FrameRate(pM, NULL);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_POINTER, "IMediaDet_get_FrameRate failed: %08x\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
|
|
|
hr = IMediaDet_get_FrameRate(pM, &fps);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_FrameRate failed: %08x\n", hr);
|
|
|
|
ok(fps == 10.0, "IMediaDet_get_FrameRate: fps is %f\n", fps);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
2008-02-13 23:12:17 +01:00
|
|
|
hr = IMediaDet_Release(pM);
|
|
|
|
ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
|
2008-04-05 00:59:08 +02:00
|
|
|
|
|
|
|
DeleteFileW(test_avi_filename);
|
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);
|
|
|
|
ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
|
|
|
|
ok(pM != NULL, "pM is NULL\n");
|
|
|
|
|
|
|
|
filename = SysAllocString(test_sound_avi_filename);
|
|
|
|
hr = IMediaDet_put_Filename(pM, filename);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr);
|
2008-04-09 01:53:52 +02:00
|
|
|
SysFreeString(filename);
|
|
|
|
|
|
|
|
hr = IMediaDet_get_OutputStreams(pM, &nstrms);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
|
|
|
|
ok(nstrms == 2, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
|
2008-04-09 01:53:52 +02:00
|
|
|
|
|
|
|
filename = NULL;
|
|
|
|
hr = IMediaDet_get_Filename(pM, &filename);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
|
2008-04-09 01:53:52 +02:00
|
|
|
ok(lstrcmpW(filename, test_sound_avi_filename) == 0,
|
|
|
|
"IMediaDet_get_Filename\n");
|
|
|
|
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);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
|
|
|
strm = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == i, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
2008-04-10 01:02:02 +02:00
|
|
|
|
|
|
|
ZeroMemory(&mt, sizeof mt);
|
|
|
|
hr = IMediaDet_get_StreamMediaType(pM, &mt);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\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))
|
|
|
|
{
|
|
|
|
hr = IMediaDet_get_FrameRate(pM, &fps);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == VFW_E_INVALIDMEDIATYPE, "IMediaDet_get_FrameRate failed: %08x\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);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
|
|
|
strm = -1;
|
|
|
|
hr = IMediaDet_get_CurrentStream(pM, &strm);
|
2013-04-27 17:50:57 +02:00
|
|
|
ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
|
|
|
|
ok(strm == 1, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
|
2008-04-09 01:55:37 +02:00
|
|
|
|
2008-04-09 01:53:52 +02:00
|
|
|
hr = IMediaDet_Release(pM);
|
|
|
|
ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
|
|
|
|
|
|
|
|
DeleteFileW(test_sound_avi_filename);
|
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)
|
|
|
|
{
|
|
|
|
struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
|
|
|
|
ISampleGrabber *sg;
|
2014-02-12 01:05:05 +01:00
|
|
|
IBaseFilter *bf;
|
|
|
|
IMediaFilter *mf;
|
|
|
|
IPersist *persist;
|
|
|
|
IUnknown *unk;
|
2016-05-16 15:28:38 +02:00
|
|
|
IPin *pin;
|
|
|
|
IMemInputPin *inpin;
|
|
|
|
IEnumPins *pins;
|
2011-11-21 14:46:57 +01:00
|
|
|
ULONG refcount;
|
|
|
|
HRESULT hr;
|
2016-05-16 15:28:38 +02:00
|
|
|
FILTER_STATE fstate;
|
2011-11-21 14:46:57 +01:00
|
|
|
|
|
|
|
/* COM aggregation */
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IUnknown, (void**)&unk_obj.inner_unk);
|
2012-06-26 23:54:49 +02:00
|
|
|
ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
|
2011-11-21 14:46:57 +01:00
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk_obj.inner_unk, &IID_ISampleGrabber, (void**)&sg);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_ISampleGrabber failed: %08x\n", hr);
|
|
|
|
refcount = ISampleGrabber_AddRef(sg);
|
|
|
|
ok(refcount == unk_obj.ref, "SampleGrabber just pretends to support COM aggregation\n");
|
|
|
|
refcount = ISampleGrabber_Release(sg);
|
|
|
|
ok(refcount == unk_obj.ref, "SampleGrabber just pretends to support COM aggregation\n");
|
|
|
|
refcount = ISampleGrabber_Release(sg);
|
|
|
|
ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
|
|
|
|
IUnknown_Release(unk_obj.inner_unk);
|
2014-02-12 01:05:05 +01:00
|
|
|
|
|
|
|
/* Invalid RIID */
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory,
|
|
|
|
(void**)&sg);
|
|
|
|
ok(hr == E_NOINTERFACE, "SampleGrabber create failed: %08x, expected E_NOINTERFACE\n", hr);
|
|
|
|
|
|
|
|
/* Same refcount for all SampleGrabber interfaces */
|
|
|
|
hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_ISampleGrabber,
|
|
|
|
(void**)&sg);
|
|
|
|
ok(hr == S_OK, "SampleGrabber create failed: %08x, expected S_OK\n", hr);
|
|
|
|
refcount = ISampleGrabber_AddRef(sg);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
|
|
|
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IBaseFilter, (void**)&bf);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IBaseFilter failed: %08x\n", hr);
|
|
|
|
refcount = IBaseFilter_AddRef(bf);
|
|
|
|
ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
|
|
|
|
refcount = IBaseFilter_Release(bf);
|
|
|
|
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaFilter, (void**)&mf);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IMediaFilter failed: %08x\n", hr);
|
|
|
|
refcount = IMediaFilter_AddRef(mf);
|
|
|
|
ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
|
|
|
|
refcount = IMediaFilter_Release(mf);
|
|
|
|
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IPersist, (void**)&persist);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IPersist failed: %08x\n", hr);
|
|
|
|
refcount = IPersist_AddRef(persist);
|
|
|
|
ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
|
|
|
|
refcount = IPersist_Release(persist);
|
|
|
|
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
|
|
|
|
refcount = IUnknown_AddRef(unk);
|
|
|
|
ok(refcount == 7, "refcount == %u, expected 7\n", refcount);
|
|
|
|
refcount = IUnknown_Release(unk);
|
|
|
|
|
2016-05-16 15:28:38 +02:00
|
|
|
hr = ISampleGrabber_SetCallback(sg, &my_sg_cb, 0);
|
|
|
|
ok(hr == S_OK, "SetCallback failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IBaseFilter_GetState(bf, 100, &fstate);
|
|
|
|
ok(hr == S_OK, "Failed to get filter state: %08x\n", hr);
|
|
|
|
ok(fstate == State_Stopped, "Got wrong filter state: %u\n", fstate);
|
|
|
|
|
|
|
|
hr = IBaseFilter_EnumPins(bf, &pins);
|
|
|
|
ok(hr == S_OK, "EnumPins create failed: %08x, expected S_OK\n", hr);
|
|
|
|
|
|
|
|
hr = IEnumPins_Next(pins, 1, &pin, NULL);
|
|
|
|
ok(hr == S_OK, "Next failed: %08x\n", hr);
|
|
|
|
|
|
|
|
IEnumPins_Release(pins);
|
|
|
|
|
|
|
|
hr = IPin_QueryInterface(pin, &IID_IMemInputPin, (void**)&inpin);
|
|
|
|
ok(hr == S_OK, "QueryInterface(IMemInputPin) failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMemInputPin_Receive(inpin, &my_sample);
|
|
|
|
ok(hr == S_OK, "Receive failed: %08x\n", hr);
|
|
|
|
ok(samplecb_called == TRUE, "SampleCB should have been called\n");
|
|
|
|
|
|
|
|
IMemInputPin_Release(inpin);
|
|
|
|
IPin_Release(pin);
|
|
|
|
|
2014-02-12 01:05:05 +01:00
|
|
|
/* Interfaces that native does not support */
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaPosition, (void**)&unk);
|
|
|
|
todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMediaPosition failed: %08x\n", hr);
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaSeeking, (void**)&unk);
|
|
|
|
todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMediaSeeking failed: %08x\n", hr);
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IMemInputPin, (void**)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMemInputPin failed: %08x\n", hr);
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_IQualityControl, (void**)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IQualityControl failed: %08x\n", hr);
|
|
|
|
hr = ISampleGrabber_QueryInterface(sg, &IID_ISeekingPassThru, (void**)&unk);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_ISeekingPassThru failed: %08x\n", hr);
|
|
|
|
|
|
|
|
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);
|
|
|
|
ok(hr == S_OK, "SampleGrabber create failed: %08x, expected S_OK\n", hr);
|
|
|
|
hr = IBaseFilter_EnumPins(bf, &pins);
|
|
|
|
ok(hr == S_OK, "EnumPins create failed: %08x, expected S_OK\n", hr);
|
|
|
|
|
|
|
|
/* Same refcount for all EnumPins interfaces */
|
|
|
|
refcount = IEnumPins_AddRef(pins);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
|
|
|
hr = IEnumPins_QueryInterface(pins, &IID_IEnumPins, (void**)&pins2);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IEnumPins failed: %08x\n", hr);
|
|
|
|
ok(pins == pins2, "QueryInterface for self failed (%p != %p)\n", pins, pins2);
|
|
|
|
IEnumPins_Release(pins2);
|
|
|
|
|
|
|
|
hr = IEnumPins_QueryInterface(pins, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
|
|
|
|
refcount = IUnknown_AddRef(unk);
|
|
|
|
ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
|
|
|
|
refcount = IUnknown_Release(unk);
|
|
|
|
|
|
|
|
while (IEnumPins_Release(pins));
|
|
|
|
IBaseFilter_Release(bf);
|
|
|
|
}
|
|
|
|
|
2008-02-13 23:47:12 +01:00
|
|
|
START_TEST(mediadet)
|
|
|
|
{
|
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);
|
|
|
|
test_mediadet();
|
2011-11-21 14:46:57 +01:00
|
|
|
test_samplegrabber();
|
2014-02-12 01:10:54 +01:00
|
|
|
test_COM_sg_enumpins();
|
2008-04-05 00:58:17 +02:00
|
|
|
CoUninitialize();
|
2008-02-13 23:47:12 +01:00
|
|
|
}
|