22 #ifndef AVDEVICE_DSHOW_H
23 #define AVDEVICE_DSHOW_H
30 #define WIN32_LEAN_AND_MEAN
32 #define NO_DSHOW_STRSAFE
37 #ifndef EC_DEVICE_LOST
38 #define EC_DEVICE_LOST 0x1f
49 #define dshowdebug(...) av_log(&ff_dshow_context_class_ptr, AV_LOG_DEBUG, __VA_ARGS__)
51 #define dshowdebug(...)
73 #define DECLARE_QUERYINTERFACE(class, ...) \
75 class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
77 struct GUIDoffset ifaces[] = __VA_ARGS__; \
79 dshowdebug(AV_STRINGIFY(class)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
83 for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) { \
84 if (IsEqualGUID(riid, ifaces[i].iid)) { \
85 void *obj = (void *) ((uint8_t *) this + ifaces[i].offset); \
86 class##_AddRef(this); \
87 dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset); \
88 *ppvObject = (void *) obj; \
92 dshowdebug("\tE_NOINTERFACE\n"); \
94 return E_NOINTERFACE; \
96 #define DECLARE_ADDREF(class) \
97 unsigned long WINAPI \
98 class##_AddRef(class *this) \
100 dshowdebug(AV_STRINGIFY(class)"_AddRef(%p)\t%ld\n", this, this->ref+1); \
101 return InterlockedIncrement(&this->ref); \
103 #define DECLARE_RELEASE(class) \
104 unsigned long WINAPI \
105 class##_Release(class *this) \
107 long ref = InterlockedDecrement(&this->ref); \
108 dshowdebug(AV_STRINGIFY(class)"_Release(%p)\t%ld\n", this, ref); \
110 class##_Destroy(this); \
114 #define DECLARE_DESTROY(class, func) \
115 void class##_Destroy(class *this) \
117 dshowdebug(AV_STRINGIFY(class)"_Destroy(%p)\n", this); \
121 CoTaskMemFree(this->vtbl); \
122 CoTaskMemFree(this); \
125 #define DECLARE_CREATE(class, setup, ...) \
126 class *class##_Create(__VA_ARGS__) \
128 class *this = CoTaskMemAlloc(sizeof(class)); \
129 void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \
130 dshowdebug(AV_STRINGIFY(class)"_Create(%p)\n", this); \
131 if (!this || !vtbl) \
133 ZeroMemory(this, sizeof(class)); \
134 ZeroMemory(vtbl, sizeof(*this->vtbl)); \
139 dshowdebug("created "AV_STRINGIFY(class)" %p\n", this); \
142 class##_Destroy(this); \
143 dshowdebug("could not create "AV_STRINGIFY(class)"\n"); \
147 #define SETVTBL(vtbl, class, fn) \
148 do { (vtbl)->fn = (void *) class##_##fn; } while(0)