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 extern HRESULT CDECL
wmp_decoder_create(struct decoder_info
*info
, struct decoder
**result
);
36 HRESULT
create_instance(const CLSID
*clsid
, const IID
*iid
, void **ppv
)
38 return CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, iid
, ppv
);
41 HRESULT
get_decoder_info(REFCLSID clsid
, IWICBitmapDecoderInfo
**info
)
43 IWICImagingFactory
* factory
;
44 IWICComponentInfo
*compinfo
;
47 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
48 &IID_IWICImagingFactory
, (void **)&factory
);
52 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, &compinfo
);
55 IWICImagingFactory_Release(factory
);
59 hr
= IWICComponentInfo_QueryInterface(compinfo
, &IID_IWICBitmapDecoderInfo
,
62 IWICComponentInfo_Release(compinfo
);
63 IWICImagingFactory_Release(factory
);
69 IClassFactory IClassFactory_iface
;
72 static HRESULT WINAPI
wmp_class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
74 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
76 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
79 IClassFactory_AddRef(iface
);
84 FIXME("%s not implemented.\n", debugstr_guid(iid
));
88 static ULONG WINAPI
wmp_class_factory_AddRef(IClassFactory
*iface
) { return 2; }
90 static ULONG WINAPI
wmp_class_factory_Release(IClassFactory
*iface
) { return 1; }
92 static HRESULT WINAPI
wmp_class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
94 struct decoder_info decoder_info
;
95 struct decoder
*decoder
;
98 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
101 if (outer
) return CLASS_E_NOAGGREGATION
;
103 hr
= wmp_decoder_create(&decoder_info
, &decoder
);
106 hr
= CommonDecoder_CreateInstance(decoder
, &decoder_info
, iid
, out
);
111 static HRESULT WINAPI
wmp_class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
113 FIXME("iface %p, lock %d, stub!\n", iface
, lock
);
117 static const IClassFactoryVtbl wmp_class_factory_vtbl
=
119 wmp_class_factory_QueryInterface
,
120 wmp_class_factory_AddRef
,
121 wmp_class_factory_Release
,
122 wmp_class_factory_CreateInstance
,
123 wmp_class_factory_LockServer
,
126 static struct class_factory wmp_class_factory
= {{&wmp_class_factory_vtbl
}};
128 HMODULE windowscodecs_module
= 0;
130 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, LPVOID reserved
)
132 TRACE("instance %p, reason %ld, reserved %p\n", instance
, reason
, reserved
);
136 case DLL_PROCESS_ATTACH
:
137 windowscodecs_module
= instance
;
138 DisableThreadLibraryCalls(instance
);
145 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, LPVOID
*out
)
147 struct class_factory
*factory
;
149 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
151 if (IsEqualGUID(clsid
, &CLSID_WICWmpDecoder
)) factory
= &wmp_class_factory
;
154 FIXME("%s not implemented.\n", debugstr_guid(clsid
));
155 return CLASS_E_CLASSNOTAVAILABLE
;
158 return IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, iid
, out
);