2 * Copyright 2017 Vincent Povirk for CodeWeavers
3 * Copyright 2020 RĂ©mi Bernon for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wincodecs_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
34 HRESULT
create_instance(const CLSID
*clsid
, const IID
*iid
, void **ppv
)
36 return CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, iid
, ppv
);
39 HRESULT
get_decoder_info(REFCLSID clsid
, IWICBitmapDecoderInfo
**info
)
41 IWICImagingFactory
* factory
;
42 IWICComponentInfo
*compinfo
;
45 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
46 &IID_IWICImagingFactory
, (void **)&factory
);
50 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, &compinfo
);
53 IWICImagingFactory_Release(factory
);
57 hr
= IWICComponentInfo_QueryInterface(compinfo
, &IID_IWICBitmapDecoderInfo
,
60 IWICComponentInfo_Release(compinfo
);
61 IWICImagingFactory_Release(factory
);
67 IClassFactory IClassFactory_iface
;
70 static HRESULT WINAPI
wmp_class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
72 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
74 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
77 IClassFactory_AddRef(iface
);
82 FIXME("%s not implemented.\n", debugstr_guid(iid
));
86 static ULONG WINAPI
wmp_class_factory_AddRef(IClassFactory
*iface
) { return 2; }
88 static ULONG WINAPI
wmp_class_factory_Release(IClassFactory
*iface
) { return 1; }
90 static HRESULT WINAPI
wmp_class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
92 struct decoder_info decoder_info
;
93 struct decoder
*decoder
;
96 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
99 if (outer
) return CLASS_E_NOAGGREGATION
;
101 hr
= get_unix_decoder(&CLSID_WICWmpDecoder
, &decoder_info
, &decoder
);
104 hr
= CommonDecoder_CreateInstance(decoder
, &decoder_info
, iid
, out
);
109 static HRESULT WINAPI
wmp_class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
111 FIXME("iface %p, lock %d, stub!\n", iface
, lock
);
115 static const IClassFactoryVtbl wmp_class_factory_vtbl
=
117 wmp_class_factory_QueryInterface
,
118 wmp_class_factory_AddRef
,
119 wmp_class_factory_Release
,
120 wmp_class_factory_CreateInstance
,
121 wmp_class_factory_LockServer
,
124 static struct class_factory wmp_class_factory
= {{&wmp_class_factory_vtbl
}};
126 HMODULE windowscodecs_module
= 0;
128 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, LPVOID reserved
)
130 TRACE("instance %p, reason %d, reserved %p\n", instance
, reason
, reserved
);
134 case DLL_PROCESS_ATTACH
:
135 windowscodecs_module
= instance
;
136 DisableThreadLibraryCalls(instance
);
138 case DLL_WINE_PREATTACH
:
139 return FALSE
; /* prefer native version */
145 HRESULT WINAPI
DllCanUnloadNow(void)
150 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*out
)
152 struct class_factory
*factory
;
154 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
156 if (IsEqualGUID(clsid
, &CLSID_WICWmpDecoder
)) factory
= &wmp_class_factory
;
159 FIXME("%s not implemented.\n", debugstr_guid(clsid
));
160 return CLASS_E_CLASSNOTAVAILABLE
;
163 return IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, iid
, out
);
166 HRESULT WINAPI
DllRegisterServer(void)
168 return __wine_register_resources( windowscodecs_module
);
171 HRESULT WINAPI
DllUnregisterServer(void)
173 return __wine_unregister_resources( windowscodecs_module
);