2004-08-16 23:14:28 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for Direct Show functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-08-16 23:14:28 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2004-08-19 21:20:34 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-08-16 23:14:28 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "control.h"
|
|
|
|
|
2004-12-16 15:25:15 +01:00
|
|
|
static const WCHAR file[] = {'t','e','s','t','.','a','v','i',0};
|
|
|
|
|
2004-08-16 23:14:28 +02:00
|
|
|
IGraphBuilder* pgraph;
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static int createfiltergraph(void)
|
2004-08-16 23:14:28 +02:00
|
|
|
{
|
2005-03-25 11:25:24 +01:00
|
|
|
return S_OK == CoCreateInstance(
|
|
|
|
&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&pgraph);
|
2004-08-16 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void renderfile(void)
|
2004-08-16 23:14:28 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IGraphBuilder_RenderFile(pgraph, file, NULL);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "RenderFile returned: %x\n", hr);
|
2004-08-16 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void rungraph(void)
|
2004-08-16 23:14:28 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IMediaControl* pmc;
|
2005-03-02 11:12:12 +01:00
|
|
|
IMediaEvent* pme;
|
|
|
|
HANDLE hEvent;
|
2004-08-16 23:14:28 +02:00
|
|
|
|
|
|
|
hr = IGraphBuilder_QueryInterface(pgraph, &IID_IMediaControl, (LPVOID*)&pmc);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Cannot get IMediaControl interface returned: %x\n", hr);
|
2004-08-16 23:14:28 +02:00
|
|
|
|
|
|
|
hr = IMediaControl_Run(pmc);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_FALSE, "Cannot run the graph returned: %x\n", hr);
|
2004-12-16 15:25:15 +01:00
|
|
|
|
2005-03-02 11:12:12 +01:00
|
|
|
hr = IGraphBuilder_QueryInterface(pgraph, &IID_IMediaEvent, (LPVOID*)&pme);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Cannot get IMediaEvent interface returned: %x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
hr = IMediaEvent_GetEventHandle(pme, (OAEVENT*)&hEvent);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Cannot get event handle returned: %x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
/* WaitForSingleObject(hEvent, INFINITE); */
|
2004-12-16 15:25:15 +01:00
|
|
|
Sleep(20000);
|
2004-08-16 23:14:28 +02:00
|
|
|
|
2005-03-02 11:12:12 +01:00
|
|
|
hr = IMediaControl_Release(pme);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==2, "Releasing mediaevent returned: %x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
2004-12-16 15:25:15 +01:00
|
|
|
hr = IMediaControl_Stop(pmc);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==S_OK, "Cannot stop the graph returned: %x\n", hr);
|
2004-12-16 15:25:15 +01:00
|
|
|
|
|
|
|
hr = IMediaControl_Release(pmc);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==1, "Releasing mediacontrol returned: %x\n", hr);
|
2004-08-16 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void releasefiltergraph(void)
|
2004-08-16 23:14:28 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IGraphBuilder_Release(pgraph);
|
2006-10-08 00:48:51 +02:00
|
|
|
ok(hr==0, "Releasing filtergraph returned: %x\n", hr);
|
2004-08-16 23:14:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(filtergraph)
|
|
|
|
{
|
2004-12-16 15:25:15 +01:00
|
|
|
HANDLE h;
|
|
|
|
|
2004-11-29 18:01:21 +01:00
|
|
|
CoInitialize(NULL);
|
2005-03-25 11:25:24 +01:00
|
|
|
if (!createfiltergraph())
|
|
|
|
return;
|
2004-12-16 15:25:15 +01:00
|
|
|
|
|
|
|
h = CreateFileW(file, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
|
|
|
if (h != INVALID_HANDLE_VALUE) {
|
|
|
|
CloseHandle(h);
|
|
|
|
renderfile();
|
|
|
|
rungraph();
|
|
|
|
}
|
|
|
|
|
2004-08-16 23:14:28 +02:00
|
|
|
releasefiltergraph();
|
|
|
|
}
|