SetInputType返回错误代码c00d6d60

时间:2013-06-29 07:12:39

标签: c++ winapi ms-media-foundation

我正在尝试在我的项目中使用MediaFoundation杜比编码器。我能够初始化输出类型,但在设置输入tyep时它给了我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。有些人可以提供一些见解

1 个答案:

答案 0 :(得分:1)

0xC00D6D60 is MF_E_TRANSFORM_TYPE_NOT_SET“尚未为此流或其依赖的流设置有效类型。”

MSDN says,如果设置输入/输出媒体类型为时尚早,并且您需要从另一端配置转换,则会返回此错误代码。

如果是杜比数字音频编码器,真正的原因应该是编码器不可用:

  

重要根据杜比数字许可计划的条款,Microsoft实施的杜比数字技术受到限制,以供Microsoft应用程序使用。

如果您正在使用第三方转换(您没有显示实例化代码),则可能会应用其他条件或初始化序列。