0

我正在尝试在我的项目中使用 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。可以请提供一些见解

4

1 回答 1

1

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

MSDN当设置输入/输出媒体类型为时过早并且您需要从另一端配置转换时返回此错误代码。

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

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

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

于 2013-06-29T07:39:14.977 回答