2 * Unit tests for MultiMedia Stream functions
4 * Copyright (C) 2009 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
30 static const char fileA
[FILE_LEN
] = "test.avi";
32 IAMMultiMediaStream
* pams
;
33 IDirectDraw7
* pdd7
= NULL
;
34 IDirectDrawSurface7
* pdds7
= NULL
;
36 static int create_ammultimediastream(void)
38 return S_OK
== CoCreateInstance(
39 &CLSID_AMMultiMediaStream
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IAMMultiMediaStream
, (LPVOID
*)&pams
);
42 static void release_ammultimediastream(void)
44 IAMMultiMediaStream_Release(pams
);
47 static int create_directdraw(void)
50 IDirectDraw
* pdd
= NULL
;
53 hr
= DirectDrawCreate(NULL
, &pdd
, NULL
);
54 ok(hr
==DD_OK
, "DirectDrawCreate returned: %x\n", hr
);
58 hr
= IDirectDraw_QueryInterface(pdd
, &IID_IDirectDraw7
, (LPVOID
*)&pdd7
);
59 ok(hr
==DD_OK
, "QueryInterface returned: %x\n", hr
);
60 if (hr
!= DD_OK
) goto error
;
62 hr
= IDirectDraw7_SetCooperativeLevel(pdd7
, GetDesktopWindow(), DDSCL_NORMAL
);
63 ok(hr
==DD_OK
, "SetCooperativeLevel returned: %x\n", hr
);
65 ZeroMemory(&ddsd
, sizeof(ddsd
));
66 ddsd
.dwSize
= sizeof(ddsd
);
67 ddsd
.dwFlags
= DDSD_CAPS
;
68 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
;
69 hr
= IDirectDraw7_CreateSurface(pdd7
, &ddsd
, &pdds7
, NULL
);
70 ok(hr
==DD_OK
, "CreateSurface returned: %x\n", hr
);
76 IDirectDrawSurface7_Release(pdds7
);
78 IDirectDraw7_Release(pdd7
);
80 IDirectDraw_Release(pdd
);
85 static void release_directdraw(void)
87 IDirectDrawSurface7_Release(pdds7
);
88 IDirectDraw7_Release(pdd7
);
91 static void test_openfile(void)
95 WCHAR fileW
[FILE_LEN
];
96 IGraphBuilder
* pgraph
;
98 if (!create_ammultimediastream())
101 h
= CreateFileA(fileA
, 0, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
102 if (h
== INVALID_HANDLE_VALUE
) {
103 release_ammultimediastream();
107 MultiByteToWideChar(CP_ACP
, 0, fileA
, -1, fileW
, FILE_LEN
);
109 hr
= IAMMultiMediaStream_GetFilterGraph(pams
, &pgraph
);
110 ok(hr
==S_OK
, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr
);
111 ok(pgraph
==NULL
, "Filtergraph should not be created yet\n");
114 IGraphBuilder_Release(pgraph
);
116 hr
= IAMMultiMediaStream_OpenFile(pams
, fileW
, 0);
117 ok(hr
==S_OK
, "IAMMultiMediaStream_OpenFile returned: %x\n", hr
);
119 hr
= IAMMultiMediaStream_GetFilterGraph(pams
, &pgraph
);
120 ok(hr
==S_OK
, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr
);
121 ok(pgraph
!=NULL
, "Filtergraph should be created\n");
124 IGraphBuilder_Release(pgraph
);
126 release_ammultimediastream();
129 static void renderfile(const char * fileA
)
132 WCHAR fileW
[FILE_LEN
];
133 IMediaStream
*pvidstream
= NULL
;
134 IDirectDrawMediaStream
*pddstream
= NULL
;
135 IDirectDrawStreamSample
*pddsample
= NULL
;
137 if (!create_directdraw())
140 MultiByteToWideChar(CP_ACP
, 0, fileA
, -1, fileW
, FILE_LEN
);
142 hr
= IAMMultiMediaStream_Initialize(pams
, STREAMTYPE_READ
, 0, NULL
);
143 ok(hr
==S_OK
, "IAMMultiMediaStream_Initialize returned: %x\n", hr
);
145 hr
= IAMMultiMediaStream_AddMediaStream(pams
, (IUnknown
*)pdd7
, &MSPID_PrimaryVideo
, 0, NULL
);
146 ok(hr
==S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
148 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryAudio
, AMMSF_ADDDEFAULTRENDERER
, NULL
);
149 ok(hr
==S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
151 hr
= IAMMultiMediaStream_OpenFile(pams
, fileW
, 0);
152 ok(hr
==S_OK
, "IAMMultiMediaStream_OpenFile returned: %x\n", hr
);
154 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &pvidstream
);
155 ok(hr
==S_OK
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
156 if (FAILED(hr
)) goto error
;
158 hr
= IMediaStream_QueryInterface(pvidstream
, &IID_IDirectDrawMediaStream
, (LPVOID
*)&pddstream
);
159 ok(hr
==S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
160 if (FAILED(hr
)) goto error
;
162 hr
= IDirectDrawMediaStream_CreateSample(pddstream
, NULL
, NULL
, 0, &pddsample
);
163 todo_wine
ok(hr
==S_OK
, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr
);
167 IDirectDrawMediaSample_Release(pddsample
);
169 IDirectDrawMediaStream_Release(pddstream
);
171 IMediaStream_Release(pvidstream
);
173 release_directdraw();
176 static void test_render(void)
180 if (!create_ammultimediastream())
183 h
= CreateFileA(fileA
, 0, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
184 if (h
!= INVALID_HANDLE_VALUE
) {
189 release_ammultimediastream();
194 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);