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 great, 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!
When the pVideoSample is allocated, it already has a buffer for your use; you don't need to add any other buffers. In your case, my guess is that the originally allocated buffer was used to render the output - which is this case is empty, and hence there's no image.
Maybe a little late to answer to your question, but anyway ... I was in a similar situation and I solved it by using a Stream Reader configured with MF_SOURCE_READER_D3D_MANAGER. I took the IDirect3DDeviceManager9 from the Stream Sink the same way you took the allocator: hr = MFGetService(m_pVideoStreamSink,MR_VIDEO_ACCELERATION_SERVICE,IID_PPV_ARGS(&pD3DManager);
and set it as IUnknown to MF_SOURCE_READER_D3D_MANAGER attribute above.
If you cannot use IMFSourceReader then maybe this link will be helpful: https://code.google.com/p/webrtc4all/source/browse/trunk/gotham/MFT_WebRTC4All/test/test_evr.cc?r=15