Release 1.5.29.
[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 wAudioCaptureFilter[] =
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         wAudioCaptureFilter,
81         &CLSID_AudioRecord,
82         NULL, /* FIXME: Implement QCAP_createAudioCaptureFilter */
83         NULL
84     },{
85         wAVICompressor,
86         &CLSID_AVICo,
87         NULL, /* FIXME: Implement QCAP_createAVICompressor */
88         NULL
89     },{
90         wVFWCaptFilter,
91         &CLSID_VfwCapture,
92         QCAP_createVFWCaptureFilter,
93         NULL
94     },{
95         wVFWCaptFilterProp,
96         &CLSID_CaptureProperties,
97         NULL, /* FIXME: Implement QCAP_createVFWCaptureFilterPropertyPage */
98         NULL
99     },{
100         wAVIMux,
101         &CLSID_AviDest,
102         NULL, /* FIXME: Implement QCAP_createAVImux */
103         NULL
104     },{
105         wAVIMuxPropPage,
106         &CLSID_AviMuxProptyPage,
107         NULL, /* FIXME: Implement QCAP_createAVImuxPropertyPage */
108         NULL
109     },{
110         wAVIMuxPropPage1,
111         &CLSID_AviMuxProptyPage1,
112         NULL, /* FIXME: Implement QCAP_createAVImuxPropertyPage1 */
113         NULL
114     },{
115         wFileWriter,
116         &CLSID_FileWriter,
117         NULL, /* FIXME: Implement QCAP_createFileWriter */
118         NULL
119     },{
120         wCaptGraphBuilder,
121         &CLSID_CaptureGraphBuilder,
122         QCAP_createCaptureGraphBuilder2,
123         NULL
124     },{
125         wCaptGraphBuilder2,
126         &CLSID_CaptureGraphBuilder2,
127         QCAP_createCaptureGraphBuilder2,
128         NULL
129     },{
130         wInfPinTeeFilter, 
131         &CLSID_InfTee,
132         NULL, /* FIXME: Implement QCAP_createInfinitePinTeeFilter */
133         NULL
134     },{
135         wSmartTeeFilter,
136         &CLSID_SmartTee,
137         NULL, /* FIXME: Implement QCAP_createSmartTeeFilter */
138         NULL
139     },{
140         wAudioInMixerProp,
141         &CLSID_AudioInputMixerProperties,
142         NULL, /* FIXME: Implement QCAP_createAudioInputMixerPropertyPage */
143         NULL
144     }
145 };
146
147 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
148
149 /***********************************************************************
150  *    Dll EntryPoint (QCAP.@)
151  */
152 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
153 {
154     return STRMBASE_DllMain(hInstDLL,fdwReason,lpv);
155 }
156
157 /***********************************************************************
158  *    DllGetClassObject
159  */
160 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
161 {
162     return STRMBASE_DllGetClassObject( rclsid, riid, ppv );
163 }
164
165 /***********************************************************************
166  *    DllRegisterServer (QCAP.@)
167  */
168 HRESULT WINAPI DllRegisterServer(void)
169 {
170     TRACE("()\n");
171     return AMovieDllRegisterServer2(TRUE);
172 }
173
174 /***********************************************************************
175  *    DllUnregisterServer (QCAP.@)
176  */
177 HRESULT WINAPI DllUnregisterServer(void)
178 {
179     TRACE("\n");
180     return AMovieDllRegisterServer2(FALSE);
181 }
182
183 /***********************************************************************
184  *    DllCanUnloadNow (QCAP.@)
185  */
186 HRESULT WINAPI DllCanUnloadNow(void)
187 {
188     TRACE("\n");
189
190     if (STRMBASE_DllCanUnloadNow() && objects_ref == 0)
191         return S_OK;
192     return S_FALSE;
193 }
194
195 DWORD ObjectRefCount(BOOL increment)
196 {
197     if (increment)
198         return InterlockedIncrement(&objects_ref);
199     return InterlockedDecrement(&objects_ref);
200 }