avdevice/dshow: Add namespace prefix to the remaining global symbols

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2021-01-21 19:45:48 -03:00
parent 56709ca8aa
commit 911ba8417e
6 changed files with 320 additions and 371 deletions

View File

@ -87,13 +87,13 @@ dshow_read_close(AVFormatContext *s)
} }
if (ctx->capture_pin[VideoDevice]) if (ctx->capture_pin[VideoDevice])
libAVPin_Release(ctx->capture_pin[VideoDevice]); ff_dshow_pin_Release(ctx->capture_pin[VideoDevice]);
if (ctx->capture_pin[AudioDevice]) if (ctx->capture_pin[AudioDevice])
libAVPin_Release(ctx->capture_pin[AudioDevice]); ff_dshow_pin_Release(ctx->capture_pin[AudioDevice]);
if (ctx->capture_filter[VideoDevice]) if (ctx->capture_filter[VideoDevice])
libAVFilter_Release(ctx->capture_filter[VideoDevice]); ff_dshow_filter_Release(ctx->capture_filter[VideoDevice]);
if (ctx->capture_filter[AudioDevice]) if (ctx->capture_filter[AudioDevice])
libAVFilter_Release(ctx->capture_filter[AudioDevice]); ff_dshow_filter_Release(ctx->capture_filter[AudioDevice]);
if (ctx->device_pin[VideoDevice]) if (ctx->device_pin[VideoDevice])
IPin_Release(ctx->device_pin[VideoDevice]); IPin_Release(ctx->device_pin[VideoDevice]);
@ -731,8 +731,8 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum,
char *device_filter_unique_name = NULL; char *device_filter_unique_name = NULL;
IGraphBuilder *graph = ctx->graph; IGraphBuilder *graph = ctx->graph;
IPin *device_pin = NULL; IPin *device_pin = NULL;
libAVPin *capture_pin = NULL; DShowPin *capture_pin = NULL;
libAVFilter *capture_filter = NULL; DShowFilter *capture_filter = NULL;
ICaptureGraphBuilder2 *graph_builder2 = NULL; ICaptureGraphBuilder2 *graph_builder2 = NULL;
int ret = AVERROR(EIO); int ret = AVERROR(EIO);
int r; int r;
@ -807,7 +807,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum,
ctx->device_pin[devtype] = device_pin; ctx->device_pin[devtype] = device_pin;
capture_filter = libAVFilter_Create(avctx, callback, devtype); capture_filter = ff_dshow_filter_Create(avctx, callback, devtype);
if (!capture_filter) { if (!capture_filter) {
av_log(avctx, AV_LOG_ERROR, "Could not create grabber filter.\n"); av_log(avctx, AV_LOG_ERROR, "Could not create grabber filter.\n");
goto error; goto error;
@ -863,7 +863,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum,
goto error; goto error;
} }
libAVPin_AddRef(capture_filter->pin); ff_dshow_pin_AddRef(capture_filter->pin);
capture_pin = capture_filter->pin; capture_pin = capture_filter->pin;
ctx->capture_pin[devtype] = capture_pin; ctx->capture_pin[devtype] = capture_pin;
@ -953,7 +953,7 @@ dshow_add_device(AVFormatContext *avctx,
ctx->capture_filter[devtype]->stream_index = st->index; ctx->capture_filter[devtype]->stream_index = st->index;
libAVPin_ConnectionMediaType(ctx->capture_pin[devtype], &type); ff_dshow_pin_ConnectionMediaType(ctx->capture_pin[devtype], &type);
par = st->codecpar; par = st->codecpar;
if (devtype == VideoDevice) { if (devtype == VideoDevice) {

View File

@ -68,20 +68,20 @@ enum dshowSourceFilterType {
AudioSourceDevice = 1, AudioSourceDevice = 1,
}; };
#define DECLARE_QUERYINTERFACE(class, ...) \ #define DECLARE_QUERYINTERFACE(prefix, class, ...) \
long WINAPI \ long \
class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \ ff_dshow_##prefix##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
{ \ { \
struct GUIDoffset ifaces[] = __VA_ARGS__; \ struct GUIDoffset ifaces[] = __VA_ARGS__; \
int i; \ int i; \
dshowdebug(AV_STRINGIFY(class)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
ff_printGUID(riid); \ ff_printGUID(riid); \
if (!ppvObject) \ if (!ppvObject) \
return E_POINTER; \ return E_POINTER; \
for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) { \ for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) { \
if (IsEqualGUID(riid, ifaces[i].iid)) { \ if (IsEqualGUID(riid, ifaces[i].iid)) { \
void *obj = (void *) ((uint8_t *) this + ifaces[i].offset); \ void *obj = (void *) ((uint8_t *) this + ifaces[i].offset); \
class##_AddRef(this); \ ff_dshow_##prefix##_AddRef(this); \
dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset); \ dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset); \
*ppvObject = (void *) obj; \ *ppvObject = (void *) obj; \
return S_OK; \ return S_OK; \
@ -91,28 +91,28 @@ class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
*ppvObject = NULL; \ *ppvObject = NULL; \
return E_NOINTERFACE; \ return E_NOINTERFACE; \
} }
#define DECLARE_ADDREF(class) \ #define DECLARE_ADDREF(prefix, class) \
unsigned long WINAPI \ unsigned long \
class##_AddRef(class *this) \ ff_dshow_##prefix##_AddRef(class *this) \
{ \ { \
dshowdebug(AV_STRINGIFY(class)"_AddRef(%p)\t%ld\n", this, this->ref+1); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_AddRef(%p)\t%ld\n", this, this->ref+1); \
return InterlockedIncrement(&this->ref); \ return InterlockedIncrement(&this->ref); \
} }
#define DECLARE_RELEASE(class) \ #define DECLARE_RELEASE(prefix, class) \
unsigned long WINAPI \ unsigned long \
class##_Release(class *this) \ ff_dshow_##prefix##_Release(class *this) \
{ \ { \
long ref = InterlockedDecrement(&this->ref); \ long ref = InterlockedDecrement(&this->ref); \
dshowdebug(AV_STRINGIFY(class)"_Release(%p)\t%ld\n", this, ref); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Release(%p)\t%ld\n", this, ref); \
if (!ref) \ if (!ref) \
class##_Destroy(this); \ ff_dshow_##prefix##_Destroy(this); \
return ref; \ return ref; \
} }
#define DECLARE_DESTROY(class, func) \ #define DECLARE_DESTROY(prefix, class, func) \
void class##_Destroy(class *this) \ void ff_dshow_##prefix##_Destroy(class *this) \
{ \ { \
dshowdebug(AV_STRINGIFY(class)"_Destroy(%p)\n", this); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Destroy(%p)\n", this); \
func(this); \ func(this); \
if (this) { \ if (this) { \
if (this->vtbl) \ if (this->vtbl) \
@ -120,12 +120,12 @@ void class##_Destroy(class *this) \
CoTaskMemFree(this); \ CoTaskMemFree(this); \
} \ } \
} }
#define DECLARE_CREATE(class, setup, ...) \ #define DECLARE_CREATE(prefix, class, setup, ...) \
class *class##_Create(__VA_ARGS__) \ class *ff_dshow_##prefix##_Create(__VA_ARGS__) \
{ \ { \
class *this = CoTaskMemAlloc(sizeof(class)); \ class *this = CoTaskMemAlloc(sizeof(class)); \
void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \ void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \
dshowdebug(AV_STRINGIFY(class)"_Create(%p)\n", this); \ dshowdebug("ff_dshow_"AV_STRINGIFY(prefix)"_Create(%p)\n", this); \
if (!this || !vtbl) \ if (!this || !vtbl) \
goto fail; \ goto fail; \
ZeroMemory(this, sizeof(class)); \ ZeroMemory(this, sizeof(class)); \
@ -134,123 +134,123 @@ class *class##_Create(__VA_ARGS__) \
this->vtbl = vtbl; \ this->vtbl = vtbl; \
if (!setup) \ if (!setup) \
goto fail; \ goto fail; \
dshowdebug("created "AV_STRINGIFY(class)" %p\n", this); \ dshowdebug("created ff_dshow_"AV_STRINGIFY(prefix)" %p\n", this); \
return this; \ return this; \
fail: \ fail: \
class##_Destroy(this); \ ff_dshow_##prefix##_Destroy(this); \
dshowdebug("could not create "AV_STRINGIFY(class)"\n"); \ dshowdebug("could not create ff_dshow_"AV_STRINGIFY(prefix)"\n"); \
return NULL; \ return NULL; \
} }
#define SETVTBL(vtbl, class, fn) \ #define SETVTBL(vtbl, prefix, fn) \
do { (vtbl)->fn = (void *) class##_##fn; } while(0) do { (vtbl)->fn = (void *) ff_dshow_##prefix##_##fn; } while(0)
/***************************************************************************** /*****************************************************************************
* Forward Declarations * Forward Declarations
****************************************************************************/ ****************************************************************************/
typedef struct libAVPin libAVPin; typedef struct DShowPin DShowPin;
typedef struct libAVMemInputPin libAVMemInputPin; typedef struct DShowMemInputPin DShowMemInputPin;
typedef struct libAVEnumPins libAVEnumPins; typedef struct DShowEnumPins DShowEnumPins;
typedef struct libAVEnumMediaTypes libAVEnumMediaTypes; typedef struct DShowEnumMediaTypes DShowEnumMediaTypes;
typedef struct libAVFilter libAVFilter; typedef struct DShowFilter DShowFilter;
/***************************************************************************** /*****************************************************************************
* libAVPin * DShowPin
****************************************************************************/ ****************************************************************************/
struct libAVPin { struct DShowPin {
IPinVtbl *vtbl; IPinVtbl *vtbl;
long ref; long ref;
libAVFilter *filter; DShowFilter *filter;
IPin *connectedto; IPin *connectedto;
AM_MEDIA_TYPE type; AM_MEDIA_TYPE type;
IMemInputPinVtbl *imemvtbl; IMemInputPinVtbl *imemvtbl;
}; };
long WINAPI libAVPin_QueryInterface (libAVPin *, const GUID *, void **); long ff_dshow_pin_QueryInterface (DShowPin *, const GUID *, void **);
unsigned long WINAPI libAVPin_AddRef (libAVPin *); unsigned long ff_dshow_pin_AddRef (DShowPin *);
unsigned long WINAPI libAVPin_Release (libAVPin *); unsigned long ff_dshow_pin_Release (DShowPin *);
long WINAPI libAVPin_Connect (libAVPin *, IPin *, const AM_MEDIA_TYPE *); long ff_dshow_pin_Connect (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_ReceiveConnection (libAVPin *, IPin *, const AM_MEDIA_TYPE *); long ff_dshow_pin_ReceiveConnection (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_Disconnect (libAVPin *); long ff_dshow_pin_Disconnect (DShowPin *);
long WINAPI libAVPin_ConnectedTo (libAVPin *, IPin **); long ff_dshow_pin_ConnectedTo (DShowPin *, IPin **);
long WINAPI libAVPin_ConnectionMediaType (libAVPin *, AM_MEDIA_TYPE *); long ff_dshow_pin_ConnectionMediaType (DShowPin *, AM_MEDIA_TYPE *);
long WINAPI libAVPin_QueryPinInfo (libAVPin *, PIN_INFO *); long ff_dshow_pin_QueryPinInfo (DShowPin *, PIN_INFO *);
long WINAPI libAVPin_QueryDirection (libAVPin *, PIN_DIRECTION *); long ff_dshow_pin_QueryDirection (DShowPin *, PIN_DIRECTION *);
long WINAPI libAVPin_QueryId (libAVPin *, wchar_t **); long ff_dshow_pin_QueryId (DShowPin *, wchar_t **);
long WINAPI libAVPin_QueryAccept (libAVPin *, const AM_MEDIA_TYPE *); long ff_dshow_pin_QueryAccept (DShowPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_EnumMediaTypes (libAVPin *, IEnumMediaTypes **); long ff_dshow_pin_EnumMediaTypes (DShowPin *, IEnumMediaTypes **);
long WINAPI libAVPin_QueryInternalConnections(libAVPin *, IPin **, unsigned long *); long ff_dshow_pin_QueryInternalConnections(DShowPin *, IPin **, unsigned long *);
long WINAPI libAVPin_EndOfStream (libAVPin *); long ff_dshow_pin_EndOfStream (DShowPin *);
long WINAPI libAVPin_BeginFlush (libAVPin *); long ff_dshow_pin_BeginFlush (DShowPin *);
long WINAPI libAVPin_EndFlush (libAVPin *); long ff_dshow_pin_EndFlush (DShowPin *);
long WINAPI libAVPin_NewSegment (libAVPin *, REFERENCE_TIME, REFERENCE_TIME, double); long ff_dshow_pin_NewSegment (DShowPin *, REFERENCE_TIME, REFERENCE_TIME, double);
long WINAPI libAVMemInputPin_QueryInterface (libAVMemInputPin *, const GUID *, void **); long ff_dshow_meminputpin_QueryInterface (DShowMemInputPin *, const GUID *, void **);
unsigned long WINAPI libAVMemInputPin_AddRef (libAVMemInputPin *); unsigned long ff_dshow_meminputpin_AddRef (DShowMemInputPin *);
unsigned long WINAPI libAVMemInputPin_Release (libAVMemInputPin *); unsigned long ff_dshow_meminputpin_Release (DShowMemInputPin *);
long WINAPI libAVMemInputPin_GetAllocator (libAVMemInputPin *, IMemAllocator **); long ff_dshow_meminputpin_GetAllocator (DShowMemInputPin *, IMemAllocator **);
long WINAPI libAVMemInputPin_NotifyAllocator (libAVMemInputPin *, IMemAllocator *, BOOL); long ff_dshow_meminputpin_NotifyAllocator (DShowMemInputPin *, IMemAllocator *, BOOL);
long WINAPI libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *, ALLOCATOR_PROPERTIES *); long ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *, ALLOCATOR_PROPERTIES *);
long WINAPI libAVMemInputPin_Receive (libAVMemInputPin *, IMediaSample *); long ff_dshow_meminputpin_Receive (DShowMemInputPin *, IMediaSample *);
long WINAPI libAVMemInputPin_ReceiveMultiple (libAVMemInputPin *, IMediaSample **, long, long *); long ff_dshow_meminputpin_ReceiveMultiple (DShowMemInputPin *, IMediaSample **, long, long *);
long WINAPI libAVMemInputPin_ReceiveCanBlock (libAVMemInputPin *); long ff_dshow_meminputpin_ReceiveCanBlock (DShowMemInputPin *);
void libAVPin_Destroy(libAVPin *); void ff_dshow_pin_Destroy(DShowPin *);
libAVPin *libAVPin_Create (libAVFilter *filter); DShowPin *ff_dshow_pin_Create (DShowFilter *filter);
void libAVMemInputPin_Destroy(libAVMemInputPin *); void ff_dshow_meminputpin_Destroy(DShowMemInputPin *);
/***************************************************************************** /*****************************************************************************
* libAVEnumPins * DShowEnumPins
****************************************************************************/ ****************************************************************************/
struct libAVEnumPins { struct DShowEnumPins {
IEnumPinsVtbl *vtbl; IEnumPinsVtbl *vtbl;
long ref; long ref;
int pos; int pos;
libAVPin *pin; DShowPin *pin;
libAVFilter *filter; DShowFilter *filter;
}; };
long WINAPI libAVEnumPins_QueryInterface(libAVEnumPins *, const GUID *, void **); long ff_dshow_enumpins_QueryInterface(DShowEnumPins *, const GUID *, void **);
unsigned long WINAPI libAVEnumPins_AddRef (libAVEnumPins *); unsigned long ff_dshow_enumpins_AddRef (DShowEnumPins *);
unsigned long WINAPI libAVEnumPins_Release (libAVEnumPins *); unsigned long ff_dshow_enumpins_Release (DShowEnumPins *);
long WINAPI libAVEnumPins_Next (libAVEnumPins *, unsigned long, IPin **, unsigned long *); long ff_dshow_enumpins_Next (DShowEnumPins *, unsigned long, IPin **, unsigned long *);
long WINAPI libAVEnumPins_Skip (libAVEnumPins *, unsigned long); long ff_dshow_enumpins_Skip (DShowEnumPins *, unsigned long);
long WINAPI libAVEnumPins_Reset (libAVEnumPins *); long ff_dshow_enumpins_Reset (DShowEnumPins *);
long WINAPI libAVEnumPins_Clone (libAVEnumPins *, libAVEnumPins **); long ff_dshow_enumpins_Clone (DShowEnumPins *, DShowEnumPins **);
void libAVEnumPins_Destroy(libAVEnumPins *); void ff_dshow_enumpins_Destroy(DShowEnumPins *);
libAVEnumPins *libAVEnumPins_Create (libAVPin *pin, libAVFilter *filter); DShowEnumPins *ff_dshow_enumpins_Create (DShowPin *pin, DShowFilter *filter);
/***************************************************************************** /*****************************************************************************
* libAVEnumMediaTypes * DShowEnumMediaTypes
****************************************************************************/ ****************************************************************************/
struct libAVEnumMediaTypes { struct DShowEnumMediaTypes {
IEnumMediaTypesVtbl *vtbl; IEnumMediaTypesVtbl *vtbl;
long ref; long ref;
int pos; int pos;
AM_MEDIA_TYPE type; AM_MEDIA_TYPE type;
}; };
long WINAPI libAVEnumMediaTypes_QueryInterface(libAVEnumMediaTypes *, const GUID *, void **); long ff_dshow_enummediatypes_QueryInterface(DShowEnumMediaTypes *, const GUID *, void **);
unsigned long WINAPI libAVEnumMediaTypes_AddRef (libAVEnumMediaTypes *); unsigned long ff_dshow_enummediatypes_AddRef (DShowEnumMediaTypes *);
unsigned long WINAPI libAVEnumMediaTypes_Release (libAVEnumMediaTypes *); unsigned long ff_dshow_enummediatypes_Release (DShowEnumMediaTypes *);
long WINAPI libAVEnumMediaTypes_Next (libAVEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *); long ff_dshow_enummediatypes_Next (DShowEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *);
long WINAPI libAVEnumMediaTypes_Skip (libAVEnumMediaTypes *, unsigned long); long ff_dshow_enummediatypes_Skip (DShowEnumMediaTypes *, unsigned long);
long WINAPI libAVEnumMediaTypes_Reset (libAVEnumMediaTypes *); long ff_dshow_enummediatypes_Reset (DShowEnumMediaTypes *);
long WINAPI libAVEnumMediaTypes_Clone (libAVEnumMediaTypes *, libAVEnumMediaTypes **); long ff_dshow_enummediatypes_Clone (DShowEnumMediaTypes *, DShowEnumMediaTypes **);
void libAVEnumMediaTypes_Destroy(libAVEnumMediaTypes *); void ff_dshow_enummediatypes_Destroy(DShowEnumMediaTypes *);
libAVEnumMediaTypes *libAVEnumMediaTypes_Create(const AM_MEDIA_TYPE *type); DShowEnumMediaTypes *ff_dshow_enummediatypes_Create(const AM_MEDIA_TYPE *type);
/***************************************************************************** /*****************************************************************************
* libAVFilter * DShowFilter
****************************************************************************/ ****************************************************************************/
struct libAVFilter { struct DShowFilter {
IBaseFilterVtbl *vtbl; IBaseFilterVtbl *vtbl;
long ref; long ref;
const wchar_t *name; const wchar_t *name;
libAVPin *pin; DShowPin *pin;
FILTER_INFO info; FILTER_INFO info;
FILTER_STATE state; FILTER_STATE state;
IReferenceClock *clock; IReferenceClock *clock;
@ -261,24 +261,24 @@ struct libAVFilter {
void (*callback)(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType type); void (*callback)(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType type);
}; };
long WINAPI libAVFilter_QueryInterface (libAVFilter *, const GUID *, void **); long ff_dshow_filter_QueryInterface (DShowFilter *, const GUID *, void **);
unsigned long WINAPI libAVFilter_AddRef (libAVFilter *); unsigned long ff_dshow_filter_AddRef (DShowFilter *);
unsigned long WINAPI libAVFilter_Release (libAVFilter *); unsigned long ff_dshow_filter_Release (DShowFilter *);
long WINAPI libAVFilter_GetClassID (libAVFilter *, CLSID *); long ff_dshow_filter_GetClassID (DShowFilter *, CLSID *);
long WINAPI libAVFilter_Stop (libAVFilter *); long ff_dshow_filter_Stop (DShowFilter *);
long WINAPI libAVFilter_Pause (libAVFilter *); long ff_dshow_filter_Pause (DShowFilter *);
long WINAPI libAVFilter_Run (libAVFilter *, REFERENCE_TIME); long ff_dshow_filter_Run (DShowFilter *, REFERENCE_TIME);
long WINAPI libAVFilter_GetState (libAVFilter *, DWORD, FILTER_STATE *); long ff_dshow_filter_GetState (DShowFilter *, DWORD, FILTER_STATE *);
long WINAPI libAVFilter_SetSyncSource (libAVFilter *, IReferenceClock *); long ff_dshow_filter_SetSyncSource (DShowFilter *, IReferenceClock *);
long WINAPI libAVFilter_GetSyncSource (libAVFilter *, IReferenceClock **); long ff_dshow_filter_GetSyncSource (DShowFilter *, IReferenceClock **);
long WINAPI libAVFilter_EnumPins (libAVFilter *, IEnumPins **); long ff_dshow_filter_EnumPins (DShowFilter *, IEnumPins **);
long WINAPI libAVFilter_FindPin (libAVFilter *, const wchar_t *, IPin **); long ff_dshow_filter_FindPin (DShowFilter *, const wchar_t *, IPin **);
long WINAPI libAVFilter_QueryFilterInfo(libAVFilter *, FILTER_INFO *); long ff_dshow_filter_QueryFilterInfo(DShowFilter *, FILTER_INFO *);
long WINAPI libAVFilter_JoinFilterGraph(libAVFilter *, IFilterGraph *, const wchar_t *); long ff_dshow_filter_JoinFilterGraph(DShowFilter *, IFilterGraph *, const wchar_t *);
long WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, wchar_t **); long ff_dshow_filter_QueryVendorInfo(DShowFilter *, wchar_t **);
void libAVFilter_Destroy(libAVFilter *); void ff_dshow_filter_Destroy(DShowFilter *);
libAVFilter *libAVFilter_Create (void *, void *, enum dshowDeviceType); DShowFilter *ff_dshow_filter_Create (void *, void *, enum dshowDeviceType);
/***************************************************************************** /*****************************************************************************
* dshow_ctx * dshow_ctx
@ -314,8 +314,8 @@ struct dshow_ctx {
IBaseFilter *device_filter[2]; IBaseFilter *device_filter[2];
IPin *device_pin[2]; IPin *device_pin[2];
libAVFilter *capture_filter[2]; DShowFilter *capture_filter[2];
libAVPin *capture_pin[2]; DShowPin *capture_pin[2];
HANDLE mutex; HANDLE mutex;
HANDLE event[2]; /* event[0] is set by DirectShow HANDLE event[2]; /* event[0] is set by DirectShow

View File

@ -21,17 +21,16 @@
#include "dshow_capture.h" #include "dshow_capture.h"
DECLARE_QUERYINTERFACE(libAVEnumMediaTypes, DECLARE_QUERYINTERFACE(enummediatypes, DShowEnumMediaTypes,
{ {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} }) { {&IID_IUnknown,0}, {&IID_IEnumMediaTypes,0} })
DECLARE_ADDREF(libAVEnumMediaTypes) DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
DECLARE_RELEASE(libAVEnumMediaTypes) DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)
long WINAPI long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *this, unsigned long n,
libAVEnumMediaTypes_Next(libAVEnumMediaTypes *this, unsigned long n,
AM_MEDIA_TYPE **types, unsigned long *fetched) AM_MEDIA_TYPE **types, unsigned long *fetched)
{ {
int count = 0; int count = 0;
dshowdebug("libAVEnumMediaTypes_Next(%p)\n", this); dshowdebug("ff_dshow_enummediatypes_Next(%p)\n", this);
if (!types) if (!types)
return E_POINTER; return E_POINTER;
if (!this->pos && n == 1) { if (!this->pos && n == 1) {
@ -51,29 +50,26 @@ libAVEnumMediaTypes_Next(libAVEnumMediaTypes *this, unsigned long n,
return S_FALSE; return S_FALSE;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *this, unsigned long n)
libAVEnumMediaTypes_Skip(libAVEnumMediaTypes *this, unsigned long n)
{ {
dshowdebug("libAVEnumMediaTypes_Skip(%p)\n", this); dshowdebug("ff_dshow_enummediatypes_Skip(%p)\n", this);
if (n) /* Any skip will always fall outside of the only valid type. */ if (n) /* Any skip will always fall outside of the only valid type. */
return S_FALSE; return S_FALSE;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *this)
libAVEnumMediaTypes_Reset(libAVEnumMediaTypes *this)
{ {
dshowdebug("libAVEnumMediaTypes_Reset(%p)\n", this); dshowdebug("ff_dshow_enummediatypes_Reset(%p)\n", this);
this->pos = 0; this->pos = 0;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
libAVEnumMediaTypes_Clone(libAVEnumMediaTypes *this, libAVEnumMediaTypes **enums)
{ {
libAVEnumMediaTypes *new; DShowEnumMediaTypes *new;
dshowdebug("libAVEnumMediaTypes_Clone(%p)\n", this); dshowdebug("ff_dshow_enummediatypes_Clone(%p)\n", this);
if (!enums) if (!enums)
return E_POINTER; return E_POINTER;
new = libAVEnumMediaTypes_Create(&this->type); new = ff_dshow_enummediatypes_Create(&this->type);
if (!new) if (!new)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
new->pos = this->pos; new->pos = this->pos;
@ -81,17 +77,16 @@ libAVEnumMediaTypes_Clone(libAVEnumMediaTypes *this, libAVEnumMediaTypes **enums
return S_OK; return S_OK;
} }
static int static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
libAVEnumMediaTypes_Setup(libAVEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
{ {
IEnumMediaTypesVtbl *vtbl = this->vtbl; IEnumMediaTypesVtbl *vtbl = this->vtbl;
SETVTBL(vtbl, libAVEnumMediaTypes, QueryInterface); SETVTBL(vtbl, enummediatypes, QueryInterface);
SETVTBL(vtbl, libAVEnumMediaTypes, AddRef); SETVTBL(vtbl, enummediatypes, AddRef);
SETVTBL(vtbl, libAVEnumMediaTypes, Release); SETVTBL(vtbl, enummediatypes, Release);
SETVTBL(vtbl, libAVEnumMediaTypes, Next); SETVTBL(vtbl, enummediatypes, Next);
SETVTBL(vtbl, libAVEnumMediaTypes, Skip); SETVTBL(vtbl, enummediatypes, Skip);
SETVTBL(vtbl, libAVEnumMediaTypes, Reset); SETVTBL(vtbl, enummediatypes, Reset);
SETVTBL(vtbl, libAVEnumMediaTypes, Clone); SETVTBL(vtbl, enummediatypes, Clone);
if (!type) { if (!type) {
this->type.majortype = GUID_NULL; this->type.majortype = GUID_NULL;
@ -101,5 +96,5 @@ libAVEnumMediaTypes_Setup(libAVEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
return 1; return 1;
} }
DECLARE_CREATE(libAVEnumMediaTypes, libAVEnumMediaTypes_Setup(this, type), const AM_MEDIA_TYPE *type) DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
DECLARE_DESTROY(libAVEnumMediaTypes, nothing) DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)

View File

@ -21,21 +21,20 @@
#include "dshow_capture.h" #include "dshow_capture.h"
DECLARE_QUERYINTERFACE(libAVEnumPins, DECLARE_QUERYINTERFACE(enumpins, DShowEnumPins,
{ {&IID_IUnknown,0}, {&IID_IEnumPins,0} }) { {&IID_IUnknown,0}, {&IID_IEnumPins,0} })
DECLARE_ADDREF(libAVEnumPins) DECLARE_ADDREF(enumpins, DShowEnumPins)
DECLARE_RELEASE(libAVEnumPins) DECLARE_RELEASE(enumpins, DShowEnumPins)
long WINAPI long ff_dshow_enumpins_Next(DShowEnumPins *this, unsigned long n, IPin **pins,
libAVEnumPins_Next(libAVEnumPins *this, unsigned long n, IPin **pins,
unsigned long *fetched) unsigned long *fetched)
{ {
int count = 0; int count = 0;
dshowdebug("libAVEnumPins_Next(%p)\n", this); dshowdebug("ff_dshow_enumpins_Next(%p)\n", this);
if (!pins) if (!pins)
return E_POINTER; return E_POINTER;
if (!this->pos && n == 1) { if (!this->pos && n == 1) {
libAVPin_AddRef(this->pin); ff_dshow_pin_AddRef(this->pin);
*pins = (IPin *) this->pin; *pins = (IPin *) this->pin;
count = 1; count = 1;
this->pos = 1; this->pos = 1;
@ -46,29 +45,26 @@ libAVEnumPins_Next(libAVEnumPins *this, unsigned long n, IPin **pins,
return S_FALSE; return S_FALSE;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enumpins_Skip(DShowEnumPins *this, unsigned long n)
libAVEnumPins_Skip(libAVEnumPins *this, unsigned long n)
{ {
dshowdebug("libAVEnumPins_Skip(%p)\n", this); dshowdebug("ff_dshow_enumpins_Skip(%p)\n", this);
if (n) /* Any skip will always fall outside of the only valid pin. */ if (n) /* Any skip will always fall outside of the only valid pin. */
return S_FALSE; return S_FALSE;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enumpins_Reset(DShowEnumPins *this)
libAVEnumPins_Reset(libAVEnumPins *this)
{ {
dshowdebug("libAVEnumPins_Reset(%p)\n", this); dshowdebug("ff_dshow_enumpins_Reset(%p)\n", this);
this->pos = 0; this->pos = 0;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_enumpins_Clone(DShowEnumPins *this, DShowEnumPins **pins)
libAVEnumPins_Clone(libAVEnumPins *this, libAVEnumPins **pins)
{ {
libAVEnumPins *new; DShowEnumPins *new;
dshowdebug("libAVEnumPins_Clone(%p)\n", this); dshowdebug("ff_dshow_enumpins_Clone(%p)\n", this);
if (!pins) if (!pins)
return E_POINTER; return E_POINTER;
new = libAVEnumPins_Create(this->pin, this->filter); new = ff_dshow_enumpins_Create(this->pin, this->filter);
if (!new) if (!new)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
new->pos = this->pos; new->pos = this->pos;
@ -76,30 +72,28 @@ libAVEnumPins_Clone(libAVEnumPins *this, libAVEnumPins **pins)
return S_OK; return S_OK;
} }
static int static int ff_dshow_enumpins_Setup(DShowEnumPins *this, DShowPin *pin, DShowFilter *filter)
libAVEnumPins_Setup(libAVEnumPins *this, libAVPin *pin, libAVFilter *filter)
{ {
IEnumPinsVtbl *vtbl = this->vtbl; IEnumPinsVtbl *vtbl = this->vtbl;
SETVTBL(vtbl, libAVEnumPins, QueryInterface); SETVTBL(vtbl, enumpins, QueryInterface);
SETVTBL(vtbl, libAVEnumPins, AddRef); SETVTBL(vtbl, enumpins, AddRef);
SETVTBL(vtbl, libAVEnumPins, Release); SETVTBL(vtbl, enumpins, Release);
SETVTBL(vtbl, libAVEnumPins, Next); SETVTBL(vtbl, enumpins, Next);
SETVTBL(vtbl, libAVEnumPins, Skip); SETVTBL(vtbl, enumpins, Skip);
SETVTBL(vtbl, libAVEnumPins, Reset); SETVTBL(vtbl, enumpins, Reset);
SETVTBL(vtbl, libAVEnumPins, Clone); SETVTBL(vtbl, enumpins, Clone);
this->pin = pin; this->pin = pin;
this->filter = filter; this->filter = filter;
libAVFilter_AddRef(this->filter); ff_dshow_filter_AddRef(this->filter);
return 1; return 1;
} }
static int static int ff_dshow_enumpins_Cleanup(DShowEnumPins *this)
libAVEnumPins_Cleanup(libAVEnumPins *this)
{ {
libAVFilter_Release(this->filter); ff_dshow_filter_Release(this->filter);
return 1; return 1;
} }
DECLARE_CREATE(libAVEnumPins, libAVEnumPins_Setup(this, pin, filter), DECLARE_CREATE(enumpins, DShowEnumPins, ff_dshow_enumpins_Setup(this, pin, filter),
libAVPin *pin, libAVFilter *filter) DShowPin *pin, DShowFilter *filter)
DECLARE_DESTROY(libAVEnumPins, libAVEnumPins_Cleanup) DECLARE_DESTROY(enumpins, DShowEnumPins, ff_dshow_enumpins_Cleanup)

View File

@ -21,53 +21,47 @@
#include "dshow_capture.h" #include "dshow_capture.h"
DECLARE_QUERYINTERFACE(libAVFilter, DECLARE_QUERYINTERFACE(filter, DShowFilter,
{ {&IID_IUnknown,0}, {&IID_IBaseFilter,0} }) { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
DECLARE_ADDREF(libAVFilter) DECLARE_ADDREF(filter, DShowFilter)
DECLARE_RELEASE(libAVFilter) DECLARE_RELEASE(filter, DShowFilter)
long WINAPI long ff_dshow_filter_GetClassID(DShowFilter *this, CLSID *id)
libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
{ {
dshowdebug("libAVFilter_GetClassID(%p)\n", this); dshowdebug("ff_dshow_filter_GetClassID(%p)\n", this);
/* I'm not creating a ClassID just for this. */ /* I'm not creating a ClassID just for this. */
return E_FAIL; return E_FAIL;
} }
long WINAPI long ff_dshow_filter_Stop(DShowFilter *this)
libAVFilter_Stop(libAVFilter *this)
{ {
dshowdebug("libAVFilter_Stop(%p)\n", this); dshowdebug("ff_dshow_filter_Stop(%p)\n", this);
this->state = State_Stopped; this->state = State_Stopped;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_Pause(DShowFilter *this)
libAVFilter_Pause(libAVFilter *this)
{ {
dshowdebug("libAVFilter_Pause(%p)\n", this); dshowdebug("ff_dshow_filter_Pause(%p)\n", this);
this->state = State_Paused; this->state = State_Paused;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_Run(DShowFilter *this, REFERENCE_TIME start)
libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
{ {
dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start); dshowdebug("ff_dshow_filter_Run(%p) %"PRId64"\n", this, start);
this->state = State_Running; this->state = State_Running;
this->start_time = start; this->start_time = start;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_GetState(DShowFilter *this, DWORD ms, FILTER_STATE *state)
libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
{ {
dshowdebug("libAVFilter_GetState(%p)\n", this); dshowdebug("ff_dshow_filter_GetState(%p)\n", this);
if (!state) if (!state)
return E_POINTER; return E_POINTER;
*state = this->state; *state = this->state;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_SetSyncSource(DShowFilter *this, IReferenceClock *clock)
libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
{ {
dshowdebug("libAVFilter_SetSyncSource(%p)\n", this); dshowdebug("ff_dshow_filter_SetSyncSource(%p)\n", this);
if (this->clock != clock) { if (this->clock != clock) {
if (this->clock) if (this->clock)
@ -79,10 +73,9 @@ libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_GetSyncSource(DShowFilter *this, IReferenceClock **clock)
libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
{ {
dshowdebug("libAVFilter_GetSyncSource(%p)\n", this); dshowdebug("ff_dshow_filter_GetSyncSource(%p)\n", this);
if (!clock) if (!clock)
return E_POINTER; return E_POINTER;
@ -92,32 +85,30 @@ libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_EnumPins(DShowFilter *this, IEnumPins **enumpin)
libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
{ {
libAVEnumPins *new; DShowEnumPins *new;
dshowdebug("libAVFilter_EnumPins(%p)\n", this); dshowdebug("ff_dshow_filter_EnumPins(%p)\n", this);
if (!enumpin) if (!enumpin)
return E_POINTER; return E_POINTER;
new = libAVEnumPins_Create(this->pin, this); new = ff_dshow_enumpins_Create(this->pin, this);
if (!new) if (!new)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*enumpin = (IEnumPins *) new; *enumpin = (IEnumPins *) new;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_FindPin(DShowFilter *this, const wchar_t *id, IPin **pin)
libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
{ {
libAVPin *found = NULL; DShowPin *found = NULL;
dshowdebug("libAVFilter_FindPin(%p)\n", this); dshowdebug("ff_dshow_filter_FindPin(%p)\n", this);
if (!id || !pin) if (!id || !pin)
return E_POINTER; return E_POINTER;
if (!wcscmp(id, L"In")) { if (!wcscmp(id, L"In")) {
found = this->pin; found = this->pin;
libAVPin_AddRef(found); ff_dshow_pin_AddRef(found);
} }
*pin = (IPin *) found; *pin = (IPin *) found;
if (!found) if (!found)
@ -125,10 +116,9 @@ libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_QueryFilterInfo(DShowFilter *this, FILTER_INFO *info)
libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
{ {
dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this); dshowdebug("ff_dshow_filter_QueryFilterInfo(%p)\n", this);
if (!info) if (!info)
return E_POINTER; return E_POINTER;
@ -138,11 +128,10 @@ libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_JoinFilterGraph(DShowFilter *this, IFilterGraph *graph,
libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
const wchar_t *name) const wchar_t *name)
{ {
dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this); dshowdebug("ff_dshow_filter_JoinFilterGraph(%p)\n", this);
this->info.pGraph = graph; this->info.pGraph = graph;
if (name) if (name)
@ -150,10 +139,9 @@ libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_filter_QueryVendorInfo(DShowFilter *this, wchar_t **info)
libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
{ {
dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this); dshowdebug("ff_dshow_filter_QueryVendorInfo(%p)\n", this);
if (!info) if (!info)
return E_POINTER; return E_POINTER;
@ -161,27 +149,27 @@ libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
} }
static int static int
libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback, ff_dshow_filter_Setup(DShowFilter *this, void *priv_data, void *callback,
enum dshowDeviceType type) enum dshowDeviceType type)
{ {
IBaseFilterVtbl *vtbl = this->vtbl; IBaseFilterVtbl *vtbl = this->vtbl;
SETVTBL(vtbl, libAVFilter, QueryInterface); SETVTBL(vtbl, filter, QueryInterface);
SETVTBL(vtbl, libAVFilter, AddRef); SETVTBL(vtbl, filter, AddRef);
SETVTBL(vtbl, libAVFilter, Release); SETVTBL(vtbl, filter, Release);
SETVTBL(vtbl, libAVFilter, GetClassID); SETVTBL(vtbl, filter, GetClassID);
SETVTBL(vtbl, libAVFilter, Stop); SETVTBL(vtbl, filter, Stop);
SETVTBL(vtbl, libAVFilter, Pause); SETVTBL(vtbl, filter, Pause);
SETVTBL(vtbl, libAVFilter, Run); SETVTBL(vtbl, filter, Run);
SETVTBL(vtbl, libAVFilter, GetState); SETVTBL(vtbl, filter, GetState);
SETVTBL(vtbl, libAVFilter, SetSyncSource); SETVTBL(vtbl, filter, SetSyncSource);
SETVTBL(vtbl, libAVFilter, GetSyncSource); SETVTBL(vtbl, filter, GetSyncSource);
SETVTBL(vtbl, libAVFilter, EnumPins); SETVTBL(vtbl, filter, EnumPins);
SETVTBL(vtbl, libAVFilter, FindPin); SETVTBL(vtbl, filter, FindPin);
SETVTBL(vtbl, libAVFilter, QueryFilterInfo); SETVTBL(vtbl, filter, QueryFilterInfo);
SETVTBL(vtbl, libAVFilter, JoinFilterGraph); SETVTBL(vtbl, filter, JoinFilterGraph);
SETVTBL(vtbl, libAVFilter, QueryVendorInfo); SETVTBL(vtbl, filter, QueryVendorInfo);
this->pin = libAVPin_Create(this); this->pin = ff_dshow_pin_Create(this);
this->priv_data = priv_data; this->priv_data = priv_data;
this->callback = callback; this->callback = callback;
@ -189,12 +177,11 @@ libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
return 1; return 1;
} }
static int static int ff_dshow_filter_Cleanup(DShowFilter *this)
libAVFilter_Cleanup(libAVFilter *this)
{ {
libAVPin_Release(this->pin); ff_dshow_pin_Release(this->pin);
return 1; return 1;
} }
DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type), DECLARE_CREATE(filter, DShowFilter, ff_dshow_filter_Setup(this, priv_data, callback, type),
void *priv_data, void *callback, enum dshowDeviceType type) void *priv_data, void *callback, enum dshowDeviceType type)
DECLARE_DESTROY(libAVFilter, libAVFilter_Cleanup) DECLARE_DESTROY(filter, DShowFilter, ff_dshow_filter_Cleanup)

View File

@ -22,26 +22,24 @@
#include "dshow_capture.h" #include "dshow_capture.h"
#include <stddef.h> #include <stddef.h>
#define imemoffset offsetof(libAVPin, imemvtbl) #define imemoffset offsetof(DShowPin, imemvtbl)
DECLARE_QUERYINTERFACE(libAVPin, DECLARE_QUERYINTERFACE(pin, DShowPin,
{ {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,imemoffset} }) { {&IID_IUnknown,0}, {&IID_IPin,0}, {&IID_IMemInputPin,imemoffset} })
DECLARE_ADDREF(libAVPin) DECLARE_ADDREF(pin, DShowPin)
DECLARE_RELEASE(libAVPin) DECLARE_RELEASE(pin, DShowPin)
long WINAPI long ff_dshow_pin_Connect(DShowPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
libAVPin_Connect(libAVPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
{ {
dshowdebug("libAVPin_Connect(%p, %p, %p)\n", this, pin, type); dshowdebug("ff_dshow_pin_Connect(%p, %p, %p)\n", this, pin, type);
/* Input pins receive connections. */ /* Input pins receive connections. */
return S_FALSE; return S_FALSE;
} }
long WINAPI long ff_dshow_pin_ReceiveConnection(DShowPin *this, IPin *pin,
libAVPin_ReceiveConnection(libAVPin *this, IPin *pin,
const AM_MEDIA_TYPE *type) const AM_MEDIA_TYPE *type)
{ {
enum dshowDeviceType devtype = this->filter->type; enum dshowDeviceType devtype = this->filter->type;
dshowdebug("libAVPin_ReceiveConnection(%p)\n", this); dshowdebug("ff_dshow_pin_ReceiveConnection(%p)\n", this);
if (!pin) if (!pin)
return E_POINTER; return E_POINTER;
@ -64,10 +62,9 @@ libAVPin_ReceiveConnection(libAVPin *this, IPin *pin,
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_Disconnect(DShowPin *this)
libAVPin_Disconnect(libAVPin *this)
{ {
dshowdebug("libAVPin_Disconnect(%p)\n", this); dshowdebug("ff_dshow_pin_Disconnect(%p)\n", this);
if (this->filter->state != State_Stopped) if (this->filter->state != State_Stopped)
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
@ -78,10 +75,9 @@ libAVPin_Disconnect(libAVPin *this)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_ConnectedTo(DShowPin *this, IPin **pin)
libAVPin_ConnectedTo(libAVPin *this, IPin **pin)
{ {
dshowdebug("libAVPin_ConnectedTo(%p)\n", this); dshowdebug("ff_dshow_pin_ConnectedTo(%p)\n", this);
if (!pin) if (!pin)
return E_POINTER; return E_POINTER;
@ -92,10 +88,9 @@ libAVPin_ConnectedTo(libAVPin *this, IPin **pin)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_ConnectionMediaType(DShowPin *this, AM_MEDIA_TYPE *type)
libAVPin_ConnectionMediaType(libAVPin *this, AM_MEDIA_TYPE *type)
{ {
dshowdebug("libAVPin_ConnectionMediaType(%p)\n", this); dshowdebug("ff_dshow_pin_ConnectionMediaType(%p)\n", this);
if (!type) if (!type)
return E_POINTER; return E_POINTER;
@ -104,16 +99,15 @@ libAVPin_ConnectionMediaType(libAVPin *this, AM_MEDIA_TYPE *type)
return ff_copy_dshow_media_type(type, &this->type); return ff_copy_dshow_media_type(type, &this->type);
} }
long WINAPI long ff_dshow_pin_QueryPinInfo(DShowPin *this, PIN_INFO *info)
libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
{ {
dshowdebug("libAVPin_QueryPinInfo(%p)\n", this); dshowdebug("ff_dshow_pin_QueryPinInfo(%p)\n", this);
if (!info) if (!info)
return E_POINTER; return E_POINTER;
if (this->filter) if (this->filter)
libAVFilter_AddRef(this->filter); ff_dshow_filter_AddRef(this->filter);
info->pFilter = (IBaseFilter *) this->filter; info->pFilter = (IBaseFilter *) this->filter;
info->dir = PINDIR_INPUT; info->dir = PINDIR_INPUT;
@ -121,19 +115,17 @@ libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_QueryDirection(DShowPin *this, PIN_DIRECTION *dir)
libAVPin_QueryDirection(libAVPin *this, PIN_DIRECTION *dir)
{ {
dshowdebug("libAVPin_QueryDirection(%p)\n", this); dshowdebug("ff_dshow_pin_QueryDirection(%p)\n", this);
if (!dir) if (!dir)
return E_POINTER; return E_POINTER;
*dir = PINDIR_INPUT; *dir = PINDIR_INPUT;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_QueryId(DShowPin *this, wchar_t **id)
libAVPin_QueryId(libAVPin *this, wchar_t **id)
{ {
dshowdebug("libAVPin_QueryId(%p)\n", this); dshowdebug("ff_dshow_pin_QueryId(%p)\n", this);
if (!id) if (!id)
return E_POINTER; return E_POINTER;
@ -142,67 +134,59 @@ libAVPin_QueryId(libAVPin *this, wchar_t **id)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_QueryAccept(DShowPin *this, const AM_MEDIA_TYPE *type)
libAVPin_QueryAccept(libAVPin *this, const AM_MEDIA_TYPE *type)
{ {
dshowdebug("libAVPin_QueryAccept(%p)\n", this); dshowdebug("ff_dshow_pin_QueryAccept(%p)\n", this);
return S_FALSE; return S_FALSE;
} }
long WINAPI long ff_dshow_pin_EnumMediaTypes(DShowPin *this, IEnumMediaTypes **enumtypes)
libAVPin_EnumMediaTypes(libAVPin *this, IEnumMediaTypes **enumtypes)
{ {
const AM_MEDIA_TYPE *type = NULL; const AM_MEDIA_TYPE *type = NULL;
libAVEnumMediaTypes *new; DShowEnumMediaTypes *new;
dshowdebug("libAVPin_EnumMediaTypes(%p)\n", this); dshowdebug("ff_dshow_pin_EnumMediaTypes(%p)\n", this);
if (!enumtypes) if (!enumtypes)
return E_POINTER; return E_POINTER;
new = libAVEnumMediaTypes_Create(type); new = ff_dshow_enummediatypes_Create(type);
if (!new) if (!new)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
*enumtypes = (IEnumMediaTypes *) new; *enumtypes = (IEnumMediaTypes *) new;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_QueryInternalConnections(DShowPin *this, IPin **pin,
libAVPin_QueryInternalConnections(libAVPin *this, IPin **pin,
unsigned long *npin) unsigned long *npin)
{ {
dshowdebug("libAVPin_QueryInternalConnections(%p)\n", this); dshowdebug("ff_dshow_pin_QueryInternalConnections(%p)\n", this);
return E_NOTIMPL; return E_NOTIMPL;
} }
long WINAPI long ff_dshow_pin_EndOfStream(DShowPin *this)
libAVPin_EndOfStream(libAVPin *this)
{ {
dshowdebug("libAVPin_EndOfStream(%p)\n", this); dshowdebug("ff_dshow_pin_EndOfStream(%p)\n", this);
/* I don't care. */ /* I don't care. */
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_BeginFlush(DShowPin *this)
libAVPin_BeginFlush(libAVPin *this)
{ {
dshowdebug("libAVPin_BeginFlush(%p)\n", this); dshowdebug("ff_dshow_pin_BeginFlush(%p)\n", this);
/* I don't care. */ /* I don't care. */
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_EndFlush(DShowPin *this)
libAVPin_EndFlush(libAVPin *this)
{ {
dshowdebug("libAVPin_EndFlush(%p)\n", this); dshowdebug("ff_dshow_pin_EndFlush(%p)\n", this);
/* I don't care. */ /* I don't care. */
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_pin_NewSegment(DShowPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
libAVPin_NewSegment(libAVPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
double rate) double rate)
{ {
dshowdebug("libAVPin_NewSegment(%p)\n", this); dshowdebug("ff_dshow_pin_NewSegment(%p)\n", this);
/* I don't care. */ /* I don't care. */
return S_OK; return S_OK;
} }
static int static int ff_dshow_pin_Setup(DShowPin *this, DShowFilter *filter)
libAVPin_Setup(libAVPin *this, libAVFilter *filter)
{ {
IPinVtbl *vtbl = this->vtbl; IPinVtbl *vtbl = this->vtbl;
IMemInputPinVtbl *imemvtbl; IMemInputPinVtbl *imemvtbl;
@ -214,44 +198,43 @@ libAVPin_Setup(libAVPin *this, libAVFilter *filter)
if (!imemvtbl) if (!imemvtbl)
return 0; return 0;
SETVTBL(imemvtbl, libAVMemInputPin, QueryInterface); SETVTBL(imemvtbl, meminputpin, QueryInterface);
SETVTBL(imemvtbl, libAVMemInputPin, AddRef); SETVTBL(imemvtbl, meminputpin, AddRef);
SETVTBL(imemvtbl, libAVMemInputPin, Release); SETVTBL(imemvtbl, meminputpin, Release);
SETVTBL(imemvtbl, libAVMemInputPin, GetAllocator); SETVTBL(imemvtbl, meminputpin, GetAllocator);
SETVTBL(imemvtbl, libAVMemInputPin, NotifyAllocator); SETVTBL(imemvtbl, meminputpin, NotifyAllocator);
SETVTBL(imemvtbl, libAVMemInputPin, GetAllocatorRequirements); SETVTBL(imemvtbl, meminputpin, GetAllocatorRequirements);
SETVTBL(imemvtbl, libAVMemInputPin, Receive); SETVTBL(imemvtbl, meminputpin, Receive);
SETVTBL(imemvtbl, libAVMemInputPin, ReceiveMultiple); SETVTBL(imemvtbl, meminputpin, ReceiveMultiple);
SETVTBL(imemvtbl, libAVMemInputPin, ReceiveCanBlock); SETVTBL(imemvtbl, meminputpin, ReceiveCanBlock);
this->imemvtbl = imemvtbl; this->imemvtbl = imemvtbl;
SETVTBL(vtbl, libAVPin, QueryInterface); SETVTBL(vtbl, pin, QueryInterface);
SETVTBL(vtbl, libAVPin, AddRef); SETVTBL(vtbl, pin, AddRef);
SETVTBL(vtbl, libAVPin, Release); SETVTBL(vtbl, pin, Release);
SETVTBL(vtbl, libAVPin, Connect); SETVTBL(vtbl, pin, Connect);
SETVTBL(vtbl, libAVPin, ReceiveConnection); SETVTBL(vtbl, pin, ReceiveConnection);
SETVTBL(vtbl, libAVPin, Disconnect); SETVTBL(vtbl, pin, Disconnect);
SETVTBL(vtbl, libAVPin, ConnectedTo); SETVTBL(vtbl, pin, ConnectedTo);
SETVTBL(vtbl, libAVPin, ConnectionMediaType); SETVTBL(vtbl, pin, ConnectionMediaType);
SETVTBL(vtbl, libAVPin, QueryPinInfo); SETVTBL(vtbl, pin, QueryPinInfo);
SETVTBL(vtbl, libAVPin, QueryDirection); SETVTBL(vtbl, pin, QueryDirection);
SETVTBL(vtbl, libAVPin, QueryId); SETVTBL(vtbl, pin, QueryId);
SETVTBL(vtbl, libAVPin, QueryAccept); SETVTBL(vtbl, pin, QueryAccept);
SETVTBL(vtbl, libAVPin, EnumMediaTypes); SETVTBL(vtbl, pin, EnumMediaTypes);
SETVTBL(vtbl, libAVPin, QueryInternalConnections); SETVTBL(vtbl, pin, QueryInternalConnections);
SETVTBL(vtbl, libAVPin, EndOfStream); SETVTBL(vtbl, pin, EndOfStream);
SETVTBL(vtbl, libAVPin, BeginFlush); SETVTBL(vtbl, pin, BeginFlush);
SETVTBL(vtbl, libAVPin, EndFlush); SETVTBL(vtbl, pin, EndFlush);
SETVTBL(vtbl, libAVPin, NewSegment); SETVTBL(vtbl, pin, NewSegment);
this->filter = filter; this->filter = filter;
return 1; return 1;
} }
static void static void ff_dshow_pin_Free(DShowPin *this)
libAVPin_Free(libAVPin *this)
{ {
if (!this) if (!this)
return; return;
@ -261,58 +244,51 @@ libAVPin_Free(libAVPin *this)
this->type.pbFormat = NULL; this->type.pbFormat = NULL;
} }
} }
DECLARE_CREATE(libAVPin, libAVPin_Setup(this, filter), libAVFilter *filter) DECLARE_CREATE(pin, DShowPin, ff_dshow_pin_Setup(this, filter), DShowFilter *filter)
DECLARE_DESTROY(libAVPin, libAVPin_Free) DECLARE_DESTROY(pin, DShowPin, ff_dshow_pin_Free)
/***************************************************************************** /*****************************************************************************
* libAVMemInputPin * DShowMemInputPin
****************************************************************************/ ****************************************************************************/
long WINAPI long ff_dshow_meminputpin_QueryInterface(DShowMemInputPin *this, const GUID *riid,
libAVMemInputPin_QueryInterface(libAVMemInputPin *this, const GUID *riid,
void **ppvObject) void **ppvObject)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_QueryInterface(%p)\n", this); dshowdebug("ff_dshow_meminputpin_QueryInterface(%p)\n", this);
return libAVPin_QueryInterface(pin, riid, ppvObject); return ff_dshow_pin_QueryInterface(pin, riid, ppvObject);
} }
unsigned long WINAPI unsigned long ff_dshow_meminputpin_AddRef(DShowMemInputPin *this)
libAVMemInputPin_AddRef(libAVMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_AddRef(%p)\n", this); dshowdebug("ff_dshow_meminputpin_AddRef(%p)\n", this);
return libAVPin_AddRef(pin); return ff_dshow_pin_AddRef(pin);
} }
unsigned long WINAPI unsigned long ff_dshow_meminputpin_Release(DShowMemInputPin *this)
libAVMemInputPin_Release(libAVMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_Release(%p)\n", this); dshowdebug("ff_dshow_meminputpin_Release(%p)\n", this);
return libAVPin_Release(pin); return ff_dshow_pin_Release(pin);
} }
long WINAPI long ff_dshow_meminputpin_GetAllocator(DShowMemInputPin *this, IMemAllocator **alloc)
libAVMemInputPin_GetAllocator(libAVMemInputPin *this, IMemAllocator **alloc)
{ {
dshowdebug("libAVMemInputPin_GetAllocator(%p)\n", this); dshowdebug("ff_dshow_meminputpin_GetAllocator(%p)\n", this);
return VFW_E_NO_ALLOCATOR; return VFW_E_NO_ALLOCATOR;
} }
long WINAPI long ff_dshow_meminputpin_NotifyAllocator(DShowMemInputPin *this, IMemAllocator *alloc,
libAVMemInputPin_NotifyAllocator(libAVMemInputPin *this, IMemAllocator *alloc,
BOOL rdwr) BOOL rdwr)
{ {
dshowdebug("libAVMemInputPin_NotifyAllocator(%p)\n", this); dshowdebug("ff_dshow_meminputpin_NotifyAllocator(%p)\n", this);
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *this,
libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *this,
ALLOCATOR_PROPERTIES *props) ALLOCATOR_PROPERTIES *props)
{ {
dshowdebug("libAVMemInputPin_GetAllocatorRequirements(%p)\n", this); dshowdebug("ff_dshow_meminputpin_GetAllocatorRequirements(%p)\n", this);
return E_NOTIMPL; return E_NOTIMPL;
} }
long WINAPI long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
enum dshowDeviceType devtype = pin->filter->type; enum dshowDeviceType devtype = pin->filter->type;
void *priv_data; void *priv_data;
AVFormatContext *s; AVFormatContext *s;
@ -328,7 +304,7 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
struct dshow_ctx *ctx; struct dshow_ctx *ctx;
dshowdebug("libAVMemInputPin_Receive(%p)\n", this); dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this);
if (!sample) if (!sample)
return E_POINTER; return E_POINTER;
@ -366,31 +342,28 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_meminputpin_ReceiveMultiple(DShowMemInputPin *this,
libAVMemInputPin_ReceiveMultiple(libAVMemInputPin *this,
IMediaSample **samples, long n, long *nproc) IMediaSample **samples, long n, long *nproc)
{ {
int i; int i;
dshowdebug("libAVMemInputPin_ReceiveMultiple(%p)\n", this); dshowdebug("ff_dshow_meminputpin_ReceiveMultiple(%p)\n", this);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
libAVMemInputPin_Receive(this, samples[i]); ff_dshow_meminputpin_Receive(this, samples[i]);
*nproc = n; *nproc = n;
return S_OK; return S_OK;
} }
long WINAPI long ff_dshow_meminputpin_ReceiveCanBlock(DShowMemInputPin *this)
libAVMemInputPin_ReceiveCanBlock(libAVMemInputPin *this)
{ {
dshowdebug("libAVMemInputPin_ReceiveCanBlock(%p)\n", this); dshowdebug("ff_dshow_meminputpin_ReceiveCanBlock(%p)\n", this);
/* I swear I will not block. */ /* I swear I will not block. */
return S_FALSE; return S_FALSE;
} }
void void ff_dshow_meminputpin_Destroy(DShowMemInputPin *this)
libAVMemInputPin_Destroy(libAVMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset); DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_Destroy(%p)\n", this); dshowdebug("ff_dshow_meminputpin_Destroy(%p)\n", this);
libAVPin_Destroy(pin); ff_dshow_pin_Destroy(pin);
} }