2 * DirectShow capture interface
3 * Copyright (c) 2010 Ramiro Polla
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "dshow_capture.h"
24 DECLARE_QUERYINTERFACE(libAVFilter,
25 { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
26 DECLARE_ADDREF(libAVFilter)
27 DECLARE_RELEASE(libAVFilter)
30 libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
32 dshowdebug("libAVFilter_GetClassID(%p)\n", this);
33 /* I'm not creating a ClassID just for this. */
37 libAVFilter_Stop(libAVFilter *this)
39 dshowdebug("libAVFilter_Stop(%p)\n", this);
40 this->state = State_Stopped;
44 libAVFilter_Pause(libAVFilter *this)
46 dshowdebug("libAVFilter_Pause(%p)\n", this);
47 this->state = State_Paused;
51 libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
53 dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
54 this->state = State_Running;
55 this->start_time = start;
59 libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
61 dshowdebug("libAVFilter_GetState(%p)\n", this);
68 libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
70 dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
72 if (this->clock != clock) {
74 IReferenceClock_Release(this->clock);
77 IReferenceClock_AddRef(clock);
83 libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
85 dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
90 IReferenceClock_AddRef(this->clock);
96 libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
99 dshowdebug("libAVFilter_EnumPins(%p)\n", this);
103 new = libAVEnumPins_Create(this->pin, this);
105 return E_OUTOFMEMORY;
107 *enumpin = (IEnumPins *) new;
111 libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
113 libAVPin *found = NULL;
114 dshowdebug("libAVFilter_FindPin(%p)\n", this);
118 if (!wcscmp(id, L"In")) {
120 libAVPin_AddRef(found);
122 *pin = (IPin *) found;
124 return VFW_E_NOT_FOUND;
129 libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
131 dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
135 if (this->info.pGraph)
136 IFilterGraph_AddRef(this->info.pGraph);
142 libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
145 dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
147 this->info.pGraph = graph;
149 wcscpy(this->info.achName, name);
154 libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
156 dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
160 *info = wcsdup(L"libAV");
166 libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
167 enum dshowDeviceType type)
169 IBaseFilterVtbl *vtbl = this->vtbl;
170 SETVTBL(vtbl, libAVFilter, QueryInterface);
171 SETVTBL(vtbl, libAVFilter, AddRef);
172 SETVTBL(vtbl, libAVFilter, Release);
173 SETVTBL(vtbl, libAVFilter, GetClassID);
174 SETVTBL(vtbl, libAVFilter, Stop);
175 SETVTBL(vtbl, libAVFilter, Pause);
176 SETVTBL(vtbl, libAVFilter, Run);
177 SETVTBL(vtbl, libAVFilter, GetState);
178 SETVTBL(vtbl, libAVFilter, SetSyncSource);
179 SETVTBL(vtbl, libAVFilter, GetSyncSource);
180 SETVTBL(vtbl, libAVFilter, EnumPins);
181 SETVTBL(vtbl, libAVFilter, FindPin);
182 SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
183 SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
184 SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
186 this->pin = libAVPin_Create(this);
188 this->priv_data = priv_data;
189 this->callback = callback;
195 libAVFilter_Cleanup(libAVFilter *this)
197 libAVPin_Release(this->pin);
200 DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type),
201 void *priv_data, void *callback, enum dshowDeviceType type)
202 DECLARE_DESTROY(libAVFilter, libAVFilter_Cleanup)