2 * Unit tests for MultiMedia Stream functions
4 * Copyright (C) 2009, 2012 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
23 #include "wine/test.h"
29 #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
30 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
32 ULONG rc
= IUnknown_AddRef(obj
);
33 IUnknown_Release(obj
);
34 ok_(__FILE__
,line
)(rc
-1 == ref
, "expected refcount %d, got %d\n", ref
, rc
-1);
37 static const WCHAR filenameW
[] = {'t','e','s','t','.','a','v','i',0};
39 static IDirectDraw7
* pdd7
;
40 static IDirectDrawSurface7
* pdds7
;
42 static IAMMultiMediaStream
*create_ammultimediastream(void)
44 IAMMultiMediaStream
*stream
= NULL
;
45 CoCreateInstance(&CLSID_AMMultiMediaStream
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IAMMultiMediaStream
,
50 static int create_directdraw(void)
53 IDirectDraw
* pdd
= NULL
;
56 hr
= DirectDrawCreate(NULL
, &pdd
, NULL
);
57 ok(hr
==DD_OK
, "DirectDrawCreate returned: %x\n", hr
);
61 hr
= IDirectDraw_QueryInterface(pdd
, &IID_IDirectDraw7
, (LPVOID
*)&pdd7
);
62 ok(hr
==DD_OK
, "QueryInterface returned: %x\n", hr
);
63 if (hr
!= DD_OK
) goto error
;
65 hr
= IDirectDraw7_SetCooperativeLevel(pdd7
, GetDesktopWindow(), DDSCL_NORMAL
);
66 ok(hr
==DD_OK
, "SetCooperativeLevel returned: %x\n", hr
);
68 ZeroMemory(&ddsd
, sizeof(ddsd
));
69 ddsd
.dwSize
= sizeof(ddsd
);
70 ddsd
.dwFlags
= DDSD_CAPS
;
71 ddsd
.ddsCaps
.dwCaps
= DDSCAPS_PRIMARYSURFACE
;
72 hr
= IDirectDraw7_CreateSurface(pdd7
, &ddsd
, &pdds7
, NULL
);
73 ok(hr
==DD_OK
, "CreateSurface returned: %x\n", hr
);
79 IDirectDrawSurface7_Release(pdds7
);
81 IDirectDraw7_Release(pdd7
);
83 IDirectDraw_Release(pdd
);
88 static void release_directdraw(void)
90 IDirectDrawSurface7_Release(pdds7
);
91 IDirectDraw7_Release(pdd7
);
94 static void test_openfile(void)
96 IAMMultiMediaStream
*pams
;
98 IGraphBuilder
* pgraph
;
100 if (!(pams
= create_ammultimediastream()))
103 hr
= IAMMultiMediaStream_GetFilterGraph(pams
, &pgraph
);
104 ok(hr
==S_OK
, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr
);
105 ok(pgraph
==NULL
, "Filtergraph should not be created yet\n");
108 IGraphBuilder_Release(pgraph
);
110 hr
= IAMMultiMediaStream_OpenFile(pams
, filenameW
, 0);
111 ok(hr
==S_OK
, "IAMMultiMediaStream_OpenFile returned: %x\n", hr
);
113 hr
= IAMMultiMediaStream_GetFilterGraph(pams
, &pgraph
);
114 ok(hr
==S_OK
, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr
);
115 ok(pgraph
!=NULL
, "Filtergraph should be created\n");
118 IGraphBuilder_Release(pgraph
);
120 IAMMultiMediaStream_Release(pams
);
123 static void test_renderfile(void)
125 IAMMultiMediaStream
*pams
;
127 IMediaStream
*pvidstream
= NULL
;
128 IDirectDrawMediaStream
*pddstream
= NULL
;
129 IDirectDrawStreamSample
*pddsample
= NULL
;
130 IDirectDrawSurface
*surface
;
133 if (!(pams
= create_ammultimediastream()))
135 if (!create_directdraw())
137 IAMMultiMediaStream_Release(pams
);
141 hr
= IAMMultiMediaStream_Initialize(pams
, STREAMTYPE_READ
, 0, NULL
);
142 ok(hr
==S_OK
, "IAMMultiMediaStream_Initialize returned: %x\n", hr
);
144 hr
= IAMMultiMediaStream_AddMediaStream(pams
, (IUnknown
*)pdd7
, &MSPID_PrimaryVideo
, 0, NULL
);
145 ok(hr
==S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
147 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryAudio
, AMMSF_ADDDEFAULTRENDERER
, NULL
);
148 ok(hr
==S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
150 hr
= IAMMultiMediaStream_OpenFile(pams
, filenameW
, 0);
151 ok(hr
==S_OK
, "IAMMultiMediaStream_OpenFile returned: %x\n", hr
);
153 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &pvidstream
);
154 ok(hr
==S_OK
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
155 if (FAILED(hr
)) goto error
;
157 hr
= IMediaStream_QueryInterface(pvidstream
, &IID_IDirectDrawMediaStream
, (LPVOID
*)&pddstream
);
158 ok(hr
==S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
159 if (FAILED(hr
)) goto error
;
161 hr
= IDirectDrawMediaStream_CreateSample(pddstream
, NULL
, NULL
, 0, &pddsample
);
162 ok(hr
== S_OK
, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr
);
165 hr
= IDirectDrawStreamSample_GetSurface(pddsample
, &surface
, &rect
);
166 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
167 ok(surface
== NULL
, "got %p\n", surface
);
168 IDirectDrawStreamSample_Release(pddsample
);
170 hr
= IDirectDrawSurface7_QueryInterface(pdds7
, &IID_IDirectDrawSurface
, (void**)&surface
);
171 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
173 EXPECT_REF(surface
, 1);
174 hr
= IDirectDrawMediaStream_CreateSample(pddstream
, surface
, NULL
, 0, &pddsample
);
175 ok(hr
== S_OK
, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr
);
176 EXPECT_REF(surface
, 2);
177 IDirectDrawStreamSample_Release(pddsample
);
178 IDirectDrawSurface_Release(surface
);
182 IDirectDrawMediaStream_Release(pddstream
);
184 IMediaStream_Release(pvidstream
);
186 release_directdraw();
187 IAMMultiMediaStream_Release(pams
);
190 static void test_media_streams(void)
192 IAMMultiMediaStream
*pams
;
194 IMediaStream
*video_stream
= NULL
;
195 IMediaStream
*audio_stream
= NULL
;
196 IMediaStream
*dummy_stream
;
197 IMediaStreamFilter
* media_stream_filter
= NULL
;
199 if (!(pams
= create_ammultimediastream()))
201 if (!create_directdraw())
203 IAMMultiMediaStream_Release(pams
);
207 hr
= IAMMultiMediaStream_Initialize(pams
, STREAMTYPE_READ
, 0, NULL
);
208 ok(hr
== S_OK
, "IAMMultiMediaStream_Initialize returned: %x\n", hr
);
210 /* Retrieve media stream filter */
211 hr
= IAMMultiMediaStream_GetFilter(pams
, NULL
);
212 ok(hr
== E_POINTER
, "IAMMultiMediaStream_GetFilter returned: %x\n", hr
);
213 hr
= IAMMultiMediaStream_GetFilter(pams
, &media_stream_filter
);
214 ok(hr
== S_OK
, "IAMMultiMediaStream_GetFilter returned: %x\n", hr
);
216 /* Verify behaviour with invalid purpose id */
217 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &IID_IUnknown
, &dummy_stream
);
218 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
219 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &IID_IUnknown
, 0, NULL
);
220 ok(hr
== MS_E_PURPOSEID
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
222 /* Verify there is no video media stream */
223 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &video_stream
);
224 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
226 /* Verify there is no default renderer for video stream */
227 hr
= IAMMultiMediaStream_AddMediaStream(pams
, (IUnknown
*)pdd7
, &MSPID_PrimaryVideo
, AMMSF_ADDDEFAULTRENDERER
, NULL
);
228 ok(hr
== MS_E_PURPOSEID
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
229 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &video_stream
);
230 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
231 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryVideo
, AMMSF_ADDDEFAULTRENDERER
, NULL
);
232 ok(hr
== MS_E_PURPOSEID
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
233 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &video_stream
);
234 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
236 /* Verify normal case for video stream */
237 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryVideo
, 0, NULL
);
238 ok(hr
== S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
239 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &video_stream
);
240 ok(hr
== S_OK
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
242 /* Verify the video stream has been added to the media stream filter */
243 if (media_stream_filter
)
245 hr
= IMediaStreamFilter_GetMediaStream(media_stream_filter
, &MSPID_PrimaryVideo
, &dummy_stream
);
246 ok(hr
== S_OK
, "IMediaStreamFilter_GetMediaStream returned: %x\n", hr
);
247 ok(dummy_stream
== video_stream
, "Got wrong returned pointer %p, expected %p\n", dummy_stream
, video_stream
);
249 IMediaStream_Release(dummy_stream
);
252 /* Check interfaces and samples for video */
255 IAMMediaStream
* am_media_stream
;
256 IMultiMediaStream
*multi_media_stream
;
257 IAudioMediaStream
* audio_media_stream
;
258 IDirectDrawMediaStream
*ddraw_stream
= NULL
;
259 IDirectDrawStreamSample
*ddraw_sample
= NULL
;
261 hr
= IMediaStream_QueryInterface(video_stream
, &IID_IAMMediaStream
, (LPVOID
*)&am_media_stream
);
262 ok(hr
== S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
263 ok((void*)am_media_stream
== (void*)video_stream
, "Not same interface, got %p expected %p\n", am_media_stream
, video_stream
);
265 hr
= IAMMediaStream_GetMultiMediaStream(am_media_stream
, NULL
);
266 ok(hr
== E_POINTER
, "Expected E_POINTER, got %x\n", hr
);
268 multi_media_stream
= (void *)0xdeadbeef;
269 hr
= IAMMediaStream_GetMultiMediaStream(am_media_stream
, &multi_media_stream
);
270 ok(hr
== S_OK
, "IAMMediaStream_GetMultiMediaStream returned: %x\n", hr
);
271 ok((void *)multi_media_stream
== (void *)pams
, "Expected %p, got %p\n", pams
, multi_media_stream
);
272 IMultiMediaStream_Release(multi_media_stream
);
274 IAMMediaStream_Release(am_media_stream
);
276 hr
= IMediaStream_QueryInterface(video_stream
, &IID_IAudioMediaStream
, (LPVOID
*)&audio_media_stream
);
277 ok(hr
== E_NOINTERFACE
, "IMediaStream_QueryInterface returned: %x\n", hr
);
279 hr
= IMediaStream_QueryInterface(video_stream
, &IID_IDirectDrawMediaStream
, (LPVOID
*)&ddraw_stream
);
280 ok(hr
== S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
284 DDSURFACEDESC current_format
, desired_format
;
285 IDirectDrawPalette
*palette
;
288 hr
= IDirectDrawMediaStream_GetFormat(ddraw_stream
, ¤t_format
, &palette
, &desired_format
, &flags
);
289 ok(hr
== MS_E_NOSTREAM
, "IDirectDrawoMediaStream_GetFormat returned: %x\n", hr
);
291 hr
= IDirectDrawMediaStream_CreateSample(ddraw_stream
, NULL
, NULL
, 0, &ddraw_sample
);
292 ok(hr
== S_OK
, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr
);
294 hr
= IDirectDrawMediaStream_GetMultiMediaStream(ddraw_stream
, NULL
);
295 ok(hr
== E_POINTER
, "Expected E_POINTER, got %x\n", hr
);
297 multi_media_stream
= (void *)0xdeadbeef;
298 hr
= IDirectDrawMediaStream_GetMultiMediaStream(ddraw_stream
, &multi_media_stream
);
299 ok(hr
== S_OK
, "IDirectDrawMediaStream_GetMultiMediaStream returned: %x\n", hr
);
300 ok((void *)multi_media_stream
== (void *)pams
, "Expected %p, got %p\n", pams
, multi_media_stream
);
301 IMultiMediaStream_Release(multi_media_stream
);
305 IDirectDrawStreamSample_Release(ddraw_sample
);
307 IDirectDrawMediaStream_Release(ddraw_stream
);
310 /* Verify there is no audio media stream */
311 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryAudio
, &audio_stream
);
312 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
314 /* Verify no stream is created when using the default renderer for audio stream */
315 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryAudio
, AMMSF_ADDDEFAULTRENDERER
, NULL
);
316 ok((hr
== S_OK
) || (hr
== VFW_E_NO_AUDIO_HARDWARE
), "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
319 IGraphBuilder
* filtergraph
= NULL
;
320 IBaseFilter
* filter
= NULL
;
321 const WCHAR name
[] = {'0','0','0','1',0};
324 hr
= IAMMultiMediaStream_GetFilterGraph(pams
, &filtergraph
);
325 ok(hr
== S_OK
, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr
);
328 hr
= IGraphBuilder_FindFilterByName(filtergraph
, name
, &filter
);
329 ok(hr
== S_OK
, "IGraphBuilder_FindFilterByName returned: %x\n", hr
);
333 hr
= IBaseFilter_GetClassID(filter
, &clsid
);
334 ok(hr
== S_OK
, "IGraphBuilder_FindFilterByName returned: %x\n", hr
);
337 ok(IsEqualGUID(&clsid
, &CLSID_DSoundRender
), "Got wrong CLSID\n");
339 IBaseFilter_Release(filter
);
341 IGraphBuilder_Release(filtergraph
);
343 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryAudio
, &audio_stream
);
344 ok(hr
== MS_E_NOSTREAM
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
346 /* Verify a stream is created when no default renderer is used */
347 hr
= IAMMultiMediaStream_AddMediaStream(pams
, NULL
, &MSPID_PrimaryAudio
, 0, NULL
);
348 ok(hr
== S_OK
, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr
);
349 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryAudio
, &audio_stream
);
350 ok(hr
== S_OK
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
352 /* verify the audio stream has been added to the media stream filter */
353 if (media_stream_filter
)
355 hr
= IMediaStreamFilter_GetMediaStream(media_stream_filter
, &MSPID_PrimaryAudio
, &dummy_stream
);
356 ok(hr
== S_OK
, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr
);
357 ok(dummy_stream
== audio_stream
, "Got wrong returned pointer %p, expected %p\n", dummy_stream
, audio_stream
);
359 IMediaStream_Release(dummy_stream
);
362 /* Check interfaces and samples for audio */
365 IAMMediaStream
* am_media_stream
;
366 IMultiMediaStream
*multi_media_stream
;
367 IDirectDrawMediaStream
* ddraw_stream
= NULL
;
368 IAudioMediaStream
* audio_media_stream
= NULL
;
369 IAudioStreamSample
*audio_sample
= NULL
;
371 hr
= IMediaStream_QueryInterface(audio_stream
, &IID_IAMMediaStream
, (LPVOID
*)&am_media_stream
);
372 ok(hr
== S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
373 ok((void*)am_media_stream
== (void*)audio_stream
, "Not same interface, got %p expected %p\n", am_media_stream
, audio_stream
);
375 hr
= IAMMediaStream_GetMultiMediaStream(am_media_stream
, NULL
);
376 ok(hr
== E_POINTER
, "Expected E_POINTER, got %x\n", hr
);
378 multi_media_stream
= (void *)0xdeadbeef;
379 hr
= IAMMediaStream_GetMultiMediaStream(am_media_stream
, &multi_media_stream
);
380 ok(hr
== S_OK
, "IAMMediaStream_GetMultiMediaStream returned: %x\n", hr
);
381 ok((void *)multi_media_stream
== (void *)pams
, "Expected %p, got %p\n", pams
, multi_media_stream
);
382 IMultiMediaStream_Release(multi_media_stream
);
384 IAMMediaStream_Release(am_media_stream
);
386 hr
= IMediaStream_QueryInterface(audio_stream
, &IID_IDirectDrawMediaStream
, (LPVOID
*)&ddraw_stream
);
387 ok(hr
== E_NOINTERFACE
, "IMediaStream_QueryInterface returned: %x\n", hr
);
389 hr
= IMediaStream_QueryInterface(audio_stream
, &IID_IAudioMediaStream
, (LPVOID
*)&audio_media_stream
);
390 ok(hr
== S_OK
, "IMediaStream_QueryInterface returned: %x\n", hr
);
394 IAudioData
* audio_data
= NULL
;
397 hr
= CoCreateInstance(&CLSID_AMAudioData
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IAudioData
, (void **)&audio_data
);
398 ok(hr
== S_OK
, "CoCreateInstance returned: %x\n", hr
);
400 hr
= IAudioMediaStream_GetFormat(audio_media_stream
, NULL
);
401 ok(hr
== E_POINTER
, "IAudioMediaStream_GetFormat returned: %x\n", hr
);
402 hr
= IAudioMediaStream_GetFormat(audio_media_stream
, &format
);
403 ok(hr
== MS_E_NOSTREAM
, "IAudioMediaStream_GetFormat returned: %x\n", hr
);
405 hr
= IAudioMediaStream_CreateSample(audio_media_stream
, NULL
, 0, &audio_sample
);
406 ok(hr
== E_POINTER
, "IAudioMediaStream_CreateSample returned: %x\n", hr
);
407 hr
= IAudioMediaStream_CreateSample(audio_media_stream
, audio_data
, 0, &audio_sample
);
408 ok(hr
== S_OK
, "IAudioMediaStream_CreateSample returned: %x\n", hr
);
410 hr
= IAudioMediaStream_GetMultiMediaStream(audio_media_stream
, NULL
);
411 ok(hr
== E_POINTER
, "Expected E_POINTER, got %x\n", hr
);
413 multi_media_stream
= (void *)0xdeadbeef;
414 hr
= IAudioMediaStream_GetMultiMediaStream(audio_media_stream
, &multi_media_stream
);
415 ok(hr
== S_OK
, "IAudioMediaStream_GetMultiMediaStream returned: %x\n", hr
);
416 ok((void *)multi_media_stream
== (void *)pams
, "Expected %p, got %p\n", pams
, multi_media_stream
);
417 IMultiMediaStream_Release(multi_media_stream
);
420 IAudioData_Release(audio_data
);
422 IAudioStreamSample_Release(audio_sample
);
423 if (audio_media_stream
)
424 IAudioMediaStream_Release(audio_media_stream
);
428 if (media_stream_filter
)
430 IEnumPins
*enum_pins
;
432 hr
= IMediaStreamFilter_EnumPins(media_stream_filter
, &enum_pins
);
433 ok(hr
== S_OK
, "IBaseFilter_EnumPins returned: %x\n", hr
);
436 IPin
* pins
[3] = { NULL
, NULL
, NULL
};
438 ULONG expected_nb_pins
= audio_stream
? 2 : 1;
441 hr
= IEnumPins_Next(enum_pins
, 3, pins
, &nb_pins
);
442 ok(SUCCEEDED(hr
), "IEnumPins_Next returned: %x\n", hr
);
443 ok(nb_pins
== expected_nb_pins
, "Number of pins is %u instead of %u\n", nb_pins
, expected_nb_pins
);
444 for (i
= 0; i
< min(nb_pins
, expected_nb_pins
); i
++)
446 IEnumMediaTypes
* enum_media_types
;
447 AM_MEDIA_TYPE
* media_types
[10];
448 ULONG nb_media_types
;
453 /* Pin name is "I{guid MSPID_PrimaryVideo or MSPID_PrimaryAudio}" */
455 StringFromGUID2(i
? &MSPID_PrimaryAudio
: &MSPID_PrimaryVideo
, id
+ 1, 40);
457 hr
= IPin_ConnectedTo(pins
[i
], &pin
);
458 ok(hr
== VFW_E_NOT_CONNECTED
, "IPin_ConnectedTo returned: %x\n", hr
);
459 hr
= IPin_QueryPinInfo(pins
[i
], &info
);
460 ok(hr
== S_OK
, "IPin_QueryPinInfo returned: %x\n", hr
);
461 IBaseFilter_Release(info
.pFilter
);
462 ok(info
.dir
== PINDIR_INPUT
, "Pin direction is %u instead of %u\n", info
.dir
, PINDIR_INPUT
);
463 ok(!lstrcmpW(info
.achName
, id
), "Pin name is %s instead of %s\n", wine_dbgstr_w(info
.achName
), wine_dbgstr_w(id
));
464 hr
= IPin_EnumMediaTypes(pins
[i
], &enum_media_types
);
465 ok(hr
== S_OK
, "IPin_EnumMediaTypes returned: %x\n", hr
);
466 hr
= IEnumMediaTypes_Next(enum_media_types
, sizeof(media_types
) / sizeof(media_types
[0]), media_types
, &nb_media_types
);
467 ok(SUCCEEDED(hr
), "IEnumMediaTypes_Next returned: %x\n", hr
);
468 ok(nb_media_types
> 0, "nb_media_types should be >0\n");
469 IEnumMediaTypes_Release(enum_media_types
);
470 IPin_Release(pins
[i
]);
472 IEnumPins_Release(enum_pins
);
476 /* Test open file with no filename */
477 hr
= IAMMultiMediaStream_OpenFile(pams
, NULL
, 0);
478 ok(hr
== E_POINTER
, "IAMMultiMediaStream_OpenFile returned %x instead of %x\n", hr
, E_POINTER
);
481 IMediaStream_Release(video_stream
);
483 IMediaStream_Release(audio_stream
);
484 if (media_stream_filter
)
485 IMediaStreamFilter_Release(media_stream_filter
);
487 release_directdraw();
488 IAMMultiMediaStream_Release(pams
);
491 static void test_IDirectDrawStreamSample(void)
493 DDSURFACEDESC desc
= { sizeof(desc
) };
494 IAMMultiMediaStream
*pams
;
496 IMediaStream
*pvidstream
= NULL
;
497 IDirectDrawMediaStream
*pddstream
= NULL
;
498 IDirectDrawStreamSample
*pddsample
= NULL
;
499 IDirectDrawSurface7
*surface7
;
500 IDirectDrawSurface
*surface
, *surface2
;
501 IDirectDraw
*ddraw
, *ddraw2
;
502 IDirectDraw7
*ddraw7
;
505 if (!(pams
= create_ammultimediastream()))
507 if (!create_directdraw())
509 IAMMultiMediaStream_Release(pams
);
513 hr
= IAMMultiMediaStream_Initialize(pams
, STREAMTYPE_READ
, 0, NULL
);
514 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
516 hr
= IAMMultiMediaStream_AddMediaStream(pams
, (IUnknown
*)pdd7
, &MSPID_PrimaryVideo
, 0, NULL
);
517 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
519 hr
= IAMMultiMediaStream_GetMediaStream(pams
, &MSPID_PrimaryVideo
, &pvidstream
);
520 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
521 if (FAILED(hr
)) goto error
;
523 hr
= IMediaStream_QueryInterface(pvidstream
, &IID_IDirectDrawMediaStream
, (LPVOID
*)&pddstream
);
524 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
525 if (FAILED(hr
)) goto error
;
527 hr
= IDirectDrawMediaStream_GetDirectDraw(pddstream
, &ddraw
);
528 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
530 hr
= IDirectDrawMediaStream_GetDirectDraw(pddstream
, &ddraw2
);
531 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
532 ok(ddraw
== ddraw2
, "got %p, %p\n", ddraw
, ddraw2
);
534 hr
= IDirectDraw_QueryInterface(ddraw
, &IID_IDirectDraw7
, (void**)&ddraw7
);
535 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
536 IDirectDraw7_Release(ddraw7
);
538 IDirectDraw_Release(ddraw2
);
539 IDirectDraw_Release(ddraw
);
541 hr
= IDirectDrawMediaStream_CreateSample(pddstream
, NULL
, NULL
, 0, &pddsample
);
542 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
545 hr
= IDirectDrawStreamSample_GetSurface(pddsample
, &surface
, &rect
);
546 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
547 ok(surface
!= NULL
, "got %p\n", surface
);
549 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void**)&surface7
);
550 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
551 IDirectDrawSurface7_Release(surface7
);
553 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
554 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
555 ok(desc
.dwWidth
== 100, "width %d\n", desc
.dwWidth
);
556 ok(desc
.dwHeight
== 100, "height %d\n", desc
.dwHeight
);
557 ok(desc
.ddpfPixelFormat
.dwFlags
== DDPF_RGB
, "format flags %08x\n", desc
.ddpfPixelFormat
.dwFlags
);
558 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
, "dwRGBBitCount %d\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
559 IDirectDrawSurface_Release(surface
);
560 IDirectDrawStreamSample_Release(pddsample
);
562 hr
= IDirectDrawSurface7_QueryInterface(pdds7
, &IID_IDirectDrawSurface
, (void**)&surface
);
563 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
565 EXPECT_REF(surface
, 1);
566 hr
= IDirectDrawMediaStream_CreateSample(pddstream
, surface
, NULL
, 0, &pddsample
);
567 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
568 EXPECT_REF(surface
, 2);
571 memset(&rect
, 0, sizeof(rect
));
572 hr
= IDirectDrawStreamSample_GetSurface(pddsample
, &surface2
, &rect
);
573 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
574 ok(surface
== surface2
, "got %p\n", surface2
);
575 ok(rect
.right
> 0 && rect
.bottom
> 0, "got %d, %d\n", rect
.right
, rect
.bottom
);
576 EXPECT_REF(surface
, 3);
577 IDirectDrawSurface_Release(surface2
);
579 hr
= IDirectDrawStreamSample_GetSurface(pddsample
, NULL
, NULL
);
580 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
582 IDirectDrawStreamSample_Release(pddsample
);
583 IDirectDrawSurface_Release(surface
);
587 IDirectDrawMediaStream_Release(pddstream
);
589 IMediaStream_Release(pvidstream
);
591 release_directdraw();
592 IAMMultiMediaStream_Release(pams
);
599 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
601 test_media_streams();
602 test_IDirectDrawStreamSample();
604 file
= CreateFileW(filenameW
, 0, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
605 if (file
!= INVALID_HANDLE_VALUE
)