2 * DirectShow filter for QuickTime Toolkit on Mac OS X
4 * Copyright (C) 2010 Aric Stewart, CodeWeavers
5 * Copyright (C) 2019 Zebediah Figura
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.
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.
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
28 #define NONAMELESSSTRUCT
29 #define NONAMELESSUNION
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
42 #include "wine/strmbase.h"
44 #include "wineqtdecoder_classes.h"
47 DEFINE_GUID(WINESUBTYPE_QTSplitter
, 0xFFFFFFFF, 0x5927, 0x4894, 0xA3,0x86, 0x35,0x94,0x60,0xEE,0x87,0xC9);
49 WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder
);
51 extern HRESULT
video_decoder_create(IUnknown
*outer
, IUnknown
**out
);
52 extern HRESULT
qt_splitter_create(IUnknown
*outer
, IUnknown
**out
);
54 static const WCHAR wQTVName
[] =
55 {'Q','T',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
56 static const WCHAR wQTDName
[] =
57 {'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
59 static HINSTANCE wineqtdecoder_instance
;
61 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
63 if (reason
== DLL_PROCESS_ATTACH
)
65 wineqtdecoder_instance
= instance
;
66 DisableThreadLibraryCalls(instance
);
73 IClassFactory IClassFactory_iface
;
74 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
77 static inline struct class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
79 return CONTAINING_RECORD(iface
, struct class_factory
, IClassFactory_iface
);
82 static HRESULT WINAPI
class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
84 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
86 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
89 IClassFactory_AddRef(iface
);
94 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
98 static ULONG WINAPI
class_factory_AddRef(IClassFactory
*iface
)
103 static ULONG WINAPI
class_factory_Release(IClassFactory
*iface
)
108 static HRESULT WINAPI
class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
110 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
114 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
116 if (outer
&& !IsEqualGUID(iid
, &IID_IUnknown
))
117 return E_NOINTERFACE
;
120 if (SUCCEEDED(hr
= factory
->create_instance(outer
, &unk
)))
122 hr
= IUnknown_QueryInterface(unk
, iid
, out
);
123 IUnknown_Release(unk
);
128 static HRESULT WINAPI
class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
130 TRACE("iface %p, lock %d.\n", iface
, lock
);
134 static const IClassFactoryVtbl class_factory_vtbl
=
136 class_factory_QueryInterface
,
137 class_factory_AddRef
,
138 class_factory_Release
,
139 class_factory_CreateInstance
,
140 class_factory_LockServer
,
143 static struct class_factory qt_splitter_cf
= {{&class_factory_vtbl
}, qt_splitter_create
};
144 static struct class_factory video_decoder_cf
= {{&class_factory_vtbl
}, video_decoder_create
};
146 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, void **out
)
148 struct class_factory
*factory
;
150 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
152 if (IsEqualGUID(clsid
, &CLSID_QTSplitter
))
153 factory
= &qt_splitter_cf
;
154 else if (IsEqualGUID(clsid
, &CLSID_QTVDecoder
))
155 factory
= &video_decoder_cf
;
158 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid
));
159 return CLASS_E_CLASSNOTAVAILABLE
;
162 return IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, iid
, out
);
165 static const REGPINTYPES reg_audio_mt
= {&MEDIATYPE_Audio
, &GUID_NULL
};
166 static const REGPINTYPES reg_stream_mt
= {&MEDIATYPE_Stream
, &GUID_NULL
};
167 static const REGPINTYPES reg_video_mt
= {&MEDIATYPE_Video
, &GUID_NULL
};
169 static const REGFILTERPINS2 reg_qt_splitter_pins
[3] =
173 .lpMediaType
= ®_stream_mt
,
176 .dwFlags
= REG_PINFLAG_B_OUTPUT
| REG_PINFLAG_B_ZERO
,
178 .lpMediaType
= ®_audio_mt
,
181 .dwFlags
= REG_PINFLAG_B_OUTPUT
| REG_PINFLAG_B_ZERO
,
183 .lpMediaType
= ®_video_mt
,
187 static const REGFILTER2 reg_qt_splitter
=
190 .dwMerit
= MERIT_NORMAL
- 1,
192 .u
.s2
.rgPins2
= reg_qt_splitter_pins
,
195 static const REGFILTERPINS2 reg_video_decoder_pins
[2] =
199 .lpMediaType
= ®_video_mt
,
202 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
204 .lpMediaType
= ®_video_mt
,
208 static const REGFILTER2 reg_video_decoder
=
211 .dwMerit
= MERIT_NORMAL
- 1,
213 .u
.s2
.rgPins2
= reg_video_decoder_pins
,
216 HRESULT WINAPI
DllRegisterServer(void)
218 IFilterMapper2
*mapper
;
223 if (FAILED(hr
= __wine_register_resources(wineqtdecoder_instance
)))
226 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
227 &IID_IFilterMapper2
, (void **)&mapper
)))
230 IFilterMapper2_RegisterFilter(mapper
, &CLSID_QTSplitter
, wQTDName
, NULL
, NULL
, NULL
, ®_qt_splitter
);
231 IFilterMapper2_RegisterFilter(mapper
, &CLSID_QTVDecoder
, wQTVName
, NULL
, NULL
, NULL
, ®_video_decoder
);
233 IFilterMapper2_Release(mapper
);
237 HRESULT WINAPI
DllUnregisterServer(void)
239 IFilterMapper2
*mapper
;
244 if (FAILED(hr
= __wine_unregister_resources(wineqtdecoder_instance
)))
247 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
248 &IID_IFilterMapper2
, (void **)&mapper
)))
251 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_QTSplitter
);
252 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_QTVDecoder
);
254 IFilterMapper2_Release(mapper
);
258 HRESULT WINAPI
DllCanUnloadNow(void)