[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
|
2010-02-23 15:25:59 +00:00
|
|
|
* FILE: dll/directx/ksproxy/datatype.cpp
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
* PURPOSE: IKsDataTypeHandler interface
|
|
|
|
*
|
2013-09-15 13:06:05 +00:00
|
|
|
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
*/
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
/* FIXME guid mess */
|
[KSPROXY]
- Recreate resource file with visual studio
- Fix compilation with msvc
- Copy extra format buffer in IEnumMediaTypes::Next
- Create the pin handle in IPin::ReceiveConnection
- Implement IPin::Disconnect for the input pin
- Enumerate media formats and pass it to constructor of CEnumMediaTypes
- Check if the passed format is null in CInputPin::CheckFormat
- Copy extra format buffer after KSDATAFORMAT in the pin connection request
- Implement KsGetMediaType function
- Implement ISpecifyPropertyPages, IKsPropertySet, IKsControl, IStreamBuilder, IKsPinFactory for the output pin
- Implement IPin::ReceiveConnection, IPin::EnumMediaTypes for output pin
- Stub interfaces for IReferenceClock, IMediaSeeking, IKsTopology, IKsAggregateControl, IKsClockPropertySet, ISpecifyPropertyPages, IPersistStream for proxy filter
- Implement IAMDeviceRemoval, IKsControl, IAMFilterMiscFlags, IKsPropertySet interface for proxy filter
svn path=/trunk/; revision=46116
2010-03-11 21:38:13 +00:00
|
|
|
#ifndef _MSC_VER
|
2010-02-23 17:19:45 +00:00
|
|
|
const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
|
[KSPROXY]
- Recreate resource file with visual studio
- Fix compilation with msvc
- Copy extra format buffer in IEnumMediaTypes::Next
- Create the pin handle in IPin::ReceiveConnection
- Implement IPin::Disconnect for the input pin
- Enumerate media formats and pass it to constructor of CEnumMediaTypes
- Check if the passed format is null in CInputPin::CheckFormat
- Copy extra format buffer after KSDATAFORMAT in the pin connection request
- Implement KsGetMediaType function
- Implement ISpecifyPropertyPages, IKsPropertySet, IKsControl, IStreamBuilder, IKsPinFactory for the output pin
- Implement IPin::ReceiveConnection, IPin::EnumMediaTypes for output pin
- Stub interfaces for IReferenceClock, IMediaSeeking, IKsTopology, IKsAggregateControl, IKsClockPropertySet, ISpecifyPropertyPages, IPersistStream for proxy filter
- Implement IAMDeviceRemoval, IKsControl, IAMFilterMiscFlags, IKsPropertySet interface for proxy filter
svn path=/trunk/; revision=46116
2010-03-11 21:38:13 +00:00
|
|
|
#endif
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
const GUID IID_IClassFactory = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
|
|
|
|
|
|
|
|
class CKsDataTypeHandler : public IKsDataTypeHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) AddRef()
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&m_Ref);
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
STDMETHODIMP_(ULONG) Release()
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&m_Ref);
|
|
|
|
|
|
|
|
if (!m_Ref)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE KsCompleteIoOperation(IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation, IN BOOL Cancelled);
|
|
|
|
HRESULT STDMETHODCALLTYPE KsIsMediaTypeInRanges(IN PVOID DataRanges);
|
|
|
|
HRESULT STDMETHODCALLTYPE KsPrepareIoOperation(IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation);
|
|
|
|
HRESULT STDMETHODCALLTYPE KsQueryExtendedSize(OUT ULONG* ExtendedSize);
|
|
|
|
HRESULT STDMETHODCALLTYPE KsSetMediaType(IN const AM_MEDIA_TYPE* AmMediaType);
|
|
|
|
|
2010-03-15 16:22:41 +00:00
|
|
|
CKsDataTypeHandler() : m_Ref(0), m_Type(0){};
|
|
|
|
virtual ~CKsDataTypeHandler()
|
|
|
|
{
|
|
|
|
if (m_Type)
|
|
|
|
{
|
|
|
|
if (m_Type->pbFormat)
|
|
|
|
CoTaskMemFree(m_Type->pbFormat);
|
|
|
|
|
|
|
|
if (m_Type->pUnk)
|
|
|
|
m_Type->pUnk->Release();
|
|
|
|
|
|
|
|
CoTaskMemFree(m_Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
LONG m_Ref;
|
2010-03-15 16:22:41 +00:00
|
|
|
AM_MEDIA_TYPE * m_Type;
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::QueryInterface(
|
|
|
|
IN REFIID refiid,
|
|
|
|
OUT PVOID* Output)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(refiid, IID_IUnknown) ||
|
|
|
|
IsEqualGUID(refiid, IID_IKsDataTypeHandler))
|
|
|
|
{
|
|
|
|
*Output = PVOID(this);
|
|
|
|
reinterpret_cast<IUnknown*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::KsCompleteIoOperation(
|
|
|
|
IN OUT IMediaSample *Sample,
|
|
|
|
IN OUT PVOID StreamHeader,
|
|
|
|
IN KSIOOPERATION IoOperation,
|
|
|
|
IN BOOL Cancelled)
|
|
|
|
{
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::KsIsMediaTypeInRanges(
|
|
|
|
IN PVOID DataRanges)
|
|
|
|
{
|
2010-03-15 16:22:41 +00:00
|
|
|
PKSMULTIPLE_ITEM DataList;
|
|
|
|
PKSDATARANGE DataRange;
|
|
|
|
ULONG Index;
|
2011-09-11 16:56:56 +00:00
|
|
|
//HRESULT hr = S_FALSE;
|
2010-03-15 16:22:41 +00:00
|
|
|
|
2010-03-24 17:30:43 +00:00
|
|
|
#ifdef KSPROXY_TRACE
|
2010-03-15 16:22:41 +00:00
|
|
|
OutputDebugStringW(L"CKsDataTypeHandler::KsIsMediaTypeInRanges\n");
|
2010-03-24 17:30:43 +00:00
|
|
|
#endif
|
2010-03-15 16:22:41 +00:00
|
|
|
|
|
|
|
DataList = (PKSMULTIPLE_ITEM)DataRanges;
|
|
|
|
DataRange = (PKSDATARANGE)(DataList + 1);
|
|
|
|
|
|
|
|
for(Index = 0; Index < DataList->Count; Index++)
|
|
|
|
{
|
|
|
|
BOOL bMatch = FALSE;
|
|
|
|
|
|
|
|
if (DataRange->FormatSize >= sizeof(KSDATARANGE))
|
|
|
|
{
|
|
|
|
bMatch = IsEqualGUID(DataRange->MajorFormat, GUID_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bMatch && DataRange->FormatSize >= sizeof(KSDATARANGE_AUDIO))
|
|
|
|
{
|
|
|
|
bMatch = IsEqualGUID(DataRange->MajorFormat, MEDIATYPE_Audio);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bMatch)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(DataRange->SubFormat, m_Type->subtype) ||
|
|
|
|
IsEqualGUID(DataRange->SubFormat, GUID_NULL))
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(DataRange->Specifier, m_Type->formattype) ||
|
|
|
|
IsEqualGUID(DataRange->Specifier, GUID_NULL))
|
|
|
|
{
|
|
|
|
if (!IsEqualGUID(m_Type->formattype, FORMAT_WaveFormatEx) && !IsEqualGUID(DataRange->Specifier, FORMAT_WaveFormatEx))
|
|
|
|
{
|
|
|
|
//found match
|
2011-09-11 16:56:56 +00:00
|
|
|
//hr = S_OK;
|
2010-03-15 16:22:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DataRange->FormatSize >= sizeof(KSDATARANGE_AUDIO) && m_Type->cbFormat >= sizeof(WAVEFORMATEX))
|
|
|
|
{
|
|
|
|
LPWAVEFORMATEX Format = (LPWAVEFORMATEX)m_Type->pbFormat;
|
|
|
|
PKSDATARANGE_AUDIO AudioRange = (PKSDATARANGE_AUDIO)DataRange;
|
|
|
|
|
|
|
|
if (Format->nSamplesPerSec >= AudioRange->MinimumSampleFrequency &&
|
|
|
|
Format->nSamplesPerSec <= AudioRange->MaximumSampleFrequency &&
|
|
|
|
Format->wBitsPerSample >= AudioRange->MinimumSampleFrequency &&
|
|
|
|
Format->wBitsPerSample <= AudioRange->MaximumBitsPerSample &&
|
|
|
|
Format->nChannels <= AudioRange->MaximumChannels)
|
|
|
|
{
|
|
|
|
// found match
|
2011-09-11 16:56:56 +00:00
|
|
|
//hr = S_OK;
|
2010-03-15 16:22:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DataRange = (PKSDATARANGE)(((ULONG_PTR)DataRange + DataRange->FormatSize + 7) & ~7);
|
|
|
|
}
|
|
|
|
return S_OK;
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::KsPrepareIoOperation(
|
|
|
|
IN OUT IMediaSample *Sample,
|
|
|
|
IN OUT PVOID StreamHeader,
|
|
|
|
IN KSIOOPERATION IoOperation)
|
|
|
|
{
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::KsQueryExtendedSize(
|
|
|
|
OUT ULONG* ExtendedSize)
|
|
|
|
{
|
|
|
|
/* no header extension required */
|
|
|
|
*ExtendedSize = 0;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CKsDataTypeHandler::KsSetMediaType(
|
|
|
|
IN const AM_MEDIA_TYPE* AmMediaType)
|
|
|
|
{
|
2010-03-24 17:30:43 +00:00
|
|
|
#ifdef KSPROXY_TRACE
|
2010-03-15 16:22:41 +00:00
|
|
|
OutputDebugString("CKsDataTypeHandler::KsSetMediaType\n");
|
2010-03-24 17:30:43 +00:00
|
|
|
#endif
|
2010-03-15 16:22:41 +00:00
|
|
|
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
if (m_Type)
|
|
|
|
{
|
|
|
|
/* media type can only be set once */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-03-15 16:22:41 +00:00
|
|
|
m_Type = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
|
|
|
|
if (!m_Type)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
CopyMemory(m_Type, AmMediaType, sizeof(AM_MEDIA_TYPE));
|
|
|
|
|
|
|
|
if (m_Type->cbFormat)
|
|
|
|
{
|
|
|
|
m_Type->pbFormat = (BYTE*)CoTaskMemAlloc(m_Type->cbFormat);
|
|
|
|
|
|
|
|
if (!m_Type->pbFormat)
|
|
|
|
{
|
|
|
|
CoTaskMemFree(m_Type);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyMemory(m_Type->pbFormat, AmMediaType->pbFormat, m_Type->cbFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_Type->pUnk)
|
|
|
|
m_Type->pUnk->AddRef();
|
|
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
CKsDataTypeHandler_Constructor (
|
|
|
|
IUnknown * pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
2010-03-24 17:30:43 +00:00
|
|
|
#ifdef KSPROXY_TRACE
|
2010-03-02 16:27:50 +00:00
|
|
|
OutputDebugStringW(L"CKsDataTypeHandler_Constructor\n");
|
2010-03-24 17:30:43 +00:00
|
|
|
#endif
|
|
|
|
|
[KSPROXY]
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject
svn path=/trunk/; revision=45608
2010-02-18 15:24:29 +00:00
|
|
|
CKsDataTypeHandler * handler = new CKsDataTypeHandler();
|
|
|
|
|
|
|
|
if (!handler)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(handler->QueryInterface(riid, ppv)))
|
|
|
|
{
|
|
|
|
/* not supported */
|
|
|
|
delete handler;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|