Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

How to send IMFSample to EVR Media Sink

$
0
0

Hi, I want to use EVR standalone, but i failed sending IMFSample to it. codes list  below,

 //create the video render 
IMFActivate* pActive = NULL;
hr = MFCreateVideoRendererActivate(m_hWnd, &pActive);
CHECK_HR(hr);
hr = pActive->ActivateObject(IID_IMFMediaSink,(void**)&m_pVideoSink) ;
CHECK_HR(hr);
hr = m_pVideoSink->GetStreamSinkByIndex(0,&m_pVideoStreamSink) ;
CHECK_HR(hr);

//on Sample ready from a custom mft
hr = m_pVideoStreamSink->ProcessSample(pSample) ;

then i got an E_NOTIMPL error. After several hours struggles, i implemented IMFVideoSampleAllocator:

//get IMFVideoSampleAllocator service hr = MFGetService(m_pVideoStreamSink,MR_VIDEO_ACCELERATION_SERVICE,IID_PPV_ARGS(&m_pAllocator)) ; CHECK_HR(hr); //init IMFVideoSampleAllocator,pType is the negotiated type hr = m_pAllocator->InitializeSampleAllocator(20,pType) ; //On sample ready,pSample is the IMFSample from mft IMFSample* pVideoSample = NULL ; IMFMediaBuffer* pBuffer = NULL ; LONGLONG hnsTimeStamp = 0 ;

//copy sample data from pSample to pVideoSample CHECK_HR(hr = m_pAllocator->AllocateSample(&pVideoSample)) ; CHECK_HR(hr = pSample->GetSampleTime(&hnsTimeStamp)) ; CHECK_HR(hr = pVideoSample->SetSampleTime(hnsTimeStamp)) ; CHECK_HR(hr = pSample->GetBufferByIndex(0,&pBuffer)) ; CHECK_HR(hr = pVideoSample->AddBuffer(pBuffer)) ; hr = m_pVideoStreamSink->ProcessSample(pVideoSample) ;


now, every thing works ok, but i got only a black screen with no any movie picture drawn on it!

besides, i had added SAR to my code, it worked pretty good.

any help, thx!




Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>