ReactOS 0.4.15-dev-8100-g1887773
mediadet.c File Reference
#include "initguid.h"
#include "ole2.h"
#include "vfwmsgs.h"
#include "uuids.h"
#include "wine/test.h"
#include "qedit.h"
#include "control.h"
#include "rc.h"
Include dependency graph for mediadet.c:

Go to the source code of this file.

Classes

struct  unk_impl
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 

Functions

static struct unk_implimpl_from_IUnknown (IUnknown *iface)
 
static HRESULT WINAPI unk_QueryInterface (IUnknown *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI unk_AddRef (IUnknown *iface)
 
static ULONG WINAPI unk_Release (IUnknown *iface)
 
static BOOL unpack_avi_file (int id, WCHAR name[MAX_PATH])
 
static BOOL init_tests (void)
 
static void test_mediadet (void)
 
static HRESULT WINAPI ms_QueryInterface (IMediaSample *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI ms_AddRef (IMediaSample *iface)
 
static ULONG WINAPI ms_Release (IMediaSample *iface)
 
static HRESULT WINAPI ms_GetPointer (IMediaSample *iface, BYTE **ppBuffer)
 
static LONG WINAPI ms_GetSize (IMediaSample *iface)
 
static HRESULT WINAPI ms_GetTime (IMediaSample *iface, REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
 
static HRESULT WINAPI ms_SetTime (IMediaSample *iface, REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
 
static HRESULT WINAPI ms_IsSyncPoint (IMediaSample *iface)
 
static HRESULT WINAPI ms_SetSyncPoint (IMediaSample *iface, BOOL bIsSyncPoint)
 
static HRESULT WINAPI ms_IsPreroll (IMediaSample *iface)
 
static HRESULT WINAPI ms_SetPreroll (IMediaSample *iface, BOOL bIsPreroll)
 
static LONG WINAPI ms_GetActualDataLength (IMediaSample *iface)
 
static HRESULT WINAPI ms_SetActualDataLength (IMediaSample *iface, LONG length)
 
static HRESULT WINAPI ms_GetMediaType (IMediaSample *iface, AM_MEDIA_TYPE **ppMediaType)
 
static HRESULT WINAPI ms_SetMediaType (IMediaSample *iface, AM_MEDIA_TYPE *pMediaType)
 
static HRESULT WINAPI ms_IsDiscontinuity (IMediaSample *iface)
 
static HRESULT WINAPI ms_SetDiscontinuity (IMediaSample *iface, BOOL bDiscontinuity)
 
static HRESULT WINAPI ms_GetMediaTime (IMediaSample *iface, LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
 
static HRESULT WINAPI ms_SetMediaTime (IMediaSample *iface, LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
 
static HRESULT WINAPI sgcb_QueryInterface (ISampleGrabberCB *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI sgcb_AddRef (ISampleGrabberCB *iface)
 
static ULONG WINAPI sgcb_Release (ISampleGrabberCB *iface)
 
static HRESULT WINAPI sgcb_SampleCB (ISampleGrabberCB *iface, double SampleTime, IMediaSample *pSample)
 
static HRESULT WINAPI sgcb_BufferCB (ISampleGrabberCB *iface, double SampleTime, BYTE *pBuffer, LONG BufferLen)
 
static void test_samplegrabber (void)
 
static void test_COM_sg_enumpins (void)
 
 START_TEST (mediadet)
 

Variables

static const IUnknownVtbl unk_vtbl
 
static WCHAR test_avi_filename [MAX_PATH]
 
static WCHAR test_sound_avi_filename [MAX_PATH]
 
static const IMediaSampleVtbl my_sample_vt
 
static IMediaSample my_sample = { &my_sample_vt }
 
static BOOL samplecb_called = FALSE
 
static const ISampleGrabberCBVtbl sgcb_vt
 
static ISampleGrabberCB my_sg_cb = { &sgcb_vt }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file mediadet.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 22 of file mediadet.c.

Function Documentation

◆ impl_from_IUnknown()

static struct unk_impl * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 40 of file mediadet.c.

41{
42 return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
43}
Definition: api.c:544
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ init_tests()

static BOOL init_tests ( void  )
static

Definition at line 125 of file mediadet.c.

126{
129}
static WCHAR test_sound_avi_filename[MAX_PATH]
Definition: mediadet.c:75
static WCHAR test_avi_filename[MAX_PATH]
Definition: mediadet.c:74
static BOOL unpack_avi_file(int id, WCHAR name[MAX_PATH])
Definition: mediadet.c:77
#define TEST_AVI_RES
Definition: rc.h:24
#define TEST_SOUND_AVI_RES
Definition: rc.h:25

Referenced by START_TEST().

◆ ms_AddRef()

static ULONG WINAPI ms_AddRef ( IMediaSample iface)
static

Definition at line 362 of file mediadet.c.

363{
364 return 2;
365}

◆ ms_GetActualDataLength()

static LONG WINAPI ms_GetActualDataLength ( IMediaSample iface)
static

Definition at line 414 of file mediadet.c.

415{
416 return E_NOTIMPL;
417}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ms_GetMediaTime()

static HRESULT WINAPI ms_GetMediaTime ( IMediaSample iface,
LONGLONG pTimeStart,
LONGLONG pTimeEnd 
)
static

Definition at line 445 of file mediadet.c.

447{
448 return E_NOTIMPL;
449}

◆ ms_GetMediaType()

static HRESULT WINAPI ms_GetMediaType ( IMediaSample iface,
AM_MEDIA_TYPE **  ppMediaType 
)
static

Definition at line 424 of file mediadet.c.

426{
427 return E_NOTIMPL;
428}

◆ ms_GetPointer()

static HRESULT WINAPI ms_GetPointer ( IMediaSample iface,
BYTE **  ppBuffer 
)
static

Definition at line 372 of file mediadet.c.

373{
374 return E_NOTIMPL;
375}

◆ ms_GetSize()

static LONG WINAPI ms_GetSize ( IMediaSample iface)
static

Definition at line 377 of file mediadet.c.

378{
379 return E_NOTIMPL;
380}

◆ ms_GetTime()

static HRESULT WINAPI ms_GetTime ( IMediaSample iface,
REFERENCE_TIME pTimeStart,
REFERENCE_TIME pTimeEnd 
)
static

Definition at line 382 of file mediadet.c.

384{
385 return E_NOTIMPL;
386}

◆ ms_IsDiscontinuity()

static HRESULT WINAPI ms_IsDiscontinuity ( IMediaSample iface)
static

Definition at line 435 of file mediadet.c.

436{
437 return E_NOTIMPL;
438}

◆ ms_IsPreroll()

static HRESULT WINAPI ms_IsPreroll ( IMediaSample iface)
static

Definition at line 404 of file mediadet.c.

405{
406 return E_NOTIMPL;
407}

◆ ms_IsSyncPoint()

static HRESULT WINAPI ms_IsSyncPoint ( IMediaSample iface)
static

Definition at line 394 of file mediadet.c.

395{
396 return E_NOTIMPL;
397}

◆ ms_QueryInterface()

static HRESULT WINAPI ms_QueryInterface ( IMediaSample iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 356 of file mediadet.c.

358{
359 return E_NOTIMPL;
360}

◆ ms_Release()

static ULONG WINAPI ms_Release ( IMediaSample iface)
static

Definition at line 367 of file mediadet.c.

368{
369 return 1;
370}

◆ ms_SetActualDataLength()

static HRESULT WINAPI ms_SetActualDataLength ( IMediaSample iface,
LONG  length 
)
static

Definition at line 419 of file mediadet.c.

420{
421 return E_NOTIMPL;
422}

◆ ms_SetDiscontinuity()

static HRESULT WINAPI ms_SetDiscontinuity ( IMediaSample iface,
BOOL  bDiscontinuity 
)
static

Definition at line 440 of file mediadet.c.

441{
442 return E_NOTIMPL;
443}

◆ ms_SetMediaTime()

static HRESULT WINAPI ms_SetMediaTime ( IMediaSample iface,
LONGLONG pTimeStart,
LONGLONG pTimeEnd 
)
static

Definition at line 451 of file mediadet.c.

453{
454 return E_NOTIMPL;
455}

◆ ms_SetMediaType()

static HRESULT WINAPI ms_SetMediaType ( IMediaSample iface,
AM_MEDIA_TYPE pMediaType 
)
static

Definition at line 430 of file mediadet.c.

431{
432 return E_NOTIMPL;
433}

◆ ms_SetPreroll()

static HRESULT WINAPI ms_SetPreroll ( IMediaSample iface,
BOOL  bIsPreroll 
)
static

Definition at line 409 of file mediadet.c.

410{
411 return E_NOTIMPL;
412}

◆ ms_SetSyncPoint()

static HRESULT WINAPI ms_SetSyncPoint ( IMediaSample iface,
BOOL  bIsSyncPoint 
)
static

Definition at line 399 of file mediadet.c.

400{
401 return E_NOTIMPL;
402}

◆ ms_SetTime()

static HRESULT WINAPI ms_SetTime ( IMediaSample iface,
REFERENCE_TIME pTimeStart,
REFERENCE_TIME pTimeEnd 
)
static

Definition at line 388 of file mediadet.c.

390{
391 return E_NOTIMPL;
392}

◆ sgcb_AddRef()

static ULONG WINAPI sgcb_AddRef ( ISampleGrabberCB iface)
static

Definition at line 489 of file mediadet.c.

490{
491 return E_NOTIMPL;
492}

◆ sgcb_BufferCB()

static HRESULT WINAPI sgcb_BufferCB ( ISampleGrabberCB iface,
double  SampleTime,
BYTE pBuffer,
LONG  BufferLen 
)
static

Definition at line 507 of file mediadet.c.

509{
510 ok(0, "BufferCB should not have been called\n");
511 return E_NOTIMPL;
512}
#define ok(value,...)
Definition: atltest.h:57

◆ sgcb_QueryInterface()

static HRESULT WINAPI sgcb_QueryInterface ( ISampleGrabberCB iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 483 of file mediadet.c.

485{
486 return E_NOTIMPL;
487}

◆ sgcb_Release()

static ULONG WINAPI sgcb_Release ( ISampleGrabberCB iface)
static

Definition at line 494 of file mediadet.c.

495{
496 return E_NOTIMPL;
497}

◆ sgcb_SampleCB()

static HRESULT WINAPI sgcb_SampleCB ( ISampleGrabberCB iface,
double  SampleTime,
IMediaSample pSample 
)
static

Definition at line 499 of file mediadet.c.

501{
502 ok(pSample == &my_sample, "Got wrong IMediaSample: %p, expected %p\n", pSample, &my_sample);
504 return E_NOTIMPL;
505}
#define TRUE
Definition: types.h:120
static IMediaSample my_sample
Definition: mediadet.c:479
static BOOL samplecb_called
Definition: mediadet.c:481

◆ START_TEST()

START_TEST ( mediadet  )

Definition at line 662 of file mediadet.c.

663{
664 if (!init_tests())
665 {
666 skip("Couldn't initialize tests!\n");
667 return;
668 }
669
675}
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_samplegrabber(void)
Definition: mediadet.c:524
static void test_mediadet(void)
Definition: mediadet.c:131
static void test_COM_sg_enumpins(void)
Definition: mediadet.c:630
static BOOL init_tests(void)
Definition: mediadet.c:125

◆ test_COM_sg_enumpins()

static void test_COM_sg_enumpins ( void  )
static

Definition at line 630 of file mediadet.c.

631{
632 IBaseFilter *bf;
633 IEnumPins *pins, *pins2;
634 IUnknown *unk;
635 ULONG refcount;
636 HRESULT hr;
637
638 hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter,
639 (void**)&bf);
640 ok(hr == S_OK, "SampleGrabber create failed: %08x, expected S_OK\n", hr);
641 hr = IBaseFilter_EnumPins(bf, &pins);
642 ok(hr == S_OK, "EnumPins create failed: %08x, expected S_OK\n", hr);
643
644 /* Same refcount for all EnumPins interfaces */
645 refcount = IEnumPins_AddRef(pins);
646 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
647 hr = IEnumPins_QueryInterface(pins, &IID_IEnumPins, (void**)&pins2);
648 ok(hr == S_OK, "QueryInterface for IID_IEnumPins failed: %08x\n", hr);
649 ok(pins == pins2, "QueryInterface for self failed (%p != %p)\n", pins, pins2);
650 IEnumPins_Release(pins2);
651
652 hr = IEnumPins_QueryInterface(pins, &IID_IUnknown, (void**)&unk);
653 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
654 refcount = IUnknown_AddRef(unk);
655 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
656 refcount = IUnknown_Release(unk);
657
658 while (IEnumPins_Release(pins));
659 IBaseFilter_Release(bf);
660}
const GUID IID_IUnknown
const GUID IID_IBaseFilter
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_mediadet()

static void test_mediadet ( void  )
static

Definition at line 131 of file mediadet.c.

132{
133 HRESULT hr;
134 struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
135 IMediaDet *pM = NULL;
136 ULONG refcount;
138 LONG nstrms = 0;
139 LONG strm;
140 AM_MEDIA_TYPE mt;
141 double fps;
142 int flags;
143 int i;
144
145 /* COM aggregation */
146 hr = CoCreateInstance(&CLSID_MediaDet, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
147 &IID_IUnknown, (void**)&unk_obj.inner_unk);
148 ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
149
150 hr = IUnknown_QueryInterface(unk_obj.inner_unk, &IID_IMediaDet, (void**)&pM);
151 ok(hr == S_OK, "QueryInterface for IID_IMediaDet failed: %08x\n", hr);
152 refcount = IMediaDet_AddRef(pM);
153 ok(refcount == unk_obj.ref, "MediaDet just pretends to support COM aggregation\n");
154 refcount = IMediaDet_Release(pM);
155 ok(refcount == unk_obj.ref, "MediaDet just pretends to support COM aggregation\n");
156 refcount = IMediaDet_Release(pM);
157 ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
158
159 IUnknown_Release(unk_obj.inner_unk);
160
161 /* test.avi has one video stream. */
162 hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
163 &IID_IMediaDet, (LPVOID*)&pM);
164 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
165 ok(pM != NULL, "pM is NULL\n");
166
167 filename = NULL;
168 hr = IMediaDet_get_Filename(pM, &filename);
169 /* Despite what MSDN claims, this returns S_OK. */
170 ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
171 ok(filename == NULL, "IMediaDet_get_Filename\n");
172
173 filename = (BSTR) -1;
174 hr = IMediaDet_get_Filename(pM, &filename);
175 /* Despite what MSDN claims, this returns S_OK. */
176 ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
177 ok(filename == NULL, "IMediaDet_get_Filename\n");
178
179 nstrms = -1;
180 hr = IMediaDet_get_OutputStreams(pM, &nstrms);
181 ok(hr == E_INVALIDARG, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
182 ok(nstrms == -1, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
183
184 strm = -1;
185 /* The stream defaults to 0, even without a file! */
186 hr = IMediaDet_get_CurrentStream(pM, &strm);
187 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
188 ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
189
190 hr = IMediaDet_get_CurrentStream(pM, NULL);
191 ok(hr == E_POINTER, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
192
193 /* But put_CurrentStream doesn't. */
194 hr = IMediaDet_put_CurrentStream(pM, 0);
195 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
196
197 hr = IMediaDet_put_CurrentStream(pM, -1);
198 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
199
200 hr = IMediaDet_get_StreamMediaType(pM, &mt);
201 ok(hr == E_INVALIDARG, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
202
203 hr = IMediaDet_get_StreamMediaType(pM, NULL);
204 ok(hr == E_POINTER, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
205
207 hr = IMediaDet_put_Filename(pM, filename);
208 ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr);
210
211 strm = -1;
212 /* The stream defaults to 0. */
213 hr = IMediaDet_get_CurrentStream(pM, &strm);
214 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
215 ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
216
217 ZeroMemory(&mt, sizeof mt);
218 hr = IMediaDet_get_StreamMediaType(pM, &mt);
219 ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
220 CoTaskMemFree(mt.pbFormat);
221
222 /* Even before get_OutputStreams. */
223 hr = IMediaDet_put_CurrentStream(pM, 1);
224 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
225
226 hr = IMediaDet_get_OutputStreams(pM, &nstrms);
227 ok(hr == S_OK, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
228 ok(nstrms == 1, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
229
230 filename = NULL;
231 hr = IMediaDet_get_Filename(pM, &filename);
232 ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
234 "IMediaDet_get_Filename\n");
236
237 hr = IMediaDet_get_Filename(pM, NULL);
238 ok(hr == E_POINTER, "IMediaDet_get_Filename failed: %08x\n", hr);
239
240 strm = -1;
241 hr = IMediaDet_get_CurrentStream(pM, &strm);
242 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
243 ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
244
245 hr = IMediaDet_get_CurrentStream(pM, NULL);
246 ok(hr == E_POINTER, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
247
248 hr = IMediaDet_put_CurrentStream(pM, -1);
249 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
250
251 hr = IMediaDet_put_CurrentStream(pM, 1);
252 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
253
254 /* Try again. */
255 strm = -1;
256 hr = IMediaDet_get_CurrentStream(pM, &strm);
257 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
258 ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
259
260 hr = IMediaDet_put_CurrentStream(pM, 0);
261 ok(hr == S_OK, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
262
263 strm = -1;
264 hr = IMediaDet_get_CurrentStream(pM, &strm);
265 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
266 ok(strm == 0, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
267
268 ZeroMemory(&mt, sizeof mt);
269 hr = IMediaDet_get_StreamMediaType(pM, &mt);
270 ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
271 ok(IsEqualGUID(&mt.majortype, &MEDIATYPE_Video),
272 "IMediaDet_get_StreamMediaType\n");
273 CoTaskMemFree(mt.pbFormat);
274
275 hr = IMediaDet_get_FrameRate(pM, NULL);
276 ok(hr == E_POINTER, "IMediaDet_get_FrameRate failed: %08x\n", hr);
277
278 hr = IMediaDet_get_FrameRate(pM, &fps);
279 ok(hr == S_OK, "IMediaDet_get_FrameRate failed: %08x\n", hr);
280 ok(fps == 10.0, "IMediaDet_get_FrameRate: fps is %f\n", fps);
281
282 hr = IMediaDet_Release(pM);
283 ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
284
286
287 /* test_sound.avi has one video stream and one audio stream. */
288 hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
289 &IID_IMediaDet, (LPVOID*)&pM);
290 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
291 ok(pM != NULL, "pM is NULL\n");
292
294 hr = IMediaDet_put_Filename(pM, filename);
295 ok(hr == S_OK, "IMediaDet_put_Filename failed: %08x\n", hr);
297
298 hr = IMediaDet_get_OutputStreams(pM, &nstrms);
299 ok(hr == S_OK, "IMediaDet_get_OutputStreams failed: %08x\n", hr);
300 ok(nstrms == 2, "IMediaDet_get_OutputStreams: nstrms is %i\n", nstrms);
301
302 filename = NULL;
303 hr = IMediaDet_get_Filename(pM, &filename);
304 ok(hr == S_OK, "IMediaDet_get_Filename failed: %08x\n", hr);
306 "IMediaDet_get_Filename\n");
308
309 /* I don't know if the stream order is deterministic. Just check
310 for both an audio and video stream. */
311 flags = 0;
312
313 for (i = 0; i < 2; ++i)
314 {
315 hr = IMediaDet_put_CurrentStream(pM, i);
316 ok(hr == S_OK, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
317
318 strm = -1;
319 hr = IMediaDet_get_CurrentStream(pM, &strm);
320 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
321 ok(strm == i, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
322
323 ZeroMemory(&mt, sizeof mt);
324 hr = IMediaDet_get_StreamMediaType(pM, &mt);
325 ok(hr == S_OK, "IMediaDet_get_StreamMediaType failed: %08x\n", hr);
326 flags += (IsEqualGUID(&mt.majortype, &MEDIATYPE_Video)
327 ? 1
328 : (IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio)
329 ? 2
330 : 0));
331
332 if (IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio))
333 {
334 hr = IMediaDet_get_FrameRate(pM, &fps);
335 ok(hr == VFW_E_INVALIDMEDIATYPE, "IMediaDet_get_FrameRate failed: %08x\n", hr);
336 }
337
338 CoTaskMemFree(mt.pbFormat);
339 }
340 ok(flags == 3, "IMediaDet_get_StreamMediaType: flags are %i\n", flags);
341
342 hr = IMediaDet_put_CurrentStream(pM, 2);
343 ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream failed: %08x\n", hr);
344
345 strm = -1;
346 hr = IMediaDet_get_CurrentStream(pM, &strm);
347 ok(hr == S_OK, "IMediaDet_get_CurrentStream failed: %08x\n", hr);
348 ok(strm == 1, "IMediaDet_get_CurrentStream: strm is %i\n", strm);
349
350 hr = IMediaDet_Release(pM);
351 ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
352
354}
#define E_INVALIDARG
Definition: ddrawi.h:101
OLECHAR * BSTR
Definition: compat.h:2293
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
const char * filename
Definition: ioapi.h:137
static const IUnknownVtbl unk_vtbl
Definition: mediadet.c:66
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
IUnknown IUnknown_iface
Definition: api.c:545
IUnknown * inner_unk
Definition: api.c:547
LONG ref
Definition: api.c:546
#define VFW_E_INVALIDMEDIATYPE
Definition: vfwmsgs.h:39
#define ZeroMemory
Definition: winbase.h:1712
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_samplegrabber()

static void test_samplegrabber ( void  )
static

Definition at line 524 of file mediadet.c.

525{
526 struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
527 ISampleGrabber *sg;
528 IBaseFilter *bf;
529 IMediaFilter *mf;
530 IPersist *persist;
531 IUnknown *unk;
532 IPin *pin;
533 IMemInputPin *inpin;
534 IEnumPins *pins;
535 ULONG refcount;
536 HRESULT hr;
537 FILTER_STATE fstate;
538
539 /* COM aggregation */
540 hr = CoCreateInstance(&CLSID_SampleGrabber, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
541 &IID_IUnknown, (void**)&unk_obj.inner_unk);
542 ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
543
544 hr = IUnknown_QueryInterface(unk_obj.inner_unk, &IID_ISampleGrabber, (void**)&sg);
545 ok(hr == S_OK, "QueryInterface for IID_ISampleGrabber failed: %08x\n", hr);
546 refcount = ISampleGrabber_AddRef(sg);
547 ok(refcount == unk_obj.ref, "SampleGrabber just pretends to support COM aggregation\n");
548 refcount = ISampleGrabber_Release(sg);
549 ok(refcount == unk_obj.ref, "SampleGrabber just pretends to support COM aggregation\n");
550 refcount = ISampleGrabber_Release(sg);
551 ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
552 IUnknown_Release(unk_obj.inner_unk);
553
554 /* Invalid RIID */
555 hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory,
556 (void**)&sg);
557 ok(hr == E_NOINTERFACE, "SampleGrabber create failed: %08x, expected E_NOINTERFACE\n", hr);
558
559 /* Same refcount for all SampleGrabber interfaces */
560 hr = CoCreateInstance(&CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, &IID_ISampleGrabber,
561 (void**)&sg);
562 ok(hr == S_OK, "SampleGrabber create failed: %08x, expected S_OK\n", hr);
563 refcount = ISampleGrabber_AddRef(sg);
564 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
565
566 hr = ISampleGrabber_QueryInterface(sg, &IID_IBaseFilter, (void**)&bf);
567 ok(hr == S_OK, "QueryInterface for IID_IBaseFilter failed: %08x\n", hr);
568 refcount = IBaseFilter_AddRef(bf);
569 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
570 refcount = IBaseFilter_Release(bf);
571
572 hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaFilter, (void**)&mf);
573 ok(hr == S_OK, "QueryInterface for IID_IMediaFilter failed: %08x\n", hr);
574 refcount = IMediaFilter_AddRef(mf);
575 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
576 refcount = IMediaFilter_Release(mf);
577
578 hr = ISampleGrabber_QueryInterface(sg, &IID_IPersist, (void**)&persist);
579 ok(hr == S_OK, "QueryInterface for IID_IPersist failed: %08x\n", hr);
580 refcount = IPersist_AddRef(persist);
581 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
582 refcount = IPersist_Release(persist);
583
584 hr = ISampleGrabber_QueryInterface(sg, &IID_IUnknown, (void**)&unk);
585 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
586 refcount = IUnknown_AddRef(unk);
587 ok(refcount == 7, "refcount == %u, expected 7\n", refcount);
588 refcount = IUnknown_Release(unk);
589
590 hr = ISampleGrabber_SetCallback(sg, &my_sg_cb, 0);
591 ok(hr == S_OK, "SetCallback failed: %08x\n", hr);
592
593 hr = IBaseFilter_GetState(bf, 100, &fstate);
594 ok(hr == S_OK, "Failed to get filter state: %08x\n", hr);
595 ok(fstate == State_Stopped, "Got wrong filter state: %u\n", fstate);
596
597 hr = IBaseFilter_EnumPins(bf, &pins);
598 ok(hr == S_OK, "EnumPins create failed: %08x, expected S_OK\n", hr);
599
600 hr = IEnumPins_Next(pins, 1, &pin, NULL);
601 ok(hr == S_OK, "Next failed: %08x\n", hr);
602
603 IEnumPins_Release(pins);
604
605 hr = IPin_QueryInterface(pin, &IID_IMemInputPin, (void**)&inpin);
606 ok(hr == S_OK, "QueryInterface(IMemInputPin) failed: %08x\n", hr);
607
608 hr = IMemInputPin_Receive(inpin, &my_sample);
609 ok(hr == S_OK, "Receive failed: %08x\n", hr);
610 ok(samplecb_called == TRUE, "SampleCB should have been called\n");
611
612 IMemInputPin_Release(inpin);
613 IPin_Release(pin);
614
615 /* Interfaces that native does not support */
616 hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaPosition, (void**)&unk);
617 todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMediaPosition failed: %08x\n", hr);
618 hr = ISampleGrabber_QueryInterface(sg, &IID_IMediaSeeking, (void**)&unk);
619 todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMediaSeeking failed: %08x\n", hr);
620 hr = ISampleGrabber_QueryInterface(sg, &IID_IMemInputPin, (void**)&unk);
621 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IMemInputPin failed: %08x\n", hr);
622 hr = ISampleGrabber_QueryInterface(sg, &IID_IQualityControl, (void**)&unk);
623 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IQualityControl failed: %08x\n", hr);
624 hr = ISampleGrabber_QueryInterface(sg, &IID_ISeekingPassThru, (void**)&unk);
625 ok(hr == E_NOINTERFACE, "QueryInterface for IID_ISeekingPassThru failed: %08x\n", hr);
626
627 while (ISampleGrabber_Release(sg));
628}
const GUID IID_IClassFactory
Definition: axcore.idl:92
#define todo_wine
Definition: custom.c:79
static ISampleGrabberCB my_sg_cb
Definition: mediadet.c:522
fstate
Definition: ms2ps.cpp:80
const GUID IID_IPersist
Definition: proxy.cpp:14
Definition: regsvr.c:104
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by START_TEST().

◆ unk_AddRef()

static ULONG WINAPI unk_AddRef ( IUnknown iface)
static

Definition at line 52 of file mediadet.c.

53{
54 struct unk_impl *This = impl_from_IUnknown(iface);
55
56 return InterlockedIncrement(&This->ref);
57}
#define InterlockedIncrement
Definition: armddk.h:53
static MediaDetImpl * impl_from_IUnknown(IUnknown *iface)
Definition: mediadet.c:48

◆ unk_QueryInterface()

static HRESULT WINAPI unk_QueryInterface ( IUnknown iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 45 of file mediadet.c.

46{
47 struct unk_impl *This = impl_from_IUnknown(iface);
48
49 return IUnknown_QueryInterface(This->inner_unk, riid, ppv);
50}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ unk_Release()

static ULONG WINAPI unk_Release ( IUnknown iface)
static

Definition at line 59 of file mediadet.c.

60{
61 struct unk_impl *This = impl_from_IUnknown(iface);
62
63 return InterlockedDecrement(&This->ref);
64}
#define InterlockedDecrement
Definition: armddk.h:52

◆ unpack_avi_file()

static BOOL unpack_avi_file ( int  id,
WCHAR  name[MAX_PATH] 
)
static

Definition at line 77 of file mediadet.c.

78{
79 static WCHAR temp_path[MAX_PATH];
80 static const WCHAR prefix[] = {'D','E','S',0};
81 static const WCHAR avi[] = {'a','v','i',0};
82 HRSRC res;
84 char *mem;
85 DWORD size, written;
86 HANDLE fh;
87 BOOL ret;
88
90 if (!res)
91 return FALSE;
92
94 if (!data)
95 return FALSE;
96
98 if (!mem)
99 return FALSE;
100
102 if (size == 0)
103 return FALSE;
104
106 return FALSE;
107
108 /* We might end up relying on the extension here, so .TMP is no good. */
109 if (!GetTempFileNameW(temp_path, prefix, 0, name))
110 return FALSE;
111
113 lstrcpyW(name + lstrlenW(name) - 3, avi);
114
117 if (fh == INVALID_HANDLE_VALUE)
118 return FALSE;
119
120 ret = WriteFile(fh, mem, size, &written, NULL);
121 CloseHandle(fh);
122 return ret && written == size;
123}
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
#define CREATE_NEW
Definition: disk.h:69
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define GENERIC_WRITE
Definition: nt_native.h:90
#define AVI_RES_TYPE
Definition: rc.h:27
Definition: mem.c:156
Definition: name.c:39
int ret
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by init_tests().

Variable Documentation

◆ my_sample

IMediaSample my_sample = { &my_sample_vt }
static

Definition at line 479 of file mediadet.c.

Referenced by sgcb_SampleCB(), and test_samplegrabber().

◆ my_sample_vt

const IMediaSampleVtbl my_sample_vt
static
Initial value:
= {
}
static HRESULT WINAPI ms_GetMediaTime(IMediaSample *iface, LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
Definition: mediadet.c:445
static HRESULT WINAPI ms_GetPointer(IMediaSample *iface, BYTE **ppBuffer)
Definition: mediadet.c:372
static HRESULT WINAPI ms_SetPreroll(IMediaSample *iface, BOOL bIsPreroll)
Definition: mediadet.c:409
static HRESULT WINAPI ms_IsPreroll(IMediaSample *iface)
Definition: mediadet.c:404
static LONG WINAPI ms_GetActualDataLength(IMediaSample *iface)
Definition: mediadet.c:414
static HRESULT WINAPI ms_SetMediaTime(IMediaSample *iface, LONGLONG *pTimeStart, LONGLONG *pTimeEnd)
Definition: mediadet.c:451
static ULONG WINAPI ms_AddRef(IMediaSample *iface)
Definition: mediadet.c:362
static HRESULT WINAPI ms_SetTime(IMediaSample *iface, REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
Definition: mediadet.c:388
static HRESULT WINAPI ms_QueryInterface(IMediaSample *iface, REFIID riid, void **ppvObject)
Definition: mediadet.c:356
static HRESULT WINAPI ms_SetMediaType(IMediaSample *iface, AM_MEDIA_TYPE *pMediaType)
Definition: mediadet.c:430
static HRESULT WINAPI ms_IsDiscontinuity(IMediaSample *iface)
Definition: mediadet.c:435
static HRESULT WINAPI ms_IsSyncPoint(IMediaSample *iface)
Definition: mediadet.c:394
static HRESULT WINAPI ms_GetTime(IMediaSample *iface, REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)
Definition: mediadet.c:382
static HRESULT WINAPI ms_SetSyncPoint(IMediaSample *iface, BOOL bIsSyncPoint)
Definition: mediadet.c:399
static HRESULT WINAPI ms_SetActualDataLength(IMediaSample *iface, LONG length)
Definition: mediadet.c:419
static HRESULT WINAPI ms_GetMediaType(IMediaSample *iface, AM_MEDIA_TYPE **ppMediaType)
Definition: mediadet.c:424
static HRESULT WINAPI ms_SetDiscontinuity(IMediaSample *iface, BOOL bDiscontinuity)
Definition: mediadet.c:440
static ULONG WINAPI ms_Release(IMediaSample *iface)
Definition: mediadet.c:367
static LONG WINAPI ms_GetSize(IMediaSample *iface)
Definition: mediadet.c:377

Definition at line 457 of file mediadet.c.

◆ my_sg_cb

ISampleGrabberCB my_sg_cb = { &sgcb_vt }
static

Definition at line 522 of file mediadet.c.

Referenced by test_samplegrabber().

◆ samplecb_called

BOOL samplecb_called = FALSE
static

Definition at line 481 of file mediadet.c.

Referenced by sgcb_SampleCB(), and test_samplegrabber().

◆ sgcb_vt

const ISampleGrabberCBVtbl sgcb_vt
static
Initial value:
= {
}
static ULONG WINAPI sgcb_AddRef(ISampleGrabberCB *iface)
Definition: mediadet.c:489
static ULONG WINAPI sgcb_Release(ISampleGrabberCB *iface)
Definition: mediadet.c:494
static HRESULT WINAPI sgcb_QueryInterface(ISampleGrabberCB *iface, REFIID riid, void **ppvObject)
Definition: mediadet.c:483
static HRESULT WINAPI sgcb_BufferCB(ISampleGrabberCB *iface, double SampleTime, BYTE *pBuffer, LONG BufferLen)
Definition: mediadet.c:507
static HRESULT WINAPI sgcb_SampleCB(ISampleGrabberCB *iface, double SampleTime, IMediaSample *pSample)
Definition: mediadet.c:499

Definition at line 514 of file mediadet.c.

◆ test_avi_filename

WCHAR test_avi_filename[MAX_PATH]
static

Definition at line 74 of file mediadet.c.

Referenced by init_tests(), and test_mediadet().

◆ test_sound_avi_filename

WCHAR test_sound_avi_filename[MAX_PATH]
static

Definition at line 75 of file mediadet.c.

Referenced by init_tests(), and test_mediadet().

◆ unk_vtbl

const IUnknownVtbl unk_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: mediadet.c:59
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: mediadet.c:45
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: mediadet.c:52

Definition at line 66 of file mediadet.c.

Referenced by test_mediadet(), and test_samplegrabber().