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(filter, DShowFilter,
25 { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
26 DECLARE_ADDREF(filter, DShowFilter)
27 DECLARE_RELEASE(filter, DShowFilter)
29 long ff_dshow_filter_GetClassID(DShowFilter *this, CLSID *id)
31 dshowdebug("ff_dshow_filter_GetClassID(%p)\n", this);
32 /* I'm not creating a ClassID just for this. */
35 long ff_dshow_filter_Stop(DShowFilter *this)
37 dshowdebug("ff_dshow_filter_Stop(%p)\n", this);
38 this->state = State_Stopped;
41 long ff_dshow_filter_Pause(DShowFilter *this)
43 dshowdebug("ff_dshow_filter_Pause(%p)\n", this);
44 this->state = State_Paused;
47 long ff_dshow_filter_Run(DShowFilter *this, REFERENCE_TIME start)
49 dshowdebug("ff_dshow_filter_Run(%p) %"PRId64"\n", this, start);
50 this->state = State_Running;
51 this->start_time = start;
54 long ff_dshow_filter_GetState(DShowFilter *this, DWORD ms, FILTER_STATE *state)
56 dshowdebug("ff_dshow_filter_GetState(%p)\n", this);
62 long ff_dshow_filter_SetSyncSource(DShowFilter *this, IReferenceClock *clock)
64 dshowdebug("ff_dshow_filter_SetSyncSource(%p)\n", this);
66 if (this->clock != clock) {
68 IReferenceClock_Release(this->clock);
71 IReferenceClock_AddRef(clock);
76 long ff_dshow_filter_GetSyncSource(DShowFilter *this, IReferenceClock **clock)
78 dshowdebug("ff_dshow_filter_GetSyncSource(%p)\n", this);
83 IReferenceClock_AddRef(this->clock);
88 long ff_dshow_filter_EnumPins(DShowFilter *this, IEnumPins **enumpin)
91 dshowdebug("ff_dshow_filter_EnumPins(%p)\n", this);
95 new = ff_dshow_enumpins_Create(this->pin, this);
99 *enumpin = (IEnumPins *) new;
102 long ff_dshow_filter_FindPin(DShowFilter *this, const wchar_t *id, IPin **pin)
104 DShowPin *found = NULL;
105 dshowdebug("ff_dshow_filter_FindPin(%p)\n", this);
109 if (!wcscmp(id, L"In")) {
111 ff_dshow_pin_AddRef(found);
113 *pin = (IPin *) found;
115 return VFW_E_NOT_FOUND;
119 long ff_dshow_filter_QueryFilterInfo(DShowFilter *this, FILTER_INFO *info)
121 dshowdebug("ff_dshow_filter_QueryFilterInfo(%p)\n", this);
125 if (this->info.pGraph)
126 IFilterGraph_AddRef(this->info.pGraph);
131 long ff_dshow_filter_JoinFilterGraph(DShowFilter *this, IFilterGraph *graph,
134 dshowdebug("ff_dshow_filter_JoinFilterGraph(%p)\n", this);
136 this->info.pGraph = graph;
138 wcscpy(this->info.achName, name);
142 long ff_dshow_filter_QueryVendorInfo(DShowFilter *this, wchar_t **info)
144 dshowdebug("ff_dshow_filter_QueryVendorInfo(%p)\n", this);
148 return E_NOTIMPL; /* don't have to do anything here */
152 ff_dshow_filter_Setup(DShowFilter *this, void *priv_data, void *callback,
153 enum dshowDeviceType type)
155 IBaseFilterVtbl *vtbl = this->vtbl;
156 SETVTBL(vtbl, filter, QueryInterface);
157 SETVTBL(vtbl, filter, AddRef);
158 SETVTBL(vtbl, filter, Release);
159 SETVTBL(vtbl, filter, GetClassID);
160 SETVTBL(vtbl, filter, Stop);
161 SETVTBL(vtbl, filter, Pause);
162 SETVTBL(vtbl, filter, Run);
163 SETVTBL(vtbl, filter, GetState);
164 SETVTBL(vtbl, filter, SetSyncSource);
165 SETVTBL(vtbl, filter, GetSyncSource);
166 SETVTBL(vtbl, filter, EnumPins);
167 SETVTBL(vtbl, filter, FindPin);
168 SETVTBL(vtbl, filter, QueryFilterInfo);
169 SETVTBL(vtbl, filter, JoinFilterGraph);
170 SETVTBL(vtbl, filter, QueryVendorInfo);
172 this->pin = ff_dshow_pin_Create(this);
174 this->priv_data = priv_data;
175 this->callback = callback;
180 static int ff_dshow_filter_Cleanup(DShowFilter *this)
182 ff_dshow_pin_Release(this->pin);
185 DECLARE_CREATE(filter, DShowFilter, ff_dshow_filter_Setup(this, priv_data, callback, type),
186 void *priv_data, void *callback, enum dshowDeviceType type)
187 DECLARE_DESTROY(filter, DShowFilter, ff_dshow_filter_Cleanup)