我正在尝试在我的项目中使用 MediaFoundation 杜比编码器。我能够初始化输出类型,但是在设置输入类型时它给了我 c00d6d60 错误代码
IMFMediaType* pInputMediaType = NULL;
IMFMediaType *pOutputType = NULL;
if (!m_pMFT)
{
return MF_E_NOT_INITIALIZED;
}
HRESULT hr = S_OK;
DWORD pcInputStreams = 0;
DWORD pcOutputStreams = 0;
CHECK_HR(m_pMFT->GetStreamCount(&pcInputStreams,&pcOutputStreams));
assert(pcInputStreams==1 && pcInputStreams == pcOutputStreams);
hr = m_pMFT->GetStreamIDs(1, &m_dwInputID, 1, &m_dwOutputID);
if (hr == E_NOTIMPL)
{
// The stream identifiers are zero-based.
m_dwInputID = 0;
m_dwOutputID = 0;
hr = S_OK;
}
else if (FAILED(hr))
{
goto done;
}
SafeRelease(&m_pOutputType);
CHECK_HR( MFCreateMediaType( &pOutputType ) );
CHECK_HR( pOutputType->SetGUID( MF_MT_MAJOR_TYPE, MFMediaType_Audio ) );
CHECK_HR( pOutputType->SetGUID( MF_MT_SUBTYPE, MFAudioFormat_Dolby_AC3 ) );
CHECK_HR( pOutputType->SetUINT32( MF_MT_AUDIO_SAMPLES_PER_SECOND, inSamplePerSec ) );
CHECK_HR( pOutputType->SetUINT32( MF_MT_AUDIO_AVG_BYTES_PER_SECOND, inOutputAvgBytesPerSec ) );
CHECK_HR( pOutputType->SetUINT32( MF_MT_AUDIO_NUM_CHANNELS, inNumChannels ) );
LogMediaType(pOutputType);
hr = m_pMFT->SetOutputType(m_dwOutputID, pOutputType, 0);
if (SUCCEEDED(hr))
{
m_pOutputType = pOutputType;
m_pOutputType->AddRef();
}
CHECK_HR( MFCreateMediaType( &pInputMediaType ) );
CHECK_HR( pInputMediaType->SetGUID( MF_MT_MAJOR_TYPE, MFMediaType_Audio ) );
CHECK_HR( pInputMediaType->SetGUID( MF_MT_SUBTYPE, MFAudioFormat_PCM ) );
CHECK_HR( pInputMediaType->SetUINT32( MF_MT_AUDIO_BITS_PER_SAMPLE, 16 ) );
CHECK_HR( pInputMediaType->SetUINT32( MF_MT_AUDIO_SAMPLES_PER_SECOND, inSamplePerSec ) );
CHECK_HR( pInputMediaType->SetUINT32( MF_MT_AUDIO_NUM_CHANNELS, inNumChannels ) );
//CHECK_HR( spMFTypeIn->SetUINT32( MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1 ) );
CHECK_HR( pInputMediaType->SetUINT32( MF_MT_AUDIO_BLOCK_ALIGNMENT, inNumChannels*2 ) );
CHECK_HR( pInputMediaType->SetUINT32( MF_MT_AUDIO_AVG_BYTES_PER_SECOND, inNumChannels*2*inSamplePerSec) );
LogMediaType(pInputMediaType);
if (FAILED(hr))
{
goto done;
}
hr = m_pMFT->SetInputType(m_dwInputID, pInputMediaType, 0);
我使用的指南是http://msdn.microsoft.com/en-us/library/windows/desktop/hh447682%28v=vs.85%29.aspx。可以请提供一些见解