Browse Source

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

Signed-off-by: James Almer <jamrial@gmail.com>
tags/n4.4
James Almer 4 years ago
parent
commit
911ba8417e
6 changed files with 325 additions and 376 deletions
  1. +9
    -9
      libavdevice/dshow.c
  2. +113
    -113
      libavdevice/dshow_capture.h
  3. +23
    -28
      libavdevice/dshow_enummediatypes.c
  4. +28
    -34
      libavdevice/dshow_enumpins.c
  5. +53
    -66
      libavdevice/dshow_filter.c
  6. +99
    -126
      libavdevice/dshow_pin.c

+ 9
- 9
libavdevice/dshow.c 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;
libAVFilter *capture_filter = NULL;
DShowPin *capture_pin = 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) {


+ 113
- 113
libavdevice/dshow_capture.h View File

@@ -68,20 +68,20 @@ enum dshowSourceFilterType {
AudioSourceDevice = 1, AudioSourceDevice = 1,
}; };


#define DECLARE_QUERYINTERFACE(class, ...) \
long WINAPI \
class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
#define DECLARE_QUERYINTERFACE(prefix, class, ...) \
long \
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) \
unsigned long WINAPI \
class##_AddRef(class *this) \
#define DECLARE_ADDREF(prefix, class) \
unsigned long \
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) \
unsigned long WINAPI \
class##_Release(class *this) \
#define DECLARE_RELEASE(prefix, class) \
unsigned long \
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) \
void class##_Destroy(class *this) \
#define DECLARE_DESTROY(prefix, class, func) \
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, ...) \
class *class##_Create(__VA_ARGS__) \
#define DECLARE_CREATE(prefix, class, setup, ...) \
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); \
dshowdebug("could not create "AV_STRINGIFY(class)"\n"); \
ff_dshow_##prefix##_Destroy(this); \
dshowdebug("could not create ff_dshow_"AV_STRINGIFY(prefix)"\n"); \
return NULL; \ return NULL; \
} }


#define SETVTBL(vtbl, class, fn) \
do { (vtbl)->fn = (void *) class##_##fn; } while(0)
#define SETVTBL(vtbl, prefix, fn) \
do { (vtbl)->fn = (void *) ff_dshow_##prefix##_##fn; } while(0)


/***************************************************************************** /*****************************************************************************
* Forward Declarations * Forward Declarations
****************************************************************************/ ****************************************************************************/
typedef struct libAVPin libAVPin;
typedef struct libAVMemInputPin libAVMemInputPin;
typedef struct libAVEnumPins libAVEnumPins;
typedef struct libAVEnumMediaTypes libAVEnumMediaTypes;
typedef struct libAVFilter libAVFilter;
typedef struct DShowPin DShowPin;
typedef struct DShowMemInputPin DShowMemInputPin;
typedef struct DShowEnumPins DShowEnumPins;
typedef struct DShowEnumMediaTypes DShowEnumMediaTypes;
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 **);
unsigned long WINAPI libAVPin_AddRef (libAVPin *);
unsigned long WINAPI libAVPin_Release (libAVPin *);
long WINAPI libAVPin_Connect (libAVPin *, IPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_ReceiveConnection (libAVPin *, IPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_Disconnect (libAVPin *);
long WINAPI libAVPin_ConnectedTo (libAVPin *, IPin **);
long WINAPI libAVPin_ConnectionMediaType (libAVPin *, AM_MEDIA_TYPE *);
long WINAPI libAVPin_QueryPinInfo (libAVPin *, PIN_INFO *);
long WINAPI libAVPin_QueryDirection (libAVPin *, PIN_DIRECTION *);
long WINAPI libAVPin_QueryId (libAVPin *, wchar_t **);
long WINAPI libAVPin_QueryAccept (libAVPin *, const AM_MEDIA_TYPE *);
long WINAPI libAVPin_EnumMediaTypes (libAVPin *, IEnumMediaTypes **);
long WINAPI libAVPin_QueryInternalConnections(libAVPin *, IPin **, unsigned long *);
long WINAPI libAVPin_EndOfStream (libAVPin *);
long WINAPI libAVPin_BeginFlush (libAVPin *);
long WINAPI libAVPin_EndFlush (libAVPin *);
long WINAPI libAVPin_NewSegment (libAVPin *, REFERENCE_TIME, REFERENCE_TIME, double);
long WINAPI libAVMemInputPin_QueryInterface (libAVMemInputPin *, const GUID *, void **);
unsigned long WINAPI libAVMemInputPin_AddRef (libAVMemInputPin *);
unsigned long WINAPI libAVMemInputPin_Release (libAVMemInputPin *);
long WINAPI libAVMemInputPin_GetAllocator (libAVMemInputPin *, IMemAllocator **);
long WINAPI libAVMemInputPin_NotifyAllocator (libAVMemInputPin *, IMemAllocator *, BOOL);
long WINAPI libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *, ALLOCATOR_PROPERTIES *);
long WINAPI libAVMemInputPin_Receive (libAVMemInputPin *, IMediaSample *);
long WINAPI libAVMemInputPin_ReceiveMultiple (libAVMemInputPin *, IMediaSample **, long, long *);
long WINAPI libAVMemInputPin_ReceiveCanBlock (libAVMemInputPin *);
void libAVPin_Destroy(libAVPin *);
libAVPin *libAVPin_Create (libAVFilter *filter);
void libAVMemInputPin_Destroy(libAVMemInputPin *);
long ff_dshow_pin_QueryInterface (DShowPin *, const GUID *, void **);
unsigned long ff_dshow_pin_AddRef (DShowPin *);
unsigned long ff_dshow_pin_Release (DShowPin *);
long ff_dshow_pin_Connect (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
long ff_dshow_pin_ReceiveConnection (DShowPin *, IPin *, const AM_MEDIA_TYPE *);
long ff_dshow_pin_Disconnect (DShowPin *);
long ff_dshow_pin_ConnectedTo (DShowPin *, IPin **);
long ff_dshow_pin_ConnectionMediaType (DShowPin *, AM_MEDIA_TYPE *);
long ff_dshow_pin_QueryPinInfo (DShowPin *, PIN_INFO *);
long ff_dshow_pin_QueryDirection (DShowPin *, PIN_DIRECTION *);
long ff_dshow_pin_QueryId (DShowPin *, wchar_t **);
long ff_dshow_pin_QueryAccept (DShowPin *, const AM_MEDIA_TYPE *);
long ff_dshow_pin_EnumMediaTypes (DShowPin *, IEnumMediaTypes **);
long ff_dshow_pin_QueryInternalConnections(DShowPin *, IPin **, unsigned long *);
long ff_dshow_pin_EndOfStream (DShowPin *);
long ff_dshow_pin_BeginFlush (DShowPin *);
long ff_dshow_pin_EndFlush (DShowPin *);
long ff_dshow_pin_NewSegment (DShowPin *, REFERENCE_TIME, REFERENCE_TIME, double);
long ff_dshow_meminputpin_QueryInterface (DShowMemInputPin *, const GUID *, void **);
unsigned long ff_dshow_meminputpin_AddRef (DShowMemInputPin *);
unsigned long ff_dshow_meminputpin_Release (DShowMemInputPin *);
long ff_dshow_meminputpin_GetAllocator (DShowMemInputPin *, IMemAllocator **);
long ff_dshow_meminputpin_NotifyAllocator (DShowMemInputPin *, IMemAllocator *, BOOL);
long ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *, ALLOCATOR_PROPERTIES *);
long ff_dshow_meminputpin_Receive (DShowMemInputPin *, IMediaSample *);
long ff_dshow_meminputpin_ReceiveMultiple (DShowMemInputPin *, IMediaSample **, long, long *);
long ff_dshow_meminputpin_ReceiveCanBlock (DShowMemInputPin *);
void ff_dshow_pin_Destroy(DShowPin *);
DShowPin *ff_dshow_pin_Create (DShowFilter *filter);
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;
libAVFilter *filter;
DShowPin *pin;
DShowFilter *filter;
}; };


long WINAPI libAVEnumPins_QueryInterface(libAVEnumPins *, const GUID *, void **);
unsigned long WINAPI libAVEnumPins_AddRef (libAVEnumPins *);
unsigned long WINAPI libAVEnumPins_Release (libAVEnumPins *);
long WINAPI libAVEnumPins_Next (libAVEnumPins *, unsigned long, IPin **, unsigned long *);
long WINAPI libAVEnumPins_Skip (libAVEnumPins *, unsigned long);
long WINAPI libAVEnumPins_Reset (libAVEnumPins *);
long WINAPI libAVEnumPins_Clone (libAVEnumPins *, libAVEnumPins **);
long ff_dshow_enumpins_QueryInterface(DShowEnumPins *, const GUID *, void **);
unsigned long ff_dshow_enumpins_AddRef (DShowEnumPins *);
unsigned long ff_dshow_enumpins_Release (DShowEnumPins *);
long ff_dshow_enumpins_Next (DShowEnumPins *, unsigned long, IPin **, unsigned long *);
long ff_dshow_enumpins_Skip (DShowEnumPins *, unsigned long);
long ff_dshow_enumpins_Reset (DShowEnumPins *);
long ff_dshow_enumpins_Clone (DShowEnumPins *, DShowEnumPins **);


void libAVEnumPins_Destroy(libAVEnumPins *);
libAVEnumPins *libAVEnumPins_Create (libAVPin *pin, libAVFilter *filter);
void ff_dshow_enumpins_Destroy(DShowEnumPins *);
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 **);
unsigned long WINAPI libAVEnumMediaTypes_AddRef (libAVEnumMediaTypes *);
unsigned long WINAPI libAVEnumMediaTypes_Release (libAVEnumMediaTypes *);
long WINAPI libAVEnumMediaTypes_Next (libAVEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *);
long WINAPI libAVEnumMediaTypes_Skip (libAVEnumMediaTypes *, unsigned long);
long WINAPI libAVEnumMediaTypes_Reset (libAVEnumMediaTypes *);
long WINAPI libAVEnumMediaTypes_Clone (libAVEnumMediaTypes *, libAVEnumMediaTypes **);
long ff_dshow_enummediatypes_QueryInterface(DShowEnumMediaTypes *, const GUID *, void **);
unsigned long ff_dshow_enummediatypes_AddRef (DShowEnumMediaTypes *);
unsigned long ff_dshow_enummediatypes_Release (DShowEnumMediaTypes *);
long ff_dshow_enummediatypes_Next (DShowEnumMediaTypes *, unsigned long, AM_MEDIA_TYPE **, unsigned long *);
long ff_dshow_enummediatypes_Skip (DShowEnumMediaTypes *, unsigned long);
long ff_dshow_enummediatypes_Reset (DShowEnumMediaTypes *);
long ff_dshow_enummediatypes_Clone (DShowEnumMediaTypes *, DShowEnumMediaTypes **);


void libAVEnumMediaTypes_Destroy(libAVEnumMediaTypes *);
libAVEnumMediaTypes *libAVEnumMediaTypes_Create(const AM_MEDIA_TYPE *type);
void ff_dshow_enummediatypes_Destroy(DShowEnumMediaTypes *);
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 **);
unsigned long WINAPI libAVFilter_AddRef (libAVFilter *);
unsigned long WINAPI libAVFilter_Release (libAVFilter *);
long WINAPI libAVFilter_GetClassID (libAVFilter *, CLSID *);
long WINAPI libAVFilter_Stop (libAVFilter *);
long WINAPI libAVFilter_Pause (libAVFilter *);
long WINAPI libAVFilter_Run (libAVFilter *, REFERENCE_TIME);
long WINAPI libAVFilter_GetState (libAVFilter *, DWORD, FILTER_STATE *);
long WINAPI libAVFilter_SetSyncSource (libAVFilter *, IReferenceClock *);
long WINAPI libAVFilter_GetSyncSource (libAVFilter *, IReferenceClock **);
long WINAPI libAVFilter_EnumPins (libAVFilter *, IEnumPins **);
long WINAPI libAVFilter_FindPin (libAVFilter *, const wchar_t *, IPin **);
long WINAPI libAVFilter_QueryFilterInfo(libAVFilter *, FILTER_INFO *);
long WINAPI libAVFilter_JoinFilterGraph(libAVFilter *, IFilterGraph *, const wchar_t *);
long WINAPI libAVFilter_QueryVendorInfo(libAVFilter *, wchar_t **);
void libAVFilter_Destroy(libAVFilter *);
libAVFilter *libAVFilter_Create (void *, void *, enum dshowDeviceType);
long ff_dshow_filter_QueryInterface (DShowFilter *, const GUID *, void **);
unsigned long ff_dshow_filter_AddRef (DShowFilter *);
unsigned long ff_dshow_filter_Release (DShowFilter *);
long ff_dshow_filter_GetClassID (DShowFilter *, CLSID *);
long ff_dshow_filter_Stop (DShowFilter *);
long ff_dshow_filter_Pause (DShowFilter *);
long ff_dshow_filter_Run (DShowFilter *, REFERENCE_TIME);
long ff_dshow_filter_GetState (DShowFilter *, DWORD, FILTER_STATE *);
long ff_dshow_filter_SetSyncSource (DShowFilter *, IReferenceClock *);
long ff_dshow_filter_GetSyncSource (DShowFilter *, IReferenceClock **);
long ff_dshow_filter_EnumPins (DShowFilter *, IEnumPins **);
long ff_dshow_filter_FindPin (DShowFilter *, const wchar_t *, IPin **);
long ff_dshow_filter_QueryFilterInfo(DShowFilter *, FILTER_INFO *);
long ff_dshow_filter_JoinFilterGraph(DShowFilter *, IFilterGraph *, const wchar_t *);
long ff_dshow_filter_QueryVendorInfo(DShowFilter *, wchar_t **);
void ff_dshow_filter_Destroy(DShowFilter *);
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];
libAVPin *capture_pin[2];
DShowFilter *capture_filter[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


+ 23
- 28
libavdevice/dshow_enummediatypes.c 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_RELEASE(libAVEnumMediaTypes)
DECLARE_ADDREF(enummediatypes, DShowEnumMediaTypes)
DECLARE_RELEASE(enummediatypes, DShowEnumMediaTypes)


long WINAPI
libAVEnumMediaTypes_Next(libAVEnumMediaTypes *this, unsigned long n,
long ff_dshow_enummediatypes_Next(DShowEnumMediaTypes *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
libAVEnumMediaTypes_Skip(libAVEnumMediaTypes *this, unsigned long n)
long ff_dshow_enummediatypes_Skip(DShowEnumMediaTypes *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
libAVEnumMediaTypes_Reset(libAVEnumMediaTypes *this)
long ff_dshow_enummediatypes_Reset(DShowEnumMediaTypes *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
libAVEnumMediaTypes_Clone(libAVEnumMediaTypes *this, libAVEnumMediaTypes **enums)
long ff_dshow_enummediatypes_Clone(DShowEnumMediaTypes *this, DShowEnumMediaTypes **enums)
{ {
libAVEnumMediaTypes *new;
dshowdebug("libAVEnumMediaTypes_Clone(%p)\n", this);
DShowEnumMediaTypes *new;
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
libAVEnumMediaTypes_Setup(libAVEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
static int ff_dshow_enummediatypes_Setup(DShowEnumMediaTypes *this, const AM_MEDIA_TYPE *type)
{ {
IEnumMediaTypesVtbl *vtbl = this->vtbl; IEnumMediaTypesVtbl *vtbl = this->vtbl;
SETVTBL(vtbl, libAVEnumMediaTypes, QueryInterface);
SETVTBL(vtbl, libAVEnumMediaTypes, AddRef);
SETVTBL(vtbl, libAVEnumMediaTypes, Release);
SETVTBL(vtbl, libAVEnumMediaTypes, Next);
SETVTBL(vtbl, libAVEnumMediaTypes, Skip);
SETVTBL(vtbl, libAVEnumMediaTypes, Reset);
SETVTBL(vtbl, libAVEnumMediaTypes, Clone);
SETVTBL(vtbl, enummediatypes, QueryInterface);
SETVTBL(vtbl, enummediatypes, AddRef);
SETVTBL(vtbl, enummediatypes, Release);
SETVTBL(vtbl, enummediatypes, Next);
SETVTBL(vtbl, enummediatypes, Skip);
SETVTBL(vtbl, enummediatypes, Reset);
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_DESTROY(libAVEnumMediaTypes, nothing)
DECLARE_CREATE(enummediatypes, DShowEnumMediaTypes, ff_dshow_enummediatypes_Setup(this, type), const AM_MEDIA_TYPE *type)
DECLARE_DESTROY(enummediatypes, DShowEnumMediaTypes, nothing)

+ 28
- 34
libavdevice/dshow_enumpins.c 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_RELEASE(libAVEnumPins)
DECLARE_ADDREF(enumpins, DShowEnumPins)
DECLARE_RELEASE(enumpins, DShowEnumPins)


long WINAPI
libAVEnumPins_Next(libAVEnumPins *this, unsigned long n, IPin **pins,
long ff_dshow_enumpins_Next(DShowEnumPins *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
libAVEnumPins_Skip(libAVEnumPins *this, unsigned long n)
long ff_dshow_enumpins_Skip(DShowEnumPins *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
libAVEnumPins_Reset(libAVEnumPins *this)
long ff_dshow_enumpins_Reset(DShowEnumPins *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
libAVEnumPins_Clone(libAVEnumPins *this, libAVEnumPins **pins)
long ff_dshow_enumpins_Clone(DShowEnumPins *this, DShowEnumPins **pins)
{ {
libAVEnumPins *new;
dshowdebug("libAVEnumPins_Clone(%p)\n", this);
DShowEnumPins *new;
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
libAVEnumPins_Setup(libAVEnumPins *this, libAVPin *pin, libAVFilter *filter)
static int ff_dshow_enumpins_Setup(DShowEnumPins *this, DShowPin *pin, DShowFilter *filter)
{ {
IEnumPinsVtbl *vtbl = this->vtbl; IEnumPinsVtbl *vtbl = this->vtbl;
SETVTBL(vtbl, libAVEnumPins, QueryInterface);
SETVTBL(vtbl, libAVEnumPins, AddRef);
SETVTBL(vtbl, libAVEnumPins, Release);
SETVTBL(vtbl, libAVEnumPins, Next);
SETVTBL(vtbl, libAVEnumPins, Skip);
SETVTBL(vtbl, libAVEnumPins, Reset);
SETVTBL(vtbl, libAVEnumPins, Clone);
SETVTBL(vtbl, enumpins, QueryInterface);
SETVTBL(vtbl, enumpins, AddRef);
SETVTBL(vtbl, enumpins, Release);
SETVTBL(vtbl, enumpins, Next);
SETVTBL(vtbl, enumpins, Skip);
SETVTBL(vtbl, enumpins, Reset);
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
libAVEnumPins_Cleanup(libAVEnumPins *this)
static int ff_dshow_enumpins_Cleanup(DShowEnumPins *this)
{ {
libAVFilter_Release(this->filter);
ff_dshow_filter_Release(this->filter);
return 1; return 1;
} }
DECLARE_CREATE(libAVEnumPins, libAVEnumPins_Setup(this, pin, filter),
libAVPin *pin, libAVFilter *filter)
DECLARE_DESTROY(libAVEnumPins, libAVEnumPins_Cleanup)
DECLARE_CREATE(enumpins, DShowEnumPins, ff_dshow_enumpins_Setup(this, pin, filter),
DShowPin *pin, DShowFilter *filter)
DECLARE_DESTROY(enumpins, DShowEnumPins, ff_dshow_enumpins_Cleanup)

+ 53
- 66
libavdevice/dshow_filter.c 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_RELEASE(libAVFilter)
DECLARE_ADDREF(filter, DShowFilter)
DECLARE_RELEASE(filter, DShowFilter)


long WINAPI
libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
long ff_dshow_filter_GetClassID(DShowFilter *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
libAVFilter_Stop(libAVFilter *this)
long ff_dshow_filter_Stop(DShowFilter *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
libAVFilter_Pause(libAVFilter *this)
long ff_dshow_filter_Pause(DShowFilter *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
libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
long ff_dshow_filter_Run(DShowFilter *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
libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
long ff_dshow_filter_GetState(DShowFilter *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
libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
long ff_dshow_filter_SetSyncSource(DShowFilter *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
libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
long ff_dshow_filter_GetSyncSource(DShowFilter *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
libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
long ff_dshow_filter_EnumPins(DShowFilter *this, IEnumPins **enumpin)
{ {
libAVEnumPins *new;
dshowdebug("libAVFilter_EnumPins(%p)\n", this);
DShowEnumPins *new;
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
libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
long ff_dshow_filter_FindPin(DShowFilter *this, const wchar_t *id, IPin **pin)
{ {
libAVPin *found = NULL;
dshowdebug("libAVFilter_FindPin(%p)\n", this);
DShowPin *found = NULL;
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
libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
long ff_dshow_filter_QueryFilterInfo(DShowFilter *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
libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
long ff_dshow_filter_JoinFilterGraph(DShowFilter *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
libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
long ff_dshow_filter_QueryVendorInfo(DShowFilter *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, libAVFilter, AddRef);
SETVTBL(vtbl, libAVFilter, Release);
SETVTBL(vtbl, libAVFilter, GetClassID);
SETVTBL(vtbl, libAVFilter, Stop);
SETVTBL(vtbl, libAVFilter, Pause);
SETVTBL(vtbl, libAVFilter, Run);
SETVTBL(vtbl, libAVFilter, GetState);
SETVTBL(vtbl, libAVFilter, SetSyncSource);
SETVTBL(vtbl, libAVFilter, GetSyncSource);
SETVTBL(vtbl, libAVFilter, EnumPins);
SETVTBL(vtbl, libAVFilter, FindPin);
SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
this->pin = libAVPin_Create(this);
SETVTBL(vtbl, filter, QueryInterface);
SETVTBL(vtbl, filter, AddRef);
SETVTBL(vtbl, filter, Release);
SETVTBL(vtbl, filter, GetClassID);
SETVTBL(vtbl, filter, Stop);
SETVTBL(vtbl, filter, Pause);
SETVTBL(vtbl, filter, Run);
SETVTBL(vtbl, filter, GetState);
SETVTBL(vtbl, filter, SetSyncSource);
SETVTBL(vtbl, filter, GetSyncSource);
SETVTBL(vtbl, filter, EnumPins);
SETVTBL(vtbl, filter, FindPin);
SETVTBL(vtbl, filter, QueryFilterInfo);
SETVTBL(vtbl, filter, JoinFilterGraph);
SETVTBL(vtbl, filter, QueryVendorInfo);
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
libAVFilter_Cleanup(libAVFilter *this)
static int ff_dshow_filter_Cleanup(DShowFilter *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)

+ 99
- 126
libavdevice/dshow_pin.c 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_RELEASE(libAVPin)
DECLARE_ADDREF(pin, DShowPin)
DECLARE_RELEASE(pin, DShowPin)


long WINAPI
libAVPin_Connect(libAVPin *this, IPin *pin, const AM_MEDIA_TYPE *type)
long ff_dshow_pin_Connect(DShowPin *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
libAVPin_ReceiveConnection(libAVPin *this, IPin *pin,
long ff_dshow_pin_ReceiveConnection(DShowPin *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
libAVPin_Disconnect(libAVPin *this)
long ff_dshow_pin_Disconnect(DShowPin *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
libAVPin_ConnectedTo(libAVPin *this, IPin **pin)
long ff_dshow_pin_ConnectedTo(DShowPin *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
libAVPin_ConnectionMediaType(libAVPin *this, AM_MEDIA_TYPE *type)
long ff_dshow_pin_ConnectionMediaType(DShowPin *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
libAVPin_QueryPinInfo(libAVPin *this, PIN_INFO *info)
long ff_dshow_pin_QueryPinInfo(DShowPin *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
libAVPin_QueryDirection(libAVPin *this, PIN_DIRECTION *dir)
long ff_dshow_pin_QueryDirection(DShowPin *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
libAVPin_QueryId(libAVPin *this, wchar_t **id)
long ff_dshow_pin_QueryId(DShowPin *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
libAVPin_QueryAccept(libAVPin *this, const AM_MEDIA_TYPE *type)
long ff_dshow_pin_QueryAccept(DShowPin *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
libAVPin_EnumMediaTypes(libAVPin *this, IEnumMediaTypes **enumtypes)
long ff_dshow_pin_EnumMediaTypes(DShowPin *this, IEnumMediaTypes **enumtypes)
{ {
const AM_MEDIA_TYPE *type = NULL; const AM_MEDIA_TYPE *type = NULL;
libAVEnumMediaTypes *new;
dshowdebug("libAVPin_EnumMediaTypes(%p)\n", this);
DShowEnumMediaTypes *new;
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
libAVPin_QueryInternalConnections(libAVPin *this, IPin **pin,
long ff_dshow_pin_QueryInternalConnections(DShowPin *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
libAVPin_EndOfStream(libAVPin *this)
long ff_dshow_pin_EndOfStream(DShowPin *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
libAVPin_BeginFlush(libAVPin *this)
long ff_dshow_pin_BeginFlush(DShowPin *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
libAVPin_EndFlush(libAVPin *this)
long ff_dshow_pin_EndFlush(DShowPin *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
libAVPin_NewSegment(libAVPin *this, REFERENCE_TIME start, REFERENCE_TIME stop,
long ff_dshow_pin_NewSegment(DShowPin *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
libAVPin_Setup(libAVPin *this, libAVFilter *filter)
static int ff_dshow_pin_Setup(DShowPin *this, DShowFilter *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, libAVMemInputPin, AddRef);
SETVTBL(imemvtbl, libAVMemInputPin, Release);
SETVTBL(imemvtbl, libAVMemInputPin, GetAllocator);
SETVTBL(imemvtbl, libAVMemInputPin, NotifyAllocator);
SETVTBL(imemvtbl, libAVMemInputPin, GetAllocatorRequirements);
SETVTBL(imemvtbl, libAVMemInputPin, Receive);
SETVTBL(imemvtbl, libAVMemInputPin, ReceiveMultiple);
SETVTBL(imemvtbl, libAVMemInputPin, ReceiveCanBlock);
SETVTBL(imemvtbl, meminputpin, QueryInterface);
SETVTBL(imemvtbl, meminputpin, AddRef);
SETVTBL(imemvtbl, meminputpin, Release);
SETVTBL(imemvtbl, meminputpin, GetAllocator);
SETVTBL(imemvtbl, meminputpin, NotifyAllocator);
SETVTBL(imemvtbl, meminputpin, GetAllocatorRequirements);
SETVTBL(imemvtbl, meminputpin, Receive);
SETVTBL(imemvtbl, meminputpin, ReceiveMultiple);
SETVTBL(imemvtbl, meminputpin, ReceiveCanBlock);


this->imemvtbl = imemvtbl; this->imemvtbl = imemvtbl;


SETVTBL(vtbl, libAVPin, QueryInterface);
SETVTBL(vtbl, libAVPin, AddRef);
SETVTBL(vtbl, libAVPin, Release);
SETVTBL(vtbl, libAVPin, Connect);
SETVTBL(vtbl, libAVPin, ReceiveConnection);
SETVTBL(vtbl, libAVPin, Disconnect);
SETVTBL(vtbl, libAVPin, ConnectedTo);
SETVTBL(vtbl, libAVPin, ConnectionMediaType);
SETVTBL(vtbl, libAVPin, QueryPinInfo);
SETVTBL(vtbl, libAVPin, QueryDirection);
SETVTBL(vtbl, libAVPin, QueryId);
SETVTBL(vtbl, libAVPin, QueryAccept);
SETVTBL(vtbl, libAVPin, EnumMediaTypes);
SETVTBL(vtbl, libAVPin, QueryInternalConnections);
SETVTBL(vtbl, libAVPin, EndOfStream);
SETVTBL(vtbl, libAVPin, BeginFlush);
SETVTBL(vtbl, libAVPin, EndFlush);
SETVTBL(vtbl, libAVPin, NewSegment);
SETVTBL(vtbl, pin, QueryInterface);
SETVTBL(vtbl, pin, AddRef);
SETVTBL(vtbl, pin, Release);
SETVTBL(vtbl, pin, Connect);
SETVTBL(vtbl, pin, ReceiveConnection);
SETVTBL(vtbl, pin, Disconnect);
SETVTBL(vtbl, pin, ConnectedTo);
SETVTBL(vtbl, pin, ConnectionMediaType);
SETVTBL(vtbl, pin, QueryPinInfo);
SETVTBL(vtbl, pin, QueryDirection);
SETVTBL(vtbl, pin, QueryId);
SETVTBL(vtbl, pin, QueryAccept);
SETVTBL(vtbl, pin, EnumMediaTypes);
SETVTBL(vtbl, pin, QueryInternalConnections);
SETVTBL(vtbl, pin, EndOfStream);
SETVTBL(vtbl, pin, BeginFlush);
SETVTBL(vtbl, pin, EndFlush);
SETVTBL(vtbl, pin, NewSegment);


this->filter = filter; this->filter = filter;


return 1; return 1;
} }


static void
libAVPin_Free(libAVPin *this)
static void ff_dshow_pin_Free(DShowPin *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_DESTROY(libAVPin, libAVPin_Free)
DECLARE_CREATE(pin, DShowPin, ff_dshow_pin_Setup(this, filter), DShowFilter *filter)
DECLARE_DESTROY(pin, DShowPin, ff_dshow_pin_Free)


/***************************************************************************** /*****************************************************************************
* libAVMemInputPin
* DShowMemInputPin
****************************************************************************/ ****************************************************************************/
long WINAPI
libAVMemInputPin_QueryInterface(libAVMemInputPin *this, const GUID *riid,
long ff_dshow_meminputpin_QueryInterface(DShowMemInputPin *this, const GUID *riid,
void **ppvObject) void **ppvObject)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_QueryInterface(%p)\n", this);
return libAVPin_QueryInterface(pin, riid, ppvObject);
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("ff_dshow_meminputpin_QueryInterface(%p)\n", this);
return ff_dshow_pin_QueryInterface(pin, riid, ppvObject);
} }
unsigned long WINAPI
libAVMemInputPin_AddRef(libAVMemInputPin *this)
unsigned long ff_dshow_meminputpin_AddRef(DShowMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_AddRef(%p)\n", this);
return libAVPin_AddRef(pin);
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("ff_dshow_meminputpin_AddRef(%p)\n", this);
return ff_dshow_pin_AddRef(pin);
} }
unsigned long WINAPI
libAVMemInputPin_Release(libAVMemInputPin *this)
unsigned long ff_dshow_meminputpin_Release(DShowMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_Release(%p)\n", this);
return libAVPin_Release(pin);
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("ff_dshow_meminputpin_Release(%p)\n", this);
return ff_dshow_pin_Release(pin);
} }
long WINAPI
libAVMemInputPin_GetAllocator(libAVMemInputPin *this, IMemAllocator **alloc)
long ff_dshow_meminputpin_GetAllocator(DShowMemInputPin *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
libAVMemInputPin_NotifyAllocator(libAVMemInputPin *this, IMemAllocator *alloc,
long ff_dshow_meminputpin_NotifyAllocator(DShowMemInputPin *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
libAVMemInputPin_GetAllocatorRequirements(libAVMemInputPin *this,
long ff_dshow_meminputpin_GetAllocatorRequirements(DShowMemInputPin *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
libAVMemInputPin_Receive(libAVMemInputPin *this, IMediaSample *sample)
long ff_dshow_meminputpin_Receive(DShowMemInputPin *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
libAVMemInputPin_ReceiveMultiple(libAVMemInputPin *this,
long ff_dshow_meminputpin_ReceiveMultiple(DShowMemInputPin *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
libAVMemInputPin_ReceiveCanBlock(libAVMemInputPin *this)
long ff_dshow_meminputpin_ReceiveCanBlock(DShowMemInputPin *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
libAVMemInputPin_Destroy(libAVMemInputPin *this)
void ff_dshow_meminputpin_Destroy(DShowMemInputPin *this)
{ {
libAVPin *pin = (libAVPin *) ((uint8_t *) this - imemoffset);
dshowdebug("libAVMemInputPin_Destroy(%p)\n", this);
libAVPin_Destroy(pin);
DShowPin *pin = (DShowPin *) ((uint8_t *) this - imemoffset);
dshowdebug("ff_dshow_meminputpin_Destroy(%p)\n", this);
ff_dshow_pin_Destroy(pin);
} }

Loading…
Cancel
Save