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 #define NO_DSHOW_STRSAFE
23 #include "dshow_capture.h"
25 DECLARE_QUERYINTERFACE(libAVFilter,
26 { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
27 DECLARE_ADDREF(libAVFilter)
28 DECLARE_RELEASE(libAVFilter)
31 libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
33 dshowdebug("libAVFilter_GetClassID(%p)\n", this);
34 /* I'm not creating a ClassID just for this. */
38 libAVFilter_Stop(libAVFilter *this)
40 dshowdebug("libAVFilter_Stop(%p)\n", this);
41 this->state = State_Stopped;
45 libAVFilter_Pause(libAVFilter *this)
47 dshowdebug("libAVFilter_Pause(%p)\n", this);
48 this->state = State_Paused;
52 libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
54 dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
55 this->state = State_Running;
56 this->start_time = start;
60 libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
62 dshowdebug("libAVFilter_GetState(%p)\n", this);
69 libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
71 dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
73 if (this->clock != clock) {
75 IReferenceClock_Release(this->clock);
78 IReferenceClock_AddRef(clock);
84 libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
86 dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
91 IReferenceClock_AddRef(this->clock);
97 libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
100 dshowdebug("libAVFilter_EnumPins(%p)\n", this);
104 new = libAVEnumPins_Create(this->pin, this);
106 return E_OUTOFMEMORY;
108 *enumpin = (IEnumPins *) new;
112 libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
114 libAVPin *found = NULL;
115 dshowdebug("libAVFilter_FindPin(%p)\n", this);
119 if (!wcscmp(id, L"In")) {
121 libAVPin_AddRef(found);
123 *pin = (IPin *) found;
125 return VFW_E_NOT_FOUND;
130 libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
132 dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
136 if (this->info.pGraph)
137 IFilterGraph_AddRef(this->info.pGraph);
143 libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
146 dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
148 this->info.pGraph = graph;
150 wcscpy(this->info.achName, name);
155 libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
157 dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
161 *info = wcsdup(L"libAV");
167 libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
168 enum dshowDeviceType type)
170 IBaseFilterVtbl *vtbl = this->vtbl;
171 SETVTBL(vtbl, libAVFilter, QueryInterface);
172 SETVTBL(vtbl, libAVFilter, AddRef);
173 SETVTBL(vtbl, libAVFilter, Release);
174 SETVTBL(vtbl, libAVFilter, GetClassID);
175 SETVTBL(vtbl, libAVFilter, Stop);
176 SETVTBL(vtbl, libAVFilter, Pause);
177 SETVTBL(vtbl, libAVFilter, Run);
178 SETVTBL(vtbl, libAVFilter, GetState);
179 SETVTBL(vtbl, libAVFilter, SetSyncSource);
180 SETVTBL(vtbl, libAVFilter, GetSyncSource);
181 SETVTBL(vtbl, libAVFilter, EnumPins);
182 SETVTBL(vtbl, libAVFilter, FindPin);
183 SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
184 SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
185 SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
187 this->pin = libAVPin_Create(this);
189 this->priv_data = priv_data;
190 this->callback = callback;
196 libAVFilter_Cleanup(libAVFilter *this)
198 libAVPin_Release(this->pin);
201 DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type),
202 void *priv_data, void *callback, enum dshowDeviceType type)
203 DECLARE_DESTROY(libAVFilter, libAVFilter_Cleanup)