ReactOS 0.4.17-dev-806-gffa4164
api.c File Reference
#include "wine/test.h"
#include "initguid.h"
#include "wingdi.h"
#include "vfw.h"
Include dependency graph for api.c:

Go to the source code of this file.

Classes

struct  common_avi_headers
 
struct  unk_impl
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define IS_INFO_UPDATED(m)
 

Typedefs

typedef struct common_avi_headers COMMON_AVI_HEADERS
 

Functions

 DEFINE_AVIGUID (CLSID_WAVFile, 0x00020003, 0, 0)
 
static void test_AVISaveOptions (void)
 
static void test_EditStreamSetInfo (void)
 
static void init_test_struct (COMMON_AVI_HEADERS *cah)
 
static void create_avi_file (const COMMON_AVI_HEADERS *cah, char *filename)
 
static ULONG get_file_refcount (PAVIFILE file)
 
static void test_default_data (void)
 
static void test_amh_corruption (void)
 
static void test_ash1_corruption (void)
 
static void test_ash1_corruption2 (void)
 
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 void test_COM (void)
 
static void test_COM_wavfile (void)
 
static void test_COM_editstream (void)
 
 START_TEST (api)
 

Variables

static const CHAR winetest0 [] = "winetest0"
 
static const CHAR winetest1 [] = "winetest1"
 
static const CHAR testfilename [] = "wine_avifil32_test.avi"
 
static const DWORD deffh []
 
static const MainAVIHeader defmah
 
static const AVIStreamHeader defash0
 
static const AVIStreamHeader defash1
 
static const PCMWAVEFORMAT defpcmwf
 
static const DWORD streamlist []
 
static const DWORD videostreamformat []
 
static const DWORD padding1 []
 
static const DWORD videopropheader []
 
static const DWORD audiostreamformat_pre []
 
static DWORD data []
 
static const IUnknownVtbl unk_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file api.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 23 of file api.c.

◆ IS_INFO_UPDATED

#define IS_INFO_UPDATED (   m)
Value:
do { \
ok( hres == 0, "got 0x%08lX, expected 0\n", hres); \
hres = AVIStreamInfoA(stream, &info2, sizeof(info2) ); \
ok( hres == 0, "got 0x%08lX, expected 0\n", hres); \
ok( info2.m == info.m, "EditStreamSetInfo did not update "#m" parameter\n" ); \
} while(0)
HRESULT WINAPI EditStreamSetInfoA(PAVISTREAM pstream, LPAVISTREAMINFOA asi, LONG size)
Definition: api.c:2093
HRESULT WINAPI AVIStreamInfoA(PAVISTREAM pstream, LPAVISTREAMINFOA asi, LONG size)
Definition: api.c:496
const GLfloat * m
Definition: glext.h:10848
HRESULT hres
Definition: protocol.c:465
Definition: parse.h:23

Typedef Documentation

◆ COMMON_AVI_HEADERS

Function Documentation

◆ create_avi_file()

static void create_avi_file ( const COMMON_AVI_HEADERS cah,
char filename 
)
static

Definition at line 331 of file api.c.

332{
334 DWORD written;
335
337
338 ok(hFile != INVALID_HANDLE_VALUE, "Couldn't create file\n");
339
340 WriteFile(hFile, &cah->fh, sizeof(deffh), &written, NULL);
341 WriteFile(hFile, &cah->mah, sizeof(MainAVIHeader), &written, NULL);
342 WriteFile(hFile, streamlist, sizeof(streamlist), &written, NULL);
343 WriteFile(hFile, &cah->ash0, 0x38, &written, NULL);
345 WriteFile(hFile, padding1, sizeof(padding1), &written, NULL);
346 WriteFile(hFile, videopropheader, sizeof(videopropheader), &written, NULL);
347 WriteFile(hFile, &cah->ash1, 0x38, &written, NULL);
349 WriteFile(hFile, &cah->pcmwf, sizeof(PCMWAVEFORMAT), &written, NULL);
350 WriteFile(hFile, data, sizeof(data), &written, NULL);
351
353}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped)
Definition: rw.c:25
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const char * filename
Definition: ioapi.h:137
#define CREATE_ALWAYS
Definition: disk.h:72
static const DWORD audiostreamformat_pre[]
Definition: api.c:151
static const DWORD padding1[]
Definition: api.c:134
static const DWORD videostreamformat[]
Definition: api.c:127
static const DWORD streamlist[]
Definition: api.c:121
static const DWORD deffh[]
Definition: api.c:39
static const DWORD videopropheader[]
Definition: api.c:139
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
MainAVIHeader mah
Definition: api.c:112
PCMWAVEFORMAT pcmwf
Definition: api.c:115
DWORD fh[sizeof(deffh)]
Definition: api.c:111
AVIStreamHeader ash0
Definition: api.c:113
AVIStreamHeader ash1
Definition: api.c:114

Referenced by test_amh_corruption(), test_ash1_corruption(), test_ash1_corruption2(), and test_default_data().

◆ DEFINE_AVIGUID()

DEFINE_AVIGUID ( CLSID_WAVFile  ,
0x00020003  ,
,
 
)

◆ get_file_refcount()

static ULONG get_file_refcount ( PAVIFILE  file)
static

Definition at line 355 of file api.c.

356{
358 return AVIFileRelease(file);
359}
ULONG WINAPI AVIFileRelease(PAVIFILE pfile)
Definition: api.c:291
ULONG WINAPI AVIFileAddRef(PAVIFILE pfile)
Definition: api.c:276
Definition: fci.c:123

Referenced by test_default_data().

◆ impl_from_IUnknown()

static struct unk_impl * impl_from_IUnknown ( IUnknown iface)
inlinestatic

Definition at line 582 of file api.c.

583{
584 return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
585}
Definition: api.c:576
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by unk_AddRef(), unk_QueryInterface(), and unk_Release().

◆ init_test_struct()

static void init_test_struct ( COMMON_AVI_HEADERS cah)
static

Definition at line 322 of file api.c.

323{
324 memcpy(cah->fh, deffh, sizeof(deffh));
325 cah->mah = defmah;
326 cah->ash0 = defash0;
327 cah->ash1 = defash1;
328 cah->pcmwf = defpcmwf;
329}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const AVIStreamHeader defash0
Definition: api.c:61
static const AVIStreamHeader defash1
Definition: api.c:79
static const PCMWAVEFORMAT defpcmwf
Definition: api.c:98
static const MainAVIHeader defmah
Definition: api.c:46

Referenced by test_amh_corruption(), test_ash1_corruption(), test_ash1_corruption2(), and test_default_data().

◆ START_TEST()

START_TEST ( api  )

Definition at line 774 of file api.c.

775{
776
777 AVIFileInit();
784 test_COM();
787 AVIFileExit();
788
789}
void WINAPI AVIFileExit(void)
Definition: api.c:182
void WINAPI AVIFileInit(void)
Definition: api.c:175
static void test_amh_corruption(void)
Definition: api.c:484
static void test_ash1_corruption2(void)
Definition: api.c:541
static void test_ash1_corruption(void)
Definition: api.c:505
static void test_COM_editstream(void)
Definition: api.c:745
static void test_COM_wavfile(void)
Definition: api.c:684
static void test_AVISaveOptions(void)
Definition: api.c:174
static void test_EditStreamSetInfo(void)
Definition: api.c:226
static void test_default_data(void)
Definition: api.c:361
static void test_COM(void)
Definition: api.c:634

◆ test_amh_corruption()

static void test_amh_corruption ( void  )
static

Definition at line 484 of file api.c.

485{
487 char filename[MAX_PATH];
489 int res;
490
493
494 /* Make sure only AVI files with the proper headers will be loaded */
495 init_test_struct(&cah);
496 cah.fh[3] = mmioFOURCC('A', 'V', 'i', ' ');
497
500 ok(res != 0, "Able to open file: error=%u\n", res);
501
502 ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
503}
HRESULT WINAPI AVIFileOpenA(PAVIFILE *ppfile, LPCSTR szFile, UINT uMode, LPCLSID lpHandler)
Definition: api.c:192
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:1973
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
#define L(x)
Definition: resources.c:13
MdFileObject pFile
GLuint res
Definition: glext.h:9613
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
static void init_test_struct(COMMON_AVI_HEADERS *cah)
Definition: api.c:322
static const CHAR testfilename[]
Definition: api.c:35
static void create_avi_file(const COMMON_AVI_HEADERS *cah, char *filename)
Definition: api.c:331
strcpy
Definition: string.h:131
#define OF_SHARE_DENY_WRITE
Definition: winbase.h:125

Referenced by START_TEST().

◆ test_ash1_corruption()

static void test_ash1_corruption ( void  )
static

Definition at line 505 of file api.c.

506{
508 char filename[MAX_PATH];
510 int res;
511 PAVISTREAM pStream1;
512 AVISTREAMINFOA asi1;
513
516
517 /* Corrupt the sample size in the audio stream header */
518 init_test_struct(&cah);
519 cah.ash1.dwSampleSize = 0xdeadbeef;
520
522
524 ok(res == 0, "Unable to open file: error=%u\n", res);
525
526 res = AVIFileGetStream(pFile, &pStream1, 0, 1);
527 ok(res == 0, "Unable to open audio stream: error=%u\n", res);
528
529 res = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1));
530 ok(res == 0, "Unable to read stream info: error=%u\n", res);
531
532 /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign
533 value from the stream format header. The next test will prove this */
534 ok(asi1.dwSampleSize == 2, "got %lu (expected 2)\n", asi1.dwSampleSize);
535
536 AVIStreamRelease(pStream1);
538 ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
539}
HRESULT WINAPI AVIFileGetStream(PAVIFILE pfile, PAVISTREAM *avis, DWORD fccType, LONG lParam)
Definition: api.c:345
ULONG WINAPI AVIStreamRelease(PAVISTREAM pstream)
Definition: api.c:449
DWORD dwSampleSize
Definition: vfw.h:971
DWORD dwSampleSize
Definition: vfw.h:1017

Referenced by START_TEST().

◆ test_ash1_corruption2()

static void test_ash1_corruption2 ( void  )
static

Definition at line 541 of file api.c.

542{
544 char filename[MAX_PATH];
546 int res;
547 PAVISTREAM pStream1;
548 AVISTREAMINFOA asi1;
549
552
553 /* Corrupt the block alignment in the audio format header */
554 init_test_struct(&cah);
555 cah.pcmwf.wf.nBlockAlign = 0xdead;
556
558
560 ok(res == 0, "Unable to open file: error=%u\n", res);
561
562 res = AVIFileGetStream(pFile, &pStream1, 0, 1);
563 ok(res == 0, "Unable to open audio stream: error=%u\n", res);
564
565 ok(AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)) == 0, "Unable to read stream info\n");
566
567 /* The result will also be the corrupt value, as explained above. */
568 ok(asi1.dwSampleSize == 0xdead, "got 0x%lx (expected 0xdead)\n", asi1.dwSampleSize);
569
570 AVIStreamRelease(pStream1);
572 ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
573}
WAVEFORMAT wf
Definition: mmsystem.h:1077
WORD nBlockAlign
Definition: mmsystem.h:1073

Referenced by START_TEST().

◆ test_AVISaveOptions()

static void test_AVISaveOptions ( void  )
static

Definition at line 174 of file api.c.

175{
177 LPAVICOMPRESSOPTIONS poptions[2];
178 PAVISTREAM streams[2] = {NULL, NULL};
180 DWORD res;
181 LONG lres;
182
183 poptions[0] = &options[0];
184 poptions[1] = &options[1];
185 ZeroMemory(options, sizeof(options));
186
187 SetLastError(0xdeadbeef);
188 hres = CreateEditableStream(&streams[0], NULL);
189 ok(hres == AVIERR_OK, "0: got 0x%lx and %p (expected AVIERR_OK)\n", hres, streams[0]);
190
191 SetLastError(0xdeadbeef);
192 hres = CreateEditableStream(&streams[1], NULL);
193 ok(hres == AVIERR_OK, "1: got 0x%lx and %p (expected AVIERR_OK)\n", hres, streams[1]);
194
195 SetLastError(0xdeadbeef);
196 hres = EditStreamSetNameA(streams[0], winetest0);
197 ok(hres == AVIERR_OK, "0: got 0x%lx (expected AVIERR_OK)\n", hres);
198
199 SetLastError(0xdeadbeef);
200 hres = EditStreamSetNameA(streams[1], winetest1);
201 ok(hres == AVIERR_OK, "1: got 0x%lx (expected AVIERR_OK)\n", hres);
202
204 SetLastError(0xdeadbeef);
206 2, streams, poptions);
207 trace("got %lu with 0x%lx/%lu\n", res, GetLastError(), GetLastError());
208 }
209
210 SetLastError(0xdeadbeef);
211 lres = AVISaveOptionsFree(2, poptions);
212 ok(lres == AVIERR_OK, "got 0x%lx with 0x%lx/%lu\n", lres, GetLastError(), GetLastError());
213
214 SetLastError(0xdeadbeef);
215 res = AVIStreamRelease(streams[0]);
216 ok(res == 0, "0: got refcount %lu (expected 0)\n", res);
217
218 SetLastError(0xdeadbeef);
219 res = AVIStreamRelease(streams[1]);
220 ok(res == 0, "1: got refcount %lu (expected 0)\n", res);
221
222}
#define trace
Definition: atltest.h:70
BOOL WINAPI AVISaveOptions(HWND hWnd, UINT uFlags, INT nStreams, PAVISTREAM *ppavi, LPAVICOMPRESSOPTIONS *ppOptions)
Definition: api.c:1421
HRESULT WINAPI EditStreamSetNameA(PAVISTREAM pstream, LPCSTR szName)
Definition: api.c:2137
HRESULT WINAPI AVISaveOptionsFree(INT nStreams, LPAVICOMPRESSOPTIONS *ppOptions)
Definition: api.c:1474
#define SetLastError(x)
Definition: compat.h:752
HRESULT WINAPI CreateEditableStream(IAVIStream **editable, IAVIStream *src)
Definition: editstream.c:1027
int winetest_interactive
#define ZeroMemory
Definition: minwinbase.h:31
static const CHAR winetest0[]
Definition: api.c:33
static const CHAR winetest1[]
Definition: api.c:34
long LONG
Definition: pedump.c:60
#define ICMF_CHOOSE_KEYFRAME
Definition: vfw.h:848
#define AVIERR_OK
Definition: vfw.h:1740
#define ICMF_CHOOSE_DATARATE
Definition: vfw.h:849
#define ICMF_CHOOSE_ALLCOMPRESSORS
Definition: vfw.h:851
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ test_COM()

static void test_COM ( void  )
static

Definition at line 634 of file api.c.

635{
636 struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
637 IAVIFile *avif = NULL;
638 IPersistFile *pf;
639 IUnknown *unk;
640 LONG refcount;
641 HRESULT hr;
642
643 /* COM aggregation */
644 hr = CoCreateInstance(&CLSID_AVIFile, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
645 &IID_IUnknown, (void**)&unk_obj.inner_unk);
646 ok(hr == S_OK, "COM aggregation failed: %08lx, expected S_OK\n", hr);
647 hr = IUnknown_QueryInterface(&unk_obj.IUnknown_iface, &IID_IAVIFile, (void**)&avif);
648 ok(hr == S_OK, "QueryInterface for IID_IAVIFile failed: %08lx\n", hr);
649 refcount = IAVIFile_AddRef(avif);
650 ok(refcount == unk_obj.ref, "AVIFile just pretends to support COM aggregation\n");
651 refcount = IAVIFile_Release(avif);
652 ok(refcount == unk_obj.ref, "AVIFile just pretends to support COM aggregation\n");
653 hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
654 ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08lx\n", hr);
655 refcount = IPersistFile_Release(pf);
656 ok(refcount == unk_obj.ref, "AVIFile just pretends to support COM aggregation\n");
657 refcount = IAVIFile_Release(avif);
658 ok(refcount == 19, "Outer ref count should be back at 19 but is %ld\n", refcount);
659 refcount = IUnknown_Release(unk_obj.inner_unk);
660 ok(refcount == 0, "Inner ref count should be 0 but is %lu\n", refcount);
661
662 /* Invalid RIID */
663 hr = CoCreateInstance(&CLSID_AVIFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIStream,
664 (void**)&avif);
665 ok(hr == E_NOINTERFACE, "AVIFile create failed: %08lx, expected E_NOINTERFACE\n", hr);
666
667 /* Same refcount */
668 hr = CoCreateInstance(&CLSID_AVIFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIFile, (void**)&avif);
669 ok(hr == S_OK, "AVIFile create failed: %08lx, expected S_OK\n", hr);
670 refcount = IAVIFile_AddRef(avif);
671 ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
672 hr = IAVIFile_QueryInterface(avif, &IID_IUnknown, (void**)&unk);
673 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08lx\n", hr);
674 refcount = IUnknown_AddRef(unk);
675 ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
676 hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
677 ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08lx\n", hr);
678 refcount = IPersistFile_AddRef(pf);
679 ok(refcount == 6, "refcount == %lu, expected 6\n", refcount);
680
681 while (IAVIFile_Release(avif));
682}
const GUID IID_IUnknown
HRESULT hr
Definition: delayimp.cpp:582
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define S_OK
Definition: intsafe.h:52
static const IUnknownVtbl unk_vtbl
Definition: api.c:627
const GUID IID_IPersistFile
IUnknown IUnknown_iface
Definition: api.c:577
IUnknown * inner_unk
Definition: api.c:579
LONG ref
Definition: api.c:578
#define IAVIFile_QueryInterface(p, a, b)
Definition: vfw.h:1602
#define IAVIFile_Release(p)
Definition: vfw.h:1604
#define IAVIFile_AddRef(p)
Definition: vfw.h:1603
#define E_NOINTERFACE
Definition: winerror.h:3479

Referenced by START_TEST().

◆ test_COM_editstream()

static void test_COM_editstream ( void  )
static

Definition at line 745 of file api.c.

746{
747 IAVIEditStream *edit;
749 IUnknown *unk;
750 ULONG refcount;
751 HRESULT hr;
752
753 /* Same refcount for all AVIEditStream interfaces */
755 ok(hr == S_OK, "AVIEditStream create failed: %08lx, expected S_OK\n", hr);
756 refcount = IAVIStream_AddRef(stream);
757 ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
758
759 hr = IAVIStream_QueryInterface(stream, &IID_IAVIEditStream, (void**)&edit);
760 ok(hr == S_OK, "QueryInterface for IID_IAVIEditStream failed: %08lx\n", hr);
761 refcount = IAVIEditStream_AddRef(edit);
762 ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
763 refcount = IAVIEditStream_Release(edit);
764
765 hr = IAVIEditStream_QueryInterface(edit, &IID_IUnknown, (void**)&unk);
766 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08lx\n", hr);
767 refcount = IUnknown_AddRef(unk);
768 ok(refcount == 5, "refcount == %lu, expected 5\n", refcount);
769 IUnknown_Release(unk);
770
771 while (IAVIEditStream_Release(edit));
772}
uint32_t ULONG
Definition: typedefs.h:59
#define IAVIEditStream_AddRef(p)
Definition: vfw.h:1510
#define IAVIStream_AddRef(p)
Definition: vfw.h:1176
#define IAVIStream_QueryInterface(p, a, b)
Definition: vfw.h:1175
#define IAVIEditStream_QueryInterface(p, a, b)
Definition: vfw.h:1509
#define IAVIEditStream_Release(p)
Definition: vfw.h:1511

Referenced by START_TEST().

◆ test_COM_wavfile()

static void test_COM_wavfile ( void  )
static

Definition at line 684 of file api.c.

685{
686 struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
687 IAVIFile *avif = NULL;
688 IPersistFile *pf;
689 IAVIStream *avis;
690 IUnknown *unk;
691 ULONG refcount;
692 HRESULT hr;
693
694 /* COM aggregation */
695 hr = CoCreateInstance(&CLSID_WAVFile, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
696 &IID_IUnknown, (void**)&unk_obj.inner_unk);
697 ok(hr == S_OK, "COM aggregation failed: %08lx, expected S_OK\n", hr);
698 hr = IUnknown_QueryInterface(&unk_obj.IUnknown_iface, &IID_IAVIFile, (void**)&avif);
699 ok(hr == S_OK, "QueryInterface for IID_IAVIFile failed: %08lx\n", hr);
700 refcount = IAVIFile_AddRef(avif);
701 ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
702 refcount = IAVIFile_Release(avif);
703 ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
704 hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
705 ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08lx\n", hr);
706 refcount = IPersistFile_Release(pf);
707 ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
708 refcount = IAVIFile_Release(avif);
709 ok(refcount == 19, "Outer ref count should be back at 19 but is %ld\n", refcount);
710 refcount = IUnknown_Release(unk_obj.inner_unk);
711 ok(refcount == 0, "Inner ref count should be 0 but is %lu\n", refcount);
712
713 /* Invalid RIID */
714 hr = CoCreateInstance(&CLSID_WAVFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIStreaming,
715 (void**)&avif);
716 ok(hr == E_NOINTERFACE, "WAVFile create failed: %08lx, expected E_NOINTERFACE\n", hr);
717
718 /* Same refcount for all WAVFile interfaces */
719 hr = CoCreateInstance(&CLSID_WAVFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIFile, (void**)&avif);
720 ok(hr == S_OK, "WAVFile create failed: %08lx, expected S_OK\n", hr);
721 refcount = IAVIFile_AddRef(avif);
722 ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
723
724 hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
725 ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08lx\n", hr);
726 refcount = IPersistFile_AddRef(pf);
727 ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
728 refcount = IPersistFile_Release(pf);
729
730 hr = IAVIFile_QueryInterface(avif, &IID_IAVIStream, (void**)&avis);
731 ok(hr == S_OK, "QueryInterface for IID_IAVIStream failed: %08lx\n", hr);
732 refcount = IAVIStream_AddRef(avis);
733 ok(refcount == 5, "refcount == %lu, expected 5\n", refcount);
734 refcount = IAVIStream_Release(avis);
735
736 hr = IAVIFile_QueryInterface(avif, &IID_IUnknown, (void**)&unk);
737 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08lx\n", hr);
738 refcount = IUnknown_AddRef(unk);
739 ok(refcount == 6, "refcount == %lu, expected 6\n", refcount);
740 refcount = IUnknown_Release(unk);
741
742 while (IAVIFile_Release(avif));
743}
#define IAVIStream_Release(p)
Definition: vfw.h:1177

Referenced by START_TEST().

◆ test_default_data()

static void test_default_data ( void  )
static

Definition at line 361 of file api.c.

362{
364 char filename[MAX_PATH];
366 int res;
367 LONG lSize;
368 PAVISTREAM pStream0;
369 PAVISTREAM pStream1;
370 AVISTREAMINFOA asi0, asi1;
371 WAVEFORMATEX wfx;
372 ULONG refcount;
373
376
377 init_test_struct(&cah);
379
381 ok(res == 0, "Unable to open file: error=%u\n", res);
382
383 pStream0 = (void *)0xdeadbeef;
384 res = AVIFileGetStream(pFile, &pStream0, ~0U, 0);
385 ok(res == AVIERR_NODATA, "expected AVIERR_NODATA, got %u\n", res);
386 ok(pStream0 == NULL, "AVIFileGetStream should set stream to NULL\n");
387
388 res = AVIFileGetStream(pFile, &pStream0, 0, 0);
389 ok(res == 0, "Unable to open video stream: error=%u\n", res);
390
391 res = AVIFileGetStream(pFile, &pStream1, 0, 1);
392 ok(res == 0, "Unable to open audio stream: error=%u\n", res);
393
394 res = AVIStreamInfoA(pStream0, &asi0, sizeof(asi0));
395 ok(res == 0, "Unable to read stream info: error=%u\n", res);
396
397 res = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1));
398 ok(res == 0, "Unable to read stream info: error=%u\n", res);
399
400 res = AVIStreamReadFormat(pStream0, AVIStreamStart(pStream1), NULL, &lSize);
401 ok(res == 0, "Unable to read format size: error=%u\n", res);
402
403 res = AVIStreamReadFormat(pStream1, AVIStreamStart(pStream1), &wfx, &lSize);
404 ok(res == 0, "Unable to read format: error=%u\n", res);
405
406 ok(asi0.fccType == streamtypeVIDEO, "got 0x%lx (expected streamtypeVIDEO)\n", asi0.fccType);
407 ok(asi0.fccHandler == 0x30323449, "got 0x%lx (expected 0x30323449)\n", asi0.fccHandler);
408 ok(asi0.dwFlags == 0, "got %lu (expected 0)\n", asi0.dwFlags);
409 ok(asi0.wPriority == 0, "got %u (expected 0)\n", asi0.wPriority);
410 ok(asi0.wLanguage == 0, "got %u (expected 0)\n", asi0.wLanguage);
411 ok(asi0.dwScale == 1001, "got %lu (expected 1001)\n", asi0.dwScale);
412 ok(asi0.dwRate == 30000, "got %lu (expected 30000)\n", asi0.dwRate);
413 ok(asi0.dwStart == 0, "got %lu (expected 0)\n", asi0.dwStart);
414 ok(asi0.dwLength == 1, "got %lu (expected 1)\n", asi0.dwLength);
415 ok(asi0.dwInitialFrames == 0, "got %lu (expected 0)\n", asi0.dwInitialFrames);
416 ok(asi0.dwSuggestedBufferSize == 0, "got %lu (expected 0)\n", asi0.dwSuggestedBufferSize);
417 ok(asi0.dwQuality == 0xffffffff, "got 0x%lx (expected 0xffffffff)\n", asi0.dwQuality);
418 ok(asi0.dwSampleSize == 0, "got %lu (expected 0)\n", asi0.dwSampleSize);
419 ok(asi0.rcFrame.left == 0, "got %lu (expected 0)\n", asi0.rcFrame.left);
420 ok(asi0.rcFrame.top == 0, "got %lu (expected 0)\n", asi0.rcFrame.top);
421 ok(asi0.rcFrame.right == 8, "got %lu (expected 8)\n", asi0.rcFrame.right); /* these are based on the values in the mah and not */
422 ok(asi0.rcFrame.bottom == 6, "got %lu (expected 6)\n", asi0.rcFrame.bottom);/* on the ones in the ash which are 0 here */
423 ok(asi0.dwEditCount == 0, "got %lu (expected 0)\n", asi0.dwEditCount);
424 ok(asi0.dwFormatChangeCount == 0, "got %lu (expected 0)\n", asi0.dwFormatChangeCount);
425
426 ok(asi1.fccType == streamtypeAUDIO, "got 0x%lx (expected streamtypeVIDEO)\n", asi1.fccType);
427 ok(asi1.fccHandler == 0x1, "got 0x%lx (expected 0x1)\n", asi1.fccHandler);
428 ok(asi1.dwFlags == 0, "got %lu (expected 0)\n", asi1.dwFlags);
429 ok(asi1.wPriority == 0, "got %u (expected 0)\n", asi1.wPriority);
430 ok(asi1.wLanguage == 0, "got %u (expected 0)\n", asi1.wLanguage);
431 ok(asi1.dwScale == 1, "got %lu (expected 1)\n", asi1.dwScale);
432 ok(asi1.dwRate == 11025, "got %lu (expected 11025)\n", asi1.dwRate);
433 ok(asi1.dwStart == 0, "got %lu (expected 0)\n", asi1.dwStart);
434 ok(asi1.dwLength == 1637, "got %lu (expected 1637)\n", asi1.dwLength);
435 ok(asi1.dwInitialFrames == 0, "got %lu (expected 0)\n", asi1.dwInitialFrames);
436 ok(asi1.dwSuggestedBufferSize == 0, "got %lu (expected 0)\n", asi1.dwSuggestedBufferSize);
437 ok(asi1.dwQuality == 0xffffffff, "got 0x%lx (expected 0xffffffff)\n", asi1.dwQuality);
438 ok(asi1.dwSampleSize == 2, "got %lu (expected 2)\n", asi1.dwSampleSize);
439 ok(asi1.rcFrame.left == 0, "got %lu (expected 0)\n", asi1.rcFrame.left);
440 ok(asi1.rcFrame.top == 0, "got %lu (expected 0)\n", asi1.rcFrame.top);
441 ok(asi1.rcFrame.right == 0, "got %lu (expected 0)\n", asi1.rcFrame.right);
442 ok(asi1.rcFrame.bottom == 0, "got %lu (expected 0)\n", asi1.rcFrame.bottom);
443 ok(asi1.dwEditCount == 0, "got %lu (expected 0)\n", asi1.dwEditCount);
444 ok(asi1.dwFormatChangeCount == 0, "got %lu (expected 0)\n", asi1.dwFormatChangeCount);
445
446 ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag);
447 ok(wfx.nChannels == 2, "got %u (expected 2)\n",wfx.nChannels);
448 ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag);
449 ok(wfx.nSamplesPerSec == 11025, "got %lu (expected 11025)\n",wfx.nSamplesPerSec);
450 ok(wfx.nAvgBytesPerSec == 22050, "got %lu (expected 22050)\n",wfx.nAvgBytesPerSec);
451 ok(wfx.nBlockAlign == 2, "got %u (expected 2)\n",wfx.nBlockAlign);
452
453 refcount = get_file_refcount(pFile);
454 ok(refcount == 3, "got %lu (expected 3)\n", refcount);
455
456 AVIStreamRelease(pStream0);
457
458 refcount = get_file_refcount(pFile);
459 ok(refcount == 2, "got %lu (expected 2)\n", refcount);
460
461 AVIStreamAddRef(pStream1);
462
463 refcount = get_file_refcount(pFile);
464 ok(refcount == 2, "got %lu (expected 2)\n", refcount);
465
466 AVIStreamRelease(pStream1);
467 AVIStreamRelease(pStream1);
468
469 refcount = get_file_refcount(pFile);
470 ok(refcount == 1, "got %lu (expected 1)\n", refcount);
471
472 refcount = AVIStreamRelease(pStream1);
473 ok(refcount == (ULONG)-1, "got %lu (expected 4294967295)\n", refcount);
474
475 refcount = get_file_refcount(pFile);
476 ok(refcount == 1, "got %lu (expected 1)\n", refcount);
477
478 refcount = AVIFileRelease(pFile);
479 ok(refcount == 0, "got %lu (expected 0)\n", refcount);
480
481 ok(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
482}
#define streamtypeAUDIO
Definition: aviriff.h:93
#define streamtypeVIDEO
Definition: aviriff.h:92
#define U(x)
Definition: wordpad.c:45
ULONG WINAPI AVIStreamAddRef(PAVISTREAM pstream)
Definition: api.c:434
LONG WINAPI AVIStreamStart(PAVISTREAM pstream)
Definition: api.c:858
HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM pstream, LONG pos, LPVOID format, LPLONG formatsize)
Definition: api.c:549
static ULONG get_file_refcount(PAVIFILE file)
Definition: api.c:355
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
DWORD nSamplesPerSec
Definition: audioclient.idl:42
DWORD dwScale
Definition: vfw.h:1010
WORD wPriority
Definition: vfw.h:1008
WORD wLanguage
Definition: vfw.h:1009
DWORD dwEditCount
Definition: vfw.h:1019
DWORD dwFlags
Definition: vfw.h:1006
RECT rcFrame
Definition: vfw.h:1018
DWORD dwFormatChangeCount
Definition: vfw.h:1020
DWORD dwStart
Definition: vfw.h:1012
DWORD dwQuality
Definition: vfw.h:1016
DWORD fccHandler
Definition: vfw.h:1005
DWORD dwInitialFrames
Definition: vfw.h:1014
DWORD dwLength
Definition: vfw.h:1013
DWORD dwRate
Definition: vfw.h:1011
DWORD dwSuggestedBufferSize
Definition: vfw.h:1015
DWORD fccType
Definition: vfw.h:1004
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#define AVIERR_NODATA
Definition: vfw.h:1757

Referenced by START_TEST().

◆ test_EditStreamSetInfo()

static void test_EditStreamSetInfo ( void  )
static

Definition at line 226 of file api.c.

227{
230 AVISTREAMINFOA info, info2;
231
233 ok(hres == AVIERR_OK, "got 0x%08lX, expected AVIERR_OK\n", hres);
234
235 /* Size parameter is somehow checked (notice the crash with size=-1 below) */
237 ok( hres == AVIERR_BADSIZE, "got 0x%08lX, expected AVIERR_BADSIZE\n", hres);
238
240 ok( hres == AVIERR_BADSIZE, "got 0x%08lX, expected AVIERR_BADSIZE\n", hres);
241
242 if(0)
243 {
244 /* Crashing - first parameter not checked */
245 EditStreamSetInfoA(NULL, &info, sizeof(info) );
246
247 /* Crashing - second parameter not checked */
249
251 }
252
253 hres = AVIStreamInfoA(stream, &info, sizeof(info) );
254 ok( hres == 0, "got 0x%08lX, expected 0\n", hres);
255
256 /* Does the function check what's it's updating ? */
257
258#define IS_INFO_UPDATED(m) do { \
259 hres = EditStreamSetInfoA(stream, &info, sizeof(info) ); \
260 ok( hres == 0, "got 0x%08lX, expected 0\n", hres); \
261 hres = AVIStreamInfoA(stream, &info2, sizeof(info2) ); \
262 ok( hres == 0, "got 0x%08lX, expected 0\n", hres); \
263 ok( info2.m == info.m, "EditStreamSetInfo did not update "#m" parameter\n" ); \
264 } while(0)
265
266 info.dwStart++;
267 IS_INFO_UPDATED(dwStart);
268 info.dwStart = 0;
269 IS_INFO_UPDATED(dwStart);
270
271 info.wPriority++;
272 IS_INFO_UPDATED(wPriority);
273 info.wPriority = 0;
274 IS_INFO_UPDATED(wPriority);
275
276 info.wLanguage++;
277 IS_INFO_UPDATED(wLanguage);
278 info.wLanguage = 0;
279 IS_INFO_UPDATED(wLanguage);
280
281 info.dwScale++;
282 IS_INFO_UPDATED(dwScale);
283 info.dwScale = 0;
284 IS_INFO_UPDATED(dwScale);
285
286 info.dwRate++;
287 IS_INFO_UPDATED(dwRate);
288 info.dwRate = 0;
289 IS_INFO_UPDATED(dwRate);
290
291 info.dwQuality++;
292 IS_INFO_UPDATED(dwQuality);
293 info.dwQuality = 0;
294 IS_INFO_UPDATED(dwQuality);
295 info.dwQuality = -2;
296 IS_INFO_UPDATED(dwQuality);
297 info.dwQuality = ICQUALITY_HIGH+1;
298 IS_INFO_UPDATED(dwQuality);
299
300 info.rcFrame.left = 0;
301 IS_INFO_UPDATED(rcFrame.left);
302 info.rcFrame.top = 0;
303 IS_INFO_UPDATED(rcFrame.top);
304 info.rcFrame.right = 0;
305 IS_INFO_UPDATED(rcFrame.right);
306 info.rcFrame.bottom = 0;
307 IS_INFO_UPDATED(rcFrame.bottom);
308
309 info.rcFrame.left = -1;
310 IS_INFO_UPDATED(rcFrame.left);
311 info.rcFrame.top = -1;
312 IS_INFO_UPDATED(rcFrame.top);
313 info.rcFrame.right = -1;
314 IS_INFO_UPDATED(rcFrame.right);
315 info.rcFrame.bottom = -1;
316 IS_INFO_UPDATED(rcFrame.bottom);
318#undef IS_INFO_UPDATED
319}
#define IS_INFO_UPDATED(m)
#define ICQUALITY_HIGH
Definition: vfw.h:277
#define AVIERR_BADSIZE
Definition: vfw.h:1749

Referenced by START_TEST().

◆ unk_AddRef()

static ULONG WINAPI unk_AddRef ( IUnknown iface)
static

Definition at line 613 of file api.c.

614{
615 struct unk_impl *This = impl_from_IUnknown(iface);
616
617 return InterlockedIncrement(&This->ref);
618}
#define InterlockedIncrement
Definition: armddk.h:53
static struct unk_impl * impl_from_IUnknown(IUnknown *iface)
Definition: api.c:582

◆ unk_QueryInterface()

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

Definition at line 587 of file api.c.

588{
589 struct unk_impl *This = impl_from_IUnknown(iface);
590 LONG ref = This->ref;
591 HRESULT hr;
592
594 {
595 *ppv = iface;
596 IUnknown_AddRef(iface);
597 return S_OK;
598 }
599
600 hr = IUnknown_QueryInterface(This->inner_unk, riid, ppv);
601 if (hr == S_OK)
602 {
603 trace("Working around COM aggregation ref counting bug\n");
604 ok(ref == This->ref, "Outer ref count expected %ld got %ld\n", ref, This->ref);
605 IUnknown_AddRef((IUnknown*)*ppv);
606 ref = IUnknown_Release(This->inner_unk);
607 ok(ref == 1, "Inner ref count expected 1 got %ld\n", ref);
608 }
609
610 return hr;
611}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: send.c:48

◆ unk_Release()

static ULONG WINAPI unk_Release ( IUnknown iface)
static

Definition at line 620 of file api.c.

621{
622 struct unk_impl *This = impl_from_IUnknown(iface);
623
624 return InterlockedDecrement(&This->ref);
625}
#define InterlockedDecrement
Definition: armddk.h:52

Variable Documentation

◆ audiostreamformat_pre

const DWORD audiostreamformat_pre[]
static
Initial value:
=
{
}
#define ckidSTREAMFORMAT
Definition: aviriff.h:125
struct pcmwaveformat_tag PCMWAVEFORMAT

Definition at line 151 of file api.c.

Referenced by create_avi_file().

◆ data

DWORD data[]
static
Initial value:
=
{
0x00000004, 0x00000000, 0x62773130,
0x6c6d646f, 0x686c6d64, 0x000000f8,
FOURCC_LIST, 0x18 ,
0x4f464e49,
0x54465349, 0xc ,
0x6676614c, 0x332e3235, 0x00302e37,
0,
0, 0
}
#define FOURCC_LIST
Definition: mmsystem.h:565
#define listtypeAVIMOVIE
Definition: vfw.h:898
#define ckidAVIPADDING
Definition: vfw.h:916

Definition at line 156 of file api.c.

◆ defash0

const AVIStreamHeader defash0
static
Initial value:
=
{
0x30323449,
0x00000000,
0,
0,
0,
0x000003e9,
0x00007530,
0,
1,
0x00100000,
0xffffffff,
0,
{ 0, 0, 0, 0 }
}

Definition at line 61 of file api.c.

Referenced by init_test_struct().

◆ defash1

const AVIStreamHeader defash1
static
Initial value:
=
{
1,
0,
0,
0,
0,
1,
0x00002b11,
0,
0x00000665,
0x00003000,
0xffffffff,
2,
{ 0, 0, 0, 0 }
}

Definition at line 79 of file api.c.

Referenced by init_test_struct().

◆ deffh

const DWORD deffh[]
static
Initial value:
=
{
FOURCC_LIST, 0x1ac ,
}
#define FOURCC_RIFF
Definition: mmsystem.h:564
struct _MainAVIHeader MainAVIHeader
#define listtypeAVIHEADER
Definition: vfw.h:890
#define ckidAVIMAINHDR
Definition: vfw.h:891
#define formtypeAVI
Definition: vfw.h:889

Definition at line 39 of file api.c.

Referenced by create_avi_file(), and init_test_struct().

◆ defmah

const MainAVIHeader defmah
static
Initial value:
=
{
0x00008256,
0x000080e8,
0x00000000,
0x00000910,
1,
0,
2,
0x00100000,
8,
6,
{ 0, 0, 0, 0 }
}

Definition at line 46 of file api.c.

Referenced by init_test_struct().

◆ defpcmwf

const PCMWAVEFORMAT defpcmwf
static
Initial value:
=
{
{
1,
2,
11025,
22050,
2,
},
8,
}

Definition at line 98 of file api.c.

Referenced by init_test_struct().

◆ padding1

const DWORD padding1[]
static
Initial value:
=
{
0x00000004, 0x00000000, 0x63643030
}

Definition at line 134 of file api.c.

Referenced by create_avi_file().

◆ streamlist

const DWORD streamlist[]
static
Initial value:
=
{
FOURCC_LIST, 0xd4 ,
}
#define ckidSTREAMHEADER
Definition: aviriff.h:88
#define listtypeSTREAMHEADER
Definition: vfw.h:892

Definition at line 121 of file api.c.

Referenced by create_avi_file().

◆ testfilename

const CHAR testfilename[] = "wine_avifil32_test.avi"
static

◆ unk_vtbl

const IUnknownVtbl unk_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI unk_Release(IUnknown *iface)
Definition: api.c:620
static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
Definition: api.c:587
static ULONG WINAPI unk_AddRef(IUnknown *iface)
Definition: api.c:613

Definition at line 627 of file api.c.

Referenced by test_COM(), and test_COM_wavfile().

◆ videopropheader

const DWORD videopropheader[]
static
Initial value:
=
{
0x70727076, 0x44 ,
0x00000000, 0x00000000,
0x0000001e, 0x00000008, 0x00000006, 0x00100009,
0x00000008, 0x00000006, 0x00000001, 0x00000006,
0x00000008, 0x00000006, 0x00000008, 0x00000000,
0x00000000, 0x00000000, 0x00000000,
FOURCC_LIST, 0x70 ,
}

Definition at line 139 of file api.c.

Referenced by create_avi_file().

◆ videostreamformat

const DWORD videostreamformat[]
static
Initial value:
=
{
0x00000028, 0x00000008, 0x00000006, 0x00180001,
0x30323449, 0x00000090, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
}

Definition at line 127 of file api.c.

Referenced by create_avi_file().

◆ winetest0

const CHAR winetest0[] = "winetest0"
static

Definition at line 33 of file api.c.

Referenced by test_AVISaveOptions().

◆ winetest1

const CHAR winetest1[] = "winetest1"
static

Definition at line 34 of file api.c.

Referenced by test_AVISaveOptions().