2011-04-05 19:56:00 +02:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2019-09-07 10:31:10 +02:00
|
|
|
#include "wine/heap.h"
|
2011-04-05 19:56:00 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/strmbase.h"
|
|
|
|
|
|
|
|
#include "qtprivate.h"
|
2020-03-08 20:05:10 +01:00
|
|
|
#include "wineqtdecoder_classes.h"
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qtsplitter);
|
|
|
|
|
|
|
|
typedef struct QTOutPin {
|
2019-09-12 21:28:25 +02:00
|
|
|
struct strmbase_source pin;
|
2012-03-26 21:05:59 +02:00
|
|
|
IQualityControl IQualityControl_iface;
|
2019-12-08 05:20:32 +01:00
|
|
|
SourceSeeking seeking;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
AM_MEDIA_TYPE * pmt;
|
|
|
|
OutputQueue * queue;
|
|
|
|
} QTOutPin;
|
|
|
|
|
|
|
|
typedef struct QTInPin {
|
2019-12-13 04:24:32 +01:00
|
|
|
struct strmbase_sink pin;
|
2011-04-05 19:56:00 +02:00
|
|
|
GUID subType;
|
|
|
|
|
|
|
|
IAsyncReader *pReader;
|
|
|
|
IMemAllocator *pAlloc;
|
|
|
|
} QTInPin;
|
|
|
|
|
|
|
|
typedef struct QTSplitter {
|
2019-08-29 03:24:30 +02:00
|
|
|
struct strmbase_filter filter;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
QTInPin pInputPin;
|
|
|
|
QTOutPin *pVideo_Pin;
|
2011-04-05 19:56:02 +02:00
|
|
|
QTOutPin *pAudio_Pin;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
ALLOCATOR_PROPERTIES props;
|
|
|
|
|
|
|
|
Movie pQTMovie;
|
|
|
|
QTVisualContextRef vContext;
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
MovieAudioExtractionRef aSession;
|
|
|
|
HANDLE runEvent;
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
DWORD outputSize;
|
2012-01-18 14:50:07 +01:00
|
|
|
CRITICAL_SECTION csReceive;
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
TimeValue movie_time;
|
|
|
|
TimeValue movie_start;
|
|
|
|
TimeScale movie_scale;
|
2012-11-20 15:08:36 +01:00
|
|
|
|
|
|
|
HANDLE loaderThread;
|
|
|
|
HANDLE splitterThread;
|
2011-04-05 19:56:00 +02:00
|
|
|
} QTSplitter;
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl QT_Vtbl;
|
2012-01-18 14:50:20 +01:00
|
|
|
static const IMediaSeekingVtbl QT_Seeking_Vtbl;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name, const AM_MEDIA_TYPE *mt, BOOL video);
|
2011-04-05 19:56:00 +02:00
|
|
|
static HRESULT QT_RemoveOutputPins(QTSplitter *This);
|
|
|
|
|
2012-01-18 14:50:20 +01:00
|
|
|
static HRESULT WINAPI QTSplitter_ChangeStart(IMediaSeeking *iface);
|
|
|
|
static HRESULT WINAPI QTSplitter_ChangeStop(IMediaSeeking *iface);
|
|
|
|
static HRESULT WINAPI QTSplitter_ChangeRate(IMediaSeeking *iface);
|
|
|
|
|
2019-12-08 05:20:32 +01:00
|
|
|
static inline QTOutPin *impl_from_IMediaSeeking(IMediaSeeking *iface)
|
2012-01-18 14:50:20 +01:00
|
|
|
{
|
2019-12-08 05:20:32 +01:00
|
|
|
return CONTAINING_RECORD(iface, QTOutPin, seeking.IMediaSeeking_iface);
|
2012-01-18 14:50:20 +01:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static inline QTSplitter *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
2012-03-26 21:05:53 +02:00
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, QTSplitter, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline QTSplitter *impl_from_IBaseFilter( IBaseFilter *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, QTSplitter, filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:33:20 +02:00
|
|
|
static inline QTInPin *impl_from_IPin(IPin *iface)
|
|
|
|
{
|
2019-12-13 04:24:32 +01:00
|
|
|
return CONTAINING_RECORD(iface, QTInPin, pin.pin.IPin_iface);
|
2019-09-24 02:33:20 +02:00
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
/*
|
|
|
|
* Base Filter
|
|
|
|
*/
|
|
|
|
|
2019-11-23 04:13:59 +01:00
|
|
|
static struct strmbase_pin *qt_splitter_get_pin(struct strmbase_filter *base, unsigned int index)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
QTSplitter *filter = impl_from_strmbase_filter(base);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-05-14 05:17:55 +02:00
|
|
|
if (index == 0)
|
2019-12-13 04:24:32 +01:00
|
|
|
return &filter->pInputPin.pin.pin;
|
2019-05-14 05:17:55 +02:00
|
|
|
else if (index == 1)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
2019-05-14 05:17:55 +02:00
|
|
|
if (filter->pVideo_Pin)
|
2019-11-23 04:13:59 +01:00
|
|
|
return &filter->pVideo_Pin->pin.pin;
|
2019-05-14 05:17:55 +02:00
|
|
|
else if (filter->pAudio_Pin)
|
2019-11-23 04:13:59 +01:00
|
|
|
return &filter->pAudio_Pin->pin.pin;
|
2011-04-05 19:56:00 +02:00
|
|
|
}
|
2019-05-14 05:17:55 +02:00
|
|
|
else if (index == 2 && filter->pVideo_Pin && filter->pAudio_Pin)
|
2019-11-23 04:13:59 +01:00
|
|
|
return &filter->pAudio_Pin->pin.pin;
|
2019-05-14 05:17:55 +02:00
|
|
|
|
|
|
|
return NULL;
|
2011-04-05 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static void qt_splitter_destroy(struct strmbase_filter *iface)
|
2019-05-25 22:21:25 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
QTSplitter *filter = impl_from_strmbase_filter(iface);
|
2019-05-25 22:21:25 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&filter->csReceive);
|
|
|
|
/* Don't need to clean up output pins, disconnecting input pin will do that */
|
2019-12-13 04:24:32 +01:00
|
|
|
if (filter->pInputPin.pin.pin.peer)
|
|
|
|
IPin_Disconnect(filter->pInputPin.pin.pin.peer);
|
2019-11-19 01:51:22 +01:00
|
|
|
|
2019-06-18 03:41:59 +02:00
|
|
|
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;
|
2019-05-25 22:21:25 +02:00
|
|
|
|
|
|
|
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);
|
2019-12-13 04:24:32 +01:00
|
|
|
strmbase_sink_cleanup(&filter->pInputPin.pin);
|
2019-05-25 22:21:25 +02:00
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
|
|
|
|
CoTaskMemFree(filter);
|
|
|
|
}
|
|
|
|
|
2019-12-04 05:03:28 +01:00
|
|
|
static HRESULT qt_splitter_start_stream(struct strmbase_filter *iface, REFERENCE_TIME time)
|
|
|
|
{
|
|
|
|
QTSplitter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
HRESULT hr = VFW_E_NOT_CONNECTED, pin_hr;
|
|
|
|
|
2019-12-08 05:20:31 +01:00
|
|
|
EnterCriticalSection(&filter->csReceive);
|
2019-12-04 05:03:28 +01:00
|
|
|
|
|
|
|
if (filter->pVideo_Pin)
|
2019-12-13 04:24:33 +01:00
|
|
|
{
|
|
|
|
if (SUCCEEDED(pin_hr = BaseOutputPinImpl_Active(&filter->pVideo_Pin->pin)))
|
|
|
|
hr = pin_hr;
|
|
|
|
}
|
2019-12-04 05:03:28 +01:00
|
|
|
if (filter->pAudio_Pin)
|
2019-12-13 04:24:33 +01:00
|
|
|
{
|
|
|
|
if (SUCCEEDED(pin_hr = BaseOutputPinImpl_Active(&filter->pAudio_Pin->pin)))
|
|
|
|
hr = pin_hr;
|
|
|
|
}
|
2019-12-04 05:03:28 +01:00
|
|
|
SetEvent(filter->runEvent);
|
|
|
|
|
2019-12-08 05:20:31 +01:00
|
|
|
LeaveCriticalSection(&filter->csReceive);
|
2019-12-04 05:03:28 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT qt_splitter_cleanup_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
QTSplitter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
2019-12-08 05:20:31 +01:00
|
|
|
EnterCriticalSection(&filter->csReceive);
|
2019-12-04 05:03:28 +01:00
|
|
|
IAsyncReader_BeginFlush(filter->pInputPin.pReader);
|
|
|
|
IAsyncReader_EndFlush(filter->pInputPin.pReader);
|
2019-12-08 05:20:31 +01:00
|
|
|
LeaveCriticalSection(&filter->csReceive);
|
2019-12-04 05:03:28 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:29 +02:00
|
|
|
static const struct strmbase_filter_ops filter_ops =
|
|
|
|
{
|
2019-05-24 00:06:31 +02:00
|
|
|
.filter_get_pin = qt_splitter_get_pin,
|
2019-05-25 22:21:25 +02:00
|
|
|
.filter_destroy = qt_splitter_destroy,
|
2019-12-04 05:03:28 +01:00
|
|
|
.filter_start_stream = qt_splitter_start_stream,
|
|
|
|
.filter_cleanup_stream = qt_splitter_cleanup_stream,
|
2011-04-05 19:56:00 +02:00
|
|
|
};
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt)
|
2019-09-24 02:33:20 +02:00
|
|
|
{
|
|
|
|
QTInPin *pin = impl_from_IPin(&iface->IPin_iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&mt->majortype, &MEDIATYPE_Stream))
|
|
|
|
{
|
|
|
|
pin->subType = mt->subtype;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2019-12-13 04:24:33 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-12-13 04:24:32 +01:00
|
|
|
static const struct strmbase_sink_ops sink_ops =
|
2019-09-24 02:33:20 +02:00
|
|
|
{
|
2019-12-13 04:24:32 +01:00
|
|
|
.base.pin_query_accept = sink_query_accept,
|
2019-12-13 04:24:33 +01:00
|
|
|
.sink_connect = qt_splitter_sink_connect,
|
|
|
|
.sink_disconnect = qt_splitter_sink_disconnect,
|
2019-09-24 02:33:20 +02:00
|
|
|
};
|
|
|
|
|
2020-03-08 20:05:10 +01:00
|
|
|
HRESULT qt_splitter_create(IUnknown *outer, IUnknown **out)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
|
|
|
QTSplitter *This;
|
|
|
|
static const WCHAR wcsInputPinName[] = {'I','n','p','u','t',' ','P','i','n',0};
|
|
|
|
|
2016-03-31 14:16:04 +02:00
|
|
|
EnterMoviesOnThread(0);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
RegisterWineDataHandler();
|
|
|
|
|
2020-03-08 20:05:10 +01:00
|
|
|
if (!(This = CoTaskMemAlloc(sizeof(*This))))
|
|
|
|
return E_OUTOFMEMORY;
|
2012-01-16 17:11:47 +01:00
|
|
|
ZeroMemory(This,sizeof(*This));
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-12-05 06:03:31 +01:00
|
|
|
strmbase_filter_init(&This->filter, outer, &CLSID_QTSplitter, &filter_ops);
|
2019-12-13 04:24:39 +01:00
|
|
|
strmbase_sink_init(&This->pInputPin.pin, &This->filter, wcsInputPinName, &sink_ops, NULL);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2012-01-18 14:50:07 +01:00
|
|
|
InitializeCriticalSection(&This->csReceive);
|
|
|
|
This->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": QTSplitter.csReceive");
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
This->pVideo_Pin = NULL;
|
2011-04-05 19:56:02 +02:00
|
|
|
This->pAudio_Pin = NULL;
|
|
|
|
This->aSession = NULL;
|
|
|
|
This->runEvent = CreateEventW(NULL, 0, 0, NULL);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2020-03-08 20:05:10 +01:00
|
|
|
TRACE("Created QT splitter %p.\n", This);
|
|
|
|
*out = &This->filter.IUnknown_inner;
|
|
|
|
return S_OK;
|
2011-04-05 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
static OSErr QT_Create_Extract_Session(QTSplitter *filter)
|
|
|
|
{
|
|
|
|
AudioStreamBasicDescription aDesc;
|
|
|
|
OSErr err;
|
2011-04-06 20:36:13 +02:00
|
|
|
WAVEFORMATEX* pvi;
|
|
|
|
|
|
|
|
pvi = (WAVEFORMATEX*)filter->pAudio_Pin->pmt->pbFormat;
|
2011-04-05 19:56:02 +02:00
|
|
|
|
|
|
|
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;
|
2011-04-06 20:36:13 +02:00
|
|
|
aDesc.mChannelsPerFrame = pvi->nChannels;
|
|
|
|
aDesc.mBitsPerChannel = pvi->wBitsPerSample;
|
|
|
|
aDesc.mSampleRate = pvi->nSamplesPerSec;
|
2011-04-05 19:56:02 +02:00
|
|
|
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;
|
|
|
|
}
|
2011-04-06 20:36:13 +02:00
|
|
|
if (aDesc.mChannelsPerFrame != pvi->nChannels)
|
2011-04-05 19:56:02 +02:00
|
|
|
{
|
|
|
|
ERR("Unhandled channel count %li\n",aDesc.mChannelsPerFrame);
|
|
|
|
err = -1;
|
|
|
|
}
|
2011-04-06 20:36:13 +02:00
|
|
|
if (aDesc.mBitsPerChannel != pvi->wBitsPerSample)
|
2011-04-05 19:56:02 +02:00
|
|
|
{
|
|
|
|
ERR("Unhandled bits per channel %li\n",aDesc.mBitsPerChannel);
|
|
|
|
err = -1;
|
|
|
|
}
|
2011-04-06 20:36:13 +02:00
|
|
|
if (aDesc.mSampleRate != pvi->nSamplesPerSec)
|
2011-04-05 19:56:02 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-05-22 18:17:09 +02:00
|
|
|
static DWORD WINAPI QTSplitter_loading_thread(LPVOID data)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
|
|
|
QTSplitter *This = (QTSplitter *)data;
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
if (This->pAudio_Pin)
|
|
|
|
{
|
|
|
|
/* according to QA1469 a movie has to be fully loaded before we
|
2012-05-22 18:17:09 +02:00
|
|
|
can reliably start the Extraction session.
|
2011-04-05 19:56:02 +02:00
|
|
|
|
2012-06-02 10:35:21 +02:00
|
|
|
If loaded earlier, then we only get an extraction session for
|
2012-05-22 18:17:09 +02:00
|
|
|
the part of the movie that is loaded at that time.
|
2011-04-05 19:56:02 +02:00
|
|
|
|
2012-05-22 18:17:09 +02:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-11-20 15:08:36 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
|
|
|
while(This->pQTMovie && GetMovieLoadState(This->pQTMovie) < kMovieLoadStateComplete)
|
2012-05-22 18:17:09 +02:00
|
|
|
{
|
|
|
|
MoviesTask(This->pQTMovie, 100);
|
|
|
|
LeaveCriticalSection(&This->csReceive);
|
|
|
|
Sleep(0);
|
2012-11-20 15:08:36 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2012-05-22 18:17:09 +02:00
|
|
|
}
|
2012-11-20 15:08:36 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2011-04-05 19:56:02 +02:00
|
|
|
}
|
2012-05-22 18:17:09 +02:00
|
|
|
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;
|
2011-04-05 19:56:02 +02:00
|
|
|
|
|
|
|
WaitForSingleObject(This->runEvent, -1);
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2012-11-20 15:08:36 +01:00
|
|
|
if (!This->pQTMovie)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csReceive);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-06 20:36:24 +02:00
|
|
|
/* Prime the pump: Needed for MPEG streams */
|
2012-01-19 16:42:42 +01:00
|
|
|
GetMovieNextInterestingTime(This->pQTMovie, nextTimeEdgeOK | nextTimeStep, 0, NULL, This->movie_time, 1, &next_time, NULL);
|
2011-04-06 20:36:24 +02:00
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
GetMovieTime(This->pQTMovie, &tr);
|
2012-05-22 18:17:09 +02:00
|
|
|
|
|
|
|
if (This->pAudio_Pin)
|
|
|
|
QT_Create_Extract_Session(This);
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2012-05-22 18:17:09 +02:00
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
LONGLONG tStart=0, tStop=0;
|
2012-01-16 17:13:12 +01:00
|
|
|
LONGLONG mStart=0, mStop=0;
|
2011-04-05 19:56:00 +02:00
|
|
|
float time;
|
|
|
|
|
2012-01-18 14:50:07 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2012-11-20 15:08:36 +01:00
|
|
|
if (!This->pQTMovie)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csReceive);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
GetMovieNextInterestingTime(This->pQTMovie, nextTimeStep, 0, NULL, This->movie_time, 1, &next_time, NULL);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
if (next_time == -1)
|
|
|
|
{
|
|
|
|
TRACE("No next time\n");
|
2012-01-18 14:50:07 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2011-04-05 19:56:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tr.value = SInt64ToWide(next_time);
|
|
|
|
SetMovieTime(This->pQTMovie, &tr);
|
|
|
|
MoviesTask(This->pQTMovie,0);
|
|
|
|
QTVisualContextTask(This->vContext);
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
TRACE("In loop at time %ld\n",This->movie_time);
|
2011-04-05 19:56:00 +02:00
|
|
|
TRACE("In Next time %ld\n",next_time);
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
mStart = This->movie_time;
|
2012-01-16 17:13:12 +01:00
|
|
|
mStop = next_time;
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
time = (float)(This->movie_time - This->movie_start) / This->movie_scale;
|
2011-04-05 19:56:00 +02:00
|
|
|
tStart = time * 10000000;
|
2012-01-19 16:42:42 +01:00
|
|
|
time = (float)(next_time - This->movie_start) / This->movie_scale;
|
2011-04-05 19:56:00 +02:00
|
|
|
tStop = time * 10000000;
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
/* Deliver Audio */
|
2019-09-27 04:40:53 +02:00
|
|
|
if (This->pAudio_Pin && This->pAudio_Pin->pin.pin.peer && This->aSession)
|
2011-04-05 19:56:02 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2012-03-26 21:05:53 +02:00
|
|
|
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->pAudio_Pin->pin, &sample, NULL, NULL, 0);
|
2011-04-05 19:56:02 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
duration = (float)next_time / This->movie_scale;
|
|
|
|
time = (float)This->movie_time / This->movie_scale;
|
2011-04-05 19:56:02 +02:00
|
|
|
duration -= time;
|
|
|
|
frames = pvi->nSamplesPerSec * duration;
|
|
|
|
TRACE("Need audio for %f seconds (%li frames)\n",duration,frames);
|
|
|
|
|
|
|
|
data_size = IMediaSample_GetSize(sample);
|
2011-04-06 20:36:13 +02:00
|
|
|
if (data_size < frames * pvi->nBlockAlign)
|
2011-04-05 19:56:02 +02:00
|
|
|
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);
|
2012-05-22 18:17:09 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
TRACE("Got %i frames\n",(int)frames);
|
|
|
|
|
2011-04-06 20:36:13 +02:00
|
|
|
IMediaSample_SetActualDataLength(sample, frames * pvi->nBlockAlign);
|
2011-04-05 19:56:02 +02:00
|
|
|
|
2012-01-16 17:13:12 +01:00
|
|
|
IMediaSample_SetMediaTime(sample, &mStart, &mStop);
|
|
|
|
IMediaSample_SetTime(sample, &tStart, &tStop);
|
2011-04-05 19:56:02 +02:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
/* Deliver Video */
|
2011-04-05 19:56:02 +02:00
|
|
|
if (This->pVideo_Pin && QTVisualContextIsNewImageAvailable(This->vContext,0))
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
|
|
|
err = QTVisualContextCopyImageForTime(This->vContext, NULL, NULL, &pixelBuffer);
|
|
|
|
if (err == noErr)
|
|
|
|
{
|
|
|
|
int data_size=0;
|
|
|
|
BYTE* ptr;
|
|
|
|
IMediaSample *sample = NULL;
|
|
|
|
|
2012-03-26 21:05:53 +02:00
|
|
|
hr = BaseOutputPinImpl_GetDeliveryBuffer(&This->pVideo_Pin->pin, &sample, NULL, NULL, 0);
|
2011-04-05 19:56:00 +02:00
|
|
|
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);
|
|
|
|
|
2012-01-16 17:13:12 +01:00
|
|
|
IMediaSample_SetMediaTime(sample, &mStart, &mStop);
|
|
|
|
IMediaSample_SetTime(sample, &tStart, &tStop);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2011-04-05 19:56:02 +02:00
|
|
|
else
|
|
|
|
TRACE("No video to deliver\n");
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2012-01-19 16:42:42 +01:00
|
|
|
This->movie_time = next_time;
|
2012-01-18 14:50:07 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2011-04-05 19:56:00 +02:00
|
|
|
} while (hr == S_OK);
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
if (This->pAudio_Pin)
|
|
|
|
OutputQueue_EOS(This->pAudio_Pin->queue);
|
|
|
|
if (This->pVideo_Pin)
|
|
|
|
OutputQueue_EOS(This->pVideo_Pin->queue);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-06-19 03:17:33 +02:00
|
|
|
static void free_source_pin(QTOutPin *pin)
|
2019-05-11 21:46:20 +02:00
|
|
|
{
|
2019-09-27 04:40:53 +02:00
|
|
|
if (pin->pin.pin.peer)
|
2019-05-11 21:46:20 +02:00
|
|
|
{
|
2019-06-19 03:17:33 +02:00
|
|
|
if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator)))
|
2019-09-27 04:40:53 +02:00
|
|
|
IPin_Disconnect(pin->pin.pin.peer);
|
2019-06-19 03:17:33 +02:00
|
|
|
IPin_Disconnect(&pin->pin.pin.IPin_iface);
|
2019-05-11 21:46:20 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 03:17:33 +02:00
|
|
|
DeleteMediaType(pin->pmt);
|
2019-12-08 05:20:32 +01:00
|
|
|
strmbase_seeking_cleanup(&pin->seeking);
|
2019-09-06 02:02:12 +02:00
|
|
|
strmbase_source_cleanup(&pin->pin);
|
|
|
|
heap_free(pin);
|
2019-05-11 21:46:20 +02:00
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
/*
|
|
|
|
* Input Pin
|
|
|
|
*/
|
|
|
|
static HRESULT QT_RemoveOutputPins(QTSplitter *This)
|
|
|
|
{
|
|
|
|
if (This->pVideo_Pin)
|
|
|
|
{
|
2012-04-11 21:07:18 +02:00
|
|
|
OutputQueue_Destroy(This->pVideo_Pin->queue);
|
2019-06-19 03:17:33 +02:00
|
|
|
free_source_pin(This->pVideo_Pin);
|
2011-04-05 19:56:00 +02:00
|
|
|
This->pVideo_Pin = NULL;
|
|
|
|
}
|
2011-04-05 19:56:02 +02:00
|
|
|
if (This->pAudio_Pin)
|
|
|
|
{
|
2012-04-11 21:07:18 +02:00
|
|
|
OutputQueue_Destroy(This->pAudio_Pin->queue);
|
2019-06-19 03:17:33 +02:00
|
|
|
free_source_pin(This->pAudio_Pin);
|
2011-04-05 19:56:02 +02:00
|
|
|
This->pAudio_Pin = NULL;
|
|
|
|
}
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2012-03-26 21:05:53 +02:00
|
|
|
BaseFilterImpl_IncrementPinVersion(&This->filter);
|
2011-04-05 19:56:00 +02:00
|
|
|
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;
|
2013-07-15 20:04:42 +02:00
|
|
|
Media videoMedia;
|
|
|
|
long sampleCount;
|
|
|
|
TimeValue64 duration;
|
|
|
|
TimeScale timeScale;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
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;
|
2012-01-16 21:14:07 +01:00
|
|
|
pvi->bmiHeader.biHeight = outputHeight;
|
2011-04-05 19:56:00 +02:00
|
|
|
pvi->bmiHeader.biPlanes = 1;
|
|
|
|
pvi->bmiHeader.biBitCount = 24;
|
|
|
|
pvi->bmiHeader.biCompression = BI_RGB;
|
2012-01-16 21:14:07 +01:00
|
|
|
pvi->bmiHeader.biSizeImage = outputWidth * outputHeight * outputDepth;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2012-01-16 21:14:07 +01:00
|
|
|
filter->outputSize = pvi->bmiHeader.biSizeImage;
|
2011-04-05 19:56:00 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-07-15 20:04:42 +02:00
|
|
|
videoMedia = GetTrackMedia(trk);
|
|
|
|
sampleCount = GetMediaSampleCount(videoMedia);
|
|
|
|
timeScale = GetMediaTimeScale(videoMedia);
|
|
|
|
duration = GetMediaDisplayDuration(videoMedia);
|
|
|
|
pvi->AvgTimePerFrame = (100000.0 * sampleCount * timeScale) / duration;
|
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
hr = QT_AddPin(filter, szwVideoOut, &amt, TRUE);
|
2011-04-05 19:56:00 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Failed to add Video Track\n");
|
|
|
|
else
|
|
|
|
TRACE("Video Pin %p\n",filter->pVideo_Pin);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
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};
|
2011-04-06 20:36:13 +02:00
|
|
|
Media audioMedia;
|
|
|
|
|
|
|
|
SoundDescriptionHandle aDesc = (SoundDescriptionHandle) NewHandle(sizeof(SoundDescription));
|
|
|
|
|
|
|
|
audioMedia = GetTrackMedia(trk);
|
|
|
|
GetMediaSampleDescription(audioMedia, 1, (SampleDescriptionHandle)aDesc);
|
2011-04-05 19:56:02 +02:00
|
|
|
|
|
|
|
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;
|
2011-04-06 20:36:13 +02:00
|
|
|
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;
|
2011-04-05 19:56:02 +02:00
|
|
|
pvi->nBlockAlign = (pvi->nChannels * pvi->wBitsPerSample) / 8;
|
|
|
|
pvi->nAvgBytesPerSec = pvi->nSamplesPerSec * pvi->nBlockAlign;
|
|
|
|
|
2011-04-06 20:36:13 +02:00
|
|
|
DisposeHandle((Handle)aDesc);
|
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
hr = QT_AddPin(filter, szwAudioOut, &amt, FALSE);
|
2011-04-05 19:56:02 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Failed to add Audio Track\n");
|
|
|
|
else
|
|
|
|
TRACE("Audio Pin %p\n",filter->pAudio_Pin);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
static HRESULT QT_Process_Movie(QTSplitter* filter)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
OSErr err;
|
|
|
|
WineDataRefRecord ptrDataRefRec;
|
|
|
|
Handle dataRef = NULL;
|
|
|
|
Track trk;
|
|
|
|
short id = 0;
|
2011-04-05 19:56:02 +02:00
|
|
|
DWORD tid;
|
2019-12-08 05:20:32 +01:00
|
|
|
LONGLONG time, duration;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
TRACE("Trying movie connect\n");
|
|
|
|
|
|
|
|
ptrDataRefRec.pReader = filter->pInputPin.pReader;
|
|
|
|
ptrDataRefRec.streamSubtype = filter->pInputPin.subType;
|
|
|
|
PtrToHand( &ptrDataRefRec, &dataRef, sizeof(WineDataRefRecord));
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
err = NewMovieFromDataRef(&filter->pQTMovie, newMovieActive|newMovieDontInteractWithUser|newMovieDontAutoUpdateClock|newMovieDontAskUnresolvedDataRefs|newMovieAsyncOK, &id, dataRef, 'WINE');
|
|
|
|
|
|
|
|
DisposeHandle(dataRef);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
if (err != noErr)
|
|
|
|
{
|
2011-05-09 09:03:40 +02:00
|
|
|
FIXME("QuickTime cannot handle media type(%i)\n",err);
|
2011-04-05 19:56:00 +02:00
|
|
|
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);
|
|
|
|
|
2011-09-25 23:30:03 +02:00
|
|
|
if (FAILED(hr))
|
2011-04-05 19:56:00 +02:00
|
|
|
return hr;
|
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
trk = GetMovieIndTrackType(filter->pQTMovie, 1, AudioMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly);
|
2013-12-03 14:25:04 +01:00
|
|
|
TRACE("%p is an audio track\n",trk);
|
2011-04-05 19:56:02 +02:00
|
|
|
if (trk)
|
|
|
|
hr = QT_Process_Audio_Track(filter, trk);
|
|
|
|
|
2012-01-18 14:50:20 +01:00
|
|
|
time = GetMovieDuration(filter->pQTMovie);
|
2012-01-19 16:42:42 +01:00
|
|
|
filter->movie_scale = GetMovieTimeScale(filter->pQTMovie);
|
2019-12-08 05:20:32 +01:00
|
|
|
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;
|
2012-01-18 14:50:20 +01:00
|
|
|
|
2012-11-20 15:08:36 +01:00
|
|
|
filter->loaderThread = CreateThread(NULL, 0, QTSplitter_loading_thread, filter, 0, &tid);
|
|
|
|
if (filter->loaderThread)
|
2012-05-22 18:17:09 +02:00
|
|
|
TRACE("Created loading thread 0x%08x\n", tid);
|
2012-11-20 15:08:36 +01:00
|
|
|
filter->splitterThread = CreateThread(NULL, 0, QTSplitter_thread, filter, 0, &tid);
|
|
|
|
if (filter->splitterThread)
|
2012-05-22 18:17:09 +02:00
|
|
|
TRACE("Created processing thread 0x%08x\n", tid);
|
2011-12-30 21:55:06 +01:00
|
|
|
else
|
|
|
|
hr = HRESULT_FROM_WIN32(GetLastError());
|
2011-04-05 19:56:02 +02:00
|
|
|
|
2011-04-05 19:56:00 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-08 05:20:34 +01:00
|
|
|
static inline QTOutPin *impl_source_from_strmbase_pin(struct strmbase_pin *iface)
|
2012-03-26 21:05:53 +02:00
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, QTOutPin, pin.pin);
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static inline QTOutPin *impl_QTOutPin_from_BaseOutputPin(struct strmbase_source *iface)
|
2012-03-26 21:05:53 +02:00
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, QTOutPin, pin);
|
|
|
|
}
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-12-08 05:20:34 +01:00
|
|
|
static HRESULT source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
2019-12-08 05:20:34 +01:00
|
|
|
QTOutPin *pin = impl_source_from_strmbase_pin(&iface->IPin_iface);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-12-08 05:20:34 +01:00
|
|
|
if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
|
|
|
*out = &pin->seeking.IMediaSeeking_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IQualityControl))
|
|
|
|
*out = &pin->IQualityControl_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-12-08 05:20:34 +01:00
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
2011-04-05 19:56:00 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT source_query_accept(struct strmbase_pin *base, const AM_MEDIA_TYPE *amt)
|
2018-05-04 06:47:13 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", base);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:12 +02:00
|
|
|
static HRESULT source_get_media_type(struct strmbase_pin *iface, unsigned int iPosition, AM_MEDIA_TYPE *pmt)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
2019-12-08 05:20:34 +01:00
|
|
|
QTOutPin *This = impl_source_from_strmbase_pin(iface);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
|
|
|
if (iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
CopyMediaType(pmt, This->pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI QTOutPin_DecideBufferSize(struct strmbase_source *iface,
|
|
|
|
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
|
|
|
/* Unused */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI QTOutPin_DecideAllocator(struct strmbase_source *iface,
|
|
|
|
IMemInputPin *pPin, IMemAllocator **pAlloc)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2012-03-26 21:05:53 +02:00
|
|
|
QTOutPin *This = impl_QTOutPin_from_BaseOutputPin(iface);
|
2019-09-06 02:02:15 +02:00
|
|
|
QTSplitter *QTfilter = impl_from_strmbase_filter(This->pin.pin.filter);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2011-07-10 18:50:43 +02:00
|
|
|
*pAlloc = NULL;
|
2011-04-05 19:56:00 +02:00
|
|
|
if (QTfilter->pInputPin.pAlloc)
|
2013-01-17 06:39:17 +01:00
|
|
|
{
|
2011-04-05 19:56:00 +02:00
|
|
|
hr = IMemInputPin_NotifyAllocator(pPin, QTfilter->pInputPin.pAlloc, FALSE);
|
2013-01-17 06:39:17 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
*pAlloc = QTfilter->pInputPin.pAlloc;
|
|
|
|
IMemAllocator_AddRef(*pAlloc);
|
|
|
|
}
|
|
|
|
}
|
2011-04-05 19:56:00 +02:00
|
|
|
else
|
|
|
|
hr = VFW_E_NO_ALLOCATOR;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-03-26 21:05:59 +02:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2019-09-12 21:28:26 +02:00
|
|
|
static const struct strmbase_source_ops source_ops =
|
|
|
|
{
|
2019-09-25 02:10:10 +02:00
|
|
|
.base.pin_query_accept = source_query_accept,
|
2019-09-25 02:10:11 +02:00
|
|
|
.base.pin_get_media_type = source_get_media_type,
|
2019-09-25 02:10:10 +02:00
|
|
|
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
|
|
|
|
.pfnDecideBufferSize = QTOutPin_DecideBufferSize,
|
|
|
|
.pfnDecideAllocator = QTOutPin_DecideAllocator,
|
2011-04-05 19:56:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const OutputQueueFuncTable output_OutputQueueFuncTable = {
|
|
|
|
OutputQueueImpl_ThreadProc
|
|
|
|
};
|
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name,
|
2019-09-06 02:02:12 +02:00
|
|
|
const AM_MEDIA_TYPE *mt, BOOL video)
|
2011-04-05 19:56:00 +02:00
|
|
|
{
|
2019-09-06 02:02:12 +02:00
|
|
|
QTOutPin *pin;
|
|
|
|
|
|
|
|
if (!(pin = heap_alloc_zero(sizeof(*pin))))
|
|
|
|
return E_OUTOFMEMORY;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2011-04-05 19:56:02 +02:00
|
|
|
if (video)
|
2019-09-06 02:02:12 +02:00
|
|
|
filter->pVideo_Pin = pin;
|
2011-04-05 19:56:02 +02:00
|
|
|
else
|
2019-09-06 02:02:12 +02:00
|
|
|
filter->pAudio_Pin = pin;
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-12-08 05:20:38 +01:00
|
|
|
strmbase_source_init(&pin->pin, &filter->filter, name, &source_ops);
|
2019-09-06 02:02:12 +02:00
|
|
|
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
|
|
|
|
CopyMediaType(pin->pmt, mt);
|
|
|
|
pin->IQualityControl_iface.lpVtbl = &QTOutPin_QualityControl_Vtbl;
|
2019-12-08 05:20:32 +01:00
|
|
|
strmbase_seeking_init(&pin->seeking, &QT_Seeking_Vtbl,
|
|
|
|
QTSplitter_ChangeStop, QTSplitter_ChangeStart, QTSplitter_ChangeRate);
|
2019-09-06 02:02:12 +02:00
|
|
|
BaseFilterImpl_IncrementPinVersion(&filter->filter);
|
2011-04-05 19:56:00 +02:00
|
|
|
|
2019-09-06 02:02:12 +02:00
|
|
|
return OutputQueue_Construct(&pin->pin, TRUE, TRUE, 5, FALSE,
|
|
|
|
THREAD_PRIORITY_NORMAL, &output_OutputQueueFuncTable, &pin->queue);
|
2011-04-05 19:56:00 +02:00
|
|
|
}
|
2012-01-18 14:50:20 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI QTSplitter_ChangeStart(IMediaSeeking *iface)
|
|
|
|
{
|
2019-12-08 05:20:32 +01:00
|
|
|
QTOutPin *pin = impl_from_IMediaSeeking(iface);
|
|
|
|
QTSplitter *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
|
2012-01-19 16:42:42 +01:00
|
|
|
TRACE("(%p)\n", iface);
|
2019-12-08 05:20:32 +01:00
|
|
|
EnterCriticalSection(&filter->csReceive);
|
|
|
|
filter->movie_start = filter->movie_time = (pin->seeking.llCurrent * filter->movie_scale)/10000000;
|
|
|
|
LeaveCriticalSection(&filter->csReceive);
|
2012-01-18 14:50:20 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-12-08 05:20:32 +01:00
|
|
|
static HRESULT WINAPI QT_Seeking_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out)
|
2012-01-18 14:50:20 +01:00
|
|
|
{
|
2019-12-08 05:20:32 +01:00
|
|
|
QTOutPin *pin = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_QueryInterface(&pin->pin.pin.IPin_iface, iid, out);
|
2012-01-18 14:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI QT_Seeking_AddRef(IMediaSeeking * iface)
|
|
|
|
{
|
2019-12-08 05:20:32 +01:00
|
|
|
QTOutPin *pin = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_AddRef(&pin->pin.pin.IPin_iface);
|
2012-01-18 14:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI QT_Seeking_Release(IMediaSeeking * iface)
|
|
|
|
{
|
2019-12-08 05:20:32 +01:00
|
|
|
QTOutPin *pin = impl_from_IMediaSeeking(iface);
|
|
|
|
return IPin_Release(&pin->pin.pin.IPin_iface);
|
2012-01-18 14:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|