?? cmediasample.c
字號(hào):
/* * Modified for use with MPlayer, detailed changelog at * http://svn.mplayerhq.hu/mplayer/trunk/ * $Id$ */#include "config.h"#if (C_HAS_DIRECTSHOW)#include "cmediasample.h"#include "mediatype.h"#include "wine/winerror.h"/* * currently hack to make some extra room for DS Acel codec which * seems to overwrite allocated memory - FIXME better later * check the buffer allocation */static const int SAFETY_ACEL = 1024;/** * \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 * */static long STDCALL CMediaSample_QueryInterface(IUnknown* This, /* [in] */ const GUID* iid, /* [iid_is][out] */ void **ppv){ LOG_MSG("CMediaSample_QueryInterface(%p) called", This); if (!ppv) return E_INVALIDARG; if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0) { *ppv = (void*)This; ((IMediaSample*) This)->vt->AddRef(This); return 0; } if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0) { *ppv = (void*)This; ((IMediaSample*) This)->vt->AddRef(This); return 0; } return E_NOINTERFACE;}/** * \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 long STDCALL CMediaSample_AddRef(IUnknown* This){ LOG_MSG("CMediaSample_AddRef(%p) called", This); ((CMediaSample*)This)->refcount++; return 0;}/** * \brief CMediaSample destructor * * \param[in] This pointer to CMediaSample object * */void CMediaSample_Destroy(CMediaSample* This){ LOG_MSG("CMediaSample_Destroy(%p) called (ref:%d)", This, This->refcount); free(This->vt); free(This->own_block); FreeMediaType(&(This->media_type)); free(This);}/** * \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 long STDCALL CMediaSample_Release(IUnknown* This){ CMediaSample* parent = (CMediaSample*)This; LOG_MSG("CMediaSample_Release(%p) called (new ref:%d)", This, ((CMediaSample*)This)->refcount-1); if (--((CMediaSample*) This)->refcount == 0) { parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all), (IMediaSample*)This); } return 0;}/** * \brief IMediaSample::GetPointer (retrieves a read/write pointer to the media sample's buffer) * * \param[in] This pointer to CMediaSample object * \param[out] address of variable that receives pointer to sample's buffer * * \return S_OK success * \return apropriate error otherwise * * \note The calles should not free or reallocate buffer * */static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample* This, /* [out] */ BYTE** ppBuffer){ LOG_MSG("CMediaSample_GetPointer(%p) called -> %p, size: %d %d", This, ((CMediaSample*) This)->block, ((CMediaSample*)This)->actual_size, ((CMediaSample*)This)->size); if (!ppBuffer) return E_INVALIDARG; *ppBuffer = (BYTE*) ((CMediaSample*) This)->block; return 0;}/** * \brief IMediaSample::GetSize (retrieves a size of buffer in bytes) * * \param[in] This pointer to CMediaSample object * * \return size of buffer in bytes * */static long STDCALL CMediaSample_GetSize(IMediaSample * This){ CMediaSample* cs = (CMediaSample*) This; // this is a hack to prevent buffer overflows when custom buffer is used if((cs->block != cs->own_block) && (cs->actual_size)) { LOG_MSG("CMediaSample_GetSize(%p) called -> %d", This, ((CMediaSample*) This)->actual_size); return cs->actual_size; } LOG_MSG("CMediaSample_GetSize(%p) called -> %d", This, ((CMediaSample*) This)->size); return cs->size;}/** * \brief IMediaSample::GetTime (retrieves a stream time at wich sample sould start and finish) * * \param[in] This pointer to CMediaSample object * \param[out] pTimeStart pointer to variable that receives start time * \param[out] pTimeEnd pointer to variable that receives end time * * \return S_OK success * \return VFW_E_NO_STOP_TIME The sample has valid start time, but no stop time * \return VFW_E_SAMPLE_TIME_NOT_SET The sample is not time-stamped * * \remarks * Both values are relative to stream time * */static HRESULT STDCALL CMediaSample_GetTime(IMediaSample * This, /* [out] */ REFERENCE_TIME *pTimeStart, /* [out] */ REFERENCE_TIME *pTimeEnd){ if (pTimeStart) *pTimeStart = ((CMediaSample*) This)->time_start; if (pTimeEnd) *pTimeEnd = ((CMediaSample*) This)->time_end; LOG_MSG("CMediaSample_GetTime(%p) called (" LLD ") (" LLD ")", This, pTimeStart ? *pTimeStart : -1LL, pTimeEnd ? *pTimeEnd : -1LL); return 0;}/** * \brief IMediaSample::SetTime (sets a stream time at wich sample sould start and finish) * * \param[in] This pointer to CMediaSample object * \param[out] pTimeStart pointer to variable that contains start time * \param[out] pTimeEnd pointer to variable that contains end time * * \return S_OK success * \return apropriate error otherwise * * \remarks * Both values are relative to stream time * To invalidate the stream times set pTimeStart and pTimeEnd to NULL. this will cause * IMEdiaSample::GetTime to return VFW_E_SAMPLE_TIME_NOT_SET * */static HRESULT STDCALL CMediaSample_SetTime(IMediaSample * This, /* [in] */ REFERENCE_TIME *pTimeStart, /* [in] */ REFERENCE_TIME *pTimeEnd){ if (pTimeStart) ((CMediaSample*) This)->time_start = *pTimeStart; if (pTimeEnd) ((CMediaSample*) This)->time_end = *pTimeEnd; LOG_MSG("CMediaSample_SetTime(%p) called (" LLD ") (" LLD ")", This, pTimeStart ? *pTimeStart : -1LL, pTimeEnd ? *pTimeEnd : -1LL); return 0;}/** * \brief IMediaSample::IsSyncPoint (determines if start of this sample is sync point) * * \param[in] This pointer to CMediaSample object * * \return S_OK start of this sample is sync point * \return S_FALSE start of this sample is not sync point * * \remarks * If bTemporalCompression of AM_MEDIA_TYPE is FALSE, all samples are sync points. * */static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This){ LOG_MSG("CMediaSample_IsSyncPoint(%p) called", This); if (((CMediaSample*)This)->isSyncPoint) return 0; return 1;}/** * \brief IMediaSample::SetSyncPoint (specifies if start of this sample is sync point) * * \param[in] This pointer to CMediaSample object * \param[in] bIsSyncPoint specifies whether this is sync point or not * * \return S_OK success * \return apropriate error code otherwise * */static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This, long bIsSyncPoint){ LOG_MSG("CMediaSample_SetSyncPoint(%p) called", This); ((CMediaSample*)This)->isSyncPoint = bIsSyncPoint; return 0;}/** * \brief IMediaSample::IsPreroll (determines if this sample is preroll sample) * * \param[in] This pointer to CMediaSample object * * \return S_OK if this sample is preroll sample * \return S_FALSE if this sample is not preroll sample * * \remarks * Preroll samples are processed but not displayed. They are lokated in media stream * before displayable samples. * */static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This){ LOG_MSG("CMediaSample_IsPreroll(%p) called", This); if (((CMediaSample*)This)->isPreroll) return 0;//S_OK return 1;//S_FALSE}/** * \brief IMediaSample::SetPreroll (specifies if this sample is preroll sample) * * \param[in] This pointer to CMediaSample object * \param[in] bIsPreroll specifies whether this sample is preroll sample or not * * \return S_OK success * \return apropriate error code otherwise * * \remarks * Preroll samples are processed but not displayed. They are lokated in media stream * before displayable samples. * */static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This, long bIsPreroll){ LOG_MSG("CMediaSample_SetPreroll(%p) called", This); ((CMediaSample*)This)->isPreroll=bIsPreroll; return 0;}/** * \brief IMediaSample::GetActualDataLength (retrieves the length of valid data in the buffer)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -