Hello,
I am wanting to render out audio from a micraphone via an IMFSample in Media Foundation, I have spent days on trying to figure out how to do this, I have looked at the MSDN docs for media foundation and they are not that helpful.
Currently I am capturing the audio device with MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_ENDPOINT_ID then I am creating an IMFSourceReader via the IMFActivate of the capture object, I am reading the samples asynchronously in OnReadSample via the IMFSourceReaderCallback.
I then enumerate an audio output device via:
hr = pEnum->EnumAudioEndpoints(eRender, eMultimedia, &pDevices);
and create an audio renderer with the following:
hr = MFCreateAudioRenderer(pAttributes, &m_pAudioSink);
I never hear anything at the endpoint even though OnReadSample is generating data.
I also tried the following:
IMFActivate* pActivate = MadNull;
hr = MFCreateAudioRendererActivate( &pActivate );
hr = MFCreateTopology( &m_pTopology );
IMFPresentationDescriptor* pPresDesc = MadNull;
hr = m_pMediaSource->CreatePresentationDescriptor( &pPresDesc );
BOOL bSelected = FALSE;
IMFStreamDescriptor* pStreamDesc = MadNull;
hr = pPresDesc->GetStreamDescriptorByIndex( 0, &bSelected, &pStreamDesc );
IMFTopologyNode* pSourceNode = MadNull;
IMFTopologyNode* pOutputNode = MadNull;
hr = MFCreateTopologyNode( MF_TOPOLOGY_SOURCESTREAM_NODE, &pSourceNode );
hr = pSourceNode->SetUnknown( MF_TOPONODE_SOURCE, m_pMediaSource );
hr = pSourceNode->SetUnknown( MF_TOPONODE_PRESENTATION_DESCRIPTOR, pPresDesc );
hr = pSourceNode->SetUnknown( MF_TOPONODE_STREAM_DESCRIPTOR, pStreamDesc );
DWORD stream_id;
GUID major_type = GUID_NULL;
IMFMediaTypeHandler* pHdlr = MadNull;
hr = pStreamDesc->GetStreamIdentifier( &stream_id );
hr = pStreamDesc->GetMediaTypeHandler( &pHdlr );
hr = pHdlr->GetMajorType( &major_type );
hr = MFCreateTopologyNode( MF_TOPOLOGY_OUTPUT_NODE, &pOutputNode );
hr = pOutputNode->SetObject( pActivate );
hr = m_pTopology->AddNode( pSourceNode );
hr = m_pTopology->AddNode( pOutputNode );
hr = pSourceNode->ConnectOutput( 0, pOutputNode, 0 );
hr = pActivate->SetString( MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, wstrID );
if( SUCCEEDED( hr ) )
{
hr = MFCreateMediaSession( MadNull, &m_pSession );
hr = m_pSession->SetTopology( 0, m_pTopology );
hr = m_pSession->Start(&GUID_NULL, MadNull);
}
I still got nothing from that......
All I want to do is send the samples generated from the sourcereader to the audio output device.
Cheers