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
30 #define WINE_NO_NAMELESS_EXTENSION
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "wine/strmbase.h"
45 #include "wineqtdecoder_classes.h"
48 DEFINE_GUID(WINESUBTYPE_QTSplitter
, 0xFFFFFFFF, 0x5927, 0x4894, 0xA3,0x86, 0x35,0x94,0x60,0xEE,0x87,0xC9);
50 WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder
);
52 extern HRESULT
video_decoder_create(IUnknown
*outer
, IUnknown
**out
);
53 extern HRESULT
qt_splitter_create(IUnknown
*outer
, IUnknown
**out
);
55 static const WCHAR wQTVName
[] =
56 {'Q','T',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
57 static const WCHAR wQTDName
[] =
58 {'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
60 static HINSTANCE wineqtdecoder_instance
;
62 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
64 if (reason
== DLL_PROCESS_ATTACH
)
66 wineqtdecoder_instance
= instance
;
67 DisableThreadLibraryCalls(instance
);
74 IClassFactory IClassFactory_iface
;
75 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
78 static inline struct class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
80 return CONTAINING_RECORD(iface
, struct class_factory
, IClassFactory_iface
);
83 static HRESULT WINAPI
class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
85 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
87 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
90 IClassFactory_AddRef(iface
);
95 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
99 static ULONG WINAPI
class_factory_AddRef(IClassFactory
*iface
)
104 static ULONG WINAPI
class_factory_Release(IClassFactory
*iface
)
109 static HRESULT WINAPI
class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
111 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
115 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
117 if (outer
&& !IsEqualGUID(iid
, &IID_IUnknown
))
118 return E_NOINTERFACE
;
121 if (SUCCEEDED(hr
= factory
->create_instance(outer
, &unk
)))
123 hr
= IUnknown_QueryInterface(unk
, iid
, out
);
124 IUnknown_Release(unk
);
129 static HRESULT WINAPI
class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
131 TRACE("iface %p, lock %d.\n", iface
, lock
);
135 static const IClassFactoryVtbl class_factory_vtbl
=
137 class_factory_QueryInterface
,
138 class_factory_AddRef
,
139 class_factory_Release
,
140 class_factory_CreateInstance
,
141 class_factory_LockServer
,
144 static struct class_factory qt_splitter_cf
= {{&class_factory_vtbl
}, qt_splitter_create
};
145 static struct class_factory video_decoder_cf
= {{&class_factory_vtbl
}, video_decoder_create
};
147 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, void **out
)
149 struct class_factory
*factory
;
151 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
153 if (IsEqualGUID(clsid
, &CLSID_QTSplitter
))
154 factory
= &qt_splitter_cf
;
155 else if (IsEqualGUID(clsid
, &CLSID_QTVDecoder
))
156 factory
= &video_decoder_cf
;
159 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid
));
160 return CLASS_E_CLASSNOTAVAILABLE
;
163 return IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, iid
, out
);
166 static const REGPINTYPES reg_audio_mt
= {&MEDIATYPE_Audio
, &GUID_NULL
};
167 static const REGPINTYPES reg_stream_mt
= {&MEDIATYPE_Stream
, &GUID_NULL
};
168 static const REGPINTYPES reg_video_mt
= {&MEDIATYPE_Video
, &GUID_NULL
};
170 static const REGFILTERPINS2 reg_qt_splitter_pins
[3] =
174 .lpMediaType
= ®_stream_mt
,
177 .dwFlags
= REG_PINFLAG_B_OUTPUT
| REG_PINFLAG_B_ZERO
,
179 .lpMediaType
= ®_audio_mt
,
182 .dwFlags
= REG_PINFLAG_B_OUTPUT
| REG_PINFLAG_B_ZERO
,
184 .lpMediaType
= ®_video_mt
,
188 static const REGFILTER2 reg_qt_splitter
=
191 .dwMerit
= MERIT_NORMAL
- 1,
193 .u
.s2
.rgPins2
= reg_qt_splitter_pins
,
196 static const REGFILTERPINS2 reg_video_decoder_pins
[2] =
200 .lpMediaType
= ®_video_mt
,
203 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
205 .lpMediaType
= ®_video_mt
,
209 static const REGFILTER2 reg_video_decoder
=
212 .dwMerit
= MERIT_NORMAL
- 1,
214 .u
.s2
.rgPins2
= reg_video_decoder_pins
,
217 HRESULT WINAPI
DllRegisterServer(void)
219 IFilterMapper2
*mapper
;
224 if (FAILED(hr
= __wine_register_resources(wineqtdecoder_instance
)))
227 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
228 &IID_IFilterMapper2
, (void **)&mapper
)))
231 IFilterMapper2_RegisterFilter(mapper
, &CLSID_QTSplitter
, wQTDName
, NULL
, NULL
, NULL
, ®_qt_splitter
);
232 IFilterMapper2_RegisterFilter(mapper
, &CLSID_QTVDecoder
, wQTVName
, NULL
, NULL
, NULL
, ®_video_decoder
);
234 IFilterMapper2_Release(mapper
);
238 HRESULT WINAPI
DllUnregisterServer(void)
240 IFilterMapper2
*mapper
;
245 if (FAILED(hr
= __wine_unregister_resources(wineqtdecoder_instance
)))
248 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
249 &IID_IFilterMapper2
, (void **)&mapper
)))
252 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_QTSplitter
);
253 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_QTVDecoder
);
255 IFilterMapper2_Release(mapper
);
259 HRESULT WINAPI
DllCanUnloadNow(void)