MFTranscodeGetAudioOutputAvailableTypes 함수(mfidl.h)

오디오 인코더에서 출력 형식 목록을 가져옵니다.

구문

HRESULT MFTranscodeGetAudioOutputAvailableTypes(
  [in]  REFGUID       guidSubType,
  [in]  DWORD         dwMFTFlags,
  [in]  IMFAttributes *pCodecConfig,
  [out] IMFCollection **ppAvailableTypes
);

매개 변수

[in] guidSubType

출력 미디어의 하위 형식을 지정합니다. 인코더는 사용 가능한 출력 형식을 열거할 때 이 값을 필터로 사용합니다. 오디오 하위 형식에 대한 자세한 내용은 오디오 하위 유형 GUID를 참조하세요.

[in] dwMFTFlags

_MFT_ENUM_FLAG 열거형에서 0개 이상의 플래그의 비트 OR입니다.

[in] pCodecConfig

특성 저장소의 IMFAttributes 인터페이스에 대한 포인터입니다. 특성 저장소는 인코더 구성 설정을 지정합니다. 이 매개 변수는 NULL일 수 있습니다. 특성 저장소는 다음 특성 중 어느 것을 보유할 수 있습니다.

의미
MFT_FIELDOFUSE_UNLOCK_Attribute
사용 필드 설명이 있는 인코더의 잠금을 해제하려면 이 특성을 설정합니다.
MF_TRANSCODE_ENCODINGPROFILE
Windows Media 인코더에 대한 디바이스 규칙 프로필을 지정합니다.
MF_TRANSCODE_QUALITYVSSPEED
인코딩 품질과 인코딩 속도 간의 절충을 설정합니다.

[out] ppAvailableTypes

기본 설정 오디오 미디어 형식 목록이 포함된 컬렉션 개체의 IMFCollection 인터페이스에 대한 포인터를 받습니다. 컬렉션에는 IMFMediaType 포인터가 포함되어 있습니다. 호출자는 인터페이스 포인터를 해제해야 합니다.

반환 값

함수는 HRESULT를 반환합니다. 가능한 값에는 다음 표에 있는 값이 포함되지만, 이에 국한되는 것은 아닙니다.

반환 코드 Description
S_OK
함수 호출이 성공했습니다.
MF_E_TRANSCODE_NO_MATCHING_ENCODER
지정된 구성 설정과 일치하는 인코더를 찾지 못했습니다.

설명

이 함수는 인코더가 일반적으로 CBR(상수 비트 전송률) 인코딩인 기본 인코딩 모드에서 사용된다고 가정합니다. 따라서 함수에서 반환된 형식은 VBR(가변 비트 비율) 인코딩과 같은 다른 모드에서 작동하지 않을 수 있습니다.

내부적으로 이 함수는 MFTEnumEx 를 호출하여 일치하는 인코더를 찾은 다음 IMFTransform::GetOutputAvailableType 을 호출하여 인코더의 출력 형식을 가져옵니다.

예제

다음 예제에서는 WMA(Windows Media Audio)에 대한 코드 변환 프로필을 만듭니다.

template <class Q>
HRESULT GetCollectionObject(IMFCollection *pCollection, DWORD index, Q **ppObj)
{
    IUnknown *pUnk;
    HRESULT hr = pCollection->GetElement(index, &pUnk);
    if (SUCCEEDED(hr))
    {
        hr = pUnk->QueryInterface(IID_PPV_ARGS(ppObj));
        pUnk->Release();
    }
    return hr;
}

HRESULT CreateTranscodeProfile(IMFTranscodeProfile **ppProfile)
{
    IMFTranscodeProfile *pProfile = NULL;     // Transcode profile.
    IMFCollection   *pAvailableTypes = NULL;  // List of audio media types.
    IMFMediaType    *pAudioType = NULL;       // Audio media type.
    IMFAttributes   *pAudioAttrs = NULL;      // Copy of the audio media type.
    IMFAttributes   *pContainer = NULL;       // Container attributes.

    DWORD dwMTCount = 0;
    
    // Create an empty transcode profile.
    HRESULT hr = MFCreateTranscodeProfile(&pProfile);
    if (FAILED(hr))
    {
        goto done;
    }

    // Get output media types for the Windows Media audio encoder.

    // Enumerate all codecs except for codecs with field-of-use restrictions.
    // Sort the results.

    DWORD dwFlags = 
        (MFT_ENUM_FLAG_ALL & (~MFT_ENUM_FLAG_FIELDOFUSE)) | 
        MFT_ENUM_FLAG_SORTANDFILTER;

    hr = MFTranscodeGetAudioOutputAvailableTypes(MFAudioFormat_WMAudioV9, 
        dwFlags, NULL, &pAvailableTypes);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAvailableTypes->GetElementCount(&dwMTCount);
    if (FAILED(hr))
    {
        goto done;
    }
    if (dwMTCount == 0)
    {
        hr = E_FAIL;
        goto done;
    }

    // Get the first audio type in the collection and make a copy.
    hr = GetCollectionObject(pAvailableTypes, 0, &pAudioType);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = MFCreateAttributes(&pAudioAttrs, 0);       
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pAudioType->CopyAllItems(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the audio attributes on the profile.
    hr = pProfile->SetAudioAttributes(pAudioAttrs);
    if (FAILED(hr))
    {
        goto done;
    }

    // Set the container attributes.
    hr = MFCreateAttributes(&pContainer, 1);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pContainer->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_ASF);
    if (FAILED(hr))
    {
        goto done;
    }

    hr = pProfile->SetContainerAttributes(pContainer);
    if (FAILED(hr))
    {
        goto done;
    }

    *ppProfile = pProfile;
    (*ppProfile)->AddRef();

done:
    SafeRelease(&pProfile);
    SafeRelease(&pAvailableTypes);
    SafeRelease(&pAudioType);
    SafeRelease(&pAudioAttrs);
    SafeRelease(&pContainer);
    return hr;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 mfidl.h
라이브러리 Mf.lib
DLL Mf.dll

추가 정보

IMFCollection::GetElement

MFCreateTranscodeProfile

미디어 파운데이션 함수

자습서: WMA 파일 인코딩