1 /* Gstreamer Base Functions
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2010 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <gst/app/gstappsink.h>
26 #include <gst/app/gstappsrc.h>
27 #include <gst/app/gstappbuffer.h>
35 #include "wine/debug.h"
37 #include "wine/unicode.h"
38 #include "gst_private.h"
40 #include "gst_guids.h"
42 static HINSTANCE hInst = NULL;
44 WINE_DEFAULT_DEBUG_CHANNEL(gstreamer);
46 static const WCHAR wGstreamer_Splitter[] =
47 {'G','S','t','r','e','a','m','e','r',' ','s','p','l','i','t','t','e','r',' ','f','i','l','t','e','r',0};
48 static const WCHAR wGstreamer_YUV[] =
49 {'G','S','t','r','e','a','m','e','r',' ','Y','U','V',' ','f','i','l','t','e','r',0};
50 static const WCHAR wGstreamer_Mp3[] =
51 {'G','S','t','r','e','a','m','e','r',' ','M','p','3',' ','f','i','l','t','e','r',0};
52 static const WCHAR wGstreamer_AudioConvert[] =
53 {'G','S','t','r','e','a','m','e','r',' ','A','u','d','i','o','C','o','n','v','e','r','t',' ','f','i','l','t','e','r',0};
55 static WCHAR wNull[] = {'\0'};
57 static const AMOVIESETUP_MEDIATYPE amfMTstream[] =
58 { { &MEDIATYPE_Stream, &WINESUBTYPE_Gstreamer },
59 { &MEDIATYPE_Stream, &MEDIASUBTYPE_NULL },
62 static const AMOVIESETUP_MEDIATYPE amfMTaudio[] =
63 { { &MEDIATYPE_Audio, &MEDIASUBTYPE_NULL } };
65 static const AMOVIESETUP_MEDIATYPE amfMTvideo[] =
66 { { &MEDIATYPE_Video, &MEDIASUBTYPE_NULL } };
68 static const AMOVIESETUP_PIN amfSplitPin[] =
70 FALSE, FALSE, FALSE, FALSE,
78 FALSE, TRUE, FALSE, FALSE,
86 FALSE, TRUE, FALSE, FALSE,
94 static const AMOVIESETUP_FILTER amfSplitter =
95 { &CLSID_Gstreamer_Splitter,
102 static const AMOVIESETUP_PIN amfYUVPin[] =
104 FALSE, FALSE, FALSE, FALSE,
112 FALSE, TRUE, FALSE, FALSE,
120 static const AMOVIESETUP_FILTER amfYUV =
121 { &CLSID_Gstreamer_YUV,
128 AMOVIESETUP_PIN amfMp3Pin[] =
130 FALSE, FALSE, FALSE, FALSE,
138 FALSE, TRUE, FALSE, FALSE,
146 AMOVIESETUP_FILTER const amfMp3 =
147 { &CLSID_Gstreamer_Mp3,
154 AMOVIESETUP_PIN amfAudioConvertPin[] =
156 FALSE, FALSE, FALSE, FALSE,
164 FALSE, TRUE, FALSE, FALSE,
172 AMOVIESETUP_FILTER const amfAudioConvert =
173 { &CLSID_Gstreamer_AudioConvert,
174 wGstreamer_AudioConvert,
180 FactoryTemplate const g_Templates[] = {
183 &CLSID_Gstreamer_Splitter,
184 Gstreamer_Splitter_create,
190 &CLSID_Gstreamer_YUV,
191 Gstreamer_YUV_create,
197 &CLSID_Gstreamer_Mp3,
198 Gstreamer_Mp3_create,
203 wGstreamer_AudioConvert,
204 &CLSID_Gstreamer_AudioConvert,
205 Gstreamer_AudioConvert_create,
211 const int g_cTemplates = sizeof(g_Templates) / sizeof (g_Templates[0]);
213 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
215 if (fdwReason == DLL_PROCESS_ATTACH)
217 return STRMBASE_DllMain(hInstDLL, fdwReason, lpv);
220 /***********************************************************************
223 HRESULT WINAPI DllCanUnloadNow(void)
225 return STRMBASE_DllCanUnloadNow();
228 /***********************************************************************
231 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
233 return STRMBASE_DllGetClassObject( rclsid, riid, ppv );
236 /* GStreamer common functions */
238 void dump_AM_MEDIA_TYPE(const AM_MEDIA_TYPE * pmt)
242 TRACE("\t%s\n\t%s\n\t...\n\t%s\n", debugstr_guid(&pmt->majortype), debugstr_guid(&pmt->subtype), debugstr_guid(&pmt->formattype));
245 DWORD Gstreamer_init(void) {
249 char argv0[] = "wine";
250 char argv1[] = "--gst-disable-registry-fork";
251 char **argv = HeapAlloc(GetProcessHeap(), 0, sizeof(char *)*3);
257 g_thread_impl_init();
258 inited = gst_init_check(&argc, &argv, &err);
259 HeapFree(GetProcessHeap(), 0, argv);
261 FIXME("Failed to initialize gstreamer: %s\n", err->message);
266 /* Unloading glib is a bad idea.. it installs atexit handlers,
267 * so never unload the dll after loading */
268 GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
269 (LPCWSTR)hInst, &newhandle);
271 ERR("Could not pin module %p\n", hInst);
277 #define INF_SET_ID(id) \
280 static CHAR name[] = #id; \
282 pse[i].pszName = name; \
286 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
288 static HRESULT register_server(BOOL do_register)
292 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
295 static CLSID const *clsids[3];
298 static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
300 TRACE("(%x)\n", do_register);
302 INF_SET_CLSID(AsyncReader);
303 INF_SET_ID(MEDIATYPE_Stream);
304 INF_SET_ID(WINESUBTYPE_Gstreamer);
306 for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) {
307 pse[i].pszValue = HeapAlloc(GetProcessHeap(),0,39);
308 sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
309 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
310 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
311 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
314 strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
317 hAdvpack = LoadLibraryW(wszAdvpack);
318 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
320 hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
322 for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
323 HeapFree(GetProcessHeap(),0,pse[i].pszValue);
326 ERR("RegInstall failed: %08x\n", hres);
336 /***********************************************************************
339 HRESULT WINAPI DllRegisterServer(void)
345 hr = AMovieDllRegisterServer2(TRUE);
347 hr = register_server(TRUE);
351 /***********************************************************************
352 * DllUnregisterServer
354 HRESULT WINAPI DllUnregisterServer(void)
360 hr = AMovieDllRegisterServer2(FALSE);
362 hr = register_server(FALSE);