00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #define NO_DSHOW_STRSAFE
00023 #include "dshow_capture.h"
00024
00025 DECLARE_QUERYINTERFACE(libAVFilter,
00026 { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
00027 DECLARE_ADDREF(libAVFilter)
00028 DECLARE_RELEASE(libAVFilter)
00029
00030 long WINAPI
00031 libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
00032 {
00033 dshowdebug("libAVFilter_GetClassID(%p)\n", this);
00034
00035 return E_FAIL;
00036 }
00037 long WINAPI
00038 libAVFilter_Stop(libAVFilter *this)
00039 {
00040 dshowdebug("libAVFilter_Stop(%p)\n", this);
00041 this->state = State_Stopped;
00042 return S_OK;
00043 }
00044 long WINAPI
00045 libAVFilter_Pause(libAVFilter *this)
00046 {
00047 dshowdebug("libAVFilter_Pause(%p)\n", this);
00048 this->state = State_Paused;
00049 return S_OK;
00050 }
00051 long WINAPI
00052 libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
00053 {
00054 dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
00055 this->state = State_Running;
00056 this->start_time = start;
00057 return S_OK;
00058 }
00059 long WINAPI
00060 libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
00061 {
00062 dshowdebug("libAVFilter_GetState(%p)\n", this);
00063 if (!state)
00064 return E_POINTER;
00065 *state = this->state;
00066 return S_OK;
00067 }
00068 long WINAPI
00069 libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
00070 {
00071 dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
00072
00073 if (this->clock != clock) {
00074 if (this->clock)
00075 IReferenceClock_Release(this->clock);
00076 this->clock = clock;
00077 if (clock)
00078 IReferenceClock_AddRef(clock);
00079 }
00080
00081 return S_OK;
00082 }
00083 long WINAPI
00084 libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
00085 {
00086 dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
00087
00088 if (!clock)
00089 return E_POINTER;
00090 if (this->clock)
00091 IReferenceClock_AddRef(this->clock);
00092 *clock = this->clock;
00093
00094 return S_OK;
00095 }
00096 long WINAPI
00097 libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
00098 {
00099 libAVEnumPins *new;
00100 dshowdebug("libAVFilter_EnumPins(%p)\n", this);
00101
00102 if (!enumpin)
00103 return E_POINTER;
00104 new = libAVEnumPins_Create(this->pin, this);
00105 if (!new)
00106 return E_OUTOFMEMORY;
00107
00108 *enumpin = (IEnumPins *) new;
00109 return S_OK;
00110 }
00111 long WINAPI
00112 libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
00113 {
00114 libAVPin *found = NULL;
00115 dshowdebug("libAVFilter_FindPin(%p)\n", this);
00116
00117 if (!id || !pin)
00118 return E_POINTER;
00119 if (!wcscmp(id, L"In")) {
00120 found = this->pin;
00121 libAVPin_AddRef(found);
00122 }
00123 *pin = (IPin *) found;
00124 if (!found)
00125 return VFW_E_NOT_FOUND;
00126
00127 return S_OK;
00128 }
00129 long WINAPI
00130 libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
00131 {
00132 dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
00133
00134 if (!info)
00135 return E_POINTER;
00136 if (this->info.pGraph)
00137 IFilterGraph_AddRef(this->info.pGraph);
00138 *info = this->info;
00139
00140 return S_OK;
00141 }
00142 long WINAPI
00143 libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
00144 const wchar_t *name)
00145 {
00146 dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
00147
00148 this->info.pGraph = graph;
00149 if (name)
00150 wcscpy(this->info.achName, name);
00151
00152 return S_OK;
00153 }
00154 long WINAPI
00155 libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
00156 {
00157 dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
00158
00159 if (!info)
00160 return E_POINTER;
00161 *info = wcsdup(L"libAV");
00162
00163 return S_OK;
00164 }
00165
00166 static int
00167 libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
00168 enum dshowDeviceType type)
00169 {
00170 IBaseFilterVtbl *vtbl = this->vtbl;
00171 SETVTBL(vtbl, libAVFilter, QueryInterface);
00172 SETVTBL(vtbl, libAVFilter, AddRef);
00173 SETVTBL(vtbl, libAVFilter, Release);
00174 SETVTBL(vtbl, libAVFilter, GetClassID);
00175 SETVTBL(vtbl, libAVFilter, Stop);
00176 SETVTBL(vtbl, libAVFilter, Pause);
00177 SETVTBL(vtbl, libAVFilter, Run);
00178 SETVTBL(vtbl, libAVFilter, GetState);
00179 SETVTBL(vtbl, libAVFilter, SetSyncSource);
00180 SETVTBL(vtbl, libAVFilter, GetSyncSource);
00181 SETVTBL(vtbl, libAVFilter, EnumPins);
00182 SETVTBL(vtbl, libAVFilter, FindPin);
00183 SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
00184 SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
00185 SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
00186
00187 this->pin = libAVPin_Create(this);
00188
00189 this->priv_data = priv_data;
00190 this->callback = callback;
00191 this->type = type;
00192
00193 return 1;
00194 }
00195 static int
00196 libAVFilter_Cleanup(libAVFilter *this)
00197 {
00198 libAVPin_Release(this->pin);
00199 return 1;
00200 }
00201 DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type),
00202 void *priv_data, void *callback, enum dshowDeviceType type)
00203 DECLARE_DESTROY(libAVFilter, libAVFilter_Cleanup)