本文整理汇总了C++中FreeMediaType函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeMediaType函数的具体用法?C++ FreeMediaType怎么用?C++ FreeMediaType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeMediaType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IEnumMediaTypesImpl_Reset
static HRESULT WINAPI IEnumMediaTypesImpl_Reset(IEnumMediaTypes * iface)
{
ULONG i;
AM_MEDIA_TYPE amt;
IEnumMediaTypesImpl *This = impl_from_IEnumMediaTypes(iface);
TRACE("(%p)->()\n", iface);
for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
FreeMediaType(&This->enumMediaDetails.pMediaTypes[i]);
CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
i = 0;
while (This->enumMediaFunction(This->basePin, i, &amt) == S_OK) i++;
This->enumMediaDetails.cMediaTypes = i;
This->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * i);
for (i = 0; i < This->enumMediaDetails.cMediaTypes; i++)
{
This->enumMediaFunction(This->basePin, i,&amt);
if (FAILED(CopyMediaType(&This->enumMediaDetails.pMediaTypes[i], &amt)))
{
while (i--)
FreeMediaType(&This->enumMediaDetails.pMediaTypes[i]);
CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
return E_OUTOFMEMORY;
}
}
This->currentVersion = This->mediaVersionFunction(This->basePin);
This->uIndex = 0;
return S_OK;
}
示例2: ACMWrapper_SetMediaType
static HRESULT WINAPI ACMWrapper_SetMediaType(TransformFilter *tf, PIN_DIRECTION dir, const AM_MEDIA_TYPE * pmt)
{
ACMWrapperImpl* This = impl_from_TransformFilter(tf);
MMRESULT res;
TRACE("(%p)->(%i %p)\n", This, dir, pmt);
if (dir != PINDIR_INPUT)
return S_OK;
/* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio)) &&
(!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Audio)+4, sizeof(GUID)-4)) &&
(IsEqualIID(&pmt->formattype, &FORMAT_WaveFormatEx)))
{
HACMSTREAM drv;
WAVEFORMATEX *wfx = (WAVEFORMATEX*)pmt->pbFormat;
AM_MEDIA_TYPE* outpmt = &This->tf.pmt;
if (!wfx || wfx->wFormatTag == WAVE_FORMAT_PCM || wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
return VFW_E_TYPE_NOT_ACCEPTED;
FreeMediaType(outpmt);
This->pWfIn = (LPWAVEFORMATEX)pmt->pbFormat;
/* HACK */
/* TRACE("ALIGN = %d\n", pACMWrapper->pWfIn->nBlockAlign); */
/* pACMWrapper->pWfIn->nBlockAlign = 1; */
/* Set output audio data to PCM */
CopyMediaType(outpmt, pmt);
outpmt->subtype.Data1 = WAVE_FORMAT_PCM;
This->pWfOut = (WAVEFORMATEX*)outpmt->pbFormat;
This->pWfOut->wFormatTag = WAVE_FORMAT_PCM;
This->pWfOut->wBitsPerSample = 16;
This->pWfOut->nBlockAlign = This->pWfOut->wBitsPerSample * This->pWfOut->nChannels / 8;
This->pWfOut->cbSize = 0;
This->pWfOut->nAvgBytesPerSec = This->pWfOut->nChannels * This->pWfOut->nSamplesPerSec
* (This->pWfOut->wBitsPerSample/8);
if (!(res = acmStreamOpen(&drv, NULL, This->pWfIn, This->pWfOut, NULL, 0, 0, 0)))
{
This->has = drv;
TRACE("Connection accepted\n");
return S_OK;
}
else
FIXME("acmStreamOpen returned %d\n", res);
FreeMediaType(outpmt);
TRACE("Unable to find a suitable ACM decompressor\n");
}
TRACE("Connection refused\n");
return VFW_E_TYPE_NOT_ACCEPTED;
}
示例3: msg_Dbg
CapturePin::~CapturePin()
{
#ifdef DEBUG_DSHOW
msg_Dbg( p_input, "CapturePin::~CapturePin" );
#endif
for( size_t c=0; c<media_type_count; c++ )
{
FreeMediaType(media_types[c]);
}
FreeMediaType(cx_media_type);
}
示例4: ATLTRACE
SampleCapturePin::~SampleCapturePin()
{
#ifdef DEBUG_DSHOW
ATLTRACE( "SampleCapturePin::~SampleCapturePin" );
#endif
for( size_t c=0; c<media_type_count; c++ )
{
FreeMediaType(media_types[c]);
}
free(media_types);
media_types = NULL;
FreeMediaType(cx_media_type);
DeleteCriticalSection(&m_mylock);
}
示例5: GetFrameSize
HRESULT __fastcall GetFrameSize(IPin* pPin, LONG* plWidth, LONG* plHeight)
{
HRESULT hr;
if(!pPin || !plWidth || !plHeight)
return E_POINTER;
*plWidth = *plHeight = 0;
AM_MEDIA_TYPE mt;
hr = pPin->ConnectionMediaType(&mt);
if(SUCCEEDED(hr))
{
if(FORMAT_VideoInfo==mt.formattype)
{
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(mt.pbFormat);
if(pVih)
{
*plWidth = pVih->bmiHeader.biWidth;
*plHeight = pVih->bmiHeader.biHeight;
}
}
else
{
hr = VFW_E_UNSUPPORTED_STREAM;
}
FreeMediaType(mt);
}
return hr;
}
示例6: _T
void CTextInfoForm::DoPinDetails(GraphStudio::Pin *pin, int level, int offset)
{
CString ofs, t, f;
for (int i=0; i<offset; i++) ofs += _T(" ");
AM_MEDIA_TYPE mt;
HRESULT hr = pin->pin->ConnectionMediaType(&mt);
if (SUCCEEDED(hr)) {
GraphStudio::NameGuid(mt.majortype, f);
t = _T("Major: ") + f; Echo(ofs+t);
GraphStudio::NameGuid(mt.subtype, f);
t = _T("Subtype: ") + f; Echo(ofs+t);
// parse one level deeper
if (level > 1) {
DoMediaTypeDetails(&mt, level, offset+4);
}
GraphStudio::NameGuid(mt.formattype, f);
t = _T("Format: ") + f; Echo(ofs+t);
if (level > 2) {
// parse format
if (mt.formattype == FORMAT_WaveFormatEx) DoWaveFormatEx(&mt, level, offset); else
if (mt.formattype == FORMAT_VideoInfo2) DoVideoInfo2(&mt, level, offset); else
if (mt.formattype == FORMAT_VideoInfo) DoVideoInfo(&mt, level, offset); else
if (mt.formattype == FORMAT_MPEG2_VIDEO) DoMPEG2VideoInfo(&mt, level, offset);
}
Echo(_T(""));
FreeMediaType(mt);
}
}
示例7: InitCaptureGraphBuilder
HRESULT CCaptureVideo::Open(int iDeviceID,int iPress)
{
HRESULT hr;
hr = InitCaptureGraphBuilder();
if (FAILED(hr)){
return hr;
}
// Bind Device Filter. We know the device because the id was passed in
if(!BindVideoFilter(iDeviceID, &m_pBF))
return S_FALSE;
hr = m_pGB->AddFilter(m_pBF, L"Capture Filter");
// create a sample grabber
hr = CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_ISampleGrabber, (void**)&m_pGrabber );
if(FAILED(hr)){
return hr;
}
CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );//设置视频格式
AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
mt.subtype = MEDIASUBTYPE_RGB24; // MEDIASUBTYPE_RGB24 ;
hr = m_pGrabber->SetMediaType(&mt);
if( FAILED( hr ) ){
return hr;
}
hr = m_pGB->AddFilter( pGrabBase, L"Grabber" );
if( FAILED( hr ) ){
return hr;
}// try to render preview/capture pin
hr = m_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
if( FAILED( hr ) )
hr = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
if( FAILED( hr ) ){
return hr;
}
hr = m_pGrabber->GetConnectedMediaType( &mt );
if ( FAILED( hr) ){
return hr;
}VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
mCB.lWidth = vih->bmiHeader.biWidth;
mCB.lHeight = vih->bmiHeader.biHeight;
mCB.bGrabVideo = FALSE ;
//mCB.frame_handler = NULL ;
FreeMediaType(mt);
hr = m_pGrabber->SetBufferSamples( FALSE );
hr = m_pGrabber->SetOneShot( FALSE );
//设置视频捕获回调函数 也就是如果有视频数据时就会调用这个类的BufferCB函数
//返回OnTimer
hr = m_pGrabber->SetCallback( &mCB, 1 );
//设置视频捕捉窗口
m_hWnd = CreateWindow("#32770", /* Dialog */ "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
SetupVideoWindow();
hr = m_pMC->Run();//开始视频捕捉
if(FAILED(hr)){
//AfxMessageBox("Couldn’t run the graph!");return hr;
}
return S_OK;
}
示例8: FreeMediaType
HRESULT VideoCapture::GetMediaType()
{
AM_MEDIA_TYPE mt;
HRESULT hr = m_pGrabber->GetConnectedMediaType(&mt);
if (FAILED(hr)) {
FreeMediaType(mt);
return hr;
}
memcpy(&m_BmiHeader, &((VIDEOINFOHEADER *)mt.pbFormat)->bmiHeader, sizeof(BITMAPINFOHEADER));
if (m_pFrameData != 0) delete[] m_pFrameData;
m_pFrameData = new BYTE[m_BmiHeader.biSizeImage];
FreeMediaType(mt);
return hr;
}
示例9: DSoundRender_PrepareReceive
static HRESULT WINAPI DSoundRender_PrepareReceive(BaseRenderer *iface, IMediaSample *pSample)
{
DSoundRenderImpl *This = impl_from_BaseRenderer(iface);
HRESULT hr;
AM_MEDIA_TYPE *amt;
if (IMediaSample_GetMediaType(pSample, &amt) == S_OK)
{
AM_MEDIA_TYPE *orig = &This->renderer.pInputPin->pin.mtCurrent;
WAVEFORMATEX *origfmt = (WAVEFORMATEX *)orig->pbFormat;
WAVEFORMATEX *newfmt = (WAVEFORMATEX *)amt->pbFormat;
if (origfmt->wFormatTag == newfmt->wFormatTag &&
origfmt->nChannels == newfmt->nChannels &&
origfmt->nBlockAlign == newfmt->nBlockAlign &&
origfmt->wBitsPerSample == newfmt->wBitsPerSample &&
origfmt->cbSize == newfmt->cbSize)
{
if (origfmt->nSamplesPerSec != newfmt->nSamplesPerSec)
{
hr = IDirectSoundBuffer_SetFrequency(This->dsbuffer,
newfmt->nSamplesPerSec);
if (FAILED(hr))
return VFW_E_TYPE_NOT_ACCEPTED;
FreeMediaType(orig);
CopyMediaType(orig, amt);
IMediaSample_SetMediaType(pSample, NULL);
}
}
else
return VFW_E_TYPE_NOT_ACCEPTED;
}
return S_OK;
}
示例10: CoTaskMemAlloc
bool Misc::SetStreamConfigData(AM_MEDIA_TYPE *pMT,
BYTE *pMediaHex, int inMediaSize,
BYTE *pVideoHeaderHex, int inVideoHeaderSize)
{
int mediaSize = inMediaSize / 2;
int videoHeaderSize = inVideoHeaderSize / 2;
if (mediaSize != sizeof AM_MEDIA_TYPE)
return false;
LPVOID pNewVideoHeader = NULL;
if (videoHeaderSize > 0)
{
pNewVideoHeader = CoTaskMemAlloc(videoHeaderSize);
if (pNewVideoHeader)
{
Make8Bit((char *) pVideoHeaderHex, (char *) pNewVideoHeader, inVideoHeaderSize);
}
else
return false;
}
// Release any previously allocated format tag
FreeMediaType(*pMT);
Make8Bit((char *) pMediaHex, (char *) pMT, inMediaSize);
pMT->pbFormat = (BYTE *) pNewVideoHeader; // may be NULL under certain circumstances
return true;
}
示例11: Parser_OutputPin_Release
static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
{
Parser_OutputPin *This = (Parser_OutputPin *)iface;
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
if (!refCount)
{
FreeMediaType(This->pmt);
CoTaskMemFree(This->pmt);
FreeMediaType(&This->pin.pin.mtCurrent);
CoTaskMemFree(This);
return 0;
}
return refCount;
}
示例12: COutputPin_Destroy
/**
* \brief COutputPin destructor
*
* \param[in] This pointer to COutputPin class
*
*/
static void COutputPin_Destroy(COutputPin* This)
{
free(This->mempin->vt);
free(This->mempin);
free(This->vt);
FreeMediaType(&(This->type));
free(This);
}
示例13: Clear
inline void Clear()
{
if (ptr) {
FreeMediaType(*ptr);
CoTaskMemFree(ptr);
ptr = nullptr;
}
}
示例14: DeleteMediaType
void DeleteMediaType(AM_MEDIA_TYPE *pmt)
{
if (pmt)
{
FreeMediaType(*pmt);
CoTaskMemFree(pmt);
}
}
示例15: CheckPointer
HRESULT RtspSourcePin::GetMediaType(CMediaType* pMediaType)
{
// We only support one MediaType - the one that is streamed
CheckPointer(pMediaType, E_POINTER);
CAutoLock cAutoLock(m_pFilter->pStateLock());
FreeMediaType(*pMediaType);
return CopyMediaType(pMediaType, &_mediaType);
}