1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef DIRECTSHOWCAMERAGLOBAL_H
41 #define DIRECTSHOWCAMERAGLOBAL_H
42 
43 #include <QtCore/qglobal.h>
44 
45 #include <dshow.h>
46 
47 extern const GUID MEDIASUBTYPE_RGB24;
48 extern const GUID MEDIASUBTYPE_RGB32;
49 extern const GUID MEDIASUBTYPE_YUY2;
50 extern const GUID MEDIASUBTYPE_MJPG;
51 extern const GUID MEDIASUBTYPE_RGB555;
52 extern const GUID MEDIASUBTYPE_YVU9;
53 extern const GUID MEDIASUBTYPE_UYVY;
54 extern const GUID PIN_CATEGORY_CAPTURE;
55 extern const GUID PIN_CATEGORY_PREVIEW;
56 
57 extern const IID IID_IPropertyBag;
58 extern const IID IID_ISampleGrabber;
59 extern const IID IID_ICaptureGraphBuilder2;
60 extern const IID IID_IAMStreamConfig;
61 
62 
63 extern const CLSID CLSID_CVidCapClassManager;
64 extern const CLSID CLSID_VideoInputDeviceCategory;
65 extern const CLSID CLSID_SampleGrabber;
66 extern const CLSID CLSID_CaptureGraphBuilder2;
67 
68 #define SAFE_RELEASE(x) { if (x) x->Release(); x = nullptr; }
69 
70 typedef struct IFileSinkFilter *LPFILESINKFILTER;
71 typedef struct IAMCopyCaptureFileProgress *LPAMCOPYCAPTUREFILEPROGRESS;
72 
73 #ifndef __ICaptureGraphBuilder2_INTERFACE_DEFINED__
74 #define __ICaptureGraphBuilder2_INTERFACE_DEFINED__
75 struct ICaptureGraphBuilder2 : public IUnknown
76 {
77 public:
78     virtual HRESULT STDMETHODCALLTYPE SetFiltergraph(
79         /* [in] */ IGraphBuilder *pfg) = 0;
80 
81     virtual HRESULT STDMETHODCALLTYPE GetFiltergraph(
82         /* [out] */ IGraphBuilder **ppfg) = 0;
83 
84     virtual HRESULT STDMETHODCALLTYPE SetOutputFileName(
85         /* [in] */ const GUID *pType,
86         /* [in] */ LPCOLESTR lpstrFile,
87         /* [out] */ IBaseFilter **ppf,
88         /* [out] */ IFileSinkFilter **ppSink) = 0;
89 
90     virtual /* [local] */ HRESULT STDMETHODCALLTYPE FindInterface(
91         /* [in] */ const GUID *pCategory,
92         /* [in] */ const GUID *pType,
93         /* [in] */ IBaseFilter *pf,
94         /* [in] */ REFIID riid,
95         /* [out] */ void **ppint) = 0;
96 
97     virtual HRESULT STDMETHODCALLTYPE RenderStream(
98         /* [in] */ const GUID *pCategory,
99         /* [in] */ const GUID *pType,
100         /* [in] */ IUnknown *pSource,
101         /* [in] */ IBaseFilter *pfCompressor,
102         /* [in] */ IBaseFilter *pfRenderer) = 0;
103 
104     virtual HRESULT STDMETHODCALLTYPE ControlStream(
105         /* [in] */ const GUID *pCategory,
106         /* [in] */ const GUID *pType,
107         /* [in] */ IBaseFilter *pFilter,
108         /* [in] */ REFERENCE_TIME *pstart,
109         /* [in] */ REFERENCE_TIME *pstop,
110         /* [in] */ WORD wStartCookie,
111         /* [in] */ WORD wStopCookie) = 0;
112 
113     virtual HRESULT STDMETHODCALLTYPE AllocCapFile(
114         /* [in] */ LPCOLESTR lpstr,
115         /* [in] */ DWORDLONG dwlSize) = 0;
116 
117     virtual HRESULT STDMETHODCALLTYPE CopyCaptureFile(
118         /* [in] */ LPOLESTR lpwstrOld,
119         /* [in] */ LPOLESTR lpwstrNew,
120         /* [in] */ int fAllowEscAbort,
121         /* [in] */ IAMCopyCaptureFileProgress *pCallback) = 0;
122 
123     virtual HRESULT STDMETHODCALLTYPE FindPin(
124         /* [in] */ IUnknown *pSource,
125         /* [in] */ PIN_DIRECTION pindir,
126         /* [in] */ const GUID *pCategory,
127         /* [in] */ const GUID *pType,
128         /* [in] */ BOOL fUnconnected,
129         /* [in] */ int num,
130         /* [out] */ IPin **ppPin) = 0;
131 
132 };
133 #endif
134 
135 #ifndef __IAMStreamConfig_INTERFACE_DEFINED__
136 #define __IAMStreamConfig_INTERFACE_DEFINED__
137 struct IAMStreamConfig : public IUnknown
138 {
139 public:
140     virtual HRESULT STDMETHODCALLTYPE SetFormat(
141         /* [in] */ AM_MEDIA_TYPE *pmt) = 0;
142 
143     virtual HRESULT STDMETHODCALLTYPE GetFormat(
144         /* [out] */ AM_MEDIA_TYPE **ppmt) = 0;
145 
146     virtual HRESULT STDMETHODCALLTYPE GetNumberOfCapabilities(
147         /* [out] */ int *piCount,
148         /* [out] */ int *piSize) = 0;
149 
150     virtual HRESULT STDMETHODCALLTYPE GetStreamCaps(
151         /* [in] */ int iIndex,
152         /* [out] */ AM_MEDIA_TYPE **ppmt,
153         /* [out] */ BYTE *pSCC) = 0;
154 
155 };
156 #endif
157 
158 #ifndef __IErrorLog_INTERFACE_DEFINED__
159 #define __IErrorLog_INTERFACE_DEFINED__
160 struct IErrorLog : public IUnknown
161     {
162     public:
163         virtual HRESULT STDMETHODCALLTYPE AddError(
164             /* [in] */ LPCOLESTR pszPropName,
165             /* [in] */ EXCEPINFO *pExcepInfo) = 0;
166 
167     };
168 #endif
169 
170 #ifndef __IPropertyBag_INTERFACE_DEFINED__
171 #define __IPropertyBag_INTERFACE_DEFINED__
172 struct IPropertyBag : public IUnknown
173 {
174 public:
175     virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(
176         /* [in] */ LPCOLESTR pszPropName,
177         /* [out][in] */ VARIANT *pVar,
178         /* [in] */ IErrorLog *pErrorLog) = 0;
179 
180     virtual HRESULT STDMETHODCALLTYPE Write(
181         /* [in] */ LPCOLESTR pszPropName,
182         /* [in] */ VARIANT *pVar) = 0;
183 
184 };
185 #endif
186 
187 typedef struct IMediaSample *LPMEDIASAMPLE;
188 
189 EXTERN_C const IID IID_ISampleGrabberCB;
190 
191 #ifndef __ISampleGrabberCB_INTERFACE_DEFINED__
192 #define __ISampleGrabberCB_INTERFACE_DEFINED__
193 
194 #undef INTERFACE
195 #define INTERFACE ISampleGrabberCB
DECLARE_INTERFACE_(ISampleGrabberCB,IUnknown)196 DECLARE_INTERFACE_(ISampleGrabberCB, IUnknown)
197 {
198 //    STDMETHOD(QueryInterface) (THIS_ const GUID *, void **) PURE;
199     STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **) PURE;
200     STDMETHOD_(ULONG, AddRef) (THIS) PURE;
201     STDMETHOD_(ULONG, Release) (THIS) PURE;
202     STDMETHOD_(HRESULT, SampleCB) (THIS_ double, LPMEDIASAMPLE) PURE;
203     STDMETHOD_(HRESULT, BufferCB) (THIS_ double, BYTE *, long) PURE;
204 };
205 #undef INTERFACE
206 
207 #endif
208 
209 
210 #ifndef __ISampleGrabber_INTERFACE_DEFINED__
211 #define __ISampleGrabber_INTERFACE_DEFINED__
212 
213 #define INTERFACE ISampleGrabber
DECLARE_INTERFACE_(ISampleGrabber,IUnknown)214 DECLARE_INTERFACE_(ISampleGrabber,IUnknown)
215 {
216   STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
217   STDMETHOD_(ULONG,AddRef)(THIS) PURE;
218   STDMETHOD_(ULONG,Release)(THIS) PURE;
219   STDMETHOD(SetOneShot)(THIS_ BOOL) PURE;
220   STDMETHOD(SetMediaType)(THIS_ const AM_MEDIA_TYPE*) PURE;
221   STDMETHOD(GetConnectedMediaType)(THIS_ AM_MEDIA_TYPE*) PURE;
222   STDMETHOD(SetBufferSamples)(THIS_ BOOL) PURE;
223   STDMETHOD(GetCurrentBuffer)(THIS_ long*,long*) PURE;
224   STDMETHOD(GetCurrentSample)(THIS_ IMediaSample**) PURE;
225   STDMETHOD(SetCallback)(THIS_ ISampleGrabberCB *,long) PURE;
226 };
227 #undef INTERFACE
228 #endif
229 
230 
231 #endif
232