Commit 34289e74 authored by Alexandre Julliard's avatar Alexandre Julliard

wineqtdecoder: Remove the QuickTime decoder.

QuickTime is deprecated on macOS, so remove the module instead of doing the work to convert it to msvcrt. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent f98d956e
......@@ -749,7 +749,6 @@ LIBWINE_LDFLAGS
LIBWINE_SHAREDLIB
METAL_LIBS
CARBON_LIBS
QUICKTIME_LIBS
OPENCL_LIBS
OPENAL_LIBS
COREAUDIO_LIBS
......@@ -909,7 +908,6 @@ with_oss
with_pcap
with_pthread
with_pulse
with_quicktime
with_sane
with_sdl
with_udev
......@@ -1725,7 +1723,6 @@ enable_winemapi
enable_wineoss_drv
enable_wineps_drv
enable_winepulse_drv
enable_wineqtdecoder
enable_wineusb_sys
enable_winevulkan
enable_winex11_drv
......@@ -2695,7 +2692,6 @@ Optional Packages:
--without-pcap do not use the Packet Capture library
--without-pthread do not use the pthread library
--without-pulse do not use PulseAudio sound support
--without-quicktime do not use QuickTime support
--without-sane do not use SANE (scanner support)
--without-sdl do not use SDL
--without-udev do not use udev (plug and play support)
......@@ -4615,13 +4611,6 @@ then :
fi
# Check whether --with-quicktime was given.
if test ${with_quicktime+y}
then :
withval=$with_quicktime;
fi
# Check whether --with-sane was given.
if test ${with_sane+y}
then :
......@@ -8216,12 +8205,6 @@ then :
printf "%s\n" "#define HAVE_OPENCL_OPENCL_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "QuickTime/ImageCompression.h" "ac_cv_header_QuickTime_ImageCompression_h" "$ac_includes_default"
if test "x$ac_cv_header_QuickTime_ImageCompression_h" = xyes
then :
printf "%s\n" "#define HAVE_QUICKTIME_IMAGECOMPRESSION_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "Security/Security.h" "ac_cv_header_Security_Security_h" "$ac_includes_default"
if test "x$ac_cv_header_Security_Security_h" = xyes
then :
......@@ -10547,53 +10530,6 @@ fi
LIBS="$ac_save_LIBS"
fi
if test "x$with_quicktime" != "xno"
then
if test "$ac_cv_header_QuickTime_ImageCompression_h" = "yes"
then
ac_save_LIBS="$LIBS"
LIBS="-framework QuickTime -framework ApplicationServices -framework CoreVideo $LIBS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the QuickTime framework" >&5
printf %s "checking for the QuickTime framework... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <QuickTime/ImageCompression.h>
int
main (void)
{
CodecManagerVersion(NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
QUICKTIME_LIBS="-framework QuickTime -framework ApplicationServices -framework CoreVideo"
enable_wineqtdecoder=${enable_wineqtdecoder:-yes}
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
ac_cv_header_QuickTime_ImageCompression_h=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS="$ac_save_LIBS"
fi
fi
if test "$ac_cv_header_QuickTime_ImageCompression_h" != "yes"
then :
case "x$with_quicktime" in
x) as_fn_append wine_notices "|QuickTime ${notice_platform}development files not found, video decoding won't be supported." ;;
xno) ;;
*) as_fn_error $? "QuickTime ${notice_platform}development files not found, video decoding won't be supported.
This is an error since --with-quicktime was requested." "$LINENO" 5 ;;
esac
fi
if test "$ac_cv_header_Carbon_Carbon_h" = "yes"
then
CARBON_LIBS="-framework Carbon"
......@@ -11141,7 +11077,6 @@ fi
esac
enable_winecoreaudio_drv=${enable_winecoreaudio_drv:-no}
enable_wineqtdecoder=${enable_wineqtdecoder:-no}
enable_wineandroid_drv=${enable_wineandroid_drv:-no}
enable_winemac_drv=${enable_winemac_drv:-no}
test "$ac_cv_header_linux_joystick_h" = "yes" -o "$ac_cv_header_IOKit_hid_IOHIDLib_h" = "yes" || enable_winejoystick_drv=${enable_winejoystick_drv:-no}
......@@ -16176,9 +16111,7 @@ fi
CPPFLAGS=$ac_save_CPPFLAGS
fi
if test "x$with_gstreamer" = xyes -o "x$with_quicktime" = xno -o "x$ac_cv_header_QuickTime_ImageCompression_h" != xyes
then
if test "x$ac_glib2_broken" != xyes -a "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" != xyes
if test "x$ac_glib2_broken" != xyes -a "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" != xyes
then :
case "x$with_gstreamer" in
x) as_fn_append wine_notices "|gstreamer-1.0 base plugins ${notice_platform}development files not found, GStreamer won't be supported." ;;
......@@ -16186,10 +16119,8 @@ then :
*) as_fn_error $? "gstreamer-1.0 base plugins ${notice_platform}development files not found, GStreamer won't be supported.
This is an error since --with-gstreamer was requested." "$LINENO" 5 ;;
esac
fi
enable_winegstreamer=${enable_winegstreamer:-no}
fi
test "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" = xyes || enable_winegstreamer=${enable_winegstreamer:-no}
ALSA_LIBS=""
......@@ -21798,7 +21729,6 @@ wine_fn_config_makefile dlls/wineoss.drv enable_wineoss_drv
wine_fn_config_makefile dlls/wineps.drv enable_wineps_drv
wine_fn_config_makefile dlls/wineps16.drv16 enable_win16
wine_fn_config_makefile dlls/winepulse.drv enable_winepulse_drv
wine_fn_config_makefile dlls/wineqtdecoder enable_wineqtdecoder
wine_fn_config_makefile dlls/wineusb.sys enable_wineusb_sys
wine_fn_config_makefile dlls/winevulkan enable_winevulkan
wine_fn_config_makefile dlls/winex11.drv enable_winex11_drv
......@@ -23015,7 +22945,6 @@ SECURITY_LIBS = $SECURITY_LIBS
COREAUDIO_LIBS = $COREAUDIO_LIBS
OPENAL_LIBS = $OPENAL_LIBS
OPENCL_LIBS = $OPENCL_LIBS
QUICKTIME_LIBS = $QUICKTIME_LIBS
CARBON_LIBS = $CARBON_LIBS
METAL_LIBS = $METAL_LIBS
LIBWINE_SHAREDLIB = $LIBWINE_SHAREDLIB
......
......@@ -57,7 +57,6 @@ AC_ARG_WITH(pcap, AS_HELP_STRING([--without-pcap],[do not use the Packet Ca
AC_ARG_WITH(pthread, AS_HELP_STRING([--without-pthread],[do not use the pthread library]),
[if test "x$withval" = "xno"; then ac_cv_header_pthread_h=no; fi])
AC_ARG_WITH(pulse, AS_HELP_STRING([--without-pulse],[do not use PulseAudio sound support]))
AC_ARG_WITH(quicktime, AS_HELP_STRING([--without-quicktime],[do not use QuickTime support]))
AC_ARG_WITH(sane, AS_HELP_STRING([--without-sane],[do not use SANE (scanner support)]))
AC_ARG_WITH(sdl, AS_HELP_STRING([--without-sdl],[do not use SDL]))
AC_ARG_WITH(udev, AS_HELP_STRING([--without-udev],[do not use udev (plug and play support)]))
......@@ -427,7 +426,6 @@ AC_CHECK_HEADERS(\
IOKit/hid/IOHIDLib.h \
OpenAL/al.h \
OpenCL/opencl.h \
QuickTime/ImageCompression.h \
Security/Security.h \
SystemConfiguration/SCDynamicStoreCopyDHCPInfo.h \
SystemConfiguration/SCNetworkConfiguration.h \
......@@ -787,27 +785,6 @@ case $host_os in
LIBS="$ac_save_LIBS"
fi
dnl *** Check for QuickTime ***
if test "x$with_quicktime" != "xno"
then
if test "$ac_cv_header_QuickTime_ImageCompression_h" = "yes"
then
dnl Make sure we can actually use the QuickTime framework
ac_save_LIBS="$LIBS"
LIBS="-framework QuickTime -framework ApplicationServices -framework CoreVideo $LIBS"
AC_MSG_CHECKING([for the QuickTime framework])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QuickTime/ImageCompression.h>]],[[CodecManagerVersion(NULL);]])],
[AC_MSG_RESULT([yes])
AC_SUBST(QUICKTIME_LIBS,"-framework QuickTime -framework ApplicationServices -framework CoreVideo")
enable_wineqtdecoder=${enable_wineqtdecoder:-yes}],
[AC_MSG_RESULT([no])
ac_cv_header_QuickTime_ImageCompression_h=no])
LIBS="$ac_save_LIBS"
fi
fi
WINE_NOTICE_WITH(quicktime,[test "$ac_cv_header_QuickTime_ImageCompression_h" != "yes"],
[QuickTime ${notice_platform}development files not found, video decoding won't be supported.])
if test "$ac_cv_header_Carbon_Carbon_h" = "yes"
then
AC_SUBST(CARBON_LIBS,"-framework Carbon")
......@@ -920,7 +897,6 @@ case $host_os in
esac
enable_winecoreaudio_drv=${enable_winecoreaudio_drv:-no}
enable_wineqtdecoder=${enable_wineqtdecoder:-no}
enable_wineandroid_drv=${enable_wineandroid_drv:-no}
enable_winemac_drv=${enable_winemac_drv:-no}
test "$ac_cv_header_linux_joystick_h" = "yes" -o "$ac_cv_header_IOKit_hid_IOHIDLib_h" = "yes" || enable_winejoystick_drv=${enable_winejoystick_drv:-no}
......@@ -1503,12 +1479,9 @@ then
ac_glib2_broken=yes
WINE_NOTICE([glib-2.0 pkgconfig configuration is for the wrong architecture, winegstreamer won't be built.])])])])
fi
if test "x$with_gstreamer" = xyes -o "x$with_quicktime" = xno -o "x$ac_cv_header_QuickTime_ImageCompression_h" != xyes
then
WINE_NOTICE_WITH(gstreamer,[test "x$ac_glib2_broken" != xyes -a "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" != xyes],
[gstreamer-1.0 base plugins ${notice_platform}development files not found, GStreamer won't be supported.])
fi
test "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" = xyes || enable_winegstreamer=${enable_winegstreamer:-no}
WINE_NOTICE_WITH(gstreamer,[test "x$ac_glib2_broken" != xyes -a "x$ac_cv_lib_gstreamer_1_0_gst_pad_new" != xyes],
[gstreamer-1.0 base plugins ${notice_platform}development files not found, GStreamer won't be supported.],
[enable_winegstreamer])
dnl **** Check for ALSA 1.x ****
AC_SUBST(ALSA_LIBS,"")
......@@ -3473,7 +3446,6 @@ WINE_CONFIG_MAKEFILE(dlls/wineoss.drv)
WINE_CONFIG_MAKEFILE(dlls/wineps.drv)
WINE_CONFIG_MAKEFILE(dlls/wineps16.drv16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/winepulse.drv)
WINE_CONFIG_MAKEFILE(dlls/wineqtdecoder)
WINE_CONFIG_MAKEFILE(dlls/wineusb.sys)
WINE_CONFIG_MAKEFILE(dlls/winevulkan)
WINE_CONFIG_MAKEFILE(dlls/winex11.drv)
......
MODULE = wineqtdecoder.dll
IMPORTS = strmiids uuid ole32 advapi32
EXTRALIBS = $(QUICKTIME_LIBS)
PARENTSRC = ../strmbase
EXTRADLLFLAGS = -mcygwin
C_SRCS = \
filter.c \
main.c \
mediatype.c \
outputqueue.c \
pin.c \
qtdatahandler.c \
qtsplitter.c \
qtutils.c \
qtvdecoder.c \
seeking.c
RC_SRCS = \
rsrc.rc
IDL_SRCS = \
wineqtdecoder_classes.idl
/*
* DirectShow filter for QuickTime Toolkit on Mac OS X
*
* Copyright (C) 2010 Aric Stewart, CodeWeavers
* Copyright (C) 2019 Zebediah Figura
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#define COBJMACROS
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#define WINE_NO_NAMELESS_EXTENSION
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winerror.h"
#include "objbase.h"
#include "uuids.h"
#include "strmif.h"
#include "rpcproxy.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/strmbase.h"
#include "wineqtdecoder_classes.h"
#include "initguid.h"
DEFINE_GUID(WINESUBTYPE_QTSplitter, 0xFFFFFFFF, 0x5927, 0x4894, 0xA3,0x86, 0x35,0x94,0x60,0xEE,0x87,0xC9);
WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder);
extern HRESULT video_decoder_create(IUnknown *outer, IUnknown **out);
extern HRESULT qt_splitter_create(IUnknown *outer, IUnknown **out);
static const WCHAR wQTVName[] =
{'Q','T',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
static const WCHAR wQTDName[] =
{'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
struct class_factory
{
IClassFactory IClassFactory_iface;
HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
};
static inline struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
}
static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
{
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
{
*out = iface;
IClassFactory_AddRef(iface);
return S_OK;
}
*out = NULL;
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
return E_NOINTERFACE;
}
static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
{
return 2;
}
static ULONG WINAPI class_factory_Release(IClassFactory *iface)
{
return 1;
}
static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
{
struct class_factory *factory = impl_from_IClassFactory(iface);
IUnknown *unk;
HRESULT hr;
TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
if (outer && !IsEqualGUID(iid, &IID_IUnknown))
return E_NOINTERFACE;
*out = NULL;
if (SUCCEEDED(hr = factory->create_instance(outer, &unk)))
{
hr = IUnknown_QueryInterface(unk, iid, out);
IUnknown_Release(unk);
}
return hr;
}
static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
{
TRACE("iface %p, lock %d.\n", iface, lock);
return S_OK;
}
static const IClassFactoryVtbl class_factory_vtbl =
{
class_factory_QueryInterface,
class_factory_AddRef,
class_factory_Release,
class_factory_CreateInstance,
class_factory_LockServer,
};
static struct class_factory qt_splitter_cf = {{&class_factory_vtbl}, qt_splitter_create};
static struct class_factory video_decoder_cf = {{&class_factory_vtbl}, video_decoder_create};
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
{
struct class_factory *factory;
TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
if (IsEqualGUID(clsid, &CLSID_QTSplitter))
factory = &qt_splitter_cf;
else if (IsEqualGUID(clsid, &CLSID_QTVDecoder))
factory = &video_decoder_cf;
else
{
FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
return CLASS_E_CLASSNOTAVAILABLE;
}
return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out);
}
static const REGPINTYPES reg_audio_mt = {&MEDIATYPE_Audio, &GUID_NULL};
static const REGPINTYPES reg_stream_mt = {&MEDIATYPE_Stream, &GUID_NULL};
static const REGPINTYPES reg_video_mt = {&MEDIATYPE_Video, &GUID_NULL};
static const REGFILTERPINS2 reg_qt_splitter_pins[3] =
{
{
.nMediaTypes = 1,
.lpMediaType = &reg_stream_mt,
},
{
.dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
.nMediaTypes = 1,
.lpMediaType = &reg_audio_mt,
},
{
.dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
.nMediaTypes = 1,
.lpMediaType = &reg_video_mt,
},
};
static const REGFILTER2 reg_qt_splitter =
{
.dwVersion = 2,
.dwMerit = MERIT_NORMAL - 1,
.u.s2.cPins2 = 3,
.u.s2.rgPins2 = reg_qt_splitter_pins,
};
static const REGFILTERPINS2 reg_video_decoder_pins[2] =
{
{
.nMediaTypes = 1,
.lpMediaType = &reg_video_mt,
},
{
.dwFlags = REG_PINFLAG_B_OUTPUT,
.nMediaTypes = 1,
.lpMediaType = &reg_video_mt,
},
};
static const REGFILTER2 reg_video_decoder =
{
.dwVersion = 2,
.dwMerit = MERIT_NORMAL - 1,
.u.s2.cPins2 = 2,
.u.s2.rgPins2 = reg_video_decoder_pins,
};
HRESULT WINAPI DllRegisterServer(void)
{
IFilterMapper2 *mapper;
HRESULT hr;
TRACE(".\n");
if (FAILED(hr = __wine_register_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterMapper2, (void **)&mapper)))
return hr;
IFilterMapper2_RegisterFilter(mapper, &CLSID_QTSplitter, wQTDName, NULL, NULL, NULL, &reg_qt_splitter);
IFilterMapper2_RegisterFilter(mapper, &CLSID_QTVDecoder, wQTVName, NULL, NULL, NULL, &reg_video_decoder);
IFilterMapper2_Release(mapper);
return S_OK;
}
HRESULT WINAPI DllUnregisterServer(void)
{
IFilterMapper2 *mapper;
HRESULT hr;
TRACE(".\n");
if (FAILED(hr = __wine_unregister_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterMapper2, (void **)&mapper)))
return hr;
IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTSplitter);
IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTVDecoder);
IFilterMapper2_Release(mapper);
return S_OK;
}
/*
* QuickTime Data Handler
*
* Copyright 2011 Aric Stewart for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#define ULONG CoreFoundation_ULONG
#define HRESULT CoreFoundation_HRESULT
#define LoadResource __carbon_LoadResource
#define CompareString __carbon_CompareString
#define GetCurrentThread __carbon_GetCurrentThread
#define GetCurrentProcess __carbon_GetCurrentProcess
#define AnimatePalette __carbon_AnimatePalette
#define EqualRgn __carbon_EqualRgn
#define FillRgn __carbon_FillRgn
#define FrameRgn __carbon_FrameRgn
#define GetPixel __carbon_GetPixel
#define InvertRgn __carbon_InvertRgn
#define LineTo __carbon_LineTo
#define OffsetRgn __carbon_OffsetRgn
#define PaintRgn __carbon_PaintRgn
#define Polygon __carbon_Polygon
#define ResizePalette __carbon_ResizePalette
#define SetRectRgn __carbon_SetRectRgn
#define CheckMenuItem __carbon_CheckMenuItem
#define DeleteMenu __carbon_DeleteMenu
#define DrawMenuBar __carbon_DrawMenuBar
#define EnableMenuItem __carbon_EnableMenuItem
#define EqualRect __carbon_EqualRect
#define FillRect __carbon_FillRect
#define FrameRect __carbon_FrameRect
#define GetCursor __carbon_GetCursor
#define GetMenu __carbon_GetMenu
#define InvertRect __carbon_InvertRect
#define IsWindowVisible __carbon_IsWindowVisible
#define MoveWindow __carbon_MoveWindow
#define OffsetRect __carbon_OffsetRect
#define PtInRect __carbon_PtInRect
#define SetCursor __carbon_SetCursor
#define SetRect __carbon_SetRect
#define ShowCursor __carbon_ShowCursor
#define ShowWindow __carbon_ShowWindow
#define UnionRect __carbon_UnionRect
#include <QuickTime/QuickTimeComponents.h>
#undef LoadResource
#undef CompareString
#undef GetCurrentThread
#undef _CDECL
#undef GetCurrentProcess
#undef AnimatePalette
#undef EqualRgn
#undef FillRgn
#undef FrameRgn
#undef GetPixel
#undef InvertRgn
#undef LineTo
#undef OffsetRgn
#undef PaintRgn
#undef Polygon
#undef ResizePalette
#undef SetRectRgn
#undef CheckMenuItem
#undef DeleteMenu
#undef DrawMenuBar
#undef EnableMenuItem
#undef EqualRect
#undef FillRect
#undef FrameRect
#undef GetCursor
#undef GetMenu
#undef InvertRect
#undef IsWindowVisible
#undef MoveWindow
#undef OffsetRect
#undef PtInRect
#undef SetCursor
#undef SetRect
#undef ShowCursor
#undef ShowWindow
#undef UnionRect
#undef ULONG
#undef HRESULT
#undef STDMETHODCALLTYPE
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "winuser.h"
#include "dshow.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "qtprivate.h"
WINE_DEFAULT_DEBUG_CHANNEL(qtdatahandler);
static ComponentDescription myType =
{
'dhlr',
'WINE',
'WINE',
0,
0
};
typedef struct DHData
{
WineDataRefRecord dataRef;
Ptr AsyncPtr;
long AsyncRefCon;
DataHCompletionUPP AsyncCompletionRtn;
} DHData;
static pascal ComponentResult myComponentRoutineProc ( ComponentParameters *
cp, Handle componentStorage);
void RegisterWineDataHandler( void )
{
ComponentRoutineUPP MyComponentRoutineUPP;
MyComponentRoutineUPP = NewComponentRoutineUPP(&myComponentRoutineProc);
RegisterComponent( &myType , MyComponentRoutineUPP, 0, NULL, NULL, NULL);
}
static pascal ComponentResult myDataHCanUseDataRef ( DataHandler dh,
Handle dataRef,
long *useFlags
)
{
WineDataRefRecord *record = (WineDataRefRecord*)(*dataRef);
TRACE("%p %p %p\n",dh,dataRef,useFlags);
if (record->pReader == NULL)
return badComponentSelector;
*useFlags = kDataHCanRead;
return noErr;
}
static pascal ComponentResult myDataHSetDataRef ( DataHandler dh, Handle dataRef)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
WineDataRefRecord* newRef = (WineDataRefRecord*)(*dataRef);
TRACE("\n");
if (newRef->pReader != data->dataRef.pReader)
IAsyncReader_AddRef(newRef->pReader);
data->dataRef = *newRef;
return noErr;
}
static pascal ComponentResult myDataHGetAvailableFileSize ( DataHandler dh,
long *fileSize)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
LONGLONG total;
LONGLONG available;
TRACE("%p\n",dh);
IAsyncReader_Length(data->dataRef.pReader,&total,&available);
*fileSize = available;
return noErr;
}
static pascal ComponentResult myDataHGetFileSize ( DataHandler dh, long *fileSize)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
LONGLONG total;
LONGLONG available;
TRACE("%p\n",dh);
IAsyncReader_Length(data->dataRef.pReader,&total,&available);
*fileSize = total;
return noErr;
}
static pascal ComponentResult myDataHScheduleData ( DataHandler dh,
Ptr PlaceToPutDataPtr,
long FileOffset,
long DataSize,
long RefCon,
DataHSchedulePtr scheduleRec,
DataHCompletionUPP CompletionRtn)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
HRESULT hr;
LONGLONG offset = FileOffset;
BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
TRACE("%p %p %li %li %li %p %p\n",dh, PlaceToPutDataPtr, FileOffset, DataSize, RefCon, scheduleRec, CompletionRtn);
hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
TRACE("result %x\n",hr);
if (CompletionRtn)
{
if (data->AsyncCompletionRtn)
InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
data->AsyncPtr = PlaceToPutDataPtr;
data->AsyncRefCon = RefCon;
data->AsyncCompletionRtn = CompletionRtn;
}
return noErr;
}
static pascal ComponentResult myDataHFinishData (DataHandler dh, Ptr PlaceToPutDataPtr, Boolean Cancel)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
if (!data->AsyncCompletionRtn)
return noErr;
if (!PlaceToPutDataPtr || PlaceToPutDataPtr == data->AsyncPtr)
{
if (!Cancel)
InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
data->AsyncPtr = NULL;
data->AsyncRefCon = 0;
data->AsyncCompletionRtn = NULL;
}
return noErr;
}
static pascal ComponentResult myDataHGetData ( DataHandler dh,
Handle h,
long hOffset,
long offset,
long size)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
BYTE *target = (BYTE*)*h;
LONGLONG off = offset;
HRESULT hr;
TRACE("%p %p %li %li %li\n",dh, h, hOffset, offset, size);
hr = IAsyncReader_SyncRead(data->dataRef.pReader, off, size, target+hOffset);
TRACE("result %x\n",hr);
return noErr;
}
static pascal ComponentResult myDataHCompareDataRef ( DataHandler dh,
Handle dataRef, Boolean *equal)
{
WineDataRefRecord *ptr1;
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
TRACE("\n");
ptr1 = (WineDataRefRecord*)dataRef;
*equal = (ptr1->pReader == data->dataRef.pReader);
return noErr;
}
static pascal ComponentResult myDataHGetDataRef ( DataHandler dh, Handle *dataRef)
{
Handle storage = GetComponentInstanceStorage(dh);
TRACE("\n");
*dataRef = storage;
HandToHand(dataRef);
return noErr;
}
static pascal ComponentResult myDataHGetScheduleAheadTime ( DataHandler dh,
long *millisecs)
{
TRACE("\n");
*millisecs = 1000;
return noErr;
}
static pascal ComponentResult myDataHGetInfoFlags ( DataHandler dh, UInt32 *flags)
{
TRACE("\n");
*flags = 0;
return noErr;
}
static pascal ComponentResult myDataHGetFileTypeOrdering ( DataHandler dh,
DataHFileTypeOrderingHandle *orderingListHandle)
{
OSType orderlist[1] = {kDataHFileTypeExtension};
TRACE("\n");
PtrToHand( &orderlist, (Handle*)orderingListHandle, sizeof(OSType));
return noErr;
}
typedef struct {
const char *const fname;
const int sig_length;
const BYTE sig[10];
} signature;
static const signature stream_sigs[] = {
{"video.asf",4,{0x30,0x26,0xb2,0x75}},
{"video.mov",8,{0x00,0x00,0x00,0x14,0x66,0x74,0x79,0x70}},
{"video.mp4",8,{0x00,0x00,0x00,0x18,0x66,0x74,0x79,0x70}},
{"video.m4v",8,{0x00,0x00,0x00,0x1c,0x66,0x74,0x79,0x70}},
{"video.flv",4,{0x46,0x4C,0x56,0x01}},
{"video.mpg",3,{0x00,0x00,0x01}},
{"avideo.rm",4,{0x2E,0x52,0x4D,0x46}}
};
static pascal ComponentResult myDataHGetFileName ( DataHandler dh, Str255 str)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
TRACE("%p %s\n",str,debugstr_guid(&data->dataRef.streamSubtype));
/* Todo Expand this list */
if (IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1Video) ||
IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1System))
CFStringGetPascalString(CFSTR("video.mpg"),str,256,kCFStringEncodingMacRoman);
else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Asf))
CFStringGetPascalString(CFSTR("video.asf"),str,256,kCFStringEncodingMacRoman);
else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Avi))
CFStringGetPascalString(CFSTR("video.avi"),str,256,kCFStringEncodingMacRoman);
else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_QTMovie))
CFStringGetPascalString(CFSTR("video.mov"),str,256,kCFStringEncodingMacRoman);
else
{
BYTE header[10] = {0,0,0,0,0,0,0,0,0,0};
int i;
IAsyncReader_SyncRead(data->dataRef.pReader, 0, 8, header);
for (i = 0; i < ARRAY_SIZE(stream_sigs); i++)
if (memcmp(header, stream_sigs[i].sig, stream_sigs[i].sig_length)==0)
{
str[0] = strlen(stream_sigs[i].fname);
memcpy(str + 1, stream_sigs[i].fname, str[0]);
return noErr;
}
return badComponentSelector;
}
return noErr;
}
static pascal ComponentResult myDataHOpenForRead(DataHandler dh)
{
TRACE("\n");
return noErr;
}
static pascal ComponentResult myDataHTask(DataHandler dh)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
if (data->AsyncCompletionRtn)
{
TRACE("Sending Completion\n");
InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
data->AsyncPtr = NULL;
data->AsyncRefCon = 0;
data->AsyncCompletionRtn = NULL;
}
return noErr;
}
static pascal ComponentResult myDataHPlaybackHints(DataHandler dh, long flags,
unsigned long minFileOffset, unsigned long maxFileOffset,
long bytesPerSecond)
{
TRACE("%lu %lu %li\n",minFileOffset, maxFileOffset, bytesPerSecond);
return noErr;
}
static pascal ComponentResult myDataHPlaybackHints64(DataHandler dh, long flags,
wide *minFileOffset, wide *maxFileOffset,
long bytesPerSecond)
{
if (TRACE_ON(qtdatahandler))
{
SInt64 minFileOffset64 = WideToSInt64(*minFileOffset);
LONGLONG minFileOffsetLL = minFileOffset64;
SInt64 maxFileOffset64 = WideToSInt64(*maxFileOffset);
LONGLONG maxFileOffsetLL = maxFileOffset64;
TRACE("%s %s %li\n",wine_dbgstr_longlong(minFileOffsetLL), wine_dbgstr_longlong(maxFileOffsetLL), bytesPerSecond);
}
return noErr;
}
static pascal ComponentResult myDataHGetFileSize64(DataHandler dh, wide * fileSize)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
LONGLONG total;
LONGLONG available;
SInt64 total64;
TRACE("%p\n",dh);
IAsyncReader_Length(data->dataRef.pReader,&total,&available);
total64 = total;
*fileSize = SInt64ToWide(total64);
return noErr;
}
static pascal ComponentResult myDataHGetFileSizeAsync ( DataHandler dh, wide *fileSize, DataHCompletionUPP CompletionRtn, long RefCon )
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
LONGLONG total;
LONGLONG available;
SInt64 total64;
TRACE("%p\n",dh);
IAsyncReader_Length(data->dataRef.pReader,&total,&available);
total64 = total;
*fileSize = SInt64ToWide(total64);
if (CompletionRtn)
{
if (data->AsyncCompletionRtn)
InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
data->AsyncPtr = (Ptr)fileSize;
data->AsyncRefCon = RefCon;
data->AsyncCompletionRtn = CompletionRtn;
}
return noErr;
}
static pascal ComponentResult myDataHGetAvailableFileSize64(DataHandler dh, wide * fileSize)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
LONGLONG total;
LONGLONG available;
SInt64 total64;
TRACE("%p\n",dh);
IAsyncReader_Length(data->dataRef.pReader,&total,&available);
total64 = available;
*fileSize = SInt64ToWide(total64);
return noErr;
}
static pascal ComponentResult myDataHScheduleData64( DataHandler dh,
Ptr PlaceToPutDataPtr,
const wide * FileOffset,
long DataSize,
long RefCon,
DataHSchedulePtr scheduleRec,
DataHCompletionUPP CompletionRtn)
{
Handle storage = GetComponentInstanceStorage(dh);
DHData *data = (DHData*)*storage;
HRESULT hr;
SInt64 fileOffset64 = WideToSInt64(*FileOffset);
LONGLONG offset = fileOffset64;
BYTE* buffer = (BYTE*)PlaceToPutDataPtr;
TRACE("%p %p %s %li %li %p %p\n",dh, PlaceToPutDataPtr, wine_dbgstr_longlong(offset), DataSize, RefCon, scheduleRec, CompletionRtn);
hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer);
TRACE("result %x\n",hr);
if (CompletionRtn)
{
if (data->AsyncCompletionRtn)
InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn);
data->AsyncPtr = PlaceToPutDataPtr;
data->AsyncRefCon = RefCon;
data->AsyncCompletionRtn = CompletionRtn;
}
return noErr;
}
static const struct { LPVOID proc; ProcInfoType type;} componentFunctions[] =
{
{NULL, 0}, /* 0 */
{NULL, 0}, /* 1 */
{myDataHGetData, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
}, /* kDataHGetDataSelect */
{NULL, 0}, /* kDataHPutDataSelect */
{NULL, 0}, /* kDataHFlushDataSelect */
{NULL, 0}, /* kDataHOpenForWriteSelect */
{NULL, 0}, /* kDataHCloseForWriteSelect */
{NULL, 0}, /* 7 */
{myDataHOpenForRead, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
}, /* kDataHOpenForReadSelect
*/
{NULL, 0}, /* kDataHCloseForReadSelect */
{myDataHSetDataRef, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
}, /* kDataHSetDataRefSelect */
{myDataHGetDataRef, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
}, /* kDataHGetDataRefSelect */
{myDataHCompareDataRef, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean*)))
}, /* kDataHCompareDataRefSelect */
{myDataHTask, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
}, /* kDataHTaskSelect */
{myDataHScheduleData, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
| STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
}, /* kDataHScheduleDataSelect */
{myDataHFinishData, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean)))
}, /* kDataHFinishDataSelect */
{NULL, 0}, /* kDataHFlushCacheSelect 0x10 */
{NULL, 0}, /* kDataHResolveDataRefSelect */
{myDataHGetFileSize, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
}, /* kDataHGetFileSizeSelect */
{myDataHCanUseDataRef, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long*)))
}, /* kDataHCanUseDataRefSelect */
{NULL, 0}, /* kDataHGetVolumeListSelect */
{NULL, 0}, /* kDataHWriteSelect */
{NULL, 0}, /* kDataHPreextendSelect */
{NULL, 0}, /* kDataHSetFileSizeSelect */
{NULL, 0}, /* kDataHGetFreeSpaceSelect */
{NULL, 0}, /* kDataHCreateFileSelect */
{NULL, 0}, /* kDataHGetPreferredBlockSizeSelect */
{NULL, 0}, /* kDataHGetDeviceIndexSelect */
{NULL, 0}, /* kDataHIsStreamingDataHandlerSelect */
{NULL, 0}, /* kDataHGetDataInBufferSelect */
{myDataHGetScheduleAheadTime, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
}, /* kDataHGetScheduleAheadTimeSelect */
/* End of Required List */
{NULL, 0}, /* kDataHSetCacheSizeLimitSelect */
{NULL, 0}, /* kDataHGetCacheSizeLimitSelect 0x20 */
{NULL, 0}, /* kDataHGetMovieSelect */
{NULL, 0}, /* kDataHAddMovieSelect */
{NULL, 0}, /* kDataHUpdateMovieSelect */
{NULL, 0}, /* kDataHDoesBufferSelect */
{myDataHGetFileName, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Str255*)))
}, /* kDataHGetFileNameSelect */
{myDataHGetAvailableFileSize, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long*)))
}, /* kDataHGetAvailableFileSizeSelect */
{NULL, 0}, /* kDataHGetMacOSFileTypeSelect */
{NULL, 0}, /* kDataHGetMIMETypeSelect */
{NULL, 0}, /* kDataHSetDataRefWithAnchorSelect */
{NULL, 0}, /* kDataHGetDataRefWithAnchorSelect */
{NULL, 0}, /* kDataHSetMacOSFileTypeSelect */
{NULL, 0}, /* kDataHSetTimeBaseSelect */
{myDataHGetInfoFlags, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(UInt32*)))
}, /* kDataHGetInfoFlagsSelect */
{myDataHScheduleData64, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide*)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DataHSchedulePtr)))
| STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DataHCompletionUPP)))
}, /* kDataHScheduleData64Select */
{NULL, 0}, /* kDataHWrite64Select */
{myDataHGetFileSize64, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
}, /* kDataHGetFileSize64Select 0x30 */
{NULL, 0}, /* kDataHPreextend64Select */
{NULL, 0}, /* kDataHSetFileSize64Select */
{NULL, 0}, /* kDataHGetFreeSpace64Select */
{NULL, 0}, /* kDataHAppend64Select */
{NULL, 0}, /* kDataHReadAsyncSelect */
{NULL, 0}, /* kDataHPollReadSelect */
{NULL, 0}, /* kDataHGetDataAvailabilitySelect */
{NULL, 0}, /* 0x0038 */
{NULL, 0}, /* 0x0039 */
{myDataHGetFileSizeAsync, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DataHCompletionUPP)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
}, /* kDataHGetFileSizeAsyncSelect */
{NULL, 0}, /* kDataHGetDataRefAsTypeSelect */
{NULL, 0}, /* kDataHSetDataRefExtensionSelect */
{NULL, 0}, /* kDataHGetDataRefExtensionSelect */
{NULL, 0}, /* kDataHGetMovieWithFlagsSelect */
{NULL, 0}, /* 0x3F */
{myDataHGetFileTypeOrdering, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DataHFileTypeOrderingHandle*)))
}, /* kDataHGetFileTypeOrderingSelect 0x40 */
{NULL, 0}, /* kDataHCreateFileWithFlagsSelect */
{NULL, 0}, /* kDataHGetMIMETypeAsyncSelect */
{NULL, 0}, /* kDataHGetInfoSelect */
{NULL, 0}, /* kDataHSetIdleManagerSelect */
{NULL, 0}, /* kDataHDeleteFileSelect */
{NULL, 0}, /* kDataHSetMovieUsageFlagsSelect */
{NULL, 0}, /* kDataHUseTemporaryDataRefSelect */
{NULL, 0}, /* kDataHGetTemporaryDataRefCapabilitiesSelect */
{NULL, 0}, /* kDataHRenameFileSelect */
{NULL, 0}, /* 0x4A */
{NULL, 0}, /* 0x4B */
{NULL, 0}, /* 0x4C */
{NULL, 0}, /* 0x4D */
{myDataHGetAvailableFileSize64, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(wide*)))
}, /* kDataHGetAvailableFileSize64Select */
{NULL, 0}, /* kDataHGetDataAvailability64Select */
};
static const struct { LPVOID proc; ProcInfoType type;} componentFunctions_2[] =
{
{myDataHPlaybackHints, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned long)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
}, /* kDataHPlaybackHintsSelect 0x103 */
{myDataHPlaybackHints64, kPascalStackBased
| RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DataHandler)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(wide*)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(wide*)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
}, /* kDataHPlaybackHints64Select 0x10E */
{NULL, 0}, /* kDataHGetDataRateSelect 0x110 */
{NULL, 0}, /* kDataHSetTimeHintsSelect 0x111 */
};
/* Component Functions */
static pascal ComponentResult myComponentOpen(ComponentInstance ci, ComponentInstance self)
{
DHData myData;
Handle storage;
ZeroMemory(&myData,sizeof(DHData));
PtrToHand( &myData, &storage, sizeof(DHData));
SetComponentInstanceStorage(self,storage);
return noErr;
}
static pascal ComponentResult myComponentClose(ComponentInstance ci, ComponentInstance self)
{
Handle storage = GetComponentInstanceStorage(self);
DHData *data;
if (storage)
{
data = (DHData*)*storage;
if (data && data->dataRef.pReader != NULL)
IAsyncReader_Release(data->dataRef.pReader);
DisposeHandle(storage);
SetComponentInstanceStorage(self,NULL);
}
return noErr;
}
static pascal ComponentResult myComponentCanDo(ComponentInstance ci, SInt16 ftnNumber)
{
TRACE("test 0x%x\n",ftnNumber);
if (ftnNumber <= kComponentOpenSelect && ftnNumber >= kComponentCanDoSelect)
return TRUE;
if (ftnNumber == kDataHPlaybackHintsSelect)
return TRUE;
if (ftnNumber == kDataHPlaybackHints64Select)
return TRUE;
if (ftnNumber > kDataHGetDataAvailability64Select)
return FALSE;
TRACE("impl? %i\n",(componentFunctions[ftnNumber].proc != NULL));
return (componentFunctions[ftnNumber].proc != NULL);
}
/* Main Proc */
static ComponentResult callOurFunction(LPVOID proc, ProcInfoType type, ComponentParameters * cp)
{
ComponentRoutineUPP myUUP;
ComponentResult result;
myUUP = NewComponentFunctionUPP(proc, type);
result = CallComponentFunction(cp, myUUP);
DisposeComponentFunctionUPP(myUUP);
return result;
}
static pascal ComponentResult myComponentRoutineProc ( ComponentParameters * cp,
Handle componentStorage)
{
switch (cp->what)
{
case kComponentOpenSelect:
return callOurFunction(myComponentOpen, uppCallComponentOpenProcInfo, cp);
case kComponentCloseSelect:
return callOurFunction(myComponentClose, uppCallComponentOpenProcInfo, cp);
case kComponentCanDoSelect:
return callOurFunction(myComponentCanDo, uppCallComponentCanDoProcInfo, cp);
case kDataHPlaybackHintsSelect:
return callOurFunction(componentFunctions_2[0].proc, componentFunctions_2[0].type, cp);
case kDataHPlaybackHints64Select:
return callOurFunction(componentFunctions_2[1].proc, componentFunctions_2[1].type, cp);
}
if (cp->what > 0 && cp->what <=kDataHGetDataAvailability64Select && componentFunctions[cp->what].proc)
return callOurFunction(componentFunctions[cp->what].proc, componentFunctions[cp->what].type, cp);
FIXME("unhandled select 0x%x\n",cp->what);
return badComponentSelector;
}
/*
* QuickTime Toolkit decoder header
*
* Copyright 2011 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
typedef struct WineDataRefRecordTag
{
IAsyncReader* pReader;
GUID streamSubtype;
} WineDataRefRecord;
HRESULT AccessPixelBufferPixels( CVPixelBufferRef pixelBuffer, LPBYTE pbDstStream);
void RegisterWineDataHandler( void );
/*
* QuickTime splitter + decoder
*
* Copyright 2011 Aric Stewart for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#define ULONG CoreFoundation_ULONG
#define HRESULT CoreFoundation_HRESULT
#define LoadResource __carbon_LoadResource
#define CompareString __carbon_CompareString
#define GetCurrentThread __carbon_GetCurrentThread
#define GetCurrentProcess __carbon_GetCurrentProcess
#define AnimatePalette __carbon_AnimatePalette
#define EqualRgn __carbon_EqualRgn
#define FillRgn __carbon_FillRgn
#define FrameRgn __carbon_FrameRgn
#define GetPixel __carbon_GetPixel
#define InvertRgn __carbon_InvertRgn
#define LineTo __carbon_LineTo
#define OffsetRgn __carbon_OffsetRgn
#define PaintRgn __carbon_PaintRgn
#define Polygon __carbon_Polygon
#define ResizePalette __carbon_ResizePalette
#define SetRectRgn __carbon_SetRectRgn
#define CheckMenuItem __carbon_CheckMenuItem
#define DeleteMenu __carbon_DeleteMenu
#define DrawMenuBar __carbon_DrawMenuBar
#define EnableMenuItem __carbon_EnableMenuItem
#define EqualRect __carbon_EqualRect
#define FillRect __carbon_FillRect
#define FrameRect __carbon_FrameRect
#define GetCursor __carbon_GetCursor
#define GetMenu __carbon_GetMenu
#define InvertRect __carbon_InvertRect
#define IsWindowVisible __carbon_IsWindowVisible
#define MoveWindow __carbon_MoveWindow
#define OffsetRect __carbon_OffsetRect
#define PtInRect __carbon_PtInRect
#define SetCursor __carbon_SetCursor
#define SetRect __carbon_SetRect
#define ShowCursor __carbon_ShowCursor
#define ShowWindow __carbon_ShowWindow
#define UnionRect __carbon_UnionRect
#include <QuickTime/Movies.h>
#include <QuickTime/QuickTimeComponents.h>
#undef LoadResource
#undef CompareString
#undef GetCurrentThread
#undef _CDECL
#undef GetCurrentProcess
#undef AnimatePalette
#undef EqualRgn
#undef FillRgn
#undef FrameRgn
#undef GetPixel
#undef InvertRgn
#undef LineTo
#undef OffsetRgn
#undef PaintRgn
#undef Polygon
#undef ResizePalette
#undef SetRectRgn
#undef CheckMenuItem
#undef DeleteMenu
#undef DrawMenuBar
#undef EnableMenuItem
#undef EqualRect
#undef FillRect
#undef FrameRect
#undef GetCursor
#undef GetMenu
#undef InvertRect
#undef IsWindowVisible
#undef MoveWindow
#undef OffsetRect
#undef PtInRect
#undef SetCursor
#undef SetRect
#undef ShowCursor
#undef ShowWindow
#undef UnionRect
#undef ULONG
#undef HRESULT
#undef STDMETHODCALLTYPE
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "winuser.h"
#include "dshow.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/strmbase.h"
#include "qtprivate.h"
#include "wineqtdecoder_classes.h"
WINE_DEFAULT_DEBUG_CHANNEL(qtsplitter);
typedef struct QTOutPin {
struct strmbase_source pin;
IQualityControl IQualityControl_iface;
SourceSeeking seeking;
AM_MEDIA_TYPE * pmt;
OutputQueue * queue;
} QTOutPin;
typedef struct QTInPin {
struct strmbase_sink pin;
GUID subType;
IAsyncReader *pReader;
IMemAllocator *pAlloc;
} QTInPin;
typedef struct QTSplitter {
struct strmbase_filter filter;
QTInPin pInputPin;
QTOutPin *pVideo_Pin;
QTOutPin *pAudio_Pin;
ALLOCATOR_PROPERTIES props;
Movie pQTMovie;
QTVisualContextRef vContext;
MovieAudioExtractionRef aSession;
HANDLE runEvent;
DWORD outputSize;
CRITICAL_SECTION csReceive;
TimeValue movie_time;
TimeValue movie_start;
TimeScale movie_scale;
HANDLE loaderThread;
HANDLE splitterThread;
} QTSplitter;
static const IBaseFilterVtbl QT_Vtbl;
static const IMediaSeekingVtbl QT_Seeking_Vtbl;
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name, const AM_MEDIA_TYPE *mt, BOOL video);
static HRESULT QT_RemoveOutputPins(QTSplitter *This);
static HRESULT WINAPI QTSplitter_ChangeStart(IMediaSeeking *iface);
static HRESULT WINAPI QTSplitter_ChangeStop(IMediaSeeking *iface);
static HRESULT WINAPI QTSplitter_ChangeRate(IMediaSeeking *iface);
static inline QTOutPin *impl_from_IMediaSeeking(IMediaSeeking *iface)
{
return CONTAINING_RECORD(iface, QTOutPin, seeking.IMediaSeeking_iface);
}
static inline QTSplitter *impl_from_strmbase_filter(struct strmbase_filter *iface)
{
return CONTAINING_RECORD(iface, QTSplitter, filter);
}
static inline QTSplitter *impl_from_IBaseFilter( IBaseFilter *iface )
{
return CONTAINING_RECORD(iface, QTSplitter, filter.IBaseFilter_iface);
}
static inline QTInPin *impl_from_IPin(IPin *iface)
{
return CONTAINING_RECORD(iface, QTInPin, pin.pin.IPin_iface);
}
/*
* Base Filter
*/
static struct strmbase_pin *qt_splitter_get_pin(struct strmbase_filter *base, unsigned int index)
{
QTSplitter *filter = impl_from_strmbase_filter(base);
if (index == 0)
return &filter->pInputPin.pin.pin;
else if (index == 1)
{
if (filter->pVideo_Pin)
return &filter->pVideo_Pin->pin.pin;
else if (filter->pAudio_Pin)
return &filter->pAudio_Pin->pin.pin;
}
else if (index == 2 && filter->pVideo_Pin && filter->pAudio_Pin)
return &filter->pAudio_Pin->pin.pin;
return NULL;
}
static void qt_splitter_destroy(struct strmbase_filter *iface)
{
QTSplitter *filter = impl_from_strmbase_filter(iface);
EnterCriticalSection(&filter->csReceive);
/* Don't need to clean up output pins, disconnecting input pin will do that */
if (filter->pInputPin.pin.pin.peer)
IPin_Disconnect(filter->pInputPin.pin.pin.peer);
if (filter->pInputPin.pAlloc)
IMemAllocator_Release(filter->pInputPin.pAlloc);
filter->pInputPin.pAlloc = NULL;
if (filter->pInputPin.pReader)
IAsyncReader_Release(filter->pInputPin.pReader);
filter->pInputPin.pReader = NULL;
if (filter->pQTMovie)
{
DisposeMovie(filter->pQTMovie);
filter->pQTMovie = NULL;
}
if (filter->vContext)
QTVisualContextRelease(filter->vContext);
if (filter->aSession)
MovieAudioExtractionEnd(filter->aSession);
ExitMoviesOnThread();
LeaveCriticalSection(&filter->csReceive);
if (filter->loaderThread)
{
WaitForSingleObject(filter->loaderThread, INFINITE);
CloseHandle(filter->loaderThread);
}
if (filter->splitterThread)
{
SetEvent(filter->runEvent);
WaitForSingleObject(filter->splitterThread, INFINITE);
CloseHandle(filter->splitterThread);
}
CloseHandle(filter->runEvent);
filter->csReceive.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&filter->csReceive);
strmbase_sink_cleanup(&filter->pInputPin.pin);
strmbase_filter_cleanup(&filter->filter);
CoTaskMemFree(filter);
}
static HRESULT qt_splitter_start_stream(struct strmbase_filter *iface, REFERENCE_TIME time)
{
QTSplitter *filter = impl_from_strmbase_filter(iface);
HRESULT hr;
EnterCriticalSection(&filter->csReceive);
if (filter->pVideo_Pin && filter->pVideo_Pin->pin.pin.peer
&& FAILED(hr = IMemAllocator_Commit(filter->pVideo_Pin->pin.pAllocator)))
ERR("Failed to commit video allocator, hr %#x.\n", hr);
if (filter->pAudio_Pin && filter->pAudio_Pin->pin.pin.peer
&& FAILED(hr = IMemAllocator_Commit(filter->pAudio_Pin->pin.pAllocator)))
ERR("Failed to commit audio allocator, hr %#x.\n", hr);
SetEvent(filter->runEvent);
LeaveCriticalSection(&filter->csReceive);
return S_OK;
}
static HRESULT qt_splitter_cleanup_stream(struct strmbase_filter *iface)
{
QTSplitter *filter = impl_from_strmbase_filter(iface);
EnterCriticalSection(&filter->csReceive);
IAsyncReader_BeginFlush(filter->pInputPin.pReader);
IAsyncReader_EndFlush(filter->pInputPin.pReader);
LeaveCriticalSection(&filter->csReceive);
return S_OK;
}
static const struct strmbase_filter_ops filter_ops =
{
.filter_get_pin = qt_splitter_get_pin,
.filter_destroy = qt_splitter_destroy,
.filter_start_stream = qt_splitter_start_stream,
.filter_cleanup_stream = qt_splitter_cleanup_stream,
};
static HRESULT sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
{
QTInPin *pin = impl_from_IPin(&iface->IPin_iface);
if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Stream))
{
pin->subType = mt->subtype;
return S_OK;
}
return S_FALSE;
}
static HRESULT QT_Process_Movie(QTSplitter *filter);
static HRESULT qt_splitter_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
{
QTSplitter *filter = impl_from_strmbase_filter(iface->pin.filter);
ALLOCATOR_PROPERTIES props;
IMemAllocator *allocator;
HRESULT hr = S_OK;
filter->pInputPin.pReader = NULL;
if (FAILED(hr = IPin_QueryInterface(peer, &IID_IAsyncReader, (void **)&filter->pInputPin.pReader)))
return hr;
if (FAILED(hr = QT_Process_Movie(filter)))
{
IAsyncReader_Release(filter->pInputPin.pReader);
filter->pInputPin.pReader = NULL;
return hr;
}
filter->pInputPin.pAlloc = NULL;
props.cBuffers = 8;
props.cbAlign = 1;
props.cbBuffer = filter->outputSize + props.cbAlign;
props.cbPrefix = 0;
/* Some applications depend on IAsyncReader::RequestAllocator() passing a
* non-NULL preferred allocator. */
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC,
&IID_IMemAllocator, (void **)&allocator);
if (FAILED(hr))
goto err;
hr = IAsyncReader_RequestAllocator(filter->pInputPin.pReader, allocator, &props, &filter->pInputPin.pAlloc);
IMemAllocator_Release(allocator);
if (FAILED(hr))
{
WARN("Failed to get allocator, hr %#x.\n", hr);
goto err;
}
if (FAILED(hr = IMemAllocator_Commit(filter->pInputPin.pAlloc)))
{
WARN("Failed to commit allocator, hr %#x.\n", hr);
goto err;
}
return S_OK;
err:
QT_RemoveOutputPins(filter);
IAsyncReader_Release(filter->pInputPin.pReader);
return hr;
}
static void qt_splitter_sink_disconnect(struct strmbase_sink *iface)
{
QTSplitter *filter = impl_from_strmbase_filter(iface->pin.filter);
IMemAllocator_Decommit(filter->pInputPin.pAlloc);
QT_RemoveOutputPins(filter);
}
static const struct strmbase_sink_ops sink_ops =
{
.base.pin_query_accept = sink_query_accept,
.sink_connect = qt_splitter_sink_connect,
.sink_disconnect = qt_splitter_sink_disconnect,
};
HRESULT qt_splitter_create(IUnknown *outer, IUnknown **out)
{
QTSplitter *This;
static const WCHAR wcsInputPinName[] = {'I','n','p','u','t',' ','P','i','n',0};
EnterMoviesOnThread(0);
RegisterWineDataHandler();
if (!(This = CoTaskMemAlloc(sizeof(*This))))
return E_OUTOFMEMORY;
ZeroMemory(This,sizeof(*This));
strmbase_filter_init(&This->filter, outer, &CLSID_QTSplitter, &filter_ops);
strmbase_sink_init(&This->pInputPin.pin, &This->filter, wcsInputPinName, &sink_ops, NULL);
InitializeCriticalSection(&This->csReceive);
This->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": QTSplitter.csReceive");
This->pVideo_Pin = NULL;
This->pAudio_Pin = NULL;
This->aSession = NULL;
This->runEvent = CreateEventW(NULL, 0, 0, NULL);
TRACE("Created QT splitter %p.\n", This);
*out = &This->filter.IUnknown_inner;
return S_OK;
}
static OSErr QT_Create_Extract_Session(QTSplitter *filter)
{
AudioStreamBasicDescription aDesc;
OSErr err;
WAVEFORMATEX* pvi;
pvi = (WAVEFORMATEX*)filter->pAudio_Pin->pmt->pbFormat;
err = MovieAudioExtractionBegin(filter->pQTMovie, 0, &filter->aSession);
if (err != noErr)
{
ERR("Failed to begin Extraction session %i\n",err);
return err;
}
err = MovieAudioExtractionGetProperty(filter->aSession,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription,
sizeof(AudioStreamBasicDescription), &aDesc, NULL);
if (err != noErr)
{
MovieAudioExtractionEnd(filter->aSession);
filter->aSession = NULL;
ERR("Failed to get session description %i\n",err);
return err;
}
aDesc.mFormatID = kAudioFormatLinearPCM;
aDesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger +
kAudioFormatFlagIsPacked;
aDesc.mFramesPerPacket = 1;
aDesc.mChannelsPerFrame = pvi->nChannels;
aDesc.mBitsPerChannel = pvi->wBitsPerSample;
aDesc.mSampleRate = pvi->nSamplesPerSec;
aDesc.mBytesPerFrame = (aDesc.mBitsPerChannel * aDesc.mChannelsPerFrame) / 8;
aDesc.mBytesPerPacket = aDesc.mBytesPerFrame * aDesc.mFramesPerPacket;
err = MovieAudioExtractionSetProperty(filter->aSession,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription,
sizeof(AudioStreamBasicDescription), &aDesc);
if (aDesc.mFormatID != kAudioFormatLinearPCM)
{
ERR("Not PCM Wave\n");
err = -1;
}
if (aDesc.mFormatFlags != kLinearPCMFormatFlagIsSignedInteger +
kAudioFormatFlagIsPacked)
{
ERR("Unhandled Flags\n");
err = -1;
}
if (aDesc.mFramesPerPacket != 1)
{
ERR("Unhandled Frames per packet %li\n",aDesc.mFramesPerPacket);
err = -1;
}
if (aDesc.mChannelsPerFrame != pvi->nChannels)
{
ERR("Unhandled channel count %li\n",aDesc.mChannelsPerFrame);
err = -1;
}
if (aDesc.mBitsPerChannel != pvi->wBitsPerSample)
{
ERR("Unhandled bits per channel %li\n",aDesc.mBitsPerChannel);
err = -1;
}
if (aDesc.mSampleRate != pvi->nSamplesPerSec)
{
ERR("Unhandled sample rate %f\n",aDesc.mSampleRate);
err = -1;
}
if (err != noErr)
{
ERR("Failed to create Extraction Session\n");
MovieAudioExtractionEnd(filter->aSession);
filter->aSession = NULL;
}
return err;
}
static DWORD WINAPI QTSplitter_loading_thread(LPVOID data)
{
QTSplitter *This = (QTSplitter *)data;
if (This->pAudio_Pin)
{
/* according to QA1469 a movie has to be fully loaded before we
can reliably start the Extraction session.
If loaded earlier, then we only get an extraction session for
the part of the movie that is loaded at that time.
We are trying to load as much of the movie as we can before we
start extracting. However we can recreate the extraction session
again when we run out of loaded extraction frames. But we want
to try to minimize that.
*/
EnterCriticalSection(&This->csReceive);
while(This->pQTMovie && GetMovieLoadState(This->pQTMovie) < kMovieLoadStateComplete)
{
MoviesTask(This->pQTMovie, 100);
LeaveCriticalSection(&This->csReceive);
Sleep(0);
EnterCriticalSection(&This->csReceive);
}
LeaveCriticalSection(&This->csReceive);
}
return 0;
}
static DWORD WINAPI QTSplitter_thread(LPVOID data)
{
QTSplitter *This = (QTSplitter *)data;
HRESULT hr = S_OK;
TimeValue next_time;
CVPixelBufferRef pixelBuffer = NULL;
OSStatus err;
TimeRecord tr;
WaitForSingleObject(This->runEvent, -1);
EnterCriticalSection(&This->csReceive);
if (!This->pQTMovie)
{
LeaveCriticalSection(&This->csReceive);
return 0;
}
/* Prime the pump: Needed for MPEG streams */
GetMovieNextInterestingTime(This->pQTMovie, nextTimeEdgeOK | nextTimeStep, 0, NULL, This->movie_time, 1, &next_time, NULL);
GetMovieTime(This->pQTMovie, &tr);
if (This->pAudio_Pin)
QT_Create_Extract_Session(This);
LeaveCriticalSection(&This->csReceive);
do
{
LONGLONG tStart=0, tStop=0;
LONGLONG mStart=0, mStop=0;
float time;
EnterCriticalSection(&This->csReceive);
if (!This->pQTMovie)
{
LeaveCriticalSection(&This->csReceive);
return 0;
}
GetMovieNextInterestingTime(This->pQTMovie, nextTimeStep, 0, NULL, This->movie_time, 1, &next_time, NULL);
if (next_time == -1)
{
TRACE("No next time\n");
LeaveCriticalSection(&This->csReceive);
break;
}
tr.value = SInt64ToWide(next_time);
SetMovieTime(This->pQTMovie, &tr);
MoviesTask(This->pQTMovie,0);
QTVisualContextTask(This->vContext);
TRACE("In loop at time %ld\n",This->movie_time);
TRACE("In Next time %ld\n",next_time);
mStart = This->movie_time;
mStop = next_time;
time = (float)(This->movie_time - This->movie_start) / This->movie_scale;
tStart = time * 10000000;
time = (float)(next_time - This->movie_start) / This->movie_scale;
tStop = time * 10000000;
/* Deliver Audio */
if (This->pAudio_Pin && This->pAudio_Pin->pin.pin.peer && This->aSession)
{
int data_size=0;
BYTE* ptr;
IMediaSample *sample = NULL;
AudioBufferList aData;
UInt32 flags;
UInt32 frames;
WAVEFORMATEX* pvi;
float duration;
pvi = (WAVEFORMATEX*)This->pAudio_Pin->pmt->pbFormat;
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->pAudio_Pin->pin, &sample, NULL, NULL, 0);
if (FAILED(hr))
{
ERR("Audio: Unable to get delivery buffer (%x)\n", hr);
goto audio_error;
}
hr = IMediaSample_GetPointer(sample, &ptr);
if (FAILED(hr))
{
ERR("Audio: Unable to get pointer to buffer (%x)\n", hr);
goto audio_error;
}
duration = (float)next_time / This->movie_scale;
time = (float)This->movie_time / This->movie_scale;
duration -= time;
frames = pvi->nSamplesPerSec * duration;
TRACE("Need audio for %f seconds (%li frames)\n",duration,frames);
data_size = IMediaSample_GetSize(sample);
if (data_size < frames * pvi->nBlockAlign)
FIXME("Audio buffer is too small\n");
aData.mNumberBuffers = 1;
aData.mBuffers[0].mNumberChannels = pvi->nChannels;
aData.mBuffers[0].mDataByteSize = data_size;
aData.mBuffers[0].mData = ptr;
err = MovieAudioExtractionFillBuffer(This->aSession, &frames, &aData, &flags);
if (frames == 0)
{
TimeRecord etr;
/* Ran out of frames, Restart the extraction session */
TRACE("Restarting extraction session\n");
MovieAudioExtractionEnd(This->aSession);
This->aSession = NULL;
QT_Create_Extract_Session(This);
etr = tr;
etr.value = SInt64ToWide(This->movie_time);
MovieAudioExtractionSetProperty(This->aSession,
kQTPropertyClass_MovieAudioExtraction_Movie,
kQTMovieAudioExtractionMoviePropertyID_CurrentTime,
sizeof(TimeRecord), &etr );
frames = pvi->nSamplesPerSec * duration;
aData.mNumberBuffers = 1;
aData.mBuffers[0].mNumberChannels = pvi->nChannels;
aData.mBuffers[0].mDataByteSize = data_size;
aData.mBuffers[0].mData = ptr;
MovieAudioExtractionFillBuffer(This->aSession, &frames, &aData, &flags);
}
TRACE("Got %i frames\n",(int)frames);
IMediaSample_SetActualDataLength(sample, frames * pvi->nBlockAlign);
IMediaSample_SetMediaTime(sample, &mStart, &mStop);
IMediaSample_SetTime(sample, &tStart, &tStop);
hr = OutputQueue_Receive(This->pAudio_Pin->queue, sample);
TRACE("Audio Delivered (%x)\n",hr);
audio_error:
if (sample)
IMediaSample_Release(sample);
}
else
TRACE("Audio Pin not connected or no Audio\n");
/* Deliver Video */
if (This->pVideo_Pin && QTVisualContextIsNewImageAvailable(This->vContext,0))
{
err = QTVisualContextCopyImageForTime(This->vContext, NULL, NULL, &pixelBuffer);
if (err == noErr)
{
int data_size=0;
BYTE* ptr;
IMediaSample *sample = NULL;
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->pVideo_Pin->pin, &sample, NULL, NULL, 0);
if (FAILED(hr))
{
ERR("Video: Unable to get delivery buffer (%x)\n", hr);
goto video_error;
}
data_size = IMediaSample_GetSize(sample);
if (data_size < This->outputSize)
{
ERR("Sample size is too small %d < %d\n", data_size, This->outputSize)
;
hr = E_FAIL;
goto video_error;
}
hr = IMediaSample_GetPointer(sample, &ptr);
if (FAILED(hr))
{
ERR("Video: Unable to get pointer to buffer (%x)\n", hr);
goto video_error;
}
hr = AccessPixelBufferPixels( pixelBuffer, ptr);
if (FAILED(hr))
{
ERR("Failed to access Pixels\n");
goto video_error;
}
IMediaSample_SetActualDataLength(sample, This->outputSize);
IMediaSample_SetMediaTime(sample, &mStart, &mStop);
IMediaSample_SetTime(sample, &tStart, &tStop);
hr = OutputQueue_Receive(This->pVideo_Pin->queue, sample);
TRACE("Video Delivered (%x)\n",hr);
video_error:
if (sample)
IMediaSample_Release(sample);
if (pixelBuffer)
CVPixelBufferRelease(pixelBuffer);
}
}
else
TRACE("No video to deliver\n");
This->movie_time = next_time;
LeaveCriticalSection(&This->csReceive);
} while (hr == S_OK);
if (This->pAudio_Pin)
OutputQueue_EOS(This->pAudio_Pin->queue);
if (This->pVideo_Pin)
OutputQueue_EOS(This->pVideo_Pin->queue);
return hr;
}
static void free_source_pin(QTOutPin *pin)
{
if (pin->pin.pin.peer)
{
if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator)))
IPin_Disconnect(pin->pin.pin.peer);
IPin_Disconnect(&pin->pin.pin.IPin_iface);
}
DeleteMediaType(pin->pmt);
strmbase_seeking_cleanup(&pin->seeking);
strmbase_source_cleanup(&pin->pin);
heap_free(pin);
}
/*
* Input Pin
*/
static HRESULT QT_RemoveOutputPins(QTSplitter *This)
{
if (This->pVideo_Pin)
{
OutputQueue_Destroy(This->pVideo_Pin->queue);
free_source_pin(This->pVideo_Pin);
This->pVideo_Pin = NULL;
}
if (This->pAudio_Pin)
{
OutputQueue_Destroy(This->pAudio_Pin->queue);
free_source_pin(This->pAudio_Pin);
This->pAudio_Pin = NULL;
}
BaseFilterImpl_IncrementPinVersion(&This->filter);
return S_OK;
}
static HRESULT QT_Process_Video_Track(QTSplitter* filter, Track trk)
{
AM_MEDIA_TYPE amt;
VIDEOINFOHEADER * pvi;
HRESULT hr = S_OK;
OSErr err;
static const WCHAR szwVideoOut[] = {'V','i','d','e','o',0};
CFMutableDictionaryRef pixelBufferOptions = NULL;
CFMutableDictionaryRef visualContextOptions = NULL;
CFNumberRef n = NULL;
int t;
DWORD outputWidth, outputHeight, outputDepth;
Fixed trackWidth, trackHeight;
Media videoMedia;
long sampleCount;
TimeValue64 duration;
TimeScale timeScale;
ZeroMemory(&amt, sizeof(amt));
amt.formattype = FORMAT_VideoInfo;
amt.majortype = MEDIATYPE_Video;
amt.subtype = MEDIASUBTYPE_RGB24;
GetTrackDimensions(trk, &trackWidth, &trackHeight);
outputDepth = 3;
outputWidth = Fix2Long(trackWidth);
outputHeight = Fix2Long(trackHeight);
TRACE("Width %i Height %i\n",outputWidth, outputHeight);
amt.cbFormat = sizeof(VIDEOINFOHEADER);
amt.pbFormat = CoTaskMemAlloc(amt.cbFormat);
ZeroMemory(amt.pbFormat, amt.cbFormat);
pvi = (VIDEOINFOHEADER *)amt.pbFormat;
pvi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = outputWidth;
pvi->bmiHeader.biHeight = outputHeight;
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biBitCount = 24;
pvi->bmiHeader.biCompression = BI_RGB;
pvi->bmiHeader.biSizeImage = outputWidth * outputHeight * outputDepth;
filter->outputSize = pvi->bmiHeader.biSizeImage;
amt.lSampleSize = 0;
pixelBufferOptions = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
t = k32ARGBPixelFormat;
n = CFNumberCreate(NULL, kCFNumberIntType, &t);
CFDictionaryAddValue(pixelBufferOptions, kCVPixelBufferPixelFormatTypeKey, n);
CFRelease(n);
n = CFNumberCreate(NULL, kCFNumberIntType, &outputWidth);
CFDictionaryAddValue(pixelBufferOptions, kCVPixelBufferWidthKey, n);
CFRelease(n);
n = CFNumberCreate(NULL, kCFNumberIntType, &outputHeight);
CFDictionaryAddValue(pixelBufferOptions, kCVPixelBufferHeightKey, n);
CFRelease(n);
t = 16;
n = CFNumberCreate(NULL, kCFNumberIntType, &t);
CFDictionaryAddValue(pixelBufferOptions, kCVPixelBufferBytesPerRowAlignmentKey, n);
CFRelease(n);
visualContextOptions = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(visualContextOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferOptions);
err = QTPixelBufferContextCreate(NULL, visualContextOptions,&filter->vContext);
CFRelease(pixelBufferOptions);
CFRelease(visualContextOptions);
if (err != noErr)
{
ERR("Failed to create Visual Context\n");
return E_FAIL;
}
err = SetMovieVisualContext(filter->pQTMovie, filter->vContext);
if (err != noErr)
{
ERR("Failed to set Visual Context\n");
return E_FAIL;
}
videoMedia = GetTrackMedia(trk);
sampleCount = GetMediaSampleCount(videoMedia);
timeScale = GetMediaTimeScale(videoMedia);
duration = GetMediaDisplayDuration(videoMedia);
pvi->AvgTimePerFrame = (100000.0 * sampleCount * timeScale) / duration;
hr = QT_AddPin(filter, szwVideoOut, &amt, TRUE);
if (FAILED(hr))
ERR("Failed to add Video Track\n");
else
TRACE("Video Pin %p\n",filter->pVideo_Pin);
return hr;
}
static HRESULT QT_Process_Audio_Track(QTSplitter* filter, Track trk)
{
AM_MEDIA_TYPE amt;
WAVEFORMATEX* pvi;
HRESULT hr = S_OK;
static const WCHAR szwAudioOut[] = {'A','u','d','i','o',0};
Media audioMedia;
SoundDescriptionHandle aDesc = (SoundDescriptionHandle) NewHandle(sizeof(SoundDescription));
audioMedia = GetTrackMedia(trk);
GetMediaSampleDescription(audioMedia, 1, (SampleDescriptionHandle)aDesc);
ZeroMemory(&amt, sizeof(amt));
amt.formattype = FORMAT_WaveFormatEx;
amt.majortype = MEDIATYPE_Audio;
amt.subtype = MEDIASUBTYPE_PCM;
amt.bTemporalCompression = 0;
amt.cbFormat = sizeof(WAVEFORMATEX);
amt.pbFormat = CoTaskMemAlloc(amt.cbFormat);
ZeroMemory(amt.pbFormat, amt.cbFormat);
pvi = (WAVEFORMATEX*)amt.pbFormat;
pvi->cbSize = sizeof(WAVEFORMATEX);
pvi->wFormatTag = WAVE_FORMAT_PCM;
pvi->nChannels = ((SoundDescription)**aDesc).numChannels;
if (pvi->nChannels < 1 || pvi->nChannels > 2)
pvi->nChannels = 2;
pvi->nSamplesPerSec = (((SoundDescription)**aDesc).sampleRate/65536);
if (pvi->nSamplesPerSec < 8000 || pvi->nChannels > 48000)
pvi->nSamplesPerSec = 44100;
pvi->wBitsPerSample = ((SoundDescription)**aDesc).sampleSize;
if (pvi->wBitsPerSample < 8 || pvi->wBitsPerSample > 32)
pvi->wBitsPerSample = 16;
pvi->nBlockAlign = (pvi->nChannels * pvi->wBitsPerSample) / 8;
pvi->nAvgBytesPerSec = pvi->nSamplesPerSec * pvi->nBlockAlign;
DisposeHandle((Handle)aDesc);
hr = QT_AddPin(filter, szwAudioOut, &amt, FALSE);
if (FAILED(hr))
ERR("Failed to add Audio Track\n");
else
TRACE("Audio Pin %p\n",filter->pAudio_Pin);
return hr;
}
static HRESULT QT_Process_Movie(QTSplitter* filter)
{
HRESULT hr = S_OK;
OSErr err;
WineDataRefRecord ptrDataRefRec;
Handle dataRef = NULL;
Track trk;
short id = 0;
DWORD tid;
LONGLONG time, duration;
TRACE("Trying movie connect\n");
ptrDataRefRec.pReader = filter->pInputPin.pReader;
ptrDataRefRec.streamSubtype = filter->pInputPin.subType;
PtrToHand( &ptrDataRefRec, &dataRef, sizeof(WineDataRefRecord));
err = NewMovieFromDataRef(&filter->pQTMovie, newMovieActive|newMovieDontInteractWithUser|newMovieDontAutoUpdateClock|newMovieDontAskUnresolvedDataRefs|newMovieAsyncOK, &id, dataRef, 'WINE');
DisposeHandle(dataRef);
if (err != noErr)
{
FIXME("QuickTime cannot handle media type(%i)\n",err);
return VFW_E_TYPE_NOT_ACCEPTED;
}
PrePrerollMovie(filter->pQTMovie, 0, fixed1, NULL, NULL);
PrerollMovie(filter->pQTMovie, 0, fixed1);
GoToBeginningOfMovie(filter->pQTMovie);
SetMovieActive(filter->pQTMovie,TRUE);
if (GetMovieLoadState(filter->pQTMovie) < kMovieLoadStateLoaded)
MoviesTask(filter->pQTMovie,100);
trk = GetMovieIndTrackType(filter->pQTMovie, 1, VisualMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly);
TRACE("%p is a video track\n",trk);
if (trk)
hr = QT_Process_Video_Track(filter, trk);
if (FAILED(hr))
return hr;
trk = GetMovieIndTrackType(filter->pQTMovie, 1, AudioMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly);
TRACE("%p is an audio track\n",trk);
if (trk)
hr = QT_Process_Audio_Track(filter, trk);
time = GetMovieDuration(filter->pQTMovie);
filter->movie_scale = GetMovieTimeScale(filter->pQTMovie);
duration = ((double)time / filter->movie_scale) * 10000000;
TRACE("Movie duration is %s.\n", wine_dbgstr_longlong(duration));
if (filter->pVideo_Pin)
filter->pVideo_Pin->seeking.llStop = filter->pVideo_Pin->seeking.llDuration = duration;
if (filter->pAudio_Pin)
filter->pAudio_Pin->seeking.llStop = filter->pAudio_Pin->seeking.llDuration = duration;
filter->loaderThread = CreateThread(NULL, 0, QTSplitter_loading_thread, filter, 0, &tid);
if (filter->loaderThread)
TRACE("Created loading thread 0x%08x\n", tid);
filter->splitterThread = CreateThread(NULL, 0, QTSplitter_thread, filter, 0, &tid);
if (filter->splitterThread)
TRACE("Created processing thread 0x%08x\n", tid);
else
hr = HRESULT_FROM_WIN32(GetLastError());
return hr;
}
static inline QTOutPin *impl_source_from_strmbase_pin(struct strmbase_pin *iface)
{
return CONTAINING_RECORD(iface, QTOutPin, pin.pin);
}
static inline QTOutPin *impl_QTOutPin_from_BaseOutputPin(struct strmbase_source *iface)
{
return CONTAINING_RECORD(iface, QTOutPin, pin);
}
static HRESULT source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
{
QTOutPin *pin = impl_source_from_strmbase_pin(&iface->IPin_iface);
if (IsEqualGUID(iid, &IID_IMediaSeeking))
*out = &pin->seeking.IMediaSeeking_iface;
else if (IsEqualGUID(iid, &IID_IQualityControl))
*out = &pin->IQualityControl_iface;
else
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown *)*out);
return S_OK;
}
static HRESULT source_query_accept(struct strmbase_pin *base, const AM_MEDIA_TYPE *amt)
{
FIXME("(%p) stub\n", base);
return S_OK;
}
static HRESULT source_get_media_type(struct strmbase_pin *iface, unsigned int iPosition, AM_MEDIA_TYPE *pmt)
{
QTOutPin *This = impl_source_from_strmbase_pin(iface);
if (iPosition > 0)
return VFW_S_NO_MORE_ITEMS;
CopyMediaType(pmt, This->pmt);
return S_OK;
}
static HRESULT WINAPI QTOutPin_DecideBufferSize(struct strmbase_source *iface,
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
/* Unused */
return S_OK;
}
static HRESULT WINAPI QTOutPin_DecideAllocator(struct strmbase_source *iface,
IMemInputPin *pPin, IMemAllocator **pAlloc)
{
HRESULT hr;
QTOutPin *This = impl_QTOutPin_from_BaseOutputPin(iface);
QTSplitter *QTfilter = impl_from_strmbase_filter(This->pin.pin.filter);
*pAlloc = NULL;
if (QTfilter->pInputPin.pAlloc)
{
hr = IMemInputPin_NotifyAllocator(pPin, QTfilter->pInputPin.pAlloc, FALSE);
if (SUCCEEDED(hr))
{
*pAlloc = QTfilter->pInputPin.pAlloc;
IMemAllocator_AddRef(*pAlloc);
}
}
else
hr = VFW_E_NO_ALLOCATOR;
return hr;
}
static inline QTOutPin *impl_from_IQualityControl( IQualityControl *iface )
{
return CONTAINING_RECORD(iface, QTOutPin, IQualityControl_iface);
}
HRESULT WINAPI QT_QualityControl_QueryInterface(IQualityControl *iface, REFIID riid, void **ppv)
{
QTOutPin *This = impl_from_IQualityControl(iface);
return IPin_QueryInterface(&This->pin.pin.IPin_iface, riid, ppv);
}
ULONG WINAPI QT_QualityControl_AddRef(IQualityControl *iface)
{
QTOutPin *This = impl_from_IQualityControl(iface);
return IPin_AddRef(&This->pin.pin.IPin_iface);
}
ULONG WINAPI QT_QualityControl_Release(IQualityControl *iface)
{
QTOutPin *This = impl_from_IQualityControl(iface);
return IPin_Release(&This->pin.pin.IPin_iface);
}
static HRESULT WINAPI QT_QualityControl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality qm)
{
REFERENCE_TIME late = qm.Late;
if (qm.Late < 0 && -qm.Late > qm.TimeStamp)
late = -qm.TimeStamp;
/* TODO: Do Something */
return S_OK;
}
HRESULT WINAPI QT_QualityControl_SetSink(IQualityControl *iface, IQualityControl *tonotify)
{
/* Do nothing */
return S_OK;
}
static const IQualityControlVtbl QTOutPin_QualityControl_Vtbl = {
QT_QualityControl_QueryInterface,
QT_QualityControl_AddRef,
QT_QualityControl_Release,
QT_QualityControl_Notify,
QT_QualityControl_SetSink
};
static const struct strmbase_source_ops source_ops =
{
.base.pin_query_accept = source_query_accept,
.base.pin_get_media_type = source_get_media_type,
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
.pfnDecideBufferSize = QTOutPin_DecideBufferSize,
.pfnDecideAllocator = QTOutPin_DecideAllocator,
};
static const OutputQueueFuncTable output_OutputQueueFuncTable = {
OutputQueueImpl_ThreadProc
};
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name,
const AM_MEDIA_TYPE *mt, BOOL video)
{
QTOutPin *pin;
if (!(pin = heap_alloc_zero(sizeof(*pin))))
return E_OUTOFMEMORY;
if (video)
filter->pVideo_Pin = pin;
else
filter->pAudio_Pin = pin;
strmbase_source_init(&pin->pin, &filter->filter, name, &source_ops);
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
CopyMediaType(pin->pmt, mt);
pin->IQualityControl_iface.lpVtbl = &QTOutPin_QualityControl_Vtbl;
strmbase_seeking_init(&pin->seeking, &QT_Seeking_Vtbl,
QTSplitter_ChangeStop, QTSplitter_ChangeStart, QTSplitter_ChangeRate);
BaseFilterImpl_IncrementPinVersion(&filter->filter);
return OutputQueue_Construct(&pin->pin, TRUE, TRUE, 5, FALSE,
THREAD_PRIORITY_NORMAL, &output_OutputQueueFuncTable, &pin->queue);
}
static HRESULT WINAPI QTSplitter_ChangeStart(IMediaSeeking *iface)
{
QTOutPin *pin = impl_from_IMediaSeeking(iface);
QTSplitter *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
TRACE("(%p)\n", iface);
EnterCriticalSection(&filter->csReceive);
filter->movie_start = filter->movie_time = (pin->seeking.llCurrent * filter->movie_scale)/10000000;
LeaveCriticalSection(&filter->csReceive);
return S_OK;
}
static HRESULT WINAPI QTSplitter_ChangeStop(IMediaSeeking *iface)
{
FIXME("(%p) filter hasn't implemented stop position change!\n", iface);
return S_OK;
}
static HRESULT WINAPI QTSplitter_ChangeRate(IMediaSeeking *iface)
{
FIXME("(%p) filter hasn't implemented rate change!\n", iface);
return S_OK;
}
static HRESULT WINAPI QT_Seeking_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out)
{
QTOutPin *pin = impl_from_IMediaSeeking(iface);
return IPin_QueryInterface(&pin->pin.pin.IPin_iface, iid, out);
}
static ULONG WINAPI QT_Seeking_AddRef(IMediaSeeking * iface)
{
QTOutPin *pin = impl_from_IMediaSeeking(iface);
return IPin_AddRef(&pin->pin.pin.IPin_iface);
}
static ULONG WINAPI QT_Seeking_Release(IMediaSeeking * iface)
{
QTOutPin *pin = impl_from_IMediaSeeking(iface);
return IPin_Release(&pin->pin.pin.IPin_iface);
}
static const IMediaSeekingVtbl QT_Seeking_Vtbl =
{
QT_Seeking_QueryInterface,
QT_Seeking_AddRef,
QT_Seeking_Release,
SourceSeekingImpl_GetCapabilities,
SourceSeekingImpl_CheckCapabilities,
SourceSeekingImpl_IsFormatSupported,
SourceSeekingImpl_QueryPreferredFormat,
SourceSeekingImpl_GetTimeFormat,
SourceSeekingImpl_IsUsingTimeFormat,
SourceSeekingImpl_SetTimeFormat,
SourceSeekingImpl_GetDuration,
SourceSeekingImpl_GetStopPosition,
SourceSeekingImpl_GetCurrentPosition,
SourceSeekingImpl_ConvertTimeFormat,
SourceSeekingImpl_SetPositions,
SourceSeekingImpl_GetPositions,
SourceSeekingImpl_GetAvailable,
SourceSeekingImpl_SetRate,
SourceSeekingImpl_GetRate,
SourceSeekingImpl_GetPreroll
};
/*
* QuickTime Toolkit decoder utils
*
* Copyright 2011 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#define ULONG CoreFoundation_ULONG
#define HRESULT CoreFoundation_HRESULT
#define LoadResource __carbon_LoadResource
#define CompareString __carbon_CompareString
#define GetCurrentThread __carbon_GetCurrentThread
#define GetCurrentProcess __carbon_GetCurrentProcess
#define AnimatePalette __carbon_AnimatePalette
#define EqualRgn __carbon_EqualRgn
#define FillRgn __carbon_FillRgn
#define FrameRgn __carbon_FrameRgn
#define GetPixel __carbon_GetPixel
#define InvertRgn __carbon_InvertRgn
#define LineTo __carbon_LineTo
#define OffsetRgn __carbon_OffsetRgn
#define PaintRgn __carbon_PaintRgn
#define Polygon __carbon_Polygon
#define ResizePalette __carbon_ResizePalette
#define SetRectRgn __carbon_SetRectRgn
#define CheckMenuItem __carbon_CheckMenuItem
#define DeleteMenu __carbon_DeleteMenu
#define DrawMenuBar __carbon_DrawMenuBar
#define EnableMenuItem __carbon_EnableMenuItem
#define EqualRect __carbon_EqualRect
#define FillRect __carbon_FillRect
#define FrameRect __carbon_FrameRect
#define GetCursor __carbon_GetCursor
#define GetMenu __carbon_GetMenu
#define InvertRect __carbon_InvertRect
#define IsWindowVisible __carbon_IsWindowVisible
#define MoveWindow __carbon_MoveWindow
#define OffsetRect __carbon_OffsetRect
#define PtInRect __carbon_PtInRect
#define SetCursor __carbon_SetCursor
#define SetRect __carbon_SetRect
#define ShowCursor __carbon_ShowCursor
#define ShowWindow __carbon_ShowWindow
#define UnionRect __carbon_UnionRect
#include <CoreVideo/CVPixelBuffer.h>
#undef LoadResource
#undef CompareString
#undef GetCurrentThread
#undef _CDECL
#undef GetCurrentProcess
#undef AnimatePalette
#undef EqualRgn
#undef FillRgn
#undef FrameRgn
#undef GetPixel
#undef InvertRgn
#undef LineTo
#undef OffsetRgn
#undef PaintRgn
#undef Polygon
#undef ResizePalette
#undef SetRectRgn
#undef CheckMenuItem
#undef DeleteMenu
#undef DrawMenuBar
#undef EnableMenuItem
#undef EqualRect
#undef FillRect
#undef FrameRect
#undef GetCursor
#undef GetMenu
#undef InvertRect
#undef IsWindowVisible
#undef MoveWindow
#undef OffsetRect
#undef PtInRect
#undef SetCursor
#undef SetRect
#undef ShowCursor
#undef ShowWindow
#undef UnionRect
#undef ULONG
#undef HRESULT
#undef STDMETHODCALLTYPE
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "winuser.h"
#include "dshow.h"
#include "wine/debug.h"
#include "qtprivate.h"
WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder);
typedef struct {
UInt8 a; /* Alpha Channel */
UInt8 r; /* red component */
UInt8 g; /* green component */
UInt8 b; /* blue component */
} ARGBPixelRecord, *ARGBPixelPtr, **ARGBPixelHdl;
HRESULT AccessPixelBufferPixels( CVPixelBufferRef pixelBuffer, LPBYTE pbDstStream)
{
LPBYTE pPixels = NULL;
size_t bytesPerRow = 0, height = 0, width = 0;
OSType actualType;
int i;
actualType = CVPixelBufferGetPixelFormatType(pixelBuffer);
if (k32ARGBPixelFormat != actualType)
{
ERR("Pixel Buffer is not desired Type\n");
return E_FAIL;
}
CVPixelBufferLockBaseAddress(pixelBuffer,0);
pPixels = (LPBYTE)CVPixelBufferGetBaseAddress(pixelBuffer);
bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer);
height = CVPixelBufferGetHeight(pixelBuffer);
width = CVPixelBufferGetWidth(pixelBuffer);
for (i = 1; i <= height; i++)
{
int j;
LPBYTE out = pbDstStream + ((height - i) * width * 3);
for (j = 0; j < width; j++)
{
*((DWORD*)out) = (((ARGBPixelPtr)pPixels)[j].r) << 16
| (((ARGBPixelPtr)pPixels)[j].g) << 8
| (((ARGBPixelPtr)pPixels)[j].b);
out+=3;
}
pPixels += bytesPerRow;
}
CVPixelBufferUnlockBaseAddress(pixelBuffer,0);
return S_OK;
}
/*
* QuickTime Toolkit decoder filter for video
*
* Copyright 2010 Aric Stewart, CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#define ULONG CoreFoundation_ULONG
#define HRESULT CoreFoundation_HRESULT
#define LoadResource __carbon_LoadResource
#define CompareString __carbon_CompareString
#define GetCurrentThread __carbon_GetCurrentThread
#define GetCurrentProcess __carbon_GetCurrentProcess
#define AnimatePalette __carbon_AnimatePalette
#define EqualRgn __carbon_EqualRgn
#define FillRgn __carbon_FillRgn
#define FrameRgn __carbon_FrameRgn
#define GetPixel __carbon_GetPixel
#define InvertRgn __carbon_InvertRgn
#define LineTo __carbon_LineTo
#define OffsetRgn __carbon_OffsetRgn
#define PaintRgn __carbon_PaintRgn
#define Polygon __carbon_Polygon
#define ResizePalette __carbon_ResizePalette
#define SetRectRgn __carbon_SetRectRgn
#define CheckMenuItem __carbon_CheckMenuItem
#define DeleteMenu __carbon_DeleteMenu
#define DrawMenuBar __carbon_DrawMenuBar
#define EnableMenuItem __carbon_EnableMenuItem
#define EqualRect __carbon_EqualRect
#define FillRect __carbon_FillRect
#define FrameRect __carbon_FrameRect
#define GetCursor __carbon_GetCursor
#define GetMenu __carbon_GetMenu
#define InvertRect __carbon_InvertRect
#define IsWindowVisible __carbon_IsWindowVisible
#define MoveWindow __carbon_MoveWindow
#define OffsetRect __carbon_OffsetRect
#define PtInRect __carbon_PtInRect
#define SetCursor __carbon_SetCursor
#define SetRect __carbon_SetRect
#define ShowCursor __carbon_ShowCursor
#define ShowWindow __carbon_ShowWindow
#define UnionRect __carbon_UnionRect
#include <QuickTime/ImageCompression.h>
#include <CoreVideo/CVPixelBuffer.h>
#undef LoadResource
#undef CompareString
#undef GetCurrentThread
#undef _CDECL
#undef GetCurrentProcess
#undef AnimatePalette
#undef EqualRgn
#undef FillRgn
#undef FrameRgn
#undef GetPixel
#undef InvertRgn
#undef LineTo
#undef OffsetRgn
#undef PaintRgn
#undef Polygon
#undef ResizePalette
#undef SetRectRgn
#undef CheckMenuItem
#undef DeleteMenu
#undef DrawMenuBar
#undef EnableMenuItem
#undef EqualRect
#undef FillRect
#undef FrameRect
#undef GetCursor
#undef GetMenu
#undef InvertRect
#undef IsWindowVisible
#undef MoveWindow
#undef OffsetRect
#undef PtInRect
#undef SetCursor
#undef SetRect
#undef ShowCursor
#undef ShowWindow
#undef UnionRect
#undef ULONG
#undef HRESULT
#undef STDMETHODCALLTYPE
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "winuser.h"
#include "dshow.h"
#include "uuids.h"
#include "amvideo.h"
#include "strmif.h"
#include "vfwmsgs.h"
#include "vfw.h"
#include "dvdmedia.h"
#include <assert.h>
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/strmbase.h"
#include "qtprivate.h"
#include "wineqtdecoder_classes.h"
WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder);
typedef struct QTVDecoderImpl
{
struct strmbase_filter filter;
CRITICAL_SECTION stream_cs;
AM_MEDIA_TYPE mt;
struct strmbase_source source;
IUnknown *seeking;
struct strmbase_sink sink;
ImageDescriptionHandle hImageDescription;
CFMutableDictionaryRef outputBufferAttributes;
ICMDecompressionSessionRef decompressionSession;
HRESULT decodeHR;
DWORD outputSize;
} QTVDecoderImpl;
static inline QTVDecoderImpl *impl_from_strmbase_filter(struct strmbase_filter *iface)
{
return CONTAINING_RECORD(iface, QTVDecoderImpl, filter);
}
static HRESULT video_decoder_sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface->filter);
if (IsEqualGUID(iid, &IID_IMemInputPin))
*out = &filter->sink.IMemInputPin_iface;
else
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown *)*out);
return S_OK;
}
static void trackingCallback(
void *decompressionTrackingRefCon,
OSStatus result,
ICMDecompressionTrackingFlags decompressionTrackingFlags,
CVPixelBufferRef pixelBuffer,
TimeValue64 displayTime,
TimeValue64 displayDuration,
ICMValidTimeFlags validTimeFlags,
void *reserved,
void *sourceFrameRefCon )
{
QTVDecoderImpl *This = (QTVDecoderImpl*)decompressionTrackingRefCon;
IMediaSample *pSample = (IMediaSample*)sourceFrameRefCon;
HRESULT hr = S_OK;
IMediaSample* pOutSample = NULL;
LPBYTE pbDstStream;
DWORD cbDstStream;
if (result != noErr)
{
ERR("Error from Codec, no frame decompressed\n");
return;
}
if (!pixelBuffer)
{
ERR("No pixel buffer, no frame decompressed\n");
return;
}
EnterCriticalSection(&This->stream_cs);
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->source, &pOutSample, NULL, NULL, 0);
if (FAILED(hr)) {
ERR("Unable to get delivery buffer (%x)\n", hr);
goto error;
}
hr = IMediaSample_SetActualDataLength(pOutSample, 0);
assert(hr == S_OK);
hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
if (FAILED(hr)) {
ERR("Unable to get pointer to buffer (%x)\n", hr);
goto error;
}
cbDstStream = IMediaSample_GetSize(pOutSample);
if (cbDstStream < This->outputSize) {
ERR("Sample size is too small %d < %d\n", cbDstStream, This->outputSize);
hr = E_FAIL;
goto error;
}
hr = AccessPixelBufferPixels(pixelBuffer, pbDstStream);
if (FAILED(hr))
goto error;
IMediaSample_SetActualDataLength(pOutSample, This->outputSize);
IMediaSample_SetPreroll(pOutSample, (IMediaSample_IsPreroll(pSample) == S_OK));
IMediaSample_SetDiscontinuity(pOutSample, (IMediaSample_IsDiscontinuity(pSample) == S_OK));
IMediaSample_SetSyncPoint(pOutSample, (IMediaSample_IsSyncPoint(pSample) == S_OK));
if (!validTimeFlags)
IMediaSample_SetTime(pOutSample, NULL, NULL);
else
{
LONGLONG tStart, tStop;
if (validTimeFlags & kICMValidTime_DisplayTimeStampIsValid)
tStart = displayTime;
else
tStart = 0;
if (validTimeFlags & kICMValidTime_DisplayDurationIsValid)
tStop = tStart + displayDuration;
else
tStop = tStart;
IMediaSample_SetTime(pOutSample, &tStart, &tStop);
}
hr = IMemInputPin_Receive(This->source.pMemInputPin, pOutSample);
if (hr != S_OK && hr != VFW_E_NOT_CONNECTED)
ERR("Error sending sample (%x)\n", hr);
error:
LeaveCriticalSection(&This->stream_cs);
if (pOutSample)
IMediaSample_Release(pOutSample);
This->decodeHR = hr;
}
static HRESULT WINAPI video_decoder_sink_Receive(struct strmbase_sink *iface, IMediaSample *pSample)
{
QTVDecoderImpl *This = impl_from_strmbase_filter(iface->pin.filter);
HRESULT hr;
DWORD cbSrcStream;
LPBYTE pbSrcStream;
ICMFrameTimeRecord frameTime = {{0}};
TimeValue time = 1;
TimeScale timeScale = 1;
OSStatus err = noErr;
LONGLONG tStart, tStop;
EnterCriticalSection(&This->stream_cs);
hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
if (FAILED(hr))
{
ERR("Cannot get pointer to sample data (%x)\n", hr);
goto error;
}
cbSrcStream = IMediaSample_GetActualDataLength(pSample);
if (IMediaSample_GetTime(pSample, &tStart, &tStop) != S_OK)
tStart = tStop = 0;
time = tStart;
frameTime.recordSize = sizeof(ICMFrameTimeRecord);
*(TimeValue64 *)&frameTime.value = tStart;
frameTime.scale = 1;
frameTime.rate = fixed1;
frameTime.duration = tStop - tStart;
frameTime.frameNumber = 0;
frameTime.flags = icmFrameTimeIsNonScheduledDisplayTime;
err = ICMDecompressionSessionDecodeFrame(This->decompressionSession,
(UInt8 *)pbSrcStream, cbSrcStream, NULL, &frameTime, pSample);
if (err != noErr)
{
ERR("Error with ICMDecompressionSessionDecodeFrame\n");
hr = E_FAIL;
goto error;
}
ICMDecompressionSessionSetNonScheduledDisplayTime(This->decompressionSession, time, timeScale, 0);
ICMDecompressionSessionFlush(This->decompressionSession);
hr = This->decodeHR;
error:
LeaveCriticalSection(&This->stream_cs);
return hr;
}
static HRESULT video_decoder_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *pmt)
{
QTVDecoderImpl *This = impl_from_strmbase_filter(iface->pin.filter);
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
OSErr err = noErr;
AM_MEDIA_TYPE *outpmt = &This->mt;
CFNumberRef n = NULL;
FreeMediaType(outpmt);
CopyMediaType(outpmt, pmt);
if (This->hImageDescription)
DisposeHandle((Handle)This->hImageDescription);
This->hImageDescription = (ImageDescriptionHandle)
NewHandleClear(sizeof(ImageDescription));
if (This->hImageDescription != NULL)
{
(**This->hImageDescription).idSize = sizeof(ImageDescription);
(**This->hImageDescription).spatialQuality = codecNormalQuality;
(**This->hImageDescription).frameCount = 1;
(**This->hImageDescription).clutID = -1;
}
else
{
ERR("Failed to create ImageDescription\n");
goto failed;
}
/* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
(!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4)))
{
VIDEOINFOHEADER *format1 = (VIDEOINFOHEADER *)outpmt->pbFormat;
VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)outpmt->pbFormat;
BITMAPINFOHEADER *bmi;
OSType fourCC;
DecompressorComponent dc;
OSType format;
DWORD outputWidth, outputHeight, outputDepth;
if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
bmi = &format1->bmiHeader;
else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
bmi = &format2->bmiHeader;
else
goto failed;
TRACE("Fourcc: %s\n", debugstr_an((const char *)&pmt->subtype.Data1, 4));
fourCC = ((const char *)&pmt->subtype.Data1)[3] |
(((const char *)&pmt->subtype.Data1)[2]<<8) |
(((const char *)&pmt->subtype.Data1)[1]<<16) |
(((const char *)&pmt->subtype.Data1)[0]<<24);
err = FindCodec(fourCC,NULL,NULL,&dc);
if (err != noErr || dc == 0x0)
{
TRACE("Codec not found\n");
goto failed;
}
outputWidth = bmi->biWidth;
outputHeight = bmi->biHeight;
(**This->hImageDescription).cType = fourCC;
(**This->hImageDescription).width = outputWidth;
(**This->hImageDescription).height = outputHeight;
(**This->hImageDescription).depth = bmi->biBitCount;
(**This->hImageDescription).hRes = 72<<16;
(**This->hImageDescription).vRes = 72<<16;
if (This->outputBufferAttributes)
CFRelease(This->outputBufferAttributes);
This->outputBufferAttributes = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (!This->outputBufferAttributes)
{
ERR("Failed to create outputBufferAttributes\n");
goto failed;
}
n = CFNumberCreate(NULL, kCFNumberIntType, &outputWidth);
CFDictionaryAddValue(This->outputBufferAttributes, kCVPixelBufferWidthKey, n);
CFRelease(n);
n = CFNumberCreate(NULL, kCFNumberIntType, &outputHeight);
CFDictionaryAddValue(This->outputBufferAttributes, kCVPixelBufferHeightKey, n);
CFRelease(n);
/* yes this looks wrong. but 32ARGB is 24 RGB with an alpha channel */
format = k32ARGBPixelFormat;
n = CFNumberCreate(NULL, kCFNumberIntType, &format);
CFDictionaryAddValue(This->outputBufferAttributes, kCVPixelBufferPixelFormatTypeKey, n);
CFRelease(n);
CFDictionaryAddValue(This->outputBufferAttributes, kCVPixelBufferCGBitmapContextCompatibilityKey, kCFBooleanTrue);
CFDictionaryAddValue(This->outputBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
outputDepth = 3;
This->outputSize = outputWidth * outputHeight * outputDepth;
bmi->biCompression = BI_RGB;
bmi->biBitCount = 24;
outpmt->subtype = MEDIASUBTYPE_RGB24;
return S_OK;
}
failed:
if (This->hImageDescription)
{
DisposeHandle((Handle)This->hImageDescription);
This->hImageDescription = NULL;
}
if (This->outputBufferAttributes)
{
CFRelease(This->outputBufferAttributes);
This->outputBufferAttributes = NULL;
}
TRACE("Connection refused\n");
return hr;
}
static void video_decoder_sink_disconnect(struct strmbase_sink *iface)
{
QTVDecoderImpl *This = impl_from_strmbase_filter(iface->pin.filter);
if (This->hImageDescription)
DisposeHandle((Handle)This->hImageDescription);
if (This->outputBufferAttributes)
CFRelease(This->outputBufferAttributes);
This->hImageDescription = NULL;
This->outputBufferAttributes = NULL;
}
static const struct strmbase_sink_ops sink_ops =
{
.base.pin_query_interface = video_decoder_sink_query_interface,
.pfnReceive = video_decoder_sink_Receive,
.sink_connect = video_decoder_sink_connect,
.sink_disconnect = video_decoder_sink_disconnect,
};
static HRESULT video_decoder_source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface->filter);
if (IsEqualGUID(iid, &IID_IMediaSeeking))
return IUnknown_QueryInterface(filter->seeking, iid, out);
else
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown *)*out);
return S_OK;
}
static HRESULT video_decoder_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface->filter);
if (IsEqualGUID(&mt->majortype, &filter->mt.majortype)
&& (IsEqualGUID(&mt->subtype, &filter->mt.subtype)
|| IsEqualGUID(&filter->mt.subtype, &GUID_NULL)))
return S_OK;
return S_FALSE;
}
static HRESULT video_decoder_source_get_media_type(struct strmbase_pin *iface,
unsigned int index, AM_MEDIA_TYPE *mt)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface->filter);
if (index)
return VFW_S_NO_MORE_ITEMS;
CopyMediaType(mt, &filter->mt);
return S_OK;
}
static HRESULT WINAPI video_decoder_source_DecideBufferSize(struct strmbase_source *iface,
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
QTVDecoderImpl *This = impl_from_strmbase_filter(iface->pin.filter);
ALLOCATOR_PROPERTIES actual;
if (!ppropInputRequest->cbAlign)
ppropInputRequest->cbAlign = 1;
if (ppropInputRequest->cbBuffer < This->outputSize)
ppropInputRequest->cbBuffer = This->outputSize + ppropInputRequest->cbAlign;
if (!ppropInputRequest->cBuffers)
ppropInputRequest->cBuffers = 1;
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
}
static const struct strmbase_source_ops source_ops =
{
.base.pin_query_interface = video_decoder_source_query_interface,
.base.pin_query_accept = video_decoder_source_query_accept,
.base.pin_get_media_type = video_decoder_source_get_media_type,
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
.pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
.pfnDecideBufferSize = video_decoder_source_DecideBufferSize,
};
static struct strmbase_pin *video_decoder_get_pin(struct strmbase_filter *iface, unsigned int index)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface);
if (index == 0)
return &filter->sink.pin;
else if (index == 1)
return &filter->source.pin;
return NULL;
}
static void video_decoder_destroy(struct strmbase_filter *iface)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface);
if (filter->sink.pin.peer)
IPin_Disconnect(filter->sink.pin.peer);
IPin_Disconnect(&filter->sink.pin.IPin_iface);
if (filter->source.pin.peer)
IPin_Disconnect(filter->source.pin.peer);
IPin_Disconnect(&filter->source.pin.IPin_iface);
strmbase_sink_cleanup(&filter->sink);
strmbase_source_cleanup(&filter->source);
filter->stream_cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&filter->stream_cs);
FreeMediaType(&filter->mt);
IUnknown_Release(filter->seeking);
strmbase_filter_cleanup(&filter->filter);
free(filter);
}
static HRESULT video_decoder_init_stream(struct strmbase_filter *iface)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface);
HRESULT hr;
OSErr err = noErr;
ICMDecompressionSessionOptionsRef sessionOptions = NULL;
ICMDecompressionTrackingCallbackRecord trackingCallbackRecord;
trackingCallbackRecord.decompressionTrackingCallback = trackingCallback;
trackingCallbackRecord.decompressionTrackingRefCon = filter;
err = ICMDecompressionSessionCreate(NULL, filter->hImageDescription, sessionOptions,
filter->outputBufferAttributes, &trackingCallbackRecord, &filter->decompressionSession);
if (err != noErr)
{
ERR("Error with ICMDecompressionSessionCreate %i\n",err);
return E_FAIL;
}
if (filter->source.pin.peer && FAILED(hr = IMemAllocator_Commit(filter->source.pAllocator)))
ERR("Failed to commit allocator, hr %#x.\n", hr);
return S_OK;
}
static HRESULT video_decoder_cleanup_stream(struct strmbase_filter *iface)
{
QTVDecoderImpl *filter = impl_from_strmbase_filter(iface);
if (filter->decompressionSession)
ICMDecompressionSessionRelease(filter->decompressionSession);
filter->decompressionSession = NULL;
if (filter->source.pin.peer)
IMemAllocator_Decommit(filter->source.pAllocator);
return S_OK;
}
static const struct strmbase_filter_ops filter_ops =
{
.filter_get_pin = video_decoder_get_pin,
.filter_destroy = video_decoder_destroy,
.filter_init_stream = video_decoder_init_stream,
.filter_cleanup_stream = video_decoder_cleanup_stream,
};
HRESULT video_decoder_create(IUnknown *outer, IUnknown **out)
{
static const WCHAR inW[] = { 'I','n',0 };
static const WCHAR outW[] = { 'O','u','t',0 };
QTVDecoderImpl *object;
HRESULT hr;
ISeekingPassThru *passthrough;
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
strmbase_filter_init(&object->filter, outer, &CLSID_QTVDecoder, &filter_ops);
InitializeCriticalSection(&object->stream_cs);
object->stream_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": QTVDecoderImpl.stream_cs");
strmbase_sink_init(&object->sink, &object->filter, inW, &sink_ops, NULL);
strmbase_source_init(&object->source, &object->filter, outW, &source_ops);
if (FAILED(hr = CoCreateInstance(&CLSID_SeekingPassThru,
(IUnknown *)&object->source.pin.IPin_iface, CLSCTX_INPROC_SERVER,
&IID_IUnknown, (void **)&object->seeking)))
{
strmbase_sink_cleanup(&object->sink);
strmbase_source_cleanup(&object->source);
strmbase_filter_cleanup(&object->filter);
free(object);
return hr;
}
IUnknown_QueryInterface(object->seeking, &IID_ISeekingPassThru, (void **)&passthrough);
ISeekingPassThru_Init(passthrough, FALSE, &object->sink.pin.IPin_iface);
ISeekingPassThru_Release(passthrough);
TRACE("Created video decoder %p.\n", object);
*out = &object->filter.IUnknown_inner;
return S_OK;
}
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINE_FILEDESCRIPTION_STR "Wine QT Decoder"
#define WINE_FILENAME_STR "wineqtdecoder.dll"
#define WINE_FILEVERSION 0,0,1,0
#define WINE_FILEVERSION_STR "0.0.1.0"
#define WINE_PRODUCTVERSION 0,0,1,0
#define WINE_PRODUCTVERSION_STR "1.0.1.0"
#define WINE_EXTRAVALUES VALUE "OLESelfRegister",""
#include "wine/wine_common_ver.rc"
/* @makedep: wineqtdecoder.rgs */
2 WINE_REGISTRY wineqtdecoder.rgs
HKCR
{
NoRemove 'Media Type'
{
NoRemove '{E436EB83-524F-11CE-9F53-0020AF0BA770}'
{
ForceRemove '{FFFFFFFF-5927-4894-A386-359460EE87C9}'
{
val '0' = s '0,1,00,0'
val 'Source Filter' = s '{E436EBB5-524F-11CE-9F53-0020AF0BA770}'
}
}
}
}
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
/*
* COM classes for wineqtdecoder
*
* Copyright 2019 Zebediah Figura
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep header
#pragma makedep ident
#pragma makedep register
[
helpstring("Wine QuickTime splitter"),
threading(both),
uuid(d0e70e49-5927-4894-a386-359460ee87c9)
]
coclass QTSplitter {}
[
helpstring("Wine QuickTime video decoder"),
threading(both),
uuid(683ddacb-4354-490c-a058-e05ad0f20537)
]
coclass QTVDecoder {}
......@@ -419,9 +419,6 @@
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
/* Define to 1 if you have the <QuickTime/ImageCompression.h> header file. */
#undef HAVE_QUICKTIME_IMAGECOMPRESSION_H
/* Define to 1 if the system has the type `request_sense'. */
#undef HAVE_REQUEST_SENSE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment