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(...)
68 #define DECLARE_QUERYINTERFACE(class, ...) \
70 class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
72 struct GUIDoffset ifaces[] = __VA_ARGS__; \
74 dshowdebug(AV_STRINGIFY(class)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
78 for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) { \
79 if (IsEqualGUID(riid, ifaces[i].iid)) { \
80 void *obj = (void *) ((uint8_t *) this + ifaces[i].offset); \
81 class##_AddRef(this); \
82 dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset); \
83 *ppvObject = (void *) obj; \
87 dshowdebug("\tE_NOINTERFACE\n"); \
89 return E_NOINTERFACE; \
91 #define DECLARE_ADDREF(class) \
92 unsigned long WINAPI \
93 class##_AddRef(class *this) \
95 dshowdebug(AV_STRINGIFY(class)"_AddRef(%p)\t%ld\n", this, this->ref+1); \
96 return InterlockedIncrement(&this->ref); \
98 #define DECLARE_RELEASE(class) \
99 unsigned long WINAPI \
100 class##_Release(class *this) \
102 long ref = InterlockedDecrement(&this->ref); \
103 dshowdebug(AV_STRINGIFY(class)"_Release(%p)\t%ld\n", this, ref); \
105 class##_Destroy(this); \
109 #define DECLARE_DESTROY(class, func) \
110 void class##_Destroy(class *this) \
112 dshowdebug(AV_STRINGIFY(class)"_Destroy(%p)\n", this); \
116 CoTaskMemFree(this->vtbl); \
117 CoTaskMemFree(this); \
120 #define DECLARE_CREATE(class, setup, ...) \
121 class *class##_Create(__VA_ARGS__) \
123 class *this = CoTaskMemAlloc(sizeof(class)); \
124 void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \
125 dshowdebug(AV_STRINGIFY(class)"_Create(%p)\n", this); \
126 if (!this || !vtbl) \
128 ZeroMemory(this, sizeof(class)); \
129 ZeroMemory(vtbl, sizeof(*this->vtbl)); \
134 dshowdebug("created "AV_STRINGIFY(class)" %p\n", this); \
137 class##_Destroy(this); \
138 dshowdebug("could not create "AV_STRINGIFY(class)"\n"); \
142 #define SETVTBL(vtbl, class, fn) \
143 do { (vtbl)->fn = (void *) class##_##fn; } while(0)