ReactOS 0.4.17-dev-934-g091855f
filesource.c File Reference
#include "dshow.h"
#include "wine/strmbase.h"
#include "wine/test.h"
Include dependency graph for filesource.c:

Go to the source code of this file.

Classes

struct  request_thread_params
 
struct  testsink
 

Macros

#define COBJMACROS
 
#define check_interface(a, b, c)   check_interface_(__LINE__, a, b, c)
 

Functions

static IBaseFilter * create_file_source (void)
 
static BOOL compare_media_types (const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b)
 
static WCHAR * load_resource (const WCHAR *name)
 
static void load_file (IBaseFilter *filter, const WCHAR *filename)
 
static ULONG get_refcount (void *iface)
 
static void check_interface_ (unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
 
static void test_interfaces (void)
 
static HRESULT WINAPI outer_QueryInterface (IUnknown *iface, REFIID iid, void **out)
 
static ULONG WINAPI outer_AddRef (IUnknown *iface)
 
static ULONG WINAPI outer_Release (IUnknown *iface)
 
static void test_aggregation (void)
 
static void test_file_source_filter (void)
 
static void test_enum_pins (void)
 
static void test_find_pin (void)
 
static void test_pin_info (void)
 
static void test_unconnected_filter_state (void)
 
static void test_sync_read_aligned (IAsyncReader *reader, IMemAllocator *allocator)
 
static DWORD CALLBACK request_thread (void *arg)
 
static void test_request (IAsyncReader *reader, IMemAllocator *allocator)
 
static DWORD CALLBACK wait_thread (void *arg)
 
static void test_flush (IAsyncReader *reader, IMemAllocator *allocator)
 
static void test_async_reader (void)
 
static void test_enum_media_types (void)
 
static struct testsink * impl_sink_from_strmbase_filter (struct strmbase_filter *iface)
 
static struct strmbase_pin * testsink_get_pin (struct strmbase_filter *iface, unsigned int index)
 
static void testsink_destroy (struct strmbase_filter *iface)
 
static HRESULT testsink_get_media_type (struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
 
static HRESULT testsink_connect (struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
 
static void testsink_disconnect (struct strmbase_sink *iface)
 
static void testsink_init (struct testsink *filter)
 
static void test_connect_pin (void)
 
static void test_file_share_delete (void)
 
 START_TEST (filesource)
 

Variables

static const GUID test_iid = {0x33333333}
 
static LONG outer_ref = 1
 
static const IUnknownVtbl outer_vtbl
 
static IUnknown test_outer = {&outer_vtbl}
 
static const struct strmbase_filter_ops testsink_ops
 
static const struct strmbase_sink_ops testsink_pin_ops
 

Macro Definition Documentation

◆ check_interface

#define check_interface (   a,
  b,
  c 
)    check_interface_(__LINE__, a, b, c)

Definition at line 86 of file filesource.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file filesource.c.

Function Documentation

◆ check_interface_()

static void check_interface_ ( unsigned int  line,
void *  iface_ptr,
REFIID  iid,
BOOL  supported 
)
static

Definition at line 87 of file filesource.c.

88{
89 IUnknown *iface = iface_ptr;
91 IUnknown *unk;
92
93 expected_hr = supported ? S_OK : E_NOINTERFACE;
94
95 hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
96 ok_(__FILE__, line)(hr == expected_hr, "Got hr %#lx, expected %#lx.\n", hr, expected_hr);
97 if (SUCCEEDED(hr))
98 IUnknown_Release(unk);
99}
#define ok_(x1, x2)
Definition: atltest.h:61
HRESULT expected_hr
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
Definition: parser.c:49
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ compare_media_types()

static BOOL compare_media_types ( const AM_MEDIA_TYPE *  a,
const AM_MEDIA_TYPE *  b 
)
static

Definition at line 36 of file filesource.c.

37{
38 return !memcmp(a, b, offsetof(AM_MEDIA_TYPE, pbFormat))
39 && !memcmp(a->pbFormat, b->pbFormat, a->cbFormat);
40}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define offsetof(TYPE, MEMBER)

Referenced by test_connect_pin().

◆ create_file_source()

static IBaseFilter * create_file_source ( void  )
static

Definition at line 27 of file filesource.c.

28{
30 HRESULT hr = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER,
31 &IID_IBaseFilter, (void **)&filter);
32 ok(hr == S_OK, "Got hr %#lx.\n", hr);
33 return filter;
34}
#define ok(value,...)
Definition: atltest.h:57
const GUID IID_IBaseFilter
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
Definition: filter.c:165

Referenced by test_async_reader(), test_connect_pin(), test_enum_media_types(), test_enum_pins(), test_file_share_delete(), test_file_source_filter(), test_find_pin(), test_interfaces(), test_pin_info(), and test_unconnected_filter_state().

◆ get_refcount()

static ULONG get_refcount ( void *  iface)
static

Definition at line 79 of file filesource.c.

80{
81 IUnknown *unknown = iface;
82 IUnknown_AddRef(unknown);
83 return IUnknown_Release(unknown);
84}
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674

Referenced by test_aggregation(), test_enum_pins(), test_find_pin(), and test_pin_info().

◆ impl_sink_from_strmbase_filter()

static struct testsink * impl_sink_from_strmbase_filter ( struct strmbase_filter *  iface)
inlinestatic

Definition at line 1217 of file filesource.c.

1218{
1219 return CONTAINING_RECORD(iface, struct testsink, filter);
1220}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by testsink_connect(), testsink_destroy(), testsink_disconnect(), testsink_get_media_type(), and testsink_get_pin().

◆ load_file()

static void load_file ( IBaseFilter *  filter,
const WCHAR *  filename 
)
static

Definition at line 67 of file filesource.c.

68{
69 IFileSourceFilter *filesource;
70 HRESULT hr;
71
72 hr = IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
73 ok(hr == S_OK, "Got hr %#lx.\n", hr);
74 hr = IFileSourceFilter_Load(filesource, filename, NULL);
75 ok(hr == S_OK, "Got hr %#lx.\n", hr);
76 IFileSourceFilter_Release(filesource);
77}
const char * filename
Definition: ioapi.h:137

Referenced by test_connect_pin(), test_enum_media_types(), test_enum_pins(), test_file_share_delete(), test_find_pin(), test_interfaces(), and test_pin_info().

◆ load_resource()

static WCHAR * load_resource ( const WCHAR *  name)
static

Definition at line 42 of file filesource.c.

43{
44 static WCHAR pathW[MAX_PATH];
45 DWORD written;
47 HRSRC res;
48 void *ptr;
49
52
54 ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %lu.\n",
56
58 ok(!!res, "Failed to load resource, error %lu.\n", GetLastError());
61 ok(written == SizeofResource(GetModuleHandleA(NULL), res), "Failed to write resource.\n");
63
64 return pathW;
65}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
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
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2098
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
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CREATE_ALWAYS
Definition: disk.h:72
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR pathW[]
Definition: path.c:2368
#define GENERIC_WRITE
Definition: nt_native.h:90
short WCHAR
Definition: pedump.c:58
#define RT_RCDATA
Definition: pedump.c:372
wcscat
Definition: fci.c:123
Definition: name.c:39
const uint16_t * LPCWSTR
Definition: typedefs.h:57
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ outer_AddRef()

static ULONG WINAPI outer_AddRef ( IUnknown *  iface)
static

Definition at line 155 of file filesource.c.

156{
158}
#define InterlockedIncrement
Definition: armddk.h:53
static LONG outer_ref
Definition: filesource.c:140

◆ outer_QueryInterface()

static HRESULT WINAPI outer_QueryInterface ( IUnknown *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 142 of file filesource.c.

143{
144 if (IsEqualGUID(iid, &IID_IUnknown)
146 || IsEqualGUID(iid, &test_iid))
147 {
148 *out = (IUnknown *)0xdeadbeef;
149 return S_OK;
150 }
151 ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
152 return E_NOINTERFACE;
153}
const GUID IID_IUnknown
static const GUID test_iid
Definition: filesource.c:139
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ outer_Release()

static ULONG WINAPI outer_Release ( IUnknown *  iface)
static

Definition at line 160 of file filesource.c.

161{
163}
#define InterlockedDecrement
Definition: armddk.h:52

◆ request_thread()

static DWORD CALLBACK request_thread ( void *  arg)
static

Definition at line 813 of file filesource.c.

814{
816 HRESULT hr = IAsyncReader_Request(params->reader, params->sample, 123);
817 ok(hr == S_OK, "Got hr %#lx.\n", hr);
818 return 0;
819}
GLenum const GLfloat * params
Definition: glext.h:5645
void * arg
Definition: msvc.h:10

Referenced by test_request().

◆ START_TEST()

START_TEST ( filesource  )

Definition at line 1497 of file filesource.c.

1498{
1500
1504 test_find_pin();
1505 test_pin_info();
1512
1514}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static void test_async_reader(void)
Definition: filesource.c:1009
static void test_aggregation(void)
Definition: filesource.c:174
static void test_pin_info(void)
Definition: filesource.c:648
static void test_find_pin(void)
Definition: filesource.c:610
static void test_enum_media_types(void)
Definition: filesource.c:1102
static void test_interfaces(void)
Definition: filesource.c:101
static void test_connect_pin(void)
Definition: filesource.c:1285
static void test_enum_pins(void)
Definition: filesource.c:500
static void test_file_share_delete(void)
Definition: filesource.c:1479
static void test_unconnected_filter_state(void)
Definition: filesource.c:696
static void test_file_source_filter(void)
Definition: filesource.c:233

◆ test_aggregation()

static void test_aggregation ( void  )
static

Definition at line 174 of file filesource.c.

175{
176 IBaseFilter *filter, *filter2;
177 IUnknown *unk, *unk2;
178 HRESULT hr;
179 ULONG ref;
180
181 filter = (IBaseFilter *)0xdeadbeef;
182 hr = CoCreateInstance(&CLSID_AsyncReader, &test_outer, CLSCTX_INPROC_SERVER,
183 &IID_IBaseFilter, (void **)&filter);
184 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
185 ok(!filter, "Got interface %p.\n", filter);
186
187 hr = CoCreateInstance(&CLSID_AsyncReader, &test_outer, CLSCTX_INPROC_SERVER,
188 &IID_IUnknown, (void **)&unk);
189 ok(hr == S_OK, "Got hr %#lx.\n", hr);
190 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
191 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
192 ref = get_refcount(unk);
193 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
194
195 ref = IUnknown_AddRef(unk);
196 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
197 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
198
199 ref = IUnknown_Release(unk);
200 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
201 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
202
203 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
204 ok(hr == S_OK, "Got hr %#lx.\n", hr);
205 ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
206 IUnknown_Release(unk2);
207
208 hr = IUnknown_QueryInterface(unk, &IID_IBaseFilter, (void **)&filter);
209 ok(hr == S_OK, "Got hr %#lx.\n", hr);
210
211 hr = IBaseFilter_QueryInterface(filter, &IID_IUnknown, (void **)&unk2);
212 ok(hr == S_OK, "Got hr %#lx.\n", hr);
213 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
214
215 hr = IBaseFilter_QueryInterface(filter, &IID_IBaseFilter, (void **)&filter2);
216 ok(hr == S_OK, "Got hr %#lx.\n", hr);
217 ok(filter2 == (IBaseFilter *)0xdeadbeef, "Got unexpected IBaseFilter %p.\n", filter2);
218
219 hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
220 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
221 ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
222
223 hr = IBaseFilter_QueryInterface(filter, &test_iid, (void **)&unk2);
224 ok(hr == S_OK, "Got hr %#lx.\n", hr);
225 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
226
227 IBaseFilter_Release(filter);
228 ref = IUnknown_Release(unk);
229 ok(!ref, "Got unexpected refcount %ld.\n", ref);
230 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
231}
static ULONG get_refcount(void *iface)
Definition: filesource.c:79
static IUnknown test_outer
Definition: filesource.c:172
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_async_reader()

static void test_async_reader ( void  )
static

Definition at line 1009 of file filesource.c.

1010{
1011 ALLOCATOR_PROPERTIES req_props = {100, 1024, 512, 0}, ret_props;
1013 IFileSourceFilter *filesource;
1018 BYTE buffer[20];
1019 DWORD written;
1020 HANDLE file;
1021 HRESULT hr;
1022 ULONG ref;
1023 IPin *pin;
1024 BOOL ret;
1025 int i;
1026
1028 wcscat(filename, L"test.avi");
1030 ok(file != INVALID_HANDLE_VALUE, "Failed to create file, error %lu.\n", GetLastError());
1031 for (i = 0; i < 600; i++)
1032 {
1033 BYTE b = i % 111;
1034 WriteFile(file, &b, 1, &written, NULL);
1035 }
1037
1038 IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
1039 IFileSourceFilter_Load(filesource, filename, NULL);
1040 IBaseFilter_FindPin(filter, L"Output", &pin);
1041
1042 hr = IPin_QueryInterface(pin, &IID_IAsyncReader, (void **)&reader);
1043 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1044
1045 hr = IAsyncReader_Length(reader, &length, &available);
1046 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1047 ok(length == 600, "Got length %s.\n", wine_dbgstr_longlong(length));
1048 ok(available == 600, "Got available length %s.\n", wine_dbgstr_longlong(available));
1049
1050 memset(buffer, 0xcc, sizeof(buffer));
1051 hr = IAsyncReader_SyncRead(reader, 0, 10, buffer);
1052 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1053 for (i = 0; i < 10; i++)
1054 ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
1055
1056 hr = IAsyncReader_SyncRead(reader, 0, 10, buffer);
1057 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1058 for (i = 0; i < 10; i++)
1059 ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
1060
1061 hr = IAsyncReader_SyncRead(reader, 10, 10, buffer);
1062 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1063 for (i = 0; i < 10; i++)
1064 ok(buffer[i] == (10 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
1065
1066 hr = IAsyncReader_SyncRead(reader, 590, 20, buffer);
1067 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1068 for (i = 0; i < 10; i++)
1069 ok(buffer[i] == (590 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
1070 for (; i < 20; i++)
1071 ok(buffer[i] == 0xcc, "Got wrong byte %02x at %u.\n", buffer[i], i);
1072
1073 memset(buffer, 0xcc, sizeof(buffer));
1074 hr = IAsyncReader_SyncRead(reader, 600, 10, buffer);
1075 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1076 ok(buffer[0] == 0xcc, "Got wrong byte %02x.\n", buffer[0]);
1077
1078 ret_props = req_props;
1079 hr = IAsyncReader_RequestAllocator(reader, NULL, &ret_props, &allocator);
1080 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1081 ok(ret_props.cBuffers == 100, "Got %ld buffers.\n", ret_props.cBuffers);
1082 ok(ret_props.cbBuffer == 1024, "Got size %ld.\n", ret_props.cbBuffer);
1083 ok(ret_props.cbAlign == 512, "Got alignment %ld.\n", ret_props.cbAlign);
1084 ok(ret_props.cbPrefix == 0, "Got prefix %ld.\n", ret_props.cbPrefix);
1085
1086 IMemAllocator_Commit(allocator);
1087
1091
1092 IMemAllocator_Release(allocator);
1093 IAsyncReader_Release(reader);
1094 IPin_Release(pin);
1095 IFileSourceFilter_Release(filesource);
1096 ref = IBaseFilter_Release(filter);
1097 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1099 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
1100}
const GUID IID_IAsyncReader
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2402
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
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
Definition: axcore.idl:92
static void test_sync_read_aligned(IAsyncReader *reader, IMemAllocator *allocator)
Definition: filesource.c:753
static IBaseFilter * create_file_source(void)
Definition: filesource.c:27
static void test_flush(void)
Definition: writer.c:676
#define memset(x, y, z)
Definition: compat.h:39
Definition: reader.h:84
int64_t LONGLONG
Definition: typedefs.h:68
#define S_FALSE
Definition: winerror.h:3451
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_connect_pin()

static void test_connect_pin ( void  )
static

Definition at line 1285 of file filesource.c.

1286{
1287 AM_MEDIA_TYPE req_mt =
1288 {
1289 .majortype = MEDIATYPE_Stream,
1290 .subtype = MEDIASUBTYPE_Avi,
1291 .formattype = FORMAT_None,
1292 .lSampleSize = 888,
1293 };
1294 const WCHAR *filename = load_resource(L"test.avi");
1296 AM_MEDIA_TYPE mt, *source_mt;
1297 struct testsink testsink;
1298 IEnumMediaTypes *enummt;
1299 IMediaControl *control;
1301 IPin *source, *peer;
1302 BYTE my_format = 1;
1303 HRESULT hr;
1304 ULONG ref;
1305 BOOL ret;
1306
1308 CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
1309 &IID_IFilterGraph2, (void **)&graph);
1310 IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink");
1311 IFilterGraph2_AddFilter(graph, filter, L"file source");
1312 IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
1314 IBaseFilter_FindPin(filter, L"Output", &source);
1315
1316 IPin_EnumMediaTypes(source, &enummt);
1317 IEnumMediaTypes_Next(enummt, 1, &source_mt, NULL);
1318 IEnumMediaTypes_Release(enummt);
1319
1320 peer = (IPin *)0xdeadbeef;
1321 hr = IPin_ConnectedTo(source, &peer);
1322 ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#lx.\n", hr);
1323 ok(!peer, "Got peer %p.\n", peer);
1324
1325 hr = IPin_ConnectionMediaType(source, &mt);
1326 ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#lx.\n", hr);
1327
1328 /* Test exact connection. */
1329
1330 hr = IMediaControl_Pause(control);
1331 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1332 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1333 ok(hr == VFW_E_NOT_STOPPED, "Got hr %#lx.\n", hr);
1334 hr = IMediaControl_Stop(control);
1335 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1336
1337 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1338 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1339
1340 hr = IPin_ConnectedTo(source, &peer);
1341 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1342 ok(peer == &testsink.pin.pin.IPin_iface, "Got peer %p.\n", peer);
1343 IPin_Release(peer);
1344
1345 hr = IPin_ConnectionMediaType(source, &mt);
1346 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1347 ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n");
1348 ok(compare_media_types(&testsink.pin.pin.mt, &req_mt), "Media types didn't match.\n");
1349
1350 hr = IMediaControl_Pause(control);
1351 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1352 hr = IFilterGraph2_Disconnect(graph, source);
1353 ok(hr == VFW_E_NOT_STOPPED, "Got hr %#lx.\n", hr);
1354 hr = IMediaControl_Stop(control);
1355 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1356
1357 hr = IFilterGraph2_Disconnect(graph, source);
1358 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1359 hr = IFilterGraph2_Disconnect(graph, source);
1360 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1361 ok(testsink.pin.pin.peer == source, "Got peer %p.\n", testsink.pin.pin.peer);
1362 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1363
1364 req_mt.pbFormat = &my_format;
1365 req_mt.cbFormat = sizeof(my_format);
1366 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1367 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1368 ok(compare_media_types(&testsink.pin.pin.mt, &req_mt), "Media types didn't match.\n");
1369 IFilterGraph2_Disconnect(graph, source);
1370 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1371 req_mt.pbFormat = NULL;
1372 req_mt.cbFormat = 0;
1373
1374 req_mt.majortype = MEDIATYPE_Video;
1375 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1376 ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr);
1377 req_mt.majortype = MEDIATYPE_Stream;
1378
1379 req_mt.subtype = MEDIASUBTYPE_RGB8;
1380 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1381 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1382 ok(compare_media_types(&testsink.pin.pin.mt, &req_mt), "Media types didn't match.\n");
1383 IFilterGraph2_Disconnect(graph, source);
1384 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1385 req_mt.subtype = GUID_NULL;
1386 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1387 ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr);
1388 req_mt.subtype = MEDIASUBTYPE_Avi;
1389
1390 /* Test connection with wildcards. */
1391
1392 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, NULL);
1393 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1394 ok(compare_media_types(&testsink.pin.pin.mt, source_mt), "Media types didn't match.\n");
1395 IFilterGraph2_Disconnect(graph, source);
1396 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1397
1398 req_mt.formattype = GUID_NULL;
1399 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1400 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1401 ok(compare_media_types(&testsink.pin.pin.mt, source_mt), "Media types didn't match.\n");
1402 IFilterGraph2_Disconnect(graph, source);
1403 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1404
1405 req_mt.formattype = FORMAT_None;
1406 req_mt.majortype = GUID_NULL;
1407 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1408 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1409
1410 req_mt.formattype = GUID_NULL;
1411 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1412 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1413 ok(compare_media_types(&testsink.pin.pin.mt, source_mt), "Media types didn't match.\n");
1414 IFilterGraph2_Disconnect(graph, source);
1415 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1416
1417 req_mt.subtype = MEDIASUBTYPE_RGB8;
1418 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1419 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1420
1421 req_mt.subtype = GUID_NULL;
1422 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1423 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1424 ok(compare_media_types(&testsink.pin.pin.mt, source_mt), "Media types didn't match.\n");
1425 IFilterGraph2_Disconnect(graph, source);
1426 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1427
1428 req_mt.majortype = MEDIATYPE_Stream;
1429 req_mt.subtype = MEDIASUBTYPE_RGB8;
1430 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1431 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1432
1433 req_mt.subtype = GUID_NULL;
1434 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1435 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1436 ok(compare_media_types(&testsink.pin.pin.mt, source_mt), "Media types didn't match.\n");
1437 IFilterGraph2_Disconnect(graph, source);
1438 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1439
1440 req_mt.majortype = MEDIATYPE_Video;
1441 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, &req_mt);
1442 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1443
1444 /* The second type (i.e. whose subtype is GUID_NULL) is not tried. This is
1445 * consistent with its being rejected by IPin::QueryAccept(). */
1447 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, NULL);
1448 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1449
1450 /* But any types we expose are tried. */
1451 testsink.mt = &mt;
1452 memset(&mt, 0, sizeof(mt));
1453 mt.majortype = MEDIATYPE_Video;
1454 mt.subtype = MEDIASUBTYPE_RGB8;
1455 mt.formattype = FORMAT_None;
1456 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, NULL);
1457 ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#lx.\n", hr);
1458
1459 mt.majortype = MEDIATYPE_Stream;
1460 hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.pin.pin.IPin_iface, NULL);
1461 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1462 ok(compare_media_types(&testsink.pin.pin.mt, &mt), "Media types didn't match.\n");
1463 IFilterGraph2_Disconnect(graph, source);
1464 IFilterGraph2_Disconnect(graph, &testsink.pin.pin.IPin_iface);
1465
1466 CoTaskMemFree(source_mt);
1467 IPin_Release(source);
1468 IMediaControl_Release(control);
1469 ref = IFilterGraph2_Release(graph);
1470 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1471 ref = IBaseFilter_Release(filter);
1472 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1473 ref = IBaseFilter_Release(&testsink.filter.IBaseFilter_iface);
1474 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1476 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
1477}
#define TRUE
Definition: types.h:120
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define GUID_NULL
Definition: ks.h:106
#define load_resource(a, b, c)
Definition: font.c:46
static void testsink_init(struct testsink *filter)
Definition: filesource.c:1277
static BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b)
Definition: filesource.c:36
static void load_file(IBaseFilter *filter, const WCHAR *filename)
Definition: filesource.c:67
Definition: dialog.c:52
Definition: graph.c:32
struct strmbase_sink pin
Definition: filesource.c:1211
BOOL reject_avi
Definition: filesource.c:1213
struct strmbase_filter filter
Definition: filesource.c:1210
const AM_MEDIA_TYPE * mt
Definition: filesource.c:1214
#define VFW_E_TYPE_NOT_ACCEPTED
Definition: vfwmsgs.h:81
#define VFW_E_NOT_STOPPED
Definition: vfwmsgs.h:75
#define VFW_E_NO_ACCEPTABLE_TYPES
Definition: vfwmsgs.h:46
#define VFW_E_NOT_CONNECTED
Definition: vfwmsgs.h:48

Referenced by START_TEST().

◆ test_enum_media_types()

static void test_enum_media_types ( void  )
static

Definition at line 1102 of file filesource.c.

1103{
1104 const WCHAR *filename = load_resource(L"test.avi");
1106 IEnumMediaTypes *enum1, *enum2;
1107 AM_MEDIA_TYPE *mts[3];
1108 ULONG ref, count;
1109 HRESULT hr;
1110 IPin *pin;
1111 BOOL ret;
1112
1114
1115 IBaseFilter_FindPin(filter, L"Output", &pin);
1116
1117 hr = IPin_EnumMediaTypes(pin, &enum1);
1118 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1119
1120 hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
1121 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1122 CoTaskMemFree(mts[0]);
1123
1124 hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
1125 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1126 CoTaskMemFree(mts[0]);
1127
1128 hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
1129 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1130
1131 hr = IEnumMediaTypes_Reset(enum1);
1132 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1133
1134 hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
1135 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1136 ok(count == 1, "Got count %lu.\n", count);
1137 CoTaskMemFree(mts[0]);
1138
1139 hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
1140 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1141 ok(count == 1, "Got count %lu.\n", count);
1142 CoTaskMemFree(mts[0]);
1143
1144 hr = IEnumMediaTypes_Next(enum1, 1, mts, &count);
1145 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1146 ok(!count, "Got count %lu.\n", count);
1147
1148 hr = IEnumMediaTypes_Reset(enum1);
1149 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1150
1151 hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
1152 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1153 ok(count == 2, "Got count %lu.\n", count);
1154 CoTaskMemFree(mts[0]);
1155 CoTaskMemFree(mts[1]);
1156
1157 hr = IEnumMediaTypes_Next(enum1, 2, mts, &count);
1158 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1159 ok(!count, "Got count %lu.\n", count);
1160
1161 hr = IEnumMediaTypes_Reset(enum1);
1162 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1163
1164 hr = IEnumMediaTypes_Next(enum1, 3, mts, &count);
1165 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1166 ok(count == 2, "Got count %lu.\n", count);
1167 CoTaskMemFree(mts[0]);
1168 CoTaskMemFree(mts[1]);
1169
1170 hr = IEnumMediaTypes_Reset(enum1);
1171 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1172
1173 hr = IEnumMediaTypes_Clone(enum1, &enum2);
1174 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1175
1176 hr = IEnumMediaTypes_Skip(enum1, 3);
1177 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1178
1179 hr = IEnumMediaTypes_Skip(enum1, 1);
1180 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1181
1182 hr = IEnumMediaTypes_Reset(enum1);
1183 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1184
1185 hr = IEnumMediaTypes_Skip(enum1, 2);
1186 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1187
1188 hr = IEnumMediaTypes_Skip(enum1, 1);
1189 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1190
1191 hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL);
1192 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
1193
1194 hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL);
1195 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1196 CoTaskMemFree(mts[0]);
1197
1198 IEnumMediaTypes_Release(enum1);
1199 IEnumMediaTypes_Release(enum2);
1200 IPin_Release(pin);
1201
1202 ref = IBaseFilter_Release(filter);
1203 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1205 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
1206}
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by START_TEST().

◆ test_enum_pins()

static void test_enum_pins ( void  )
static

Definition at line 500 of file filesource.c.

501{
502 const WCHAR *filename = load_resource(L"test.avi");
504 IEnumPins *enum1, *enum2;
505 IPin *pins[2];
506 ULONG count;
507 HRESULT hr;
508 ULONG ref;
509 BOOL ret;
510
512 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
513
514 hr = IBaseFilter_EnumPins(filter, NULL);
515 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
516
517 hr = IBaseFilter_EnumPins(filter, &enum1);
518 ok(hr == S_OK, "Got hr %#lx.\n", hr);
519
521 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
522 ref = get_refcount(enum1);
523 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
524
525 hr = IEnumPins_Next(enum1, 1, NULL, NULL);
526 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
527
528 hr = IEnumPins_Next(enum1, 1, pins, NULL);
529 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
530
531 hr = IEnumPins_Skip(enum1, 1);
532 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
533
535
536 hr = IEnumPins_Next(enum1, 1, pins, NULL);
537 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
538
539 hr = IEnumPins_Reset(enum1);
540 ok(hr == S_OK, "Got hr %#lx.\n", hr);
541
542 hr = IEnumPins_Next(enum1, 1, pins, NULL);
543 ok(hr == S_OK, "Got hr %#lx.\n", hr);
545 ok(ref == 3, "Got unexpected refcount %ld.\n", ref);
546 ref = get_refcount(pins[0]);
547 ok(ref == 3, "Got unexpected refcount %ld.\n", ref);
548 ref = get_refcount(enum1);
549 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
550 IPin_Release(pins[0]);
552 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
553
554 hr = IEnumPins_Next(enum1, 1, pins, NULL);
555 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
556
557 hr = IEnumPins_Reset(enum1);
558 ok(hr == S_OK, "Got hr %#lx.\n", hr);
559
560 hr = IEnumPins_Next(enum1, 1, pins, &count);
561 ok(hr == S_OK, "Got hr %#lx.\n", hr);
562 ok(count == 1, "Got count %lu.\n", count);
563 IPin_Release(pins[0]);
564
565 hr = IEnumPins_Next(enum1, 1, pins, &count);
566 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
567 ok(!count, "Got count %lu.\n", count);
568
569 hr = IEnumPins_Reset(enum1);
570 ok(hr == S_OK, "Got hr %#lx.\n", hr);
571
572 hr = IEnumPins_Next(enum1, 2, pins, NULL);
573 ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
574
575 hr = IEnumPins_Next(enum1, 2, pins, &count);
576 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
577 ok(count == 1, "Got count %lu.\n", count);
578 IPin_Release(pins[0]);
579
580 hr = IEnumPins_Reset(enum1);
581 ok(hr == S_OK, "Got hr %#lx.\n", hr);
582
583 hr = IEnumPins_Clone(enum1, &enum2);
584 ok(hr == S_OK, "Got hr %#lx.\n", hr);
585
586 hr = IEnumPins_Skip(enum1, 2);
587 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
588
589 hr = IEnumPins_Skip(enum1, 1);
590 ok(hr == S_OK, "Got hr %#lx.\n", hr);
591
592 hr = IEnumPins_Skip(enum1, 1);
593 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
594
595 hr = IEnumPins_Next(enum1, 1, pins, NULL);
596 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
597
598 hr = IEnumPins_Next(enum2, 1, pins, NULL);
599 ok(hr == S_OK, "Got hr %#lx.\n", hr);
600 IPin_Release(pins[0]);
601
602 IEnumPins_Release(enum2);
603 IEnumPins_Release(enum1);
604 ref = IBaseFilter_Release(filter);
605 ok(!ref, "Got outstanding refcount %ld.\n", ref);
607 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
608}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_POINTER
Definition: winerror.h:3480

Referenced by START_TEST().

◆ test_file_share_delete()

static void test_file_share_delete ( void  )
static

Definition at line 1479 of file filesource.c.

1480{
1481 const WCHAR *filename = load_resource(L"test.avi");
1483 ULONG ref;
1484 BOOL ret;
1485
1487
1488 /* Test that we can delete the file while it's open. */
1490 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
1491
1492 ref = IBaseFilter_Release(filter);
1493 ok(!ref, "Got outstanding refcount %ld.\n", ref);
1494}

Referenced by START_TEST().

◆ test_file_source_filter()

static void test_file_source_filter ( void  )
static

Definition at line 233 of file filesource.c.

234{
235 static const struct
236 {
237 const char *label;
238 const char *data;
239 DWORD size;
240 const GUID *subtype;
241 }
242 tests[] =
243 {
244 {
245 "AVI",
246 "\x52\x49\x46\x46xxxx\x41\x56\x49\x20",
247 12,
248 &MEDIASUBTYPE_Avi,
249 },
250 {
251 "MPEG1 System",
252 "\x00\x00\x01\xBA\x21\x00\x01\x00\x01\x80\x00\x01\x00\x00\x01\xBB",
253 16,
254 &MEDIASUBTYPE_MPEG1System,
255 },
256 {
257 "MPEG1 Video",
258 "\x00\x00\x01\xB3",
259 4,
260 &MEDIASUBTYPE_MPEG1Video,
261 },
262 {
263 "MPEG1 Audio",
264 "\xFF\xE0",
265 2,
266 &MEDIASUBTYPE_MPEG1Audio,
267 },
268 {
269 "MPEG2 Program",
270 "\x00\x00\x01\xBA\x40",
271 5,
272 &MEDIASUBTYPE_MPEG2_PROGRAM,
273 },
274 {
275 "WAVE",
276 "\x52\x49\x46\x46xxxx\x57\x41\x56\x45",
277 12,
278 &MEDIASUBTYPE_WAVE,
279 },
280 {
281 "unknown format",
282 "Hello World",
283 11,
285 },
286 };
288 AM_MEDIA_TYPE mt, file_mt, *pmt;
289 IFileSourceFilter *filesource;
290 IEnumMediaTypes *enum_mt;
292 OLECHAR *olepath;
293 DWORD written;
294 HANDLE file;
295 HRESULT hr;
296 ULONG ref;
297 IPin *pin;
298 BOOL ret;
299 int i;
300
302 GetTempFileNameW(temp, L"win", 0, path);
303
304 for (i = 0; i < ARRAY_SIZE(tests); i++)
305 {
306 trace("Running test for %s.\n", tests[i].label);
307
309 ok(file != INVALID_HANDLE_VALUE, "Failed to create file, error %lu.\n", GetLastError());
310 ret = WriteFile(file, tests[i].data, tests[i].size, &written, NULL);
311 ok(ret, "Failed to write file, error %lu.\n", GetLastError());
313
315 IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
316
317 olepath = (void *)0xdeadbeef;
318 hr = IFileSourceFilter_GetCurFile(filesource, &olepath, NULL);
319 ok(hr == S_OK, "Got hr %#lx.\n", hr);
320 ok(!olepath, "Got path %s.\n", wine_dbgstr_w(olepath));
321
322 hr = IFileSourceFilter_Load(filesource, NULL, NULL);
323 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
324
325 hr = IFileSourceFilter_Load(filesource, path, NULL);
326 ok(hr == S_OK, "Got hr %#lx.\n", hr);
327
328 hr = IFileSourceFilter_GetCurFile(filesource, NULL, &mt);
329 ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
330
331 olepath = NULL;
332 hr = IFileSourceFilter_GetCurFile(filesource, &olepath, NULL);
333 ok(hr == S_OK, "Got hr %#lx.\n", hr);
334 CoTaskMemFree(olepath);
335
336 olepath = NULL;
337 memset(&file_mt, 0x11, sizeof(file_mt));
338 hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &file_mt);
339 ok(hr == S_OK, "Got hr %#lx.\n", hr);
340 ok(!wcscmp(olepath, path), "Expected path %s, got %s.\n",
341 wine_dbgstr_w(path), wine_dbgstr_w(olepath));
342 ok(IsEqualGUID(&file_mt.majortype, &MEDIATYPE_Stream), "Got major type %s.\n",
343 wine_dbgstr_guid(&file_mt.majortype));
344 /* winegstreamer hijacks format type detection. */
346 ok(IsEqualGUID(&file_mt.subtype, tests[i].subtype), "Expected subtype %s, got %s.\n",
347 wine_dbgstr_guid(tests[i].subtype), wine_dbgstr_guid(&file_mt.subtype));
348 ok(file_mt.bFixedSizeSamples == TRUE, "Got fixed size %d.\n", file_mt.bFixedSizeSamples);
349 ok(file_mt.bTemporalCompression == FALSE, "Got temporal compression %d.\n",
350 file_mt.bTemporalCompression);
351 ok(file_mt.lSampleSize == 1, "Got sample size %lu.\n", file_mt.lSampleSize);
352 ok(IsEqualGUID(&file_mt.formattype, &GUID_NULL), "Got format type %s.\n",
353 wine_dbgstr_guid(&file_mt.formattype));
354 ok(!file_mt.pUnk, "Got pUnk %p.\n", file_mt.pUnk);
355 ok(!file_mt.cbFormat, "Got format size %#lx.\n", file_mt.cbFormat);
356 ok(!file_mt.pbFormat, "Got format %p.\n", file_mt.pbFormat);
357 CoTaskMemFree(olepath);
358
359 hr = IBaseFilter_FindPin(filter, L"Output", &pin);
360 ok(hr == S_OK, "Got hr %#lx.\n", hr);
361
362 hr = IPin_EnumMediaTypes(pin, &enum_mt);
363 ok(hr == S_OK, "Got hr %#lx.\n", hr);
364
365 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
366 ok(hr == S_OK, "Got hr %#lx.\n", hr);
367 ok(!memcmp(pmt, &file_mt, sizeof(*pmt)), "Media types did not match.\n");
368 CoTaskMemFree(pmt);
369
370 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
371 ok(hr == S_OK, "Got hr %#lx.\n", hr);
372 mt = file_mt;
373 mt.subtype = GUID_NULL;
374 ok(!memcmp(pmt, &mt, sizeof(*pmt)), "Media types did not match.\n");
375 CoTaskMemFree(pmt);
376
377 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
378 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
379
380 IEnumMediaTypes_Release(enum_mt);
381
382 mt = file_mt;
383 hr = IPin_QueryAccept(pin, &mt);
384 ok(hr == S_OK, "Got hr %#lx.\n", hr);
385
386 mt.bFixedSizeSamples = FALSE;
387 mt.bTemporalCompression = TRUE;
388 mt.lSampleSize = 123;
389 mt.formattype = FORMAT_VideoInfo;
390 mt.subtype = MEDIASUBTYPE_RGB32;
391 hr = IPin_QueryAccept(pin, &mt);
392 ok(hr == S_OK, "Got hr %#lx.\n", hr);
393
394 mt.majortype = MEDIATYPE_Video;
395 hr = IPin_QueryAccept(pin, &mt);
396 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
397 mt.majortype = MEDIATYPE_Stream;
398
400 {
401 mt.subtype = GUID_NULL;
402 hr = IPin_QueryAccept(pin, &mt);
403 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
404 }
405
406 IPin_Release(pin);
407 IFileSourceFilter_Release(filesource);
408 ref = IBaseFilter_Release(filter);
409 ok(!ref, "Got outstanding refcount %ld.\n", ref);
410
412 ok(ret, "Failed to delete file, error %lu\n", GetLastError());
413 }
414
415 /* test prescribed format */
417 hr = IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource);
418 ok(hr == S_OK, "Got hr %#lx.\n", hr);
419
420 mt.majortype = MEDIATYPE_Video;
421 mt.subtype = MEDIASUBTYPE_RGB8;
422 mt.bFixedSizeSamples = FALSE;
423 mt.bTemporalCompression = TRUE;
424 mt.lSampleSize = 123;
425 mt.formattype = FORMAT_None;
426 mt.pUnk = NULL;
427 mt.cbFormat = 0;
428 mt.pbFormat = NULL;
429 filename = load_resource(L"test.avi");
430 hr = IFileSourceFilter_Load(filesource, filename, &mt);
431 ok(hr == S_OK, "Got hr %#lx.\n", hr);
432
433 hr = IFileSourceFilter_GetCurFile(filesource, &olepath, &file_mt);
434 ok(hr == S_OK, "Got hr %#lx.\n", hr);
435 ok(!memcmp(&file_mt, &mt, sizeof(mt)), "Media types did not match.\n");
436 CoTaskMemFree(olepath);
437
438 hr = IBaseFilter_FindPin(filter, L"Output", &pin);
439 ok(hr == S_OK, "Got hr %#lx.\n", hr);
440
441 hr = IPin_EnumMediaTypes(pin, &enum_mt);
442 ok(hr == S_OK, "Got hr %#lx.\n", hr);
443
444 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
445 ok(hr == S_OK, "Got hr %#lx.\n", hr);
446 ok(!memcmp(pmt, &file_mt, sizeof(*pmt)), "Media types did not match.\n");
447 CoTaskMemFree(pmt);
448
449 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
450 ok(hr == S_OK, "Got hr %#lx.\n", hr);
451 ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Stream), "Got major type %s.\n",
452 wine_dbgstr_guid(&pmt->majortype));
453 ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s.\n",
454 wine_dbgstr_guid(&pmt->subtype));
455 ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples);
456 ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression);
457 ok(pmt->lSampleSize == 1, "Got sample size %lu.\n", pmt->lSampleSize);
458 ok(IsEqualGUID(&pmt->formattype, &GUID_NULL), "Got format type %s.\n",
459 wine_dbgstr_guid(&pmt->formattype));
460 ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk);
461 ok(!pmt->cbFormat, "Got format size %#lx.\n", pmt->cbFormat);
462 ok(!pmt->pbFormat, "Got format %p.\n", pmt->pbFormat);
463
464 hr = IPin_QueryAccept(pin, pmt);
465 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
466 CoTaskMemFree(pmt);
467
468 hr = IEnumMediaTypes_Next(enum_mt, 1, &pmt, NULL);
469 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
470
471 IEnumMediaTypes_Release(enum_mt);
472
473 hr = IPin_QueryAccept(pin, &mt);
474 ok(hr == S_OK, "Got hr %#lx.\n", hr);
475
476 mt.bFixedSizeSamples = TRUE;
477 mt.bTemporalCompression = FALSE;
478 mt.lSampleSize = 456;
479 mt.formattype = FORMAT_VideoInfo;
480 hr = IPin_QueryAccept(pin, &mt);
481 ok(hr == S_OK, "Got hr %#lx.\n", hr);
482
483 mt.majortype = MEDIATYPE_Stream;
484 hr = IPin_QueryAccept(pin, &mt);
485 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
486 mt.majortype = MEDIATYPE_Video;
487
488 mt.subtype = MEDIASUBTYPE_NULL;
489 hr = IPin_QueryAccept(pin, &mt);
490 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
491
492 IPin_Release(pin);
493 IFileSourceFilter_Release(filesource);
494 ref = IBaseFilter_Release(filter);
495 ok(!ref, "Got outstanding refcount %ld.\n", ref);
497 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
498}
#define trace
Definition: atltest.h:70
#define FALSE
Definition: types.h:117
WCHAR OLECHAR
Definition: compat.h:2292
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
static struct test_info tests[]
static const WCHAR label[]
Definition: itemdlg.c:1608
const GUID * subtype
Definition: mpegvideo.c:120
static calc_node_t temp
Definition: rpn_ieee.c:38
#define MEDIASUBTYPE_NULL
Definition: uuids.h:25

Referenced by START_TEST().

◆ test_find_pin()

static void test_find_pin ( void  )
static

Definition at line 610 of file filesource.c.

611{
612 const WCHAR *filename = load_resource(L"test.avi");
614 IEnumPins *enumpins;
615 IPin *pin, *pin2;
616 HRESULT hr;
617 ULONG ref;
618 BOOL ret;
619
620 hr = IBaseFilter_FindPin(filter, L"Output", &pin);
621 ok(hr == VFW_E_NOT_FOUND, "Got hr %#lx.\n", hr);
622
624
625 hr = IBaseFilter_FindPin(filter, L"Output", &pin);
626 ok(hr == S_OK, "Got hr %#lx.\n", hr);
628 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
629 ref = get_refcount(pin);
630 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
631
632 hr = IBaseFilter_EnumPins(filter, &enumpins);
633 ok(hr == S_OK, "Got hr %#lx.\n", hr);
634
635 hr = IEnumPins_Next(enumpins, 1, &pin2, NULL);
636 ok(hr == S_OK, "Got hr %#lx.\n", hr);
637 ok(pin == pin2, "Expected pin %p, got %p.\n", pin, pin2);
638
639 IPin_Release(pin2);
640 IPin_Release(pin);
641 IEnumPins_Release(enumpins);
642 ref = IBaseFilter_Release(filter);
643 ok(!ref, "Got outstanding refcount %ld.\n", ref);
645 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
646}
#define VFW_E_NOT_FOUND
Definition: vfwmsgs.h:61

Referenced by START_TEST().

◆ test_flush()

static void test_flush ( IAsyncReader *  reader,
IMemAllocator *  allocator 
)
static

Definition at line 937 of file filesource.c.

938{
939 REFERENCE_TIME start_time, end_time;
940 IMediaSample *sample, *ret_sample;
941 BYTE buffer[20], *data;
944 HRESULT hr;
945 int i;
946
947 IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
948 IMediaSample_GetPointer(sample, &data);
949
950 start_time = 0;
951 end_time = 512 * (LONGLONG)10000000;
952 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
953 ok(hr == S_OK, "Got hr %#lx.\n", hr);
954
955 hr = IAsyncReader_BeginFlush(reader);
956 ok(hr == S_OK, "Got hr %#lx.\n", hr);
957
958 hr = IAsyncReader_SyncRead(reader, 0, 20, buffer);
959 ok(hr == S_OK, "Got hr %#lx.\n", hr);
960 for (i = 0; i < 20; i++)
961 ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
962
963 start_time = 0;
964 end_time = 512 * (LONGLONG)10000000;
965 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
966 ok(hr == S_OK, "Got hr %#lx.\n", hr);
967
968 hr = IAsyncReader_SyncReadAligned(reader, sample);
969 ok(hr == S_OK, "Got hr %#lx.\n", hr);
970 for (i = 0; i < 512; i++)
971 ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i);
972
973 hr = IAsyncReader_Request(reader, sample, 456);
974 ok(hr == VFW_E_WRONG_STATE, "Got hr %#lx.\n", hr);
975
976 hr = IAsyncReader_EndFlush(reader);
977 ok(hr == S_OK, "Got hr %#lx.\n", hr);
978
979 hr = IAsyncReader_WaitForNext(reader, 0, &ret_sample, &cookie);
980 ok(hr == VFW_E_TIMEOUT, "Got hr %#lx.\n", hr);
981
982 start_time = 0;
983 end_time = 512 * (LONGLONG)10000000;
984 hr = IAsyncReader_Request(reader, sample, 123);
985 ok(hr == S_OK, "Got hr %#lx.\n", hr);
986
987 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
988 ok(hr == S_OK, "Got hr %#lx.\n", hr);
989 ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample);
990 ok(cookie == 123, "Got cookie %Iu.\n", cookie);
991
992 for (i = 0; i < 512; i++)
993 ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i);
994
996 ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Expected timeout.\n");
997
998 hr = IAsyncReader_BeginFlush(reader);
999 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1000 ok(!WaitForSingleObject(thread, 1000), "Wait timed out.\n");
1002
1003 hr = IAsyncReader_EndFlush(reader);
1004 ok(hr == S_OK, "Got hr %#lx.\n", hr);
1005
1006 IMediaSample_Release(sample);
1007}
static HANDLE thread
Definition: service.c:33
#define WAIT_TIMEOUT
Definition: dderror.h:14
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
static DWORD CALLBACK wait_thread(void *arg)
Definition: filesource.c:927
Definition: cookie.c:34
Definition: wave.c:25
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define VFW_E_TIMEOUT
Definition: vfwmsgs.h:85
#define VFW_E_WRONG_STATE
Definition: vfwmsgs.h:78

◆ test_interfaces()

static void test_interfaces ( void  )
static

Definition at line 101 of file filesource.c.

102{
103 const WCHAR *filename = load_resource(L"test.avi");
105 IPin *pin;
106
108 check_interface(filter, &IID_IFileSourceFilter, TRUE);
109
110 check_interface(filter, &IID_IAMFilterMiscFlags, FALSE);
111 check_interface(filter, &IID_IBasicAudio, FALSE);
112 check_interface(filter, &IID_IBasicVideo, FALSE);
114 check_interface(filter, &IID_IMediaPosition, FALSE);
115 check_interface(filter, &IID_IMediaSeeking, FALSE);
118 check_interface(filter, &IID_IQualityControl, FALSE);
119 check_interface(filter, &IID_IQualProp, FALSE);
120 check_interface(filter, &IID_IReferenceClock, FALSE);
121 check_interface(filter, &IID_IVideoWindow, FALSE);
122
124 IBaseFilter_FindPin(filter, L"Output", &pin);
125
128 todo_wine check_interface(pin, &IID_IQualityControl, TRUE);
130
132 check_interface(pin, &IID_IMediaPosition, FALSE);
133 check_interface(pin, &IID_IMediaSeeking, FALSE);
134
135 IPin_Release(pin);
136 IBaseFilter_Release(filter);
137}
const GUID IID_IKsPropertySet
Definition: controlnode.cpp:13
#define todo_wine
Definition: minitest.h:80
#define check_interface(a, b, c)
Definition: filesource.c:86
const GUID IID_IPin
Definition: pincontrol.cpp:15
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11

Referenced by START_TEST().

◆ test_pin_info()

static void test_pin_info ( void  )
static

Definition at line 648 of file filesource.c.

649{
650 const WCHAR *filename = load_resource(L"test.avi");
654 HRESULT hr;
655 WCHAR *id;
656 ULONG ref;
657 IPin *pin;
658 BOOL ret;
659
661
662 hr = IBaseFilter_FindPin(filter, L"Output", &pin);
663 ok(hr == S_OK, "Got hr %#lx.\n", hr);
665 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
666 ref = get_refcount(pin);
667 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
668
669 hr = IPin_QueryPinInfo(pin, &info);
670 ok(hr == S_OK, "Got hr %#lx.\n", hr);
671 ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter);
672 ok(info.dir == PINDIR_OUTPUT, "Got direction %d.\n", info.dir);
673 ok(!wcscmp(info.achName, L"Output"), "Got name %s.\n", wine_dbgstr_w(info.achName));
675 ok(ref == 3, "Got unexpected refcount %ld.\n", ref);
676 ref = get_refcount(pin);
677 ok(ref == 3, "Got unexpected refcount %ld.\n", ref);
678 IBaseFilter_Release(info.pFilter);
679
680 hr = IPin_QueryDirection(pin, &dir);
681 ok(hr == S_OK, "Got hr %#lx.\n", hr);
682 ok(dir == PINDIR_OUTPUT, "Got direction %d.\n", dir);
683
684 hr = IPin_QueryId(pin, &id);
685 ok(hr == S_OK, "Got hr %#lx.\n", hr);
686 ok(!wcscmp(id, L"Output"), "Got id %s.\n", wine_dbgstr_w(id));
687 CoTaskMemFree(id);
688
689 IPin_Release(pin);
690 ref = IBaseFilter_Release(filter);
691 ok(!ref, "Got outstanding refcount %ld.\n", ref);
693 ok(ret, "Failed to delete file, error %lu.\n", GetLastError());
694}
unsigned int dir
Definition: maze.c:112
enum _PinDirection PIN_DIRECTION
@ PINDIR_OUTPUT
Definition: axcore.idl:42
GLuint id
Definition: glext.h:5910

Referenced by START_TEST().

◆ test_request()

static void test_request ( IAsyncReader *  reader,
IMemAllocator *  allocator 
)
static

Definition at line 821 of file filesource.c.

822{
823 IMediaSample *sample, *sample2, *ret_sample;
825 REFERENCE_TIME start_time, end_time;
826 BYTE *data, *data2;
829 HRESULT hr;
830 LONG len;
831 int i;
832
833 IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
834 IMediaSample_GetPointer(sample, &data);
835 IMemAllocator_GetBuffer(allocator, &sample2, NULL, NULL, 0);
836 IMediaSample_GetPointer(sample2, &data2);
837
838 hr = IAsyncReader_WaitForNext(reader, 0, &ret_sample, &cookie);
839 ok(hr == VFW_E_TIMEOUT, "Got hr %#lx.\n", hr);
840
841 start_time = 0;
842 end_time = 512 * (LONGLONG)10000000;
843 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
844 ok(hr == S_OK, "Got hr %#lx.\n", hr);
845
846 hr = IAsyncReader_Request(reader, sample, 123);
847 ok(hr == S_OK, "Got hr %#lx.\n", hr);
848
849 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
850 ok(hr == S_OK, "Got hr %#lx.\n", hr);
851 ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample);
852 ok(cookie == 123, "Got cookie %Iu.\n", cookie);
853
854 len = IMediaSample_GetActualDataLength(sample);
855 ok(len == 512, "Got length %ld.\n", len);
856
857 for (i = 0; i < 512; i++)
858 ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i);
859
860 start_time = 1024 * (LONGLONG)10000000;
861 end_time = 1536 * (LONGLONG)10000000;
862 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
863 ok(hr == S_OK, "Got hr %#lx.\n", hr);
864
865 hr = IAsyncReader_Request(reader, sample, 123);
866 ok(hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF), "Got hr %#lx.\n", hr);
867
868 start_time = 0;
869 end_time = 512 * (LONGLONG)10000000;
870 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
871 ok(hr == S_OK, "Got hr %#lx.\n", hr);
872
873 hr = IAsyncReader_Request(reader, sample, 123);
874 ok(hr == S_OK, "Got hr %#lx.\n", hr);
875
876 start_time = 512 * (LONGLONG)10000000;
877 end_time = 1024 * (LONGLONG)10000000;
878 hr = IMediaSample_SetTime(sample2, &start_time, &end_time);
879 ok(hr == S_OK, "Got hr %#lx.\n", hr);
880
881 hr = IAsyncReader_Request(reader, sample2, 456);
882 ok(hr == S_OK, "Got hr %#lx.\n", hr);
883
884 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
885 ok(hr == S_OK, "Got hr %#lx.\n", hr);
886 if (cookie == 123)
887 {
888 ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample);
889
890 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
891 ok(hr == S_OK, "Got hr %#lx.\n", hr);
892 ok(ret_sample == sample2, "Expected sample %p, got %p.\n", sample2, ret_sample);
893 ok(cookie == 456, "Got cookie %Iu.\n", cookie);
894 }
895 else
896 {
897 ok(cookie == 456, "Got cookie %Iu.\n", cookie);
898 ok(ret_sample == sample2, "Expected sample %p, got %p.\n", sample2, ret_sample);
899
900 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
901 ok(hr == S_OK, "Got hr %#lx.\n", hr);
902 ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample);
903 ok(cookie == 123, "Got cookie %Iu.\n", cookie);
904 }
905
906 for (i = 0; i < 512; i++)
907 ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i);
908
909 for (i = 0; i < 88; i++)
910 ok(data2[i] == (512 + i) % 111, "Got wrong byte %02x at %u.\n", data2[i], i);
911
912 params.reader = reader;
913 params.sample = sample;
915 ok(!WaitForSingleObject(thread, 1000), "Wait timed out.\n");
917
918 hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie);
919 ok(hr == S_OK, "Got hr %#lx.\n", hr);
920 ok(ret_sample == sample, "Samples didn't match.\n");
921 ok(cookie == 123, "Got cookie %Iu.\n", cookie);
922
923 IMediaSample_Release(sample);
924 IMediaSample_Release(sample2);
925}
GLenum GLsizei len
Definition: glext.h:6722
static DWORD CALLBACK request_thread(void *arg)
Definition: filesource.c:813
long LONG
Definition: pedump.c:60
Definition: tftpd.h:138
IMediaSample * sample
Definition: filesource.c:810
IAsyncReader * reader
Definition: filesource.c:809
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_HANDLE_EOF
Definition: winerror.h:262

◆ test_sync_read_aligned()

static void test_sync_read_aligned ( IAsyncReader *  reader,
IMemAllocator *  allocator 
)
static

Definition at line 753 of file filesource.c.

754{
755 REFERENCE_TIME start_time, end_time;
757 HRESULT hr;
758 BYTE *data;
759 LONG len;
760 int i;
761
762 IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
763 IMediaSample_GetPointer(sample, &data);
764
765 start_time = 0;
766 end_time = 512 * (LONGLONG)10000000;
767 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
768 ok(hr == S_OK, "Got hr %#lx.\n", hr);
769
770 hr = IAsyncReader_SyncReadAligned(reader, sample);
771 ok(hr == S_OK, "Got hr %#lx.\n", hr);
772
773 len = IMediaSample_GetActualDataLength(sample);
774 ok(len == 512, "Got length %ld.\n", len);
775
776 for (i = 0; i < 512; i++)
777 ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i);
778
779 start_time = 512 * (LONGLONG)10000000;
780 end_time = 1024 * (LONGLONG)10000000;
781 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
782 ok(hr == S_OK, "Got hr %#lx.\n", hr);
783
784 hr = IAsyncReader_SyncReadAligned(reader, sample);
785 ok(hr == S_FALSE, "Got hr %#lx.\n", hr);
786
787 len = IMediaSample_GetActualDataLength(sample);
788 ok(len == 88, "Got length %ld.\n", len);
789
790 for (i = 0; i < 88; i++)
791 ok(data[i] == (512 + i) % 111, "Got wrong byte %02x at %u.\n", data[i], i);
792
793 start_time = 1024 * (LONGLONG)10000000;
794 end_time = 1536 * (LONGLONG)10000000;
795 hr = IMediaSample_SetTime(sample, &start_time, &end_time);
796 ok(hr == S_OK, "Got hr %#lx.\n", hr);
797
798 hr = IAsyncReader_SyncReadAligned(reader, sample);
799 ok(hr == S_OK, "Got hr %#lx.\n", hr);
800
801 len = IMediaSample_GetActualDataLength(sample);
802 ok(len == 0, "Got length %ld.\n", len);
803
804 IMediaSample_Release(sample);
805}

Referenced by test_async_reader().

◆ test_unconnected_filter_state()

static void test_unconnected_filter_state ( void  )
static

Definition at line 696 of file filesource.c.

697{
699 FILTER_STATE state;
700 HRESULT hr;
701 ULONG ref;
702
703 hr = IBaseFilter_GetState(filter, 0, &state);
704 ok(hr == S_OK, "Got hr %#lx.\n", hr);
705 ok(state == State_Stopped, "Got state %u.\n", state);
706
707 hr = IBaseFilter_Pause(filter);
708 ok(hr == S_OK, "Got hr %#lx.\n", hr);
709
710 hr = IBaseFilter_GetState(filter, 0, &state);
711 ok(hr == S_OK, "Got hr %#lx.\n", hr);
712 ok(state == State_Paused, "Got state %u.\n", state);
713
714 hr = IBaseFilter_Run(filter, 0);
715 ok(hr == S_OK, "Got hr %#lx.\n", hr);
716
717 hr = IBaseFilter_GetState(filter, 0, &state);
718 ok(hr == S_OK, "Got hr %#lx.\n", hr);
719 ok(state == State_Running, "Got state %u.\n", state);
720
721 hr = IBaseFilter_Pause(filter);
722 ok(hr == S_OK, "Got hr %#lx.\n", hr);
723
724 hr = IBaseFilter_GetState(filter, 0, &state);
725 ok(hr == S_OK, "Got hr %#lx.\n", hr);
726 ok(state == State_Paused, "Got state %u.\n", state);
727
728 hr = IBaseFilter_Stop(filter);
729 ok(hr == S_OK, "Got hr %#lx.\n", hr);
730
731 hr = IBaseFilter_GetState(filter, 0, &state);
732 ok(hr == S_OK, "Got hr %#lx.\n", hr);
733 ok(state == State_Stopped, "Got state %u.\n", state);
734
735 hr = IBaseFilter_Run(filter, 0);
736 ok(hr == S_OK, "Got hr %#lx.\n", hr);
737
738 hr = IBaseFilter_GetState(filter, 0, &state);
739 ok(hr == S_OK, "Got hr %#lx.\n", hr);
740 ok(state == State_Running, "Got state %u.\n", state);
741
742 hr = IBaseFilter_Stop(filter);
743 ok(hr == S_OK, "Got hr %#lx.\n", hr);
744
745 hr = IBaseFilter_GetState(filter, 0, &state);
746 ok(hr == S_OK, "Got hr %#lx.\n", hr);
747 ok(state == State_Stopped, "Got state %u.\n", state);
748
749 ref = IBaseFilter_Release(filter);
750 ok(!ref, "Got outstanding refcount %ld.\n", ref);
751}
static int state
Definition: maze.c:121

Referenced by START_TEST().

◆ testsink_connect()

static HRESULT testsink_connect ( struct strmbase_sink *  iface,
IPin *  peer,
const AM_MEDIA_TYPE *  mt 
)
static

Definition at line 1254 of file filesource.c.

1255{
1256 struct testsink *filter = impl_sink_from_strmbase_filter(iface->pin.filter);
1257 if (filter->reject_avi && IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_Avi))
1259 IPin_QueryInterface(peer, &IID_IAsyncReader, (void **)&filter->reader);
1260 return S_OK;
1261}
static struct testsink * impl_sink_from_strmbase_filter(struct strmbase_filter *iface)
Definition: filesource.c:1217
struct strmbase_pin pin
Definition: strmbase.h:106

◆ testsink_destroy()

static void testsink_destroy ( struct strmbase_filter *  iface)
static

Definition at line 1230 of file filesource.c.

1231{
1235}
void strmbase_sink_cleanup(struct strmbase_sink *pin)
Definition: pin.c:1185
void strmbase_filter_cleanup(struct strmbase_filter *filter)
Definition: filter.c:540
IBaseFilter * filter
Definition: filtergraph.c:75

◆ testsink_disconnect()

static void testsink_disconnect ( struct strmbase_sink *  iface)
static

Definition at line 1263 of file filesource.c.

1264{
1265 struct testsink *filter = impl_sink_from_strmbase_filter(iface->pin.filter);
1266 IAsyncReader_Release(filter->reader);
1267 filter->reader = NULL;
1268}

◆ testsink_get_media_type()

static HRESULT testsink_get_media_type ( struct strmbase_pin *  iface,
unsigned int  index,
AM_MEDIA_TYPE *  mt 
)
static

Definition at line 1243 of file filesource.c.

1244{
1246 if (!index && filter->mt)
1247 {
1248 CopyMediaType(mt, filter->mt);
1249 return S_OK;
1250 }
1251 return VFW_S_NO_MORE_ITEMS;
1252}
GLuint index
Definition: glext.h:6031
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: mediatype.c:150
struct strmbase_filter * filter
Definition: strmbase.h:58
#define VFW_S_NO_MORE_ITEMS
Definition: vfwmsgs.h:19

◆ testsink_get_pin()

static struct strmbase_pin * testsink_get_pin ( struct strmbase_filter *  iface,
unsigned int  index 
)
static

Definition at line 1222 of file filesource.c.

1223{
1225 if (!index)
1226 return &filter->pin.pin;
1227 return NULL;
1228}

◆ testsink_init()

static void testsink_init ( struct testsink *  filter)
static

Definition at line 1277 of file filesource.c.

1278{
1279 static const GUID clsid = {0xabacab};
1280 memset(filter, 0, sizeof(*filter));
1283}
static const struct strmbase_sink_ops testsink_pin_ops
Definition: filesource.c:1270
static const struct strmbase_filter_ops testsink_ops
Definition: filesource.c:1237
const CLSID * clsid
Definition: msctf.cpp:50
void strmbase_sink_init(struct strmbase_sink *pin, struct strmbase_filter *filter, const WCHAR *name, const struct strmbase_sink_ops *ops, IMemAllocator *allocator)
Definition: pin.c:1168
void strmbase_filter_init(struct strmbase_filter *filter, IUnknown *outer, const CLSID *clsid, const struct strmbase_filter_ops *func_table)
Definition: filter.c:517

Referenced by test_connect_pin().

◆ wait_thread()

static DWORD CALLBACK wait_thread ( void *  arg)
static

Definition at line 927 of file filesource.c.

928{
932 HRESULT hr = IAsyncReader_WaitForNext(reader, 2000, &sample, &cookie);
933 ok(hr == VFW_E_WRONG_STATE, "Got hr %#lx.\n", hr);
934 return 0;
935}

Referenced by RpcMgmtWaitServerListen(), test_flush(), and tp_object_execute().

Variable Documentation

◆ outer_ref

LONG outer_ref = 1
static

Definition at line 140 of file filesource.c.

Referenced by outer_AddRef(), outer_Release(), and test_aggregation().

◆ outer_vtbl

const IUnknownVtbl outer_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI outer_AddRef(IUnknown *iface)
Definition: filesource.c:155
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
Definition: filesource.c:142
static ULONG WINAPI outer_Release(IUnknown *iface)
Definition: filesource.c:160

Definition at line 165 of file filesource.c.

◆ test_iid

const GUID test_iid = {0x33333333}
static

Definition at line 139 of file filesource.c.

Referenced by outer_QueryInterface(), and test_aggregation().

◆ test_outer

IUnknown test_outer = {&outer_vtbl}
static

Definition at line 172 of file filesource.c.

Referenced by test_aggregation().

◆ testsink_ops

const struct strmbase_filter_ops testsink_ops
static
Initial value:
=
{
.filter_get_pin = testsink_get_pin,
.filter_destroy = testsink_destroy,
}
static void testsink_destroy(struct strmbase_filter *iface)
Definition: filesource.c:1230
static struct strmbase_pin * testsink_get_pin(struct strmbase_filter *iface, unsigned int index)
Definition: filesource.c:1222

Definition at line 1237 of file filesource.c.

Referenced by testsink_init().

◆ testsink_pin_ops

const struct strmbase_sink_ops testsink_pin_ops
static
Initial value:
=
{
.base.pin_get_media_type = testsink_get_media_type,
.sink_connect = testsink_connect,
.sink_disconnect = testsink_disconnect,
}
static HRESULT testsink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
Definition: filesource.c:1254
static HRESULT testsink_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt)
Definition: filesource.c:1243
static void testsink_disconnect(struct strmbase_sink *iface)
Definition: filesource.c:1263

Definition at line 1270 of file filesource.c.

Referenced by testsink_init().