qcap: COM cleanup in capturegraph.c.
[wine] / dlls / qcap / qcap_main.c
1 /*
2  * Qcap implementation, dllentry points
3  *
4  * Copyright (C) 2003 Dominik Strasser
5  * Copyright (C) 2005 Rolf Kalbermatter
6  *
7  * This library 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  * This library 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 this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 #include "config.h"
22
23 #include <assert.h>
24 #include <stdio.h>
25 #include <stdarg.h>
26
27 #define COBJMACROS
28 #define NONAMELESSSTRUCT
29 #define NONAMELESSUNION
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winerror.h"
35 #include "objbase.h"
36 #include "uuids.h"
37 #include "strmif.h"
38
39 #include "qcap_main.h"
40
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(qcap);
45
46 static LONG objects_ref = 0;
47
48 static const WCHAR wAudioCaptFilter[] =
49 {'A','u','d','i','o',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',0};
50 static const WCHAR wAVICompressor[] =
51 {'A','V','I',' ','C','o','m','p','r','e','s','s','o','r',0};
52 static const WCHAR wVFWCaptFilter[] =
53 {'V','F','W',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',0};
54 static const WCHAR wVFWCaptFilterProp[] =
55 {'V','F','W',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',' ',
56  'P','r','o','p','e','r','t','y',' ','P','a','g','e',0};
57 static const WCHAR wAVIMux[] =
58 {'A','V','I',' ','m','u','x',0};
59 static const WCHAR wAVIMuxPropPage[] =
60 {'A','V','I',' ','m','u','x',' ','P','r','o','p','e','r','t','y',' ','P','a','g','e',0};
61 static const WCHAR wAVIMuxPropPage1[] =
62 {'A','V','I',' ','m','u','x',' ','P','r','o','p','e','r','t','y',' ','P','a','g','e','1',0};
63 static const WCHAR wFileWriter[] =
64 {'F','i','l','e',' ','W','r','i','t','e','r',0};
65 static const WCHAR wCaptGraphBuilder[] =
66 {'C','a','p','t','u','r','e',' ','G','r','a','p','h',' ','B','u','i','l','d','e','r',0};
67 static const WCHAR wCaptGraphBuilder2[] =
68 {'C','a','p','t','u','r','e',' ','G','r','a','p','h',' ','B','u','i','l','d','e','r','2',0};
69 static const WCHAR wInfPinTeeFilter[] =
70 {'I','n','f','i','n','i','t','e',' ','P','i','n',' ','T','e','e',' ','F','i',
71  'l','t','e','r',0};
72 static const WCHAR wSmartTeeFilter[] =
73 {'S','m','a','r','t',' ','T','e','e',' ','F','i','l','t','e','r',0};
74 static const WCHAR wAudioInMixerProp[] =
75 {'A','u','d','i','o','I','n','p','u','t','M','i','x','e','r',' ','P','r','o',
76  'p','e','r','t','y',' ','P','a','g','e',0};
77  
78 FactoryTemplate const g_Templates[] = {
79 /*
80     {
81         wAudioCaptureFilter, 
82         &CLSID_AudioCaptureFilter,
83         QCAP_createAudioCaptureFilter,
84         NULL
85     },{
86         wAVICompressor, 
87         &CLSID_AVICompressor, 
88         QCAP_createAVICompressor,
89         NULL
90     },*/{
91         wVFWCaptFilter,
92         &CLSID_VfwCapture,
93         QCAP_createVFWCaptureFilter,
94         NULL
95     },/*{
96         wVFWCaptFilterProp,
97         &CLSID_VFWCaptureFilterPropertyPage,
98         QCAP_createVFWCaptureFilterPropertyPage,
99         NULL
100     },{
101         wAVIMux,
102         &CLSID_AVImux,
103         QCAP_createAVImux,
104         NULL
105     },{
106         wAVIMuxPropPage,
107         &CLSID_AVImuxPropertyPage,
108         QCAP_createAVImuxPropertyPage,
109         NULL
110     },{
111         wAVIMuxPropPage1,
112         &CLSID_AVImuxPropertyPage1,
113         QCAP_createAVImuxPropertyPage1,
114         NULL
115     },{
116         wFileWriter,
117         &CLSID_FileWriter,
118         QCAP_createFileWriter,
119         NULL
120     },*/{
121         wCaptGraphBuilder,
122         &CLSID_CaptureGraphBuilder,
123         QCAP_createCaptureGraphBuilder2,
124         NULL
125     },{
126         wCaptGraphBuilder2,
127         &CLSID_CaptureGraphBuilder2,
128         QCAP_createCaptureGraphBuilder2,
129         NULL
130     }/*,{
131         wInfPinTeeFilter, 
132         &CLSID_InfinitePinTeeFilter, 
133         QCAP_createInfinitePinTeeFilter,
134         NULL
135     },{
136         wSmartTeeFilter,
137         &CLSID_SmartTeeFilter,
138         QCAP_createSmartTeeFilter,
139         NULL
140     },{
141         wAudioInMixerProp,
142         &CLSID_AudioInputMixerPropertyPage,
143         QCAP_createAudioInputMixerPropertyPage,
144         NULL
145     }*/
146 };
147
148 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
149
150 /***********************************************************************
151  *    Dll EntryPoint (QCAP.@)
152  */
153 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
154 {
155     return STRMBASE_DllMain(hInstDLL,fdwReason,lpv);
156 }
157
158 /***********************************************************************
159  *    DllGetClassObject
160  */
161 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
162 {
163     return STRMBASE_DllGetClassObject( rclsid, riid, ppv );
164 }
165
166 /***********************************************************************
167  *    DllRegisterServer (QCAP.@)
168  */
169 HRESULT WINAPI DllRegisterServer(void)
170 {
171     TRACE("()\n");
172     return AMovieDllRegisterServer2(TRUE);
173 }
174
175 /***********************************************************************
176  *    DllUnregisterServer (QCAP.@)
177  */
178 HRESULT WINAPI DllUnregisterServer(void)
179 {
180     TRACE("\n");
181     return AMovieDllRegisterServer2(FALSE);
182 }
183
184 /***********************************************************************
185  *    DllCanUnloadNow (QCAP.@)
186  */
187 HRESULT WINAPI DllCanUnloadNow(void)
188 {
189     TRACE("\n");
190
191     if (STRMBASE_DllCanUnloadNow() && objects_ref == 0)
192         return S_OK;
193     return S_FALSE;
194 }
195
196 DWORD ObjectRefCount(BOOL increment)
197 {
198     if (increment)
199         return InterlockedIncrement(&objects_ref);
200     return InterlockedDecrement(&objects_ref);
201 }