2014-07-21 33 views
2

我想使用EVR獨立發送,但是我無法將IMFSample發送給它。代碼清單如下,如何將IMFSample發送到EVR媒體接收器

//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) ; 

然後我得到一個E_NOTIMPL錯誤。經過幾個小時的掙扎,我實現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) ; 

現在,每一件事情的偉大工程,但我只拿到了一個黑色的屏幕上繪製它沒有任何電影畫面!

此外,我增加了SAR到我的代碼,它工作得很好。

任何幫助,thx!

回答

0

也許有點晚回答你的問題,但無論如何... 我處於類似的情況,我用MF_SOURCE_READER_D3D_MANAGER配置的流讀取器解決了它。我從流接收器的IDirect3DDeviceManager9你拿了分配方式相同: HR = MFGetService(m_pVideoStreamSink,MR_VIDEO_ACCELERATION_SERVICE,IID_PPV_ARGS(& pD3DManager);

並將其設置爲的IUnknown到MF_SOURCE_READER_D3D_MANAGER上述屬性

如果你不能使用IMFSourceReader然後也許這個鏈接將有所幫助: https://code.google.com/p/webrtc4all/source/browse/trunk/gotham/MFT_WebRTC4All/test/test_evr.cc?r=15

相關問題