2005-04-15 20:17:14 +00:00
|
|
|
/*
|
2006-06-22 13:34:00 +00:00
|
|
|
* Modified for use with MPlayer, detailed changelog at
|
|
|
|
* http://svn.mplayerhq.hu/mplayer/trunk/
|
2005-04-15 20:17:14 +00:00
|
|
|
*/
|
2001-10-04 11:56:12 +00:00
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
#include "wine/winerror.h"
|
|
|
|
#include "wine/windef.h"
|
|
|
|
#include "outputpin.h"
|
2007-02-23 09:58:01 +00:00
|
|
|
#include "mediatype.h"
|
2001-11-21 19:12:39 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2002-09-13 19:43:17 +00:00
|
|
|
#include <stdlib.h>
|
2001-05-06 21:43:45 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
static inline int output_unimplemented(const char* s, void* p)
|
2001-12-11 23:29:24 +00:00
|
|
|
{
|
|
|
|
Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
An object beyond interface IEnumMediaTypes.
|
|
|
|
Returned by COutputPin through call IPin::EnumMediaTypes().
|
|
|
|
*/
|
2001-11-21 19:12:39 +00:00
|
|
|
typedef struct CEnumMediaTypes
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-11-21 19:12:39 +00:00
|
|
|
IEnumMediaTypes_vt* vt;
|
2001-12-11 23:29:24 +00:00
|
|
|
DECLARE_IUNKNOWN();
|
2001-03-20 00:05:27 +00:00
|
|
|
AM_MEDIA_TYPE type;
|
2001-11-21 19:12:39 +00:00
|
|
|
GUID interfaces[2];
|
|
|
|
} CEnumMediaTypes;
|
2001-03-20 00:05:27 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
IMemOutput interface implementation
|
|
|
|
*/
|
2008-01-20 17:16:39 +00:00
|
|
|
struct COutputMemPin
|
2002-09-13 19:43:17 +00:00
|
|
|
{
|
|
|
|
IMemInputPin_vt* vt;
|
|
|
|
DECLARE_IUNKNOWN();
|
|
|
|
char** frame_pointer;
|
|
|
|
long* frame_size_pointer;
|
|
|
|
MemAllocator* pAllocator;
|
|
|
|
COutputPin* parent;
|
|
|
|
};
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IEnumMediaTypes:Next (retrives a specified number of media types )
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to CEnumMediaTypes object
|
|
|
|
* \param[in] cMediaTypes number of media types to retrive
|
|
|
|
* \param[out] ppMediaTypes array of AM_MEDIA_TYPE structure pointers of size cMediaTypes
|
|
|
|
* \param[out] pcFetched address of variables that receives number of returned media types
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - did not return as meny structures as requested
|
|
|
|
* \return E_INVALIDARG Invalid argument
|
|
|
|
* \return E_POINTER Null pointer
|
|
|
|
* \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This,
|
|
|
|
/* [in] */ ULONG cMediaTypes,
|
|
|
|
/* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes,
|
|
|
|
/* [out] */ ULONG *pcFetched)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-11-21 19:12:39 +00:00
|
|
|
AM_MEDIA_TYPE* type = &((CEnumMediaTypes*)This)->type;
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("CEnumMediaTypes::Next(%p) called\n", This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!ppMediaTypes)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (!pcFetched && (cMediaTypes!=1))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (cMediaTypes <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (pcFetched)
|
|
|
|
*pcFetched=1;
|
2007-02-23 09:58:01 +00:00
|
|
|
ppMediaTypes[0] = CreateMediaType(type);
|
|
|
|
|
2001-08-16 00:50:02 +00:00
|
|
|
if (cMediaTypes == 1)
|
|
|
|
return 0;
|
2001-03-20 00:05:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
|
|
|
|
/* I expect that these methods are unused. */
|
2007-01-27 15:49:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief IEnumMediaTypes::Skip (skips over a specified number of media types)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to CEnumMEdiaTypes object
|
|
|
|
* \param[in] cMediaTypes number of media types to skip
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - skipped past the end of the sequence
|
|
|
|
* \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL CEnumMediaTypes_Skip(IEnumMediaTypes * This,
|
|
|
|
/* [in] */ ULONG cMediaTypes)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("CEnumMediaTypes::Skip", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IEnumMediaTypes::Reset (resets enumeration sequence to beginning)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to CEnumMEdiaTypes object
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL CEnumMediaTypes_Reset(IEnumMediaTypes * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("CEnumMediaTypes::Reset(%p) called\n", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IEnumMediaTypes::Clone (makes a copy of enumerator, returned object
|
|
|
|
* starts at the same position as original)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to CEnumMEdiaTypes object
|
|
|
|
* \param[out] ppEnum address of variable that receives pointer to IEnumMediaTypes interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_OUTOFMEMRY - Insufficient memory
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_ENUM_OUT_OF_SYNC - pin's state has changed and is now inconsistent with enumerator
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL CEnumMediaTypes_Clone(IEnumMediaTypes * This,
|
|
|
|
/* [out] */ IEnumMediaTypes **ppEnum)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("CEnumMediaTypes::Clone(%p) called\n", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief CEnumMediaTypes destructor
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to CEnumMediaTypes object
|
|
|
|
*
|
|
|
|
*/
|
2002-11-26 21:00:20 +00:00
|
|
|
static void CEnumMediaTypes_Destroy(CEnumMediaTypes* This)
|
2001-08-16 00:50:02 +00:00
|
|
|
{
|
2007-02-23 10:59:54 +00:00
|
|
|
FreeMediaType(&(This->type));
|
2001-11-21 19:12:39 +00:00
|
|
|
free(This->vt);
|
|
|
|
free(This);
|
2001-05-06 21:43:45 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
// IEnumMediaTypes->IUnknown methods
|
2001-11-21 19:12:39 +00:00
|
|
|
IMPLEMENT_IUNKNOWN(CEnumMediaTypes)
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief CEnumMediaTypes constructor
|
|
|
|
*
|
|
|
|
* \param[in] amt media type for enumerating
|
|
|
|
*
|
|
|
|
* \return pointer to CEnumMEdiaTypes object or NULL if error occured
|
|
|
|
*
|
|
|
|
*/
|
2002-11-26 21:00:20 +00:00
|
|
|
static CEnumMediaTypes* CEnumMediaTypesCreate(const AM_MEDIA_TYPE* amt)
|
2001-05-06 21:43:45 +00:00
|
|
|
{
|
2008-10-31 13:12:54 +00:00
|
|
|
CEnumMediaTypes *This = malloc(sizeof(CEnumMediaTypes)) ;
|
2001-12-11 23:29:24 +00:00
|
|
|
|
|
|
|
if (!This)
|
|
|
|
return NULL;
|
|
|
|
|
2008-10-31 13:12:54 +00:00
|
|
|
This->vt = malloc(sizeof(IEnumMediaTypes_vt));
|
2001-12-11 23:29:24 +00:00
|
|
|
if (!This->vt)
|
|
|
|
{
|
|
|
|
free(This);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
This->refcount = 1;
|
2007-02-23 09:58:01 +00:00
|
|
|
CopyMediaType(&(This->type),amt);
|
2001-03-20 00:05:27 +00:00
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
This->vt->QueryInterface = CEnumMediaTypes_QueryInterface;
|
|
|
|
This->vt->AddRef = CEnumMediaTypes_AddRef;
|
|
|
|
This->vt->Release = CEnumMediaTypes_Release;
|
|
|
|
This->vt->Next = CEnumMediaTypes_Next;
|
|
|
|
This->vt->Skip = CEnumMediaTypes_Skip;
|
|
|
|
This->vt->Reset = CEnumMediaTypes_Reset;
|
|
|
|
This->vt->Clone = CEnumMediaTypes_Clone;
|
2001-03-20 00:05:27 +00:00
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
This->interfaces[0] = IID_IUnknown;
|
|
|
|
This->interfaces[1] = IID_IEnumMediaTypes;
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
return This;
|
2001-08-16 00:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
/*************
|
|
|
|
* COutputPin
|
2007-01-27 15:49:53 +00:00
|
|
|
*
|
|
|
|
* WARNING:
|
|
|
|
* This is implementation of INPUT pin in DirectShow's terms
|
|
|
|
*
|
2001-11-21 19:12:39 +00:00
|
|
|
*************/
|
2001-08-16 00:50:02 +00:00
|
|
|
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \brief IUnknown::QueryInterface (query object for interface)
|
|
|
|
* \param[in] This pointer to IUnknown interface
|
|
|
|
* \param[in] iid GUID of requested interface
|
|
|
|
* \param[out] ppv receives pointer to interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success (and *ppv contains valid pointer)
|
|
|
|
* \return E_NOINTERFACE - interface not found (and *ppv was set NULL)
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Make sure to call Release on received interface when you are done
|
|
|
|
*
|
|
|
|
*/
|
2002-09-13 19:43:17 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv)
|
2001-08-16 00:50:02 +00:00
|
|
|
{
|
2001-11-21 19:12:39 +00:00
|
|
|
COutputPin* p = (COutputPin*) This;
|
|
|
|
|
2001-08-16 00:50:02 +00:00
|
|
|
Debug printf("COutputPin_QueryInterface(%p) called\n", This);
|
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (memcmp(iid, &IID_IUnknown, 16) == 0)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-08-16 00:50:02 +00:00
|
|
|
*ppv = p;
|
|
|
|
p->vt->AddRef(This);
|
|
|
|
return 0;
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
if (memcmp(iid, &IID_IMemInputPin, 16) == 0)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-08-16 00:50:02 +00:00
|
|
|
*ppv = p->mempin;
|
|
|
|
p->mempin->vt->AddRef((IUnknown*)*ppv);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-"
|
2001-05-06 21:43:45 +00:00
|
|
|
"%02x%02x%02x%02x%02x%02x\n",
|
|
|
|
iid->f1, iid->f2, iid->f3,
|
|
|
|
(unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
|
|
|
|
(unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
|
|
|
|
(unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
|
|
|
|
(unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
|
2001-08-16 00:50:02 +00:00
|
|
|
return E_NOINTERFACE;
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// IPin methods
|
2007-01-27 15:49:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief IPin::Connect (connects pin to another pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[in] pReceivePin pointer to IPin interface of remote pin
|
|
|
|
* \param[in] pmt suggested media type for link. Can be NULL (any media type)
|
|
|
|
*
|
|
|
|
* \return S_OK - success.
|
|
|
|
* \return VFW_E_ALREADY_CONNECTED - pin already connected
|
|
|
|
* \return VFW_E_NOT_STOPPED - filter is active
|
|
|
|
* \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable
|
|
|
|
* \return Apropriate error code otherwise.
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_Connect(IPin * This,
|
|
|
|
/* [in] */ IPin *pReceivePin,
|
|
|
|
/* [in] */ /* const */ AM_MEDIA_TYPE *pmt)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputPin_Connect(%p) called\n",This);
|
2001-03-20 00:05:27 +00:00
|
|
|
/*
|
|
|
|
*pmt=((COutputPin*)This)->type;
|
|
|
|
if(pmt->cbFormat>0)
|
|
|
|
{
|
2003-04-21 20:12:43 +00:00
|
|
|
pmt->pbFormat=malloc(pmt->cbFormat);
|
2001-03-20 00:05:27 +00:00
|
|
|
memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat);
|
2001-11-21 19:12:39 +00:00
|
|
|
}
|
2001-03-20 00:05:27 +00:00
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
//return E_NOTIMPL;
|
|
|
|
return 0;// XXXXXXXXXXXXX CHECKME XXXXXXXXXXXXXXX
|
2001-03-20 00:05:27 +00:00
|
|
|
// if I put return 0; here, it crashes
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::ReceiveConnection (accepts a connection from another pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[in] pConnector connecting pin's IPin interface
|
|
|
|
* \param[in] pmt suggested media type for connection
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_ALREADY_CONNECTED - pin already connected
|
|
|
|
* \return VFW_E_NOT_STOPPED - filter is active
|
|
|
|
* \return VFW_E_TYPE_NOT_ACCEPT - type is not acceptable
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* When returning S_OK method should also do the following:
|
|
|
|
* - store media type and return the same type in IPin::ConnectionMediaType
|
|
|
|
* - store pConnector and return it in IPin::ConnectedTo
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_ReceiveConnection(IPin * This,
|
|
|
|
/* [in] */ IPin *pConnector,
|
|
|
|
/* [in] */ const AM_MEDIA_TYPE *pmt)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_ReceiveConnection(%p) called\n", This);
|
|
|
|
((COutputPin*)This)->remote = pConnector;
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::Disconnect (accepts a connection from another pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - pin was not connected
|
|
|
|
* \return VFW_E_NOT_STOPPED - filter is active
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* To break connection you have to also call Disconnect on other pin
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_Disconnect(IPin * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_Disconnect(%p) called\n", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::ConnectedTo (retrieves pointer to the connected pin, if such exist)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] pPin pointer to remote pin's IPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_NOT_CONNECTED - pin is not connected
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Caller must call Release on received IPin, when done
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_ConnectedTo(IPin * This,
|
|
|
|
/* [out] */ IPin **pPin)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_ConnectedTo(%p) called\n", This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!pPin)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pPin = ((COutputPin*)This)->remote;
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::ConnectionMediaType (retrieves media type for connection, if such exist)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] pmt pointer to AM_MEDIA_TYPE, that receives connection media type
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_NOT_CONNECTED - pin is not connected
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_ConnectionMediaType(IPin * This,
|
|
|
|
/* [out] */ AM_MEDIA_TYPE *pmt)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputPin_ConnectionMediaType(%p) called\n",This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!pmt)
|
|
|
|
return E_INVALIDARG;
|
2007-02-23 09:58:01 +00:00
|
|
|
CopyMediaType(pmt,&(((COutputPin*)This)->type));
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::QueryPinInfo (retrieves information about the pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] pInfo pointer to PIN_INFO structure, that receives pin info
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* If pInfo->pFilter is not NULL, then caller must call Release on pInfo->pFilter when done
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryPinInfo(IPin * This,
|
|
|
|
/* [out] */ PIN_INFO *pInfo)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_QueryPinInfo", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::QueryDirection (retrieves pin direction)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] pPinDir pointer to variable, that receives pin direction (PINDIR_INPUT,PINDIR_OUTPUT)
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryDirection(IPin * This,
|
|
|
|
/* [out] */ PIN_DIRECTION *pPinDir)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_QueryDirection(%p) called\n", This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!pPinDir)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pPinDir = PINDIR_INPUT;
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::QueryId (retrieves pin identificator)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] Id adress of variable, that receives string with pin's Id.
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_OUTOFMEMORY - Insufficient memory
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Pin's Id is not the same as pin's name
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryId(IPin * This,
|
|
|
|
/* [out] */ LPWSTR *Id)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_QueryId", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::QueryAccept (determines can media type be accepted or not)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[in] pmt Media type to check
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - pin rejects media type
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryAccept(IPin * This,
|
|
|
|
/* [in] */ const AM_MEDIA_TYPE *pmt)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_QueryAccept", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::EnumMediaTypes (enumerates the pin's preferred media types)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] ppEnum adress of variable that receives pointer to IEnumMEdiaTypes interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_OUTOFMEMORY - Insufficient memory
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Caller must call Release on received interface when done
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_EnumMediaTypes(IPin * This,
|
|
|
|
/* [out] */ IEnumMediaTypes **ppEnum)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputPin_EnumMediaTypes(%p) called\n",This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!ppEnum)
|
|
|
|
return E_INVALIDARG;
|
2001-11-21 19:12:39 +00:00
|
|
|
*ppEnum = (IEnumMediaTypes*) CEnumMediaTypesCreate(&((COutputPin*)This)->type);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::QueryInternalConnections (retries pin's internal connections)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[out] apPin Array that receives pins, internally connected to this
|
|
|
|
* \param[in,out] nPint Size of an array
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - pin rejects media type
|
|
|
|
* \return E_NOTIMPL - not implemented
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_QueryInternalConnections(IPin * This,
|
|
|
|
/* [out] */ IPin **apPin,
|
|
|
|
/* [out][in] */ ULONG *nPin)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_QueryInternalConnections", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::EndOfStream (notifies pin, that no data is expected, until new run command)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_UNEXPECTED - The pin is output pin
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream,
|
|
|
|
* IMemAllocator::GetBuffer runs in different (streaming) thread then other
|
|
|
|
* methods (application thread).
|
|
|
|
* IMemoryInputPin::NewSegment runs either in streaming or application thread.
|
|
|
|
* Developer must use critical sections for thread-safing work.
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_EndOfStream(IPin * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_EndOfStream", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IPin::BeginFlush (begins a flush operation)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_UNEXPECTED - The pin is output pin
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_BeginFlush(IPin * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_BeginFlush", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
2007-01-27 16:28:16 +00:00
|
|
|
* \brief IPin::EndFlush (ends a flush operation)
|
2007-01-27 15:49:53 +00:00
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_UNEXPECTED - The pin is output pin
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_EndFlush(IPin * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2002-09-13 19:43:17 +00:00
|
|
|
return output_unimplemented("COutputPin_EndFlush", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
2007-01-27 16:28:16 +00:00
|
|
|
* \brief IPin::NewSegment (media sample received after this call grouped as segment with common
|
2007-01-27 15:49:53 +00:00
|
|
|
* start,stop time and rate)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IPin interface
|
|
|
|
* \param[in] tStart start time of new segment
|
|
|
|
* \param[in] tStop end time of new segment
|
|
|
|
* \param[in] dRate rate at wich segment should be processed
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_UNEXPECTED - The pin is output pin
|
|
|
|
*
|
|
|
|
*/
|
2001-08-16 00:50:02 +00:00
|
|
|
static HRESULT STDCALL COutputPin_NewSegment(IPin * This,
|
|
|
|
/* [in] */ REFERENCE_TIME tStart,
|
|
|
|
/* [in] */ REFERENCE_TIME tStop,
|
|
|
|
/* [in] */ double dRate)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2001-11-21 19:12:39 +00:00
|
|
|
Debug printf("COutputPin_NewSegment(%Ld,%Ld,%f) called\n",
|
2001-08-16 00:50:02 +00:00
|
|
|
tStart, tStop, dRate);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IMemInputPin->IUnknown methods
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IUnknown::QueryInterface (query object for interface)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IUnknown interface
|
|
|
|
* \param[in] iid GUID of requested interface
|
|
|
|
* \param[out] ppv receives pointer to interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success (and *ppv contains valid pointer)
|
|
|
|
* \return E_NOINTERFACE - interface not found (and *ppv was set NULL)
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Make sure to call Release on received interface when you are done
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-02-26 17:21:17 +00:00
|
|
|
COutputMemPin* p = (COutputMemPin*)This;
|
2001-11-21 19:12:39 +00:00
|
|
|
|
2007-01-27 17:01:54 +00:00
|
|
|
Debug printf("COutputMemPin_QueryInterface(%p) called\n", This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!ppv)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2001-03-20 00:05:27 +00:00
|
|
|
if(!memcmp(iid, &IID_IUnknown, 16))
|
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
*ppv = p;
|
2001-08-16 00:50:02 +00:00
|
|
|
p->vt->AddRef(This);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
/*if(!memcmp(iid, &IID_IPin, 16))
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
|
|
|
COutputPin* ptr=(COutputPin*)(This-1);
|
|
|
|
*ppv=(void*)ptr;
|
|
|
|
AddRef((IUnknown*)ptr);
|
|
|
|
return 0;
|
|
|
|
}*/
|
|
|
|
if(!memcmp(iid, &IID_IMemInputPin, 16))
|
|
|
|
{
|
2007-02-26 17:21:17 +00:00
|
|
|
*ppv = p;
|
|
|
|
p->vt->AddRef(This);
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \
|
2001-08-16 00:50:02 +00:00
|
|
|
"%02x%02x%02x%02x%02x%02x\n",
|
|
|
|
iid->f1, iid->f2, iid->f3,
|
|
|
|
(unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
|
|
|
|
(unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
|
|
|
|
(unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
|
|
|
|
(unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
|
|
|
|
return E_NOINTERFACE;
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// IMemInputPin methods
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IMemInputPin::GetAllocator (retrives memory allocator, proposed by pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
* \param[out] ppAllocator address of variable that receives allocator's IMemAllocator interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return VFW_E_NO_ALLOCATOR - No allocator
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Make sure to call Release on received interface when you are done
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_GetAllocator(IMemInputPin* This,
|
2001-11-21 19:12:39 +00:00
|
|
|
/* [out] */ IMemAllocator** ppAllocator)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputMemPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator);
|
2001-11-21 19:12:39 +00:00
|
|
|
*ppAllocator = (IMemAllocator*) MemAllocatorCreate();
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-11-21 19:12:39 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \brief IMemInputPin::NotifyAllocator (specifies an allocator for the connection)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
* \param[in] pAllocator allocator's IMemAllocator interface
|
|
|
|
* \param[in] bReadOnly specifies whether samples from allocator are readonly
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return Apropriate error code otherwise
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_NotifyAllocator(IMemInputPin* This,
|
2001-11-21 19:12:39 +00:00
|
|
|
/* [in] */ IMemAllocator* pAllocator,
|
2001-08-16 00:50:02 +00:00
|
|
|
/* [in] */ int bReadOnly)
|
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputMemPin_NotifyAllocator(%p, %p) called\n", This, pAllocator);
|
2001-08-16 00:50:02 +00:00
|
|
|
((COutputMemPin*)This)->pAllocator = (MemAllocator*) pAllocator;
|
2001-03-20 00:05:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IMemInputPin::GetAllocatorRequirements (retrieves allocator properties requested by
|
|
|
|
* input pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
* \param[out] pProps pointer to a structure that receives allocator properties
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return E_NOTIMPL - Not implemented
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_GetAllocatorRequirements(IMemInputPin* This,
|
2001-11-21 19:12:39 +00:00
|
|
|
/* [out] */ ALLOCATOR_PROPERTIES* pProps)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
return output_unimplemented("COutputMemPin_GetAllocatorRequirements", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IMemInputPin::Receive (receives the next media sample int thre stream)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
* \param[in] pSample pointer to sample's IMediaSample interface
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - The sample was rejected
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_INVALIDMEDIATYPE - invalid media type
|
|
|
|
* \return VFW_E_RUNTIME_ERROR - run-time error occured
|
|
|
|
* \return VFW_E_WRONG_STATE - pin is stopped
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* Method san do on of the following:
|
|
|
|
* - reject sample
|
|
|
|
* - accept sample and process it in another thread
|
|
|
|
* - accept sample and process it before returning
|
|
|
|
*
|
|
|
|
* In second case method should increase reference count for sample (through AddRef)
|
|
|
|
* In the last case method might block indefinitely. If this might
|
|
|
|
* happen IMemInpuPin::ReceiveCAnBlock returns S_OK
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream,
|
|
|
|
* IMemAllocator::GetBuffer runs in different (streaming) thread then other
|
|
|
|
* methods (application thread).
|
|
|
|
* IMemoryInputPin::NewSegment runs either in streaming or application thread.
|
|
|
|
* Developer must use critical sections for thread-safing work.
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_Receive(IMemInputPin* This,
|
2001-11-21 19:12:39 +00:00
|
|
|
/* [in] */ IMediaSample* pSample)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputMemPin_Receive(%p) called\n", This);
|
2001-08-16 00:50:02 +00:00
|
|
|
if (!pSample)
|
|
|
|
return E_INVALIDARG;
|
2001-11-21 19:12:39 +00:00
|
|
|
|
2007-03-02 18:52:10 +00:00
|
|
|
if(((COutputMemPin*)This)->parent->SampleProc)
|
|
|
|
return ((COutputMemPin*)This)->parent->SampleProc(((COutputMemPin*)This)->parent->pUserData,pSample);
|
|
|
|
//reject sample
|
|
|
|
return S_FALSE;
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IMemInputPin::ReceiveMultiple (receives multiple samples in the stream)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
* \param[in] pSamples pointer to array with samples
|
|
|
|
* \param[in] nSamples number of samples in array
|
|
|
|
* \param[out] nSamplesProcessed number of processed samples
|
|
|
|
*
|
|
|
|
* \return S_OK - success
|
|
|
|
* \return S_FALSE - The sample was rejected
|
|
|
|
* \return E_POINTER - Null pointer
|
|
|
|
* \return VFW_E_INVALIDMEDIATYPE - invalid media type
|
|
|
|
* \return VFW_E_RUNTIME_ERROR - run-time error occured
|
|
|
|
* \return VFW_E_WRONG_STATE - pin is stopped
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* This method behaves like IMemInputPin::Receive but for array of samples
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* IMemoryInputPin::Receive,IMemoryInputPin::ReceiveMultiple, IMemoryInputPin::EndOfStream,
|
|
|
|
* IMemAllocator::GetBuffer runs in different (streaming) thread then other
|
|
|
|
* methods (application thread).
|
|
|
|
* IMemoryInputPin::NewSegment runs either in streaming or application thread.
|
|
|
|
* Developer must use critical sections for thread-safing work.
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_ReceiveMultiple(IMemInputPin * This,
|
2001-08-16 00:50:02 +00:00
|
|
|
/* [size_is][in] */ IMediaSample **pSamples,
|
|
|
|
/* [in] */ long nSamples,
|
|
|
|
/* [out] */ long *nSamplesProcessed)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-03-02 18:52:10 +00:00
|
|
|
HRESULT hr;
|
2008-01-19 15:08:01 +00:00
|
|
|
Debug printf("COutputMemPin_ReceiveMultiple(%p) %ld\n", This,nSamples);
|
2007-03-02 18:52:10 +00:00
|
|
|
for(*nSamplesProcessed=0; *nSamplesProcessed < nSamples; *nSamplesProcessed++) {
|
|
|
|
hr = This->vt->Receive(This,pSamples[*nSamplesProcessed]);
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
}
|
|
|
|
return hr;
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IMemInputPin::ReceiveCanBlock (determines whether IMemInputPin:::Receive might block)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IMemInputPin interface
|
|
|
|
*
|
|
|
|
* \return S_OK - the pin might block
|
|
|
|
* \return S_FALSE - the pin will not block
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_ReceiveCanBlock(IMemInputPin * This)
|
2001-03-20 00:05:27 +00:00
|
|
|
{
|
2007-01-27 16:41:01 +00:00
|
|
|
return output_unimplemented("COutputMemPin_ReceiveCanBlock", This);
|
2001-03-20 00:05:27 +00:00
|
|
|
}
|
2001-08-16 00:50:02 +00:00
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief COutputPin::SetNewFormat(sets new media format for the pin)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to COutputPin class
|
|
|
|
* \param[in] amt new media format
|
|
|
|
*
|
|
|
|
*/
|
2001-11-21 19:12:39 +00:00
|
|
|
static void COutputPin_SetNewFormat(COutputPin* This, const AM_MEDIA_TYPE* amt)
|
|
|
|
{
|
2007-02-23 09:58:01 +00:00
|
|
|
CopyMediaType(&(This->type),amt);
|
2001-11-21 19:12:39 +00:00
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief COutputPin destructor
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to COutputPin class
|
|
|
|
*
|
|
|
|
*/
|
2001-11-21 19:12:39 +00:00
|
|
|
static void COutputPin_Destroy(COutputPin* This)
|
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
if (This->mempin->vt)
|
|
|
|
free(This->mempin->vt);
|
|
|
|
if (This->mempin)
|
|
|
|
free(This->mempin);
|
|
|
|
if (This->vt)
|
|
|
|
free(This->vt);
|
2007-02-23 09:58:01 +00:00
|
|
|
FreeMediaType(&(This->type));
|
2001-11-21 19:12:39 +00:00
|
|
|
free(This);
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IUnknown::AddRef (increases reference counter for interface)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IUnknown class
|
|
|
|
*
|
|
|
|
* \return new value of reference counter
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* Return value should be used only for debug purposes
|
|
|
|
*
|
|
|
|
*/
|
2001-11-21 19:12:39 +00:00
|
|
|
static HRESULT STDCALL COutputPin_AddRef(IUnknown* This)
|
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_AddRef(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);
|
2001-11-21 19:12:39 +00:00
|
|
|
((COutputPin*)This)->refcount++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IUnknown::Release (desreases reference counter for interface)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IUnknown class
|
|
|
|
*
|
|
|
|
* \return new value of reference counter
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* When reference counter reaches zero calls destructor
|
|
|
|
* Return value should be used only for debug purposes
|
|
|
|
*
|
|
|
|
*/
|
2001-11-21 19:12:39 +00:00
|
|
|
static HRESULT STDCALL COutputPin_Release(IUnknown* This)
|
|
|
|
{
|
2001-12-11 23:29:24 +00:00
|
|
|
Debug printf("COutputPin_Release(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);
|
|
|
|
if (--((COutputPin*)This)->refcount <= 0)
|
2001-11-21 19:12:39 +00:00
|
|
|
COutputPin_Destroy((COutputPin*)This);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IUnknown::AddRef (increases reference counter for interface)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IUnknown class
|
|
|
|
*
|
|
|
|
* \return new value of reference counter
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* Return value should be used only for debug purposes
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_AddRef(IUnknown* This)
|
2001-11-21 19:12:39 +00:00
|
|
|
{
|
|
|
|
COutputMemPin* p = (COutputMemPin*) This;
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputMemPin_AddRef(%p) called (%p, %d)\n", p, p->parent, p->parent->refcount);
|
2001-11-21 19:12:39 +00:00
|
|
|
p->parent->refcount++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief IUnknown::Release (desreases reference counter for interface)
|
|
|
|
*
|
|
|
|
* \param[in] This pointer to IUnknown class
|
|
|
|
*
|
|
|
|
* \return new value of reference counter
|
|
|
|
*
|
|
|
|
* \remarks
|
|
|
|
* When reference counter reaches zero calls destructor
|
|
|
|
* Return value should be used only for debug purposes
|
|
|
|
*
|
|
|
|
*/
|
2007-01-27 16:41:01 +00:00
|
|
|
static HRESULT STDCALL COutputMemPin_Release(IUnknown* This)
|
2001-11-21 19:12:39 +00:00
|
|
|
{
|
|
|
|
COutputMemPin* p = (COutputMemPin*) This;
|
2007-01-27 16:41:01 +00:00
|
|
|
Debug printf("COutputMemPin_Release(%p) called (%p, %d)\n",
|
2001-11-21 19:12:39 +00:00
|
|
|
p, p->parent, p->parent->refcount);
|
|
|
|
if (--p->parent->refcount <= 0)
|
|
|
|
COutputPin_Destroy(p->parent);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-27 15:49:53 +00:00
|
|
|
/**
|
|
|
|
* \brief COutputPin constructor
|
|
|
|
*
|
|
|
|
* \param[in] amt media type for pin
|
|
|
|
*
|
|
|
|
* \return pointer to COutputPin if success
|
|
|
|
* \return NULL if error occured
|
|
|
|
*
|
|
|
|
*/
|
2007-03-02 18:52:10 +00:00
|
|
|
COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt,SAMPLEPROC SampleProc,void* pUserData)
|
2001-11-21 19:12:39 +00:00
|
|
|
{
|
2008-10-31 13:12:54 +00:00
|
|
|
COutputPin* This = malloc(sizeof(COutputPin));
|
2001-12-11 23:29:24 +00:00
|
|
|
IMemInputPin_vt* ivt;
|
|
|
|
|
|
|
|
if (!This)
|
|
|
|
return NULL;
|
|
|
|
|
2008-10-31 13:12:54 +00:00
|
|
|
This->vt = malloc(sizeof(IPin_vt));
|
|
|
|
This->mempin = malloc(sizeof(COutputMemPin));
|
|
|
|
ivt = malloc(sizeof(IMemInputPin_vt));
|
2001-12-11 23:29:24 +00:00
|
|
|
|
|
|
|
if (!This->vt || !This->mempin || !ivt)
|
|
|
|
{
|
|
|
|
COutputPin_Destroy(This);
|
2008-10-31 13:13:52 +00:00
|
|
|
free(ivt);
|
2001-12-11 23:29:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-03-02 18:52:10 +00:00
|
|
|
This->SampleProc=SampleProc;
|
|
|
|
This->pUserData=pUserData;
|
|
|
|
|
2001-12-11 23:29:24 +00:00
|
|
|
This->mempin->vt = ivt;
|
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
This->refcount = 1;
|
|
|
|
This->remote = 0;
|
2007-02-23 09:58:01 +00:00
|
|
|
CopyMediaType(&(This->type),amt);
|
2001-12-11 23:29:24 +00:00
|
|
|
|
2001-11-21 19:12:39 +00:00
|
|
|
This->vt->QueryInterface = COutputPin_QueryInterface;
|
|
|
|
This->vt->AddRef = COutputPin_AddRef;
|
|
|
|
This->vt->Release = COutputPin_Release;
|
|
|
|
This->vt->Connect = COutputPin_Connect;
|
|
|
|
This->vt->ReceiveConnection = COutputPin_ReceiveConnection;
|
|
|
|
This->vt->Disconnect = COutputPin_Disconnect;
|
|
|
|
This->vt->ConnectedTo = COutputPin_ConnectedTo;
|
|
|
|
This->vt->ConnectionMediaType = COutputPin_ConnectionMediaType;
|
|
|
|
This->vt->QueryPinInfo = COutputPin_QueryPinInfo;
|
|
|
|
This->vt->QueryDirection = COutputPin_QueryDirection;
|
|
|
|
This->vt->QueryId = COutputPin_QueryId;
|
|
|
|
This->vt->QueryAccept = COutputPin_QueryAccept;
|
|
|
|
This->vt->EnumMediaTypes = COutputPin_EnumMediaTypes;
|
|
|
|
This->vt->QueryInternalConnections = COutputPin_QueryInternalConnections;
|
|
|
|
This->vt->EndOfStream = COutputPin_EndOfStream;
|
|
|
|
This->vt->BeginFlush = COutputPin_BeginFlush;
|
|
|
|
This->vt->EndFlush = COutputPin_EndFlush;
|
|
|
|
This->vt->NewSegment = COutputPin_NewSegment;
|
|
|
|
|
2007-01-27 16:41:01 +00:00
|
|
|
This->mempin->vt->QueryInterface = COutputMemPin_QueryInterface;
|
|
|
|
This->mempin->vt->AddRef = COutputMemPin_AddRef;
|
|
|
|
This->mempin->vt->Release = COutputMemPin_Release;
|
|
|
|
This->mempin->vt->GetAllocator = COutputMemPin_GetAllocator;
|
|
|
|
This->mempin->vt->NotifyAllocator = COutputMemPin_NotifyAllocator;
|
|
|
|
This->mempin->vt->GetAllocatorRequirements = COutputMemPin_GetAllocatorRequirements;
|
|
|
|
This->mempin->vt->Receive = COutputMemPin_Receive;
|
|
|
|
This->mempin->vt->ReceiveMultiple = COutputMemPin_ReceiveMultiple;
|
|
|
|
This->mempin->vt->ReceiveCanBlock = COutputMemPin_ReceiveCanBlock;
|
2001-11-21 19:12:39 +00:00
|
|
|
|
|
|
|
This->mempin->frame_size_pointer = 0;
|
|
|
|
This->mempin->frame_pointer = 0;
|
|
|
|
This->mempin->pAllocator = 0;
|
2001-11-26 00:56:11 +00:00
|
|
|
This->mempin->refcount = 1;
|
2001-11-21 19:12:39 +00:00
|
|
|
This->mempin->parent = This;
|
|
|
|
|
|
|
|
This->SetNewFormat = COutputPin_SetNewFormat;
|
|
|
|
|
|
|
|
return This;
|
2001-08-16 00:50:02 +00:00
|
|
|
}
|