• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavdevice/dshow_filter.c

Go to the documentation of this file.
00001 /*
00002  * DirectShow capture interface
00003  * Copyright (c) 2010 Ramiro Polla
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #include "dshow.h"
00023 
00024 DECLARE_QUERYINTERFACE(libAVFilter,
00025     { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
00026 DECLARE_ADDREF(libAVFilter)
00027 DECLARE_RELEASE(libAVFilter)
00028 
00029 long WINAPI
00030 libAVFilter_GetClassID(libAVFilter *this, CLSID *id)
00031 {
00032     dshowdebug("libAVFilter_GetClassID(%p)\n", this);
00033     /* I'm not creating a ClassID just for this. */
00034     return E_FAIL;
00035 }
00036 long WINAPI
00037 libAVFilter_Stop(libAVFilter *this)
00038 {
00039     dshowdebug("libAVFilter_Stop(%p)\n", this);
00040     this->state = State_Stopped;
00041     return S_OK;
00042 }
00043 long WINAPI
00044 libAVFilter_Pause(libAVFilter *this)
00045 {
00046     dshowdebug("libAVFilter_Pause(%p)\n", this);
00047     this->state = State_Paused;
00048     return S_OK;
00049 }
00050 long WINAPI
00051 libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
00052 {
00053     dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
00054     this->state = State_Running;
00055     this->start_time = start;
00056     return S_OK;
00057 }
00058 long WINAPI
00059 libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
00060 {
00061     dshowdebug("libAVFilter_GetState(%p)\n", this);
00062     if (!state)
00063         return E_POINTER;
00064     *state = this->state;
00065     return S_OK;
00066 }
00067 long WINAPI
00068 libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
00069 {
00070     dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
00071 
00072     if (this->clock != clock) {
00073         if (this->clock)
00074             IReferenceClock_Release(this->clock);
00075         this->clock = clock;
00076         if (clock)
00077             IReferenceClock_AddRef(clock);
00078     }
00079 
00080     return S_OK;
00081 }
00082 long WINAPI
00083 libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
00084 {
00085     dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
00086 
00087     if (!clock)
00088         return E_POINTER;
00089     if (this->clock)
00090         IReferenceClock_AddRef(this->clock);
00091     *clock = this->clock;
00092 
00093     return S_OK;
00094 }
00095 long WINAPI
00096 libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
00097 {
00098     libAVEnumPins *new;
00099     dshowdebug("libAVFilter_EnumPins(%p)\n", this);
00100 
00101     if (!enumpin)
00102         return E_POINTER;
00103     new = libAVEnumPins_Create(this->pin, this);
00104     if (!new)
00105         return E_OUTOFMEMORY;
00106 
00107     *enumpin = (IEnumPins *) new;
00108     return S_OK;
00109 }
00110 long WINAPI
00111 libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
00112 {
00113     libAVPin *found = NULL;
00114     dshowdebug("libAVFilter_FindPin(%p)\n", this);
00115 
00116     if (!id || !pin)
00117         return E_POINTER;
00118     if (!wcscmp(id, L"In")) {
00119         found = this->pin;
00120         libAVPin_AddRef(found);
00121     }
00122     *pin = (IPin *) found;
00123     if (!found)
00124         return VFW_E_NOT_FOUND;
00125 
00126     return S_OK;
00127 }
00128 long WINAPI
00129 libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
00130 {
00131     dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
00132 
00133     if (!info)
00134         return E_POINTER;
00135     if (this->info.pGraph)
00136         IFilterGraph_AddRef(this->info.pGraph);
00137     *info = this->info;
00138 
00139     return S_OK;
00140 }
00141 long WINAPI
00142 libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph,
00143                             const wchar_t *name)
00144 {
00145     dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
00146 
00147     this->info.pGraph = graph;
00148     if (name)
00149         wcscpy(this->info.achName, name);
00150 
00151     return S_OK;
00152 }
00153 long WINAPI
00154 libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
00155 {
00156     dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
00157 
00158     if (!info)
00159         return E_POINTER;
00160     *info = wcsdup(L"libAV");
00161 
00162     return S_OK;
00163 }
00164 
00165 static int
00166 libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
00167                   enum dshowDeviceType type)
00168 {
00169     IBaseFilterVtbl *vtbl = this->vtbl;
00170     SETVTBL(vtbl, libAVFilter, QueryInterface);
00171     SETVTBL(vtbl, libAVFilter, AddRef);
00172     SETVTBL(vtbl, libAVFilter, Release);
00173     SETVTBL(vtbl, libAVFilter, GetClassID);
00174     SETVTBL(vtbl, libAVFilter, Stop);
00175     SETVTBL(vtbl, libAVFilter, Pause);
00176     SETVTBL(vtbl, libAVFilter, Run);
00177     SETVTBL(vtbl, libAVFilter, GetState);
00178     SETVTBL(vtbl, libAVFilter, SetSyncSource);
00179     SETVTBL(vtbl, libAVFilter, GetSyncSource);
00180     SETVTBL(vtbl, libAVFilter, EnumPins);
00181     SETVTBL(vtbl, libAVFilter, FindPin);
00182     SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
00183     SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
00184     SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
00185 
00186     this->pin = libAVPin_Create(this);
00187 
00188     this->priv_data = priv_data;
00189     this->callback  = callback;
00190     this->type      = type;
00191 
00192     return 1;
00193 }
00194 DECLARE_CREATE(libAVFilter, libAVFilter_Setup(this, priv_data, callback, type),
00195                void *priv_data, void *callback, enum dshowDeviceType type)
00196 DECLARE_DESTROY(libAVFilter, nothing)

Generated on Wed Apr 11 2012 07:31:35 for FFmpeg by  doxygen 1.7.1