⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outputpin.c

📁 coreavc for linux in unix_linux
💻 C
📖 第 1 页 / 共 2 页
字号:
 * \param[in,out] nPint Size of an array * * \return S_OK - success * \return S_FALSE - pin rejects media type * \return E_NOTIMPL - not implemented * */static HRESULT STDCALL COutputPin_QueryInternalConnections(IPin * This,						     /* [out] */ IPin **apPin,						     /* [out][in] */ ULONG *nPin){    return output_unimplemented("COutputPin_QueryInternalConnections", This);}/** * \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. * */static HRESULT STDCALL COutputPin_EndOfStream(IPin * This){    return output_unimplemented("COutputPin_EndOfStream", This);}/** * \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 * */static HRESULT STDCALL COutputPin_BeginFlush(IPin * This){    return S_OK;    //return output_unimplemented("COutputPin_BeginFlush", This);}/** * \brief IPin::EndFlush (ends a flush operation) * * \param[in] This  pointer to IPin interface * * \return S_OK - success * \return E_UNEXPECTED - The pin is output pin * */static HRESULT STDCALL COutputPin_EndFlush(IPin * This){    return S_OK;    //return output_unimplemented("COutputPin_EndFlush", This);}/** * \brief IPin::NewSegment (media sample received after this call grouped as segment with common *        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 * */static HRESULT STDCALL COutputPin_NewSegment(IPin * This,				       /* [in] */ REFERENCE_TIME tStart,				       /* [in] */ REFERENCE_TIME tStop,				       /* [in] */ double dRate){    Debug printf("COutputPin_NewSegment(%Ld,%Ld,%f) called\n",		 tStart, tStop, dRate);    return 0;}// IMemInputPin->IUnknown methods/** * \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 * */static HRESULT STDCALL COutputMemPin_QueryInterface(IUnknown* This, const GUID* iid, void** ppv){    COutputMemPin* p = (COutputMemPin*)This;    Debug printf("COutputMemPin_QueryInterface(%p) called\n", This);    if (!ppv)	return E_INVALIDARG;    if(!memcmp(iid, &IID_IUnknown, 16))    {	*ppv = p;	p->vt->AddRef(This);	return 0;    }    /*if(!memcmp(iid, &IID_IPin, 16))    {	COutputPin* ptr=(COutputPin*)(This-1);	*ppv=(void*)ptr;	AddRef((IUnknown*)ptr);	return 0;    }*/    if(!memcmp(iid, &IID_IMemInputPin, 16))    {	*ppv = p;	p->vt->AddRef(This);	return 0;    }    Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \		 "%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;}// IMemInputPin methods/** * \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 * */static HRESULT STDCALL COutputMemPin_GetAllocator(IMemInputPin* This,					 /* [out] */ IMemAllocator** ppAllocator){    Debug printf("COutputMemPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator);    *ppAllocator = (IMemAllocator*) MemAllocatorCreate();    return 0;}/** * * \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 * */static HRESULT STDCALL COutputMemPin_NotifyAllocator(IMemInputPin* This,						  /* [in] */ IMemAllocator* pAllocator,						  /* [in] */ int bReadOnly){    Debug printf("COutputMemPin_NotifyAllocator(%p, %p) called\n", This, pAllocator);    ((COutputMemPin*)This)->pAllocator = (MemAllocator*) pAllocator;    return 0;}/** * \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 * */static HRESULT STDCALL COutputMemPin_GetAllocatorRequirements(IMemInputPin* This,							   /* [out] */ ALLOCATOR_PROPERTIES* pProps){    return output_unimplemented("COutputMemPin_GetAllocatorRequirements", This);}/** * \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. * */static HRESULT STDCALL COutputMemPin_Receive(IMemInputPin* This,					  /* [in] */ IMediaSample* pSample){    Debug printf("COutputMemPin_Receive(%p) called\n", This);    if (!pSample)	return E_INVALIDARG;    if(((COutputMemPin*)This)->parent->SampleProc)        return ((COutputMemPin*)This)->parent->SampleProc(((COutputMemPin*)This)->parent->pUserData,pSample);    //reject sample    return S_FALSE;}/** * \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. * */static HRESULT STDCALL COutputMemPin_ReceiveMultiple(IMemInputPin * This,					    /* [size_is][in] */ IMediaSample **pSamples,					    /* [in] */ long nSamples,					    /* [out] */ long *nSamplesProcessed){    HRESULT hr = S_OK;    Debug printf("COutputMemPin_ReceiveMultiple(%p) %ld\n", This,nSamples);    for(*nSamplesProcessed=0; *nSamplesProcessed < nSamples; (*nSamplesProcessed)++) {         hr = This->vt->Receive(This,pSamples[*nSamplesProcessed]);         if (hr != S_OK) break;    }    return hr;}/** * \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 * */static HRESULT STDCALL COutputMemPin_ReceiveCanBlock(IMemInputPin * This){    return output_unimplemented("COutputMemPin_ReceiveCanBlock", This);}/** * \brief COutputPin::SetNewFormat(sets new media format for the pin) * * \param[in]  This pointer to COutputPin class * \param[in]  amt  new media format * */static void COutputPin_SetNewFormat(COutputPin* This, const AM_MEDIA_TYPE* amt){    CopyMediaType(&(This->type),amt);    This->restrict_media_type = 1;}/** * \brief COutputPin destructor * * \param[in]  This pointer to COutputPin class * */static void COutputPin_Destroy(COutputPin* This){    if (This->mempin->vt)	free(This->mempin->vt);    if (This->mempin)	free(This->mempin);    if (This->vt)	free(This->vt);    FreeMediaType(&(This->type));    free(This);}/** * \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 * */static HRESULT STDCALL COutputPin_AddRef(IUnknown* This){    Debug printf("COutputPin_AddRef(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);    ((COutputPin*)This)->refcount++;    return 0;}/** * \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 * */static HRESULT STDCALL COutputPin_Release(IUnknown* This){    Debug printf("COutputPin_Release(%p) called (%d)\n", This, ((COutputPin*)This)->refcount);    if (--((COutputPin*)This)->refcount <= 0)	COutputPin_Destroy((COutputPin*)This);    return 0;}/** * \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 * */static HRESULT STDCALL COutputMemPin_AddRef(IUnknown* This){    COutputMemPin* p = (COutputMemPin*) This;    Debug printf("COutputMemPin_AddRef(%p) called (%p, %d)\n", p, p->parent, p->parent->refcount);    p->parent->refcount++;    return 0;}/** * \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 * */static HRESULT STDCALL COutputMemPin_Release(IUnknown* This){    COutputMemPin* p = (COutputMemPin*) This;    Debug printf("COutputMemPin_Release(%p) called (%p,   %d)\n",		 p, p->parent, p->parent->refcount);    if (--p->parent->refcount <= 0)	COutputPin_Destroy(p->parent);    return 0;}/** * \brief COutputPin constructor * * \param[in]  amt media type for pin * * \return pointer to COutputPin if success * \return NULL if error occured * */COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt,SAMPLEPROC SampleProc,void* pUserData){    COutputPin* This = (COutputPin*) malloc(sizeof(COutputPin));    IMemInputPin_vt* ivt;    if (!This)        return NULL;    This->vt = (IPin_vt*) malloc(sizeof(IPin_vt));    This->mempin = (COutputMemPin*) malloc(sizeof(COutputMemPin));    ivt = (IMemInputPin_vt*) malloc(sizeof(IMemInputPin_vt));    if (!This->vt || !This->mempin || !ivt)    {        COutputPin_Destroy(This);	return NULL;    }    This->SampleProc=SampleProc;    This->pUserData=pUserData;    This->mempin->vt = ivt;    This->refcount = 1;    This->remote = 0;    This->restrict_media_type = 0;    CopyMediaType(&(This->type),amt);    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;    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;    This->mempin->frame_size_pointer = 0;    This->mempin->frame_pointer = 0;    This->mempin->pAllocator = 0;    This->mempin->refcount = 1;    This->mempin->parent = This;    This->SetNewFormat = COutputPin_SetNewFormat;    return This;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -