xref: /reactos/dll/directx/wine/qcap/qcap_main.c (revision ede7a20a)
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 
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winerror.h"
33 #include "objbase.h"
34 #include "uuids.h"
35 #include "strmif.h"
36 
37 #include "qcap_main.h"
38 
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41 
42 WINE_DEFAULT_DEBUG_CHANNEL(qcap);
43 
44 static LONG objects_ref = 0;
45 
46 static const WCHAR wAudioCaptureFilter[] =
47 {'A','u','d','i','o',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',0};
48 static const WCHAR wAVICompressor[] =
49 {'A','V','I',' ','C','o','m','p','r','e','s','s','o','r',0};
50 static const WCHAR wVFWCaptFilter[] =
51 {'V','F','W',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',0};
52 static const WCHAR wVFWCaptFilterProp[] =
53 {'V','F','W',' ','C','a','p','t','u','r','e',' ','F','i','l','t','e','r',' ',
54  'P','r','o','p','e','r','t','y',' ','P','a','g','e',0};
55 static const WCHAR wAVIMux[] =
56 {'A','V','I',' ','m','u','x',0};
57 static const WCHAR wAVIMuxPropPage[] =
58 {'A','V','I',' ','m','u','x',' ','P','r','o','p','e','r','t','y',' ','P','a','g','e',0};
59 static const WCHAR wAVIMuxPropPage1[] =
60 {'A','V','I',' ','m','u','x',' ','P','r','o','p','e','r','t','y',' ','P','a','g','e','1',0};
61 static const WCHAR wFileWriter[] =
62 {'F','i','l','e',' ','W','r','i','t','e','r',0};
63 static const WCHAR wCaptGraphBuilder[] =
64 {'C','a','p','t','u','r','e',' ','G','r','a','p','h',' ','B','u','i','l','d','e','r',0};
65 static const WCHAR wCaptGraphBuilder2[] =
66 {'C','a','p','t','u','r','e',' ','G','r','a','p','h',' ','B','u','i','l','d','e','r','2',0};
67 static const WCHAR wInfPinTeeFilter[] =
68 {'I','n','f','i','n','i','t','e',' ','P','i','n',' ','T','e','e',' ','F','i',
69  'l','t','e','r',0};
70 static const WCHAR wSmartTeeFilter[] =
71 {'S','m','a','r','t',' ','T','e','e',' ','F','i','l','t','e','r',0};
72 static const WCHAR wAudioInMixerProp[] =
73 {'A','u','d','i','o','I','n','p','u','t','M','i','x','e','r',' ','P','r','o',
74  'p','e','r','t','y',' ','P','a','g','e',0};
75 
76 FactoryTemplate const g_Templates[] = {
77     {
78         wAudioCaptureFilter,
79         &CLSID_AudioRecord,
80         QCAP_createAudioCaptureFilter,
81         NULL
82     },{
83         wAVICompressor,
84         &CLSID_AVICo,
85         QCAP_createAVICompressor,
86         NULL
87     },{
88         wVFWCaptFilter,
89         &CLSID_VfwCapture,
90         QCAP_createVFWCaptureFilter,
91         NULL
92     },{
93         wVFWCaptFilterProp,
94         &CLSID_CaptureProperties,
95         NULL, /* FIXME: Implement QCAP_createVFWCaptureFilterPropertyPage */
96         NULL
97     },{
98         wAVIMux,
99         &CLSID_AviDest,
100         QCAP_createAVIMux,
101         NULL
102     },{
103         wAVIMuxPropPage,
104         &CLSID_AviMuxProptyPage,
105         NULL, /* FIXME: Implement QCAP_createAVIMuxPropertyPage */
106         NULL
107     },{
108         wAVIMuxPropPage1,
109         &CLSID_AviMuxProptyPage1,
110         NULL, /* FIXME: Implement QCAP_createAVIMuxPropertyPage1 */
111         NULL
112     },{
113         wFileWriter,
114         &CLSID_FileWriter,
115         NULL, /* FIXME: Implement QCAP_createFileWriter */
116         NULL
117     },{
118         wCaptGraphBuilder,
119         &CLSID_CaptureGraphBuilder,
120         QCAP_createCaptureGraphBuilder2,
121         NULL
122     },{
123         wCaptGraphBuilder2,
124         &CLSID_CaptureGraphBuilder2,
125         QCAP_createCaptureGraphBuilder2,
126         NULL
127     },{
128         wInfPinTeeFilter,
129         &CLSID_InfTee,
130         NULL, /* FIXME: Implement QCAP_createInfinitePinTeeFilter */
131         NULL
132     },{
133         wSmartTeeFilter,
134         &CLSID_SmartTee,
135         QCAP_createSmartTeeFilter,
136         NULL
137     },{
138         wAudioInMixerProp,
139         &CLSID_AudioInputMixerProperties,
140         NULL, /* FIXME: Implement QCAP_createAudioInputMixerPropertyPage */
141         NULL
142     }
143 };
144 
145 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
146 
147 /***********************************************************************
148  *    Dll EntryPoint (QCAP.@)
149  */
150 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
151 {
152     return STRMBASE_DllMain(hInstDLL,fdwReason,lpv);
153 }
154 
155 /***********************************************************************
156  *    DllGetClassObject
157  */
158 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
159 {
160     return STRMBASE_DllGetClassObject( rclsid, riid, ppv );
161 }
162 
163 /***********************************************************************
164  *    DllRegisterServer (QCAP.@)
165  */
166 HRESULT WINAPI DllRegisterServer(void)
167 {
168     TRACE("()\n");
169     return AMovieDllRegisterServer2(TRUE);
170 }
171 
172 /***********************************************************************
173  *    DllUnregisterServer (QCAP.@)
174  */
175 HRESULT WINAPI DllUnregisterServer(void)
176 {
177     TRACE("\n");
178     return AMovieDllRegisterServer2(FALSE);
179 }
180 
181 /***********************************************************************
182  *    DllCanUnloadNow (QCAP.@)
183  */
184 HRESULT WINAPI DllCanUnloadNow(void)
185 {
186     TRACE("\n");
187 
188     if (STRMBASE_DllCanUnloadNow() == S_OK && objects_ref == 0)
189         return S_OK;
190     return S_FALSE;
191 }
192 
193 DWORD ObjectRefCount(BOOL increment)
194 {
195     if (increment)
196         return InterlockedIncrement(&objects_ref);
197     return InterlockedDecrement(&objects_ref);
198 }
199