FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
129 libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
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)
#define NULL
Definition: coverity.c:32
libAVPin * libAVPin_Create(libAVFilter *filter)
#define S_OK
Definition: windows2linux.h:40
#define dshowdebug(...)
Definition: dshow_capture.h:50
#define DECLARE_DESTROY(class, func)
unsigned long WINAPI libAVPin_Release(libAVPin *)
dshowDeviceType
Definition: dshow_capture.h:61
#define E_POINTER
Definition: windows2linux.h:43
#define DECLARE_CREATE(class, setup,...)
long WINAPI libAVFilter_GetState(libAVFilter *this, DWORD ms, FILTER_STATE *state)
Definition: dshow_filter.c:59
static int64_t start_time
Definition: ffplay.c:326
long WINAPI libAVFilter_SetSyncSource(libAVFilter *this, IReferenceClock *clock)
Definition: dshow_filter.c:68
#define DECLARE_RELEASE(class)
long WINAPI libAVFilter_GetSyncSource(libAVFilter *this, IReferenceClock **clock)
Definition: dshow_filter.c:83
unsigned long WINAPI libAVPin_AddRef(libAVPin *)
long WINAPI libAVFilter_Stop(libAVFilter *this)
Definition: dshow_filter.c:37
static void callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, enum dshowDeviceType devtype)
Definition: dshow.c:161
static int libAVFilter_Setup(libAVFilter *this, void *priv_data, void *callback, enum dshowDeviceType type)
Definition: dshow_filter.c:164
#define E_FAIL
Definition: windows2linux.h:44
#define L(x)
Definition: vp56_arith.h:36
static int libAVFilter_Cleanup(libAVFilter *this)
Definition: dshow_filter.c:193
long WINAPI libAVFilter_Run(libAVFilter *this, REFERENCE_TIME start)
Definition: dshow_filter.c:51
#define SETVTBL(vtbl, class, fn)
static struct @246 state
GLint GLenum type
Definition: opengl_enc.c:105
DECLARE_QUERYINTERFACE(libAVFilter,{{&IID_IUnknown, 0},{&IID_IBaseFilter, 0}})
Definition: dshow_filter.c:24
uint32_t DWORD
libAVEnumPins * libAVEnumPins_Create(libAVPin *pin, libAVFilter *filter)
#define E_OUTOFMEMORY
Definition: windows2linux.h:45
long WINAPI libAVFilter_Pause(libAVFilter *this)
Definition: dshow_filter.c:44
long WINAPI libAVFilter_QueryFilterInfo(libAVFilter *this, FILTER_INFO *info)
Definition: dshow_filter.c:129
long WINAPI libAVFilter_EnumPins(libAVFilter *this, IEnumPins **enumpin)
Definition: dshow_filter.c:96
void INT64 start
Definition: avisynth_c.h:690
long WINAPI libAVFilter_GetClassID(libAVFilter *, CLSID *)
#define DECLARE_ADDREF(class)
Definition: dshow_capture.h:94
long WINAPI libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info)
Definition: dshow_filter.c:154
long WINAPI libAVFilter_JoinFilterGraph(libAVFilter *this, IFilterGraph *graph, const wchar_t *name)
Definition: dshow_filter.c:142
IGraphBuilder * graph
const char * name
Definition: opengl_enc.c:103
long WINAPI libAVFilter_FindPin(libAVFilter *this, const wchar_t *id, IPin **pin)
Definition: dshow_filter.c:111