FFmpeg
dshow_filter.c
Go to the documentation of this file.
1 /*
2  * DirectShow capture interface
3  * Copyright (c) 2010 Ramiro Polla
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 #include "dshow_capture.h"
23 
25  { {&IID_IUnknown,0}, {&IID_IBaseFilter,0} })
28 
29 long WINAPI
31 {
32  dshowdebug("libAVFilter_GetClassID(%p)\n", this);
33  /* I'm not creating a ClassID just for this. */
34  return E_FAIL;
35 }
36 long WINAPI
38 {
39  dshowdebug("libAVFilter_Stop(%p)\n", this);
40  this->state = State_Stopped;
41  return S_OK;
42 }
43 long WINAPI
45 {
46  dshowdebug("libAVFilter_Pause(%p)\n", this);
47  this->state = State_Paused;
48  return S_OK;
49 }
50 long WINAPI
51 libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
52 {
53  dshowdebug("libAVFilter_Run(%p) %"PRId64"\n", this, start);
54  this->state = State_Running;
55  this->start_time = start;
56  return S_OK;
57 }
58 long WINAPI
59 libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
60 {
61  dshowdebug("libAVFilter_GetState(%p)\n", this);
62  if (!state)
63  return E_POINTER;
64  *state = this->state;
65  return S_OK;
66 }
67 long WINAPI
68 libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
69 {
70  dshowdebug("libAVFilter_SetSyncSource(%p)\n", this);
71 
72  if (this->clock != clock) {
73  if (this->clock)
74  IReferenceClock_Release(this->clock);
75  this->clock = clock;
76  if (clock)
77  IReferenceClock_AddRef(clock);
78  }
79 
80  return S_OK;
81 }
82 long WINAPI
83 libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
84 {
85  dshowdebug("libAVFilter_GetSyncSource(%p)\n", this);
86 
87  if (!clock)
88  return E_POINTER;
89  if (this->clock)
90  IReferenceClock_AddRef(this->clock);
91  *clock = this->clock;
92 
93  return S_OK;
94 }
95 long WINAPI
96 libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
97 {
98  libAVEnumPins *new;
99  dshowdebug("libAVFilter_EnumPins(%p)\n", this);
100 
101  if (!enumpin)
102  return E_POINTER;
103  new = libAVEnumPins_Create(this->pin, this);
104  if (!new)
105  return E_OUTOFMEMORY;
106 
107  *enumpin = (IEnumPins *) new;
108  return S_OK;
109 }
110 long WINAPI
111 libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
112 {
113  libAVPin *found = NULL;
114  dshowdebug("libAVFilter_FindPin(%p)\n", this);
115 
116  if (!id || !pin)
117  return E_POINTER;
118  if (!wcscmp(id, L"In")) {
119  found = this->pin;
120  libAVPin_AddRef(found);
121  }
122  *pin = (IPin *) found;
123  if (!found)
124  return VFW_E_NOT_FOUND;
125 
126  return S_OK;
127 }
128 long WINAPI
130 {
131  dshowdebug("libAVFilter_QueryFilterInfo(%p)\n", this);
132 
133  if (!info)
134  return E_POINTER;
135  if (this->info.pGraph)
136  IFilterGraph_AddRef(this->info.pGraph);
137  *info = this->info;
138 
139  return S_OK;
140 }
141 long WINAPI
143  const wchar_t *name)
144 {
145  dshowdebug("libAVFilter_JoinFilterGraph(%p)\n", this);
146 
147  this->info.pGraph = graph;
148  if (name)
149  wcscpy(this->info.achName, name);
150 
151  return S_OK;
152 }
153 long WINAPI
155 {
156  dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this);
157 
158  if (!info)
159  return E_POINTER;
160  return E_NOTIMPL; /* don't have to do anything here */
161 }
162 
163 static int
164 libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback,
165  enum dshowDeviceType type)
166 {
167  IBaseFilterVtbl *vtbl = this->vtbl;
168  SETVTBL(vtbl, libAVFilter, QueryInterface);
169  SETVTBL(vtbl, libAVFilter, AddRef);
170  SETVTBL(vtbl, libAVFilter, Release);
171  SETVTBL(vtbl, libAVFilter, GetClassID);
172  SETVTBL(vtbl, libAVFilter, Stop);
173  SETVTBL(vtbl, libAVFilter, Pause);
174  SETVTBL(vtbl, libAVFilter, Run);
175  SETVTBL(vtbl, libAVFilter, GetState);
176  SETVTBL(vtbl, libAVFilter, SetSyncSource);
177  SETVTBL(vtbl, libAVFilter, GetSyncSource);
178  SETVTBL(vtbl, libAVFilter, EnumPins);
179  SETVTBL(vtbl, libAVFilter, FindPin);
180  SETVTBL(vtbl, libAVFilter, QueryFilterInfo);
181  SETVTBL(vtbl, libAVFilter, JoinFilterGraph);
182  SETVTBL(vtbl, libAVFilter, QueryVendorInfo);
183 
184  this->pin = libAVPin_Create(this);
185 
186  this->priv_data = priv_data;
187  this->callback = callback;
188  this->type = type;
189 
190  return 1;
191 }
192 static int
194 {
195  libAVPin_Release(this->pin);
196  return 1;
197 }
199  void *priv_data, void *callback, enum dshowDeviceType type)
libAVFilter_JoinFilterGraph
long WINAPI libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph, const wchar_t *name)
Definition: dshow_filter.c:142
E_POINTER
#define E_POINTER
Definition: windows2linux.h:43
libAVPin_AddRef
unsigned long WINAPI libAVPin_AddRef(libAVPin *)
dshow_capture.h
DECLARE_RELEASE
#define DECLARE_RELEASE(class)
Definition: dshow_capture.h:101
name
const char * name
Definition: avisynth_c.h:867
DECLARE_QUERYINTERFACE
DECLARE_QUERYINTERFACE(libAVFilter, { {&IID_IUnknown, 0}, {&IID_IBaseFilter, 0} })
Definition: dshow_filter.c:24
dshow_ctx::graph
IGraphBuilder * graph
Definition: dshow_capture.h:291
S_OK
#define S_OK
Definition: windows2linux.h:40
start
void INT64 start
Definition: avisynth_c.h:767
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
libAVFilter_GetState
long WINAPI libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
Definition: dshow_filter.c:59
DECLARE_ADDREF
#define DECLARE_ADDREF(class)
Definition: dshow_capture.h:94
state
static struct @313 state
libAVFilter_Stop
long WINAPI libAVFilter_Stop(libAVFilter *this)
Definition: dshow_filter.c:37
libAVPin
Definition: dshow_capture.h:160
libAVPin_Create
libAVPin * libAVPin_Create(libAVFilter *filter)
DECLARE_CREATE
#define DECLARE_CREATE(class, setup,...)
Definition: dshow_capture.h:123
dshowdebug
#define dshowdebug(...)
Definition: dshow_capture.h:50
libAVFilter_GetSyncSource
long WINAPI libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
Definition: dshow_filter.c:83
info
MIPS optimizations info
Definition: mips.txt:2
callback
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType devtype)
Definition: dshow.c:161
NULL
#define NULL
Definition: coverity.c:32
libAVPin_Release
unsigned long WINAPI libAVPin_Release(libAVPin *)
libAVFilter_SetSyncSource
long WINAPI libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
Definition: dshow_filter.c:68
libAVFilter_Run
long WINAPI libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
Definition: dshow_filter.c:51
SETVTBL
#define SETVTBL(vtbl, class, fn)
Definition: dshow_capture.h:145
E_FAIL
#define E_FAIL
Definition: windows2linux.h:44
libAVFilter_Setup
static int libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback, enum dshowDeviceType type)
Definition: dshow_filter.c:164
libAVFilter_GetClassID
long WINAPI libAVFilter_GetClassID(libAVFilter *, CLSID *)
start_time
static int64_t start_time
Definition: ffplay.c:331
libAVFilter_Cleanup
static int libAVFilter_Cleanup(libAVFilter *this)
Definition: dshow_filter.c:193
libAVFilter_Pause
long WINAPI libAVFilter_Pause(libAVFilter *this)
Definition: dshow_filter.c:44
libAVFilter_EnumPins
long WINAPI libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
Definition: dshow_filter.c:96
libAVEnumPins
Definition: dshow_capture.h:206
CLSID
GUID CLSID
Definition: basicDataTypeConversions.h:78
DWORD
uint32_t DWORD
Definition: basicDataTypeConversions.h:51
L
#define L(x)
Definition: vp56_arith.h:36
E_OUTOFMEMORY
#define E_OUTOFMEMORY
Definition: windows2linux.h:45
libAVFilter
Definition: dshow_capture.h:249
DECLARE_DESTROY
#define DECLARE_DESTROY(class, func)
Definition: dshow_capture.h:112
libAVFilter_FindPin
long WINAPI libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
Definition: dshow_filter.c:111
libAVFilter_QueryVendorInfo
long WINAPI libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
Definition: dshow_filter.c:154
dshowDeviceType
dshowDeviceType
Definition: dshow_capture.h:61
libAVEnumPins_Create
libAVEnumPins * libAVEnumPins_Create(libAVPin *pin, libAVFilter *filter)
libAVFilter_QueryFilterInfo
long WINAPI libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
Definition: dshow_filter.c:129